- Revoking a server's tools takes them from every level beneath too, and a level left naming no tool stays closed ([]) while any level above or beneath names tools: an organization's revoke left its teams the copies their first grants took, and going back to no list opened the level to what was above it. A closed level is shown on the page and in the console with an action to open it (store.OpenTools). A key's owner's list is among the levels above a key. - The flag check matches short flags as written again (-m, -hf, -mu were let through), takes a long flag's beginning for it only for the engines that parse with argparse (vLLM, SGLang, ComfyUI: --li is --listen), so llama.cpp's own --chat-template is not refused, and refuses llama.cpp's short spellings (-hfr, -hff, -mm, -jf, …). - A stored model with an adapter by Hugging Face id can be changed again: what it already had is not asked about anew. - The catalog reads a Hugging Face id as the agent does (engines.IsHubID). - The page's form cannot move llmgw:admin to another address. - server init skips the memory check only where the gateway already runs, not wherever a half-finished first run left server.yaml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ecf5545a7a
commit
1948a787ae
15 files changed
+322
-44
No files matched your search
@@ -57,10 +57,12 @@ WantedBy=multi-user.target
|
||||
// it again finishes an install that stopped halfway and changes nothing on
|
||||
// one that did not.
|
||||
type serverInit struct {
|
||||
etcDir string // /etc/llmgw
|
||||
stateDir string // /var/lib/llmgw
|
||||
pkiDir string // where the authority lives
|
||||
unitPath string // "" leaves systemd alone
|
||||
// serviceActive says whether llmgw-server runs; nil asks systemctl.
|
||||
serviceActive func() bool
|
||||
etcDir string // /etc/llmgw
|
||||
stateDir string // /var/lib/llmgw
|
||||
pkiDir string // where the authority lives
|
||||
unitPath string // "" leaves systemd alone
|
||||
|
||||
// user owns the state and reads the key; "" means no user is created and
|
||||
// nothing is chowned, which is what a test wants.
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"math"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"slices"
|
||||
"strconv"
|
||||
@@ -195,9 +196,10 @@ func (in *serverInit) checkMemory() error {
|
||||
if in.unitPath == "" {
|
||||
return nil // a development run, served by nothing
|
||||
}
|
||||
// Run again on a machine already set up — to change --host, say, as
|
||||
// the docs advise — it installs no models it does not already serve.
|
||||
if _, err := os.Stat(in.configPath()); err == nil {
|
||||
// Run again on a machine already serving — to change --host, say, as
|
||||
// the docs advise — it installs no models it does not already serve. A
|
||||
// first run that stopped half way is checked again: it still would.
|
||||
if in.alreadyServing() {
|
||||
return nil
|
||||
}
|
||||
meminfo, err := os.ReadFile("/proc/meminfo")
|
||||
@@ -478,3 +480,15 @@ func shellWord(s string) string {
|
||||
}
|
||||
return "'" + strings.ReplaceAll(s, "'", `'\''`) + "'"
|
||||
}
|
||||
|
||||
// alreadyServing reports whether this machine's gateway is set up and
|
||||
// running: a server.yaml, and its unit active.
|
||||
func (in *serverInit) alreadyServing() bool {
|
||||
if _, err := os.Stat(in.configPath()); err != nil {
|
||||
return false
|
||||
}
|
||||
if in.serviceActive != nil {
|
||||
return in.serviceActive()
|
||||
}
|
||||
return exec.Command("systemctl", "is-active", "--quiet", "llmgw-server").Run() == nil
|
||||
}
|
||||
@@ -39,8 +39,14 @@ func TestSetupRunAgainOnAMachineAlreadySetUpIsNotRefusedItsMemory(t *testing.T)
|
||||
if err := os.WriteFile(cfg, []byte("listen: :8080\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
in := &serverInit{unitPath: dir + "/llmgw-server.service", etcDir: dir}
|
||||
in := &serverInit{unitPath: dir + "/llmgw-server.service", etcDir: dir, serviceActive: func() bool { return true }}
|
||||
if err := in.checkMemory(); err != nil {
|
||||
t.Errorf("refused: %v", err)
|
||||
}
|
||||
// A first run that stopped half way left server.yaml and serves nothing:
|
||||
// it still would install the models, and is checked.
|
||||
in.serviceActive = func() bool { return false }
|
||||
if in.alreadyServing() {
|
||||
t.Error("a machine whose gateway is not running was taken for one serving")
|
||||
}
|
||||
}
|
||||
+48
-3
@@ -115,6 +115,17 @@ func (s *consoleMCPMsg) name(scope store.Scope, id, label string) {
|
||||
}
|
||||
}
|
||||
|
||||
// closed are the levels whose list names no tool at all.
|
||||
func (k mcpState) closed() []mcpGrant {
|
||||
var out []mcpGrant
|
||||
for _, g := range k.grants {
|
||||
if len(g.tools) == 0 {
|
||||
out = append(out, g)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// mcpGrantsOf is who may use a server's tools, and which of them.
|
||||
func (k mcpState) grantsOf(server string) []mcpGrant {
|
||||
var out []mcpGrant
|
||||
@@ -176,7 +187,16 @@ func (m consoleModel) mcpPanel(pw int) (string, string, string) {
|
||||
rows = append(rows, []string{s.Name, state, granted, rate, dash(strings.Join(mcpCredentials(s), ", ")), s.URL})
|
||||
}
|
||||
b.WriteString(table([]string{"SERVER", "STATE", "GRANTED TO", "RATE", "SENT", "ADDRESS"}, rows, m.row, pw, m.inPanel))
|
||||
b.WriteString("\n\n " + sDim.Render("A server's tools are seen only where they are granted; nothing is granted by default.") + "\n\n")
|
||||
b.WriteString("\n\n " + sDim.Render("A server's tools are seen only where they are granted; nothing is granted by default.") + "\n")
|
||||
if closed := k.closed(); len(closed) > 0 {
|
||||
var names []string
|
||||
for _, g := range closed {
|
||||
names = append(names, g.label)
|
||||
}
|
||||
b.WriteString(" " + sBad.Render("Closed to every tool: ") + strings.Join(names, ", ") +
|
||||
sDim.Render(" (a server's menu opens them)") + "\n")
|
||||
}
|
||||
b.WriteString("\n")
|
||||
b.WriteString(mcpClientHint())
|
||||
return "MCP servers", b.String(), keys
|
||||
}
|
||||
@@ -290,12 +310,20 @@ func (m consoleModel) mcpMenu(s adminapi.MCPServerView) *menuDialog {
|
||||
items = append(items, menuItem{"Revoke from " + g.label + " (" + strings.Join(g.tools, ", ") + ")…",
|
||||
func(m *consoleModel) tea.Cmd {
|
||||
m.confirmD = &confirmDialog{title: "Revoke " + s.Name + " from " + g.label,
|
||||
text: "It then sees " + strings.Join(g.tools, ", ") + " only if the levels above grant them\n" +
|
||||
"and it names no tools of its own. Its other grants stay.",
|
||||
text: "Taken from it and from everything beneath it. Its other grants stay; left naming\n" +
|
||||
"no tool, it is closed rather than opened to what the levels above allow.",
|
||||
yes: func(m *consoleModel) tea.Cmd { return m.mcpSetTools(s.Name, g.owner, nil) }}
|
||||
return nil
|
||||
}})
|
||||
}
|
||||
for _, g := range m.mcp.closed() {
|
||||
items = append(items, menuItem{"Open " + g.label + ", closed to every tool…", func(m *consoleModel) tea.Cmd {
|
||||
m.confirmD = &confirmDialog{title: "Open " + g.label,
|
||||
text: "It then names no tools of its own and sees what the levels above it allow.",
|
||||
yes: func(m *consoleModel) tea.Cmd { return m.mcpOpen(g.owner) }}
|
||||
return nil
|
||||
}})
|
||||
}
|
||||
items = append(items,
|
||||
menuItem{"Change…", func(m *consoleModel) tea.Cmd { m.mcpEditForm(s); return nil }},
|
||||
menuItem{"Replace its credential…", func(m *consoleModel) tea.Cmd { m.mcpCredentialForm(s); return nil }},
|
||||
@@ -487,3 +515,20 @@ func (m *consoleModel) mcpSetTools(server string, owner store.LimitOwner, tools
|
||||
return actionDoneMsg{title: title, text: text}
|
||||
}
|
||||
}
|
||||
|
||||
// mcpOpen has a closed level name no tools of its own (store.OpenTools).
|
||||
func (m *consoleModel) mcpOpen(owner store.LimitOwner) tea.Cmd {
|
||||
h := m.st
|
||||
return func() tea.Msg {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
s, err := h.get(ctx)
|
||||
if err == nil {
|
||||
err = s.OpenTools(ctx, owner.Scope, owner.ID)
|
||||
}
|
||||
if err != nil {
|
||||
return actionDoneMsg{title: "Open", err: err}
|
||||
}
|
||||
return actionDoneMsg{title: "Open", text: "Opened: it names no tools of its own now."}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user