bots-garden/mini-mepublic Fork
⑂ 55c8f33
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

Merge feature/razorbill-provider into main

agent committed 2026-11-26T09:29:35+01:00 Browse files
55c8f33 parents: de8579a 4eaf659
added .tickets/issues/0264-razorbill-provider-with-autostart.yaml +89 -0
new file mode 100644
@@ -0,0 +1,89 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 264
3+title: "razorbill provider (rzb, MLX on the Mac) with razorbill.autoStart"
4+state: closed
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-26T08:00:00.000Z
9+updatedAt: 2026-11-26T11:00:00.000Z
10+closedAt: 2026-11-26T11:00:00.000Z
11+labels:
12+ - enhancement
13+ - kind::feature
14+milestone: v2.1.1
15+related:
16+ - 223
17+ - 252
18+body: |
19+ Asked by the user (2026-11-26): add razorbill (the user's MLX model
20+ server for the Mac, command `rzb`, OpenAI API on 127.0.0.1:7920) as a
21+ provider, with an autoStart mode like llamacpp's. macOS only.
22+
23+ ## What it does
24+ - Provider `razorbill`: base http://127.0.0.1:7920/v1, fallback
25+ host.docker.internal:7920, key RZB_API_KEY, reasoning off through
26+ chat_template_kwargs.enable_thinking (it wins over reasoning_effort),
27+ probe on /v1/models (warning when the model is not in the cache).
28+ - `razorbill: {autoStart, server, config, serverArgs, startTimeout}`:
29+ mm starts `rzb serve` when nothing answers at a loopback address,
30+ pulls the model with `rzb models pull` when it is missing, and stops
31+ the server with the last mm session using it. Never a server mm did
32+ not start. Only when mm runs on the Mac itself — not in a sandbox or
33+ a container.
34+ - The lease registry of internal/llamastart is shared (one package for
35+ both servers).
36+
37+ ## Acceptance criteria
38+ - Tests; `mm init` knows the provider and asks autostart; docs EN+FR.
39+tasks:
40+ - id: 1
41+ title: Provider entry and probe
42+ state: closed
43+ priority: high
44+ author:
45+ name: k33g
46+ email: ph.charriere@gmail.com
47+ createdAt: 2026-11-26T08:00:00.000Z
48+ updatedAt: 2026-11-26T10:00:00.000Z
49+ closedAt: 2026-11-26T10:00:00.000Z
50+ - id: 2
51+ title: Shared server lifecycle (registry, leases, lock) out of llamastart
52+ state: closed
53+ priority: high
54+ author:
55+ name: k33g
56+ email: ph.charriere@gmail.com
57+ createdAt: 2026-11-26T08:00:00.000Z
58+ updatedAt: 2026-11-26T10:00:00.000Z
59+ closedAt: 2026-11-26T10:00:00.000Z
60+ - id: 3
61+ title: razorbill config block and autoStart (rzb serve, rzb models pull)
62+ state: closed
63+ priority: high
64+ author:
65+ name: k33g
66+ email: ph.charriere@gmail.com
67+ createdAt: 2026-11-26T08:00:00.000Z
68+ updatedAt: 2026-11-26T10:00:00.000Z
69+ closedAt: 2026-11-26T10:00:00.000Z
70+ - id: 4
71+ title: mm init
72+ state: closed
73+ priority: medium
74+ author:
75+ name: k33g
76+ email: ph.charriere@gmail.com
77+ createdAt: 2026-11-26T08:00:00.000Z
78+ updatedAt: 2026-11-26T10:00:00.000Z
79+ closedAt: 2026-11-26T10:00:00.000Z
80+ - id: 5
81+ title: Docs EN+FR
82+ state: closed
83+ priority: medium
84+ author:
85+ name: k33g
86+ email: ph.charriere@gmail.com
87+ createdAt: 2026-11-26T08:00:00.000Z
88+ updatedAt: 2026-11-26T10:00:00.000Z
89+ closedAt: 2026-11-26T10:00:00.000Z
new file mode 100644
@@ -0,0 +1,89 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 264
3+title: "razorbill provider (rzb, MLX on the Mac) with razorbill.autoStart"
4+state: closed
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-26T08:00:00.000Z
9+updatedAt: 2026-11-26T11:00:00.000Z
10+closedAt: 2026-11-26T11:00:00.000Z
11+labels:
12+ - enhancement
13+ - kind::feature
14+milestone: v2.1.1
15+related:
16+ - 223
17+ - 252
18+body: |
19+ Asked by the user (2026-11-26): add razorbill (the user's MLX model
20+ server for the Mac, command `rzb`, OpenAI API on 127.0.0.1:7920) as a
21+ provider, with an autoStart mode like llamacpp's. macOS only.
22+
23+ ## What it does
24+ - Provider `razorbill`: base http://127.0.0.1:7920/v1, fallback
25+ host.docker.internal:7920, key RZB_API_KEY, reasoning off through
26+ chat_template_kwargs.enable_thinking (it wins over reasoning_effort),
27+ probe on /v1/models (warning when the model is not in the cache).
28+ - `razorbill: {autoStart, server, config, serverArgs, startTimeout}`:
29+ mm starts `rzb serve` when nothing answers at a loopback address,
30+ pulls the model with `rzb models pull` when it is missing, and stops
31+ the server with the last mm session using it. Never a server mm did
32+ not start. Only when mm runs on the Mac itself — not in a sandbox or
33+ a container.
34+ - The lease registry of internal/llamastart is shared (one package for
35+ both servers).
36+
37+ ## Acceptance criteria
38+ - Tests; `mm init` knows the provider and asks autostart; docs EN+FR.
39+tasks:
40+ - id: 1
41+ title: Provider entry and probe
42+ state: closed
43+ priority: high
44+ author:
45+ name: k33g
46+ email: ph.charriere@gmail.com
47+ createdAt: 2026-11-26T08:00:00.000Z
48+ updatedAt: 2026-11-26T10:00:00.000Z
49+ closedAt: 2026-11-26T10:00:00.000Z
50+ - id: 2
51+ title: Shared server lifecycle (registry, leases, lock) out of llamastart
52+ state: closed
53+ priority: high
54+ author:
55+ name: k33g
56+ email: ph.charriere@gmail.com
57+ createdAt: 2026-11-26T08:00:00.000Z
58+ updatedAt: 2026-11-26T10:00:00.000Z
59+ closedAt: 2026-11-26T10:00:00.000Z
60+ - id: 3
61+ title: razorbill config block and autoStart (rzb serve, rzb models pull)
62+ state: closed
63+ priority: high
64+ author:
65+ name: k33g
66+ email: ph.charriere@gmail.com
67+ createdAt: 2026-11-26T08:00:00.000Z
68+ updatedAt: 2026-11-26T10:00:00.000Z
69+ closedAt: 2026-11-26T10:00:00.000Z
70+ - id: 4
71+ title: mm init
72+ state: closed
73+ priority: medium
74+ author:
75+ name: k33g
76+ email: ph.charriere@gmail.com
77+ createdAt: 2026-11-26T08:00:00.000Z
78+ updatedAt: 2026-11-26T10:00:00.000Z
79+ closedAt: 2026-11-26T10:00:00.000Z
80+ - id: 5
81+ title: Docs EN+FR
82+ state: closed
83+ priority: medium
84+ author:
85+ name: k33g
86+ email: ph.charriere@gmail.com
87+ createdAt: 2026-11-26T08:00:00.000Z
88+ updatedAt: 2026-11-26T10:00:00.000Z
89+ closedAt: 2026-11-26T10:00:00.000Z
modified README.md +3 -3
@@ -8,7 +8,7 @@
88
99 Mini Me started as the preparation of a *Tools-in-Action* talk for **Devoxx Belgium 2026**, where I explain how an **agent loop** works with a single tool: `bash`. The model asks for a command, the agent runs it, the output goes back to the model, and so on until the model answers.
1010
11-From there it grew into the coding agent I wanted for local models (Docker Model Runner, llama.cpp, llmman, Ollama, Kronk, MLX-Serve): small enough to be read in an afternoon, and careful about what a small model does wrong:
11+From there it grew into the coding agent I wanted for local models (Docker Model Runner, llama.cpp, llmman, Ollama, Kronk, MLX-Serve, razorbill): small enough to be read in an afternoon, and careful about what a small model does wrong:
1212
1313 - **hallucinations** — the agent shows the real output of every command before the model comments on it, and the prompt forbids stating anything a command did not return;
1414 - **silent failures** — a failing command, a refused edit or a rejected permission goes back to the model as text, so it reads why and tries something else;
@@ -20,7 +20,7 @@ What makes Mini Me a bit special is that it was designed from the start to be us
2020
2121 ## Install
2222
23-You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), or [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key).
23+You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`), or razorbill (`rzb`, MLX on the Mac: `razorbill`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key).
2424
2525 ```bash
2626 git clone https://git.rickub.com/bots-garden/mini-me.git
@@ -44,7 +44,7 @@ Then pick a configuration file. Copy one to `agent.yaml` in your project and adj
4444 | `agent.lsp.yaml` | the same agent with a language server behind an `lsp` tool |
4545 | `agent.mcp-example.yaml` | the same agent with MCP servers |
4646
47-For Ollama, see [Run mini-me on Ollama](docs/en/how-to/run-with-ollama.md) and `demos/ollama/`; for Kronk, [Run mini-me on Kronk](docs/en/how-to/run-with-kronk.md) and `demos/kronk/`; for MLX-Serve, [Run mini-me on MLX-Serve](docs/en/how-to/run-with-mlx-serve.md) and `demos/mlx-gemma-4-e4b/`.
47+For Ollama, see [Run mini-me on Ollama](docs/en/how-to/run-with-ollama.md) and `demos/ollama/`; for Kronk, [Run mini-me on Kronk](docs/en/how-to/run-with-kronk.md) and `demos/kronk/`; for MLX-Serve, [Run mini-me on MLX-Serve](docs/en/how-to/run-with-mlx-serve.md) and `demos/mlx-gemma-4-e4b/`; for razorbill, [Run mini-me on razorbill](docs/en/how-to/run-with-razorbill.md) (with `razorbill.autoStart`, mm starts `rzb` itself).
4848
4949 Or let `mm init` write the file for you: see [More features](#more-features). To keep a project's mini-me files together, put the agent in `.mm/agent.yaml`: `mm` finds it on its own, and its paths are written from the project root — see [Keep a project's mini-me files in a `.mm` folder](docs/en/how-to/keep-the-config-in-a-mm-folder.md).
5050
@@ -8,7 +8,7 @@
8 8
9 Mini Me started as the preparation of a *Tools-in-Action* talk for **Devoxx Belgium 2026**, where I explain how an **agent loop** works with a single tool: `bash`. The model asks for a command, the agent runs it, the output goes back to the model, and so on until the model answers.9 Mini Me started as the preparation of a *Tools-in-Action* talk for **Devoxx Belgium 2026**, where I explain how an **agent loop** works with a single tool: `bash`. The model asks for a command, the agent runs it, the output goes back to the model, and so on until the model answers.
10 10
11-From there it grew into the coding agent I wanted for local models (Docker Model Runner, llama.cpp, llmman, Ollama, Kronk, MLX-Serve): small enough to be read in an afternoon, and careful about what a small model does wrong:11+From there it grew into the coding agent I wanted for local models (Docker Model Runner, llama.cpp, llmman, Ollama, Kronk, MLX-Serve, razorbill): small enough to be read in an afternoon, and careful about what a small model does wrong:
12 12
13 - **hallucinations** — the agent shows the real output of every command before the model comments on it, and the prompt forbids stating anything a command did not return;13 - **hallucinations** — the agent shows the real output of every command before the model comments on it, and the prompt forbids stating anything a command did not return;
14 - **silent failures** — a failing command, a refused edit or a rejected permission goes back to the model as text, so it reads why and tries something else;14 - **silent failures** — a failing command, a refused edit or a rejected permission goes back to the model as text, so it reads why and tries something else;
@@ -20,7 +20,7 @@ What makes Mini Me a bit special is that it was designed from the start to be us
20 20
21 ## Install21 ## Install
22 22
23-You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), or [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key).23+You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`), or razorbill (`rzb`, MLX on the Mac: `razorbill`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key).
24 24
25 ```bash25 ```bash
26 git clone https://git.rickub.com/bots-garden/mini-me.git26 git clone https://git.rickub.com/bots-garden/mini-me.git
@@ -44,7 +44,7 @@ Then pick a configuration file. Copy one to `agent.yaml` in your project and adj
44 | `agent.lsp.yaml` | the same agent with a language server behind an `lsp` tool |44 | `agent.lsp.yaml` | the same agent with a language server behind an `lsp` tool |
45 | `agent.mcp-example.yaml` | the same agent with MCP servers |45 | `agent.mcp-example.yaml` | the same agent with MCP servers |
46 46
47-For Ollama, see [Run mini-me on Ollama](docs/en/how-to/run-with-ollama.md) and `demos/ollama/`; for Kronk, [Run mini-me on Kronk](docs/en/how-to/run-with-kronk.md) and `demos/kronk/`; for MLX-Serve, [Run mini-me on MLX-Serve](docs/en/how-to/run-with-mlx-serve.md) and `demos/mlx-gemma-4-e4b/`.47+For Ollama, see [Run mini-me on Ollama](docs/en/how-to/run-with-ollama.md) and `demos/ollama/`; for Kronk, [Run mini-me on Kronk](docs/en/how-to/run-with-kronk.md) and `demos/kronk/`; for MLX-Serve, [Run mini-me on MLX-Serve](docs/en/how-to/run-with-mlx-serve.md) and `demos/mlx-gemma-4-e4b/`; for razorbill, [Run mini-me on razorbill](docs/en/how-to/run-with-razorbill.md) (with `razorbill.autoStart`, mm starts `rzb` itself).
48 48
49 Or let `mm init` write the file for you: see [More features](#more-features). To keep a project's mini-me files together, put the agent in `.mm/agent.yaml`: `mm` finds it on its own, and its paths are written from the project root — see [Keep a project's mini-me files in a `.mm` folder](docs/en/how-to/keep-the-config-in-a-mm-folder.md).49 Or let `mm init` write the file for you: see [More features](#more-features). To keep a project's mini-me files together, put the agent in `.mm/agent.yaml`: `mm` finds it on its own, and its paths are written from the project root — see [Keep a project's mini-me files in a `.mm` folder](docs/en/how-to/keep-the-config-in-a-mm-folder.md).
50 50
added autostart_wiring.go +97 -0
new file mode 100644
@@ -0,0 +1,97 @@
1+package main
2+
3+import (
4+ "context"
5+ "fmt"
6+ "os"
7+ "os/signal"
8+ "syscall"
9+
10+ "mm/internal/ask"
11+ "mm/internal/config"
12+ "mm/internal/engine"
13+ "mm/internal/llamastart"
14+ "mm/internal/rzbstart"
15+ "mm/internal/serverstart"
16+ "mm/internal/spinner"
17+)
18+
19+// startLocalServer starts the agent's local server when its autoStart is
20+// on and nothing answers at its address — llama-server for llamacpp
21+// (ticket 223), rzb for razorbill (ticket 264) — and returns this
22+// process's lease on the server mm started: nil when mm did not start one
23+// (nothing to do, or the user's own server answers). A failure is a
24+// warning: mm goes on as without autoStart, and the probe says what does
25+// not answer.
26+func startLocalServer(ctx context.Context, acpMode bool) *serverstart.Lease {
27+ report := func(line string) { _, _ = fmt.Fprintln(os.Stderr, line) }
28+ // The spinner in a terminal; in ACP mode (disabled spinner) and in an
29+ // agent asked by another one, the report lines only.
30+ var wait func(string) func()
31+ if !acpMode && ask.Depth() == 0 {
32+ wait = func(text string) func() { spinner.Start(text); return spinner.Stop }
33+ }
34+ if host, port, ok := engine.LlamaStartAddress(config.Cfg); ok {
35+ lc := config.Cfg.LlamaCpp
36+ o := llamastart.Options{
37+ Binary: lc.Server, Args: lc.LaunchArgs(), Host: host, Port: port,
38+ Model: config.Cfg.Model, Timeout: orDefault(lc.StartTimeout, config.DefaultLlamaStartTimeout),
39+ Report: report, Wait: wait,
40+ }
41+ return acquire(ctx, "llamacpp.autoStart", func(ctx context.Context) (*serverstart.Lease, error) {
42+ return llamastart.Acquire(ctx, o)
43+ })
44+ }
45+ if host, port, ok := engine.RazorbillStartAddress(config.Cfg); ok {
46+ rc := config.Cfg.Razorbill
47+ o := rzbstart.Options{
48+ Binary: rc.Server, ConfigFile: rc.Config, Args: rc.ServerArgs, Host: host, Port: port,
49+ Model: config.Cfg.Model, APIKey: razorbillKey(),
50+ Timeout: orDefault(rc.StartTimeout, config.DefaultRazorbillStartTimeout),
51+ Report: report, Wait: wait,
52+ }
53+ return acquire(ctx, "razorbill.autoStart", func(ctx context.Context) (*serverstart.Lease, error) {
54+ return rzbstart.Acquire(ctx, o)
55+ })
56+ }
57+ return nil
58+}
59+
60+// acquire runs a start under its own signal context: a download can take
61+// minutes, and Ctrl-C, SIGTERM or SIGHUP meanwhile stop the start — and the
62+// server, unless another mm uses it — then mm. The lease comes back even
63+// with an error after a start (the model failed to load): the exit must
64+// still stop the server.
65+func acquire(ctx context.Context, key string, start func(context.Context) (*serverstart.Lease, error)) *serverstart.Lease {
66+ sigCtx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
67+ defer stop()
68+ lease, err := start(sigCtx)
69+ if sigCtx.Err() != nil && ctx.Err() == nil {
70+ _, _ = fmt.Fprintf(os.Stderr, "\n[%s: interrupted]\n", key)
71+ lease.Release()
72+ os.Exit(130)
73+ }
74+ if err != nil {
75+ _, _ = fmt.Fprintf(os.Stderr, "[warning: %s: %v]\n", key, err)
76+ }
77+ return lease
78+}
79+
80+// razorbillKey is the key the agent sends to rzb — the variable apiKeyEnv
81+// names, RZB_API_KEY by default — so the model check after a start passes
82+// a server that checks one.
83+func razorbillKey() string {
84+ name := config.Cfg.APIKeyEnv
85+ if name == "" {
86+ name = "RZB_API_KEY"
87+ }
88+ return os.Getenv(name)
89+}
90+
91+func orDefault[T comparable](v, def T) T {
92+ var zero T
93+ if v == zero {
94+ return def
95+ }
96+ return v
97+}
new file mode 100644
@@ -0,0 +1,97 @@
1+package main
2+
3+import (
4+ "context"
5+ "fmt"
6+ "os"
7+ "os/signal"
8+ "syscall"
9+
10+ "mm/internal/ask"
11+ "mm/internal/config"
12+ "mm/internal/engine"
13+ "mm/internal/llamastart"
14+ "mm/internal/rzbstart"
15+ "mm/internal/serverstart"
16+ "mm/internal/spinner"
17+)
18+
19+// startLocalServer starts the agent's local server when its autoStart is
20+// on and nothing answers at its address — llama-server for llamacpp
21+// (ticket 223), rzb for razorbill (ticket 264) — and returns this
22+// process's lease on the server mm started: nil when mm did not start one
23+// (nothing to do, or the user's own server answers). A failure is a
24+// warning: mm goes on as without autoStart, and the probe says what does
25+// not answer.
26+func startLocalServer(ctx context.Context, acpMode bool) *serverstart.Lease {
27+ report := func(line string) { _, _ = fmt.Fprintln(os.Stderr, line) }
28+ // The spinner in a terminal; in ACP mode (disabled spinner) and in an
29+ // agent asked by another one, the report lines only.
30+ var wait func(string) func()
31+ if !acpMode && ask.Depth() == 0 {
32+ wait = func(text string) func() { spinner.Start(text); return spinner.Stop }
33+ }
34+ if host, port, ok := engine.LlamaStartAddress(config.Cfg); ok {
35+ lc := config.Cfg.LlamaCpp
36+ o := llamastart.Options{
37+ Binary: lc.Server, Args: lc.LaunchArgs(), Host: host, Port: port,
38+ Model: config.Cfg.Model, Timeout: orDefault(lc.StartTimeout, config.DefaultLlamaStartTimeout),
39+ Report: report, Wait: wait,
40+ }
41+ return acquire(ctx, "llamacpp.autoStart", func(ctx context.Context) (*serverstart.Lease, error) {
42+ return llamastart.Acquire(ctx, o)
43+ })
44+ }
45+ if host, port, ok := engine.RazorbillStartAddress(config.Cfg); ok {
46+ rc := config.Cfg.Razorbill
47+ o := rzbstart.Options{
48+ Binary: rc.Server, ConfigFile: rc.Config, Args: rc.ServerArgs, Host: host, Port: port,
49+ Model: config.Cfg.Model, APIKey: razorbillKey(),
50+ Timeout: orDefault(rc.StartTimeout, config.DefaultRazorbillStartTimeout),
51+ Report: report, Wait: wait,
52+ }
53+ return acquire(ctx, "razorbill.autoStart", func(ctx context.Context) (*serverstart.Lease, error) {
54+ return rzbstart.Acquire(ctx, o)
55+ })
56+ }
57+ return nil
58+}
59+
60+// acquire runs a start under its own signal context: a download can take
61+// minutes, and Ctrl-C, SIGTERM or SIGHUP meanwhile stop the start — and the
62+// server, unless another mm uses it — then mm. The lease comes back even
63+// with an error after a start (the model failed to load): the exit must
64+// still stop the server.
65+func acquire(ctx context.Context, key string, start func(context.Context) (*serverstart.Lease, error)) *serverstart.Lease {
66+ sigCtx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
67+ defer stop()
68+ lease, err := start(sigCtx)
69+ if sigCtx.Err() != nil && ctx.Err() == nil {
70+ _, _ = fmt.Fprintf(os.Stderr, "\n[%s: interrupted]\n", key)
71+ lease.Release()
72+ os.Exit(130)
73+ }
74+ if err != nil {
75+ _, _ = fmt.Fprintf(os.Stderr, "[warning: %s: %v]\n", key, err)
76+ }
77+ return lease
78+}
79+
80+// razorbillKey is the key the agent sends to rzb — the variable apiKeyEnv
81+// names, RZB_API_KEY by default — so the model check after a start passes
82+// a server that checks one.
83+func razorbillKey() string {
84+ name := config.Cfg.APIKeyEnv
85+ if name == "" {
86+ name = "RZB_API_KEY"
87+ }
88+ return os.Getenv(name)
89+}
90+
91+func orDefault[T comparable](v, def T) T {
92+ var zero T
93+ if v == zero {
94+ return def
95+ }
96+ return v
97+}
added autostart_wiring_test.go +45 -0
new file mode 100644
@@ -0,0 +1,45 @@
1+package main
2+
3+import (
4+ "context"
5+ "testing"
6+ "time"
7+
8+ "mm/internal/config"
9+)
10+
11+// The key sent to rzb is the one the agent's apiKeyEnv names, RZB_API_KEY
12+// by default.
13+func TestRazorbillKey(t *testing.T) {
14+ defaults := config.Cfg
15+ t.Cleanup(func() { config.Cfg = defaults })
16+ t.Setenv("RZB_API_KEY", "default-key")
17+ t.Setenv("MY_RZB_KEY", "own-key")
18+ config.Cfg.APIKeyEnv = ""
19+ if got := razorbillKey(); got != "default-key" {
20+ t.Errorf("default variable: %q", got)
21+ }
22+ config.Cfg.APIKeyEnv = "MY_RZB_KEY"
23+ if got := razorbillKey(); got != "own-key" {
24+ t.Errorf("apiKeyEnv: %q", got)
25+ }
26+}
27+
28+func TestOrDefault(t *testing.T) {
29+ if orDefault(time.Duration(0), time.Minute) != time.Minute || orDefault(time.Second, time.Minute) != time.Second {
30+ t.Error("orDefault")
31+ }
32+}
33+
34+// Without autoStart nothing is started and there is no lease.
35+func TestStartLocalServerWithoutAutoStart(t *testing.T) {
36+ defaults := config.Cfg
37+ t.Cleanup(func() { config.Cfg = defaults })
38+ for _, p := range []string{"llamacpp", "razorbill", "ollama"} {
39+ config.Cfg.Provider = p
40+ config.Cfg.LlamaCpp.AutoStart, config.Cfg.Razorbill.AutoStart = false, false
41+ if l := startLocalServer(context.Background(), true); l != nil {
42+ t.Errorf("%s: lease %v, want none", p, l)
43+ }
44+ }
45+}
new file mode 100644
@@ -0,0 +1,45 @@
1+package main
2+
3+import (
4+ "context"
5+ "testing"
6+ "time"
7+
8+ "mm/internal/config"
9+)
10+
11+// The key sent to rzb is the one the agent's apiKeyEnv names, RZB_API_KEY
12+// by default.
13+func TestRazorbillKey(t *testing.T) {
14+ defaults := config.Cfg
15+ t.Cleanup(func() { config.Cfg = defaults })
16+ t.Setenv("RZB_API_KEY", "default-key")
17+ t.Setenv("MY_RZB_KEY", "own-key")
18+ config.Cfg.APIKeyEnv = ""
19+ if got := razorbillKey(); got != "default-key" {
20+ t.Errorf("default variable: %q", got)
21+ }
22+ config.Cfg.APIKeyEnv = "MY_RZB_KEY"
23+ if got := razorbillKey(); got != "own-key" {
24+ t.Errorf("apiKeyEnv: %q", got)
25+ }
26+}
27+
28+func TestOrDefault(t *testing.T) {
29+ if orDefault(time.Duration(0), time.Minute) != time.Minute || orDefault(time.Second, time.Minute) != time.Second {
30+ t.Error("orDefault")
31+ }
32+}
33+
34+// Without autoStart nothing is started and there is no lease.
35+func TestStartLocalServerWithoutAutoStart(t *testing.T) {
36+ defaults := config.Cfg
37+ t.Cleanup(func() { config.Cfg = defaults })
38+ for _, p := range []string{"llamacpp", "razorbill", "ollama"} {
39+ config.Cfg.Provider = p
40+ config.Cfg.LlamaCpp.AutoStart, config.Cfg.Razorbill.AutoStart = false, false
41+ if l := startLocalServer(context.Background(), true); l != nil {
42+ t.Errorf("%s: lease %v, want none", p, l)
43+ }
44+ }
45+}
modified docs/diagrams/packages.drawio +2 -2
@@ -1,4 +1,4 @@
1-<mxfile host="app.diagrams.net" modified="2026-10-22T00:00:00.000Z" agent="mm docs" version="24.0.0" type="device"><diagram id="packages" name="packages"><mxGraphModel dx="1400" dy="900" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1400" pageHeight="1060"><root><mxCell id="0" /><mxCell id="1" parent="0" /><mxCell id="main" value="&lt;b&gt;main (mm)&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;wiring: config, engine, tools, then one front end&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1"><mxGeometry x="420" y="40" width="200" height="60" as="geometry" /></mxCell><mxCell id="agent" value="&lt;b&gt;internal/agent&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal REPL: /quit /abort /compact /new&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="160" y="180" width="200" height="60" as="geometry" /></mxCell><mxCell id="acp" value="&lt;b&gt;internal/acp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;editor front end: Agent Client Protocol on stdio&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="700" y="180" width="200" height="60" as="geometry" /></mxCell><mxCell id="session" value="&lt;b&gt;internal/session&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;what a conversation starts from; the /new reset&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="compact" value="&lt;b&gt;internal/compact&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;history compression into a model-written summary&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="40" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="engine" value="&lt;b&gt;internal/engine&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;LLM connection + generation, one Provider per server&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="700" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="tools" value="&lt;b&gt;internal/tools&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;built-in tools: bash, read_skill, file tools, lsp, fetch_content; declared toolsbuilt-in tools: bash, read_skill, file tools, lsp, fetch_content&lt;/font&gt;lt;/fontbuilt-in tools: bash, read_skill, file tools, lsp, fetch_content&lt;/font&gt;gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="460" width="200" height="60" as="geometry" /></mxCell><mxCell id="detector" value="&lt;b&gt;internal/detector&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;repeated-action (loop) detection&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="40" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="config" value="&lt;b&gt;internal/config&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;settings with YAML overrides (agent.yaml)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="260" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="spinner" value="&lt;b&gt;internal/spinner&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal spinner and styling&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="480" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="ui" value="&lt;b&gt;internal/ui&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;human output destination + shared event sink&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="700" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="fileedit" value="&lt;b&gt;internal/fileedit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;exact-replacement file editing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="920" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="skills" value="&lt;b&gt;internal/skills&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;markdown skills catalogue (./skills)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1140" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="genkit" value="&lt;b&gt;github.com/firebase/genkit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;ai.Message, tools, model calls&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="160" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="acpsdk" value="&lt;b&gt;github.com/coder/acp-go-sdk&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;JSON-RPC transport for ACP&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="700" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="openai" value="&lt;b&gt;github.com/openai/openai-go&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;OpenAI-compatible HTTP client&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="920" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="yaml" value="&lt;b&gt;gopkg.in/yaml.v3&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;YAML parsing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="400" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="e0" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="version" value="&lt;b&gt;internal/version&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;which mm this is: build stamp, else the commit&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1380" y="600" width="200" height="60" as="geometry" /></mxCell>
1+<mxfile host="app.diagrams.net" modified="2026-11-26T00:00:00.000Z" agent="mm docs" version="24.0.0" type="device"><diagram id="packages" name="packages"><mxGraphModel dx="1400" dy="900" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1400" pageHeight="1060"><root><mxCell id="0" /><mxCell id="1" parent="0" /><mxCell id="main" value="&lt;b&gt;main (mm)&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;wiring: config, engine, tools, then one front end&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1"><mxGeometry x="420" y="40" width="200" height="60" as="geometry" /></mxCell><mxCell id="agent" value="&lt;b&gt;internal/agent&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal REPL: /quit /abort /compact /new&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="160" y="180" width="200" height="60" as="geometry" /></mxCell><mxCell id="acp" value="&lt;b&gt;internal/acp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;editor front end: Agent Client Protocol on stdio&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="700" y="180" width="200" height="60" as="geometry" /></mxCell><mxCell id="session" value="&lt;b&gt;internal/session&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;what a conversation starts from; the /new reset&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="compact" value="&lt;b&gt;internal/compact&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;history compression into a model-written summary&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="40" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="engine" value="&lt;b&gt;internal/engine&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;LLM connection + generation, one Provider per server&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="700" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="tools" value="&lt;b&gt;internal/tools&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;built-in tools: bash, read_skill, file tools, lsp, fetch_content; declared toolsbuilt-in tools: bash, read_skill, file tools, lsp, fetch_content&lt;/font&gt;lt;/fontbuilt-in tools: bash, read_skill, file tools, lsp, fetch_content&lt;/font&gt;gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="460" width="200" height="60" as="geometry" /></mxCell><mxCell id="detector" value="&lt;b&gt;internal/detector&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;repeated-action (loop) detection&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="40" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="config" value="&lt;b&gt;internal/config&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;settings with YAML overrides (agent.yaml)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="260" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="spinner" value="&lt;b&gt;internal/spinner&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal spinner and styling&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="480" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="ui" value="&lt;b&gt;internal/ui&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;human output destination + shared event sink&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="700" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="fileedit" value="&lt;b&gt;internal/fileedit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;exact-replacement file editing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="920" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="skills" value="&lt;b&gt;internal/skills&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;markdown skills catalogue (./skills)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1140" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="genkit" value="&lt;b&gt;github.com/firebase/genkit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;ai.Message, tools, model calls&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="160" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="acpsdk" value="&lt;b&gt;github.com/coder/acp-go-sdk&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;JSON-RPC transport for ACP&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="700" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="openai" value="&lt;b&gt;github.com/openai/openai-go&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;OpenAI-compatible HTTP client&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="920" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="yaml" value="&lt;b&gt;gopkg.in/yaml.v3&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;YAML parsing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="400" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="e0" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="version" value="&lt;b&gt;internal/version&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;which mm this is: build stamp, else the commit&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1380" y="600" width="200" height="60" as="geometry" /></mxCell>
22 <mxCell id="e61" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="version"><mxGeometry relative="1" as="geometry" /></mxCell>
33 <mxCell id="e1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="acp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e3" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e4" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e5" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e6" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e7" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e8" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e9" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e10" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e11" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e12" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="acp" target="acpsdk"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e13" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="acp" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e14" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e15" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e16" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e17" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e18" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e19" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e20" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="agent" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e21" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="compact" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e22" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="compact" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e23" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="config" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e24" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e25" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e26" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e27" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="engine" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e28" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="engine" target="openai"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e29" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e30" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e31" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="fileedit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e32" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e33" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e34" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e35" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="tools" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e36" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="session" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="mention" value="&lt;b&gt;internal/mention&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the @path notation of a question&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="400" width="200" height="60" as="geometry" /></mxCell><mxCell id="e37" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e38" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="store" value="&lt;b&gt;internal/store&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;per-project session files (.mm/sessions/&lt;id&gt;.json), the questions ↑ recalls, /memory and search_memory&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="480" width="200" height="60" as="geometry" /></mxCell><mxCell id="e39" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e40" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="tui" value="&lt;b&gt;internal/tui&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;window front end: one screen on tcell (mm -tui)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="430" y="160" width="200" height="60" as="geometry" /></mxCell><mxCell id="command" value="&lt;b&gt;internal/command&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the one slash-command table, per front end&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="tcell" value="&lt;b&gt;github.com/gdamore/tcell/v2&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal screen, keys, mouse&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="920" y="840" width="200" height="60" as="geometry" /></mxCell><mxCell id="e41" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="tui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e42" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e43" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e44" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e45" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e46" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e47" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e48" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e49" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e50" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e51" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="tcell"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e52" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e53" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e54" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="command" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="saved" value="&lt;b&gt;internal/saved&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;an answer to a new file: /save, save_answer&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="920" y="680" width="200" height="60" as="geometry" /></mxCell><mxCell id="e87" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e88" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e89" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="clipboard" value="&lt;b&gt;internal/clipboard&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;system clipboard: native tool, then OSC 52&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1140" y="680" width="200" height="60" as="geometry" /></mxCell><mxCell id="e55" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="clipboard"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e56" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="clipboard"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="lsp" value="&lt;b&gt;internal/lsp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;language-server client: definition, references, hover, symbols, diagnostics, rename&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1160" y="600" width="220" height="60" as="geometry" /></mxCell><mxCell id="lspdev" value="&lt;b&gt;go.lsp.dev/protocol + jsonrpc2&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;LSP types and JSON-RPC 2.0 over stdio&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#ffffff;strokeColor=#999999;" vertex="1" parent="1"><mxGeometry x="1160" y="700" width="220" height="60" as="geometry" /></mxCell><mxCell id="e57" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="lsp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e58" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="lsp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e59" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="lsp" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e60" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="lsp" target="lspdev"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="legend" value="&lt;b&gt;mm — package dependencies&lt;/b&gt;&lt;br/&gt;Arrow: &quot;imports&quot;. Yellow: entry point. Blue: front ends. Green: shared logic. Grey: leaf packages. Dashed purple: third-party modules.&lt;br/&gt;Regenerate the edge list from: go list -f '{{.ImportPath}}: {{join .Imports &quot; &quot;}}' ./..." style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=top;fillColor=#ffffff;strokeColor=#999999;" vertex="1" parent="1"><mxGeometry x="900" y="40" width="440" height="90" as="geometry" /></mxCell><mxCell id="webmd" value="&lt;b&gt;internal/webmd&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;web page → Markdown: fetch (robots.txt, charset → UTF-8), clean, convert&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1400" y="460" width="220" height="60" as="geometry" /></mxCell><mxCell id="xnet" value="&lt;b&gt;golang.org/x/net/html (+ x/text)&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;HTML5 parser, charset lookup&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="1400" y="760" width="220" height="60" as="geometry" /></mxCell><mxCell id="e_main_webmd" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="webmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_webmd" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="webmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_webmd_xnet" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="webmd" target="xnet"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ask" value="&lt;b&gt;internal/ask&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;/ask another mm agent: child mm -acp, ACP client side&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="640" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_main_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_command" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_compact" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_ui" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_acpsdk" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="acpsdk"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_genkit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_yaml" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="consent" value="&lt;b&gt;internal/consent&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;yolo switch, the four answers, per-session memory, the line mode prompt hook, a hook's one-call approval&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="700" y="500" width="200" height="60" as="geometry" /></mxCell><mxCell id="mcp" value="&lt;b&gt;internal/mcp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;MCP clients (stdio, HTTP), their tools wrapped as mm tools&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1400" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="e62" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="consent" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e63" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="consent" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e64" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e65" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e66" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e67" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e68" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e70consent" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e69" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e70" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e71" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e72" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e73" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e74" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="structured" value="&lt;b&gt;internal/structured&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;structuredOutput: Go declarations → JSON Schema (go/parser)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="260" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e75" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="config" target="structured"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="agentsmd" value="&lt;b&gt;internal/agentsmd&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the project's AGENTS.md, appended to the system prompt per conversation&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="520.0" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e76" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e77" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e78" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e79" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e80" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentsmd" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="elicit" value="&lt;b&gt;internal/elicit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;ask_user's questions and answers: normalize, line answers, elicitation form schema&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="780.0" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e81" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ui" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell>
4- <mxCell id="e90" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ui" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e82" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e83" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e84" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e85" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e86" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="hooks" value="&lt;b&gt;internal/hooks&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the hooks: block — runs each hook (sh -c, JSON on stdin/stdout), chain, onError&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="940" y="400" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_engine_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_main_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_hooks_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="hooks" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_session" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_compact" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_engine" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_store" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="docsearch" value="&lt;b&gt;internal/docsearch&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;BM25 over the text files of folders: /docs, search_docs&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="460" width="200" height="60" as="geometry" /></mxCell><mxCell id="textfold" value="&lt;b&gt;internal/textfold&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;case and accents folded, rune for rune&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1640" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_docsearch_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="docsearch" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_docsearch_textfold" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="docsearch" target="textfold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_textfold" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="textfold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_textfold_xnet" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="textfold" target="xnet"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_tools" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_tools" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="agentinit" value="&lt;b&gt;internal/agentinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm init: the agent.yaml wizard, presets.yaml, the server's model facts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="660" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_main_agentinit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_elicit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_engine" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_agentinit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="wasmtool" value="&lt;b&gt;internal/wasmtool&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;runs the wasm tools and hooks: JSON on stdin, declared folders only, timeout&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1640" y="360" width="200" height="60" as="geometry" /></mxCell><mxCell id="wazero" value="&lt;b&gt;github.com/tetratelabs/wazero&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;WebAssembly runtime in pure Go, WASI preview 1&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="1640" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_tools_wasmtool" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="wasmtool"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_wasmtool_wazero" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="wasmtool" target="wazero"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_hooks_wasmtool" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="hooks" target="wasmtool"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="decide" value="&lt;b&gt;internal/decide&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;decision models: /v1/systemone client, skill and tool routing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1140" y="840" width="200" height="60" as="geometry" /></mxCell><mxCell id="ed0" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed3" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed4" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed5" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="config" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed6" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="decide" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="dockerinit" value="&lt;b&gt;internal/dockerinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm dockerinit: writes the Dockerfile and compose.yaml&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="860" width="200" height="60" as="geometry" /></mxCell><mxCell id="e91" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="dockerinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="sbxinit" value="&lt;b&gt;internal/sbxinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm sbxinit: writes sbxenv.yaml with the latest kit (.mm aware)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="960" width="200" height="60" as="geometry" /></mxCell><mxCell id="scaffold" value="&lt;b&gt;internal/scaffold&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;what mm dockerinit and mm sbxinit share: the agent name, writing without destroying&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="1060" width="200" height="60" as="geometry" /></mxCell><mxCell id="e92" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="dockerinit" target="scaffold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e93" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="sbxinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e94" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="scaffold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e95" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e96" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="scaffold" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e97" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="scaffold" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_mcp" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_detector" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="skillcreate" value="&lt;b&gt;internal/skillcreate&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm skillcreate: the skill wizard, writes &amp;lt;skillsDir&amp;gt;/&amp;lt;name&amp;gt;/SKILL.md&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="1160" width="200" height="60" as="geometry" /></mxCell><mxCell id="e98" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="skillcreate"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e99" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="skillcreate"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e100" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e101" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e102" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e103" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e104" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e105" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e106" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="config"><mxGeometry relative="1" as="geometry" /></mxCell></root></mxGraphModel></diagram></mxfile>
\ No newline at end of file
4+ <mxCell id="e90" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ui" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e82" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e83" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e84" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e85" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e86" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="hooks" value="&lt;b&gt;internal/hooks&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the hooks: block — runs each hook (sh -c, JSON on stdin/stdout), chain, onError&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="940" y="400" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_engine_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_main_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_hooks_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="hooks" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_session" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_compact" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_engine" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_store" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="docsearch" value="&lt;b&gt;internal/docsearch&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;BM25 over the text files of folders: /docs, search_docs&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="460" width="200" height="60" as="geometry" /></mxCell><mxCell id="textfold" value="&lt;b&gt;internal/textfold&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;case and accents folded, rune for rune&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1640" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_docsearch_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="docsearch" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_docsearch_textfold" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="docsearch" target="textfold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_textfold" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="textfold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_textfold_xnet" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="textfold" target="xnet"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_tools" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_tools" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="agentinit" value="&lt;b&gt;internal/agentinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm init: the agent.yaml wizard, presets.yaml, the server's model facts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="660" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_main_agentinit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_elicit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_engine" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_agentinit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="wasmtool" value="&lt;b&gt;internal/wasmtool&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;runs the wasm tools and hooks: JSON on stdin, declared folders only, timeout&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1640" y="360" width="200" height="60" as="geometry" /></mxCell><mxCell id="wazero" value="&lt;b&gt;github.com/tetratelabs/wazero&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;WebAssembly runtime in pure Go, WASI preview 1&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="1640" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_tools_wasmtool" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="wasmtool"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_wasmtool_wazero" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="wasmtool" target="wazero"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_hooks_wasmtool" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="hooks" target="wasmtool"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="decide" value="&lt;b&gt;internal/decide&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;decision models: /v1/systemone client, skill and tool routing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1140" y="840" width="200" height="60" as="geometry" /></mxCell><mxCell id="ed0" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed3" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed4" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed5" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="config" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed6" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="decide" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="dockerinit" value="&lt;b&gt;internal/dockerinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm dockerinit: writes the Dockerfile and compose.yaml&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="860" width="200" height="60" as="geometry" /></mxCell><mxCell id="e91" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="dockerinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="sbxinit" value="&lt;b&gt;internal/sbxinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm sbxinit: writes sbxenv.yaml with the latest kit (.mm aware)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="960" width="200" height="60" as="geometry" /></mxCell><mxCell id="scaffold" value="&lt;b&gt;internal/scaffold&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;what mm dockerinit and mm sbxinit share: the agent name, writing without destroying&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="1060" width="200" height="60" as="geometry" /></mxCell><mxCell id="e92" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="dockerinit" target="scaffold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e93" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="sbxinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e94" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="scaffold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e95" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e96" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="scaffold" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e97" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="scaffold" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_mcp" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_detector" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="skillcreate" value="&lt;b&gt;internal/skillcreate&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm skillcreate: the skill wizard, writes &amp;lt;skillsDir&amp;gt;/&amp;lt;name&amp;gt;/SKILL.md&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="1160" width="200" height="60" as="geometry" /></mxCell><mxCell id="e98" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="skillcreate"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e99" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="skillcreate"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e100" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e101" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e102" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e103" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e104" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e105" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e106" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="llamastart" value="&lt;b&gt;internal/llamastart&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;llamacpp.autoStart: starts llama-server (router, models preset), loads the model&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="700" y="1260" width="200" height="60" as="geometry" /></mxCell><mxCell id="rzbstart" value="&lt;b&gt;internal/rzbstart&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;razorbill.autoStart: starts rzb serve, rzb models pull (macOS only)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="960" y="1260" width="200" height="60" as="geometry" /></mxCell><mxCell id="serverstart" value="&lt;b&gt;internal/serverstart&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;shared server lifetime: registry, leases, lock, start, stop with the last session&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="830" y="1380" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_ls1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="llamastart"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_rs1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="rzbstart"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ls2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="llamastart" target="serverstart"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_rs2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="rzbstart" target="serverstart"><mxGeometry relative="1" as="geometry" /></mxCell></root></mxGraphModel></diagram></mxfile>
\ No newline at end of file
@@ -1,4 +1,4 @@
1-<mxfile host="app.diagrams.net" modified="2026-10-22T00:00:00.000Z" agent="mm docs" version="24.0.0" type="device"><diagram id="packages" name="packages"><mxGraphModel dx="1400" dy="900" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1400" pageHeight="1060"><root><mxCell id="0" /><mxCell id="1" parent="0" /><mxCell id="main" value="&lt;b&gt;main (mm)&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;wiring: config, engine, tools, then one front end&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1"><mxGeometry x="420" y="40" width="200" height="60" as="geometry" /></mxCell><mxCell id="agent" value="&lt;b&gt;internal/agent&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal REPL: /quit /abort /compact /new&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="160" y="180" width="200" height="60" as="geometry" /></mxCell><mxCell id="acp" value="&lt;b&gt;internal/acp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;editor front end: Agent Client Protocol on stdio&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="700" y="180" width="200" height="60" as="geometry" /></mxCell><mxCell id="session" value="&lt;b&gt;internal/session&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;what a conversation starts from; the /new reset&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="compact" value="&lt;b&gt;internal/compact&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;history compression into a model-written summary&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="40" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="engine" value="&lt;b&gt;internal/engine&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;LLM connection + generation, one Provider per server&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="700" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="tools" value="&lt;b&gt;internal/tools&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;built-in tools: bash, read_skill, file tools, lsp, fetch_content; declared toolsbuilt-in tools: bash, read_skill, file tools, lsp, fetch_content&lt;/font&gt;lt;/fontbuilt-in tools: bash, read_skill, file tools, lsp, fetch_content&lt;/font&gt;gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="460" width="200" height="60" as="geometry" /></mxCell><mxCell id="detector" value="&lt;b&gt;internal/detector&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;repeated-action (loop) detection&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="40" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="config" value="&lt;b&gt;internal/config&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;settings with YAML overrides (agent.yaml)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="260" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="spinner" value="&lt;b&gt;internal/spinner&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal spinner and styling&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="480" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="ui" value="&lt;b&gt;internal/ui&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;human output destination + shared event sink&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="700" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="fileedit" value="&lt;b&gt;internal/fileedit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;exact-replacement file editing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="920" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="skills" value="&lt;b&gt;internal/skills&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;markdown skills catalogue (./skills)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1140" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="genkit" value="&lt;b&gt;github.com/firebase/genkit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;ai.Message, tools, model calls&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="160" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="acpsdk" value="&lt;b&gt;github.com/coder/acp-go-sdk&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;JSON-RPC transport for ACP&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="700" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="openai" value="&lt;b&gt;github.com/openai/openai-go&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;OpenAI-compatible HTTP client&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="920" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="yaml" value="&lt;b&gt;gopkg.in/yaml.v3&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;YAML parsing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="400" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="e0" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="version" value="&lt;b&gt;internal/version&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;which mm this is: build stamp, else the commit&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1380" y="600" width="200" height="60" as="geometry" /></mxCell>1+<mxfile host="app.diagrams.net" modified="2026-11-26T00:00:00.000Z" agent="mm docs" version="24.0.0" type="device"><diagram id="packages" name="packages"><mxGraphModel dx="1400" dy="900" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1400" pageHeight="1060"><root><mxCell id="0" /><mxCell id="1" parent="0" /><mxCell id="main" value="&lt;b&gt;main (mm)&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;wiring: config, engine, tools, then one front end&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1"><mxGeometry x="420" y="40" width="200" height="60" as="geometry" /></mxCell><mxCell id="agent" value="&lt;b&gt;internal/agent&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal REPL: /quit /abort /compact /new&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="160" y="180" width="200" height="60" as="geometry" /></mxCell><mxCell id="acp" value="&lt;b&gt;internal/acp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;editor front end: Agent Client Protocol on stdio&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="700" y="180" width="200" height="60" as="geometry" /></mxCell><mxCell id="session" value="&lt;b&gt;internal/session&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;what a conversation starts from; the /new reset&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="compact" value="&lt;b&gt;internal/compact&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;history compression into a model-written summary&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="40" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="engine" value="&lt;b&gt;internal/engine&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;LLM connection + generation, one Provider per server&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="700" y="320" width="200" height="60" as="geometry" /></mxCell><mxCell id="tools" value="&lt;b&gt;internal/tools&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;built-in tools: bash, read_skill, file tools, lsp, fetch_content; declared toolsbuilt-in tools: bash, read_skill, file tools, lsp, fetch_content&lt;/font&gt;lt;/fontbuilt-in tools: bash, read_skill, file tools, lsp, fetch_content&lt;/font&gt;gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="460" width="200" height="60" as="geometry" /></mxCell><mxCell id="detector" value="&lt;b&gt;internal/detector&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;repeated-action (loop) detection&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="40" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="config" value="&lt;b&gt;internal/config&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;settings with YAML overrides (agent.yaml)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="260" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="spinner" value="&lt;b&gt;internal/spinner&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal spinner and styling&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="480" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="ui" value="&lt;b&gt;internal/ui&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;human output destination + shared event sink&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="700" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="fileedit" value="&lt;b&gt;internal/fileedit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;exact-replacement file editing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="920" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="skills" value="&lt;b&gt;internal/skills&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;markdown skills catalogue (./skills)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1140" y="600" width="200" height="60" as="geometry" /></mxCell><mxCell id="genkit" value="&lt;b&gt;github.com/firebase/genkit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;ai.Message, tools, model calls&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="160" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="acpsdk" value="&lt;b&gt;github.com/coder/acp-go-sdk&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;JSON-RPC transport for ACP&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="700" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="openai" value="&lt;b&gt;github.com/openai/openai-go&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;OpenAI-compatible HTTP client&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="920" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="yaml" value="&lt;b&gt;gopkg.in/yaml.v3&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;YAML parsing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="400" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="e0" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="version" value="&lt;b&gt;internal/version&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;which mm this is: build stamp, else the commit&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1380" y="600" width="200" height="60" as="geometry" /></mxCell>
2 <mxCell id="e61" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="version"><mxGeometry relative="1" as="geometry" /></mxCell>2 <mxCell id="e61" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="version"><mxGeometry relative="1" as="geometry" /></mxCell>
3 <mxCell id="e1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="acp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e3" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e4" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e5" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e6" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e7" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e8" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e9" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e10" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e11" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e12" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="acp" target="acpsdk"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e13" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="acp" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e14" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e15" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e16" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e17" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e18" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e19" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e20" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="agent" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e21" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="compact" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e22" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="compact" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e23" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="config" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e24" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e25" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e26" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e27" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="engine" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e28" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="engine" target="openai"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e29" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e30" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e31" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="fileedit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e32" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e33" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e34" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e35" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="tools" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e36" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="session" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="mention" value="&lt;b&gt;internal/mention&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the @path notation of a question&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="400" width="200" height="60" as="geometry" /></mxCell><mxCell id="e37" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e38" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="store" value="&lt;b&gt;internal/store&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;per-project session files (.mm/sessions/&lt;id&gt;.json), the questions ↑ recalls, /memory and search_memory&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="480" width="200" height="60" as="geometry" /></mxCell><mxCell id="e39" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e40" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="tui" value="&lt;b&gt;internal/tui&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;window front end: one screen on tcell (mm -tui)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="430" y="160" width="200" height="60" as="geometry" /></mxCell><mxCell id="command" value="&lt;b&gt;internal/command&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the one slash-command table, per front end&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="tcell" value="&lt;b&gt;github.com/gdamore/tcell/v2&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal screen, keys, mouse&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="920" y="840" width="200" height="60" as="geometry" /></mxCell><mxCell id="e41" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="tui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e42" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e43" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e44" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e45" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e46" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e47" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e48" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e49" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e50" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e51" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="tcell"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e52" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e53" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e54" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="command" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="saved" value="&lt;b&gt;internal/saved&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;an answer to a new file: /save, save_answer&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="920" y="680" width="200" height="60" as="geometry" /></mxCell><mxCell id="e87" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e88" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e89" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="clipboard" value="&lt;b&gt;internal/clipboard&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;system clipboard: native tool, then OSC 52&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1140" y="680" width="200" height="60" as="geometry" /></mxCell><mxCell id="e55" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="clipboard"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e56" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="clipboard"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="lsp" value="&lt;b&gt;internal/lsp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;language-server client: definition, references, hover, symbols, diagnostics, rename&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1160" y="600" width="220" height="60" as="geometry" /></mxCell><mxCell id="lspdev" value="&lt;b&gt;go.lsp.dev/protocol + jsonrpc2&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;LSP types and JSON-RPC 2.0 over stdio&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#ffffff;strokeColor=#999999;" vertex="1" parent="1"><mxGeometry x="1160" y="700" width="220" height="60" as="geometry" /></mxCell><mxCell id="e57" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="lsp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e58" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="lsp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e59" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="lsp" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e60" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="lsp" target="lspdev"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="legend" value="&lt;b&gt;mm — package dependencies&lt;/b&gt;&lt;br/&gt;Arrow: &quot;imports&quot;. Yellow: entry point. Blue: front ends. Green: shared logic. Grey: leaf packages. Dashed purple: third-party modules.&lt;br/&gt;Regenerate the edge list from: go list -f '{{.ImportPath}}: {{join .Imports &quot; &quot;}}' ./..." style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=top;fillColor=#ffffff;strokeColor=#999999;" vertex="1" parent="1"><mxGeometry x="900" y="40" width="440" height="90" as="geometry" /></mxCell><mxCell id="webmd" value="&lt;b&gt;internal/webmd&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;web page → Markdown: fetch (robots.txt, charset → UTF-8), clean, convert&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1400" y="460" width="220" height="60" as="geometry" /></mxCell><mxCell id="xnet" value="&lt;b&gt;golang.org/x/net/html (+ x/text)&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;HTML5 parser, charset lookup&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="1400" y="760" width="220" height="60" as="geometry" /></mxCell><mxCell id="e_main_webmd" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="webmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_webmd" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="webmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_webmd_xnet" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="webmd" target="xnet"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ask" value="&lt;b&gt;internal/ask&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;/ask another mm agent: child mm -acp, ACP client side&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="640" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_main_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_command" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_compact" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_ui" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_acpsdk" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="acpsdk"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_genkit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_yaml" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="consent" value="&lt;b&gt;internal/consent&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;yolo switch, the four answers, per-session memory, the line mode prompt hook, a hook's one-call approval&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="700" y="500" width="200" height="60" as="geometry" /></mxCell><mxCell id="mcp" value="&lt;b&gt;internal/mcp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;MCP clients (stdio, HTTP), their tools wrapped as mm tools&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1400" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="e62" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="consent" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e63" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="consent" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e64" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e65" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e66" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e67" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e68" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e70consent" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e69" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e70" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e71" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e72" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e73" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e74" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="structured" value="&lt;b&gt;internal/structured&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;structuredOutput: Go declarations → JSON Schema (go/parser)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="260" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e75" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="config" target="structured"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="agentsmd" value="&lt;b&gt;internal/agentsmd&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the project's AGENTS.md, appended to the system prompt per conversation&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="520.0" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e76" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e77" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e78" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e79" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e80" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentsmd" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="elicit" value="&lt;b&gt;internal/elicit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;ask_user's questions and answers: normalize, line answers, elicitation form schema&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="780.0" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e81" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ui" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell>3 <mxCell id="e1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="acp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e3" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e4" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e5" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e6" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e7" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e8" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e9" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e10" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e11" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e12" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="acp" target="acpsdk"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e13" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="acp" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e14" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e15" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e16" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e17" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e18" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e19" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e20" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="agent" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e21" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="compact" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e22" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="compact" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e23" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="config" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e24" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e25" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e26" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e27" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="engine" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e28" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="engine" target="openai"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e29" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e30" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e31" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="fileedit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e32" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e33" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e34" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e35" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="tools" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e36" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="session" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="mention" value="&lt;b&gt;internal/mention&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the @path notation of a question&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="400" width="200" height="60" as="geometry" /></mxCell><mxCell id="e37" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e38" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="store" value="&lt;b&gt;internal/store&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;per-project session files (.mm/sessions/&lt;id&gt;.json), the questions ↑ recalls, /memory and search_memory&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="480" width="200" height="60" as="geometry" /></mxCell><mxCell id="e39" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e40" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="tui" value="&lt;b&gt;internal/tui&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;window front end: one screen on tcell (mm -tui)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="430" y="160" width="200" height="60" as="geometry" /></mxCell><mxCell id="command" value="&lt;b&gt;internal/command&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the one slash-command table, per front end&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="tcell" value="&lt;b&gt;github.com/gdamore/tcell/v2&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;terminal screen, keys, mouse&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="920" y="840" width="200" height="60" as="geometry" /></mxCell><mxCell id="e41" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="tui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e42" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e43" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e44" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e45" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e46" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="mention"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e47" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e48" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e49" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e50" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e51" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="tcell"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e52" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e53" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e54" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="command" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="saved" value="&lt;b&gt;internal/saved&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;an answer to a new file: /save, save_answer&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="920" y="680" width="200" height="60" as="geometry" /></mxCell><mxCell id="e87" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e88" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e89" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="saved"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="clipboard" value="&lt;b&gt;internal/clipboard&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;system clipboard: native tool, then OSC 52&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1140" y="680" width="200" height="60" as="geometry" /></mxCell><mxCell id="e55" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="clipboard"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e56" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="clipboard"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="lsp" value="&lt;b&gt;internal/lsp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;language-server client: definition, references, hover, symbols, diagnostics, rename&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1160" y="600" width="220" height="60" as="geometry" /></mxCell><mxCell id="lspdev" value="&lt;b&gt;go.lsp.dev/protocol + jsonrpc2&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;LSP types and JSON-RPC 2.0 over stdio&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#ffffff;strokeColor=#999999;" vertex="1" parent="1"><mxGeometry x="1160" y="700" width="220" height="60" as="geometry" /></mxCell><mxCell id="e57" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="lsp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e58" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="lsp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e59" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="lsp" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e60" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="lsp" target="lspdev"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="legend" value="&lt;b&gt;mm — package dependencies&lt;/b&gt;&lt;br/&gt;Arrow: &quot;imports&quot;. Yellow: entry point. Blue: front ends. Green: shared logic. Grey: leaf packages. Dashed purple: third-party modules.&lt;br/&gt;Regenerate the edge list from: go list -f '{{.ImportPath}}: {{join .Imports &quot; &quot;}}' ./..." style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=top;fillColor=#ffffff;strokeColor=#999999;" vertex="1" parent="1"><mxGeometry x="900" y="40" width="440" height="90" as="geometry" /></mxCell><mxCell id="webmd" value="&lt;b&gt;internal/webmd&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;web page → Markdown: fetch (robots.txt, charset → UTF-8), clean, convert&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1400" y="460" width="220" height="60" as="geometry" /></mxCell><mxCell id="xnet" value="&lt;b&gt;golang.org/x/net/html (+ x/text)&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;HTML5 parser, charset lookup&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="1400" y="760" width="220" height="60" as="geometry" /></mxCell><mxCell id="e_main_webmd" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="webmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_webmd" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="webmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_webmd_xnet" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="webmd" target="xnet"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ask" value="&lt;b&gt;internal/ask&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;/ask another mm agent: child mm -acp, ACP client side&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="430" y="640" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_main_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_ask" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="ask"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_command" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="command"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_compact" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_ui" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_acpsdk" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="acpsdk"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_genkit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="genkit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_yaml" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="ask" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="consent" value="&lt;b&gt;internal/consent&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;yolo switch, the four answers, per-session memory, the line mode prompt hook, a hook's one-call approval&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="700" y="500" width="200" height="60" as="geometry" /></mxCell><mxCell id="mcp" value="&lt;b&gt;internal/mcp&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;MCP clients (stdio, HTTP), their tools wrapped as mm tools&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1400" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="e62" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="consent" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e63" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="consent" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e64" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e65" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e66" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e67" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e68" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e70consent" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e69" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="consent"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e70" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e71" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="ui"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e72" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="mcp" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e73" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e74" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="structured" value="&lt;b&gt;internal/structured&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;structuredOutput: Go declarations → JSON Schema (go/parser)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="260" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e75" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="config" target="structured"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="agentsmd" value="&lt;b&gt;internal/agentsmd&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the project's AGENTS.md, appended to the system prompt per conversation&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="520.0" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e76" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e77" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e78" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e79" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentsmd"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e80" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentsmd" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="elicit" value="&lt;b&gt;internal/elicit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;ask_user's questions and answers: normalize, line answers, elicitation form schema&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="780.0" y="940.0" width="200" height="60" as="geometry" /></mxCell><mxCell id="e81" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ui" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell>
4- <mxCell id="e90" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ui" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e82" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e83" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e84" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e85" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e86" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="hooks" value="&lt;b&gt;internal/hooks&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the hooks: block — runs each hook (sh -c, JSON on stdin/stdout), chain, onError&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="940" y="400" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_engine_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_main_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_hooks_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="hooks" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_session" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_compact" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_engine" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_store" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="docsearch" value="&lt;b&gt;internal/docsearch&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;BM25 over the text files of folders: /docs, search_docs&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="460" width="200" height="60" as="geometry" /></mxCell><mxCell id="textfold" value="&lt;b&gt;internal/textfold&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;case and accents folded, rune for rune&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1640" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_docsearch_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="docsearch" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_docsearch_textfold" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="docsearch" target="textfold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_textfold" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="textfold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_textfold_xnet" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="textfold" target="xnet"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_tools" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_tools" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="agentinit" value="&lt;b&gt;internal/agentinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm init: the agent.yaml wizard, presets.yaml, the server's model facts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="660" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_main_agentinit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_elicit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_engine" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_agentinit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="wasmtool" value="&lt;b&gt;internal/wasmtool&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;runs the wasm tools and hooks: JSON on stdin, declared folders only, timeout&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1640" y="360" width="200" height="60" as="geometry" /></mxCell><mxCell id="wazero" value="&lt;b&gt;github.com/tetratelabs/wazero&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;WebAssembly runtime in pure Go, WASI preview 1&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="1640" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_tools_wasmtool" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="wasmtool"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_wasmtool_wazero" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="wasmtool" target="wazero"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_hooks_wasmtool" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="hooks" target="wasmtool"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="decide" value="&lt;b&gt;internal/decide&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;decision models: /v1/systemone client, skill and tool routing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1140" y="840" width="200" height="60" as="geometry" /></mxCell><mxCell id="ed0" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed3" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed4" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed5" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="config" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed6" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="decide" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="dockerinit" value="&lt;b&gt;internal/dockerinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm dockerinit: writes the Dockerfile and compose.yaml&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="860" width="200" height="60" as="geometry" /></mxCell><mxCell id="e91" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="dockerinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="sbxinit" value="&lt;b&gt;internal/sbxinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm sbxinit: writes sbxenv.yaml with the latest kit (.mm aware)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="960" width="200" height="60" as="geometry" /></mxCell><mxCell id="scaffold" value="&lt;b&gt;internal/scaffold&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;what mm dockerinit and mm sbxinit share: the agent name, writing without destroying&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="1060" width="200" height="60" as="geometry" /></mxCell><mxCell id="e92" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="dockerinit" target="scaffold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e93" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="sbxinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e94" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="scaffold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e95" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e96" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="scaffold" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e97" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="scaffold" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_mcp" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_detector" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="skillcreate" value="&lt;b&gt;internal/skillcreate&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm skillcreate: the skill wizard, writes &amp;lt;skillsDir&amp;gt;/&amp;lt;name&amp;gt;/SKILL.md&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="1160" width="200" height="60" as="geometry" /></mxCell><mxCell id="e98" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="skillcreate"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e99" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="skillcreate"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e100" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e101" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e102" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e103" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e104" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e105" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e106" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="config"><mxGeometry relative="1" as="geometry" /></mxCell></root></mxGraphModel></diagram></mxfile>
\ No newline at end of file\ No newline at end of file
4+ <mxCell id="e90" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ui" target="spinner"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e82" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e83" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e84" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e85" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e86" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="hooks" value="&lt;b&gt;internal/hooks&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;the hooks: block — runs each hook (sh -c, JSON on stdin/stdout), chain, onError&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="940" y="400" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_engine_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ask_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="ask" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_main_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_hooks_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="hooks" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_session" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="session"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_compact" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="compact"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_engine" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_hooks" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="hooks"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_store" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="store"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="docsearch" value="&lt;b&gt;internal/docsearch&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;BM25 over the text files of folders: /docs, search_docs&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="460" width="200" height="60" as="geometry" /></mxCell><mxCell id="textfold" value="&lt;b&gt;internal/textfold&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;case and accents folded, rune for rune&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1640" y="560" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_docsearch_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="docsearch" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_docsearch_textfold" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="docsearch" target="textfold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_store_textfold" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="store" target="textfold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_textfold_xnet" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="textfold" target="xnet"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tools_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agent_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_docsearch" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="docsearch"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_tools" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_tools" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="tools"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="agentinit" value="&lt;b&gt;internal/agentinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm init: the agent.yaml wizard, presets.yaml, the server's model facts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="660" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_main_agentinit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_config" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_elicit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_agentinit_engine" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agentinit" target="engine"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_tui_agentinit" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="wasmtool" value="&lt;b&gt;internal/wasmtool&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;runs the wasm tools and hooks: JSON on stdin, declared folders only, timeout&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1"><mxGeometry x="1640" y="360" width="200" height="60" as="geometry" /></mxCell><mxCell id="wazero" value="&lt;b&gt;github.com/tetratelabs/wazero&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;WebAssembly runtime in pure Go, WASI preview 1&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;dashed=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1"><mxGeometry x="1640" y="760" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_tools_wasmtool" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tools" target="wasmtool"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_wasmtool_wazero" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;dashed=1;" edge="1" parent="1" source="wasmtool" target="wazero"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_hooks_wasmtool" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="hooks" target="wasmtool"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="decide" value="&lt;b&gt;internal/decide&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;decision models: /v1/systemone client, skill and tool routing&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1140" y="840" width="200" height="60" as="geometry" /></mxCell><mxCell id="ed0" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="agent" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed3" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed4" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="engine" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed5" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="config" target="decide"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="ed6" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="decide" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="dockerinit" value="&lt;b&gt;internal/dockerinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm dockerinit: writes the Dockerfile and compose.yaml&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="860" width="200" height="60" as="geometry" /></mxCell><mxCell id="e91" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="dockerinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="sbxinit" value="&lt;b&gt;internal/sbxinit&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm sbxinit: writes sbxenv.yaml with the latest kit (.mm aware)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="960" width="200" height="60" as="geometry" /></mxCell><mxCell id="scaffold" value="&lt;b&gt;internal/scaffold&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;what mm dockerinit and mm sbxinit share: the agent name, writing without destroying&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="1060" width="200" height="60" as="geometry" /></mxCell><mxCell id="e92" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="dockerinit" target="scaffold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e93" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="sbxinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e94" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="scaffold"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e95" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e96" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="scaffold" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e97" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="scaffold" target="yaml"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_mcp" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="mcp"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_acp_detector" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="acp" target="detector"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="skillcreate" value="&lt;b&gt;internal/skillcreate&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;mm skillcreate: the skill wizard, writes &amp;lt;skillsDir&amp;gt;/&amp;lt;name&amp;gt;/SKILL.md&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="1640" y="1160" width="200" height="60" as="geometry" /></mxCell><mxCell id="e98" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="skillcreate"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e99" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="skillcreate"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e100" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e101" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e102" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="elicit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e103" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="skillcreate" target="skills"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e104" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e105" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="tui" target="agentinit"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e106" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="sbxinit" target="config"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="llamastart" value="&lt;b&gt;internal/llamastart&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;llamacpp.autoStart: starts llama-server (router, models preset), loads the model&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="700" y="1260" width="200" height="60" as="geometry" /></mxCell><mxCell id="rzbstart" value="&lt;b&gt;internal/rzbstart&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;razorbill.autoStart: starts rzb serve, rzb models pull (macOS only)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="960" y="1260" width="200" height="60" as="geometry" /></mxCell><mxCell id="serverstart" value="&lt;b&gt;internal/serverstart&lt;/b&gt;&lt;br/&gt;&lt;font style=&quot;font-size:10px&quot;&gt;shared server lifetime: registry, leases, lock, start, stop with the last session&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1"><mxGeometry x="830" y="1380" width="200" height="60" as="geometry" /></mxCell><mxCell id="e_ls1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="llamastart"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_rs1" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="main" target="rzbstart"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_ls2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="llamastart" target="serverstart"><mxGeometry relative="1" as="geometry" /></mxCell><mxCell id="e_rs2" style="endArrow=block;html=1;rounded=0;edgeStyle=orthogonalEdgeStyle;" edge="1" parent="1" source="rzbstart" target="serverstart"><mxGeometry relative="1" as="geometry" /></mxCell></root></mxGraphModel></diagram></mxfile>
\ No newline at end of file\ No newline at end of file
modified docs/en/README.md +1 -0
@@ -18,6 +18,7 @@ This documentation is organised along the four [Diátaxis](https://diataxis.fr)
1818 - [Run mini-me on Ollama](how-to/run-with-ollama.md) — `provider: ollama`, the demo config in `demos/ollama/`
1919 - [Run mini-me on Kronk](how-to/run-with-kronk.md) — `provider: kronk`, the demo config in `demos/kronk/`
2020 - [Run mini-me on MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, the demo config in `demos/mlx-gemma-4-e4b/`
21+- [Run mini-me on razorbill](how-to/run-with-razorbill.md) — `provider: razorbill` (`rzb`, MLX on the Mac), and `razorbill.autoStart`
2122 - [Use any OpenAI-compatible server](how-to/run-with-an-openai-compatible-server.md) — `provider: openai`: the OpenAI API, vLLM, LM Studio, a gateway
2223 - [Keep reasoning and tools together with OpenAI's Responses API](how-to/use-the-openai-responses-api.md) — `provider: openai-responses`: OpenAI's reasoning models with tools
2324 - [Ask another mm agent from your session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<name>`, `/ask-with-context-<name>`
@@ -18,6 +18,7 @@ This documentation is organised along the four [Diátaxis](https://diataxis.fr)
18 - [Run mini-me on Ollama](how-to/run-with-ollama.md) — `provider: ollama`, the demo config in `demos/ollama/`18 - [Run mini-me on Ollama](how-to/run-with-ollama.md) — `provider: ollama`, the demo config in `demos/ollama/`
19 - [Run mini-me on Kronk](how-to/run-with-kronk.md) — `provider: kronk`, the demo config in `demos/kronk/`19 - [Run mini-me on Kronk](how-to/run-with-kronk.md) — `provider: kronk`, the demo config in `demos/kronk/`
20 - [Run mini-me on MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, the demo config in `demos/mlx-gemma-4-e4b/`20 - [Run mini-me on MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, the demo config in `demos/mlx-gemma-4-e4b/`
21+- [Run mini-me on razorbill](how-to/run-with-razorbill.md) — `provider: razorbill` (`rzb`, MLX on the Mac), and `razorbill.autoStart`
21 - [Use any OpenAI-compatible server](how-to/run-with-an-openai-compatible-server.md) — `provider: openai`: the OpenAI API, vLLM, LM Studio, a gateway22 - [Use any OpenAI-compatible server](how-to/run-with-an-openai-compatible-server.md) — `provider: openai`: the OpenAI API, vLLM, LM Studio, a gateway
22 - [Keep reasoning and tools together with OpenAI's Responses API](how-to/use-the-openai-responses-api.md) — `provider: openai-responses`: OpenAI's reasoning models with tools23 - [Keep reasoning and tools together with OpenAI's Responses API](how-to/use-the-openai-responses-api.md) — `provider: openai-responses`: OpenAI's reasoning models with tools
23 - [Ask another mm agent from your session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<name>`, `/ask-with-context-<name>`24 - [Ask another mm agent from your session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<name>`, `/ask-with-context-<name>`
modified docs/en/explanation/mm-init.md +1 -0
@@ -18,6 +18,7 @@ The server knows the exact model that is loaded, so it is the most specific sour
1818 | `llamacpp` | `/props` | the window and the chat template |
1919 | `kronk` | `/models`, then `/v1/kronk/models/<id>` | the model list, the architecture, the window the model is configured with (the trained one when none), the sampling written in the GGUF, the chat template; for a profile, its own sampling, which wins over every other source: `mm` sends its sampling with every request and a request's value replaces a profile's, so the profile's values would otherwise never apply |
2020 | `mlxserve` | `/models`, then `/api/show` | the model list, the family, the window (the served one when the model is loaded), the chat template, and the model's own sampling (`gen_temperature`, `gen_top_p`, `gen_top_k` in `/v1/models`) |
21+| `razorbill` | `/models` | the model list only (rzb 0.2.0 reports no family, window or sampling) |
2122 | `dmr` | `/models` | the model list only |
2223 | `openai`, `openai-responses` | `/models` (with the key) | the model list only |
2324
@@ -18,6 +18,7 @@ The server knows the exact model that is loaded, so it is the most specific sour
18 | `llamacpp` | `/props` | the window and the chat template |18 | `llamacpp` | `/props` | the window and the chat template |
19 | `kronk` | `/models`, then `/v1/kronk/models/<id>` | the model list, the architecture, the window the model is configured with (the trained one when none), the sampling written in the GGUF, the chat template; for a profile, its own sampling, which wins over every other source: `mm` sends its sampling with every request and a request's value replaces a profile's, so the profile's values would otherwise never apply |19 | `kronk` | `/models`, then `/v1/kronk/models/<id>` | the model list, the architecture, the window the model is configured with (the trained one when none), the sampling written in the GGUF, the chat template; for a profile, its own sampling, which wins over every other source: `mm` sends its sampling with every request and a request's value replaces a profile's, so the profile's values would otherwise never apply |
20 | `mlxserve` | `/models`, then `/api/show` | the model list, the family, the window (the served one when the model is loaded), the chat template, and the model's own sampling (`gen_temperature`, `gen_top_p`, `gen_top_k` in `/v1/models`) |20 | `mlxserve` | `/models`, then `/api/show` | the model list, the family, the window (the served one when the model is loaded), the chat template, and the model's own sampling (`gen_temperature`, `gen_top_p`, `gen_top_k` in `/v1/models`) |
21+| `razorbill` | `/models` | the model list only (rzb 0.2.0 reports no family, window or sampling) |
21 | `dmr` | `/models` | the model list only |22 | `dmr` | `/models` | the model list only |
22 | `openai`, `openai-responses` | `/models` (with the key) | the model list only |23 | `openai`, `openai-responses` | `/models` (with the key) | the model list only |
23 24
modified docs/en/explanation/providers.md +4 -2
@@ -2,7 +2,7 @@
22
33 ## What is this about?
44
5-`mm` talks to a local model server through the OpenAI chat-completions API. Six servers are supported out of the box: Docker Model Runner, llama.cpp's `llama-server`, llmman, Ollama, Kronk and MLX-Serve, under the names `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk` and `mlxserve`. Another entry, `openai` (ticket 118), takes any other server that speaks the protocol — the OpenAI API by default, vLLM, LM Studio, a gateway — and assumes nothing beyond it: it is the same data-only entry with every server-specific field left empty, and a probe that sends the key. The engine package used to be tied to Docker Model Runner; the provider abstraction is what generalised it.
5+`mm` talks to a local model server through the OpenAI chat-completions API. Seven servers are supported out of the box: Docker Model Runner, llama.cpp's `llama-server`, llmman, Ollama, Kronk, MLX-Serve and razorbill, under the names `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve` and `razorbill`. Another entry, `openai` (ticket 118), takes any other server that speaks the protocol — the OpenAI API by default, vLLM, LM Studio, a gateway — and assumes nothing beyond it: it is the same data-only entry with every server-specific field left empty, and a probe that sends the key. The engine package used to be tied to Docker Model Runner; the provider abstraction is what generalised it.
66
77 ## Why it is designed this way
88
@@ -24,6 +24,8 @@
2424
2525 **MLX-Serve is a sixth entry, and the first whose silence is the trap.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) runs MLX models on Apple Silicon and speaks the OpenAI, Anthropic and Ollama APIs on one port; `mm` uses the OpenAI side, and Ollama's `/api/pull` for `autoPull`. Measured on mlx-serve 26.11.3: reasoning streams as `reasoning_content` and is on when **either** `enable_thinking` **or** `reasoning_effort` asks for it, so a summary is sent with both off (a third way of turning reasoning off, beside the template and the effort). No prompt progress. `GET /v1/models` lists every downloaded model with `loaded` and `context_length`: loaded, that is the window it is served with (it changed from 101376 to 73728 between two loads, with less free memory), unloaded, the trained length — so the probe trusts it only for a loaded model. A model the server does not have is answered anyway, with HTTP 200, by its default model: no 404 will ever tell, so the start-up warning is the only place it shows. And while it reads a long prompt it sends SSE comments (`: keepalive`); openai-go turns the blank line after one into an empty event and fails on it (`unexpected end of JSON input`). `mm` now removes comment-only blocks from every stream before openai-go sees them.
2626
27+**razorbill is a seventh entry, and the second server mm can start itself.** razorbill (`rzb serve`, port 7920, ticket 264) is an MLX server for Apple Silicon Macs. Measured on rzb 0.2.0, it is the plainest of the entries: reasoning streams as `reasoning_content`, `enable_thinking: false` turns it off and wins over any `reasoning_effort` (so the template switch alone is enough), no prompt progress, `: keep-alive` comments while it reads a prompt (dropped like MLX-Serve's). It reports no window, and has no route to pull or unload a model: it downloads a model on its first use and unloads an idle one itself. Downloading on first use is the trap here, since a multi-GB download inside the first question runs into the watchdog. So the probe warns about a model rzb does not list, and `razorbill.autoStart` runs `rzb models pull` before the first question. The start and stop are llamacpp's (ticket 223), now in a shared package, `internal/serverstart`: one registry per server and address, one lease per mm session, the server stopped with the last lease, and a server mm did not start never touched. Only the server-specific part differs: llama-server's preset and `/models/load` in `internal/llamastart`, `rzb serve` and `rzb models pull` in `internal/rzbstart`. Copying the lease logic into a second package was rejected: two copies of the locking and stale-lease rules would drift. rzb runs only on macOS, so the start is refused elsewhere — in a container or a sandbox, where the Mac's server is reached through the fallback instead.
28+
2729 **Errors are rewritten in the server's own words.** A stack of wrapped messages is noise; "tool calls need llama-server started with --jinja" is the whole diagnosis. The provider recognises connection refusals, the missing `--jinja` flag, 401/403, 404 with a pull or alias hint, 429 and 5xx. Unknown errors come back unchanged: a raw message beats a wrong hint.
2830
2931 **A stream the server breaks is retried, and its words are kept.** llama.cpp reports a failure in the middle of a streamed answer as an SSE `error:` event (the 200 status is already sent). openai-go only reads `data:` lines, so the message used to vanish behind `unexpected end of JSON input`. The tap that reads the stream for reasoning also picks up those events, and the model call that broke is retried once — that call only: the tools that ran earlier in the turn are not replayed, and text the broken attempt already streamed is not taken back. If it breaks again, the error shows the server's own message (`the model server reported an error while generating: Failed to parse input at pos …`), or says the connection broke. Either way the history is kept: asking to continue picks the work up.
@@ -42,5 +44,5 @@
4244
4345 - The two configuration files that parametrise each provider are listed in the [configuration reference](../reference/configuration.md).
4446 - The window the probe learns is what [context compression](context-compression.md) measures against.
45-- Switching servers for one run is covered in [how to run on llama.cpp](../how-to/run-with-llama-cpp.md) [how to run on llmman](../how-to/run-with-llmman.md), [how to run on Ollama](../how-to/run-with-ollama.md) [how to run on Kronk](../how-to/run-with-kronk.md) and [how to run on MLX-Serve](../how-to/run-with-mlx-serve.md).
47+- Switching servers for one run is covered in [how to run on llama.cpp](../how-to/run-with-llama-cpp.md) [how to run on llmman](../how-to/run-with-llmman.md), [how to run on Ollama](../how-to/run-with-ollama.md) [how to run on Kronk](../how-to/run-with-kronk.md) [how to run on MLX-Serve](../how-to/run-with-mlx-serve.md) and [how to run on razorbill](../how-to/run-with-razorbill.md).
4648 - Checking the tool order and measuring the cache gain on your own server: [how to check that the tools go out in a stable order](../how-to/verify-tool-order.md).
@@ -2,7 +2,7 @@
2 2
3 ## What is this about?3 ## What is this about?
4 4
5-`mm` talks to a local model server through the OpenAI chat-completions API. Six servers are supported out of the box: Docker Model Runner, llama.cpp's `llama-server`, llmman, Ollama, Kronk and MLX-Serve, under the names `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk` and `mlxserve`. Another entry, `openai` (ticket 118), takes any other server that speaks the protocol — the OpenAI API by default, vLLM, LM Studio, a gateway — and assumes nothing beyond it: it is the same data-only entry with every server-specific field left empty, and a probe that sends the key. The engine package used to be tied to Docker Model Runner; the provider abstraction is what generalised it.5+`mm` talks to a local model server through the OpenAI chat-completions API. Seven servers are supported out of the box: Docker Model Runner, llama.cpp's `llama-server`, llmman, Ollama, Kronk, MLX-Serve and razorbill, under the names `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve` and `razorbill`. Another entry, `openai` (ticket 118), takes any other server that speaks the protocol — the OpenAI API by default, vLLM, LM Studio, a gateway — and assumes nothing beyond it: it is the same data-only entry with every server-specific field left empty, and a probe that sends the key. The engine package used to be tied to Docker Model Runner; the provider abstraction is what generalised it.
6 6
7 ## Why it is designed this way7 ## Why it is designed this way
8 8
@@ -24,6 +24,8 @@
24 24
25 **MLX-Serve is a sixth entry, and the first whose silence is the trap.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) runs MLX models on Apple Silicon and speaks the OpenAI, Anthropic and Ollama APIs on one port; `mm` uses the OpenAI side, and Ollama's `/api/pull` for `autoPull`. Measured on mlx-serve 26.11.3: reasoning streams as `reasoning_content` and is on when **either** `enable_thinking` **or** `reasoning_effort` asks for it, so a summary is sent with both off (a third way of turning reasoning off, beside the template and the effort). No prompt progress. `GET /v1/models` lists every downloaded model with `loaded` and `context_length`: loaded, that is the window it is served with (it changed from 101376 to 73728 between two loads, with less free memory), unloaded, the trained length — so the probe trusts it only for a loaded model. A model the server does not have is answered anyway, with HTTP 200, by its default model: no 404 will ever tell, so the start-up warning is the only place it shows. And while it reads a long prompt it sends SSE comments (`: keepalive`); openai-go turns the blank line after one into an empty event and fails on it (`unexpected end of JSON input`). `mm` now removes comment-only blocks from every stream before openai-go sees them.25 **MLX-Serve is a sixth entry, and the first whose silence is the trap.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) runs MLX models on Apple Silicon and speaks the OpenAI, Anthropic and Ollama APIs on one port; `mm` uses the OpenAI side, and Ollama's `/api/pull` for `autoPull`. Measured on mlx-serve 26.11.3: reasoning streams as `reasoning_content` and is on when **either** `enable_thinking` **or** `reasoning_effort` asks for it, so a summary is sent with both off (a third way of turning reasoning off, beside the template and the effort). No prompt progress. `GET /v1/models` lists every downloaded model with `loaded` and `context_length`: loaded, that is the window it is served with (it changed from 101376 to 73728 between two loads, with less free memory), unloaded, the trained length — so the probe trusts it only for a loaded model. A model the server does not have is answered anyway, with HTTP 200, by its default model: no 404 will ever tell, so the start-up warning is the only place it shows. And while it reads a long prompt it sends SSE comments (`: keepalive`); openai-go turns the blank line after one into an empty event and fails on it (`unexpected end of JSON input`). `mm` now removes comment-only blocks from every stream before openai-go sees them.
26 26
27+**razorbill is a seventh entry, and the second server mm can start itself.** razorbill (`rzb serve`, port 7920, ticket 264) is an MLX server for Apple Silicon Macs. Measured on rzb 0.2.0, it is the plainest of the entries: reasoning streams as `reasoning_content`, `enable_thinking: false` turns it off and wins over any `reasoning_effort` (so the template switch alone is enough), no prompt progress, `: keep-alive` comments while it reads a prompt (dropped like MLX-Serve's). It reports no window, and has no route to pull or unload a model: it downloads a model on its first use and unloads an idle one itself. Downloading on first use is the trap here, since a multi-GB download inside the first question runs into the watchdog. So the probe warns about a model rzb does not list, and `razorbill.autoStart` runs `rzb models pull` before the first question. The start and stop are llamacpp's (ticket 223), now in a shared package, `internal/serverstart`: one registry per server and address, one lease per mm session, the server stopped with the last lease, and a server mm did not start never touched. Only the server-specific part differs: llama-server's preset and `/models/load` in `internal/llamastart`, `rzb serve` and `rzb models pull` in `internal/rzbstart`. Copying the lease logic into a second package was rejected: two copies of the locking and stale-lease rules would drift. rzb runs only on macOS, so the start is refused elsewhere — in a container or a sandbox, where the Mac's server is reached through the fallback instead.
28+
27 **Errors are rewritten in the server's own words.** A stack of wrapped messages is noise; "tool calls need llama-server started with --jinja" is the whole diagnosis. The provider recognises connection refusals, the missing `--jinja` flag, 401/403, 404 with a pull or alias hint, 429 and 5xx. Unknown errors come back unchanged: a raw message beats a wrong hint.29 **Errors are rewritten in the server's own words.** A stack of wrapped messages is noise; "tool calls need llama-server started with --jinja" is the whole diagnosis. The provider recognises connection refusals, the missing `--jinja` flag, 401/403, 404 with a pull or alias hint, 429 and 5xx. Unknown errors come back unchanged: a raw message beats a wrong hint.
28 30
29 **A stream the server breaks is retried, and its words are kept.** llama.cpp reports a failure in the middle of a streamed answer as an SSE `error:` event (the 200 status is already sent). openai-go only reads `data:` lines, so the message used to vanish behind `unexpected end of JSON input`. The tap that reads the stream for reasoning also picks up those events, and the model call that broke is retried once — that call only: the tools that ran earlier in the turn are not replayed, and text the broken attempt already streamed is not taken back. If it breaks again, the error shows the server's own message (`the model server reported an error while generating: Failed to parse input at pos …`), or says the connection broke. Either way the history is kept: asking to continue picks the work up.31 **A stream the server breaks is retried, and its words are kept.** llama.cpp reports a failure in the middle of a streamed answer as an SSE `error:` event (the 200 status is already sent). openai-go only reads `data:` lines, so the message used to vanish behind `unexpected end of JSON input`. The tap that reads the stream for reasoning also picks up those events, and the model call that broke is retried once — that call only: the tools that ran earlier in the turn are not replayed, and text the broken attempt already streamed is not taken back. If it breaks again, the error shows the server's own message (`the model server reported an error while generating: Failed to parse input at pos …`), or says the connection broke. Either way the history is kept: asking to continue picks the work up.
@@ -42,5 +44,5 @@
42 44
43 - The two configuration files that parametrise each provider are listed in the [configuration reference](../reference/configuration.md).45 - The two configuration files that parametrise each provider are listed in the [configuration reference](../reference/configuration.md).
44 - The window the probe learns is what [context compression](context-compression.md) measures against.46 - The window the probe learns is what [context compression](context-compression.md) measures against.
45-- Switching servers for one run is covered in [how to run on llama.cpp](../how-to/run-with-llama-cpp.md) [how to run on llmman](../how-to/run-with-llmman.md), [how to run on Ollama](../how-to/run-with-ollama.md) [how to run on Kronk](../how-to/run-with-kronk.md) and [how to run on MLX-Serve](../how-to/run-with-mlx-serve.md).47+- Switching servers for one run is covered in [how to run on llama.cpp](../how-to/run-with-llama-cpp.md) [how to run on llmman](../how-to/run-with-llmman.md), [how to run on Ollama](../how-to/run-with-ollama.md) [how to run on Kronk](../how-to/run-with-kronk.md) [how to run on MLX-Serve](../how-to/run-with-mlx-serve.md) and [how to run on razorbill](../how-to/run-with-razorbill.md).
46 - Checking the tool order and measuring the cache gain on your own server: [how to check that the tools go out in a stable order](../how-to/verify-tool-order.md).48 - Checking the tool order and measuring the cache gain on your own server: [how to check that the tools go out in a stable order](../how-to/verify-tool-order.md).
modified docs/en/how-to/run-in-a-container.md +3 -1
@@ -68,7 +68,9 @@ The project is mounted at the same path as on your machine, so the paths the edi
6868
6969 ## Reach the model
7070
71-From the container, `localhost` is the container. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve` and `llamacpp` fall back on `host.docker.internal` by themselves when their default address does not answer, as long as the agent file sets no `baseUrl`. The compose file makes that name known on Linux too.
71+From the container, `localhost` is the container. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve`, `razorbill` and `llamacpp` fall back on `host.docker.internal` by themselves when their default address does not answer, as long as the agent file sets no `baseUrl`. The compose file makes that name known on Linux too.
72+
73+`llamacpp.autoStart` and `razorbill.autoStart` start nothing from a container: they start a server only at an address on mm's own machine. Start the server on the host instead, listening on every interface (`llama-server --host 0.0.0.0`, `rzb serve --host 0.0.0.0`).
7274
7375 - **`llamacpp`**: on Linux, start llama-server with `--host 0.0.0.0`, as it listens on the loopback only by default (see the last point). Files written before v1.1.0 may say `fallback: ""`: remove that line.
7476 - **An agent file with a `baseUrl` on `localhost` or `127.0.0.1`:** replace the host with `host.docker.internal`, or add a `fallback`.
@@ -68,7 +68,9 @@ The project is mounted at the same path as on your machine, so the paths the edi
68 68
69 ## Reach the model69 ## Reach the model
70 70
71-From the container, `localhost` is the container. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve` and `llamacpp` fall back on `host.docker.internal` by themselves when their default address does not answer, as long as the agent file sets no `baseUrl`. The compose file makes that name known on Linux too.71+From the container, `localhost` is the container. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve`, `razorbill` and `llamacpp` fall back on `host.docker.internal` by themselves when their default address does not answer, as long as the agent file sets no `baseUrl`. The compose file makes that name known on Linux too.
72+
73+`llamacpp.autoStart` and `razorbill.autoStart` start nothing from a container: they start a server only at an address on mm's own machine. Start the server on the host instead, listening on every interface (`llama-server --host 0.0.0.0`, `rzb serve --host 0.0.0.0`).
72 74
73 - **`llamacpp`**: on Linux, start llama-server with `--host 0.0.0.0`, as it listens on the loopback only by default (see the last point). Files written before v1.1.0 may say `fallback: ""`: remove that line.75 - **`llamacpp`**: on Linux, start llama-server with `--host 0.0.0.0`, as it listens on the loopback only by default (see the last point). Files written before v1.1.0 may say `fallback: ""`: remove that line.
74 - **An agent file with a `baseUrl` on `localhost` or `127.0.0.1`:** replace the host with `host.docker.internal`, or add a `fallback`.76 - **An agent file with a `baseUrl` on `localhost` or `127.0.0.1`:** replace the host with `host.docker.internal`, or add a `fallback`.
added docs/en/how-to/run-with-razorbill.md +52 -0
new file mode 100644
@@ -0,0 +1,52 @@
1+# How to run mini-me on razorbill
2+
3+This guide shows how to point `mm` at razorbill, an MLX model server for Apple Silicon Macs (command `rzb`, no Python), through its OpenAI-compatible endpoint, and how to let `mm` start and stop it. It assumes `rzb` is built and installed on the Mac (razorbill's `scripts/install.sh` puts it in `/usr/local/bin`) and that you know how to build `mm`.
4+
5+## Steps
6+
7+1. Download a model and start the server. `rzb serve` listens on `127.0.0.1:7920` and loads a model on the first request that names it:
8+
9+ ```bash
10+ rzb models pull mlx-community/Qwen3-4B-4bit
11+ rzb serve
12+ ```
13+
14+2. Write the agent file:
15+
16+ ```yaml
17+ provider: razorbill
18+ model: mlx-community/Qwen3-4B-4bit
19+ ```
20+
21+3. Run `mm` with it and check the banner: `provider: razorbill`. rzb does not report the context window, so the banner says `ctx: unknown`. Set `contextWindow:` to the model's window if you want compaction to be based on it.
22+
23+## Let mm start rzb
24+
25+With `autoStart`, you skip step 1's `rzb serve`: when nothing answers at the agent's address, `mm` starts `rzb serve` there, downloads the model with `rzb models pull` when rzb does not list it, and stops the server when the last `mm` session that uses it exits.
26+
27+```yaml
28+provider: razorbill
29+model: mlx-community/Qwen3-4B-4bit
30+razorbill:
31+ autoStart: true
32+ # config: rzb-server.yaml # rzb serve --config, relative to this file
33+```
34+
35+- **On the Mac only.** rzb runs on macOS (Apple Silicon). The start works only when `mm` itself runs on the Mac. It does not work when `mm` runs in a container or a Docker sandbox: there `mm` starts nothing, and prints `[warning: razorbill.autoStart: rzb runs on macOS only …]` when no server answers. Start `rzb` on the Mac yourself in that case (see the next section).
36+- **Your own server is left alone.** A server you started yourself (for example `rzb serve` in a terminal) is used as is and never stopped.
37+- **Shared between sessions.** Several `mm` sessions on the same address share one server. The output of `rzb serve` and of `rzb models pull` goes to `~/Library/Caches/mm/rzb/127.0.0.1-7920/rzb.log`.
38+- **Another binary or settings.** `server:` names the `rzb` executable (default: `rzb` on the `PATH`, then `/usr/local/bin/rzb`). `config:` is rzb's server configuration (declared models, defaults, limits). `serverArgs:` adds any other flag. `startTimeout:` (default `15m`) bounds the start and the download.
39+
40+## Variants
41+
42+- **From a container or a Docker sandbox.** Start rzb on the Mac on every interface, with a key since it is then reachable from your network: `RZB_API_KEY=… rzb serve --host 0.0.0.0`. With no `baseUrl` answering, `mm` falls back to `http://host.docker.internal:7920/v1` by itself. Export the same key in `RZB_API_KEY` where `mm` runs. In a sandbox, allow `localhost:7920` in the network policy.
43+- **A protected server.** rzb checks `Authorization: Bearer` on every route but `/health` when its `RZB_API_KEY` is set. `mm` reads `RZB_API_KEY` too (or the variable named under `apiKeyEnv`). A refused key is a start-up warning naming the variable.
44+- **Another model.** Set `model:` to an id exactly as `GET /v1/models` lists it (`curl -s localhost:7920/v1/models`): a Hugging Face id in MLX format, or a short name declared in rzb's configuration. A model rzb does not list is a start-up warning, `model "…" is not downloaded — rzb models pull …`: the first question would download it, and the watchdog may give up before the download ends.
45+- **Write the file with the wizard.** `mm init --provider razorbill` lists the server's models and, on this machine, asks whether `mm` should start rzb (`--autostart`, default yes). See [How to create an agent](create-an-agent.md).
46+- **Reasoning.** rzb obeys `chat_template_kwargs.enable_thinking`, and it wins over `reasoning_effort`. See [How to turn a model's reasoning off](turn-reasoning-off.md).
47+- **Memory.** rzb unloads an idle model itself (its `keep_alive`, 10 minutes by default). It has no unload route, so `/unload` and the `unload_model` tool cannot free it sooner.
48+
49+## See also
50+
51+- The `razorbill` keys: [configuration reference](../reference/configuration.md).
52+- Why each server has its own provider entry: [providers](../explanation/providers.md).
new file mode 100644
@@ -0,0 +1,52 @@
1+# How to run mini-me on razorbill
2+
3+This guide shows how to point `mm` at razorbill, an MLX model server for Apple Silicon Macs (command `rzb`, no Python), through its OpenAI-compatible endpoint, and how to let `mm` start and stop it. It assumes `rzb` is built and installed on the Mac (razorbill's `scripts/install.sh` puts it in `/usr/local/bin`) and that you know how to build `mm`.
4+
5+## Steps
6+
7+1. Download a model and start the server. `rzb serve` listens on `127.0.0.1:7920` and loads a model on the first request that names it:
8+
9+ ```bash
10+ rzb models pull mlx-community/Qwen3-4B-4bit
11+ rzb serve
12+ ```
13+
14+2. Write the agent file:
15+
16+ ```yaml
17+ provider: razorbill
18+ model: mlx-community/Qwen3-4B-4bit
19+ ```
20+
21+3. Run `mm` with it and check the banner: `provider: razorbill`. rzb does not report the context window, so the banner says `ctx: unknown`. Set `contextWindow:` to the model's window if you want compaction to be based on it.
22+
23+## Let mm start rzb
24+
25+With `autoStart`, you skip step 1's `rzb serve`: when nothing answers at the agent's address, `mm` starts `rzb serve` there, downloads the model with `rzb models pull` when rzb does not list it, and stops the server when the last `mm` session that uses it exits.
26+
27+```yaml
28+provider: razorbill
29+model: mlx-community/Qwen3-4B-4bit
30+razorbill:
31+ autoStart: true
32+ # config: rzb-server.yaml # rzb serve --config, relative to this file
33+```
34+
35+- **On the Mac only.** rzb runs on macOS (Apple Silicon). The start works only when `mm` itself runs on the Mac. It does not work when `mm` runs in a container or a Docker sandbox: there `mm` starts nothing, and prints `[warning: razorbill.autoStart: rzb runs on macOS only …]` when no server answers. Start `rzb` on the Mac yourself in that case (see the next section).
36+- **Your own server is left alone.** A server you started yourself (for example `rzb serve` in a terminal) is used as is and never stopped.
37+- **Shared between sessions.** Several `mm` sessions on the same address share one server. The output of `rzb serve` and of `rzb models pull` goes to `~/Library/Caches/mm/rzb/127.0.0.1-7920/rzb.log`.
38+- **Another binary or settings.** `server:` names the `rzb` executable (default: `rzb` on the `PATH`, then `/usr/local/bin/rzb`). `config:` is rzb's server configuration (declared models, defaults, limits). `serverArgs:` adds any other flag. `startTimeout:` (default `15m`) bounds the start and the download.
39+
40+## Variants
41+
42+- **From a container or a Docker sandbox.** Start rzb on the Mac on every interface, with a key since it is then reachable from your network: `RZB_API_KEY=… rzb serve --host 0.0.0.0`. With no `baseUrl` answering, `mm` falls back to `http://host.docker.internal:7920/v1` by itself. Export the same key in `RZB_API_KEY` where `mm` runs. In a sandbox, allow `localhost:7920` in the network policy.
43+- **A protected server.** rzb checks `Authorization: Bearer` on every route but `/health` when its `RZB_API_KEY` is set. `mm` reads `RZB_API_KEY` too (or the variable named under `apiKeyEnv`). A refused key is a start-up warning naming the variable.
44+- **Another model.** Set `model:` to an id exactly as `GET /v1/models` lists it (`curl -s localhost:7920/v1/models`): a Hugging Face id in MLX format, or a short name declared in rzb's configuration. A model rzb does not list is a start-up warning, `model "…" is not downloaded — rzb models pull …`: the first question would download it, and the watchdog may give up before the download ends.
45+- **Write the file with the wizard.** `mm init --provider razorbill` lists the server's models and, on this machine, asks whether `mm` should start rzb (`--autostart`, default yes). See [How to create an agent](create-an-agent.md).
46+- **Reasoning.** rzb obeys `chat_template_kwargs.enable_thinking`, and it wins over `reasoning_effort`. See [How to turn a model's reasoning off](turn-reasoning-off.md).
47+- **Memory.** rzb unloads an idle model itself (its `keep_alive`, 10 minutes by default). It has no unload route, so `/unload` and the `unload_model` tool cannot free it sooner.
48+
49+## See also
50+
51+- The `razorbill` keys: [configuration reference](../reference/configuration.md).
52+- Why each server has its own provider entry: [providers](../explanation/providers.md).
modified docs/en/how-to/turn-reasoning-off.md +2 -2
@@ -8,7 +8,7 @@ A thinking model (Qwen3.5, Qwen3.x, gpt-oss…) reasons before it answers. On a
88
99 2. Add the server's own switch under `sampling`.
1010
11- For `dmr`, `llamacpp`, `llmman` or `kronk` — all llama.cpp underneath:
11+ For `dmr`, `llamacpp`, `llmman` or `kronk` — all llama.cpp underneath — and for `razorbill`, where `enable_thinking` wins over `reasoning_effort` (measured on rzb 0.2.0):
1212
1313 ```yaml
1414 sampling:
@@ -72,7 +72,7 @@ A thinking model (Qwen3.5, Qwen3.x, gpt-oss…) reasons before it answers. On a
7272 - On `ollama`, `reasoning_effort` goes at the top level of `sampling`, not under `chat_template_kwargs`; only `none` has been measured there.
7373 - Compaction summaries do not follow it — see below.
7474 - **Turn it off for one run.** Keep two configuration files, or start the server itself without reasoning (for llama-server, see its `--reasoning-budget` option).
75-- **Compaction summaries.** Nothing to do: `mm` turns reasoning off for the summary of `/compact` and of the automatic compression, whatever `sampling` says. On `dmr`, `llamacpp`, `llmman` and `kronk` it sets `enable_thinking: false` in `chat_template_kwargs`, keeps your other template variables, and lowers a `reasoning_effort` you set there to `low` — gpt-oss's template has no "off", so a summary from that model still reasons a little and that counts against `context.summaryMaxTokens`. On `ollama` it sends `reasoning_effort: none`. On `mlxserve` it does both.
75+- **Compaction summaries.** Nothing to do: `mm` turns reasoning off for the summary of `/compact` and of the automatic compression, whatever `sampling` says. On `dmr`, `llamacpp`, `llmman`, `kronk` and `razorbill` it sets `enable_thinking: false` in `chat_template_kwargs`, keeps your other template variables, and lowers a `reasoning_effort` you set there to `low` — gpt-oss's template has no "off", so a summary from that model still reasons a little and that counts against `context.summaryMaxTokens`. On `ollama` it sends `reasoning_effort: none`. On `mlxserve` it does both.
7676
7777 ## See also
7878
@@ -8,7 +8,7 @@ A thinking model (Qwen3.5, Qwen3.x, gpt-oss…) reasons before it answers. On a
8 8
9 2. Add the server's own switch under `sampling`.9 2. Add the server's own switch under `sampling`.
10 10
11- For `dmr`, `llamacpp`, `llmman` or `kronk` — all llama.cpp underneath:11+ For `dmr`, `llamacpp`, `llmman` or `kronk` — all llama.cpp underneath — and for `razorbill`, where `enable_thinking` wins over `reasoning_effort` (measured on rzb 0.2.0):
12 12
13 ```yaml13 ```yaml
14 sampling:14 sampling:
@@ -72,7 +72,7 @@ A thinking model (Qwen3.5, Qwen3.x, gpt-oss…) reasons before it answers. On a
72 - On `ollama`, `reasoning_effort` goes at the top level of `sampling`, not under `chat_template_kwargs`; only `none` has been measured there.72 - On `ollama`, `reasoning_effort` goes at the top level of `sampling`, not under `chat_template_kwargs`; only `none` has been measured there.
73 - Compaction summaries do not follow it — see below.73 - Compaction summaries do not follow it — see below.
74 - **Turn it off for one run.** Keep two configuration files, or start the server itself without reasoning (for llama-server, see its `--reasoning-budget` option).74 - **Turn it off for one run.** Keep two configuration files, or start the server itself without reasoning (for llama-server, see its `--reasoning-budget` option).
75-- **Compaction summaries.** Nothing to do: `mm` turns reasoning off for the summary of `/compact` and of the automatic compression, whatever `sampling` says. On `dmr`, `llamacpp`, `llmman` and `kronk` it sets `enable_thinking: false` in `chat_template_kwargs`, keeps your other template variables, and lowers a `reasoning_effort` you set there to `low` — gpt-oss's template has no "off", so a summary from that model still reasons a little and that counts against `context.summaryMaxTokens`. On `ollama` it sends `reasoning_effort: none`. On `mlxserve` it does both.75+- **Compaction summaries.** Nothing to do: `mm` turns reasoning off for the summary of `/compact` and of the automatic compression, whatever `sampling` says. On `dmr`, `llamacpp`, `llmman`, `kronk` and `razorbill` it sets `enable_thinking: false` in `chat_template_kwargs`, keeps your other template variables, and lowers a `reasoning_effort` you set there to `low` — gpt-oss's template has no "off", so a summary from that model still reasons a little and that counts against `context.summaryMaxTokens`. On `ollama` it sends `reasoning_effort: none`. On `mlxserve` it does both.
76 76
77 ## See also77 ## See also
78 78
modified docs/en/reference/cli.md +3 -3
@@ -90,7 +90,7 @@ The rule depends on where the file is, not on how it was found: `-config`, `AGEN
9090 | `MM_BIN` | Set by `mm` in its own environment, so every process it starts inherits it — the commands its `bash` tool runs, its hooks: the path of the running `mm` binary. |
9191 | `MM_CONFIG` | Set by `mm` in its own environment, like `MM_BIN`, when a configuration file was read: the absolute path of its configuration file. Read by `--ask` / `--ask-with-context` when no `-config` and no positional path are given. |
9292 | `MM_ASK_DEPTH` | How many `/ask` levels deep this agent runs (unset = 0). Set by `/ask`; at 2, `/ask` is refused. |
93-| Variable named by `apiKeyEnv` | Holds the API key. Default name: none for `dmr`, `LLAMA_API_KEY` for `llamacpp`, `LLMMAN_API_KEY` for `llmman`, `OLLAMA_API_KEY` for `ollama`, `KRONK_TOKEN` for `kronk`, `MLX_SERVE_API_KEY` for `mlxserve`. |
93+| Variable named by `apiKeyEnv` | Holds the API key. Default name: none for `dmr`, `LLAMA_API_KEY` for `llamacpp`, `LLMMAN_API_KEY` for `llmman`, `OLLAMA_API_KEY` for `ollama`, `KRONK_TOKEN` for `kronk`, `MLX_SERVE_API_KEY` for `mlxserve`, `RZB_API_KEY` for `razorbill`. |
9494
9595 ## Start-up output
9696
@@ -267,7 +267,7 @@ An agent file outside the workspace only gives a warning: see [when the agent fi
267267 | Flag | Question when absent | Default |
268268 |------|----------------------|---------|
269269 | `--project yes\|no` | Keep everything in a `.mm` folder? — asked first. `yes`: the file is `.mm/agent.yaml` (the folder is created), its paths are written from the project root (`skillsDir: .mm/skills`), and `mm` / `mm tui` started there find it with no argument | `no` |
270-| `--provider` | Model server: `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `openai`, `openai-responses` | the first local one whose server answers, in that order (`llamacpp` on 9931, then 8080), else `llamacpp` (`openai` and `openai-responses` are never probed: their default address is the OpenAI API) |
270+| `--provider` | Model server: `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `razorbill`, `openai`, `openai-responses` | the first local one whose server answers, in that order (`llamacpp` on 9931, then 8080), else `llamacpp` (`openai` and `openai-responses` are never probed: their default address is the OpenAI API) |
271271 | `--base-url` | `openai` and `openai-responses` only: Endpoint — the service's OpenAI-compatible address (OpenAI, Cerebras, Hugging Face…); for the other providers, not asked | `https://api.openai.com/v1` for `openai` and `openai-responses`; otherwise `AGENT_BASE_URL` when set, else the first of the provider's local addresses whose model list answers — its default, then the same with `127.0.0.1` when the default names `localhost`, then for `llamacpp` llama-server's former port, `http://127.0.0.1:8080/v1` — and its container fallback (`host.docker.internal`) only when none does. The model question names the address its list comes from (`Model? (listed from …)`). Written as `baseUrl` unless it is the default |
272272 | `--api-key-env` | `openai` and `openai-responses` only: Environment variable that holds the API key | `OPENAI_API_KEY`. Written as `apiKeyEnv` unless it is the default |
273273 | `--model` | Model: a list of the server's models (`/api/tags` for llmman and Ollama, `/models` for the others; 5 s for a local server, 20 s for `openai`), or a name to type when there is no list — the question says why (`<VARIABLE> is not set: no list`, or the server's error). For `openai` the list is asked with the key read from the variable named above, and not asked at all when that variable is empty | the first of the list |
@@ -277,7 +277,7 @@ An agent file outside the workspace only gives a warning: see [when the agent fi
277277 | `--yolo yes\|no` | Ask before each command or file change? — only for usages with `bash`, file tools or `fetch_content` | the usage's |
278278 | `--sessions yes\|no` | Save the conversations? | `no`; `yes`: a `sessions` section (`enabled: true`, `dir: .mm/sessions`); `no`: no section, mm's default (off) applies |
279279 | `--skills yes\|no` | Use skills? | `no` (`skillsDir: no-skills`); `yes`: `skillsDir: skills`, or `.mm/skills` with `--project yes`, and the folder is created next to the project root once the file is written |
280-| `--autostart yes\|no` | Let mm start llama-server when it is not running? (llamacpp on this machine only) | `yes` (`llamacpp.autoStart: true`); `no`: `autoStart: false`, you start the server |
280+| `--autostart yes\|no` | Let mm start llama-server (llamacpp) or rzb (razorbill) when it is not running? (those two providers, on this machine only) | `yes` (`llamacpp.autoStart: true`, `razorbill.autoStart: true`); `no`: `autoStart: false`, you start the server |
281281 | `--launch-settings yes\|no` | Write llama-server's launch settings? (with `--autostart yes` only) | `no` (llama-server's defaults); `yes`: the Llama app's values — `modelsMax: 0`, `modelsMemoryMargin: 1024`, `fitTarget: 1024`, `sleepIdleSeconds: 300`, `specDefault: true` |
282282 | `--name` | Agent name (`acp.name`) | the usage's name |
283283 | `-o`, `--output` | File to write (`-` = stdout: nothing is created, whatever the other answers). With `--project yes`, a file that is not directly in a `.mm` folder is refused | `agent.yaml`; `.mm/agent.yaml` with `--project yes` |
@@ -90,7 +90,7 @@ The rule depends on where the file is, not on how it was found: `-config`, `AGEN
90 | `MM_BIN` | Set by `mm` in its own environment, so every process it starts inherits it — the commands its `bash` tool runs, its hooks: the path of the running `mm` binary. |90 | `MM_BIN` | Set by `mm` in its own environment, so every process it starts inherits it — the commands its `bash` tool runs, its hooks: the path of the running `mm` binary. |
91 | `MM_CONFIG` | Set by `mm` in its own environment, like `MM_BIN`, when a configuration file was read: the absolute path of its configuration file. Read by `--ask` / `--ask-with-context` when no `-config` and no positional path are given. |91 | `MM_CONFIG` | Set by `mm` in its own environment, like `MM_BIN`, when a configuration file was read: the absolute path of its configuration file. Read by `--ask` / `--ask-with-context` when no `-config` and no positional path are given. |
92 | `MM_ASK_DEPTH` | How many `/ask` levels deep this agent runs (unset = 0). Set by `/ask`; at 2, `/ask` is refused. |92 | `MM_ASK_DEPTH` | How many `/ask` levels deep this agent runs (unset = 0). Set by `/ask`; at 2, `/ask` is refused. |
93-| Variable named by `apiKeyEnv` | Holds the API key. Default name: none for `dmr`, `LLAMA_API_KEY` for `llamacpp`, `LLMMAN_API_KEY` for `llmman`, `OLLAMA_API_KEY` for `ollama`, `KRONK_TOKEN` for `kronk`, `MLX_SERVE_API_KEY` for `mlxserve`. |93+| Variable named by `apiKeyEnv` | Holds the API key. Default name: none for `dmr`, `LLAMA_API_KEY` for `llamacpp`, `LLMMAN_API_KEY` for `llmman`, `OLLAMA_API_KEY` for `ollama`, `KRONK_TOKEN` for `kronk`, `MLX_SERVE_API_KEY` for `mlxserve`, `RZB_API_KEY` for `razorbill`. |
94 94
95 ## Start-up output95 ## Start-up output
96 96
@@ -267,7 +267,7 @@ An agent file outside the workspace only gives a warning: see [when the agent fi
267 | Flag | Question when absent | Default |267 | Flag | Question when absent | Default |
268 |------|----------------------|---------|268 |------|----------------------|---------|
269 | `--project yes\|no` | Keep everything in a `.mm` folder? — asked first. `yes`: the file is `.mm/agent.yaml` (the folder is created), its paths are written from the project root (`skillsDir: .mm/skills`), and `mm` / `mm tui` started there find it with no argument | `no` |269 | `--project yes\|no` | Keep everything in a `.mm` folder? — asked first. `yes`: the file is `.mm/agent.yaml` (the folder is created), its paths are written from the project root (`skillsDir: .mm/skills`), and `mm` / `mm tui` started there find it with no argument | `no` |
270-| `--provider` | Model server: `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `openai`, `openai-responses` | the first local one whose server answers, in that order (`llamacpp` on 9931, then 8080), else `llamacpp` (`openai` and `openai-responses` are never probed: their default address is the OpenAI API) |270+| `--provider` | Model server: `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `razorbill`, `openai`, `openai-responses` | the first local one whose server answers, in that order (`llamacpp` on 9931, then 8080), else `llamacpp` (`openai` and `openai-responses` are never probed: their default address is the OpenAI API) |
271 | `--base-url` | `openai` and `openai-responses` only: Endpoint — the service's OpenAI-compatible address (OpenAI, Cerebras, Hugging Face…); for the other providers, not asked | `https://api.openai.com/v1` for `openai` and `openai-responses`; otherwise `AGENT_BASE_URL` when set, else the first of the provider's local addresses whose model list answers — its default, then the same with `127.0.0.1` when the default names `localhost`, then for `llamacpp` llama-server's former port, `http://127.0.0.1:8080/v1` — and its container fallback (`host.docker.internal`) only when none does. The model question names the address its list comes from (`Model? (listed from …)`). Written as `baseUrl` unless it is the default |271 | `--base-url` | `openai` and `openai-responses` only: Endpoint — the service's OpenAI-compatible address (OpenAI, Cerebras, Hugging Face…); for the other providers, not asked | `https://api.openai.com/v1` for `openai` and `openai-responses`; otherwise `AGENT_BASE_URL` when set, else the first of the provider's local addresses whose model list answers — its default, then the same with `127.0.0.1` when the default names `localhost`, then for `llamacpp` llama-server's former port, `http://127.0.0.1:8080/v1` — and its container fallback (`host.docker.internal`) only when none does. The model question names the address its list comes from (`Model? (listed from …)`). Written as `baseUrl` unless it is the default |
272 | `--api-key-env` | `openai` and `openai-responses` only: Environment variable that holds the API key | `OPENAI_API_KEY`. Written as `apiKeyEnv` unless it is the default |272 | `--api-key-env` | `openai` and `openai-responses` only: Environment variable that holds the API key | `OPENAI_API_KEY`. Written as `apiKeyEnv` unless it is the default |
273 | `--model` | Model: a list of the server's models (`/api/tags` for llmman and Ollama, `/models` for the others; 5 s for a local server, 20 s for `openai`), or a name to type when there is no list — the question says why (`<VARIABLE> is not set: no list`, or the server's error). For `openai` the list is asked with the key read from the variable named above, and not asked at all when that variable is empty | the first of the list |273 | `--model` | Model: a list of the server's models (`/api/tags` for llmman and Ollama, `/models` for the others; 5 s for a local server, 20 s for `openai`), or a name to type when there is no list — the question says why (`<VARIABLE> is not set: no list`, or the server's error). For `openai` the list is asked with the key read from the variable named above, and not asked at all when that variable is empty | the first of the list |
@@ -277,7 +277,7 @@ An agent file outside the workspace only gives a warning: see [when the agent fi
277 | `--yolo yes\|no` | Ask before each command or file change? — only for usages with `bash`, file tools or `fetch_content` | the usage's |277 | `--yolo yes\|no` | Ask before each command or file change? — only for usages with `bash`, file tools or `fetch_content` | the usage's |
278 | `--sessions yes\|no` | Save the conversations? | `no`; `yes`: a `sessions` section (`enabled: true`, `dir: .mm/sessions`); `no`: no section, mm's default (off) applies |278 | `--sessions yes\|no` | Save the conversations? | `no`; `yes`: a `sessions` section (`enabled: true`, `dir: .mm/sessions`); `no`: no section, mm's default (off) applies |
279 | `--skills yes\|no` | Use skills? | `no` (`skillsDir: no-skills`); `yes`: `skillsDir: skills`, or `.mm/skills` with `--project yes`, and the folder is created next to the project root once the file is written |279 | `--skills yes\|no` | Use skills? | `no` (`skillsDir: no-skills`); `yes`: `skillsDir: skills`, or `.mm/skills` with `--project yes`, and the folder is created next to the project root once the file is written |
280-| `--autostart yes\|no` | Let mm start llama-server when it is not running? (llamacpp on this machine only) | `yes` (`llamacpp.autoStart: true`); `no`: `autoStart: false`, you start the server |280+| `--autostart yes\|no` | Let mm start llama-server (llamacpp) or rzb (razorbill) when it is not running? (those two providers, on this machine only) | `yes` (`llamacpp.autoStart: true`, `razorbill.autoStart: true`); `no`: `autoStart: false`, you start the server |
281 | `--launch-settings yes\|no` | Write llama-server's launch settings? (with `--autostart yes` only) | `no` (llama-server's defaults); `yes`: the Llama app's values — `modelsMax: 0`, `modelsMemoryMargin: 1024`, `fitTarget: 1024`, `sleepIdleSeconds: 300`, `specDefault: true` |281 | `--launch-settings yes\|no` | Write llama-server's launch settings? (with `--autostart yes` only) | `no` (llama-server's defaults); `yes`: the Llama app's values — `modelsMax: 0`, `modelsMemoryMargin: 1024`, `fitTarget: 1024`, `sleepIdleSeconds: 300`, `specDefault: true` |
282 | `--name` | Agent name (`acp.name`) | the usage's name |282 | `--name` | Agent name (`acp.name`) | the usage's name |
283 | `-o`, `--output` | File to write (`-` = stdout: nothing is created, whatever the other answers). With `--project yes`, a file that is not directly in a `.mm` folder is refused | `agent.yaml`; `.mm/agent.yaml` with `--project yes` |283 | `-o`, `--output` | File to write (`-` = stdout: nothing is created, whatever the other answers). With `--project yes`, a file that is not directly in a `.mm` folder is refused | `agent.yaml`; `.mm/agent.yaml` with `--project yes` |
modified docs/en/reference/configuration.md +4 -2
@@ -8,7 +8,7 @@ Where `mm` looks for this file: [Configuration file resolution](cli.md#configura
88
99 | Key | Type | Default | Description |
1010 |-----|------|---------|-------------|
11-| `provider` | string | `dmr` | Registry key of the LLM server: `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `openai` for any other OpenAI-compatible server (see [How to use any OpenAI-compatible server](../how-to/run-with-an-openai-compatible-server.md)), or `openai-responses` for the same servers through OpenAI's Responses API (see [How to keep reasoning and tools together with OpenAI's Responses API](../how-to/use-the-openai-responses-api.md)). Overridden by `AGENT_PROVIDER`. |
11+| `provider` | string | `dmr` | Registry key of the LLM server: `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `razorbill`, `openai` for any other OpenAI-compatible server (see [How to use any OpenAI-compatible server](../how-to/run-with-an-openai-compatible-server.md)), or `openai-responses` for the same servers through OpenAI's Responses API (see [How to keep reasoning and tools together with OpenAI's Responses API](../how-to/use-the-openai-responses-api.md)). Overridden by `AGENT_PROVIDER`. |
1212 | `model` | string | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Model identifier in the provider's naming. Overridden by `AGENT_MODEL`. |
1313 | `baseUrl` | string | `""` (provider default) | OpenAI-compatible endpoint tried first. Overridden by `AGENT_BASE_URL`. |
1414 | `fallback` | string or absent | absent (provider default) | Endpoint used when `baseUrl` does not answer `/models` within 2 s. Absent = provider default; `""` = no fallback. |
@@ -40,6 +40,7 @@ Where `mm` looks for this file: [Configuration file resolution](cli.md#configura
4040 | `unloadModels` | bool | `true` | The `/unload [model]` command (terminal, window, editor) and the `unload_model` tool, which free a model from the server's memory: llmman and Ollama, Kronk, llama-server in router mode. `false` removes both. The tool is never declared beside a `structuredOutput` or a `decision` block. See [tools](tools.md#unload_model) and [How to free a model's memory](../how-to/unload-a-model.md). |
4141 | `unloadOnExit` | bool | `true` | When mm exits — `/quit`, Ctrl-C at the prompt, Ctrl-D, the window closed, the end of a `-p` run, the editor closing the ACP session, SIGTERM, SIGHUP — unload the agent's model from the server's memory, so it does not keep its RAM after the session. One `🧹` line on stderr (none in ACP mode); nothing when the model was not loaded or the server cannot unload (dmr, openai, a single-model llama-server). Bounded to 3 s: a server that does not answer never holds the exit. Only the agent's own model — not the decision models, not the `mmConfigs` agents (each unloads its own when it stops). `false`: the model stays loaded (faster next start, or another session or tool uses it — mm does not know who else uses it). Independent of `unloadModels`. Overridden by `AGENT_UNLOAD_ON_EXIT`. See [How to free a model's memory](../how-to/unload-a-model.md#when-mm-exits). |
4242 | `llamacpp` | `{autoStart, server, ctxSize, modelsMax, modelsMemoryMargin, fitTarget, sleepIdleSeconds, specDefault, serverArgs, startTimeout}` | `autoStart: false` | Provider `llamacpp` only. `autoStart: true`: when nothing answers at the agent's address (a loopback one, `AGENT_BASE_URL` unset) nor on 8080 nor at the `fallback`, mm starts llama-server in router mode with the agent's model (downloaded on first load), waits until it is loaded, and stops it with the last mm session using it; a server mm did not start is never stopped. `server`: the executable (default `llama-server`, then `llama serve`, on the `PATH`). Launch settings, each one optional, each one a llama-server flag (absent = llama-server's default): `ctxSize` (`--ctx-size`), `modelsMax` (`--models-max`), `modelsMemoryMargin` (`--models-memory-margin`), `fitTarget` (`--fit-target`), `sleepIdleSeconds` (`--sleep-idle-seconds`, `-1` allowed), `specDefault` (`--spec-default`); a negative value is a configuration error. `serverArgs`: any other flag, added last. `startTimeout` (default `15m`): start, download and load. Registry and log: `<user cache dir>/mm/llama-server/<host>-<port>/`. `mm init` asks for a llamacpp agent on this machine (`--autostart`, default yes; `--launch-settings`, the Llama app's values, default no). See [Let mm start llama-server](../how-to/run-with-llama-cpp.md#let-mm-start-llama-server). |
43+| `razorbill` | `{autoStart, server, config, serverArgs, startTimeout}` | `autoStart: false` | Provider `razorbill` only. `autoStart: true`: when nothing answers at the agent's address (a loopback one, `AGENT_BASE_URL` unset) nor at the `fallback`, mm starts `rzb serve --host <host> --port <port>`, runs `rzb models pull <model>` when the server does not list the model, and stops the server with the last mm session using it; a server mm did not start is never stopped. macOS only: elsewhere — mm in a container or a sandbox — nothing is started and a warning says so. `server`: the `rzb` executable (default `rzb` on the `PATH`, then `/usr/local/bin/rzb`). `config`: rzb's server configuration, passed as `--config`; a relative path is relative to the agent file's directory, `~/` is the home directory; a missing file is a start error. `serverArgs`: any other `rzb serve` flag, added last. `startTimeout` (default `15m`, negative = configuration error): start and download. Registry and log (`rzb.log`, also the pull's output): `<user cache dir>/mm/rzb/<host>-<port>/`. `mm init` asks for a razorbill agent on this machine (`--autostart`, default yes). See [Let mm start rzb](../how-to/run-with-razorbill.md#let-mm-start-rzb). |
4344 | `autoPull` | bool | `false` | At start-up, download the models this agent will use and the server does not list: its own, its `mmConfigs` agents', its `skillRouting` / `toolRouting` deciders'. The progress goes to stderr — one line rewritten in place on a terminal (`⬇ pulling <model> — 52 MB / 145 MB (35 %)`), a line per tenth elsewhere — then `⬇ pulled <model> in 0.8s`. The agent's own model failing stops `mm` with the server's message (`[engine error: autoPull: <model>: the server says: …]`); another model failing, a server that does not answer, or a provider that cannot pull is a `[warning: autoPull: …]`. An agent started by `/ask` or `ask_agent` pulls nothing; `mm --ask` pulls nothing either. A model the server already lists is never pulled (a name without a tag also matches its `:latest` entry). By provider: `llmman` and `ollama` — `POST /api/pull`; `kronk` — `POST /v1/kronk/models/pull`, the pull counting as done only when Kronk's stream ends with `"downloaded": true` (Kronk answers 200 to a failed pull; its last status is then the message); `dmr` — `POST /models/create` on the runner (the base URL without `/engines/…`), the pull counting as done once the runner lists the model; `llamacpp` — no download over the API: the warning says to start llama-server with `-hf <repo>:<quant>`, or to put the GGUF in the router's models directory; `openai` — a warning. |
4445 | `sampling` | map | `temperature: 0.0`, `top_p: 0.9`, `max_tokens: 4096` | Generation settings, OpenAI API key names, passed to the server. The file's block is merged with these defaults: a default the file does not name is still sent. **Except with `provider: openai` and `provider: openai-responses`**: the request carries exactly the file's block, nothing added (no block: no sampling key, the server's defaults apply) — the hosted OpenAI reasoning models refuse `max_tokens` and accept only the default temperature, so a default left in would be a 400. A key the OpenAI API does not declare is sent as it is, at the top level of the request — for example `chat_template_kwargs: {enable_thinking: false}`, which tells a llama.cpp server (`dmr`, `llamacpp`, `llmman`) or Kronk not to reason; `reasoning_effort: none` does the same on Ollama. `messages`, `tools`, `tool_choice` (and the legacy `functions`, `function_call`) are ignored: Genkit builds them from the conversation. The shipped `agent.yaml` adds `parallel_tool_calls: false`. `max_tokens` also bounds one tool call: a `write_file` of a long document (or a thinking model's reasoning plus the call) can hit it, and the call is then cut off. mm hands it back to the model twice, asking for smaller pieces, then stops with `the model hit max_tokens (N) while writing a tool call`; raise the value if that happens. A config that names the limit `max_completion_tokens` (the OpenAI API's name for its newer models) is read the same way: that name is used in this message and for the summary request of the context compression. With streaming, mm also asks the server for token counts (`stream_options.include_usage`). |
4546 | `watchdogTimeout` | duration | `20s` | Silence tolerated between two streamed tokens before the connection is declared hung. Doubled for summary requests. |
@@ -259,6 +260,7 @@ workspace:
259260 | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | no |
260261 | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | no — only Kronk's `authenticated` and `full-protected` modes check it |
261262 | `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | no — only a server started with `--api-key` checks it, and not for localhost |
263+| `razorbill` | `http://127.0.0.1:7920/v1` | `http://host.docker.internal:7920/v1` | `RZB_API_KEY` | no — only a server whose `RZB_API_KEY` is set checks it |
262264 | `openai` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — a server that needs one answers 401, and the start-up warning names the variable |
263265 | `openai-responses` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — as `openai` |
264266
@@ -533,7 +535,7 @@ Reported on stderr as `[config error: <path>: <message>]`, exit code 1 — in ev
533535 | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | a name starting with `with-context` |
534536 | `mmConfigs.<name>: the path must not be empty` | `<name>: ""`, or a long form without `path` |
535537 | `hooks: unknown event "x" (…)`, `hooks.<event>[N]: …` | an invalid `hooks:` block — see [hooks](hooks.md#validation-errors) |
536-| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses)` | Reported by the engine, as `[engine error: …]`. |
538+| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses, razorbill)` | Reported by the engine, as `[engine error: …]`. |
537539
538540 A start-up warning, not an error, is printed when `context.enabled` is `true`, the window is unknown and `context.maxMessages` is `0`, and when a declared tool has the name of an MCP tool (`tools: <name> skipped — an MCP tool already has that name`; the tool is not declared), and when the file sets the deprecated `permissions` key (`permissions: ask is deprecated — use yolo: false instead …`).
539541
@@ -8,7 +8,7 @@ Where `mm` looks for this file: [Configuration file resolution](cli.md#configura
8 8
9 | Key | Type | Default | Description |9 | Key | Type | Default | Description |
10 |-----|------|---------|-------------|10 |-----|------|---------|-------------|
11-| `provider` | string | `dmr` | Registry key of the LLM server: `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `openai` for any other OpenAI-compatible server (see [How to use any OpenAI-compatible server](../how-to/run-with-an-openai-compatible-server.md)), or `openai-responses` for the same servers through OpenAI's Responses API (see [How to keep reasoning and tools together with OpenAI's Responses API](../how-to/use-the-openai-responses-api.md)). Overridden by `AGENT_PROVIDER`. |11+| `provider` | string | `dmr` | Registry key of the LLM server: `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `razorbill`, `openai` for any other OpenAI-compatible server (see [How to use any OpenAI-compatible server](../how-to/run-with-an-openai-compatible-server.md)), or `openai-responses` for the same servers through OpenAI's Responses API (see [How to keep reasoning and tools together with OpenAI's Responses API](../how-to/use-the-openai-responses-api.md)). Overridden by `AGENT_PROVIDER`. |
12 | `model` | string | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Model identifier in the provider's naming. Overridden by `AGENT_MODEL`. |12 | `model` | string | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Model identifier in the provider's naming. Overridden by `AGENT_MODEL`. |
13 | `baseUrl` | string | `""` (provider default) | OpenAI-compatible endpoint tried first. Overridden by `AGENT_BASE_URL`. |13 | `baseUrl` | string | `""` (provider default) | OpenAI-compatible endpoint tried first. Overridden by `AGENT_BASE_URL`. |
14 | `fallback` | string or absent | absent (provider default) | Endpoint used when `baseUrl` does not answer `/models` within 2 s. Absent = provider default; `""` = no fallback. |14 | `fallback` | string or absent | absent (provider default) | Endpoint used when `baseUrl` does not answer `/models` within 2 s. Absent = provider default; `""` = no fallback. |
@@ -40,6 +40,7 @@ Where `mm` looks for this file: [Configuration file resolution](cli.md#configura
40 | `unloadModels` | bool | `true` | The `/unload [model]` command (terminal, window, editor) and the `unload_model` tool, which free a model from the server's memory: llmman and Ollama, Kronk, llama-server in router mode. `false` removes both. The tool is never declared beside a `structuredOutput` or a `decision` block. See [tools](tools.md#unload_model) and [How to free a model's memory](../how-to/unload-a-model.md). |40 | `unloadModels` | bool | `true` | The `/unload [model]` command (terminal, window, editor) and the `unload_model` tool, which free a model from the server's memory: llmman and Ollama, Kronk, llama-server in router mode. `false` removes both. The tool is never declared beside a `structuredOutput` or a `decision` block. See [tools](tools.md#unload_model) and [How to free a model's memory](../how-to/unload-a-model.md). |
41 | `unloadOnExit` | bool | `true` | When mm exits — `/quit`, Ctrl-C at the prompt, Ctrl-D, the window closed, the end of a `-p` run, the editor closing the ACP session, SIGTERM, SIGHUP — unload the agent's model from the server's memory, so it does not keep its RAM after the session. One `🧹` line on stderr (none in ACP mode); nothing when the model was not loaded or the server cannot unload (dmr, openai, a single-model llama-server). Bounded to 3 s: a server that does not answer never holds the exit. Only the agent's own model — not the decision models, not the `mmConfigs` agents (each unloads its own when it stops). `false`: the model stays loaded (faster next start, or another session or tool uses it — mm does not know who else uses it). Independent of `unloadModels`. Overridden by `AGENT_UNLOAD_ON_EXIT`. See [How to free a model's memory](../how-to/unload-a-model.md#when-mm-exits). |41 | `unloadOnExit` | bool | `true` | When mm exits — `/quit`, Ctrl-C at the prompt, Ctrl-D, the window closed, the end of a `-p` run, the editor closing the ACP session, SIGTERM, SIGHUP — unload the agent's model from the server's memory, so it does not keep its RAM after the session. One `🧹` line on stderr (none in ACP mode); nothing when the model was not loaded or the server cannot unload (dmr, openai, a single-model llama-server). Bounded to 3 s: a server that does not answer never holds the exit. Only the agent's own model — not the decision models, not the `mmConfigs` agents (each unloads its own when it stops). `false`: the model stays loaded (faster next start, or another session or tool uses it — mm does not know who else uses it). Independent of `unloadModels`. Overridden by `AGENT_UNLOAD_ON_EXIT`. See [How to free a model's memory](../how-to/unload-a-model.md#when-mm-exits). |
42 | `llamacpp` | `{autoStart, server, ctxSize, modelsMax, modelsMemoryMargin, fitTarget, sleepIdleSeconds, specDefault, serverArgs, startTimeout}` | `autoStart: false` | Provider `llamacpp` only. `autoStart: true`: when nothing answers at the agent's address (a loopback one, `AGENT_BASE_URL` unset) nor on 8080 nor at the `fallback`, mm starts llama-server in router mode with the agent's model (downloaded on first load), waits until it is loaded, and stops it with the last mm session using it; a server mm did not start is never stopped. `server`: the executable (default `llama-server`, then `llama serve`, on the `PATH`). Launch settings, each one optional, each one a llama-server flag (absent = llama-server's default): `ctxSize` (`--ctx-size`), `modelsMax` (`--models-max`), `modelsMemoryMargin` (`--models-memory-margin`), `fitTarget` (`--fit-target`), `sleepIdleSeconds` (`--sleep-idle-seconds`, `-1` allowed), `specDefault` (`--spec-default`); a negative value is a configuration error. `serverArgs`: any other flag, added last. `startTimeout` (default `15m`): start, download and load. Registry and log: `<user cache dir>/mm/llama-server/<host>-<port>/`. `mm init` asks for a llamacpp agent on this machine (`--autostart`, default yes; `--launch-settings`, the Llama app's values, default no). See [Let mm start llama-server](../how-to/run-with-llama-cpp.md#let-mm-start-llama-server). |42 | `llamacpp` | `{autoStart, server, ctxSize, modelsMax, modelsMemoryMargin, fitTarget, sleepIdleSeconds, specDefault, serverArgs, startTimeout}` | `autoStart: false` | Provider `llamacpp` only. `autoStart: true`: when nothing answers at the agent's address (a loopback one, `AGENT_BASE_URL` unset) nor on 8080 nor at the `fallback`, mm starts llama-server in router mode with the agent's model (downloaded on first load), waits until it is loaded, and stops it with the last mm session using it; a server mm did not start is never stopped. `server`: the executable (default `llama-server`, then `llama serve`, on the `PATH`). Launch settings, each one optional, each one a llama-server flag (absent = llama-server's default): `ctxSize` (`--ctx-size`), `modelsMax` (`--models-max`), `modelsMemoryMargin` (`--models-memory-margin`), `fitTarget` (`--fit-target`), `sleepIdleSeconds` (`--sleep-idle-seconds`, `-1` allowed), `specDefault` (`--spec-default`); a negative value is a configuration error. `serverArgs`: any other flag, added last. `startTimeout` (default `15m`): start, download and load. Registry and log: `<user cache dir>/mm/llama-server/<host>-<port>/`. `mm init` asks for a llamacpp agent on this machine (`--autostart`, default yes; `--launch-settings`, the Llama app's values, default no). See [Let mm start llama-server](../how-to/run-with-llama-cpp.md#let-mm-start-llama-server). |
43+| `razorbill` | `{autoStart, server, config, serverArgs, startTimeout}` | `autoStart: false` | Provider `razorbill` only. `autoStart: true`: when nothing answers at the agent's address (a loopback one, `AGENT_BASE_URL` unset) nor at the `fallback`, mm starts `rzb serve --host <host> --port <port>`, runs `rzb models pull <model>` when the server does not list the model, and stops the server with the last mm session using it; a server mm did not start is never stopped. macOS only: elsewhere — mm in a container or a sandbox — nothing is started and a warning says so. `server`: the `rzb` executable (default `rzb` on the `PATH`, then `/usr/local/bin/rzb`). `config`: rzb's server configuration, passed as `--config`; a relative path is relative to the agent file's directory, `~/` is the home directory; a missing file is a start error. `serverArgs`: any other `rzb serve` flag, added last. `startTimeout` (default `15m`, negative = configuration error): start and download. Registry and log (`rzb.log`, also the pull's output): `<user cache dir>/mm/rzb/<host>-<port>/`. `mm init` asks for a razorbill agent on this machine (`--autostart`, default yes). See [Let mm start rzb](../how-to/run-with-razorbill.md#let-mm-start-rzb). |
43 | `autoPull` | bool | `false` | At start-up, download the models this agent will use and the server does not list: its own, its `mmConfigs` agents', its `skillRouting` / `toolRouting` deciders'. The progress goes to stderr — one line rewritten in place on a terminal (`⬇ pulling <model> — 52 MB / 145 MB (35 %)`), a line per tenth elsewhere — then `⬇ pulled <model> in 0.8s`. The agent's own model failing stops `mm` with the server's message (`[engine error: autoPull: <model>: the server says: …]`); another model failing, a server that does not answer, or a provider that cannot pull is a `[warning: autoPull: …]`. An agent started by `/ask` or `ask_agent` pulls nothing; `mm --ask` pulls nothing either. A model the server already lists is never pulled (a name without a tag also matches its `:latest` entry). By provider: `llmman` and `ollama` — `POST /api/pull`; `kronk` — `POST /v1/kronk/models/pull`, the pull counting as done only when Kronk's stream ends with `"downloaded": true` (Kronk answers 200 to a failed pull; its last status is then the message); `dmr` — `POST /models/create` on the runner (the base URL without `/engines/…`), the pull counting as done once the runner lists the model; `llamacpp` — no download over the API: the warning says to start llama-server with `-hf <repo>:<quant>`, or to put the GGUF in the router's models directory; `openai` — a warning. |44 | `autoPull` | bool | `false` | At start-up, download the models this agent will use and the server does not list: its own, its `mmConfigs` agents', its `skillRouting` / `toolRouting` deciders'. The progress goes to stderr — one line rewritten in place on a terminal (`⬇ pulling <model> — 52 MB / 145 MB (35 %)`), a line per tenth elsewhere — then `⬇ pulled <model> in 0.8s`. The agent's own model failing stops `mm` with the server's message (`[engine error: autoPull: <model>: the server says: …]`); another model failing, a server that does not answer, or a provider that cannot pull is a `[warning: autoPull: …]`. An agent started by `/ask` or `ask_agent` pulls nothing; `mm --ask` pulls nothing either. A model the server already lists is never pulled (a name without a tag also matches its `:latest` entry). By provider: `llmman` and `ollama` — `POST /api/pull`; `kronk` — `POST /v1/kronk/models/pull`, the pull counting as done only when Kronk's stream ends with `"downloaded": true` (Kronk answers 200 to a failed pull; its last status is then the message); `dmr` — `POST /models/create` on the runner (the base URL without `/engines/…`), the pull counting as done once the runner lists the model; `llamacpp` — no download over the API: the warning says to start llama-server with `-hf <repo>:<quant>`, or to put the GGUF in the router's models directory; `openai` — a warning. |
44 | `sampling` | map | `temperature: 0.0`, `top_p: 0.9`, `max_tokens: 4096` | Generation settings, OpenAI API key names, passed to the server. The file's block is merged with these defaults: a default the file does not name is still sent. **Except with `provider: openai` and `provider: openai-responses`**: the request carries exactly the file's block, nothing added (no block: no sampling key, the server's defaults apply) — the hosted OpenAI reasoning models refuse `max_tokens` and accept only the default temperature, so a default left in would be a 400. A key the OpenAI API does not declare is sent as it is, at the top level of the request — for example `chat_template_kwargs: {enable_thinking: false}`, which tells a llama.cpp server (`dmr`, `llamacpp`, `llmman`) or Kronk not to reason; `reasoning_effort: none` does the same on Ollama. `messages`, `tools`, `tool_choice` (and the legacy `functions`, `function_call`) are ignored: Genkit builds them from the conversation. The shipped `agent.yaml` adds `parallel_tool_calls: false`. `max_tokens` also bounds one tool call: a `write_file` of a long document (or a thinking model's reasoning plus the call) can hit it, and the call is then cut off. mm hands it back to the model twice, asking for smaller pieces, then stops with `the model hit max_tokens (N) while writing a tool call`; raise the value if that happens. A config that names the limit `max_completion_tokens` (the OpenAI API's name for its newer models) is read the same way: that name is used in this message and for the summary request of the context compression. With streaming, mm also asks the server for token counts (`stream_options.include_usage`). |45 | `sampling` | map | `temperature: 0.0`, `top_p: 0.9`, `max_tokens: 4096` | Generation settings, OpenAI API key names, passed to the server. The file's block is merged with these defaults: a default the file does not name is still sent. **Except with `provider: openai` and `provider: openai-responses`**: the request carries exactly the file's block, nothing added (no block: no sampling key, the server's defaults apply) — the hosted OpenAI reasoning models refuse `max_tokens` and accept only the default temperature, so a default left in would be a 400. A key the OpenAI API does not declare is sent as it is, at the top level of the request — for example `chat_template_kwargs: {enable_thinking: false}`, which tells a llama.cpp server (`dmr`, `llamacpp`, `llmman`) or Kronk not to reason; `reasoning_effort: none` does the same on Ollama. `messages`, `tools`, `tool_choice` (and the legacy `functions`, `function_call`) are ignored: Genkit builds them from the conversation. The shipped `agent.yaml` adds `parallel_tool_calls: false`. `max_tokens` also bounds one tool call: a `write_file` of a long document (or a thinking model's reasoning plus the call) can hit it, and the call is then cut off. mm hands it back to the model twice, asking for smaller pieces, then stops with `the model hit max_tokens (N) while writing a tool call`; raise the value if that happens. A config that names the limit `max_completion_tokens` (the OpenAI API's name for its newer models) is read the same way: that name is used in this message and for the summary request of the context compression. With streaming, mm also asks the server for token counts (`stream_options.include_usage`). |
45 | `watchdogTimeout` | duration | `20s` | Silence tolerated between two streamed tokens before the connection is declared hung. Doubled for summary requests. |46 | `watchdogTimeout` | duration | `20s` | Silence tolerated between two streamed tokens before the connection is declared hung. Doubled for summary requests. |
@@ -259,6 +260,7 @@ workspace:
259 | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | no |260 | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | no |
260 | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | no — only Kronk's `authenticated` and `full-protected` modes check it |261 | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | no — only Kronk's `authenticated` and `full-protected` modes check it |
261 | `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | no — only a server started with `--api-key` checks it, and not for localhost |262 | `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | no — only a server started with `--api-key` checks it, and not for localhost |
263+| `razorbill` | `http://127.0.0.1:7920/v1` | `http://host.docker.internal:7920/v1` | `RZB_API_KEY` | no — only a server whose `RZB_API_KEY` is set checks it |
262 | `openai` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — a server that needs one answers 401, and the start-up warning names the variable |264 | `openai` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — a server that needs one answers 401, and the start-up warning names the variable |
263 | `openai-responses` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — as `openai` |265 | `openai-responses` | `https://api.openai.com/v1` | none | `OPENAI_API_KEY` | no — as `openai` |
264 266
@@ -533,7 +535,7 @@ Reported on stderr as `[config error: <path>: <message>]`, exit code 1 — in ev
533 | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | a name starting with `with-context` |535 | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | a name starting with `with-context` |
534 | `mmConfigs.<name>: the path must not be empty` | `<name>: ""`, or a long form without `path` |536 | `mmConfigs.<name>: the path must not be empty` | `<name>: ""`, or a long form without `path` |
535 | `hooks: unknown event "x" (…)`, `hooks.<event>[N]: …` | an invalid `hooks:` block — see [hooks](hooks.md#validation-errors) |537 | `hooks: unknown event "x" (…)`, `hooks.<event>[N]: …` | an invalid `hooks:` block — see [hooks](hooks.md#validation-errors) |
536-| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses)` | Reported by the engine, as `[engine error: …]`. |538+| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses, razorbill)` | Reported by the engine, as `[engine error: …]`. |
537 539
538 A start-up warning, not an error, is printed when `context.enabled` is `true`, the window is unknown and `context.maxMessages` is `0`, and when a declared tool has the name of an MCP tool (`tools: <name> skipped — an MCP tool already has that name`; the tool is not declared), and when the file sets the deprecated `permissions` key (`permissions: ask is deprecated — use yolo: false instead …`).540 A start-up warning, not an error, is printed when `context.enabled` is `true`, the window is unknown and `context.maxMessages` is `0`, and when a declared tool has the name of an MCP tool (`tools: <name> skipped — an MCP tool already has that name`; the tool is not declared), and when the file sets the deprecated `permissions` key (`permissions: ask is deprecated — use yolo: false instead …`).
539 541
modified docs/en/reference/tools.md +1 -0
@@ -337,6 +337,7 @@ Declared when `unloadModels` is true (the default), except beside a `structuredO
337337 | llmman, `ollama` | Looks the model up in `GET /api/ps` first; when it is loaded, `POST /api/generate {"model": …, "keep_alive": 0}` and expects `done_reason: "unload"`. A model that is not loaded is never asked for: the request would load it first. |
338338 | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, which expects `status: "unloaded"`. Kronk's 404 for a model that is not loaded gives `<model> was not loaded: nothing to unload`. |
339339 | `mlxserve` | Looks the model up in `GET /v1/models` first; when it is `loaded`, `POST /v1/unload-model {"model": …}` and expects `state: "unloaded"`. MLX-Serve answers "unloaded" for a model that was not loaded too, hence the look-up. |
340+| `razorbill` | `cannot unload <model>: the razorbill provider cannot unload a model` — rzb has no unload route; it unloads an idle model itself after its `keep_alive` (10 minutes by default). |
340341 | `llamacpp` | `POST /models/unload {"model": …}`, which exists in router mode only (llama-server started without a model). A single-model server's 404 gives the reason and the alternatives: router mode, `--sleep-idle-seconds N`, stopping the server. |
341342 | `dmr` | `cannot unload <model>: the dmr provider cannot unload a model`. |
342343 | Result | One line: `unloaded <model>`, `<model> was not loaded: nothing to unload`, or `cannot unload <model>: <reason>` (unreachable server, the server's own error, no confirmation). |
@@ -337,6 +337,7 @@ Declared when `unloadModels` is true (the default), except beside a `structuredO
337 | llmman, `ollama` | Looks the model up in `GET /api/ps` first; when it is loaded, `POST /api/generate {"model": …, "keep_alive": 0}` and expects `done_reason: "unload"`. A model that is not loaded is never asked for: the request would load it first. |337 | llmman, `ollama` | Looks the model up in `GET /api/ps` first; when it is loaded, `POST /api/generate {"model": …, "keep_alive": 0}` and expects `done_reason: "unload"`. A model that is not loaded is never asked for: the request would load it first. |
338 | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, which expects `status: "unloaded"`. Kronk's 404 for a model that is not loaded gives `<model> was not loaded: nothing to unload`. |338 | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, which expects `status: "unloaded"`. Kronk's 404 for a model that is not loaded gives `<model> was not loaded: nothing to unload`. |
339 | `mlxserve` | Looks the model up in `GET /v1/models` first; when it is `loaded`, `POST /v1/unload-model {"model": …}` and expects `state: "unloaded"`. MLX-Serve answers "unloaded" for a model that was not loaded too, hence the look-up. |339 | `mlxserve` | Looks the model up in `GET /v1/models` first; when it is `loaded`, `POST /v1/unload-model {"model": …}` and expects `state: "unloaded"`. MLX-Serve answers "unloaded" for a model that was not loaded too, hence the look-up. |
340+| `razorbill` | `cannot unload <model>: the razorbill provider cannot unload a model` — rzb has no unload route; it unloads an idle model itself after its `keep_alive` (10 minutes by default). |
340 | `llamacpp` | `POST /models/unload {"model": …}`, which exists in router mode only (llama-server started without a model). A single-model server's 404 gives the reason and the alternatives: router mode, `--sleep-idle-seconds N`, stopping the server. |341 | `llamacpp` | `POST /models/unload {"model": …}`, which exists in router mode only (llama-server started without a model). A single-model server's 404 gives the reason and the alternatives: router mode, `--sleep-idle-seconds N`, stopping the server. |
341 | `dmr` | `cannot unload <model>: the dmr provider cannot unload a model`. |342 | `dmr` | `cannot unload <model>: the dmr provider cannot unload a model`. |
342 | Result | One line: `unloaded <model>`, `<model> was not loaded: nothing to unload`, or `cannot unload <model>: <reason>` (unreachable server, the server's own error, no confirmation). |343 | Result | One line: `unloaded <model>`, `<model> was not loaded: nothing to unload`, or `cannot unload <model>: <reason>` (unreachable server, the server's own error, no confirmation). |
modified docs/fr/README.md +1 -0
@@ -18,6 +18,7 @@ Cette documentation est organisée selon les quatre quadrants [Diátaxis](https:
1818 - [Faire tourner mini-me sur Ollama](how-to/run-with-ollama.md) — `provider: ollama`, la config de démo dans `demos/ollama/`
1919 - [Faire tourner mini-me sur Kronk](how-to/run-with-kronk.md) — `provider: kronk`, la config de démo dans `demos/kronk/`
2020 - [Faire tourner mini-me sur MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, la config de démo dans `demos/mlx-gemma-4-e4b/`
21+- [Faire tourner mini-me sur razorbill](how-to/run-with-razorbill.md) — `provider: razorbill` (`rzb`, MLX sur le Mac), et `razorbill.autoStart`
2122 - [Utiliser n'importe quel serveur compatible OpenAI](how-to/run-with-an-openai-compatible-server.md) — `provider: openai` : l'API d'OpenAI, vLLM, LM Studio, une passerelle
2223 - [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](how-to/use-the-openai-responses-api.md) — `provider: openai-responses` : les modèles de raisonnement d'OpenAI avec des outils
2324 - [Interroger un autre agent mm depuis votre session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<nom>`, `/ask-with-context-<nom>`
@@ -18,6 +18,7 @@ Cette documentation est organisée selon les quatre quadrants [Diátaxis](https:
18 - [Faire tourner mini-me sur Ollama](how-to/run-with-ollama.md) — `provider: ollama`, la config de démo dans `demos/ollama/`18 - [Faire tourner mini-me sur Ollama](how-to/run-with-ollama.md) — `provider: ollama`, la config de démo dans `demos/ollama/`
19 - [Faire tourner mini-me sur Kronk](how-to/run-with-kronk.md) — `provider: kronk`, la config de démo dans `demos/kronk/`19 - [Faire tourner mini-me sur Kronk](how-to/run-with-kronk.md) — `provider: kronk`, la config de démo dans `demos/kronk/`
20 - [Faire tourner mini-me sur MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, la config de démo dans `demos/mlx-gemma-4-e4b/`20 - [Faire tourner mini-me sur MLX-Serve](how-to/run-with-mlx-serve.md) — `provider: mlxserve`, la config de démo dans `demos/mlx-gemma-4-e4b/`
21+- [Faire tourner mini-me sur razorbill](how-to/run-with-razorbill.md) — `provider: razorbill` (`rzb`, MLX sur le Mac), et `razorbill.autoStart`
21 - [Utiliser n'importe quel serveur compatible OpenAI](how-to/run-with-an-openai-compatible-server.md) — `provider: openai` : l'API d'OpenAI, vLLM, LM Studio, une passerelle22 - [Utiliser n'importe quel serveur compatible OpenAI](how-to/run-with-an-openai-compatible-server.md) — `provider: openai` : l'API d'OpenAI, vLLM, LM Studio, une passerelle
22 - [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](how-to/use-the-openai-responses-api.md) — `provider: openai-responses` : les modèles de raisonnement d'OpenAI avec des outils23 - [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](how-to/use-the-openai-responses-api.md) — `provider: openai-responses` : les modèles de raisonnement d'OpenAI avec des outils
23 - [Interroger un autre agent mm depuis votre session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<nom>`, `/ask-with-context-<nom>`24 - [Interroger un autre agent mm depuis votre session](how-to/ask-another-agent.md) — `mmConfigs`, `/ask-<nom>`, `/ask-with-context-<nom>`
modified docs/fr/explanation/mm-init.md +1 -0
@@ -18,6 +18,7 @@ Le serveur connaît le modèle exact qui est chargé : c'est la source la plus p
1818 | `llamacpp` | `/props` | la fenêtre et le template de chat |
1919 | `kronk` | `/models`, puis `/v1/kronk/models/<id>` | la liste des modèles, l'architecture, la fenêtre avec laquelle le modèle est configuré (celle d'entraînement à défaut), l'échantillonnage écrit dans le GGUF, le template de chat ; pour un profil, son propre échantillonnage, qui l'emporte sur toute autre source : `mm` envoie son échantillonnage à chaque requête et une valeur de la requête remplace celle du profil, donc sans cette copie les valeurs du profil ne s'appliqueraient jamais |
2020 | `mlxserve` | `/models`, puis `/api/show` | la liste des modèles, la famille, la fenêtre (celle servie quand le modèle est chargé), le template de chat, et l'échantillonnage propre au modèle (`gen_temperature`, `gen_top_p`, `gen_top_k` dans `/v1/models`) |
21+| `razorbill` | `/models` | la liste des modèles seulement (rzb 0.2.0 ne donne ni famille, ni fenêtre, ni échantillonnage) |
2122 | `dmr` | `/models` | la liste des modèles seulement |
2223 | `openai`, `openai-responses` | `/models` (avec la clé) | la liste des modèles seulement |
2324
@@ -18,6 +18,7 @@ Le serveur connaît le modèle exact qui est chargé : c'est la source la plus p
18 | `llamacpp` | `/props` | la fenêtre et le template de chat |18 | `llamacpp` | `/props` | la fenêtre et le template de chat |
19 | `kronk` | `/models`, puis `/v1/kronk/models/<id>` | la liste des modèles, l'architecture, la fenêtre avec laquelle le modèle est configuré (celle d'entraînement à défaut), l'échantillonnage écrit dans le GGUF, le template de chat ; pour un profil, son propre échantillonnage, qui l'emporte sur toute autre source : `mm` envoie son échantillonnage à chaque requête et une valeur de la requête remplace celle du profil, donc sans cette copie les valeurs du profil ne s'appliqueraient jamais |19 | `kronk` | `/models`, puis `/v1/kronk/models/<id>` | la liste des modèles, l'architecture, la fenêtre avec laquelle le modèle est configuré (celle d'entraînement à défaut), l'échantillonnage écrit dans le GGUF, le template de chat ; pour un profil, son propre échantillonnage, qui l'emporte sur toute autre source : `mm` envoie son échantillonnage à chaque requête et une valeur de la requête remplace celle du profil, donc sans cette copie les valeurs du profil ne s'appliqueraient jamais |
20 | `mlxserve` | `/models`, puis `/api/show` | la liste des modèles, la famille, la fenêtre (celle servie quand le modèle est chargé), le template de chat, et l'échantillonnage propre au modèle (`gen_temperature`, `gen_top_p`, `gen_top_k` dans `/v1/models`) |20 | `mlxserve` | `/models`, puis `/api/show` | la liste des modèles, la famille, la fenêtre (celle servie quand le modèle est chargé), le template de chat, et l'échantillonnage propre au modèle (`gen_temperature`, `gen_top_p`, `gen_top_k` dans `/v1/models`) |
21+| `razorbill` | `/models` | la liste des modèles seulement (rzb 0.2.0 ne donne ni famille, ni fenêtre, ni échantillonnage) |
21 | `dmr` | `/models` | la liste des modèles seulement |22 | `dmr` | `/models` | la liste des modèles seulement |
22 | `openai`, `openai-responses` | `/models` (avec la clé) | la liste des modèles seulement |23 | `openai`, `openai-responses` | `/models` (avec la clé) | la liste des modèles seulement |
23 24
modified docs/fr/explanation/providers.md +4 -2
@@ -2,7 +2,7 @@
22
33 ## De quoi s'agit-il ?
44
5-`mm` dialogue avec un serveur de modèle local via l'API chat-completions d'OpenAI. Six serveurs sont pris en charge d'origine : Docker Model Runner, `llama-server` de llama.cpp, llmman, Ollama, Kronk et MLX-Serve, sous les noms `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk` et `mlxserve`. Une autre entrée, `openai` (ticket 118), prend tout autre serveur qui parle le protocole — l'API d'OpenAI par défaut, vLLM, LM Studio, une passerelle — et ne suppose rien au-delà : c'est la même entrée faite de données, avec tous les champs propres à un serveur laissés vides, et une sonde qui envoie la clé. Le paquet moteur était autrefois lié à Docker Model Runner ; l'abstraction de fournisseur est ce qui l'a généralisé.
5+`mm` dialogue avec un serveur de modèle local via l'API chat-completions d'OpenAI. Sept serveurs sont pris en charge d'origine : Docker Model Runner, `llama-server` de llama.cpp, llmman, Ollama, Kronk, MLX-Serve et razorbill, sous les noms `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve` et `razorbill`. Une autre entrée, `openai` (ticket 118), prend tout autre serveur qui parle le protocole — l'API d'OpenAI par défaut, vLLM, LM Studio, une passerelle — et ne suppose rien au-delà : c'est la même entrée faite de données, avec tous les champs propres à un serveur laissés vides, et une sonde qui envoie la clé. Le paquet moteur était autrefois lié à Docker Model Runner ; l'abstraction de fournisseur est ce qui l'a généralisé.
66
77 ## Pourquoi c'est conçu ainsi
88
@@ -24,6 +24,8 @@
2424
2525 **MLX-Serve est une sixième entrée, et la première dont le silence est le piège.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) fait tourner des modèles MLX sur Apple Silicon et parle les API d'OpenAI, d'Anthropic et d'Ollama sur un seul port ; `mm` utilise le côté OpenAI, et le `/api/pull` d'Ollama pour `autoPull`. Mesuré sur mlx-serve 26.11.3 : le raisonnement arrive dans `reasoning_content` et s'active dès que `enable_thinking` **ou** `reasoning_effort` le demande ; un résumé est donc envoyé avec les deux coupés (une troisième façon de couper le raisonnement, à côté du template et de l'effort). Pas de progression du prompt. `GET /v1/models` liste tous les modèles téléchargés avec `loaded` et `context_length` : chargé, c'est la fenêtre servie (elle est passée de 101376 à 73728 entre deux chargements, avec moins de mémoire libre) ; non chargé, la longueur d'entraînement — le probe ne s'y fie donc que pour un modèle chargé. Un modèle que le serveur n'a pas reçoit quand même une réponse, HTTP 200, de son modèle par défaut : aucun 404 ne le dira, l'avertissement du démarrage est le seul endroit où cela se voit. Enfin, pendant qu'il lit un long prompt, il envoie des commentaires SSE (`: keepalive`) ; openai-go transforme la ligne vide qui suit en événement vide et échoue dessus (`unexpected end of JSON input`). `mm` retire désormais les blocs faits uniquement de commentaires de chaque flux avant qu'openai-go ne les voie.
2626
27+**razorbill est une septième entrée, et le deuxième serveur que mm sait démarrer lui-même.** razorbill (`rzb serve`, port 7920, ticket 264) est un serveur MLX pour les Mac Apple Silicon. Mesuré sur rzb 0.2.0, c'est la plus simple des entrées : le raisonnement arrive dans `reasoning_content`, `enable_thinking: false` le coupe et l'emporte sur tout `reasoning_effort` (l'interrupteur du template suffit donc), pas de progression de lecture du prompt, des commentaires `: keep-alive` pendant la lecture d'un prompt (retirés comme ceux de MLX-Serve). Il ne donne pas de fenêtre et n'a pas de route pour télécharger ou décharger un modèle : il télécharge un modèle à sa première utilisation et décharge lui-même un modèle inactif. C'est ce téléchargement à la première utilisation qui pose problème : plusieurs Go téléchargés pendant la première question, et le watchdog abandonne. La sonde avertit donc quand rzb ne liste pas le modèle, et `razorbill.autoStart` lance `rzb models pull` avant la première question. Le démarrage et l'arrêt sont ceux de llamacpp (ticket 223), désormais dans un paquet partagé, `internal/serverstart` : un registre par serveur et par adresse, un bail par session mm, le serveur arrêté avec le dernier bail, et un serveur que mm n'a pas démarré jamais touché. Seule la partie propre au serveur diffère : le preset et `/models/load` de llama-server dans `internal/llamastart`, `rzb serve` et `rzb models pull` dans `internal/rzbstart`. Copier la logique des baux dans un second paquet a été écarté : deux copies des règles de verrou et de bail périmé finiraient par diverger. rzb ne tourne que sur macOS, le démarrage est donc refusé ailleurs — dans un container ou un sandbox, où le serveur du Mac est joint par le fallback.
28+
2729 **Les erreurs sont réécrites dans les mots du serveur.** Une pile de messages imbriqués est du bruit ; « tool calls need llama-server started with --jinja » est tout le diagnostic. Le fournisseur reconnaît les refus de connexion, l'option `--jinja` manquante, les 401/403, les 404 avec une indication de pull ou d'alias, les 429 et les 5xx. Les erreurs inconnues reviennent inchangées : un message brut vaut mieux qu'une mauvaise piste.
2830
2931 **Un flux que le serveur interrompt est relancé, et ses mots sont gardés.** llama.cpp signale un échec au milieu d'une réponse diffusée par un événement SSE `error:` (le statut 200 est déjà parti). openai-go ne lit que les lignes `data:` : le message disparaissait derrière `unexpected end of JSON input`. Le tap qui lit déjà le flux pour le raisonnement récupère aussi ces événements, et l'appel au modèle qui a échoué est relancé une fois — cet appel seulement : les outils déjà exécutés dans le tour ne sont pas rejoués, et le texte déjà diffusé par la tentative interrompue n'est pas retiré. S'il échoue encore, l'erreur donne le message du serveur (`the model server reported an error while generating: Failed to parse input at pos …`), ou indique que la connexion a été coupée. Dans les deux cas l'historique est conservé : demander de continuer reprend le travail.
@@ -42,5 +44,5 @@
4244
4345 - Les deux fichiers de configuration qui paramètrent chaque fournisseur sont listés dans la [référence de la configuration](../reference/configuration.md).
4446 - La fenêtre apprise par la sonde est ce contre quoi la [compression du contexte](context-compression.md) mesure.
45-- Changer de serveur pour une exécution est couvert dans [comment faire tourner sur llama.cpp](../how-to/run-with-llama-cpp.md) [comment faire tourner sur llmman](../how-to/run-with-llmman.md) [comment faire tourner sur Ollama](../how-to/run-with-ollama.md) [comment faire tourner sur Kronk](../how-to/run-with-kronk.md) et [comment faire tourner sur MLX-Serve](../how-to/run-with-mlx-serve.md).
47+- Changer de serveur pour une exécution est couvert dans [comment faire tourner sur llama.cpp](../how-to/run-with-llama-cpp.md) [comment faire tourner sur llmman](../how-to/run-with-llmman.md) [comment faire tourner sur Ollama](../how-to/run-with-ollama.md) [comment faire tourner sur Kronk](../how-to/run-with-kronk.md) [comment faire tourner sur MLX-Serve](../how-to/run-with-mlx-serve.md) et [comment faire tourner sur razorbill](../how-to/run-with-razorbill.md).
4648 - Vérifier l'ordre des outils et mesurer le gain de cache sur votre propre serveur : [vérifier que les outils partent dans un ordre stable](../how-to/verify-tool-order.md).
@@ -2,7 +2,7 @@
2 2
3 ## De quoi s'agit-il ?3 ## De quoi s'agit-il ?
4 4
5-`mm` dialogue avec un serveur de modèle local via l'API chat-completions d'OpenAI. Six serveurs sont pris en charge d'origine : Docker Model Runner, `llama-server` de llama.cpp, llmman, Ollama, Kronk et MLX-Serve, sous les noms `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk` et `mlxserve`. Une autre entrée, `openai` (ticket 118), prend tout autre serveur qui parle le protocole — l'API d'OpenAI par défaut, vLLM, LM Studio, une passerelle — et ne suppose rien au-delà : c'est la même entrée faite de données, avec tous les champs propres à un serveur laissés vides, et une sonde qui envoie la clé. Le paquet moteur était autrefois lié à Docker Model Runner ; l'abstraction de fournisseur est ce qui l'a généralisé.5+`mm` dialogue avec un serveur de modèle local via l'API chat-completions d'OpenAI. Sept serveurs sont pris en charge d'origine : Docker Model Runner, `llama-server` de llama.cpp, llmman, Ollama, Kronk, MLX-Serve et razorbill, sous les noms `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve` et `razorbill`. Une autre entrée, `openai` (ticket 118), prend tout autre serveur qui parle le protocole — l'API d'OpenAI par défaut, vLLM, LM Studio, une passerelle — et ne suppose rien au-delà : c'est la même entrée faite de données, avec tous les champs propres à un serveur laissés vides, et une sonde qui envoie la clé. Le paquet moteur était autrefois lié à Docker Model Runner ; l'abstraction de fournisseur est ce qui l'a généralisé.
6 6
7 ## Pourquoi c'est conçu ainsi7 ## Pourquoi c'est conçu ainsi
8 8
@@ -24,6 +24,8 @@
24 24
25 **MLX-Serve est une sixième entrée, et la première dont le silence est le piège.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) fait tourner des modèles MLX sur Apple Silicon et parle les API d'OpenAI, d'Anthropic et d'Ollama sur un seul port ; `mm` utilise le côté OpenAI, et le `/api/pull` d'Ollama pour `autoPull`. Mesuré sur mlx-serve 26.11.3 : le raisonnement arrive dans `reasoning_content` et s'active dès que `enable_thinking` **ou** `reasoning_effort` le demande ; un résumé est donc envoyé avec les deux coupés (une troisième façon de couper le raisonnement, à côté du template et de l'effort). Pas de progression du prompt. `GET /v1/models` liste tous les modèles téléchargés avec `loaded` et `context_length` : chargé, c'est la fenêtre servie (elle est passée de 101376 à 73728 entre deux chargements, avec moins de mémoire libre) ; non chargé, la longueur d'entraînement — le probe ne s'y fie donc que pour un modèle chargé. Un modèle que le serveur n'a pas reçoit quand même une réponse, HTTP 200, de son modèle par défaut : aucun 404 ne le dira, l'avertissement du démarrage est le seul endroit où cela se voit. Enfin, pendant qu'il lit un long prompt, il envoie des commentaires SSE (`: keepalive`) ; openai-go transforme la ligne vide qui suit en événement vide et échoue dessus (`unexpected end of JSON input`). `mm` retire désormais les blocs faits uniquement de commentaires de chaque flux avant qu'openai-go ne les voie.25 **MLX-Serve est une sixième entrée, et la première dont le silence est le piège.** [MLX-Serve](https://github.com/ddalcu/mlx-serve) (`mlx-serve serve`, port 11234, ticket 252) fait tourner des modèles MLX sur Apple Silicon et parle les API d'OpenAI, d'Anthropic et d'Ollama sur un seul port ; `mm` utilise le côté OpenAI, et le `/api/pull` d'Ollama pour `autoPull`. Mesuré sur mlx-serve 26.11.3 : le raisonnement arrive dans `reasoning_content` et s'active dès que `enable_thinking` **ou** `reasoning_effort` le demande ; un résumé est donc envoyé avec les deux coupés (une troisième façon de couper le raisonnement, à côté du template et de l'effort). Pas de progression du prompt. `GET /v1/models` liste tous les modèles téléchargés avec `loaded` et `context_length` : chargé, c'est la fenêtre servie (elle est passée de 101376 à 73728 entre deux chargements, avec moins de mémoire libre) ; non chargé, la longueur d'entraînement — le probe ne s'y fie donc que pour un modèle chargé. Un modèle que le serveur n'a pas reçoit quand même une réponse, HTTP 200, de son modèle par défaut : aucun 404 ne le dira, l'avertissement du démarrage est le seul endroit où cela se voit. Enfin, pendant qu'il lit un long prompt, il envoie des commentaires SSE (`: keepalive`) ; openai-go transforme la ligne vide qui suit en événement vide et échoue dessus (`unexpected end of JSON input`). `mm` retire désormais les blocs faits uniquement de commentaires de chaque flux avant qu'openai-go ne les voie.
26 26
27+**razorbill est une septième entrée, et le deuxième serveur que mm sait démarrer lui-même.** razorbill (`rzb serve`, port 7920, ticket 264) est un serveur MLX pour les Mac Apple Silicon. Mesuré sur rzb 0.2.0, c'est la plus simple des entrées : le raisonnement arrive dans `reasoning_content`, `enable_thinking: false` le coupe et l'emporte sur tout `reasoning_effort` (l'interrupteur du template suffit donc), pas de progression de lecture du prompt, des commentaires `: keep-alive` pendant la lecture d'un prompt (retirés comme ceux de MLX-Serve). Il ne donne pas de fenêtre et n'a pas de route pour télécharger ou décharger un modèle : il télécharge un modèle à sa première utilisation et décharge lui-même un modèle inactif. C'est ce téléchargement à la première utilisation qui pose problème : plusieurs Go téléchargés pendant la première question, et le watchdog abandonne. La sonde avertit donc quand rzb ne liste pas le modèle, et `razorbill.autoStart` lance `rzb models pull` avant la première question. Le démarrage et l'arrêt sont ceux de llamacpp (ticket 223), désormais dans un paquet partagé, `internal/serverstart` : un registre par serveur et par adresse, un bail par session mm, le serveur arrêté avec le dernier bail, et un serveur que mm n'a pas démarré jamais touché. Seule la partie propre au serveur diffère : le preset et `/models/load` de llama-server dans `internal/llamastart`, `rzb serve` et `rzb models pull` dans `internal/rzbstart`. Copier la logique des baux dans un second paquet a été écarté : deux copies des règles de verrou et de bail périmé finiraient par diverger. rzb ne tourne que sur macOS, le démarrage est donc refusé ailleurs — dans un container ou un sandbox, où le serveur du Mac est joint par le fallback.
28+
27 **Les erreurs sont réécrites dans les mots du serveur.** Une pile de messages imbriqués est du bruit ; « tool calls need llama-server started with --jinja » est tout le diagnostic. Le fournisseur reconnaît les refus de connexion, l'option `--jinja` manquante, les 401/403, les 404 avec une indication de pull ou d'alias, les 429 et les 5xx. Les erreurs inconnues reviennent inchangées : un message brut vaut mieux qu'une mauvaise piste.29 **Les erreurs sont réécrites dans les mots du serveur.** Une pile de messages imbriqués est du bruit ; « tool calls need llama-server started with --jinja » est tout le diagnostic. Le fournisseur reconnaît les refus de connexion, l'option `--jinja` manquante, les 401/403, les 404 avec une indication de pull ou d'alias, les 429 et les 5xx. Les erreurs inconnues reviennent inchangées : un message brut vaut mieux qu'une mauvaise piste.
28 30
29 **Un flux que le serveur interrompt est relancé, et ses mots sont gardés.** llama.cpp signale un échec au milieu d'une réponse diffusée par un événement SSE `error:` (le statut 200 est déjà parti). openai-go ne lit que les lignes `data:` : le message disparaissait derrière `unexpected end of JSON input`. Le tap qui lit déjà le flux pour le raisonnement récupère aussi ces événements, et l'appel au modèle qui a échoué est relancé une fois — cet appel seulement : les outils déjà exécutés dans le tour ne sont pas rejoués, et le texte déjà diffusé par la tentative interrompue n'est pas retiré. S'il échoue encore, l'erreur donne le message du serveur (`the model server reported an error while generating: Failed to parse input at pos …`), ou indique que la connexion a été coupée. Dans les deux cas l'historique est conservé : demander de continuer reprend le travail.31 **Un flux que le serveur interrompt est relancé, et ses mots sont gardés.** llama.cpp signale un échec au milieu d'une réponse diffusée par un événement SSE `error:` (le statut 200 est déjà parti). openai-go ne lit que les lignes `data:` : le message disparaissait derrière `unexpected end of JSON input`. Le tap qui lit déjà le flux pour le raisonnement récupère aussi ces événements, et l'appel au modèle qui a échoué est relancé une fois — cet appel seulement : les outils déjà exécutés dans le tour ne sont pas rejoués, et le texte déjà diffusé par la tentative interrompue n'est pas retiré. S'il échoue encore, l'erreur donne le message du serveur (`the model server reported an error while generating: Failed to parse input at pos …`), ou indique que la connexion a été coupée. Dans les deux cas l'historique est conservé : demander de continuer reprend le travail.
@@ -42,5 +44,5 @@
42 44
43 - Les deux fichiers de configuration qui paramètrent chaque fournisseur sont listés dans la [référence de la configuration](../reference/configuration.md).45 - Les deux fichiers de configuration qui paramètrent chaque fournisseur sont listés dans la [référence de la configuration](../reference/configuration.md).
44 - La fenêtre apprise par la sonde est ce contre quoi la [compression du contexte](context-compression.md) mesure.46 - La fenêtre apprise par la sonde est ce contre quoi la [compression du contexte](context-compression.md) mesure.
45-- Changer de serveur pour une exécution est couvert dans [comment faire tourner sur llama.cpp](../how-to/run-with-llama-cpp.md) [comment faire tourner sur llmman](../how-to/run-with-llmman.md) [comment faire tourner sur Ollama](../how-to/run-with-ollama.md) [comment faire tourner sur Kronk](../how-to/run-with-kronk.md) et [comment faire tourner sur MLX-Serve](../how-to/run-with-mlx-serve.md).47+- Changer de serveur pour une exécution est couvert dans [comment faire tourner sur llama.cpp](../how-to/run-with-llama-cpp.md) [comment faire tourner sur llmman](../how-to/run-with-llmman.md) [comment faire tourner sur Ollama](../how-to/run-with-ollama.md) [comment faire tourner sur Kronk](../how-to/run-with-kronk.md) [comment faire tourner sur MLX-Serve](../how-to/run-with-mlx-serve.md) et [comment faire tourner sur razorbill](../how-to/run-with-razorbill.md).
46 - Vérifier l'ordre des outils et mesurer le gain de cache sur votre propre serveur : [vérifier que les outils partent dans un ordre stable](../how-to/verify-tool-order.md).48 - Vérifier l'ordre des outils et mesurer le gain de cache sur votre propre serveur : [vérifier que les outils partent dans un ordre stable](../how-to/verify-tool-order.md).
modified docs/fr/how-to/run-in-a-container.md +3 -1
@@ -68,7 +68,9 @@ Le projet est monté au même chemin que sur votre machine : les chemins envoyé
6868
6969 ## Joindre le modèle
7070
71-Depuis le conteneur, `localhost` désigne le conteneur. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve` et `llamacpp` se rabattent d'eux-mêmes sur `host.docker.internal` quand leur adresse par défaut ne répond pas, tant que le fichier d'agent ne définit pas de `baseUrl`. Le fichier compose fait aussi connaître ce nom sous Linux.
71+Depuis le conteneur, `localhost` désigne le conteneur. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve`, `razorbill` et `llamacpp` se rabattent d'eux-mêmes sur `host.docker.internal` quand leur adresse par défaut ne répond pas, tant que le fichier d'agent ne définit pas de `baseUrl`. Le fichier compose fait aussi connaître ce nom sous Linux.
72+
73+`llamacpp.autoStart` et `razorbill.autoStart` ne lancent rien depuis un conteneur : ils ne démarrent un serveur qu'à une adresse de la machine de mm. Démarrez plutôt le serveur sur l'hôte, à l'écoute sur toutes les interfaces (`llama-server --host 0.0.0.0`, `rzb serve --host 0.0.0.0`).
7274
7375 - **`llamacpp`** : sous Linux, lancez llama-server avec `--host 0.0.0.0`, car par défaut il n'écoute que sur la boucle locale (voir le dernier point). Les fichiers écrits avant la v1.1.0 peuvent contenir `fallback: ""` : retirez cette ligne.
7476 - **Un fichier d'agent avec un `baseUrl` sur `localhost` ou `127.0.0.1` :** remplacez l'hôte par `host.docker.internal`, ou ajoutez un `fallback`.
@@ -68,7 +68,9 @@ Le projet est monté au même chemin que sur votre machine : les chemins envoyé
68 68
69 ## Joindre le modèle69 ## Joindre le modèle
70 70
71-Depuis le conteneur, `localhost` désigne le conteneur. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve` et `llamacpp` se rabattent d'eux-mêmes sur `host.docker.internal` quand leur adresse par défaut ne répond pas, tant que le fichier d'agent ne définit pas de `baseUrl`. Le fichier compose fait aussi connaître ce nom sous Linux.71+Depuis le conteneur, `localhost` désigne le conteneur. `dmr`, `llmman`, `ollama`, `kronk`, `mlxserve`, `razorbill` et `llamacpp` se rabattent d'eux-mêmes sur `host.docker.internal` quand leur adresse par défaut ne répond pas, tant que le fichier d'agent ne définit pas de `baseUrl`. Le fichier compose fait aussi connaître ce nom sous Linux.
72+
73+`llamacpp.autoStart` et `razorbill.autoStart` ne lancent rien depuis un conteneur : ils ne démarrent un serveur qu'à une adresse de la machine de mm. Démarrez plutôt le serveur sur l'hôte, à l'écoute sur toutes les interfaces (`llama-server --host 0.0.0.0`, `rzb serve --host 0.0.0.0`).
72 74
73 - **`llamacpp`** : sous Linux, lancez llama-server avec `--host 0.0.0.0`, car par défaut il n'écoute que sur la boucle locale (voir le dernier point). Les fichiers écrits avant la v1.1.0 peuvent contenir `fallback: ""` : retirez cette ligne.75 - **`llamacpp`** : sous Linux, lancez llama-server avec `--host 0.0.0.0`, car par défaut il n'écoute que sur la boucle locale (voir le dernier point). Les fichiers écrits avant la v1.1.0 peuvent contenir `fallback: ""` : retirez cette ligne.
74 - **Un fichier d'agent avec un `baseUrl` sur `localhost` ou `127.0.0.1` :** remplacez l'hôte par `host.docker.internal`, ou ajoutez un `fallback`.76 - **Un fichier d'agent avec un `baseUrl` sur `localhost` ou `127.0.0.1` :** remplacez l'hôte par `host.docker.internal`, ou ajoutez un `fallback`.
added docs/fr/how-to/run-with-razorbill.md +52 -0
new file mode 100644
@@ -0,0 +1,52 @@
1+# Comment faire tourner mini-me sur razorbill
2+
3+Ce guide montre comment brancher `mm` sur razorbill, un serveur de modèles MLX pour les Mac Apple Silicon (commande `rzb`, sans Python), via son point d'accès compatible OpenAI, et comment laisser `mm` le démarrer et l'arrêter. Il suppose que `rzb` est compilé et installé sur le Mac (le `scripts/install.sh` de razorbill le met dans `/usr/local/bin`) et que vous savez compiler `mm`.
4+
5+## Étapes
6+
7+1. Téléchargez un modèle et démarrez le serveur. `rzb serve` écoute sur `127.0.0.1:7920` et charge un modèle à la première requête qui le nomme :
8+
9+ ```bash
10+ rzb models pull mlx-community/Qwen3-4B-4bit
11+ rzb serve
12+ ```
13+
14+2. Écrivez le fichier d'agent :
15+
16+ ```yaml
17+ provider: razorbill
18+ model: mlx-community/Qwen3-4B-4bit
19+ ```
20+
21+3. Lancez `mm` avec ce fichier et vérifiez la bannière : `provider: razorbill`. rzb ne donne pas la fenêtre de contexte, la bannière affiche donc `ctx: unknown`. Indiquez `contextWindow:` (la fenêtre du modèle) si vous voulez que la compaction s'appuie dessus.
22+
23+## Laisser mm démarrer rzb
24+
25+Avec `autoStart`, plus besoin du `rzb serve` de l'étape 1 : quand rien ne répond à l'adresse de l'agent, `mm` y lance `rzb serve`, télécharge le modèle avec `rzb models pull` si rzb ne le liste pas, et arrête le serveur quand la dernière session `mm` qui l'utilise se termine.
26+
27+```yaml
28+provider: razorbill
29+model: mlx-community/Qwen3-4B-4bit
30+razorbill:
31+ autoStart: true
32+ # config: rzb-server.yaml # rzb serve --config, relatif à ce fichier
33+```
34+
35+- **Sur le Mac uniquement.** rzb tourne sur macOS (Apple Silicon). Le démarrage ne fonctionne que si `mm` lui-même tourne sur le Mac. Il ne fonctionne pas quand `mm` tourne dans un container ou un sandbox Docker : là, `mm` ne lance rien et affiche `[warning: razorbill.autoStart: rzb runs on macOS only …]` si aucun serveur ne répond. Démarrez alors `rzb` vous-même sur le Mac (voir la section suivante).
36+- **Votre serveur n'est pas touché.** Un serveur que vous avez lancé vous-même (par exemple `rzb serve` dans un terminal) est utilisé tel quel et jamais arrêté.
37+- **Partagé entre les sessions.** Plusieurs sessions `mm` sur la même adresse partagent un seul serveur. La sortie de `rzb serve` et de `rzb models pull` va dans `~/Library/Caches/mm/rzb/127.0.0.1-7920/rzb.log`.
38+- **Un autre binaire ou d'autres réglages.** `server:` désigne l'exécutable `rzb` (par défaut : `rzb` dans le `PATH`, puis `/usr/local/bin/rzb`). `config:` est la configuration serveur de rzb (modèles déclarés, valeurs par défaut, limites). `serverArgs:` ajoute toute autre option. `startTimeout:` (par défaut `15m`) borne le démarrage et le téléchargement.
39+
40+## Variantes
41+
42+- **Depuis un container ou un sandbox Docker.** Démarrez rzb sur le Mac sur toutes les interfaces, avec une clé puisqu'il est alors joignable depuis votre réseau : `RZB_API_KEY=… rzb serve --host 0.0.0.0`. Si aucun `baseUrl` ne répond, `mm` se replie de lui-même sur `http://host.docker.internal:7920/v1`. Exportez la même clé dans `RZB_API_KEY` là où tourne `mm`. Dans un sandbox, autorisez `localhost:7920` dans la politique réseau.
43+- **Un serveur protégé.** Quand son `RZB_API_KEY` est défini, rzb vérifie `Authorization: Bearer` sur toutes les routes sauf `/health`. `mm` lit aussi `RZB_API_KEY` (ou la variable nommée sous `apiKeyEnv`). Une clé refusée donne un avertissement au démarrage qui nomme la variable.
44+- **Un autre modèle.** Mettez dans `model:` un identifiant tel que `GET /v1/models` le liste (`curl -s localhost:7920/v1/models`) : un identifiant Hugging Face au format MLX, ou un nom court déclaré dans la configuration de rzb. Un modèle que rzb ne liste pas donne un avertissement au démarrage, `model "…" is not downloaded — rzb models pull …` : la première question le téléchargerait, et le watchdog peut abandonner avant la fin du téléchargement.
45+- **Écrire le fichier avec l'assistant.** `mm init --provider razorbill` liste les modèles du serveur et, sur cette machine, demande si `mm` doit démarrer rzb (`--autostart`, oui par défaut). Voir [Comment créer un agent](create-an-agent.md).
46+- **Raisonnement.** rzb obéit à `chat_template_kwargs.enable_thinking`, qui l'emporte sur `reasoning_effort`. Voir [Comment couper le raisonnement d'un modèle](turn-reasoning-off.md).
47+- **Mémoire.** rzb décharge lui-même un modèle inactif (son `keep_alive`, 10 minutes par défaut). Il n'a pas de route de déchargement : `/unload` et l'outil `unload_model` ne peuvent pas le libérer plus tôt.
48+
49+## Voir aussi
50+
51+- Les clés `razorbill` : [référence de la configuration](../reference/configuration.md).
52+- Pourquoi chaque serveur a sa propre entrée : [les providers](../explanation/providers.md).
new file mode 100644
@@ -0,0 +1,52 @@
1+# Comment faire tourner mini-me sur razorbill
2+
3+Ce guide montre comment brancher `mm` sur razorbill, un serveur de modèles MLX pour les Mac Apple Silicon (commande `rzb`, sans Python), via son point d'accès compatible OpenAI, et comment laisser `mm` le démarrer et l'arrêter. Il suppose que `rzb` est compilé et installé sur le Mac (le `scripts/install.sh` de razorbill le met dans `/usr/local/bin`) et que vous savez compiler `mm`.
4+
5+## Étapes
6+
7+1. Téléchargez un modèle et démarrez le serveur. `rzb serve` écoute sur `127.0.0.1:7920` et charge un modèle à la première requête qui le nomme :
8+
9+ ```bash
10+ rzb models pull mlx-community/Qwen3-4B-4bit
11+ rzb serve
12+ ```
13+
14+2. Écrivez le fichier d'agent :
15+
16+ ```yaml
17+ provider: razorbill
18+ model: mlx-community/Qwen3-4B-4bit
19+ ```
20+
21+3. Lancez `mm` avec ce fichier et vérifiez la bannière : `provider: razorbill`. rzb ne donne pas la fenêtre de contexte, la bannière affiche donc `ctx: unknown`. Indiquez `contextWindow:` (la fenêtre du modèle) si vous voulez que la compaction s'appuie dessus.
22+
23+## Laisser mm démarrer rzb
24+
25+Avec `autoStart`, plus besoin du `rzb serve` de l'étape 1 : quand rien ne répond à l'adresse de l'agent, `mm` y lance `rzb serve`, télécharge le modèle avec `rzb models pull` si rzb ne le liste pas, et arrête le serveur quand la dernière session `mm` qui l'utilise se termine.
26+
27+```yaml
28+provider: razorbill
29+model: mlx-community/Qwen3-4B-4bit
30+razorbill:
31+ autoStart: true
32+ # config: rzb-server.yaml # rzb serve --config, relatif à ce fichier
33+```
34+
35+- **Sur le Mac uniquement.** rzb tourne sur macOS (Apple Silicon). Le démarrage ne fonctionne que si `mm` lui-même tourne sur le Mac. Il ne fonctionne pas quand `mm` tourne dans un container ou un sandbox Docker : là, `mm` ne lance rien et affiche `[warning: razorbill.autoStart: rzb runs on macOS only …]` si aucun serveur ne répond. Démarrez alors `rzb` vous-même sur le Mac (voir la section suivante).
36+- **Votre serveur n'est pas touché.** Un serveur que vous avez lancé vous-même (par exemple `rzb serve` dans un terminal) est utilisé tel quel et jamais arrêté.
37+- **Partagé entre les sessions.** Plusieurs sessions `mm` sur la même adresse partagent un seul serveur. La sortie de `rzb serve` et de `rzb models pull` va dans `~/Library/Caches/mm/rzb/127.0.0.1-7920/rzb.log`.
38+- **Un autre binaire ou d'autres réglages.** `server:` désigne l'exécutable `rzb` (par défaut : `rzb` dans le `PATH`, puis `/usr/local/bin/rzb`). `config:` est la configuration serveur de rzb (modèles déclarés, valeurs par défaut, limites). `serverArgs:` ajoute toute autre option. `startTimeout:` (par défaut `15m`) borne le démarrage et le téléchargement.
39+
40+## Variantes
41+
42+- **Depuis un container ou un sandbox Docker.** Démarrez rzb sur le Mac sur toutes les interfaces, avec une clé puisqu'il est alors joignable depuis votre réseau : `RZB_API_KEY=… rzb serve --host 0.0.0.0`. Si aucun `baseUrl` ne répond, `mm` se replie de lui-même sur `http://host.docker.internal:7920/v1`. Exportez la même clé dans `RZB_API_KEY` là où tourne `mm`. Dans un sandbox, autorisez `localhost:7920` dans la politique réseau.
43+- **Un serveur protégé.** Quand son `RZB_API_KEY` est défini, rzb vérifie `Authorization: Bearer` sur toutes les routes sauf `/health`. `mm` lit aussi `RZB_API_KEY` (ou la variable nommée sous `apiKeyEnv`). Une clé refusée donne un avertissement au démarrage qui nomme la variable.
44+- **Un autre modèle.** Mettez dans `model:` un identifiant tel que `GET /v1/models` le liste (`curl -s localhost:7920/v1/models`) : un identifiant Hugging Face au format MLX, ou un nom court déclaré dans la configuration de rzb. Un modèle que rzb ne liste pas donne un avertissement au démarrage, `model "…" is not downloaded — rzb models pull …` : la première question le téléchargerait, et le watchdog peut abandonner avant la fin du téléchargement.
45+- **Écrire le fichier avec l'assistant.** `mm init --provider razorbill` liste les modèles du serveur et, sur cette machine, demande si `mm` doit démarrer rzb (`--autostart`, oui par défaut). Voir [Comment créer un agent](create-an-agent.md).
46+- **Raisonnement.** rzb obéit à `chat_template_kwargs.enable_thinking`, qui l'emporte sur `reasoning_effort`. Voir [Comment couper le raisonnement d'un modèle](turn-reasoning-off.md).
47+- **Mémoire.** rzb décharge lui-même un modèle inactif (son `keep_alive`, 10 minutes par défaut). Il n'a pas de route de déchargement : `/unload` et l'outil `unload_model` ne peuvent pas le libérer plus tôt.
48+
49+## Voir aussi
50+
51+- Les clés `razorbill` : [référence de la configuration](../reference/configuration.md).
52+- Pourquoi chaque serveur a sa propre entrée : [les providers](../explanation/providers.md).
modified docs/fr/how-to/turn-reasoning-off.md +2 -2
@@ -8,7 +8,7 @@ Un modèle à raisonnement (Qwen3.5, Qwen3.x, gpt-oss…) réfléchit avant de r
88
99 2. Ajoutez l'interrupteur propre au serveur sous `sampling`.
1010
11- Pour `dmr`, `llamacpp`, `llmman` ou `kronk` — tous llama.cpp en dessous :
11+ Pour `dmr`, `llamacpp`, `llmman` ou `kronk` — tous llama.cpp en dessous — et pour `razorbill`, où `enable_thinking` l'emporte sur `reasoning_effort` (mesuré sur rzb 0.2.0) :
1212
1313 ```yaml
1414 sampling:
@@ -72,7 +72,7 @@ Un modèle à raisonnement (Qwen3.5, Qwen3.x, gpt-oss…) réfléchit avant de r
7272 - Avec `ollama`, `reasoning_effort` se place au premier niveau de `sampling`, pas sous `chat_template_kwargs` ; seule la valeur `none` y a été mesurée.
7373 - Les résumés de compaction ne le suivent pas — voir ci-dessous.
7474 - **Le couper pour une seule exécution.** Gardez deux fichiers de configuration, ou démarrez le serveur lui-même sans raisonnement (pour llama-server, voir son option `--reasoning-budget`).
75-- **Résumés de compaction.** Rien à faire : `mm` coupe le raisonnement pour le résumé de `/compact` et de la compression automatique, quoi que dise `sampling`. Avec `dmr`, `llamacpp`, `llmman` et `kronk`, il fixe `enable_thinking: false` dans `chat_template_kwargs`, garde vos autres variables de template, et ramène à `low` un `reasoning_effort` que vous y avez mis — le template de gpt-oss n'a pas d'« arrêt », donc un résumé produit par ce modèle raisonne encore un peu, et cela est décompté de `context.summaryMaxTokens`. Avec `ollama`, il envoie `reasoning_effort: none`. Avec `mlxserve`, il fait les deux.
75+- **Résumés de compaction.** Rien à faire : `mm` coupe le raisonnement pour le résumé de `/compact` et de la compression automatique, quoi que dise `sampling`. Avec `dmr`, `llamacpp`, `llmman`, `kronk` et `razorbill`, il fixe `enable_thinking: false` dans `chat_template_kwargs`, garde vos autres variables de template, et ramène à `low` un `reasoning_effort` que vous y avez mis — le template de gpt-oss n'a pas d'« arrêt », donc un résumé produit par ce modèle raisonne encore un peu, et cela est décompté de `context.summaryMaxTokens`. Avec `ollama`, il envoie `reasoning_effort: none`. Avec `mlxserve`, il fait les deux.
7676
7777 ## Voir aussi
7878
@@ -8,7 +8,7 @@ Un modèle à raisonnement (Qwen3.5, Qwen3.x, gpt-oss…) réfléchit avant de r
8 8
9 2. Ajoutez l'interrupteur propre au serveur sous `sampling`.9 2. Ajoutez l'interrupteur propre au serveur sous `sampling`.
10 10
11- Pour `dmr`, `llamacpp`, `llmman` ou `kronk` — tous llama.cpp en dessous :11+ Pour `dmr`, `llamacpp`, `llmman` ou `kronk` — tous llama.cpp en dessous — et pour `razorbill`, où `enable_thinking` l'emporte sur `reasoning_effort` (mesuré sur rzb 0.2.0) :
12 12
13 ```yaml13 ```yaml
14 sampling:14 sampling:
@@ -72,7 +72,7 @@ Un modèle à raisonnement (Qwen3.5, Qwen3.x, gpt-oss…) réfléchit avant de r
72 - Avec `ollama`, `reasoning_effort` se place au premier niveau de `sampling`, pas sous `chat_template_kwargs` ; seule la valeur `none` y a été mesurée.72 - Avec `ollama`, `reasoning_effort` se place au premier niveau de `sampling`, pas sous `chat_template_kwargs` ; seule la valeur `none` y a été mesurée.
73 - Les résumés de compaction ne le suivent pas — voir ci-dessous.73 - Les résumés de compaction ne le suivent pas — voir ci-dessous.
74 - **Le couper pour une seule exécution.** Gardez deux fichiers de configuration, ou démarrez le serveur lui-même sans raisonnement (pour llama-server, voir son option `--reasoning-budget`).74 - **Le couper pour une seule exécution.** Gardez deux fichiers de configuration, ou démarrez le serveur lui-même sans raisonnement (pour llama-server, voir son option `--reasoning-budget`).
75-- **Résumés de compaction.** Rien à faire : `mm` coupe le raisonnement pour le résumé de `/compact` et de la compression automatique, quoi que dise `sampling`. Avec `dmr`, `llamacpp`, `llmman` et `kronk`, il fixe `enable_thinking: false` dans `chat_template_kwargs`, garde vos autres variables de template, et ramène à `low` un `reasoning_effort` que vous y avez mis — le template de gpt-oss n'a pas d'« arrêt », donc un résumé produit par ce modèle raisonne encore un peu, et cela est décompté de `context.summaryMaxTokens`. Avec `ollama`, il envoie `reasoning_effort: none`. Avec `mlxserve`, il fait les deux.75+- **Résumés de compaction.** Rien à faire : `mm` coupe le raisonnement pour le résumé de `/compact` et de la compression automatique, quoi que dise `sampling`. Avec `dmr`, `llamacpp`, `llmman`, `kronk` et `razorbill`, il fixe `enable_thinking: false` dans `chat_template_kwargs`, garde vos autres variables de template, et ramène à `low` un `reasoning_effort` que vous y avez mis — le template de gpt-oss n'a pas d'« arrêt », donc un résumé produit par ce modèle raisonne encore un peu, et cela est décompté de `context.summaryMaxTokens`. Avec `ollama`, il envoie `reasoning_effort: none`. Avec `mlxserve`, il fait les deux.
76 76
77 ## Voir aussi77 ## Voir aussi
78 78
modified docs/fr/reference/cli.md +3 -3
@@ -90,7 +90,7 @@ La règle dépend de l'emplacement du fichier, pas de la façon dont il a été
9090 | `MM_BIN` | Posée par `mm` dans son propre environnement, dont héritent tous les processus qu'il lance — les commandes de son outil `bash`, ses hooks : le chemin du binaire `mm` en cours. |
9191 | `MM_CONFIG` | Posée par `mm` dans son propre environnement, comme `MM_BIN`, quand un fichier de configuration a été lu : le chemin absolu de son fichier de configuration. Lue par `--ask` / `--ask-with-context` quand ni `-config` ni chemin positionnel ne sont donnés. |
9292 | `MM_ASK_DEPTH` | Nombre de niveaux de `/ask` au-dessus de cet agent (absente = 0). Posée par `/ask` ; à 2, `/ask` est refusée. |
93-| Variable nommée par `apiKeyEnv` | Contient la clé d'API. Nom par défaut : aucun pour `dmr`, `LLAMA_API_KEY` pour `llamacpp`, `LLMMAN_API_KEY` pour `llmman`, `OLLAMA_API_KEY` pour `ollama`, `KRONK_TOKEN` pour `kronk`, `MLX_SERVE_API_KEY` pour `mlxserve`. |
93+| Variable nommée par `apiKeyEnv` | Contient la clé d'API. Nom par défaut : aucun pour `dmr`, `LLAMA_API_KEY` pour `llamacpp`, `LLMMAN_API_KEY` pour `llmman`, `OLLAMA_API_KEY` pour `ollama`, `KRONK_TOKEN` pour `kronk`, `MLX_SERVE_API_KEY` pour `mlxserve`, `RZB_API_KEY` pour `razorbill`. |
9494
9595 ## Sortie de démarrage
9696
@@ -267,7 +267,7 @@ Un fichier d'agent hors du workspace ne donne qu'un avertissement : voir [quand
267267 | Option | Question quand elle est absente | Défaut |
268268 |--------|---------------------------------|--------|
269269 | `--project yes\|no` | Tout ranger dans un dossier `.mm` ? — posée en premier. `yes` : le fichier est `.mm/agent.yaml` (le dossier est créé), ses chemins sont écrits depuis la racine du projet (`skillsDir: .mm/skills`), et `mm` / `mm tui` lancés là le trouvent sans argument | `no` |
270-| `--provider` | Serveur de modèles : `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `openai`, `openai-responses` | le premier serveur local qui répond, dans cet ordre (`llamacpp` sur 9931, puis 8080), sinon `llamacpp` (`openai` et `openai-responses` ne sont jamais sondés : leur adresse par défaut est l'API d'OpenAI) |
270+| `--provider` | Serveur de modèles : `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `razorbill`, `openai`, `openai-responses` | le premier serveur local qui répond, dans cet ordre (`llamacpp` sur 9931, puis 8080), sinon `llamacpp` (`openai` et `openai-responses` ne sont jamais sondés : leur adresse par défaut est l'API d'OpenAI) |
271271 | `--base-url` | `openai` et `openai-responses` seulement : Endpoint — l'adresse compatible OpenAI du service (OpenAI, Cerebras, Hugging Face…) ; pour les autres fournisseurs, pas posée | `https://api.openai.com/v1` pour `openai` et `openai-responses` ; sinon `AGENT_BASE_URL` s'il est défini, sinon la première des adresses locales du fournisseur dont la liste de modèles répond — son adresse par défaut, puis la même avec `127.0.0.1` quand elle nomme `localhost`, puis pour `llamacpp` l'ancien port de llama-server, `http://127.0.0.1:8080/v1` — et son adresse de secours pour conteneur (`host.docker.internal`) seulement quand aucune ne répond. La question du modèle nomme l'adresse d'où vient sa liste (`Model? (listed from …)`). Écrite comme `baseUrl` sauf si c'est la valeur par défaut |
272272 | `--api-key-env` | `openai` et `openai-responses` seulement : variable d'environnement qui contient la clé d'API | `OPENAI_API_KEY`. Écrite comme `apiKeyEnv` sauf si c'est la valeur par défaut |
273273 | `--model` | Modèle : la liste des modèles du serveur (`/api/tags` pour llmman et Ollama, `/models` pour les autres ; 5 s pour un serveur local, 20 s pour `openai`), ou un nom à taper quand il n'y a pas de liste — la question dit pourquoi (`<VARIABLE> is not set: no list`, ou l'erreur du serveur). Pour `openai`, la liste est demandée avec la clé lue dans la variable nommée plus haut, et pas demandée du tout quand cette variable est vide | le premier de la liste |
@@ -277,7 +277,7 @@ Un fichier d'agent hors du workspace ne donne qu'un avertissement : voir [quand
277277 | `--yolo yes\|no` | Demander avant chaque commande ou modification de fichier ? — seulement pour les usages avec `bash`, les outils de fichiers ou `fetch_content` | celui de l'usage |
278278 | `--sessions yes\|no` | Enregistrer les conversations ? | `no` ; `yes` : une section `sessions` (`enabled: true`, `dir: .mm/sessions`) ; `no` : pas de section, le défaut de mm (désactivé) s'applique |
279279 | `--skills yes\|no` | Utiliser des skills ? | `no` (`skillsDir: no-skills`) ; `yes` : `skillsDir: skills`, ou `.mm/skills` avec `--project yes`, et le dossier est créé depuis la racine du projet une fois le fichier écrit |
280-| `--autostart yes\|no` | Laisser mm démarrer llama-server quand il ne tourne pas ? (llamacpp sur cette machine seulement) | `yes` (`llamacpp.autoStart: true`) ; `no` : `autoStart: false`, vous démarrez le serveur |
280+| `--autostart yes\|no` | Laisser mm démarrer llama-server (llamacpp) ou rzb (razorbill) quand il ne tourne pas ? (ces deux fournisseurs, sur cette machine seulement) | `yes` (`llamacpp.autoStart: true`, `razorbill.autoStart: true`) ; `no` : `autoStart: false`, vous démarrez le serveur |
281281 | `--launch-settings yes\|no` | Écrire les réglages de lancement de llama-server ? (avec `--autostart yes` seulement) | `no` (les valeurs par défaut de llama-server) ; `yes` : les valeurs de l'application Llama — `modelsMax: 0`, `modelsMemoryMargin: 1024`, `fitTarget: 1024`, `sleepIdleSeconds: 300`, `specDefault: true` |
282282 | `--name` | Nom de l'agent (`acp.name`) | le nom de l'usage |
283283 | `-o`, `--output` | Fichier à écrire (`-` = sortie standard : rien n'est créé, quelles que soient les autres réponses). Avec `--project yes`, un fichier qui n'est pas directement dans un dossier `.mm` est refusé | `agent.yaml` ; `.mm/agent.yaml` avec `--project yes` |
@@ -90,7 +90,7 @@ La règle dépend de l'emplacement du fichier, pas de la façon dont il a été
90 | `MM_BIN` | Posée par `mm` dans son propre environnement, dont héritent tous les processus qu'il lance — les commandes de son outil `bash`, ses hooks : le chemin du binaire `mm` en cours. |90 | `MM_BIN` | Posée par `mm` dans son propre environnement, dont héritent tous les processus qu'il lance — les commandes de son outil `bash`, ses hooks : le chemin du binaire `mm` en cours. |
91 | `MM_CONFIG` | Posée par `mm` dans son propre environnement, comme `MM_BIN`, quand un fichier de configuration a été lu : le chemin absolu de son fichier de configuration. Lue par `--ask` / `--ask-with-context` quand ni `-config` ni chemin positionnel ne sont donnés. |91 | `MM_CONFIG` | Posée par `mm` dans son propre environnement, comme `MM_BIN`, quand un fichier de configuration a été lu : le chemin absolu de son fichier de configuration. Lue par `--ask` / `--ask-with-context` quand ni `-config` ni chemin positionnel ne sont donnés. |
92 | `MM_ASK_DEPTH` | Nombre de niveaux de `/ask` au-dessus de cet agent (absente = 0). Posée par `/ask` ; à 2, `/ask` est refusée. |92 | `MM_ASK_DEPTH` | Nombre de niveaux de `/ask` au-dessus de cet agent (absente = 0). Posée par `/ask` ; à 2, `/ask` est refusée. |
93-| Variable nommée par `apiKeyEnv` | Contient la clé d'API. Nom par défaut : aucun pour `dmr`, `LLAMA_API_KEY` pour `llamacpp`, `LLMMAN_API_KEY` pour `llmman`, `OLLAMA_API_KEY` pour `ollama`, `KRONK_TOKEN` pour `kronk`, `MLX_SERVE_API_KEY` pour `mlxserve`. |93+| Variable nommée par `apiKeyEnv` | Contient la clé d'API. Nom par défaut : aucun pour `dmr`, `LLAMA_API_KEY` pour `llamacpp`, `LLMMAN_API_KEY` pour `llmman`, `OLLAMA_API_KEY` pour `ollama`, `KRONK_TOKEN` pour `kronk`, `MLX_SERVE_API_KEY` pour `mlxserve`, `RZB_API_KEY` pour `razorbill`. |
94 94
95 ## Sortie de démarrage95 ## Sortie de démarrage
96 96
@@ -267,7 +267,7 @@ Un fichier d'agent hors du workspace ne donne qu'un avertissement : voir [quand
267 | Option | Question quand elle est absente | Défaut |267 | Option | Question quand elle est absente | Défaut |
268 |--------|---------------------------------|--------|268 |--------|---------------------------------|--------|
269 | `--project yes\|no` | Tout ranger dans un dossier `.mm` ? — posée en premier. `yes` : le fichier est `.mm/agent.yaml` (le dossier est créé), ses chemins sont écrits depuis la racine du projet (`skillsDir: .mm/skills`), et `mm` / `mm tui` lancés là le trouvent sans argument | `no` |269 | `--project yes\|no` | Tout ranger dans un dossier `.mm` ? — posée en premier. `yes` : le fichier est `.mm/agent.yaml` (le dossier est créé), ses chemins sont écrits depuis la racine du projet (`skillsDir: .mm/skills`), et `mm` / `mm tui` lancés là le trouvent sans argument | `no` |
270-| `--provider` | Serveur de modèles : `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `openai`, `openai-responses` | le premier serveur local qui répond, dans cet ordre (`llamacpp` sur 9931, puis 8080), sinon `llamacpp` (`openai` et `openai-responses` ne sont jamais sondés : leur adresse par défaut est l'API d'OpenAI) |270+| `--provider` | Serveur de modèles : `llamacpp`, `llmman`, `ollama`, `dmr`, `kronk`, `mlxserve`, `razorbill`, `openai`, `openai-responses` | le premier serveur local qui répond, dans cet ordre (`llamacpp` sur 9931, puis 8080), sinon `llamacpp` (`openai` et `openai-responses` ne sont jamais sondés : leur adresse par défaut est l'API d'OpenAI) |
271 | `--base-url` | `openai` et `openai-responses` seulement : Endpoint — l'adresse compatible OpenAI du service (OpenAI, Cerebras, Hugging Face…) ; pour les autres fournisseurs, pas posée | `https://api.openai.com/v1` pour `openai` et `openai-responses` ; sinon `AGENT_BASE_URL` s'il est défini, sinon la première des adresses locales du fournisseur dont la liste de modèles répond — son adresse par défaut, puis la même avec `127.0.0.1` quand elle nomme `localhost`, puis pour `llamacpp` l'ancien port de llama-server, `http://127.0.0.1:8080/v1` — et son adresse de secours pour conteneur (`host.docker.internal`) seulement quand aucune ne répond. La question du modèle nomme l'adresse d'où vient sa liste (`Model? (listed from …)`). Écrite comme `baseUrl` sauf si c'est la valeur par défaut |271 | `--base-url` | `openai` et `openai-responses` seulement : Endpoint — l'adresse compatible OpenAI du service (OpenAI, Cerebras, Hugging Face…) ; pour les autres fournisseurs, pas posée | `https://api.openai.com/v1` pour `openai` et `openai-responses` ; sinon `AGENT_BASE_URL` s'il est défini, sinon la première des adresses locales du fournisseur dont la liste de modèles répond — son adresse par défaut, puis la même avec `127.0.0.1` quand elle nomme `localhost`, puis pour `llamacpp` l'ancien port de llama-server, `http://127.0.0.1:8080/v1` — et son adresse de secours pour conteneur (`host.docker.internal`) seulement quand aucune ne répond. La question du modèle nomme l'adresse d'où vient sa liste (`Model? (listed from …)`). Écrite comme `baseUrl` sauf si c'est la valeur par défaut |
272 | `--api-key-env` | `openai` et `openai-responses` seulement : variable d'environnement qui contient la clé d'API | `OPENAI_API_KEY`. Écrite comme `apiKeyEnv` sauf si c'est la valeur par défaut |272 | `--api-key-env` | `openai` et `openai-responses` seulement : variable d'environnement qui contient la clé d'API | `OPENAI_API_KEY`. Écrite comme `apiKeyEnv` sauf si c'est la valeur par défaut |
273 | `--model` | Modèle : la liste des modèles du serveur (`/api/tags` pour llmman et Ollama, `/models` pour les autres ; 5 s pour un serveur local, 20 s pour `openai`), ou un nom à taper quand il n'y a pas de liste — la question dit pourquoi (`<VARIABLE> is not set: no list`, ou l'erreur du serveur). Pour `openai`, la liste est demandée avec la clé lue dans la variable nommée plus haut, et pas demandée du tout quand cette variable est vide | le premier de la liste |273 | `--model` | Modèle : la liste des modèles du serveur (`/api/tags` pour llmman et Ollama, `/models` pour les autres ; 5 s pour un serveur local, 20 s pour `openai`), ou un nom à taper quand il n'y a pas de liste — la question dit pourquoi (`<VARIABLE> is not set: no list`, ou l'erreur du serveur). Pour `openai`, la liste est demandée avec la clé lue dans la variable nommée plus haut, et pas demandée du tout quand cette variable est vide | le premier de la liste |
@@ -277,7 +277,7 @@ Un fichier d'agent hors du workspace ne donne qu'un avertissement : voir [quand
277 | `--yolo yes\|no` | Demander avant chaque commande ou modification de fichier ? — seulement pour les usages avec `bash`, les outils de fichiers ou `fetch_content` | celui de l'usage |277 | `--yolo yes\|no` | Demander avant chaque commande ou modification de fichier ? — seulement pour les usages avec `bash`, les outils de fichiers ou `fetch_content` | celui de l'usage |
278 | `--sessions yes\|no` | Enregistrer les conversations ? | `no` ; `yes` : une section `sessions` (`enabled: true`, `dir: .mm/sessions`) ; `no` : pas de section, le défaut de mm (désactivé) s'applique |278 | `--sessions yes\|no` | Enregistrer les conversations ? | `no` ; `yes` : une section `sessions` (`enabled: true`, `dir: .mm/sessions`) ; `no` : pas de section, le défaut de mm (désactivé) s'applique |
279 | `--skills yes\|no` | Utiliser des skills ? | `no` (`skillsDir: no-skills`) ; `yes` : `skillsDir: skills`, ou `.mm/skills` avec `--project yes`, et le dossier est créé depuis la racine du projet une fois le fichier écrit |279 | `--skills yes\|no` | Utiliser des skills ? | `no` (`skillsDir: no-skills`) ; `yes` : `skillsDir: skills`, ou `.mm/skills` avec `--project yes`, et le dossier est créé depuis la racine du projet une fois le fichier écrit |
280-| `--autostart yes\|no` | Laisser mm démarrer llama-server quand il ne tourne pas ? (llamacpp sur cette machine seulement) | `yes` (`llamacpp.autoStart: true`) ; `no` : `autoStart: false`, vous démarrez le serveur |280+| `--autostart yes\|no` | Laisser mm démarrer llama-server (llamacpp) ou rzb (razorbill) quand il ne tourne pas ? (ces deux fournisseurs, sur cette machine seulement) | `yes` (`llamacpp.autoStart: true`, `razorbill.autoStart: true`) ; `no` : `autoStart: false`, vous démarrez le serveur |
281 | `--launch-settings yes\|no` | Écrire les réglages de lancement de llama-server ? (avec `--autostart yes` seulement) | `no` (les valeurs par défaut de llama-server) ; `yes` : les valeurs de l'application Llama — `modelsMax: 0`, `modelsMemoryMargin: 1024`, `fitTarget: 1024`, `sleepIdleSeconds: 300`, `specDefault: true` |281 | `--launch-settings yes\|no` | Écrire les réglages de lancement de llama-server ? (avec `--autostart yes` seulement) | `no` (les valeurs par défaut de llama-server) ; `yes` : les valeurs de l'application Llama — `modelsMax: 0`, `modelsMemoryMargin: 1024`, `fitTarget: 1024`, `sleepIdleSeconds: 300`, `specDefault: true` |
282 | `--name` | Nom de l'agent (`acp.name`) | le nom de l'usage |282 | `--name` | Nom de l'agent (`acp.name`) | le nom de l'usage |
283 | `-o`, `--output` | Fichier à écrire (`-` = sortie standard : rien n'est créé, quelles que soient les autres réponses). Avec `--project yes`, un fichier qui n'est pas directement dans un dossier `.mm` est refusé | `agent.yaml` ; `.mm/agent.yaml` avec `--project yes` |283 | `-o`, `--output` | Fichier à écrire (`-` = sortie standard : rien n'est créé, quelles que soient les autres réponses). Avec `--project yes`, un fichier qui n'est pas directement dans un dossier `.mm` est refusé | `agent.yaml` ; `.mm/agent.yaml` avec `--project yes` |
modified docs/fr/reference/configuration.md +4 -2
@@ -8,7 +8,7 @@ Où `mm` cherche ce fichier : [Résolution du fichier de configuration](cli.md#r
88
99 | Clé | Type | Défaut | Description |
1010 |-----|------|--------|-------------|
11-| `provider` | chaîne | `dmr` | Clé du registre du serveur LLM : `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `openai` pour tout autre serveur compatible OpenAI (voir [Utiliser n'importe quel serveur compatible OpenAI](../how-to/run-with-an-openai-compatible-server.md)), ou `openai-responses` pour les mêmes serveurs par l'API Responses d'OpenAI (voir [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](../how-to/use-the-openai-responses-api.md)). Surchargée par `AGENT_PROVIDER`. |
11+| `provider` | chaîne | `dmr` | Clé du registre du serveur LLM : `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `razorbill`, `openai` pour tout autre serveur compatible OpenAI (voir [Utiliser n'importe quel serveur compatible OpenAI](../how-to/run-with-an-openai-compatible-server.md)), ou `openai-responses` pour les mêmes serveurs par l'API Responses d'OpenAI (voir [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](../how-to/use-the-openai-responses-api.md)). Surchargée par `AGENT_PROVIDER`. |
1212 | `model` | chaîne | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Identifiant du modèle dans la nomenclature du fournisseur. Surchargé par `AGENT_MODEL`. |
1313 | `baseUrl` | chaîne | `""` (défaut du fournisseur) | Point d'accès compatible OpenAI essayé en premier. Surchargé par `AGENT_BASE_URL`. |
1414 | `fallback` | chaîne ou absente | absente (défaut du fournisseur) | Point d'accès utilisé quand `baseUrl` ne répond pas sur `/models` en 2 s. Absente = défaut du fournisseur ; `""` = pas de repli. |
@@ -40,6 +40,7 @@ Où `mm` cherche ce fichier : [Résolution du fichier de configuration](cli.md#r
4040 | `unloadModels` | bool | `true` | La commande `/unload [modèle]` (terminal, fenêtre, éditeur) et l'outil `unload_model`, qui libèrent un modèle de la mémoire du serveur : llmman et Ollama, Kronk, llama-server en mode router. `false` retire les deux. L'outil n'est jamais déclaré à côté d'une `structuredOutput` ni d'un bloc `decision`. Voir les [outils](tools.md#unload_model) et [Libérer la mémoire d'un modèle](../how-to/unload-a-model.md). |
4141 | `unloadOnExit` | booléen | `true` | Quand mm se termine — `/quit`, Ctrl-C à l'invite, Ctrl-D, la fenêtre fermée, la fin d'un `-p`, l'éditeur qui ferme la session ACP, SIGTERM, SIGHUP —, décharge le modèle de l'agent de la mémoire du serveur, pour qu'il ne garde pas sa RAM après la session. Une ligne `🧹` sur stderr (aucune en mode ACP) ; rien quand le modèle n'était pas chargé ou que le serveur ne sait pas décharger (dmr, openai, un llama-server mono-modèle). Borné à 3 s : un serveur qui ne répond pas ne retient jamais la sortie. Seul le modèle de l'agent — pas les modèles de décision, pas les agents `mmConfigs` (chacun décharge le sien quand il s'arrête). `false` : le modèle reste chargé (redémarrage plus rapide, ou une autre session ou un autre outil s'en sert — mm ne sait pas qui d'autre l'utilise). Indépendant d'`unloadModels`. Surchargé par `AGENT_UNLOAD_ON_EXIT`. Voir [Libérer la mémoire d'un modèle](../how-to/unload-a-model.md#quand-mm-se-termine). |
4242 | `llamacpp` | `{autoStart, server, ctxSize, modelsMax, modelsMemoryMargin, fitTarget, sleepIdleSeconds, specDefault, serverArgs, startTimeout}` | `autoStart: false` | Fournisseur `llamacpp` seulement. `autoStart: true` : quand rien ne répond à l'adresse de l'agent (une adresse de boucle locale, `AGENT_BASE_URL` non positionnée), ni sur 8080, ni au `fallback`, mm démarre llama-server en mode routeur avec le modèle de l'agent (téléchargé à son premier chargement), attend qu'il soit chargé, et l'arrête avec la dernière session mm qui l'utilise ; un serveur que mm n'a pas démarré n'est jamais arrêté. `server` : l'exécutable (par défaut `llama-server`, puis `llama serve`, dans le `PATH`). Réglages de lancement, tous facultatifs, chacun une option de llama-server (absent = la valeur par défaut de llama-server) : `ctxSize` (`--ctx-size`), `modelsMax` (`--models-max`), `modelsMemoryMargin` (`--models-memory-margin`), `fitTarget` (`--fit-target`), `sleepIdleSeconds` (`--sleep-idle-seconds`, `-1` accepté), `specDefault` (`--spec-default`) ; une valeur négative est une erreur de configuration. `serverArgs` : toute autre option, ajoutée en dernier. `startTimeout` (`15m` par défaut) : démarrage, téléchargement et chargement. Registre et log : `<dossier cache de l'utilisateur>/mm/llama-server/<hôte>-<port>/`. `mm init` le demande pour un agent llamacpp sur cette machine (`--autostart`, oui par défaut ; `--launch-settings`, les valeurs de l'application Llama, non par défaut). Voir [Laisser mm démarrer llama-server](../how-to/run-with-llama-cpp.md#laisser-mm-démarrer-llama-server). |
43+| `razorbill` | `{autoStart, server, config, serverArgs, startTimeout}` | `autoStart: false` | Fournisseur `razorbill` seulement. `autoStart: true` : quand rien ne répond à l'adresse de l'agent (une adresse de boucle locale, `AGENT_BASE_URL` non positionnée) ni au `fallback`, mm lance `rzb serve --host <hôte> --port <port>`, exécute `rzb models pull <modèle>` si le serveur ne liste pas le modèle, et arrête le serveur avec la dernière session mm qui l'utilise ; un serveur que mm n'a pas démarré n'est jamais arrêté. macOS seulement : ailleurs — mm dans un container ou un sandbox — rien n'est lancé et un avertissement le dit. `server` : l'exécutable `rzb` (par défaut `rzb` dans le `PATH`, puis `/usr/local/bin/rzb`). `config` : la configuration serveur de rzb, passée en `--config` ; un chemin relatif l'est au dossier du fichier d'agent, `~/` est le dossier personnel ; un fichier absent est une erreur de démarrage. `serverArgs` : toute autre option de `rzb serve`, ajoutée en dernier. `startTimeout` (`15m` par défaut, négatif = erreur de configuration) : démarrage et téléchargement. Registre et log (`rzb.log`, qui reçoit aussi la sortie du téléchargement) : `<dossier cache de l'utilisateur>/mm/rzb/<hôte>-<port>/`. `mm init` le demande pour un agent razorbill sur cette machine (`--autostart`, oui par défaut). Voir [Laisser mm démarrer rzb](../how-to/run-with-razorbill.md#laisser-mm-démarrer-rzb). |
4344 | `autoPull` | booléen | `false` | Au démarrage, télécharge les modèles que cet agent utilisera et que le serveur ne liste pas : le sien, ceux de ses agents `mmConfigs`, ceux de ses deciders `skillRouting` / `toolRouting`. La progression va sur stderr — une ligne réécrite sur place dans un terminal (`⬇ pulling <modèle> — 52 MB / 145 MB (35 %)`), une ligne par dixième ailleurs — puis `⬇ pulled <modèle> in 0.8s`. Un échec sur le modèle de l'agent arrête `mm` avec le message du serveur (`[engine error: autoPull: <modèle>: the server says: …]`) ; un échec sur un autre modèle, un serveur qui ne répond pas ou un fournisseur qui ne sait pas télécharger donne un `[warning: autoPull: …]`. Un agent lancé par `/ask` ou `ask_agent` ne télécharge rien ; `mm --ask` non plus. Un modèle que le serveur liste déjà n'est jamais téléchargé (un nom sans tag correspond aussi à son entrée `:latest`). Par fournisseur : `llmman` et `ollama` — `POST /api/pull` ; `kronk` — `POST /v1/kronk/models/pull`, le téléchargement ne comptant comme fait que si le flux de Kronk se termine par `"downloaded": true` (Kronk répond 200 à un téléchargement raté ; son dernier statut est alors le message) ; `dmr` — `POST /models/create` sur le runner (l'URL de base sans `/engines/…`), le téléchargement ne comptant comme fait qu'une fois le modèle listé par le runner ; `llamacpp` — pas de téléchargement par l'API : l'avertissement dit de lancer llama-server avec `-hf <dépôt>:<quant>`, ou de mettre le GGUF dans le dossier de modèles du router ; `openai` — un avertissement. |
4445 | `sampling` | dictionnaire | `temperature: 0.0`, `top_p: 0.9`, `max_tokens: 4096` | Paramètres de génération, noms de l'API OpenAI, transmis au serveur. Le bloc du fichier est fusionné avec ces valeurs par défaut : une valeur par défaut que le fichier ne nomme pas est quand même envoyée. **Sauf avec `provider: openai` et `provider: openai-responses`** : la requête porte exactement le bloc du fichier, rien d'ajouté (pas de bloc : aucune clé de génération, les valeurs par défaut du serveur s'appliquent) — les modèles de raisonnement hébergés par OpenAI refusent `max_tokens` et n'acceptent que la température par défaut, une valeur par défaut laissée là donnerait une erreur 400. Une clé que l'API OpenAI ne déclare pas est envoyée telle quelle, au premier niveau de la requête — par exemple `chat_template_kwargs: {enable_thinking: false}`, qui demande à un serveur llama.cpp (`dmr`, `llamacpp`, `llmman`) ou à Kronk de ne pas raisonner ; `reasoning_effort: none` fait de même avec Ollama. `messages`, `tools`, `tool_choice` (et les anciens `functions`, `function_call`) sont ignorées : Genkit les construit à partir de la conversation. L'`agent.yaml` livré ajoute `parallel_tool_calls: false`. `max_tokens` borne aussi un appel d'outil : un `write_file` de long document (ou le raisonnement d'un modèle « thinking » plus l'appel) peut l'atteindre, et l'appel est alors coupé. mm le rend deux fois au modèle en lui demandant de procéder par morceaux, puis s'arrête avec `the model hit max_tokens (N) while writing a tool call` ; augmentez la valeur si cela arrive. Une configuration qui nomme la limite `max_completion_tokens` (le nom de l'API OpenAI pour ses modèles récents) est lue de la même façon : ce nom est repris dans ce message et dans la requête de résumé de la compression du contexte. En streaming, mm demande aussi au serveur le compte des tokens (`stream_options.include_usage`). |
4546 | `watchdogTimeout` | durée | `20s` | Silence toléré entre deux tokens diffusés avant de déclarer la connexion bloquée. Doublé pour les requêtes de résumé. |
@@ -259,6 +260,7 @@ workspace:
259260 | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | non |
260261 | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | non — seuls les modes `authenticated` et `full-protected` de Kronk la vérifient |
261262 | `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | non — seul un serveur démarré avec `--api-key` la vérifie, et pas pour localhost |
263+| `razorbill` | `http://127.0.0.1:7920/v1` | `http://host.docker.internal:7920/v1` | `RZB_API_KEY` | non — seul un serveur dont `RZB_API_KEY` est défini la vérifie |
262264 | `openai` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — un serveur qui en exige une répond 401, et l'avertissement de démarrage nomme la variable |
263265 | `openai-responses` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — comme `openai` |
264266
@@ -533,7 +535,7 @@ Signalées sur stderr sous la forme `[config error: <chemin>: <message>]`, code
533535 | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | un nom commençant par `with-context` |
534536 | `mmConfigs.<nom>: the path must not be empty` | `<nom>: ""`, ou une forme longue sans `path` |
535537 | `hooks: unknown event "x" (…)`, `hooks.<événement>[N]: …` | un bloc `hooks:` invalide — voir [les hooks](hooks.md#erreurs-de-validation) |
536-| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses)` | Signalée par le moteur, sous la forme `[engine error: …]`. |
538+| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses, razorbill)` | Signalée par le moteur, sous la forme `[engine error: …]`. |
537539
538540 Un avertissement au démarrage, et non une erreur, est affiché quand `context.enabled` vaut `true`, que la fenêtre est inconnue et que `context.maxMessages` vaut `0`, quand un outil déclaré porte le nom d'un outil MCP (`tools: <nom> skipped — an MCP tool already has that name` ; l'outil n'est pas déclaré), et quand le fichier pose la clé obsolète `permissions` (`permissions: ask is deprecated — use yolo: false instead …`).
539541
@@ -8,7 +8,7 @@ Où `mm` cherche ce fichier : [Résolution du fichier de configuration](cli.md#r
8 8
9 | Clé | Type | Défaut | Description |9 | Clé | Type | Défaut | Description |
10 |-----|------|--------|-------------|10 |-----|------|--------|-------------|
11-| `provider` | chaîne | `dmr` | Clé du registre du serveur LLM : `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `openai` pour tout autre serveur compatible OpenAI (voir [Utiliser n'importe quel serveur compatible OpenAI](../how-to/run-with-an-openai-compatible-server.md)), ou `openai-responses` pour les mêmes serveurs par l'API Responses d'OpenAI (voir [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](../how-to/use-the-openai-responses-api.md)). Surchargée par `AGENT_PROVIDER`. |11+| `provider` | chaîne | `dmr` | Clé du registre du serveur LLM : `dmr`, `llamacpp`, `llmman`, `ollama`, `kronk`, `mlxserve`, `razorbill`, `openai` pour tout autre serveur compatible OpenAI (voir [Utiliser n'importe quel serveur compatible OpenAI](../how-to/run-with-an-openai-compatible-server.md)), ou `openai-responses` pour les mêmes serveurs par l'API Responses d'OpenAI (voir [Garder le raisonnement et les outils avec l'API Responses d'OpenAI](../how-to/use-the-openai-responses-api.md)). Surchargée par `AGENT_PROVIDER`. |
12 | `model` | chaîne | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Identifiant du modèle dans la nomenclature du fournisseur. Surchargé par `AGENT_MODEL`. |12 | `model` | chaîne | `huggingface.co/jetbrains/mellum2-12b-a2.5b-instruct-gguf-q4_k_m:Q4_K_M` | Identifiant du modèle dans la nomenclature du fournisseur. Surchargé par `AGENT_MODEL`. |
13 | `baseUrl` | chaîne | `""` (défaut du fournisseur) | Point d'accès compatible OpenAI essayé en premier. Surchargé par `AGENT_BASE_URL`. |13 | `baseUrl` | chaîne | `""` (défaut du fournisseur) | Point d'accès compatible OpenAI essayé en premier. Surchargé par `AGENT_BASE_URL`. |
14 | `fallback` | chaîne ou absente | absente (défaut du fournisseur) | Point d'accès utilisé quand `baseUrl` ne répond pas sur `/models` en 2 s. Absente = défaut du fournisseur ; `""` = pas de repli. |14 | `fallback` | chaîne ou absente | absente (défaut du fournisseur) | Point d'accès utilisé quand `baseUrl` ne répond pas sur `/models` en 2 s. Absente = défaut du fournisseur ; `""` = pas de repli. |
@@ -40,6 +40,7 @@ Où `mm` cherche ce fichier : [Résolution du fichier de configuration](cli.md#r
40 | `unloadModels` | bool | `true` | La commande `/unload [modèle]` (terminal, fenêtre, éditeur) et l'outil `unload_model`, qui libèrent un modèle de la mémoire du serveur : llmman et Ollama, Kronk, llama-server en mode router. `false` retire les deux. L'outil n'est jamais déclaré à côté d'une `structuredOutput` ni d'un bloc `decision`. Voir les [outils](tools.md#unload_model) et [Libérer la mémoire d'un modèle](../how-to/unload-a-model.md). |40 | `unloadModels` | bool | `true` | La commande `/unload [modèle]` (terminal, fenêtre, éditeur) et l'outil `unload_model`, qui libèrent un modèle de la mémoire du serveur : llmman et Ollama, Kronk, llama-server en mode router. `false` retire les deux. L'outil n'est jamais déclaré à côté d'une `structuredOutput` ni d'un bloc `decision`. Voir les [outils](tools.md#unload_model) et [Libérer la mémoire d'un modèle](../how-to/unload-a-model.md). |
41 | `unloadOnExit` | booléen | `true` | Quand mm se termine — `/quit`, Ctrl-C à l'invite, Ctrl-D, la fenêtre fermée, la fin d'un `-p`, l'éditeur qui ferme la session ACP, SIGTERM, SIGHUP —, décharge le modèle de l'agent de la mémoire du serveur, pour qu'il ne garde pas sa RAM après la session. Une ligne `🧹` sur stderr (aucune en mode ACP) ; rien quand le modèle n'était pas chargé ou que le serveur ne sait pas décharger (dmr, openai, un llama-server mono-modèle). Borné à 3 s : un serveur qui ne répond pas ne retient jamais la sortie. Seul le modèle de l'agent — pas les modèles de décision, pas les agents `mmConfigs` (chacun décharge le sien quand il s'arrête). `false` : le modèle reste chargé (redémarrage plus rapide, ou une autre session ou un autre outil s'en sert — mm ne sait pas qui d'autre l'utilise). Indépendant d'`unloadModels`. Surchargé par `AGENT_UNLOAD_ON_EXIT`. Voir [Libérer la mémoire d'un modèle](../how-to/unload-a-model.md#quand-mm-se-termine). |41 | `unloadOnExit` | booléen | `true` | Quand mm se termine — `/quit`, Ctrl-C à l'invite, Ctrl-D, la fenêtre fermée, la fin d'un `-p`, l'éditeur qui ferme la session ACP, SIGTERM, SIGHUP —, décharge le modèle de l'agent de la mémoire du serveur, pour qu'il ne garde pas sa RAM après la session. Une ligne `🧹` sur stderr (aucune en mode ACP) ; rien quand le modèle n'était pas chargé ou que le serveur ne sait pas décharger (dmr, openai, un llama-server mono-modèle). Borné à 3 s : un serveur qui ne répond pas ne retient jamais la sortie. Seul le modèle de l'agent — pas les modèles de décision, pas les agents `mmConfigs` (chacun décharge le sien quand il s'arrête). `false` : le modèle reste chargé (redémarrage plus rapide, ou une autre session ou un autre outil s'en sert — mm ne sait pas qui d'autre l'utilise). Indépendant d'`unloadModels`. Surchargé par `AGENT_UNLOAD_ON_EXIT`. Voir [Libérer la mémoire d'un modèle](../how-to/unload-a-model.md#quand-mm-se-termine). |
42 | `llamacpp` | `{autoStart, server, ctxSize, modelsMax, modelsMemoryMargin, fitTarget, sleepIdleSeconds, specDefault, serverArgs, startTimeout}` | `autoStart: false` | Fournisseur `llamacpp` seulement. `autoStart: true` : quand rien ne répond à l'adresse de l'agent (une adresse de boucle locale, `AGENT_BASE_URL` non positionnée), ni sur 8080, ni au `fallback`, mm démarre llama-server en mode routeur avec le modèle de l'agent (téléchargé à son premier chargement), attend qu'il soit chargé, et l'arrête avec la dernière session mm qui l'utilise ; un serveur que mm n'a pas démarré n'est jamais arrêté. `server` : l'exécutable (par défaut `llama-server`, puis `llama serve`, dans le `PATH`). Réglages de lancement, tous facultatifs, chacun une option de llama-server (absent = la valeur par défaut de llama-server) : `ctxSize` (`--ctx-size`), `modelsMax` (`--models-max`), `modelsMemoryMargin` (`--models-memory-margin`), `fitTarget` (`--fit-target`), `sleepIdleSeconds` (`--sleep-idle-seconds`, `-1` accepté), `specDefault` (`--spec-default`) ; une valeur négative est une erreur de configuration. `serverArgs` : toute autre option, ajoutée en dernier. `startTimeout` (`15m` par défaut) : démarrage, téléchargement et chargement. Registre et log : `<dossier cache de l'utilisateur>/mm/llama-server/<hôte>-<port>/`. `mm init` le demande pour un agent llamacpp sur cette machine (`--autostart`, oui par défaut ; `--launch-settings`, les valeurs de l'application Llama, non par défaut). Voir [Laisser mm démarrer llama-server](../how-to/run-with-llama-cpp.md#laisser-mm-démarrer-llama-server). |42 | `llamacpp` | `{autoStart, server, ctxSize, modelsMax, modelsMemoryMargin, fitTarget, sleepIdleSeconds, specDefault, serverArgs, startTimeout}` | `autoStart: false` | Fournisseur `llamacpp` seulement. `autoStart: true` : quand rien ne répond à l'adresse de l'agent (une adresse de boucle locale, `AGENT_BASE_URL` non positionnée), ni sur 8080, ni au `fallback`, mm démarre llama-server en mode routeur avec le modèle de l'agent (téléchargé à son premier chargement), attend qu'il soit chargé, et l'arrête avec la dernière session mm qui l'utilise ; un serveur que mm n'a pas démarré n'est jamais arrêté. `server` : l'exécutable (par défaut `llama-server`, puis `llama serve`, dans le `PATH`). Réglages de lancement, tous facultatifs, chacun une option de llama-server (absent = la valeur par défaut de llama-server) : `ctxSize` (`--ctx-size`), `modelsMax` (`--models-max`), `modelsMemoryMargin` (`--models-memory-margin`), `fitTarget` (`--fit-target`), `sleepIdleSeconds` (`--sleep-idle-seconds`, `-1` accepté), `specDefault` (`--spec-default`) ; une valeur négative est une erreur de configuration. `serverArgs` : toute autre option, ajoutée en dernier. `startTimeout` (`15m` par défaut) : démarrage, téléchargement et chargement. Registre et log : `<dossier cache de l'utilisateur>/mm/llama-server/<hôte>-<port>/`. `mm init` le demande pour un agent llamacpp sur cette machine (`--autostart`, oui par défaut ; `--launch-settings`, les valeurs de l'application Llama, non par défaut). Voir [Laisser mm démarrer llama-server](../how-to/run-with-llama-cpp.md#laisser-mm-démarrer-llama-server). |
43+| `razorbill` | `{autoStart, server, config, serverArgs, startTimeout}` | `autoStart: false` | Fournisseur `razorbill` seulement. `autoStart: true` : quand rien ne répond à l'adresse de l'agent (une adresse de boucle locale, `AGENT_BASE_URL` non positionnée) ni au `fallback`, mm lance `rzb serve --host <hôte> --port <port>`, exécute `rzb models pull <modèle>` si le serveur ne liste pas le modèle, et arrête le serveur avec la dernière session mm qui l'utilise ; un serveur que mm n'a pas démarré n'est jamais arrêté. macOS seulement : ailleurs — mm dans un container ou un sandbox — rien n'est lancé et un avertissement le dit. `server` : l'exécutable `rzb` (par défaut `rzb` dans le `PATH`, puis `/usr/local/bin/rzb`). `config` : la configuration serveur de rzb, passée en `--config` ; un chemin relatif l'est au dossier du fichier d'agent, `~/` est le dossier personnel ; un fichier absent est une erreur de démarrage. `serverArgs` : toute autre option de `rzb serve`, ajoutée en dernier. `startTimeout` (`15m` par défaut, négatif = erreur de configuration) : démarrage et téléchargement. Registre et log (`rzb.log`, qui reçoit aussi la sortie du téléchargement) : `<dossier cache de l'utilisateur>/mm/rzb/<hôte>-<port>/`. `mm init` le demande pour un agent razorbill sur cette machine (`--autostart`, oui par défaut). Voir [Laisser mm démarrer rzb](../how-to/run-with-razorbill.md#laisser-mm-démarrer-rzb). |
43 | `autoPull` | booléen | `false` | Au démarrage, télécharge les modèles que cet agent utilisera et que le serveur ne liste pas : le sien, ceux de ses agents `mmConfigs`, ceux de ses deciders `skillRouting` / `toolRouting`. La progression va sur stderr — une ligne réécrite sur place dans un terminal (`⬇ pulling <modèle> — 52 MB / 145 MB (35 %)`), une ligne par dixième ailleurs — puis `⬇ pulled <modèle> in 0.8s`. Un échec sur le modèle de l'agent arrête `mm` avec le message du serveur (`[engine error: autoPull: <modèle>: the server says: …]`) ; un échec sur un autre modèle, un serveur qui ne répond pas ou un fournisseur qui ne sait pas télécharger donne un `[warning: autoPull: …]`. Un agent lancé par `/ask` ou `ask_agent` ne télécharge rien ; `mm --ask` non plus. Un modèle que le serveur liste déjà n'est jamais téléchargé (un nom sans tag correspond aussi à son entrée `:latest`). Par fournisseur : `llmman` et `ollama` — `POST /api/pull` ; `kronk` — `POST /v1/kronk/models/pull`, le téléchargement ne comptant comme fait que si le flux de Kronk se termine par `"downloaded": true` (Kronk répond 200 à un téléchargement raté ; son dernier statut est alors le message) ; `dmr` — `POST /models/create` sur le runner (l'URL de base sans `/engines/…`), le téléchargement ne comptant comme fait qu'une fois le modèle listé par le runner ; `llamacpp` — pas de téléchargement par l'API : l'avertissement dit de lancer llama-server avec `-hf <dépôt>:<quant>`, ou de mettre le GGUF dans le dossier de modèles du router ; `openai` — un avertissement. |44 | `autoPull` | booléen | `false` | Au démarrage, télécharge les modèles que cet agent utilisera et que le serveur ne liste pas : le sien, ceux de ses agents `mmConfigs`, ceux de ses deciders `skillRouting` / `toolRouting`. La progression va sur stderr — une ligne réécrite sur place dans un terminal (`⬇ pulling <modèle> — 52 MB / 145 MB (35 %)`), une ligne par dixième ailleurs — puis `⬇ pulled <modèle> in 0.8s`. Un échec sur le modèle de l'agent arrête `mm` avec le message du serveur (`[engine error: autoPull: <modèle>: the server says: …]`) ; un échec sur un autre modèle, un serveur qui ne répond pas ou un fournisseur qui ne sait pas télécharger donne un `[warning: autoPull: …]`. Un agent lancé par `/ask` ou `ask_agent` ne télécharge rien ; `mm --ask` non plus. Un modèle que le serveur liste déjà n'est jamais téléchargé (un nom sans tag correspond aussi à son entrée `:latest`). Par fournisseur : `llmman` et `ollama` — `POST /api/pull` ; `kronk` — `POST /v1/kronk/models/pull`, le téléchargement ne comptant comme fait que si le flux de Kronk se termine par `"downloaded": true` (Kronk répond 200 à un téléchargement raté ; son dernier statut est alors le message) ; `dmr` — `POST /models/create` sur le runner (l'URL de base sans `/engines/…`), le téléchargement ne comptant comme fait qu'une fois le modèle listé par le runner ; `llamacpp` — pas de téléchargement par l'API : l'avertissement dit de lancer llama-server avec `-hf <dépôt>:<quant>`, ou de mettre le GGUF dans le dossier de modèles du router ; `openai` — un avertissement. |
44 | `sampling` | dictionnaire | `temperature: 0.0`, `top_p: 0.9`, `max_tokens: 4096` | Paramètres de génération, noms de l'API OpenAI, transmis au serveur. Le bloc du fichier est fusionné avec ces valeurs par défaut : une valeur par défaut que le fichier ne nomme pas est quand même envoyée. **Sauf avec `provider: openai` et `provider: openai-responses`** : la requête porte exactement le bloc du fichier, rien d'ajouté (pas de bloc : aucune clé de génération, les valeurs par défaut du serveur s'appliquent) — les modèles de raisonnement hébergés par OpenAI refusent `max_tokens` et n'acceptent que la température par défaut, une valeur par défaut laissée là donnerait une erreur 400. Une clé que l'API OpenAI ne déclare pas est envoyée telle quelle, au premier niveau de la requête — par exemple `chat_template_kwargs: {enable_thinking: false}`, qui demande à un serveur llama.cpp (`dmr`, `llamacpp`, `llmman`) ou à Kronk de ne pas raisonner ; `reasoning_effort: none` fait de même avec Ollama. `messages`, `tools`, `tool_choice` (et les anciens `functions`, `function_call`) sont ignorées : Genkit les construit à partir de la conversation. L'`agent.yaml` livré ajoute `parallel_tool_calls: false`. `max_tokens` borne aussi un appel d'outil : un `write_file` de long document (ou le raisonnement d'un modèle « thinking » plus l'appel) peut l'atteindre, et l'appel est alors coupé. mm le rend deux fois au modèle en lui demandant de procéder par morceaux, puis s'arrête avec `the model hit max_tokens (N) while writing a tool call` ; augmentez la valeur si cela arrive. Une configuration qui nomme la limite `max_completion_tokens` (le nom de l'API OpenAI pour ses modèles récents) est lue de la même façon : ce nom est repris dans ce message et dans la requête de résumé de la compression du contexte. En streaming, mm demande aussi au serveur le compte des tokens (`stream_options.include_usage`). |45 | `sampling` | dictionnaire | `temperature: 0.0`, `top_p: 0.9`, `max_tokens: 4096` | Paramètres de génération, noms de l'API OpenAI, transmis au serveur. Le bloc du fichier est fusionné avec ces valeurs par défaut : une valeur par défaut que le fichier ne nomme pas est quand même envoyée. **Sauf avec `provider: openai` et `provider: openai-responses`** : la requête porte exactement le bloc du fichier, rien d'ajouté (pas de bloc : aucune clé de génération, les valeurs par défaut du serveur s'appliquent) — les modèles de raisonnement hébergés par OpenAI refusent `max_tokens` et n'acceptent que la température par défaut, une valeur par défaut laissée là donnerait une erreur 400. Une clé que l'API OpenAI ne déclare pas est envoyée telle quelle, au premier niveau de la requête — par exemple `chat_template_kwargs: {enable_thinking: false}`, qui demande à un serveur llama.cpp (`dmr`, `llamacpp`, `llmman`) ou à Kronk de ne pas raisonner ; `reasoning_effort: none` fait de même avec Ollama. `messages`, `tools`, `tool_choice` (et les anciens `functions`, `function_call`) sont ignorées : Genkit les construit à partir de la conversation. L'`agent.yaml` livré ajoute `parallel_tool_calls: false`. `max_tokens` borne aussi un appel d'outil : un `write_file` de long document (ou le raisonnement d'un modèle « thinking » plus l'appel) peut l'atteindre, et l'appel est alors coupé. mm le rend deux fois au modèle en lui demandant de procéder par morceaux, puis s'arrête avec `the model hit max_tokens (N) while writing a tool call` ; augmentez la valeur si cela arrive. Une configuration qui nomme la limite `max_completion_tokens` (le nom de l'API OpenAI pour ses modèles récents) est lue de la même façon : ce nom est repris dans ce message et dans la requête de résumé de la compression du contexte. En streaming, mm demande aussi au serveur le compte des tokens (`stream_options.include_usage`). |
45 | `watchdogTimeout` | durée | `20s` | Silence toléré entre deux tokens diffusés avant de déclarer la connexion bloquée. Doublé pour les requêtes de résumé. |46 | `watchdogTimeout` | durée | `20s` | Silence toléré entre deux tokens diffusés avant de déclarer la connexion bloquée. Doublé pour les requêtes de résumé. |
@@ -259,6 +260,7 @@ workspace:
259 | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | non |260 | `ollama` | `http://localhost:11434/v1` | `http://host.docker.internal:11434/v1` | `OLLAMA_API_KEY` | non |
260 | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | non — seuls les modes `authenticated` et `full-protected` de Kronk la vérifient |261 | `kronk` | `http://127.0.0.1:11435/v1` | `http://host.docker.internal:11435/v1` | `KRONK_TOKEN` | non — seuls les modes `authenticated` et `full-protected` de Kronk la vérifient |
261 | `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | non — seul un serveur démarré avec `--api-key` la vérifie, et pas pour localhost |262 | `mlxserve` | `http://127.0.0.1:11234/v1` | `http://host.docker.internal:11234/v1` | `MLX_SERVE_API_KEY` | non — seul un serveur démarré avec `--api-key` la vérifie, et pas pour localhost |
263+| `razorbill` | `http://127.0.0.1:7920/v1` | `http://host.docker.internal:7920/v1` | `RZB_API_KEY` | non — seul un serveur dont `RZB_API_KEY` est défini la vérifie |
262 | `openai` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — un serveur qui en exige une répond 401, et l'avertissement de démarrage nomme la variable |264 | `openai` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — un serveur qui en exige une répond 401, et l'avertissement de démarrage nomme la variable |
263 | `openai-responses` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — comme `openai` |265 | `openai-responses` | `https://api.openai.com/v1` | aucun | `OPENAI_API_KEY` | non — comme `openai` |
264 266
@@ -533,7 +535,7 @@ Signalées sur stderr sous la forme `[config error: <chemin>: <message>]`, code
533 | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | un nom commençant par `with-context` |535 | `mmConfigs: "with-context-x" is not a valid name (it would read as /ask-with-context-…)` | un nom commençant par `with-context` |
534 | `mmConfigs.<nom>: the path must not be empty` | `<nom>: ""`, ou une forme longue sans `path` |536 | `mmConfigs.<nom>: the path must not be empty` | `<nom>: ""`, ou une forme longue sans `path` |
535 | `hooks: unknown event "x" (…)`, `hooks.<événement>[N]: …` | un bloc `hooks:` invalide — voir [les hooks](hooks.md#erreurs-de-validation) |537 | `hooks: unknown event "x" (…)`, `hooks.<événement>[N]: …` | un bloc `hooks:` invalide — voir [les hooks](hooks.md#erreurs-de-validation) |
536-| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses)` | Signalée par le moteur, sous la forme `[engine error: …]`. |538+| `unknown provider "x" (known: dmr, kronk, llamacpp, llmman, mlxserve, ollama, openai, openai-responses, razorbill)` | Signalée par le moteur, sous la forme `[engine error: …]`. |
537 539
538 Un avertissement au démarrage, et non une erreur, est affiché quand `context.enabled` vaut `true`, que la fenêtre est inconnue et que `context.maxMessages` vaut `0`, quand un outil déclaré porte le nom d'un outil MCP (`tools: <nom> skipped — an MCP tool already has that name` ; l'outil n'est pas déclaré), et quand le fichier pose la clé obsolète `permissions` (`permissions: ask is deprecated — use yolo: false instead …`).540 Un avertissement au démarrage, et non une erreur, est affiché quand `context.enabled` vaut `true`, que la fenêtre est inconnue et que `context.maxMessages` vaut `0`, quand un outil déclaré porte le nom d'un outil MCP (`tools: <nom> skipped — an MCP tool already has that name` ; l'outil n'est pas déclaré), et quand le fichier pose la clé obsolète `permissions` (`permissions: ask is deprecated — use yolo: false instead …`).
539 541
modified docs/fr/reference/tools.md +1 -0
@@ -337,6 +337,7 @@ Déclaré quand `unloadModels` vaut true (le défaut), sauf à côté d'une `str
337337 | llmman, `ollama` | Cherche d'abord le modèle dans `GET /api/ps` ; quand il est chargé, `POST /api/generate {"model": …, "keep_alive": 0}` et attend `done_reason: "unload"`. Un modèle non chargé n'est jamais demandé : la requête le chargerait d'abord. |
338338 | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, qui attend `status: "unloaded"`. Le 404 de Kronk pour un modèle non chargé donne `<modèle> was not loaded: nothing to unload`. |
339339 | `mlxserve` | Cherche d'abord le modèle dans `GET /v1/models` ; s'il est `loaded`, `POST /v1/unload-model {"model": …}` et attend `state: "unloaded"`. MLX-Serve répond « unloaded » aussi pour un modèle non chargé, d'où la recherche préalable. |
340+| `razorbill` | `cannot unload <modèle>: the razorbill provider cannot unload a model` — rzb n'a pas de route de déchargement ; il décharge lui-même un modèle inactif après son `keep_alive` (10 minutes par défaut). |
340341 | `llamacpp` | `POST /models/unload {"model": …}`, qui n'existe qu'en mode router (llama-server lancé sans modèle). Le 404 d'un serveur à modèle unique donne la raison et les alternatives : mode router, `--sleep-idle-seconds N`, arrêt du serveur. |
341342 | `dmr` | `cannot unload <modèle>: the dmr provider cannot unload a model`. |
342343 | Résultat | Une ligne : `unloaded <modèle>`, `<modèle> was not loaded: nothing to unload`, ou `cannot unload <modèle>: <raison>` (serveur injoignable, erreur du serveur lui-même, absence de confirmation). |
@@ -337,6 +337,7 @@ Déclaré quand `unloadModels` vaut true (le défaut), sauf à côté d'une `str
337 | llmman, `ollama` | Cherche d'abord le modèle dans `GET /api/ps` ; quand il est chargé, `POST /api/generate {"model": …, "keep_alive": 0}` et attend `done_reason: "unload"`. Un modèle non chargé n'est jamais demandé : la requête le chargerait d'abord. |337 | llmman, `ollama` | Cherche d'abord le modèle dans `GET /api/ps` ; quand il est chargé, `POST /api/generate {"model": …, "keep_alive": 0}` et attend `done_reason: "unload"`. Un modèle non chargé n'est jamais demandé : la requête le chargerait d'abord. |
338 | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, qui attend `status: "unloaded"`. Le 404 de Kronk pour un modèle non chargé donne `<modèle> was not loaded: nothing to unload`. |338 | `kronk` | `POST /v1/kronk/models/unload {"id": …}`, qui attend `status: "unloaded"`. Le 404 de Kronk pour un modèle non chargé donne `<modèle> was not loaded: nothing to unload`. |
339 | `mlxserve` | Cherche d'abord le modèle dans `GET /v1/models` ; s'il est `loaded`, `POST /v1/unload-model {"model": …}` et attend `state: "unloaded"`. MLX-Serve répond « unloaded » aussi pour un modèle non chargé, d'où la recherche préalable. |339 | `mlxserve` | Cherche d'abord le modèle dans `GET /v1/models` ; s'il est `loaded`, `POST /v1/unload-model {"model": …}` et attend `state: "unloaded"`. MLX-Serve répond « unloaded » aussi pour un modèle non chargé, d'où la recherche préalable. |
340+| `razorbill` | `cannot unload <modèle>: the razorbill provider cannot unload a model` — rzb n'a pas de route de déchargement ; il décharge lui-même un modèle inactif après son `keep_alive` (10 minutes par défaut). |
340 | `llamacpp` | `POST /models/unload {"model": …}`, qui n'existe qu'en mode router (llama-server lancé sans modèle). Le 404 d'un serveur à modèle unique donne la raison et les alternatives : mode router, `--sleep-idle-seconds N`, arrêt du serveur. |341 | `llamacpp` | `POST /models/unload {"model": …}`, qui n'existe qu'en mode router (llama-server lancé sans modèle). Le 404 d'un serveur à modèle unique donne la raison et les alternatives : mode router, `--sleep-idle-seconds N`, arrêt du serveur. |
341 | `dmr` | `cannot unload <modèle>: the dmr provider cannot unload a model`. |342 | `dmr` | `cannot unload <modèle>: the dmr provider cannot unload a model`. |
342 | Résultat | Une ligne : `unloaded <modèle>`, `<modèle> was not loaded: nothing to unload`, ou `cannot unload <modèle>: <raison>` (serveur injoignable, erreur du serveur lui-même, absence de confirmation). |343 | Résultat | Une ligne : `unloaded <modèle>`, `<modèle> was not loaded: nothing to unload`, ou `cannot unload <modèle>: <raison>` (serveur injoignable, erreur du serveur lui-même, absence de confirmation). |
modified internal/agentinit/decide.go +4 -3
@@ -7,7 +7,7 @@ import (
77
88 // Choices are the wizard's answers.
99 type Choices struct {
10- Provider string // llamacpp, llmman, ollama, dmr, kronk, mlxserve, openai, openai-responses
10+ Provider string // llamacpp, llmman, ollama, dmr, kronk, mlxserve, razorbill, openai, openai-responses
1111 BaseURL string // "" = the provider's default
1212 // APIKeyEnv names the variable holding the API key of an
1313 // OpenAI-compatible service (provider openai); "" = OPENAI_API_KEY.
@@ -27,8 +27,9 @@ type Choices struct {
2727 // Skills writes a skillsDir (skills, or .mm/skills with Project) and
2828 // creates that folder. nil = no: skillsDir: no-skills.
2929 Skills *bool
30- // AutoStart (ticket 223, provider llamacpp on this machine): mm starts
31- // llama-server when nothing answers. nil = yes, the question's default.
30+ // AutoStart (ticket 223, provider llamacpp on this machine; ticket 264,
31+ // razorbill): mm starts llama-server (rzb) when nothing answers. nil =
32+ // yes, the question's default.
3233 AutoStart *bool
3334 // Launch (ticket 257): write llama-server's launch settings — the
3435 // values the Llama app starts its server with. nil = no.
@@ -7,7 +7,7 @@ import (
7 7
8 // Choices are the wizard's answers.8 // Choices are the wizard's answers.
9 type Choices struct {9 type Choices struct {
10- Provider string // llamacpp, llmman, ollama, dmr, kronk, mlxserve, openai, openai-responses10+ Provider string // llamacpp, llmman, ollama, dmr, kronk, mlxserve, razorbill, openai, openai-responses
11 BaseURL string // "" = the provider's default11 BaseURL string // "" = the provider's default
12 // APIKeyEnv names the variable holding the API key of an12 // APIKeyEnv names the variable holding the API key of an
13 // OpenAI-compatible service (provider openai); "" = OPENAI_API_KEY.13 // OpenAI-compatible service (provider openai); "" = OPENAI_API_KEY.
@@ -27,8 +27,9 @@ type Choices struct {
27 // Skills writes a skillsDir (skills, or .mm/skills with Project) and27 // Skills writes a skillsDir (skills, or .mm/skills with Project) and
28 // creates that folder. nil = no: skillsDir: no-skills.28 // creates that folder. nil = no: skillsDir: no-skills.
29 Skills *bool29 Skills *bool
30- // AutoStart (ticket 223, provider llamacpp on this machine): mm starts30+ // AutoStart (ticket 223, provider llamacpp on this machine; ticket 264,
31- // llama-server when nothing answers. nil = yes, the question's default.31+ // razorbill): mm starts llama-server (rzb) when nothing answers. nil =
32+ // yes, the question's default.
32 AutoStart *bool33 AutoStart *bool
33 // Launch (ticket 257): write llama-server's launch settings — the34 // Launch (ticket 257): write llama-server's launch settings — the
34 // values the Llama app starts its server with. nil = no.35 // values the Llama app starts its server with. nil = no.
modified internal/agentinit/decide_test.go +41 -0
@@ -391,3 +391,44 @@ func TestFlowAsksAutoStartForALocalLlamaCpp(t *testing.T) {
391391 }
392392 }
393393 }
394+
395+// Ticket 264: razorbill on this machine gets the autostart question (its
396+// own wording) but never llama-server's launch settings; the block is
397+// written as answered and mm loads it.
398+func TestRazorbillAutoStart(t *testing.T) {
399+ p, _ := LoadPresets()
400+ f := NewFlow(context.Background(), p, Choices{Provider: "razorbill"}, "")
401+ var k []string
402+ for _, st := range f.Steps() {
403+ k = append(k, st.Key)
404+ }
405+ if got := strings.Join(k, ","); !strings.Contains(got, "skills,autostart,name") {
406+ t.Errorf("razorbill steps: %s", got)
407+ }
408+ if st := f.Step("autostart"); st.Default != "yes" || !strings.Contains(st.Prompt, "rzb") {
409+ t.Errorf("autostart step: %+v", st)
410+ }
411+ remote := NewFlow(context.Background(), p, Choices{Provider: "razorbill", BaseURL: "http://host.docker.internal:7920/v1"}, "")
412+ for _, st := range remote.Steps() {
413+ if st.Key == "autostart" {
414+ t.Error("razorbill off this machine (a sandbox reaching the Mac): asks autostart")
415+ }
416+ }
417+
418+ yes, no := true, false
419+ render := func(start *bool) string {
420+ return Render(Decide(p, Choices{Provider: "razorbill", Model: "mlx-community/Qwen3-4B-4bit", Usage: "assistant", Machine: "small", AutoStart: start}, Facts{}))
421+ }
422+ off := render(&no)
423+ if !strings.Contains(off, "razorbill:\n autoStart: false\n") || strings.Contains(off, "llamacpp:") {
424+ t.Errorf("autostart no:\n%s", off)
425+ }
426+ on := render(&yes)
427+ if !strings.Contains(on, "razorbill:\n autoStart: true\n") || !strings.Contains(on, "not in a container or a") {
428+ t.Errorf("autostart yes:\n%s", on)
429+ }
430+ loadRendered(t, on)
431+ if !config.Cfg.Razorbill.AutoStart || config.Cfg.Provider != "razorbill" {
432+ t.Errorf("loaded: %+v", config.Cfg.Razorbill)
433+ }
434+}
@@ -391,3 +391,44 @@ func TestFlowAsksAutoStartForALocalLlamaCpp(t *testing.T) {
391 }391 }
392 }392 }
393 }393 }
394+
395+// Ticket 264: razorbill on this machine gets the autostart question (its
396+// own wording) but never llama-server's launch settings; the block is
397+// written as answered and mm loads it.
398+func TestRazorbillAutoStart(t *testing.T) {
399+ p, _ := LoadPresets()
400+ f := NewFlow(context.Background(), p, Choices{Provider: "razorbill"}, "")
401+ var k []string
402+ for _, st := range f.Steps() {
403+ k = append(k, st.Key)
404+ }
405+ if got := strings.Join(k, ","); !strings.Contains(got, "skills,autostart,name") {
406+ t.Errorf("razorbill steps: %s", got)
407+ }
408+ if st := f.Step("autostart"); st.Default != "yes" || !strings.Contains(st.Prompt, "rzb") {
409+ t.Errorf("autostart step: %+v", st)
410+ }
411+ remote := NewFlow(context.Background(), p, Choices{Provider: "razorbill", BaseURL: "http://host.docker.internal:7920/v1"}, "")
412+ for _, st := range remote.Steps() {
413+ if st.Key == "autostart" {
414+ t.Error("razorbill off this machine (a sandbox reaching the Mac): asks autostart")
415+ }
416+ }
417+
418+ yes, no := true, false
419+ render := func(start *bool) string {
420+ return Render(Decide(p, Choices{Provider: "razorbill", Model: "mlx-community/Qwen3-4B-4bit", Usage: "assistant", Machine: "small", AutoStart: start}, Facts{}))
421+ }
422+ off := render(&no)
423+ if !strings.Contains(off, "razorbill:\n autoStart: false\n") || strings.Contains(off, "llamacpp:") {
424+ t.Errorf("autostart no:\n%s", off)
425+ }
426+ on := render(&yes)
427+ if !strings.Contains(on, "razorbill:\n autoStart: true\n") || !strings.Contains(on, "not in a container or a") {
428+ t.Errorf("autostart yes:\n%s", on)
429+ }
430+ loadRendered(t, on)
431+ if !config.Cfg.Razorbill.AutoStart || config.Cfg.Provider != "razorbill" {
432+ t.Errorf("loaded: %+v", config.Cfg.Razorbill)
433+ }
434+}
modified internal/agentinit/flow.go +25 -6
@@ -148,7 +148,7 @@ func (f *Flow) Steps() []Step {
148148 if (key == "endpoint" || key == "keyenv") && !isOpenAI(f.c.Provider) {
149149 continue
150150 }
151- if (key == "autostart" && !f.asksAutoStart()) || (key == "launch" && !(f.asksAutoStart() && autoStartOn(f.c.AutoStart))) {
151+ if (key == "autostart" && !f.asksAutoStart()) || (key == "launch" && !f.asksLaunch()) {
152152 continue
153153 }
154154 out = append(out, f.Step(key))
@@ -178,9 +178,22 @@ func (f *Flow) Pending() []Step {
178178 return out
179179 }
180180
181-// asksAutoStart: mm can start the server only for llamacpp on this machine.
181+// asksAutoStart: mm can start the server only for llamacpp and razorbill
182+// on this machine.
182183 func (f *Flow) asksAutoStart() bool {
183- return f.c.Provider == "llamacpp" && localURL(f.c.BaseURL)
184+ return startsServer(f.c)
185+}
186+
187+// asksLaunch: the launch settings are llama-server's, asked once its start
188+// is on.
189+func (f *Flow) asksLaunch() bool {
190+ return f.c.Provider == "llamacpp" && f.asksAutoStart() && autoStartOn(f.c.AutoStart)
191+}
192+
193+// startsServer: c names a server mm can start — llamacpp or razorbill — at
194+// an address on this machine.
195+func startsServer(c Choices) bool {
196+ return (c.Provider == "llamacpp" || c.Provider == "razorbill") && localURL(c.BaseURL)
184197 }
185198
186199 // autoStartOn reads the autostart answer: nil (not asked yet) is its
@@ -283,9 +296,15 @@ func (f *Flow) Step(key string) Step {
283296 "writes skillsDir: "+f.c.SkillsDir()+" and creates that folder",
284297 "skillsDir: no-skills")
285298 case "autostart":
286- st = yesNoStep(st, "Let mm start llama-server when it is not running?",
287- "llamacpp.autoStart: true — mm starts it with this model (downloaded on first use) and stops it with the last mm session",
288- "llamacpp.autoStart: false — you start llama-server yourself")
299+ if f.c.Provider == "razorbill" {
300+ st = yesNoStep(st, "Let mm start rzb when it is not running?",
301+ "razorbill.autoStart: true — mm starts rzb serve (macOS, mm on the Mac itself: not in a container or a sandbox), downloads this model when missing, and stops it with the last mm session",
302+ "razorbill.autoStart: false — you start rzb serve yourself")
303+ } else {
304+ st = yesNoStep(st, "Let mm start llama-server when it is not running?",
305+ "llamacpp.autoStart: true — mm starts it with this model (downloaded on first use) and stops it with the last mm session",
306+ "llamacpp.autoStart: false — you start llama-server yourself")
307+ }
289308 st.Default = "yes"
290309 case "launch":
291310 st = yesNoStep(st, "Write llama-server's launch settings?",
@@ -148,7 +148,7 @@ func (f *Flow) Steps() []Step {
148 if (key == "endpoint" || key == "keyenv") && !isOpenAI(f.c.Provider) {148 if (key == "endpoint" || key == "keyenv") && !isOpenAI(f.c.Provider) {
149 continue149 continue
150 }150 }
151- if (key == "autostart" && !f.asksAutoStart()) || (key == "launch" && !(f.asksAutoStart() && autoStartOn(f.c.AutoStart))) {151+ if (key == "autostart" && !f.asksAutoStart()) || (key == "launch" && !f.asksLaunch()) {
152 continue152 continue
153 }153 }
154 out = append(out, f.Step(key))154 out = append(out, f.Step(key))
@@ -178,9 +178,22 @@ func (f *Flow) Pending() []Step {
178 return out178 return out
179 }179 }
180 180
181-// asksAutoStart: mm can start the server only for llamacpp on this machine.181+// asksAutoStart: mm can start the server only for llamacpp and razorbill
182+// on this machine.
182 func (f *Flow) asksAutoStart() bool {183 func (f *Flow) asksAutoStart() bool {
183- return f.c.Provider == "llamacpp" && localURL(f.c.BaseURL)184+ return startsServer(f.c)
185+}
186+
187+// asksLaunch: the launch settings are llama-server's, asked once its start
188+// is on.
189+func (f *Flow) asksLaunch() bool {
190+ return f.c.Provider == "llamacpp" && f.asksAutoStart() && autoStartOn(f.c.AutoStart)
191+}
192+
193+// startsServer: c names a server mm can start — llamacpp or razorbill — at
194+// an address on this machine.
195+func startsServer(c Choices) bool {
196+ return (c.Provider == "llamacpp" || c.Provider == "razorbill") && localURL(c.BaseURL)
184 }197 }
185 198
186 // autoStartOn reads the autostart answer: nil (not asked yet) is its199 // autoStartOn reads the autostart answer: nil (not asked yet) is its
@@ -283,9 +296,15 @@ func (f *Flow) Step(key string) Step {
283 "writes skillsDir: "+f.c.SkillsDir()+" and creates that folder",296 "writes skillsDir: "+f.c.SkillsDir()+" and creates that folder",
284 "skillsDir: no-skills")297 "skillsDir: no-skills")
285 case "autostart":298 case "autostart":
286- st = yesNoStep(st, "Let mm start llama-server when it is not running?",299+ if f.c.Provider == "razorbill" {
287- "llamacpp.autoStart: true — mm starts it with this model (downloaded on first use) and stops it with the last mm session",300+ st = yesNoStep(st, "Let mm start rzb when it is not running?",
288- "llamacpp.autoStart: false — you start llama-server yourself")301+ "razorbill.autoStart: true — mm starts rzb serve (macOS, mm on the Mac itself: not in a container or a sandbox), downloads this model when missing, and stops it with the last mm session",
302+ "razorbill.autoStart: false — you start rzb serve yourself")
303+ } else {
304+ st = yesNoStep(st, "Let mm start llama-server when it is not running?",
305+ "llamacpp.autoStart: true — mm starts it with this model (downloaded on first use) and stops it with the last mm session",
306+ "llamacpp.autoStart: false — you start llama-server yourself")
307+ }
289 st.Default = "yes"308 st.Default = "yes"
290 case "launch":309 case "launch":
291 st = yesNoStep(st, "Write llama-server's launch settings?",310 st = yesNoStep(st, "Write llama-server's launch settings?",
modified internal/agentinit/render.go +22 -1
@@ -47,9 +47,12 @@ func Render(s Settings) string {
4747 if isOpenAI(c.Provider) {
4848 writeKeyEnv(&b, c)
4949 }
50- if c.Provider == "llamacpp" && localURL(c.BaseURL) {
50+ if startsServer(c) && c.Provider == "llamacpp" {
5151 writeLlamaCpp(&b, c)
5252 }
53+ if startsServer(c) && c.Provider == "razorbill" {
54+ writeRazorbill(&b, c)
55+ }
5356 b.WriteString("\n")
5457
5558 writeSettings(&b, "", s.Top)
@@ -345,6 +348,24 @@ llamacpp:
345348 }
346349 }
347350
351+// writeRazorbill writes the razorbill block (ticket 264): autoStart as
352+// answered (yes when not asked), the other keys as comments.
353+func writeRazorbill(b *strings.Builder, c Choices) {
354+ if !autoStartOn(c.AutoStart) {
355+ b.WriteString("# true: mm starts rzb serve when nothing answers (macOS, mm on the Mac\n# itself), and stops it with the last mm session using it.\nrazorbill:\n autoStart: false\n")
356+ return
357+ }
358+ b.WriteString(`# Nothing answers at this address: mm starts rzb serve (and rzb models pull
359+# when this model is missing) and stops it with the last mm session using it.
360+# macOS only, with mm running on the Mac itself — not in a container or a
361+# sandbox. A server you started yourself is never stopped.
362+razorbill:
363+ autoStart: true
364+ # config: rzb-server.yaml # rzb serve --config (relative to this file)
365+ # serverArgs: [] # any other rzb serve flag
366+`)
367+}
368+
348369 // llamaLaunch is the launch settings block: the Llama app's values. Each
349370 // key is one llama-server flag; a key removed takes llama-server's default.
350371 const llamaLaunch = ` # Launch settings, the Llama app's values: each key is one llama-server
@@ -47,9 +47,12 @@ func Render(s Settings) string {
47 if isOpenAI(c.Provider) {47 if isOpenAI(c.Provider) {
48 writeKeyEnv(&b, c)48 writeKeyEnv(&b, c)
49 }49 }
50- if c.Provider == "llamacpp" && localURL(c.BaseURL) {50+ if startsServer(c) && c.Provider == "llamacpp" {
51 writeLlamaCpp(&b, c)51 writeLlamaCpp(&b, c)
52 }52 }
53+ if startsServer(c) && c.Provider == "razorbill" {
54+ writeRazorbill(&b, c)
55+ }
53 b.WriteString("\n")56 b.WriteString("\n")
54 57
55 writeSettings(&b, "", s.Top)58 writeSettings(&b, "", s.Top)
@@ -345,6 +348,24 @@ llamacpp:
345 }348 }
346 }349 }
347 350
351+// writeRazorbill writes the razorbill block (ticket 264): autoStart as
352+// answered (yes when not asked), the other keys as comments.
353+func writeRazorbill(b *strings.Builder, c Choices) {
354+ if !autoStartOn(c.AutoStart) {
355+ b.WriteString("# true: mm starts rzb serve when nothing answers (macOS, mm on the Mac\n# itself), and stops it with the last mm session using it.\nrazorbill:\n autoStart: false\n")
356+ return
357+ }
358+ b.WriteString(`# Nothing answers at this address: mm starts rzb serve (and rzb models pull
359+# when this model is missing) and stops it with the last mm session using it.
360+# macOS only, with mm running on the Mac itself — not in a container or a
361+# sandbox. A server you started yourself is never stopped.
362+razorbill:
363+ autoStart: true
364+ # config: rzb-server.yaml # rzb serve --config (relative to this file)
365+ # serverArgs: [] # any other rzb serve flag
366+`)
367+}
368+
348 // llamaLaunch is the launch settings block: the Llama app's values. Each369 // llamaLaunch is the launch settings block: the Llama app's values. Each
349 // key is one llama-server flag; a key removed takes llama-server's default.370 // key is one llama-server flag; a key removed takes llama-server's default.
350 const llamaLaunch = ` # Launch settings, the Llama app's values: each key is one llama-server371 const llamaLaunch = ` # Launch settings, the Llama app's values: each key is one llama-server
modified internal/agentinit/wizard.go +3 -3
@@ -21,14 +21,14 @@ import (
2121 // providers are the servers mm speaks to, in the order they are offered.
2222 // llamacpp first (ticket 221, user's choice): the default when nothing
2323 // answers (firstAnswering).
24-var providers = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve", "openai", "openai-responses"}
24+var providers = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve", "razorbill", "openai", "openai-responses"}
2525
2626 // local are the providers probed for the first question's default, in this
2727 // order: the first that answers is proposed — llamacpp when llama-server
2828 // runs (9931, then 8080), else a running llmman, Ollama… Never `openai`,
2929 // whose default address is the OpenAI API — mm init must not call a remote
3030 // service nobody asked for.
31-var local = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve"}
31+var local = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve", "razorbill"}
3232
3333 // Window asks the flow's questions in a full-screen window (internal/tui's
3434 // RunInit): it returns false when the user quit without writing. main hands
@@ -128,7 +128,7 @@ func ParseArgs(name string, args []string, out io.Writer, lineSwitches bool) (a
128128 fs.StringVar(&project, "project", "", "yes: create .mm/ and write .mm/agent.yaml, paths from the project root; no: one agent.yaml (default: no)")
129129 fs.StringVar(&sessions, "sessions", "", "yes: write a sessions section that saves every conversation; no: none (default: no)")
130130 fs.StringVar(&skills, "skills", "", "yes: write skillsDir and create the folder (skills/, or .mm/skills/ with --project yes); no: skillsDir: no-skills (default: no)")
131- fs.StringVar(&autostart, "autostart", "", "llamacpp on this machine — yes: mm starts llama-server when it is not running and stops it with the last session; no: you start it (default: yes)")
131+ fs.StringVar(&autostart, "autostart", "", "llamacpp or razorbill on this machine — yes: mm starts llama-server (rzb) when it is not running and stops it with the last session; no: you start it (default: yes)")
132132 fs.StringVar(&launch, "launch-settings", "", "llamacpp with --autostart yes — yes: write llama-server's launch settings (the Llama app's values); no: llama-server's defaults (default: no)")
133133 fs.StringVar(&a.Output, "o", "", "the file to write (default agent.yaml, .mm/agent.yaml with --project yes; - for stdout, which creates nothing); an existing file is replaced only if you agree, never with --yes")
134134 fs.StringVar(&a.Output, "output", "", "same as -o")
@@ -21,14 +21,14 @@ import (
21 // providers are the servers mm speaks to, in the order they are offered.21 // providers are the servers mm speaks to, in the order they are offered.
22 // llamacpp first (ticket 221, user's choice): the default when nothing22 // llamacpp first (ticket 221, user's choice): the default when nothing
23 // answers (firstAnswering).23 // answers (firstAnswering).
24-var providers = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve", "openai", "openai-responses"}24+var providers = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve", "razorbill", "openai", "openai-responses"}
25 25
26 // local are the providers probed for the first question's default, in this26 // local are the providers probed for the first question's default, in this
27 // order: the first that answers is proposed — llamacpp when llama-server27 // order: the first that answers is proposed — llamacpp when llama-server
28 // runs (9931, then 8080), else a running llmman, Ollama… Never `openai`,28 // runs (9931, then 8080), else a running llmman, Ollama… Never `openai`,
29 // whose default address is the OpenAI API — mm init must not call a remote29 // whose default address is the OpenAI API — mm init must not call a remote
30 // service nobody asked for.30 // service nobody asked for.
31-var local = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve"}31+var local = []string{"llamacpp", "llmman", "ollama", "dmr", "kronk", "mlxserve", "razorbill"}
32 32
33 // Window asks the flow's questions in a full-screen window (internal/tui's33 // Window asks the flow's questions in a full-screen window (internal/tui's
34 // RunInit): it returns false when the user quit without writing. main hands34 // RunInit): it returns false when the user quit without writing. main hands
@@ -128,7 +128,7 @@ func ParseArgs(name string, args []string, out io.Writer, lineSwitches bool) (a
128 fs.StringVar(&project, "project", "", "yes: create .mm/ and write .mm/agent.yaml, paths from the project root; no: one agent.yaml (default: no)")128 fs.StringVar(&project, "project", "", "yes: create .mm/ and write .mm/agent.yaml, paths from the project root; no: one agent.yaml (default: no)")
129 fs.StringVar(&sessions, "sessions", "", "yes: write a sessions section that saves every conversation; no: none (default: no)")129 fs.StringVar(&sessions, "sessions", "", "yes: write a sessions section that saves every conversation; no: none (default: no)")
130 fs.StringVar(&skills, "skills", "", "yes: write skillsDir and create the folder (skills/, or .mm/skills/ with --project yes); no: skillsDir: no-skills (default: no)")130 fs.StringVar(&skills, "skills", "", "yes: write skillsDir and create the folder (skills/, or .mm/skills/ with --project yes); no: skillsDir: no-skills (default: no)")
131- fs.StringVar(&autostart, "autostart", "", "llamacpp on this machine — yes: mm starts llama-server when it is not running and stops it with the last session; no: you start it (default: yes)")131+ fs.StringVar(&autostart, "autostart", "", "llamacpp or razorbill on this machine — yes: mm starts llama-server (rzb) when it is not running and stops it with the last session; no: you start it (default: yes)")
132 fs.StringVar(&launch, "launch-settings", "", "llamacpp with --autostart yes — yes: write llama-server's launch settings (the Llama app's values); no: llama-server's defaults (default: no)")132 fs.StringVar(&launch, "launch-settings", "", "llamacpp with --autostart yes — yes: write llama-server's launch settings (the Llama app's values); no: llama-server's defaults (default: no)")
133 fs.StringVar(&a.Output, "o", "", "the file to write (default agent.yaml, .mm/agent.yaml with --project yes; - for stdout, which creates nothing); an existing file is replaced only if you agree, never with --yes")133 fs.StringVar(&a.Output, "o", "", "the file to write (default agent.yaml, .mm/agent.yaml with --project yes; - for stdout, which creates nothing); an existing file is replaced only if you agree, never with --yes")
134 fs.StringVar(&a.Output, "output", "", "same as -o")134 fs.StringVar(&a.Output, "output", "", "same as -o")
modified internal/config/config.go +9 -1
@@ -23,7 +23,7 @@ import (
2323 // Config: everything that can be tuned without touching the code.
2424 type Config struct {
2525 // Provider: which LLM server is behind BaseURL — a key of the engine
26- // registry ("dmr", "llamacpp", "llmman", "ollama", "kronk", "mlxserve", "openai"…). Defaults to "dmr" so that every agent.yaml
26+ // registry ("dmr", "llamacpp", "llmman", "ollama", "kronk", "mlxserve", "razorbill", "openai"…). Defaults to "dmr" so that every agent.yaml
2727 // written before this key existed keeps its meaning.
2828 Provider string `yaml:"provider"`
2929
@@ -221,6 +221,10 @@ type Config struct {
221221 // when nothing answers (ticket 223). See LlamaCppConfig.
222222 LlamaCpp LlamaCppConfig `yaml:"llamacpp"`
223223
224+ // Razorbill: provider razorbill only — mm starts `rzb serve` itself
225+ // when nothing answers (ticket 264, macOS). See RazorbillConfig.
226+ Razorbill RazorbillConfig `yaml:"razorbill"`
227+
224228 // Sampling: generation settings (OpenAI API keys; the plugin converts them.)
225229 Sampling map[string]any `yaml:"sampling"`
226230
@@ -1012,6 +1016,7 @@ func Load(cliPath string) (string, error) {
10121016 }
10131017 applyProviderSampling(own)
10141018 resolveAgentPaths(path)
1019+ resolveRazorbillPaths(path)
10151020 resolveHooks(path)
10161021 resolveToolPaths(path)
10171022 resolveDecider(path)
@@ -1154,6 +1159,9 @@ func (c Config) validate() error {
11541159 if err := c.LlamaCpp.validate(); err != nil {
11551160 return err
11561161 }
1162+ if err := c.Razorbill.validate(); err != nil {
1163+ return err
1164+ }
11571165 if err := c.A2A.validate(); err != nil {
11581166 return err
11591167 }
@@ -23,7 +23,7 @@ import (
23 // Config: everything that can be tuned without touching the code.23 // Config: everything that can be tuned without touching the code.
24 type Config struct {24 type Config struct {
25 // Provider: which LLM server is behind BaseURL — a key of the engine25 // Provider: which LLM server is behind BaseURL — a key of the engine
26- // registry ("dmr", "llamacpp", "llmman", "ollama", "kronk", "mlxserve", "openai"…). Defaults to "dmr" so that every agent.yaml26+ // registry ("dmr", "llamacpp", "llmman", "ollama", "kronk", "mlxserve", "razorbill", "openai"…). Defaults to "dmr" so that every agent.yaml
27 // written before this key existed keeps its meaning.27 // written before this key existed keeps its meaning.
28 Provider string `yaml:"provider"`28 Provider string `yaml:"provider"`
29 29
@@ -221,6 +221,10 @@ type Config struct {
221 // when nothing answers (ticket 223). See LlamaCppConfig.221 // when nothing answers (ticket 223). See LlamaCppConfig.
222 LlamaCpp LlamaCppConfig `yaml:"llamacpp"`222 LlamaCpp LlamaCppConfig `yaml:"llamacpp"`
223 223
224+ // Razorbill: provider razorbill only — mm starts `rzb serve` itself
225+ // when nothing answers (ticket 264, macOS). See RazorbillConfig.
226+ Razorbill RazorbillConfig `yaml:"razorbill"`
227+
224 // Sampling: generation settings (OpenAI API keys; the plugin converts them.)228 // Sampling: generation settings (OpenAI API keys; the plugin converts them.)
225 Sampling map[string]any `yaml:"sampling"`229 Sampling map[string]any `yaml:"sampling"`
226 230
@@ -1012,6 +1016,7 @@ func Load(cliPath string) (string, error) {
1012 }1016 }
1013 applyProviderSampling(own)1017 applyProviderSampling(own)
1014 resolveAgentPaths(path)1018 resolveAgentPaths(path)
1019+ resolveRazorbillPaths(path)
1015 resolveHooks(path)1020 resolveHooks(path)
1016 resolveToolPaths(path)1021 resolveToolPaths(path)
1017 resolveDecider(path)1022 resolveDecider(path)
@@ -1154,6 +1159,9 @@ func (c Config) validate() error {
1154 if err := c.LlamaCpp.validate(); err != nil {1159 if err := c.LlamaCpp.validate(); err != nil {
1155 return err1160 return err
1156 }1161 }
1162+ if err := c.Razorbill.validate(); err != nil {
1163+ return err
1164+ }
1157 if err := c.A2A.validate(); err != nil {1165 if err := c.A2A.validate(); err != nil {
1158 return err1166 return err
1159 }1167 }
added internal/config/razorbill.go +67 -0
new file mode 100644
@@ -0,0 +1,67 @@
1+package config
2+
3+import (
4+ "errors"
5+ "os"
6+ "path/filepath"
7+ "strings"
8+ "time"
9+)
10+
11+// RazorbillConfig is the `razorbill:` block (ticket 264, internal/rzbstart):
12+// mm starts razorbill (`rzb serve`, the MLX model server for Apple Silicon
13+// Macs) when nothing answers at the agent's address.
14+//
15+// razorbill:
16+// autoStart: true
17+// config: rzb-server.yaml # optional, relative to the agent file
18+// serverArgs: [--cors-origin, "*"]
19+type RazorbillConfig struct {
20+ // AutoStart: when nothing answers at the agent's address (a loopback
21+ // one, no AGENT_BASE_URL) nor at the fallback, start `rzb serve` there,
22+ // download the model with `rzb models pull` when it is missing, and stop
23+ // the server with the last mm session using it. Off by default; `mm
24+ // init` asks. macOS only, and only when mm runs on the Mac itself — not
25+ // in a container or a sandbox. A server mm did not start is never
26+ // stopped.
27+ AutoStart bool `yaml:"autoStart"`
28+ // Server is the rzb executable; "" = rzb on the PATH, then
29+ // /usr/local/bin/rzb (where razorbill's scripts/install.sh puts it).
30+ Server string `yaml:"server"`
31+ // Config is rzb's server configuration (`rzb serve --config`): declared
32+ // models, defaults, limits. A relative path is relative to the agent
33+ // file's directory. "" = none: rzb's built-in defaults.
34+ Config string `yaml:"config"`
35+ // ServerArgs are added after mm's own arguments.
36+ ServerArgs []string `yaml:"serverArgs"`
37+ // StartTimeout bounds the start and the model's download.
38+ StartTimeout time.Duration `yaml:"startTimeout"`
39+}
40+
41+// validate refuses a negative timeout.
42+func (r RazorbillConfig) validate() error {
43+ if r.StartTimeout < 0 {
44+ return errors.New("razorbill.startTimeout must be >= 0")
45+ }
46+ return nil
47+}
48+
49+// resolveRazorbillPaths makes razorbill.config absolute: ~/ is the home
50+// directory, any other relative path is relative to the agent file's
51+// directory (BaseDir: the project root for a .mm/agent.yaml).
52+func resolveRazorbillPaths(configPath string) {
53+ c := Cfg.Razorbill.Config
54+ switch {
55+ case c == "" || filepath.IsAbs(c):
56+ case strings.HasPrefix(c, "~/"):
57+ if home, err := os.UserHomeDir(); err == nil {
58+ Cfg.Razorbill.Config = filepath.Join(home, c[2:])
59+ }
60+ default:
61+ Cfg.Razorbill.Config = filepath.Join(BaseDir(configPath), c)
62+ }
63+}
64+
65+// DefaultRazorbillStartTimeout is razorbill.startTimeout when the file
66+// does not set it: like llamacpp's, a download of several GB fits in it.
67+const DefaultRazorbillStartTimeout = 15 * time.Minute
new file mode 100644
@@ -0,0 +1,67 @@
1+package config
2+
3+import (
4+ "errors"
5+ "os"
6+ "path/filepath"
7+ "strings"
8+ "time"
9+)
10+
11+// RazorbillConfig is the `razorbill:` block (ticket 264, internal/rzbstart):
12+// mm starts razorbill (`rzb serve`, the MLX model server for Apple Silicon
13+// Macs) when nothing answers at the agent's address.
14+//
15+// razorbill:
16+// autoStart: true
17+// config: rzb-server.yaml # optional, relative to the agent file
18+// serverArgs: [--cors-origin, "*"]
19+type RazorbillConfig struct {
20+ // AutoStart: when nothing answers at the agent's address (a loopback
21+ // one, no AGENT_BASE_URL) nor at the fallback, start `rzb serve` there,
22+ // download the model with `rzb models pull` when it is missing, and stop
23+ // the server with the last mm session using it. Off by default; `mm
24+ // init` asks. macOS only, and only when mm runs on the Mac itself — not
25+ // in a container or a sandbox. A server mm did not start is never
26+ // stopped.
27+ AutoStart bool `yaml:"autoStart"`
28+ // Server is the rzb executable; "" = rzb on the PATH, then
29+ // /usr/local/bin/rzb (where razorbill's scripts/install.sh puts it).
30+ Server string `yaml:"server"`
31+ // Config is rzb's server configuration (`rzb serve --config`): declared
32+ // models, defaults, limits. A relative path is relative to the agent
33+ // file's directory. "" = none: rzb's built-in defaults.
34+ Config string `yaml:"config"`
35+ // ServerArgs are added after mm's own arguments.
36+ ServerArgs []string `yaml:"serverArgs"`
37+ // StartTimeout bounds the start and the model's download.
38+ StartTimeout time.Duration `yaml:"startTimeout"`
39+}
40+
41+// validate refuses a negative timeout.
42+func (r RazorbillConfig) validate() error {
43+ if r.StartTimeout < 0 {
44+ return errors.New("razorbill.startTimeout must be >= 0")
45+ }
46+ return nil
47+}
48+
49+// resolveRazorbillPaths makes razorbill.config absolute: ~/ is the home
50+// directory, any other relative path is relative to the agent file's
51+// directory (BaseDir: the project root for a .mm/agent.yaml).
52+func resolveRazorbillPaths(configPath string) {
53+ c := Cfg.Razorbill.Config
54+ switch {
55+ case c == "" || filepath.IsAbs(c):
56+ case strings.HasPrefix(c, "~/"):
57+ if home, err := os.UserHomeDir(); err == nil {
58+ Cfg.Razorbill.Config = filepath.Join(home, c[2:])
59+ }
60+ default:
61+ Cfg.Razorbill.Config = filepath.Join(BaseDir(configPath), c)
62+ }
63+}
64+
65+// DefaultRazorbillStartTimeout is razorbill.startTimeout when the file
66+// does not set it: like llamacpp's, a download of several GB fits in it.
67+const DefaultRazorbillStartTimeout = 15 * time.Minute
added internal/config/razorbill_test.go +68 -0
new file mode 100644
@@ -0,0 +1,68 @@
1+package config
2+
3+import (
4+ "os"
5+ "path/filepath"
6+ "reflect"
7+ "strings"
8+ "testing"
9+ "time"
10+)
11+
12+func loadRazorbill(t *testing.T, body string) error {
13+ t.Helper()
14+ defaults := Cfg
15+ t.Cleanup(func() { Cfg = defaults })
16+ path := filepath.Join(t.TempDir(), "agent.yaml")
17+ if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
18+ t.Fatal(err)
19+ }
20+ _, err := Load(path)
21+ return err
22+}
23+
24+// The block is read whole; a relative config is anchored on the agent
25+// file's directory.
26+func TestRazorbillBlockIsRead(t *testing.T) {
27+ body := "provider: razorbill\nrazorbill:\n autoStart: true\n server: /opt/rzb\n config: rzb/server.yaml\n serverArgs: [--cors-origin, \"*\"]\n startTimeout: 5m\n"
28+ defaults := Cfg
29+ t.Cleanup(func() { Cfg = defaults })
30+ dir := t.TempDir()
31+ path := filepath.Join(dir, "agent.yaml")
32+ if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
33+ t.Fatal(err)
34+ }
35+ if _, err := Load(path); err != nil {
36+ t.Fatal(err)
37+ }
38+ want := RazorbillConfig{AutoStart: true, Server: "/opt/rzb", Config: filepath.Join(dir, "rzb", "server.yaml"),
39+ ServerArgs: []string{"--cors-origin", "*"}, StartTimeout: 5 * time.Minute}
40+ if !reflect.DeepEqual(Cfg.Razorbill, want) {
41+ t.Errorf("razorbill = %+v, want %+v", Cfg.Razorbill, want)
42+ }
43+}
44+
45+// ~/ is the home directory; an absolute path is kept.
46+func TestRazorbillConfigPaths(t *testing.T) {
47+ home := t.TempDir()
48+ t.Setenv("HOME", home)
49+ defaults := Cfg
50+ t.Cleanup(func() { Cfg = defaults })
51+ Cfg.Razorbill.Config = "~/rzb.yaml"
52+ resolveRazorbillPaths("/x/agent.yaml")
53+ if Cfg.Razorbill.Config != filepath.Join(home, "rzb.yaml") {
54+ t.Errorf("~/ = %q", Cfg.Razorbill.Config)
55+ }
56+ Cfg.Razorbill.Config = "/etc/rzb.yaml"
57+ resolveRazorbillPaths("/x/agent.yaml")
58+ if Cfg.Razorbill.Config != "/etc/rzb.yaml" {
59+ t.Errorf("absolute = %q", Cfg.Razorbill.Config)
60+ }
61+}
62+
63+func TestRazorbillNegativeTimeoutIsRefused(t *testing.T) {
64+ err := loadRazorbill(t, "razorbill:\n startTimeout: -1s\n")
65+ if err == nil || !strings.Contains(err.Error(), "razorbill.startTimeout") {
66+ t.Fatalf("err = %v, want an error naming the key", err)
67+ }
68+}
new file mode 100644
@@ -0,0 +1,68 @@
1+package config
2+
3+import (
4+ "os"
5+ "path/filepath"
6+ "reflect"
7+ "strings"
8+ "testing"
9+ "time"
10+)
11+
12+func loadRazorbill(t *testing.T, body string) error {
13+ t.Helper()
14+ defaults := Cfg
15+ t.Cleanup(func() { Cfg = defaults })
16+ path := filepath.Join(t.TempDir(), "agent.yaml")
17+ if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
18+ t.Fatal(err)
19+ }
20+ _, err := Load(path)
21+ return err
22+}
23+
24+// The block is read whole; a relative config is anchored on the agent
25+// file's directory.
26+func TestRazorbillBlockIsRead(t *testing.T) {
27+ body := "provider: razorbill\nrazorbill:\n autoStart: true\n server: /opt/rzb\n config: rzb/server.yaml\n serverArgs: [--cors-origin, \"*\"]\n startTimeout: 5m\n"
28+ defaults := Cfg
29+ t.Cleanup(func() { Cfg = defaults })
30+ dir := t.TempDir()
31+ path := filepath.Join(dir, "agent.yaml")
32+ if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
33+ t.Fatal(err)
34+ }
35+ if _, err := Load(path); err != nil {
36+ t.Fatal(err)
37+ }
38+ want := RazorbillConfig{AutoStart: true, Server: "/opt/rzb", Config: filepath.Join(dir, "rzb", "server.yaml"),
39+ ServerArgs: []string{"--cors-origin", "*"}, StartTimeout: 5 * time.Minute}
40+ if !reflect.DeepEqual(Cfg.Razorbill, want) {
41+ t.Errorf("razorbill = %+v, want %+v", Cfg.Razorbill, want)
42+ }
43+}
44+
45+// ~/ is the home directory; an absolute path is kept.
46+func TestRazorbillConfigPaths(t *testing.T) {
47+ home := t.TempDir()
48+ t.Setenv("HOME", home)
49+ defaults := Cfg
50+ t.Cleanup(func() { Cfg = defaults })
51+ Cfg.Razorbill.Config = "~/rzb.yaml"
52+ resolveRazorbillPaths("/x/agent.yaml")
53+ if Cfg.Razorbill.Config != filepath.Join(home, "rzb.yaml") {
54+ t.Errorf("~/ = %q", Cfg.Razorbill.Config)
55+ }
56+ Cfg.Razorbill.Config = "/etc/rzb.yaml"
57+ resolveRazorbillPaths("/x/agent.yaml")
58+ if Cfg.Razorbill.Config != "/etc/rzb.yaml" {
59+ t.Errorf("absolute = %q", Cfg.Razorbill.Config)
60+ }
61+}
62+
63+func TestRazorbillNegativeTimeoutIsRefused(t *testing.T) {
64+ err := loadRazorbill(t, "razorbill:\n startTimeout: -1s\n")
65+ if err == nil || !strings.Contains(err.Error(), "razorbill.startTimeout") {
66+ t.Fatalf("err = %v, want an error naming the key", err)
67+ }
68+}
modified internal/engine/llamastart.go +25 -2
@@ -21,10 +21,33 @@ import (
2121 // started there for another session answers, and this session takes a lease
2222 // on it (internal/llamastart decides, from its registry, whether it is mm's).
2323 func LlamaStartAddress(cfg config.Config) (host string, port int, ok bool) {
24- if cfg.Provider != "llamacpp" || !cfg.LlamaCpp.AutoStart || os.Getenv("AGENT_BASE_URL") != "" {
24+ if cfg.Provider != "llamacpp" || !cfg.LlamaCpp.AutoStart {
2525 return "", 0, false
2626 }
27- p, _ := registry["llamacpp"].(*openaiCompat)
27+ return startAddress(cfg)
28+}
29+
30+// RazorbillStartAddress is LlamaStartAddress for razorbill.autoStart
31+// (ticket 264): the agent's loopback address, unless the fallback —
32+// host.docker.internal, a Mac's rzb seen from a container or a sandbox —
33+// answers. mm in a container never starts rzb: its address is the
34+// container's own loopback, rzb runs on the Mac, and rzbstart refuses to
35+// start anything off macOS.
36+func RazorbillStartAddress(cfg config.Config) (host string, port int, ok bool) {
37+ if cfg.Provider != "razorbill" || !cfg.Razorbill.AutoStart {
38+ return "", 0, false
39+ }
40+ return startAddress(cfg)
41+}
42+
43+// startAddress is the common part: cfg.Provider's address when it is a
44+// loopback one, AGENT_BASE_URL is not set, and no other address of the
45+// provider (its alternates, its fallback) answers.
46+func startAddress(cfg config.Config) (host string, port int, ok bool) {
47+ if os.Getenv("AGENT_BASE_URL") != "" {
48+ return "", 0, false
49+ }
50+ p, _ := registry[cfg.Provider].(*openaiCompat)
2851 if p == nil {
2952 return "", 0, false
3053 }
@@ -21,10 +21,33 @@ import (
21 // started there for another session answers, and this session takes a lease21 // started there for another session answers, and this session takes a lease
22 // on it (internal/llamastart decides, from its registry, whether it is mm's).22 // on it (internal/llamastart decides, from its registry, whether it is mm's).
23 func LlamaStartAddress(cfg config.Config) (host string, port int, ok bool) {23 func LlamaStartAddress(cfg config.Config) (host string, port int, ok bool) {
24- if cfg.Provider != "llamacpp" || !cfg.LlamaCpp.AutoStart || os.Getenv("AGENT_BASE_URL") != "" {24+ if cfg.Provider != "llamacpp" || !cfg.LlamaCpp.AutoStart {
25 return "", 0, false25 return "", 0, false
26 }26 }
27- p, _ := registry["llamacpp"].(*openaiCompat)27+ return startAddress(cfg)
28+}
29+
30+// RazorbillStartAddress is LlamaStartAddress for razorbill.autoStart
31+// (ticket 264): the agent's loopback address, unless the fallback —
32+// host.docker.internal, a Mac's rzb seen from a container or a sandbox —
33+// answers. mm in a container never starts rzb: its address is the
34+// container's own loopback, rzb runs on the Mac, and rzbstart refuses to
35+// start anything off macOS.
36+func RazorbillStartAddress(cfg config.Config) (host string, port int, ok bool) {
37+ if cfg.Provider != "razorbill" || !cfg.Razorbill.AutoStart {
38+ return "", 0, false
39+ }
40+ return startAddress(cfg)
41+}
42+
43+// startAddress is the common part: cfg.Provider's address when it is a
44+// loopback one, AGENT_BASE_URL is not set, and no other address of the
45+// provider (its alternates, its fallback) answers.
46+func startAddress(cfg config.Config) (host string, port int, ok bool) {
47+ if os.Getenv("AGENT_BASE_URL") != "" {
48+ return "", 0, false
49+ }
50+ p, _ := registry[cfg.Provider].(*openaiCompat)
28 if p == nil {51 if p == nil {
29 return "", 0, false52 return "", 0, false
30 }53 }
modified internal/engine/llamastart_test.go +34 -0
@@ -47,3 +47,37 @@ func TestLlamaStartAddress(t *testing.T) {
4747 t.Error("fallback answers: ok, want no start")
4848 }
4949 }
50+
51+// razorbill.autoStart follows the same rules: loopback, nothing answers at
52+// the fallback (the Mac's rzb seen from a sandbox), its own switch only.
53+func TestRazorbillStartAddress(t *testing.T) {
54+ t.Setenv("AGENT_BASE_URL", "")
55+ none := ""
56+ cfg := config.Config{Provider: "razorbill", Fallback: &none, Razorbill: config.RazorbillConfig{AutoStart: true}}
57+ cfg.BaseURL = "http://127.0.0.1:1/v1"
58+ if h, p, ok := RazorbillStartAddress(cfg); !ok || h != "127.0.0.1" || p != 1 {
59+ t.Errorf("loopback, nothing answers: %s %d %v, want 127.0.0.1 1 true", h, p, ok)
60+ }
61+ llamaSwitch := cfg
62+ llamaSwitch.Razorbill.AutoStart = false
63+ llamaSwitch.LlamaCpp.AutoStart = true
64+ remote := cfg
65+ remote.BaseURL = "http://host.docker.internal:7920/v1"
66+ for name, c := range map[string]config.Config{"llamacpp's switch only": llamaSwitch, "not loopback": remote} {
67+ if _, _, ok := RazorbillStartAddress(c); ok {
68+ t.Errorf("%s: ok, want no start", name)
69+ }
70+ }
71+ if _, _, ok := LlamaStartAddress(cfg); ok {
72+ t.Error("LlamaStartAddress starts for razorbill")
73+ }
74+
75+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"data":[]}`)) }))
76+ t.Cleanup(srv.Close)
77+ fb := srv.URL + "/v1"
78+ withFallback := cfg
79+ withFallback.Fallback = &fb
80+ if _, _, ok := RazorbillStartAddress(withFallback); ok {
81+ t.Error("fallback answers: ok, want no start")
82+ }
83+}
@@ -47,3 +47,37 @@ func TestLlamaStartAddress(t *testing.T) {
47 t.Error("fallback answers: ok, want no start")47 t.Error("fallback answers: ok, want no start")
48 }48 }
49 }49 }
50+
51+// razorbill.autoStart follows the same rules: loopback, nothing answers at
52+// the fallback (the Mac's rzb seen from a sandbox), its own switch only.
53+func TestRazorbillStartAddress(t *testing.T) {
54+ t.Setenv("AGENT_BASE_URL", "")
55+ none := ""
56+ cfg := config.Config{Provider: "razorbill", Fallback: &none, Razorbill: config.RazorbillConfig{AutoStart: true}}
57+ cfg.BaseURL = "http://127.0.0.1:1/v1"
58+ if h, p, ok := RazorbillStartAddress(cfg); !ok || h != "127.0.0.1" || p != 1 {
59+ t.Errorf("loopback, nothing answers: %s %d %v, want 127.0.0.1 1 true", h, p, ok)
60+ }
61+ llamaSwitch := cfg
62+ llamaSwitch.Razorbill.AutoStart = false
63+ llamaSwitch.LlamaCpp.AutoStart = true
64+ remote := cfg
65+ remote.BaseURL = "http://host.docker.internal:7920/v1"
66+ for name, c := range map[string]config.Config{"llamacpp's switch only": llamaSwitch, "not loopback": remote} {
67+ if _, _, ok := RazorbillStartAddress(c); ok {
68+ t.Errorf("%s: ok, want no start", name)
69+ }
70+ }
71+ if _, _, ok := LlamaStartAddress(cfg); ok {
72+ t.Error("LlamaStartAddress starts for razorbill")
73+ }
74+
75+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"data":[]}`)) }))
76+ t.Cleanup(srv.Close)
77+ fb := srv.URL + "/v1"
78+ withFallback := cfg
79+ withFallback.Fallback = &fb
80+ if _, _, ok := RazorbillStartAddress(withFallback); ok {
81+ t.Error("fallback answers: ok, want no start")
82+ }
83+}
modified internal/engine/openai_compat.go +22 -1
@@ -22,7 +22,7 @@ import (
2222
2323 // openaiCompat is the Provider for every server that speaks the OpenAI
2424 // chat-completions protocol. Docker Model Runner, llama-server, llmman,
25-// Ollama's /v1, Kronk and MLX-Serve are six parametrisations of it (`openai`, in
25+// Ollama's /v1, Kronk, MLX-Serve and razorbill are seven parametrisations of it (`openai`, in
2626 // openai.go, is the generic one); vLLM and the remote APIs would be more
2727 // entries in init() below — the point of keeping the struct data-only.
2828 // Each server keeps its own entry even when two look alike today: a difference
@@ -249,6 +249,27 @@ func init() {
249249 unload: unloadMlxServe,
250250 pull: pullOllamaAPI,
251251 })
252+ register(&openaiCompat{
253+ name: "razorbill",
254+ // `rzb serve` binds the loopback by default: from a container or a
255+ // sandbox, the fallback answers once the host started it with
256+ // --host 0.0.0.0 (and, then, an API key).
257+ baseURL: "http://127.0.0.1:7920/v1",
258+ fallback: "http://host.docker.internal:7920/v1",
259+ // rzb checks a key only when the variable it reads is set; RZB_API_KEY
260+ // is its default name (--api-key-env changes it).
261+ apiKeyEnv: "RZB_API_KEY",
262+ dummyKey: "not-needed",
263+ startHint: "start it: rzb serve (add --host 0.0.0.0 when mm runs in a container or a sandbox), or set razorbill.autoStart: true",
264+ notFoundHint: "rzb models pull %s",
265+ probe: probeRazorbill,
266+ // Measured 2026-11-26 on rzb 0.2.0 (razorbill.go): no prompt_progress,
267+ // enable_thinking:false obeyed and stronger than reasoning_effort.
268+ progress: false,
269+ thinkingOff: thinkingOffTemplate,
270+ // No unload route: the server unloads idle models itself (keep_alive).
271+ noPull: "rzb has no download route: run rzb models pull <model> on the Mac (or set razorbill.autoStart: true, which pulls it), else the first question downloads it",
272+ })
252273 }
253274
254275 func (p *openaiCompat) Name() string { return p.name }
@@ -22,7 +22,7 @@ import (
22 22
23 // openaiCompat is the Provider for every server that speaks the OpenAI23 // openaiCompat is the Provider for every server that speaks the OpenAI
24 // chat-completions protocol. Docker Model Runner, llama-server, llmman,24 // chat-completions protocol. Docker Model Runner, llama-server, llmman,
25-// Ollama's /v1, Kronk and MLX-Serve are six parametrisations of it (`openai`, in25+// Ollama's /v1, Kronk, MLX-Serve and razorbill are seven parametrisations of it (`openai`, in
26 // openai.go, is the generic one); vLLM and the remote APIs would be more26 // openai.go, is the generic one); vLLM and the remote APIs would be more
27 // entries in init() below — the point of keeping the struct data-only.27 // entries in init() below — the point of keeping the struct data-only.
28 // Each server keeps its own entry even when two look alike today: a difference28 // Each server keeps its own entry even when two look alike today: a difference
@@ -249,6 +249,27 @@ func init() {
249 unload: unloadMlxServe,249 unload: unloadMlxServe,
250 pull: pullOllamaAPI,250 pull: pullOllamaAPI,
251 })251 })
252+ register(&openaiCompat{
253+ name: "razorbill",
254+ // `rzb serve` binds the loopback by default: from a container or a
255+ // sandbox, the fallback answers once the host started it with
256+ // --host 0.0.0.0 (and, then, an API key).
257+ baseURL: "http://127.0.0.1:7920/v1",
258+ fallback: "http://host.docker.internal:7920/v1",
259+ // rzb checks a key only when the variable it reads is set; RZB_API_KEY
260+ // is its default name (--api-key-env changes it).
261+ apiKeyEnv: "RZB_API_KEY",
262+ dummyKey: "not-needed",
263+ startHint: "start it: rzb serve (add --host 0.0.0.0 when mm runs in a container or a sandbox), or set razorbill.autoStart: true",
264+ notFoundHint: "rzb models pull %s",
265+ probe: probeRazorbill,
266+ // Measured 2026-11-26 on rzb 0.2.0 (razorbill.go): no prompt_progress,
267+ // enable_thinking:false obeyed and stronger than reasoning_effort.
268+ progress: false,
269+ thinkingOff: thinkingOffTemplate,
270+ // No unload route: the server unloads idle models itself (keep_alive).
271+ noPull: "rzb has no download route: run rzb models pull <model> on the Mac (or set razorbill.autoStart: true, which pulls it), else the first question downloads it",
272+ })
252 }273 }
253 274
254 func (p *openaiCompat) Name() string { return p.name }275 func (p *openaiCompat) Name() string { return p.name }
modified internal/engine/provider_test.go +4 -0
@@ -127,6 +127,9 @@ func TestResolveURLPrecedence(t *testing.T) {
127127 {"mlxserve falls back to the host's server", "mlxserve", config.Config{BaseURL: down}, nil, "http://host.docker.internal:11234/v1", "not-needed"},
128128 {"mlxserve keeps a reachable baseUrl", "mlxserve", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"},
129129 {"mlxserve reads MLX_SERVE_API_KEY when set", "mlxserve", config.Config{BaseURL: up.URL}, map[string]string{"MLX_SERVE_API_KEY": "k5", "OLLAMA_API_KEY": "k4"}, up.URL, "k5"},
130+ {"razorbill falls back to the host's server", "razorbill", config.Config{BaseURL: down}, nil, "http://host.docker.internal:7920/v1", "not-needed"},
131+ {"razorbill keeps a reachable baseUrl", "razorbill", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"},
132+ {"razorbill reads RZB_API_KEY when set", "razorbill", config.Config{BaseURL: up.URL}, map[string]string{"RZB_API_KEY": "k6", "MLX_SERVE_API_KEY": "k5"}, up.URL, "k6"},
130133 }
131134 for _, tc := range cases {
132135 t.Run(tc.name, func(t *testing.T) {
@@ -606,6 +609,7 @@ func TestDefaultURLs(t *testing.T) {
606609 {"ollama", "http://localhost:11434/v1", "http://host.docker.internal:11434/v1"},
607610 {"kronk", "http://127.0.0.1:11435/v1", "http://host.docker.internal:11435/v1"},
608611 {"mlxserve", "http://127.0.0.1:11234/v1", "http://host.docker.internal:11234/v1"},
612+ {"razorbill", "http://127.0.0.1:7920/v1", "http://host.docker.internal:7920/v1"},
609613 {"dmr", "http://localhost:12434/engines/v1", "http://host.docker.internal:12434/engines/v1"},
610614 {"llamacpp", "http://127.0.0.1:9931/v1", "http://host.docker.internal:9931/v1"},
611615 {"openai", "https://api.openai.com/v1", ""},
@@ -127,6 +127,9 @@ func TestResolveURLPrecedence(t *testing.T) {
127 {"mlxserve falls back to the host's server", "mlxserve", config.Config{BaseURL: down}, nil, "http://host.docker.internal:11234/v1", "not-needed"},127 {"mlxserve falls back to the host's server", "mlxserve", config.Config{BaseURL: down}, nil, "http://host.docker.internal:11234/v1", "not-needed"},
128 {"mlxserve keeps a reachable baseUrl", "mlxserve", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"},128 {"mlxserve keeps a reachable baseUrl", "mlxserve", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"},
129 {"mlxserve reads MLX_SERVE_API_KEY when set", "mlxserve", config.Config{BaseURL: up.URL}, map[string]string{"MLX_SERVE_API_KEY": "k5", "OLLAMA_API_KEY": "k4"}, up.URL, "k5"},129 {"mlxserve reads MLX_SERVE_API_KEY when set", "mlxserve", config.Config{BaseURL: up.URL}, map[string]string{"MLX_SERVE_API_KEY": "k5", "OLLAMA_API_KEY": "k4"}, up.URL, "k5"},
130+ {"razorbill falls back to the host's server", "razorbill", config.Config{BaseURL: down}, nil, "http://host.docker.internal:7920/v1", "not-needed"},
131+ {"razorbill keeps a reachable baseUrl", "razorbill", config.Config{BaseURL: up.URL}, nil, up.URL, "not-needed"},
132+ {"razorbill reads RZB_API_KEY when set", "razorbill", config.Config{BaseURL: up.URL}, map[string]string{"RZB_API_KEY": "k6", "MLX_SERVE_API_KEY": "k5"}, up.URL, "k6"},
130 }133 }
131 for _, tc := range cases {134 for _, tc := range cases {
132 t.Run(tc.name, func(t *testing.T) {135 t.Run(tc.name, func(t *testing.T) {
@@ -606,6 +609,7 @@ func TestDefaultURLs(t *testing.T) {
606 {"ollama", "http://localhost:11434/v1", "http://host.docker.internal:11434/v1"},609 {"ollama", "http://localhost:11434/v1", "http://host.docker.internal:11434/v1"},
607 {"kronk", "http://127.0.0.1:11435/v1", "http://host.docker.internal:11435/v1"},610 {"kronk", "http://127.0.0.1:11435/v1", "http://host.docker.internal:11435/v1"},
608 {"mlxserve", "http://127.0.0.1:11234/v1", "http://host.docker.internal:11234/v1"},611 {"mlxserve", "http://127.0.0.1:11234/v1", "http://host.docker.internal:11234/v1"},
612+ {"razorbill", "http://127.0.0.1:7920/v1", "http://host.docker.internal:7920/v1"},
609 {"dmr", "http://localhost:12434/engines/v1", "http://host.docker.internal:12434/engines/v1"},613 {"dmr", "http://localhost:12434/engines/v1", "http://host.docker.internal:12434/engines/v1"},
610 {"llamacpp", "http://127.0.0.1:9931/v1", "http://host.docker.internal:9931/v1"},614 {"llamacpp", "http://127.0.0.1:9931/v1", "http://host.docker.internal:9931/v1"},
611 {"openai", "https://api.openai.com/v1", ""},615 {"openai", "https://api.openai.com/v1", ""},
added internal/engine/razorbill.go +59 -0
new file mode 100644
@@ -0,0 +1,59 @@
1+package engine
2+
3+import (
4+ "context"
5+ "errors"
6+ "fmt"
7+ "net/http"
8+ "strings"
9+)
10+
11+// razorbill (ticket 264) is an MLX model server for Apple Silicon Macs,
12+// command `rzb`, that speaks the OpenAI API on 127.0.0.1:7920. Measured on
13+// rzb 0.2.0, 2026-11-26, from an sbx sandbox on the Mac's server
14+// (mlx-community/Qwen3-0.6B-4bit) and read in its HTTP API reference:
15+//
16+// - GET /health answers {"status":"ok"} without a key;
17+// - GET /v1/models lists the models declared in the server's YAML, then
18+// every loadable model of the Hugging Face cache, each with `loaded`
19+// and `kind`. No window is given: the context stays unknown until the
20+// user sets contextWindow;
21+// - a model is loaded on the first request that names it, and DOWNLOADED
22+// first when it is a Hugging Face id not in the cache; idle models are
23+// unloaded by the server itself (`keep_alive`, 10m). There is no route
24+// to load, unload or pull a model;
25+// - reasoning streams in `reasoning_content`; chat_template_kwargs
26+// enable_thinking:false turns it off and wins over reasoning_effort
27+// (measured: off even with reasoning_effort "high");
28+// - while it produces nothing it sends `: keep-alive` comments, which
29+// dropSSEComments (ssecomments.go) removes before openai-go;
30+// - with an API key (RZB_API_KEY by default) every route but /health
31+// wants `Authorization: Bearer`, else 401 invalid_api_key.
32+
33+// probeRazorbill: reachable when /v1/models answers, a warning when the
34+// server refuses the key, and one when the model is not in its list — it
35+// would be downloaded by the first question, which the watchdog may not
36+// wait for.
37+func probeRazorbill(ctx context.Context, b Backend) Info {
38+ ctx, cancel := context.WithTimeout(ctx, probeClient.Timeout)
39+ defer cancel()
40+
41+ var list modelList
42+ err := getWithKey(ctx, b, strings.TrimSuffix(b.BaseURL, "/")+"/models", &list)
43+ var status *httpStatusError
44+ switch {
45+ case errors.As(err, &status) && (status.code == http.StatusUnauthorized || status.code == http.StatusForbidden):
46+ return Info{Reachable: true, Warnings: []string{
47+ fmt.Sprintf("razorbill: the server refuses the key (%d) — is $%s set to the server's key?", status.code, b.APIKeyEnv),
48+ }}
49+ case err != nil:
50+ return Info{}
51+ }
52+
53+ info := Info{Reachable: true}
54+ if !list.has(b.Model) {
55+ info.Warnings = append(info.Warnings, fmt.Sprintf(
56+ "razorbill: model %q is not downloaded — rzb models pull %s (the first question would download it, and may time out meanwhile)", b.Model, b.Model))
57+ }
58+ return info
59+}
new file mode 100644
@@ -0,0 +1,59 @@
1+package engine
2+
3+import (
4+ "context"
5+ "errors"
6+ "fmt"
7+ "net/http"
8+ "strings"
9+)
10+
11+// razorbill (ticket 264) is an MLX model server for Apple Silicon Macs,
12+// command `rzb`, that speaks the OpenAI API on 127.0.0.1:7920. Measured on
13+// rzb 0.2.0, 2026-11-26, from an sbx sandbox on the Mac's server
14+// (mlx-community/Qwen3-0.6B-4bit) and read in its HTTP API reference:
15+//
16+// - GET /health answers {"status":"ok"} without a key;
17+// - GET /v1/models lists the models declared in the server's YAML, then
18+// every loadable model of the Hugging Face cache, each with `loaded`
19+// and `kind`. No window is given: the context stays unknown until the
20+// user sets contextWindow;
21+// - a model is loaded on the first request that names it, and DOWNLOADED
22+// first when it is a Hugging Face id not in the cache; idle models are
23+// unloaded by the server itself (`keep_alive`, 10m). There is no route
24+// to load, unload or pull a model;
25+// - reasoning streams in `reasoning_content`; chat_template_kwargs
26+// enable_thinking:false turns it off and wins over reasoning_effort
27+// (measured: off even with reasoning_effort "high");
28+// - while it produces nothing it sends `: keep-alive` comments, which
29+// dropSSEComments (ssecomments.go) removes before openai-go;
30+// - with an API key (RZB_API_KEY by default) every route but /health
31+// wants `Authorization: Bearer`, else 401 invalid_api_key.
32+
33+// probeRazorbill: reachable when /v1/models answers, a warning when the
34+// server refuses the key, and one when the model is not in its list — it
35+// would be downloaded by the first question, which the watchdog may not
36+// wait for.
37+func probeRazorbill(ctx context.Context, b Backend) Info {
38+ ctx, cancel := context.WithTimeout(ctx, probeClient.Timeout)
39+ defer cancel()
40+
41+ var list modelList
42+ err := getWithKey(ctx, b, strings.TrimSuffix(b.BaseURL, "/")+"/models", &list)
43+ var status *httpStatusError
44+ switch {
45+ case errors.As(err, &status) && (status.code == http.StatusUnauthorized || status.code == http.StatusForbidden):
46+ return Info{Reachable: true, Warnings: []string{
47+ fmt.Sprintf("razorbill: the server refuses the key (%d) — is $%s set to the server's key?", status.code, b.APIKeyEnv),
48+ }}
49+ case err != nil:
50+ return Info{}
51+ }
52+
53+ info := Info{Reachable: true}
54+ if !list.has(b.Model) {
55+ info.Warnings = append(info.Warnings, fmt.Sprintf(
56+ "razorbill: model %q is not downloaded — rzb models pull %s (the first question would download it, and may time out meanwhile)", b.Model, b.Model))
57+ }
58+ return info
59+}
added internal/engine/razorbill_test.go +83 -0
new file mode 100644
@@ -0,0 +1,83 @@
1+package engine
2+
3+import (
4+ "context"
5+ "io"
6+ "net/http"
7+ "net/http/httptest"
8+ "strings"
9+ "testing"
10+)
11+
12+const rzbTestModel = "mlx-community/Qwen3-0.6B-4bit"
13+
14+// fakeRazorbill replays rzb 0.2.0's GET /v1/models (razorbill.go), with an
15+// optional required key answered by 401 invalid_api_key.
16+func fakeRazorbill(t *testing.T, key string) Backend {
17+ t.Helper()
18+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
19+ if key != "" && r.Header.Get("Authorization") != "Bearer "+key {
20+ w.WriteHeader(http.StatusUnauthorized)
21+ _, _ = io.WriteString(w, `{"error":{"message":"Incorrect or missing API key.","type":"invalid_request_error","code":"invalid_api_key"}}`)
22+ return
23+ }
24+ if r.URL.Path != "/v1/models" {
25+ w.WriteHeader(http.StatusNotFound)
26+ return
27+ }
28+ _, _ = io.WriteString(w, `{"data":[{"created":1795678336,"id":"`+rzbTestModel+`","kind":"chat","loaded":false,"object":"model","owned_by":"razorbill"}],"object":"list"}`)
29+ }))
30+ t.Cleanup(srv.Close)
31+ return Backend{Provider: "razorbill", BaseURL: srv.URL + "/v1", Model: rzbTestModel, APIKey: "not-needed", APIKeyEnv: "RZB_API_KEY"}
32+}
33+
34+func TestProbeRazorbillListedModelHasNoWarning(t *testing.T) {
35+ info := probeRazorbill(context.Background(), fakeRazorbill(t, ""))
36+ if !info.Reachable || len(info.Warnings) != 0 || info.ContextWindow != 0 {
37+ t.Fatalf("info = %+v, want reachable, no warning, unknown window", info)
38+ }
39+}
40+
41+func TestProbeRazorbillWarnsAboutAMissingModel(t *testing.T) {
42+ b := fakeRazorbill(t, "")
43+ b.Model = "mlx-community/Other-4bit"
44+ info := probeRazorbill(context.Background(), b)
45+ if !info.Reachable || len(info.Warnings) != 1 || !strings.Contains(info.Warnings[0], "rzb models pull mlx-community/Other-4bit") {
46+ t.Fatalf("info = %+v, want one pull warning", info)
47+ }
48+}
49+
50+func TestProbeRazorbillWarnsAboutARefusedKey(t *testing.T) {
51+ info := probeRazorbill(context.Background(), fakeRazorbill(t, "secret"))
52+ if !info.Reachable || len(info.Warnings) != 1 || !strings.Contains(info.Warnings[0], "$RZB_API_KEY") {
53+ t.Fatalf("info = %+v, want reachable with a key warning", info)
54+ }
55+}
56+
57+func TestProbeRazorbillSendsTheKey(t *testing.T) {
58+ b := fakeRazorbill(t, "secret")
59+ b.APIKey = "secret"
60+ if info := probeRazorbill(context.Background(), b); !info.Reachable || len(info.Warnings) != 0 {
61+ t.Fatalf("info = %+v, want reachable without warning", info)
62+ }
63+}
64+
65+func TestProbeRazorbillDownIsUnreachable(t *testing.T) {
66+ b := Backend{Provider: "razorbill", BaseURL: "http://127.0.0.1:1/v1", Model: rzbTestModel}
67+ if info := probeRazorbill(context.Background(), b); info.Reachable {
68+ t.Fatalf("info = %+v, want unreachable", info)
69+ }
70+}
71+
72+// Summaries turn reasoning off through the template switch only: rzb obeys
73+// enable_thinking:false over any reasoning_effort (measured on rzb 0.2.0).
74+func TestRazorbillTurnsReasoningOffThroughTheTemplate(t *testing.T) {
75+ p, err := Lookup("razorbill")
76+ if err != nil {
77+ t.Fatal(err)
78+ }
79+ c := p.(*openaiCompat)
80+ if c.thinkingOff != thinkingOffTemplate || c.progress || c.unload != nil || c.pull != nil || c.noPull == "" {
81+ t.Fatalf("razorbill entry = %+v", c)
82+ }
83+}
new file mode 100644
@@ -0,0 +1,83 @@
1+package engine
2+
3+import (
4+ "context"
5+ "io"
6+ "net/http"
7+ "net/http/httptest"
8+ "strings"
9+ "testing"
10+)
11+
12+const rzbTestModel = "mlx-community/Qwen3-0.6B-4bit"
13+
14+// fakeRazorbill replays rzb 0.2.0's GET /v1/models (razorbill.go), with an
15+// optional required key answered by 401 invalid_api_key.
16+func fakeRazorbill(t *testing.T, key string) Backend {
17+ t.Helper()
18+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
19+ if key != "" && r.Header.Get("Authorization") != "Bearer "+key {
20+ w.WriteHeader(http.StatusUnauthorized)
21+ _, _ = io.WriteString(w, `{"error":{"message":"Incorrect or missing API key.","type":"invalid_request_error","code":"invalid_api_key"}}`)
22+ return
23+ }
24+ if r.URL.Path != "/v1/models" {
25+ w.WriteHeader(http.StatusNotFound)
26+ return
27+ }
28+ _, _ = io.WriteString(w, `{"data":[{"created":1795678336,"id":"`+rzbTestModel+`","kind":"chat","loaded":false,"object":"model","owned_by":"razorbill"}],"object":"list"}`)
29+ }))
30+ t.Cleanup(srv.Close)
31+ return Backend{Provider: "razorbill", BaseURL: srv.URL + "/v1", Model: rzbTestModel, APIKey: "not-needed", APIKeyEnv: "RZB_API_KEY"}
32+}
33+
34+func TestProbeRazorbillListedModelHasNoWarning(t *testing.T) {
35+ info := probeRazorbill(context.Background(), fakeRazorbill(t, ""))
36+ if !info.Reachable || len(info.Warnings) != 0 || info.ContextWindow != 0 {
37+ t.Fatalf("info = %+v, want reachable, no warning, unknown window", info)
38+ }
39+}
40+
41+func TestProbeRazorbillWarnsAboutAMissingModel(t *testing.T) {
42+ b := fakeRazorbill(t, "")
43+ b.Model = "mlx-community/Other-4bit"
44+ info := probeRazorbill(context.Background(), b)
45+ if !info.Reachable || len(info.Warnings) != 1 || !strings.Contains(info.Warnings[0], "rzb models pull mlx-community/Other-4bit") {
46+ t.Fatalf("info = %+v, want one pull warning", info)
47+ }
48+}
49+
50+func TestProbeRazorbillWarnsAboutARefusedKey(t *testing.T) {
51+ info := probeRazorbill(context.Background(), fakeRazorbill(t, "secret"))
52+ if !info.Reachable || len(info.Warnings) != 1 || !strings.Contains(info.Warnings[0], "$RZB_API_KEY") {
53+ t.Fatalf("info = %+v, want reachable with a key warning", info)
54+ }
55+}
56+
57+func TestProbeRazorbillSendsTheKey(t *testing.T) {
58+ b := fakeRazorbill(t, "secret")
59+ b.APIKey = "secret"
60+ if info := probeRazorbill(context.Background(), b); !info.Reachable || len(info.Warnings) != 0 {
61+ t.Fatalf("info = %+v, want reachable without warning", info)
62+ }
63+}
64+
65+func TestProbeRazorbillDownIsUnreachable(t *testing.T) {
66+ b := Backend{Provider: "razorbill", BaseURL: "http://127.0.0.1:1/v1", Model: rzbTestModel}
67+ if info := probeRazorbill(context.Background(), b); info.Reachable {
68+ t.Fatalf("info = %+v, want unreachable", info)
69+ }
70+}
71+
72+// Summaries turn reasoning off through the template switch only: rzb obeys
73+// enable_thinking:false over any reasoning_effort (measured on rzb 0.2.0).
74+func TestRazorbillTurnsReasoningOffThroughTheTemplate(t *testing.T) {
75+ p, err := Lookup("razorbill")
76+ if err != nil {
77+ t.Fatal(err)
78+ }
79+ c := p.(*openaiCompat)
80+ if c.thinkingOff != thinkingOffTemplate || c.progress || c.unload != nil || c.pull != nil || c.noPull == "" {
81+ t.Fatalf("razorbill entry = %+v", c)
82+ }
83+}
modified internal/llamastart/llamastart.go +38 -303
@@ -17,14 +17,11 @@
1717 // - stopping only the router's pid leaves its children running: the whole
1818 // process group (a process tree on Windows) has to be stopped.
1919 //
20-// The lifetime is shared. A small registry per address, under the user's
21-// cache directory, holds the pid of the server mm started (server.json) and
22-// one lease file per running mm process (leases/<pid>). The last mm to
23-// release its lease stops the server. A lease whose process is gone (a
24-// crash) is removed by the next mm that reads the registry. A server mm did
25-// not start — the user's own, the Llama app's — has no server.json: mm takes
26-// no lease on it and never stops it. A lock file keeps two mm starting at
27-// the same time from starting two servers.
20+// The lifetime is internal/serverstart's (ticket 264 moved it there): a
21+// registry per address under <cache>/mm/llama-server/, one lease per mm
22+// session, the server stopped with the last one, and a server mm did not
23+// start — the user's own, the Llama app's — never stopped. This package
24+// says how to start llama-server and how to get the agent's model loaded.
2825 package llamastart
2926
3027 import (
@@ -38,8 +35,9 @@ import (
3835 "path/filepath"
3936 "strconv"
4037 "strings"
41- "sync"
4238 "time"
39+
40+ "mm/internal/serverstart"
4341 )
4442
4543 // Options says which server to start and how to talk about it.
@@ -67,29 +65,7 @@ type Options struct {
6765
6866 // Lease is this process's use of a server mm started. Release it on exit.
6967 // A nil *Lease (no server mm started) releases nothing.
70-type Lease struct {
71- dir string
72- report func(string)
73- once sync.Once
74-}
75-
76-// record is server.json: the server mm started at this address.
77-type record struct {
78- PID int `json:"pid"`
79- Binary string `json:"binary"`
80- Args []string `json:"args"`
81- Started time.Time `json:"started"`
82-}
83-
84-// lockWait bounds the wait for another mm's start; lockStale is the age
85-// past which a lock whose holder still runs is taken anyway.
86-var (
87- lockWait = time.Minute
88- lockStale = 2 * time.Minute
89- stopGrace = 5 * time.Second
90- // poll is the step of every wait loop.
91- poll = 200 * time.Millisecond
92-)
68+type Lease = serverstart.Lease
9369
9470 // ErrNotFound: no llama-server binary to start.
9571 var ErrNotFound = errors.New("llama-server not found on the PATH — install llama.cpp (macOS: brew install llama.cpp; Linux, Windows: an archive from https://github.com/ggml-org/llama.cpp/releases) or set llamacpp.server to its path")
@@ -98,128 +74,34 @@ var ErrNotFound = errors.New("llama-server not found on the PATH — install lla
9874 // starting it when nothing answers, and returns this process's lease on
9975 // it. It returns a nil lease and no error when a server mm did not start
10076 // already answers there: that one is left alone. On an error after a start,
101-// the server is stopped again unless another mm uses it.
77+// the lease is returned: its release stops the server unless another mm
78+// uses it.
79+//
80+// lease, err := llamastart.Acquire(ctx, llamastart.Options{Host: "127.0.0.1", Port: 9931, Model: "ggml-org/gemma-3-1b-it-GGUF:Q4_K_M"})
81+// defer lease.Release()
10282 func Acquire(ctx context.Context, o Options) (*Lease, error) {
103- if o.Timeout <= 0 {
104- o.Timeout = 10 * time.Minute
105- }
106- dir, err := registryDir(o)
107- if err != nil {
108- return nil, err
109- }
110- base := "http://" + hostPort(o.Host, o.Port)
111- l := &Lease{dir: dir, report: o.Report}
112-
113- unlock, err := lock(ctx, dir)
114- if err != nil {
115- return nil, err
116- }
117- rec := readRecord(dir)
118- if rec != nil && !alive(rec.PID) {
119- removeRecord(dir)
120- rec = nil
121- }
122- up := healthy(base)
123- switch {
124- case up && rec == nil:
125- unlock()
126- return nil, nil // not ours: never stopped
127- case up:
128- l.add()
129- unlock()
130- o.say("🦙 llama-server already started by mm (pid %d): shared with this session", rec.PID)
131- default:
132- if rec != nil { // ours, alive, not answering: hung — replace it
133- stop(rec.PID)
134- removeRecord(dir)
135- }
136- if err := start(ctx, o, dir, base); err != nil {
137- unlock()
138- return nil, err
139- }
140- l.add()
141- unlock()
142- }
143- if err := ensureModel(ctx, o, base); err != nil {
144- return l, err
145- }
146- return l, nil
83+ return serverstart.Acquire(ctx, server(o))
14784 }
14885
149-// Release removes this process's lease and stops the server when no live
150-// lease remains. Safe to call more than once, and on a nil lease.
151-func (l *Lease) Release() {
152- if l == nil {
153- return
154- }
155- l.once.Do(func() {
156- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
157- defer cancel()
158- unlock, err := lock(ctx, l.dir)
159- if err != nil {
160- return // another mm holds it: it will see our lease is stale
161- }
162- defer unlock()
163- _ = os.Remove(filepath.Join(l.dir, "leases", strconv.Itoa(os.Getpid())))
164- others := liveLeases(l.dir)
165- rec := readRecord(l.dir)
166- switch {
167- case rec == nil:
168- case others > 0:
169- l.say("🦙 llama-server kept running: %d other mm session(s) use it", others)
170- default:
171- stop(rec.PID)
172- removeRecord(l.dir)
173- l.say("🦙 stopped llama-server (pid %d)", rec.PID)
174- }
175- })
176-}
177-
178-func (l *Lease) add() {
179- _ = os.WriteFile(filepath.Join(l.dir, "leases", strconv.Itoa(os.Getpid())), nil, 0o644)
180-}
86+// LogPath is where the server started for o writes its output.
87+func LogPath(o Options) string { return serverstart.LogPath(server(o)) }
18188
182-func (l *Lease) say(format string, args ...any) {
183- if l.report != nil {
184- l.report(fmt.Sprintf(format, args...))
89+// server is o in serverstart's terms: llama-server's name (its registry
90+// directory and log name since ticket 223), its command and its model load.
91+func server(o Options) serverstart.Options {
92+ so := serverstart.Options{
93+ Host: o.Host, Port: o.Port, StateDir: o.StateDir, Timeout: o.Timeout,
94+ Report: o.Report, Wait: o.Wait,
18595 }
186-}
187-
188-func (o Options) say(format string, args ...any) {
189- if o.Report != nil {
190- o.Report(fmt.Sprintf(format, args...))
96+ so.Server = serverstart.Server{
97+ Name: "llama-server",
98+ Emoji: "🦙",
99+ Command: func(dir string) (string, []string, error) { return command(o, dir) },
100+ Ready: func(ctx context.Context, so serverstart.Options, base string) error {
101+ return ensureModel(ctx, o, so, base)
102+ },
191103 }
192-}
193-
194-func (o Options) wait(text string) func() {
195- if o.Wait == nil {
196- return func() {}
197- }
198- return o.Wait(text)
199-}
200-
201-// registryDir is <StateDir>/<host>-<port>, with its leases directory.
202-func registryDir(o Options) (string, error) {
203- root := o.StateDir
204- if root == "" {
205- cache, err := os.UserCacheDir()
206- if err != nil {
207- return "", err
208- }
209- root = filepath.Join(cache, "mm", "llama-server")
210- }
211- name := strings.NewReplacer(":", "_", "/", "_", "\\", "_").Replace(o.Host) + "-" + strconv.Itoa(o.Port)
212- dir := filepath.Join(root, name)
213- return dir, os.MkdirAll(filepath.Join(dir, "leases"), 0o755)
214-}
215-
216-// LogPath is where the server started for o writes its output.
217-func LogPath(o Options) string {
218- dir, err := registryDir(o)
219- if err != nil {
220- return ""
221- }
222- return filepath.Join(dir, "llama-server.log")
104+ return so
223105 }
224106
225107 // command is the binary and arguments that start a router on o's address,
@@ -257,54 +139,6 @@ func command(o Options, dir string) (string, []string, error) {
257139 return bin, append(args, o.Args...), nil
258140 }
259141
260-// start launches the server detached from mm (its own process group, its
261-// output in the log file), records it and waits until /health answers.
262-func start(ctx context.Context, o Options, dir, base string) error {
263- bin, args, err := command(o, dir)
264- if err != nil {
265- return err
266- }
267- logPath := filepath.Join(dir, "llama-server.log")
268- logFile, err := os.Create(logPath)
269- if err != nil {
270- return err
271- }
272- cmd := exec.Command(bin, args...)
273- cmd.Stdout, cmd.Stderr = logFile, logFile
274- detach(cmd)
275- if err := cmd.Start(); err != nil {
276- _ = logFile.Close()
277- return fmt.Errorf("start %s: %w", bin, err)
278- }
279- _ = logFile.Close()
280- exited := make(chan error, 1)
281- go func() { exited <- cmd.Wait() }() // reaps it if it ends while mm runs
282- rec := record{PID: cmd.Process.Pid, Binary: bin, Args: args, Started: time.Now()}
283- if err := writeRecord(dir, rec); err != nil {
284- stop(rec.PID)
285- return err
286- }
287- o.say("🦙 starting llama-server on %s (pid %d, log %s)", hostPort(o.Host, o.Port), rec.PID, logPath)
288-
289- done := o.wait("Starting llama-server…")
290- defer done()
291- ctx, cancel := context.WithTimeout(ctx, o.Timeout)
292- defer cancel()
293- for !healthy(base) {
294- select {
295- case err := <-exited:
296- removeRecord(dir)
297- return fmt.Errorf("llama-server stopped at once (%v) — see %s", err, logPath)
298- case <-ctx.Done():
299- stop(rec.PID)
300- removeRecord(dir)
301- return fmt.Errorf("llama-server did not answer within %s — see %s", o.Timeout, logPath)
302- case <-time.After(poll):
303- }
304- }
305- return nil
306-}
307-
308142 // routerModel is one entry of a router's GET /models.
309143 type routerModel struct {
310144 ID string `json:"id"`
@@ -317,7 +151,7 @@ type routerModel struct {
317151
318152 // ensureModel loads o.Model on the router at base and waits until it is
319153 // loaded — downloaded first when it is not in the cache.
320-func ensureModel(ctx context.Context, o Options, base string) error {
154+func ensureModel(ctx context.Context, o Options, so serverstart.Options, base string) error {
321155 if o.Model == "" {
322156 return nil
323157 }
@@ -330,9 +164,9 @@ func ensureModel(ctx context.Context, o Options, base string) error {
330164 case m.Status.Value == "loaded":
331165 return nil
332166 }
333- done := o.wait("Loading " + o.Model + " (downloaded first when missing)…")
167+ done := so.WaitFor("Loading " + o.Model + " (downloaded first when missing)…")
334168 defer done()
335- ctx, cancel := context.WithTimeout(ctx, o.Timeout)
169+ ctx, cancel := context.WithTimeout(ctx, so.Timeout)
336170 defer cancel()
337171 body := fmt.Sprintf(`{"model":%q}`, o.Model)
338172 req, err := http.NewRequestWithContext(ctx, http.MethodPost, base+"/models/load", strings.NewReader(body))
@@ -352,19 +186,19 @@ func ensureModel(ctx context.Context, o Options, base string) error {
352186 m, _, err := findModel(ctx, base, o.Model)
353187 switch {
354188 case err != nil && ctx.Err() != nil:
355- return fmt.Errorf("%s was not loaded within %s — see %s", o.Model, o.Timeout, LogPath(o))
189+ return fmt.Errorf("%s was not loaded within %s — see %s", o.Model, so.Timeout, serverstart.LogPath(so))
356190 case err != nil:
357191 return err
358192 case m.Status.Value == "loaded":
359- o.say("🦙 %s loaded", o.Model)
193+ so.Say("%s loaded", o.Model)
360194 return nil
361195 case m.Status.Failed:
362- return fmt.Errorf("llama-server could not load %s (exit code %d) — see %s", o.Model, m.Status.ExitCode, LogPath(o))
196+ return fmt.Errorf("llama-server could not load %s (exit code %d) — see %s", o.Model, m.Status.ExitCode, serverstart.LogPath(so))
363197 }
364198 select {
365199 case <-ctx.Done():
366- return fmt.Errorf("%s was not loaded within %s — see %s", o.Model, o.Timeout, LogPath(o))
367- case <-time.After(poll):
200+ return fmt.Errorf("%s was not loaded within %s — see %s", o.Model, so.Timeout, serverstart.LogPath(so))
201+ case <-time.After(serverstart.Poll):
368202 }
369203 }
370204 }
@@ -392,102 +226,3 @@ func findModel(ctx context.Context, base, model string) (routerModel, bool, erro
392226 }
393227 return routerModel{}, false, nil
394228 }
395-
396-var healthClient = &http.Client{Timeout: time.Second}
397-
398-func healthy(base string) bool {
399- resp, err := healthClient.Get(base + "/health")
400- if err != nil {
401- return false
402- }
403- _ = resp.Body.Close()
404- return resp.StatusCode == http.StatusOK
405-}
406-
407-func hostPort(host string, port int) string {
408- if strings.Contains(host, ":") {
409- host = "[" + host + "]"
410- }
411- return host + ":" + strconv.Itoa(port)
412-}
413-
414-// liveLeases counts the leases whose process still runs, removing the
415-// others (a crashed mm).
416-func liveLeases(dir string) int {
417- entries, _ := os.ReadDir(filepath.Join(dir, "leases"))
418- n := 0
419- for _, e := range entries {
420- pid, err := strconv.Atoi(e.Name())
421- if err == nil && alive(pid) {
422- n++
423- continue
424- }
425- _ = os.Remove(filepath.Join(dir, "leases", e.Name()))
426- }
427- return n
428-}
429-
430-func readRecord(dir string) *record {
431- data, err := os.ReadFile(filepath.Join(dir, "server.json"))
432- if err != nil {
433- return nil
434- }
435- var r record
436- if json.Unmarshal(data, &r) != nil || r.PID <= 0 {
437- return nil
438- }
439- return &r
440-}
441-
442-func writeRecord(dir string, r record) error {
443- data, err := json.MarshalIndent(r, "", " ")
444- if err != nil {
445- return err
446- }
447- return os.WriteFile(filepath.Join(dir, "server.json"), data, 0o644)
448-}
449-
450-func removeRecord(dir string) { _ = os.Remove(filepath.Join(dir, "server.json")) }
451-
452-// lock takes dir's lock file — created exclusively, holding our pid — and
453-// returns its release. A lock whose holder is gone, or older than
454-// lockStale, is taken over.
455-func lock(ctx context.Context, dir string) (func(), error) {
456- path := filepath.Join(dir, "lock")
457- ctx, cancel := context.WithTimeout(ctx, lockWait)
458- defer cancel()
459- for {
460- f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644)
461- if err == nil {
462- _, _ = f.WriteString(strconv.Itoa(os.Getpid()))
463- _ = f.Close()
464- return func() { _ = os.Remove(path) }, nil
465- }
466- if !errors.Is(err, os.ErrExist) {
467- return nil, err
468- }
469- if staleLock(path) {
470- _ = os.Remove(path)
471- continue
472- }
473- select {
474- case <-ctx.Done():
475- return nil, fmt.Errorf("another mm is starting llama-server (lock %s)", path)
476- case <-time.After(poll):
477- }
478- }
479-}
480-
481-func staleLock(path string) bool {
482- info, err := os.Stat(path)
483- if err != nil {
484- return false // gone meanwhile: retry
485- }
486- data, _ := os.ReadFile(path)
487- pid, err := strconv.Atoi(strings.TrimSpace(string(data)))
488- if err != nil {
489- // Being written right now, or garbage: only an old one is stale.
490- return time.Since(info.ModTime()) > lockStale
491- }
492- return !alive(pid) || time.Since(info.ModTime()) > lockStale
493-}
@@ -17,14 +17,11 @@
17 // - stopping only the router's pid leaves its children running: the whole17 // - stopping only the router's pid leaves its children running: the whole
18 // process group (a process tree on Windows) has to be stopped.18 // process group (a process tree on Windows) has to be stopped.
19 //19 //
20-// The lifetime is shared. A small registry per address, under the user's20+// The lifetime is internal/serverstart's (ticket 264 moved it there): a
21-// cache directory, holds the pid of the server mm started (server.json) and21+// registry per address under <cache>/mm/llama-server/, one lease per mm
22-// one lease file per running mm process (leases/<pid>). The last mm to22+// session, the server stopped with the last one, and a server mm did not
23-// release its lease stops the server. A lease whose process is gone (a23+// start — the user's own, the Llama app's — never stopped. This package
24-// crash) is removed by the next mm that reads the registry. A server mm did24+// says how to start llama-server and how to get the agent's model loaded.
25-// not start — the user's own, the Llama app's — has no server.json: mm takes
26-// no lease on it and never stops it. A lock file keeps two mm starting at
27-// the same time from starting two servers.
28 package llamastart25 package llamastart
29 26
30 import (27 import (
@@ -38,8 +35,9 @@ import (
38 "path/filepath"35 "path/filepath"
39 "strconv"36 "strconv"
40 "strings"37 "strings"
41- "sync"
42 "time"38 "time"
39+
40+ "mm/internal/serverstart"
43 )41 )
44 42
45 // Options says which server to start and how to talk about it.43 // Options says which server to start and how to talk about it.
@@ -67,29 +65,7 @@ type Options struct {
67 65
68 // Lease is this process's use of a server mm started. Release it on exit.66 // Lease is this process's use of a server mm started. Release it on exit.
69 // A nil *Lease (no server mm started) releases nothing.67 // A nil *Lease (no server mm started) releases nothing.
70-type Lease struct {68+type Lease = serverstart.Lease
71- dir string
72- report func(string)
73- once sync.Once
74-}
75-
76-// record is server.json: the server mm started at this address.
77-type record struct {
78- PID int `json:"pid"`
79- Binary string `json:"binary"`
80- Args []string `json:"args"`
81- Started time.Time `json:"started"`
82-}
83-
84-// lockWait bounds the wait for another mm's start; lockStale is the age
85-// past which a lock whose holder still runs is taken anyway.
86-var (
87- lockWait = time.Minute
88- lockStale = 2 * time.Minute
89- stopGrace = 5 * time.Second
90- // poll is the step of every wait loop.
91- poll = 200 * time.Millisecond
92-)
93 69
94 // ErrNotFound: no llama-server binary to start.70 // ErrNotFound: no llama-server binary to start.
95 var ErrNotFound = errors.New("llama-server not found on the PATH — install llama.cpp (macOS: brew install llama.cpp; Linux, Windows: an archive from https://github.com/ggml-org/llama.cpp/releases) or set llamacpp.server to its path")71 var ErrNotFound = errors.New("llama-server not found on the PATH — install llama.cpp (macOS: brew install llama.cpp; Linux, Windows: an archive from https://github.com/ggml-org/llama.cpp/releases) or set llamacpp.server to its path")
@@ -98,128 +74,34 @@ var ErrNotFound = errors.New("llama-server not found on the PATH — install lla
98 // starting it when nothing answers, and returns this process's lease on74 // starting it when nothing answers, and returns this process's lease on
99 // it. It returns a nil lease and no error when a server mm did not start75 // it. It returns a nil lease and no error when a server mm did not start
100 // already answers there: that one is left alone. On an error after a start,76 // already answers there: that one is left alone. On an error after a start,
101-// the server is stopped again unless another mm uses it.77+// the lease is returned: its release stops the server unless another mm
78+// uses it.
79+//
80+// lease, err := llamastart.Acquire(ctx, llamastart.Options{Host: "127.0.0.1", Port: 9931, Model: "ggml-org/gemma-3-1b-it-GGUF:Q4_K_M"})
81+// defer lease.Release()
102 func Acquire(ctx context.Context, o Options) (*Lease, error) {82 func Acquire(ctx context.Context, o Options) (*Lease, error) {
103- if o.Timeout <= 0 {83+ return serverstart.Acquire(ctx, server(o))
104- o.Timeout = 10 * time.Minute
105- }
106- dir, err := registryDir(o)
107- if err != nil {
108- return nil, err
109- }
110- base := "http://" + hostPort(o.Host, o.Port)
111- l := &Lease{dir: dir, report: o.Report}
112-
113- unlock, err := lock(ctx, dir)
114- if err != nil {
115- return nil, err
116- }
117- rec := readRecord(dir)
118- if rec != nil && !alive(rec.PID) {
119- removeRecord(dir)
120- rec = nil
121- }
122- up := healthy(base)
123- switch {
124- case up && rec == nil:
125- unlock()
126- return nil, nil // not ours: never stopped
127- case up:
128- l.add()
129- unlock()
130- o.say("🦙 llama-server already started by mm (pid %d): shared with this session", rec.PID)
131- default:
132- if rec != nil { // ours, alive, not answering: hung — replace it
133- stop(rec.PID)
134- removeRecord(dir)
135- }
136- if err := start(ctx, o, dir, base); err != nil {
137- unlock()
138- return nil, err
139- }
140- l.add()
141- unlock()
142- }
143- if err := ensureModel(ctx, o, base); err != nil {
144- return l, err
145- }
146- return l, nil
147 }84 }
148 85
149-// Release removes this process's lease and stops the server when no live86+// LogPath is where the server started for o writes its output.
150-// lease remains. Safe to call more than once, and on a nil lease.87+func LogPath(o Options) string { return serverstart.LogPath(server(o)) }
151-func (l *Lease) Release() {
152- if l == nil {
153- return
154- }
155- l.once.Do(func() {
156- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
157- defer cancel()
158- unlock, err := lock(ctx, l.dir)
159- if err != nil {
160- return // another mm holds it: it will see our lease is stale
161- }
162- defer unlock()
163- _ = os.Remove(filepath.Join(l.dir, "leases", strconv.Itoa(os.Getpid())))
164- others := liveLeases(l.dir)
165- rec := readRecord(l.dir)
166- switch {
167- case rec == nil:
168- case others > 0:
169- l.say("🦙 llama-server kept running: %d other mm session(s) use it", others)
170- default:
171- stop(rec.PID)
172- removeRecord(l.dir)
173- l.say("🦙 stopped llama-server (pid %d)", rec.PID)
174- }
175- })
176-}
177-
178-func (l *Lease) add() {
179- _ = os.WriteFile(filepath.Join(l.dir, "leases", strconv.Itoa(os.Getpid())), nil, 0o644)
180-}
181 88
182-func (l *Lease) say(format string, args ...any) {89+// server is o in serverstart's terms: llama-server's name (its registry
183- if l.report != nil {90+// directory and log name since ticket 223), its command and its model load.
184- l.report(fmt.Sprintf(format, args...))91+func server(o Options) serverstart.Options {
92+ so := serverstart.Options{
93+ Host: o.Host, Port: o.Port, StateDir: o.StateDir, Timeout: o.Timeout,
94+ Report: o.Report, Wait: o.Wait,
185 }95 }
186-}96+ so.Server = serverstart.Server{
187-97+ Name: "llama-server",
188-func (o Options) say(format string, args ...any) {98+ Emoji: "🦙",
189- if o.Report != nil {99+ Command: func(dir string) (string, []string, error) { return command(o, dir) },
190- o.Report(fmt.Sprintf(format, args...))100+ Ready: func(ctx context.Context, so serverstart.Options, base string) error {
101+ return ensureModel(ctx, o, so, base)
102+ },
191 }103 }
192-}104+ return so
193-
194-func (o Options) wait(text string) func() {
195- if o.Wait == nil {
196- return func() {}
197- }
198- return o.Wait(text)
199-}
200-
201-// registryDir is <StateDir>/<host>-<port>, with its leases directory.
202-func registryDir(o Options) (string, error) {
203- root := o.StateDir
204- if root == "" {
205- cache, err := os.UserCacheDir()
206- if err != nil {
207- return "", err
208- }
209- root = filepath.Join(cache, "mm", "llama-server")
210- }
211- name := strings.NewReplacer(":", "_", "/", "_", "\\", "_").Replace(o.Host) + "-" + strconv.Itoa(o.Port)
212- dir := filepath.Join(root, name)
213- return dir, os.MkdirAll(filepath.Join(dir, "leases"), 0o755)
214-}
215-
216-// LogPath is where the server started for o writes its output.
217-func LogPath(o Options) string {
218- dir, err := registryDir(o)
219- if err != nil {
220- return ""
221- }
222- return filepath.Join(dir, "llama-server.log")
223 }105 }
224 106
225 // command is the binary and arguments that start a router on o's address,107 // command is the binary and arguments that start a router on o's address,
@@ -257,54 +139,6 @@ func command(o Options, dir string) (string, []string, error) {
257 return bin, append(args, o.Args...), nil139 return bin, append(args, o.Args...), nil
258 }140 }
259 141
260-// start launches the server detached from mm (its own process group, its
261-// output in the log file), records it and waits until /health answers.
262-func start(ctx context.Context, o Options, dir, base string) error {
263- bin, args, err := command(o, dir)
264- if err != nil {
265- return err
266- }
267- logPath := filepath.Join(dir, "llama-server.log")
268- logFile, err := os.Create(logPath)
269- if err != nil {
270- return err
271- }
272- cmd := exec.Command(bin, args...)
273- cmd.Stdout, cmd.Stderr = logFile, logFile
274- detach(cmd)
275- if err := cmd.Start(); err != nil {
276- _ = logFile.Close()
277- return fmt.Errorf("start %s: %w", bin, err)
278- }
279- _ = logFile.Close()
280- exited := make(chan error, 1)
281- go func() { exited <- cmd.Wait() }() // reaps it if it ends while mm runs
282- rec := record{PID: cmd.Process.Pid, Binary: bin, Args: args, Started: time.Now()}
283- if err := writeRecord(dir, rec); err != nil {
284- stop(rec.PID)
285- return err
286- }
287- o.say("🦙 starting llama-server on %s (pid %d, log %s)", hostPort(o.Host, o.Port), rec.PID, logPath)
288-
289- done := o.wait("Starting llama-server…")
290- defer done()
291- ctx, cancel := context.WithTimeout(ctx, o.Timeout)
292- defer cancel()
293- for !healthy(base) {
294- select {
295- case err := <-exited:
296- removeRecord(dir)
297- return fmt.Errorf("llama-server stopped at once (%v) — see %s", err, logPath)
298- case <-ctx.Done():
299- stop(rec.PID)
300- removeRecord(dir)
301- return fmt.Errorf("llama-server did not answer within %s — see %s", o.Timeout, logPath)
302- case <-time.After(poll):
303- }
304- }
305- return nil
306-}
307-
308 // routerModel is one entry of a router's GET /models.142 // routerModel is one entry of a router's GET /models.
309 type routerModel struct {143 type routerModel struct {
310 ID string `json:"id"`144 ID string `json:"id"`
@@ -317,7 +151,7 @@ type routerModel struct {
317 151
318 // ensureModel loads o.Model on the router at base and waits until it is152 // ensureModel loads o.Model on the router at base and waits until it is
319 // loaded — downloaded first when it is not in the cache.153 // loaded — downloaded first when it is not in the cache.
320-func ensureModel(ctx context.Context, o Options, base string) error {154+func ensureModel(ctx context.Context, o Options, so serverstart.Options, base string) error {
321 if o.Model == "" {155 if o.Model == "" {
322 return nil156 return nil
323 }157 }
@@ -330,9 +164,9 @@ func ensureModel(ctx context.Context, o Options, base string) error {
330 case m.Status.Value == "loaded":164 case m.Status.Value == "loaded":
331 return nil165 return nil
332 }166 }
333- done := o.wait("Loading " + o.Model + " (downloaded first when missing)…")167+ done := so.WaitFor("Loading " + o.Model + " (downloaded first when missing)…")
334 defer done()168 defer done()
335- ctx, cancel := context.WithTimeout(ctx, o.Timeout)169+ ctx, cancel := context.WithTimeout(ctx, so.Timeout)
336 defer cancel()170 defer cancel()
337 body := fmt.Sprintf(`{"model":%q}`, o.Model)171 body := fmt.Sprintf(`{"model":%q}`, o.Model)
338 req, err := http.NewRequestWithContext(ctx, http.MethodPost, base+"/models/load", strings.NewReader(body))172 req, err := http.NewRequestWithContext(ctx, http.MethodPost, base+"/models/load", strings.NewReader(body))
@@ -352,19 +186,19 @@ func ensureModel(ctx context.Context, o Options, base string) error {
352 m, _, err := findModel(ctx, base, o.Model)186 m, _, err := findModel(ctx, base, o.Model)
353 switch {187 switch {
354 case err != nil && ctx.Err() != nil:188 case err != nil && ctx.Err() != nil:
355- return fmt.Errorf("%s was not loaded within %s — see %s", o.Model, o.Timeout, LogPath(o))189+ return fmt.Errorf("%s was not loaded within %s — see %s", o.Model, so.Timeout, serverstart.LogPath(so))
356 case err != nil:190 case err != nil:
357 return err191 return err
358 case m.Status.Value == "loaded":192 case m.Status.Value == "loaded":
359- o.say("🦙 %s loaded", o.Model)193+ so.Say("%s loaded", o.Model)
360 return nil194 return nil
361 case m.Status.Failed:195 case m.Status.Failed:
362- return fmt.Errorf("llama-server could not load %s (exit code %d) — see %s", o.Model, m.Status.ExitCode, LogPath(o))196+ return fmt.Errorf("llama-server could not load %s (exit code %d) — see %s", o.Model, m.Status.ExitCode, serverstart.LogPath(so))
363 }197 }
364 select {198 select {
365 case <-ctx.Done():199 case <-ctx.Done():
366- return fmt.Errorf("%s was not loaded within %s — see %s", o.Model, o.Timeout, LogPath(o))200+ return fmt.Errorf("%s was not loaded within %s — see %s", o.Model, so.Timeout, serverstart.LogPath(so))
367- case <-time.After(poll):201+ case <-time.After(serverstart.Poll):
368 }202 }
369 }203 }
370 }204 }
@@ -392,102 +226,3 @@ func findModel(ctx context.Context, base, model string) (routerModel, bool, erro
392 }226 }
393 return routerModel{}, false, nil227 return routerModel{}, false, nil
394 }228 }
395-
396-var healthClient = &http.Client{Timeout: time.Second}
397-
398-func healthy(base string) bool {
399- resp, err := healthClient.Get(base + "/health")
400- if err != nil {
401- return false
402- }
403- _ = resp.Body.Close()
404- return resp.StatusCode == http.StatusOK
405-}
406-
407-func hostPort(host string, port int) string {
408- if strings.Contains(host, ":") {
409- host = "[" + host + "]"
410- }
411- return host + ":" + strconv.Itoa(port)
412-}
413-
414-// liveLeases counts the leases whose process still runs, removing the
415-// others (a crashed mm).
416-func liveLeases(dir string) int {
417- entries, _ := os.ReadDir(filepath.Join(dir, "leases"))
418- n := 0
419- for _, e := range entries {
420- pid, err := strconv.Atoi(e.Name())
421- if err == nil && alive(pid) {
422- n++
423- continue
424- }
425- _ = os.Remove(filepath.Join(dir, "leases", e.Name()))
426- }
427- return n
428-}
429-
430-func readRecord(dir string) *record {
431- data, err := os.ReadFile(filepath.Join(dir, "server.json"))
432- if err != nil {
433- return nil
434- }
435- var r record
436- if json.Unmarshal(data, &r) != nil || r.PID <= 0 {
437- return nil
438- }
439- return &r
440-}
441-
442-func writeRecord(dir string, r record) error {
443- data, err := json.MarshalIndent(r, "", " ")
444- if err != nil {
445- return err
446- }
447- return os.WriteFile(filepath.Join(dir, "server.json"), data, 0o644)
448-}
449-
450-func removeRecord(dir string) { _ = os.Remove(filepath.Join(dir, "server.json")) }
451-
452-// lock takes dir's lock file — created exclusively, holding our pid — and
453-// returns its release. A lock whose holder is gone, or older than
454-// lockStale, is taken over.
455-func lock(ctx context.Context, dir string) (func(), error) {
456- path := filepath.Join(dir, "lock")
457- ctx, cancel := context.WithTimeout(ctx, lockWait)
458- defer cancel()
459- for {
460- f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644)
461- if err == nil {
462- _, _ = f.WriteString(strconv.Itoa(os.Getpid()))
463- _ = f.Close()
464- return func() { _ = os.Remove(path) }, nil
465- }
466- if !errors.Is(err, os.ErrExist) {
467- return nil, err
468- }
469- if staleLock(path) {
470- _ = os.Remove(path)
471- continue
472- }
473- select {
474- case <-ctx.Done():
475- return nil, fmt.Errorf("another mm is starting llama-server (lock %s)", path)
476- case <-time.After(poll):
477- }
478- }
479-}
480-
481-func staleLock(path string) bool {
482- info, err := os.Stat(path)
483- if err != nil {
484- return false // gone meanwhile: retry
485- }
486- data, _ := os.ReadFile(path)
487- pid, err := strconv.Atoi(strings.TrimSpace(string(data)))
488- if err != nil {
489- // Being written right now, or garbage: only an old one is stale.
490- return time.Since(info.ModTime()) > lockStale
491- }
492- return !alive(pid) || time.Since(info.ModTime()) > lockStale
493-}
modified internal/llamastart/llamastart_test.go +12 -63
@@ -8,7 +8,6 @@ import (
88 "fmt"
99 "net"
1010 "net/http"
11- "net/http/httptest"
1211 "os"
1312 "os/exec"
1413 "path/filepath"
@@ -18,21 +17,21 @@ import (
1817 "sync"
1918 "testing"
2019 "time"
20+
21+ "mm/internal/serverstart"
2122 )
2223
2324 // The test binary is also the fake llama-server: started with
2425 // LLAMASTART_FAKE=1 it serves what a router answers (measured, see the
2526 // package comment) — /health, /models with the preset's models and their
2627 // status, /models/load that loads after a moment or fails for a model whose
27-// name holds "fail". LLAMASTART_FAKE=hang never answers.
28+// name holds "fail". The lifecycle itself (foreign server, timeout, stale
29+// lock) is tested in internal/serverstart.
2830 func TestMain(m *testing.M) {
2931 switch os.Getenv("LLAMASTART_FAKE") {
3032 case "1":
3133 fakeRouter()
3234 return
33- case "hang":
34- time.Sleep(time.Minute)
35- return
3635 }
3736 os.Exit(m.Run())
3837 }
@@ -117,16 +116,18 @@ func options(t *testing.T, model string) (Options, *[]string) {
117116 StateDir: t.TempDir(), Timeout: 10 * time.Second,
118117 Report: func(l string) { lines = append(lines, l) }}
119118 t.Cleanup(func() {
120- if dir, err := registryDir(o); err == nil {
121- if r := readRecord(dir); r != nil {
122- stop(r.PID)
119+ if pid := serverstart.RecordedPID(server(o)); pid > 0 {
120+ if p, err := os.FindProcess(pid); err == nil {
121+ _ = p.Kill() // the fake has no children
123122 }
124123 }
125124 })
126125 return o, &lines
127126 }
128127
129-func base(o Options) string { return "http://" + hostPort(o.Host, o.Port) }
128+func base(o Options) string { return serverstart.BaseURL(server(o)) }
129+
130+func healthy(base string) bool { return serverstart.Healthy(base) }
130131
131132 // otherSession is a live process standing for another mm: its lease keeps
132133 // the server running.
@@ -137,7 +138,7 @@ func otherSession(t *testing.T, o Options) *exec.Cmd {
137138 t.Fatal(err)
138139 }
139140 t.Cleanup(func() { _ = cmd.Process.Kill(); _ = cmd.Wait() })
140- dir, _ := registryDir(o)
141+ dir := filepath.Dir(LogPath(o))
141142 _ = os.WriteFile(filepath.Join(dir, "leases", strconv.Itoa(cmd.Process.Pid)), nil, 0o644)
142143 return cmd
143144 }
@@ -182,8 +183,7 @@ func TestAcquireStartsSharesAndStopsWithTheLastSession(t *testing.T) {
182183 if healthy(base(o)) {
183184 t.Fatal("the last release did not stop the server")
184185 }
185- dir, _ := registryDir(o)
186- if readRecord(dir) != nil {
186+ if serverstart.RecordedPID(server(o)) != 0 {
187187 t.Error("server.json left behind")
188188 }
189189 got := strings.Join(*lines, "\n")
@@ -194,23 +194,6 @@ func TestAcquireStartsSharesAndStopsWithTheLastSession(t *testing.T) {
194194 }
195195 }
196196
197-// A server mm did not start answers already: no lease, never stopped.
198-func TestAcquireLeavesAForeignServerAlone(t *testing.T) {
199- srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {}))
200- t.Cleanup(srv.Close)
201- addr := srv.Listener.Addr().(*net.TCPAddr)
202- l, err := Acquire(context.Background(), Options{Host: "127.0.0.1", Port: addr.Port, Model: "m", StateDir: t.TempDir()})
203- if l != nil || err != nil {
204- t.Fatalf("Acquire = %v, %v, want no lease and no error", l, err)
205- }
206- l.Release() // nil lease: nothing
207- if resp, err := http.Get(srv.URL + "/health"); err != nil {
208- t.Fatal("the foreign server was stopped")
209- } else {
210- _ = resp.Body.Close()
211- }
212-}
213-
214197 // A model the server cannot load is an error that names the log; the
215198 // lease is still returned, so the exit stops the server.
216199 func TestAcquireReportsAFailedLoad(t *testing.T) {
@@ -228,40 +211,6 @@ func TestAcquireReportsAFailedLoad(t *testing.T) {
228211 }
229212 }
230213
231-// A server that never answers is stopped after the timeout.
232-func TestAcquireTimesOut(t *testing.T) {
233- o, _ := options(t, "")
234- t.Setenv("LLAMASTART_FAKE", "hang")
235- o.Timeout = 500 * time.Millisecond
236- start := time.Now()
237- _, err := Acquire(context.Background(), o)
238- if err == nil || !strings.Contains(err.Error(), "did not answer within") {
239- t.Fatalf("err = %v, want a timeout", err)
240- }
241- if time.Since(start) > 8*time.Second {
242- t.Errorf("took %s", time.Since(start))
243- }
244- dir, _ := registryDir(o)
245- if readRecord(dir) != nil {
246- t.Error("server.json left behind")
247- }
248-}
249-
250-// A lock left by a process that is gone is taken over.
251-func TestStaleLockIsTakenOver(t *testing.T) {
252- dir := t.TempDir()
253- dead := exec.Command("true")
254- _ = dead.Run()
255- _ = os.WriteFile(filepath.Join(dir, "lock"), []byte(strconv.Itoa(dead.Process.Pid)), 0o644)
256- ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
257- defer cancel()
258- unlock, err := lock(ctx, dir)
259- if err != nil {
260- t.Fatalf("lock: %v", err)
261- }
262- unlock()
263-}
264-
265214 // The binary: llama-server first, else llama (as `llama serve`); a
266215 // configured path named llama gets `serve` too; none is ErrNotFound.
267216 func TestCommandFindsTheBinary(t *testing.T) {
@@ -8,7 +8,6 @@ import (
8 "fmt"8 "fmt"
9 "net"9 "net"
10 "net/http"10 "net/http"
11- "net/http/httptest"
12 "os"11 "os"
13 "os/exec"12 "os/exec"
14 "path/filepath"13 "path/filepath"
@@ -18,21 +17,21 @@ import (
18 "sync"17 "sync"
19 "testing"18 "testing"
20 "time"19 "time"
20+
21+ "mm/internal/serverstart"
21 )22 )
22 23
23 // The test binary is also the fake llama-server: started with24 // The test binary is also the fake llama-server: started with
24 // LLAMASTART_FAKE=1 it serves what a router answers (measured, see the25 // LLAMASTART_FAKE=1 it serves what a router answers (measured, see the
25 // package comment) — /health, /models with the preset's models and their26 // package comment) — /health, /models with the preset's models and their
26 // status, /models/load that loads after a moment or fails for a model whose27 // status, /models/load that loads after a moment or fails for a model whose
27-// name holds "fail". LLAMASTART_FAKE=hang never answers.28+// name holds "fail". The lifecycle itself (foreign server, timeout, stale
29+// lock) is tested in internal/serverstart.
28 func TestMain(m *testing.M) {30 func TestMain(m *testing.M) {
29 switch os.Getenv("LLAMASTART_FAKE") {31 switch os.Getenv("LLAMASTART_FAKE") {
30 case "1":32 case "1":
31 fakeRouter()33 fakeRouter()
32 return34 return
33- case "hang":
34- time.Sleep(time.Minute)
35- return
36 }35 }
37 os.Exit(m.Run())36 os.Exit(m.Run())
38 }37 }
@@ -117,16 +116,18 @@ func options(t *testing.T, model string) (Options, *[]string) {
117 StateDir: t.TempDir(), Timeout: 10 * time.Second,116 StateDir: t.TempDir(), Timeout: 10 * time.Second,
118 Report: func(l string) { lines = append(lines, l) }}117 Report: func(l string) { lines = append(lines, l) }}
119 t.Cleanup(func() {118 t.Cleanup(func() {
120- if dir, err := registryDir(o); err == nil {119+ if pid := serverstart.RecordedPID(server(o)); pid > 0 {
121- if r := readRecord(dir); r != nil {120+ if p, err := os.FindProcess(pid); err == nil {
122- stop(r.PID)121+ _ = p.Kill() // the fake has no children
123 }122 }
124 }123 }
125 })124 })
126 return o, &lines125 return o, &lines
127 }126 }
128 127
129-func base(o Options) string { return "http://" + hostPort(o.Host, o.Port) }128+func base(o Options) string { return serverstart.BaseURL(server(o)) }
129+
130+func healthy(base string) bool { return serverstart.Healthy(base) }
130 131
131 // otherSession is a live process standing for another mm: its lease keeps132 // otherSession is a live process standing for another mm: its lease keeps
132 // the server running.133 // the server running.
@@ -137,7 +138,7 @@ func otherSession(t *testing.T, o Options) *exec.Cmd {
137 t.Fatal(err)138 t.Fatal(err)
138 }139 }
139 t.Cleanup(func() { _ = cmd.Process.Kill(); _ = cmd.Wait() })140 t.Cleanup(func() { _ = cmd.Process.Kill(); _ = cmd.Wait() })
140- dir, _ := registryDir(o)141+ dir := filepath.Dir(LogPath(o))
141 _ = os.WriteFile(filepath.Join(dir, "leases", strconv.Itoa(cmd.Process.Pid)), nil, 0o644)142 _ = os.WriteFile(filepath.Join(dir, "leases", strconv.Itoa(cmd.Process.Pid)), nil, 0o644)
142 return cmd143 return cmd
143 }144 }
@@ -182,8 +183,7 @@ func TestAcquireStartsSharesAndStopsWithTheLastSession(t *testing.T) {
182 if healthy(base(o)) {183 if healthy(base(o)) {
183 t.Fatal("the last release did not stop the server")184 t.Fatal("the last release did not stop the server")
184 }185 }
185- dir, _ := registryDir(o)186+ if serverstart.RecordedPID(server(o)) != 0 {
186- if readRecord(dir) != nil {
187 t.Error("server.json left behind")187 t.Error("server.json left behind")
188 }188 }
189 got := strings.Join(*lines, "\n")189 got := strings.Join(*lines, "\n")
@@ -194,23 +194,6 @@ func TestAcquireStartsSharesAndStopsWithTheLastSession(t *testing.T) {
194 }194 }
195 }195 }
196 196
197-// A server mm did not start answers already: no lease, never stopped.
198-func TestAcquireLeavesAForeignServerAlone(t *testing.T) {
199- srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {}))
200- t.Cleanup(srv.Close)
201- addr := srv.Listener.Addr().(*net.TCPAddr)
202- l, err := Acquire(context.Background(), Options{Host: "127.0.0.1", Port: addr.Port, Model: "m", StateDir: t.TempDir()})
203- if l != nil || err != nil {
204- t.Fatalf("Acquire = %v, %v, want no lease and no error", l, err)
205- }
206- l.Release() // nil lease: nothing
207- if resp, err := http.Get(srv.URL + "/health"); err != nil {
208- t.Fatal("the foreign server was stopped")
209- } else {
210- _ = resp.Body.Close()
211- }
212-}
213-
214 // A model the server cannot load is an error that names the log; the197 // A model the server cannot load is an error that names the log; the
215 // lease is still returned, so the exit stops the server.198 // lease is still returned, so the exit stops the server.
216 func TestAcquireReportsAFailedLoad(t *testing.T) {199 func TestAcquireReportsAFailedLoad(t *testing.T) {
@@ -228,40 +211,6 @@ func TestAcquireReportsAFailedLoad(t *testing.T) {
228 }211 }
229 }212 }
230 213
231-// A server that never answers is stopped after the timeout.
232-func TestAcquireTimesOut(t *testing.T) {
233- o, _ := options(t, "")
234- t.Setenv("LLAMASTART_FAKE", "hang")
235- o.Timeout = 500 * time.Millisecond
236- start := time.Now()
237- _, err := Acquire(context.Background(), o)
238- if err == nil || !strings.Contains(err.Error(), "did not answer within") {
239- t.Fatalf("err = %v, want a timeout", err)
240- }
241- if time.Since(start) > 8*time.Second {
242- t.Errorf("took %s", time.Since(start))
243- }
244- dir, _ := registryDir(o)
245- if readRecord(dir) != nil {
246- t.Error("server.json left behind")
247- }
248-}
249-
250-// A lock left by a process that is gone is taken over.
251-func TestStaleLockIsTakenOver(t *testing.T) {
252- dir := t.TempDir()
253- dead := exec.Command("true")
254- _ = dead.Run()
255- _ = os.WriteFile(filepath.Join(dir, "lock"), []byte(strconv.Itoa(dead.Process.Pid)), 0o644)
256- ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
257- defer cancel()
258- unlock, err := lock(ctx, dir)
259- if err != nil {
260- t.Fatalf("lock: %v", err)
261- }
262- unlock()
263-}
264-
265 // The binary: llama-server first, else llama (as `llama serve`); a214 // The binary: llama-server first, else llama (as `llama serve`); a
266 // configured path named llama gets `serve` too; none is ErrNotFound.215 // configured path named llama gets `serve` too; none is ErrNotFound.
267 func TestCommandFindsTheBinary(t *testing.T) {216 func TestCommandFindsTheBinary(t *testing.T) {
added internal/rzbstart/rzbstart.go +235 -0
new file mode 100644
@@ -0,0 +1,235 @@
1+// Package rzbstart starts razorbill (`rzb serve`, an MLX model server for
2+// Apple Silicon Macs) for a razorbill agent when nothing answers at its
3+// address, and stops it with the last mm session that uses it (ticket 264,
4+// config `razorbill.autoStart`). The lifetime — registry under
5+// <cache>/mm/rzb/, leases, lock, a server mm did not start never stopped —
6+// is internal/serverstart's.
7+//
8+// What rzb 0.2.0 does that matters here (its CLI and HTTP API references,
9+// checked on the user's server 2026-11-26):
10+//
11+// - `rzb serve --host H --port P [--config F]` listens until SIGTERM, then
12+// unloads its models and exits 0; GET /health answers without a key;
13+// - GET /v1/models lists the declared models and every loadable model of
14+// the Hugging Face cache; a Hugging Face id that is not there is
15+// downloaded by the first request naming it — which mm's watchdog may
16+// not wait for, so a missing model is pulled first with
17+// `rzb models pull <id>` (progress bar on its output, our log);
18+// - with RZB_API_KEY set (inherited by the server mm starts), every route
19+// but /health wants `Authorization: Bearer <key>`.
20+//
21+// rzb runs on macOS only: Acquire refuses to start anything elsewhere — in
22+// particular when mm runs in a container or a sandbox, where the user
23+// starts rzb on the Mac with --host 0.0.0.0 instead.
24+package rzbstart
25+
26+import (
27+ "context"
28+ "encoding/json"
29+ "errors"
30+ "fmt"
31+ "net/http"
32+ "os"
33+ "os/exec"
34+ "runtime"
35+ "strconv"
36+ "strings"
37+ "time"
38+
39+ "mm/internal/serverstart"
40+)
41+
42+// Options says which server to start and how to talk about it.
43+type Options struct {
44+ // Binary is the rzb executable; "" = rzb on the PATH, then
45+ // /usr/local/bin/rzb.
46+ Binary string
47+ // ConfigFile is passed as `--config` when not empty.
48+ ConfigFile string
49+ // Args are added after mm's own arguments (razorbill.serverArgs).
50+ Args []string
51+ // Host and Port are where the server listens: the agent's address.
52+ Host string
53+ Port int
54+ // Model is the agent's model, downloaded before Acquire returns when
55+ // the server does not list it.
56+ Model string
57+ // APIKey is sent to /v1/models when the server checks one.
58+ APIKey string
59+ // StateDir holds the registries; "" = <user cache dir>/mm/rzb.
60+ StateDir string
61+ // Timeout bounds the start and the model's download.
62+ Timeout time.Duration
63+ // Report receives one line per step worth showing; nil = quiet.
64+ Report func(line string)
65+ // Wait shows that mm is waiting (a spinner) until the returned function
66+ // is called; nil = nothing shown.
67+ Wait func(text string) (stop func())
68+}
69+
70+// Lease is this process's use of a server mm started. Release it on exit.
71+type Lease = serverstart.Lease
72+
73+// ErrNotFound: no rzb binary to start.
74+var ErrNotFound = errors.New("rzb not found on the PATH nor in /usr/local/bin — build and install razorbill on the Mac (scripts/install.sh) or set razorbill.server to its path")
75+
76+// goos and installed are variables so the tests can play a Mac and an
77+// install directory.
78+var (
79+ goos = runtime.GOOS
80+ installed = "/usr/local/bin/rzb"
81+)
82+
83+// Acquire makes sure rzb answers at o.Host:o.Port with o.Model downloaded,
84+// starting it when nothing answers, and returns this process's lease on it
85+// — nil, with no error, when a server mm did not start already answers.
86+// Off macOS it starts nothing and says why.
87+//
88+// lease, err := rzbstart.Acquire(ctx, rzbstart.Options{Host: "127.0.0.1", Port: 7920, Model: "mlx-community/Qwen3-4B-4bit"})
89+// defer lease.Release()
90+func Acquire(ctx context.Context, o Options) (*Lease, error) {
91+ if goos != "darwin" {
92+ return nil, fmt.Errorf("rzb runs on macOS only, and mm runs on %s: nothing started — in a container or a sandbox, start rzb on the Mac with `rzb serve --host 0.0.0.0` (and RZB_API_KEY), mm then reaches it at host.docker.internal:%d", goos, o.Port)
93+ }
94+ return serverstart.Acquire(ctx, server(o))
95+}
96+
97+// LogPath is where the server started for o writes its output.
98+func LogPath(o Options) string { return serverstart.LogPath(server(o)) }
99+
100+// server is o in serverstart's terms.
101+func server(o Options) serverstart.Options {
102+ so := serverstart.Options{
103+ Host: o.Host, Port: o.Port, StateDir: o.StateDir, Timeout: o.Timeout,
104+ Report: o.Report, Wait: o.Wait,
105+ }
106+ so.Server = serverstart.Server{
107+ Name: "rzb",
108+ Emoji: "🐧",
109+ Command: func(string) (string, []string, error) { return command(o) },
110+ Ready: func(ctx context.Context, so serverstart.Options, base string) error {
111+ return ensureModel(ctx, o, so, base)
112+ },
113+ }
114+ return so
115+}
116+
117+// binary is the rzb to run: o.Binary, else rzb on the PATH, else the one
118+// razorbill's install script puts in /usr/local/bin (an editor that starts
119+// mm may not have it on its PATH).
120+func binary(o Options) (string, error) {
121+ if o.Binary != "" {
122+ p, err := exec.LookPath(o.Binary)
123+ if err != nil {
124+ return "", fmt.Errorf("razorbill.server %q: %w", o.Binary, err)
125+ }
126+ return p, nil
127+ }
128+ if p, err := exec.LookPath("rzb"); err == nil {
129+ return p, nil
130+ }
131+ if info, err := os.Stat(installed); err == nil && !info.IsDir() {
132+ return installed, nil
133+ }
134+ return "", ErrNotFound
135+}
136+
137+// command is `rzb serve` on o's address, with its configuration file.
138+func command(o Options) (string, []string, error) {
139+ bin, err := binary(o)
140+ if err != nil {
141+ return "", nil, err
142+ }
143+ args := []string{"serve", "--host", o.Host, "--port", strconv.Itoa(o.Port)}
144+ if o.ConfigFile != "" {
145+ if _, err := os.Stat(o.ConfigFile); err != nil {
146+ return "", nil, fmt.Errorf("razorbill.config: %w", err)
147+ }
148+ args = append(args, "--config", o.ConfigFile)
149+ }
150+ return bin, append(args, o.Args...), nil
151+}
152+
153+// ensureModel pulls o.Model with `rzb models pull` when the server at base
154+// does not list it. A listed model — declared or in the cache — is loaded
155+// by rzb on the first question, which is quick.
156+func ensureModel(ctx context.Context, o Options, so serverstart.Options, base string) error {
157+ if o.Model == "" {
158+ return nil
159+ }
160+ listed, err := lists(ctx, base, o)
161+ if err != nil {
162+ return err
163+ }
164+ if listed {
165+ return nil
166+ }
167+ if !strings.Contains(o.Model, "/") {
168+ return fmt.Errorf("rzb does not know the model %q: it is neither declared in its configuration (razorbill.config) nor a Hugging Face id (org/name)", o.Model)
169+ }
170+ return pull(ctx, o, so)
171+}
172+
173+// pull runs `rzb models pull <model>`, its output appended to the
174+// server's log, bounded by the timeout.
175+func pull(ctx context.Context, o Options, so serverstart.Options) error {
176+ bin, err := binary(o)
177+ if err != nil {
178+ return err
179+ }
180+ logPath := serverstart.LogPath(so)
181+ logFile, err := os.OpenFile(logPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
182+ if err != nil {
183+ return err
184+ }
185+ defer func() { _ = logFile.Close() }()
186+
187+ so.Say("downloading %s (rzb models pull, log %s)", o.Model, logPath)
188+ done := so.WaitFor("Downloading " + o.Model + "…")
189+ defer done()
190+ ctx, cancel := context.WithTimeout(ctx, so.Timeout)
191+ defer cancel()
192+ cmd := exec.CommandContext(ctx, bin, "models", "pull", o.Model)
193+ cmd.Stdout, cmd.Stderr = logFile, logFile
194+ if err := cmd.Run(); err != nil {
195+ if ctx.Err() == context.DeadlineExceeded {
196+ return fmt.Errorf("%s was not downloaded within %s — see %s", o.Model, so.Timeout, logPath)
197+ }
198+ return fmt.Errorf("rzb models pull %s failed (%v) — see %s", o.Model, err, logPath)
199+ }
200+ so.Say("%s downloaded", o.Model)
201+ return nil
202+}
203+
204+// lists reports whether GET <base>/v1/models names o.Model.
205+func lists(ctx context.Context, base string, o Options) (bool, error) {
206+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, base+"/v1/models", nil)
207+ if err != nil {
208+ return false, err
209+ }
210+ if o.APIKey != "" {
211+ req.Header.Set("Authorization", "Bearer "+o.APIKey)
212+ }
213+ resp, err := http.DefaultClient.Do(req)
214+ if err != nil {
215+ return false, err
216+ }
217+ defer func() { _ = resp.Body.Close() }()
218+ if resp.StatusCode != http.StatusOK {
219+ return false, fmt.Errorf("rzb: GET /v1/models answered %d (is RZB_API_KEY the server's key?)", resp.StatusCode)
220+ }
221+ var list struct {
222+ Data []struct {
223+ ID string `json:"id"`
224+ } `json:"data"`
225+ }
226+ if err := json.NewDecoder(resp.Body).Decode(&list); err != nil {
227+ return false, fmt.Errorf("GET /v1/models: %w", err)
228+ }
229+ for _, m := range list.Data {
230+ if m.ID == o.Model {
231+ return true, nil
232+ }
233+ }
234+ return false, nil
235+}
new file mode 100644
@@ -0,0 +1,235 @@
1+// Package rzbstart starts razorbill (`rzb serve`, an MLX model server for
2+// Apple Silicon Macs) for a razorbill agent when nothing answers at its
3+// address, and stops it with the last mm session that uses it (ticket 264,
4+// config `razorbill.autoStart`). The lifetime — registry under
5+// <cache>/mm/rzb/, leases, lock, a server mm did not start never stopped —
6+// is internal/serverstart's.
7+//
8+// What rzb 0.2.0 does that matters here (its CLI and HTTP API references,
9+// checked on the user's server 2026-11-26):
10+//
11+// - `rzb serve --host H --port P [--config F]` listens until SIGTERM, then
12+// unloads its models and exits 0; GET /health answers without a key;
13+// - GET /v1/models lists the declared models and every loadable model of
14+// the Hugging Face cache; a Hugging Face id that is not there is
15+// downloaded by the first request naming it — which mm's watchdog may
16+// not wait for, so a missing model is pulled first with
17+// `rzb models pull <id>` (progress bar on its output, our log);
18+// - with RZB_API_KEY set (inherited by the server mm starts), every route
19+// but /health wants `Authorization: Bearer <key>`.
20+//
21+// rzb runs on macOS only: Acquire refuses to start anything elsewhere — in
22+// particular when mm runs in a container or a sandbox, where the user
23+// starts rzb on the Mac with --host 0.0.0.0 instead.
24+package rzbstart
25+
26+import (
27+ "context"
28+ "encoding/json"
29+ "errors"
30+ "fmt"
31+ "net/http"
32+ "os"
33+ "os/exec"
34+ "runtime"
35+ "strconv"
36+ "strings"
37+ "time"
38+
39+ "mm/internal/serverstart"
40+)
41+
42+// Options says which server to start and how to talk about it.
43+type Options struct {
44+ // Binary is the rzb executable; "" = rzb on the PATH, then
45+ // /usr/local/bin/rzb.
46+ Binary string
47+ // ConfigFile is passed as `--config` when not empty.
48+ ConfigFile string
49+ // Args are added after mm's own arguments (razorbill.serverArgs).
50+ Args []string
51+ // Host and Port are where the server listens: the agent's address.
52+ Host string
53+ Port int
54+ // Model is the agent's model, downloaded before Acquire returns when
55+ // the server does not list it.
56+ Model string
57+ // APIKey is sent to /v1/models when the server checks one.
58+ APIKey string
59+ // StateDir holds the registries; "" = <user cache dir>/mm/rzb.
60+ StateDir string
61+ // Timeout bounds the start and the model's download.
62+ Timeout time.Duration
63+ // Report receives one line per step worth showing; nil = quiet.
64+ Report func(line string)
65+ // Wait shows that mm is waiting (a spinner) until the returned function
66+ // is called; nil = nothing shown.
67+ Wait func(text string) (stop func())
68+}
69+
70+// Lease is this process's use of a server mm started. Release it on exit.
71+type Lease = serverstart.Lease
72+
73+// ErrNotFound: no rzb binary to start.
74+var ErrNotFound = errors.New("rzb not found on the PATH nor in /usr/local/bin — build and install razorbill on the Mac (scripts/install.sh) or set razorbill.server to its path")
75+
76+// goos and installed are variables so the tests can play a Mac and an
77+// install directory.
78+var (
79+ goos = runtime.GOOS
80+ installed = "/usr/local/bin/rzb"
81+)
82+
83+// Acquire makes sure rzb answers at o.Host:o.Port with o.Model downloaded,
84+// starting it when nothing answers, and returns this process's lease on it
85+// — nil, with no error, when a server mm did not start already answers.
86+// Off macOS it starts nothing and says why.
87+//
88+// lease, err := rzbstart.Acquire(ctx, rzbstart.Options{Host: "127.0.0.1", Port: 7920, Model: "mlx-community/Qwen3-4B-4bit"})
89+// defer lease.Release()
90+func Acquire(ctx context.Context, o Options) (*Lease, error) {
91+ if goos != "darwin" {
92+ return nil, fmt.Errorf("rzb runs on macOS only, and mm runs on %s: nothing started — in a container or a sandbox, start rzb on the Mac with `rzb serve --host 0.0.0.0` (and RZB_API_KEY), mm then reaches it at host.docker.internal:%d", goos, o.Port)
93+ }
94+ return serverstart.Acquire(ctx, server(o))
95+}
96+
97+// LogPath is where the server started for o writes its output.
98+func LogPath(o Options) string { return serverstart.LogPath(server(o)) }
99+
100+// server is o in serverstart's terms.
101+func server(o Options) serverstart.Options {
102+ so := serverstart.Options{
103+ Host: o.Host, Port: o.Port, StateDir: o.StateDir, Timeout: o.Timeout,
104+ Report: o.Report, Wait: o.Wait,
105+ }
106+ so.Server = serverstart.Server{
107+ Name: "rzb",
108+ Emoji: "🐧",
109+ Command: func(string) (string, []string, error) { return command(o) },
110+ Ready: func(ctx context.Context, so serverstart.Options, base string) error {
111+ return ensureModel(ctx, o, so, base)
112+ },
113+ }
114+ return so
115+}
116+
117+// binary is the rzb to run: o.Binary, else rzb on the PATH, else the one
118+// razorbill's install script puts in /usr/local/bin (an editor that starts
119+// mm may not have it on its PATH).
120+func binary(o Options) (string, error) {
121+ if o.Binary != "" {
122+ p, err := exec.LookPath(o.Binary)
123+ if err != nil {
124+ return "", fmt.Errorf("razorbill.server %q: %w", o.Binary, err)
125+ }
126+ return p, nil
127+ }
128+ if p, err := exec.LookPath("rzb"); err == nil {
129+ return p, nil
130+ }
131+ if info, err := os.Stat(installed); err == nil && !info.IsDir() {
132+ return installed, nil
133+ }
134+ return "", ErrNotFound
135+}
136+
137+// command is `rzb serve` on o's address, with its configuration file.
138+func command(o Options) (string, []string, error) {
139+ bin, err := binary(o)
140+ if err != nil {
141+ return "", nil, err
142+ }
143+ args := []string{"serve", "--host", o.Host, "--port", strconv.Itoa(o.Port)}
144+ if o.ConfigFile != "" {
145+ if _, err := os.Stat(o.ConfigFile); err != nil {
146+ return "", nil, fmt.Errorf("razorbill.config: %w", err)
147+ }
148+ args = append(args, "--config", o.ConfigFile)
149+ }
150+ return bin, append(args, o.Args...), nil
151+}
152+
153+// ensureModel pulls o.Model with `rzb models pull` when the server at base
154+// does not list it. A listed model — declared or in the cache — is loaded
155+// by rzb on the first question, which is quick.
156+func ensureModel(ctx context.Context, o Options, so serverstart.Options, base string) error {
157+ if o.Model == "" {
158+ return nil
159+ }
160+ listed, err := lists(ctx, base, o)
161+ if err != nil {
162+ return err
163+ }
164+ if listed {
165+ return nil
166+ }
167+ if !strings.Contains(o.Model, "/") {
168+ return fmt.Errorf("rzb does not know the model %q: it is neither declared in its configuration (razorbill.config) nor a Hugging Face id (org/name)", o.Model)
169+ }
170+ return pull(ctx, o, so)
171+}
172+
173+// pull runs `rzb models pull <model>`, its output appended to the
174+// server's log, bounded by the timeout.
175+func pull(ctx context.Context, o Options, so serverstart.Options) error {
176+ bin, err := binary(o)
177+ if err != nil {
178+ return err
179+ }
180+ logPath := serverstart.LogPath(so)
181+ logFile, err := os.OpenFile(logPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
182+ if err != nil {
183+ return err
184+ }
185+ defer func() { _ = logFile.Close() }()
186+
187+ so.Say("downloading %s (rzb models pull, log %s)", o.Model, logPath)
188+ done := so.WaitFor("Downloading " + o.Model + "…")
189+ defer done()
190+ ctx, cancel := context.WithTimeout(ctx, so.Timeout)
191+ defer cancel()
192+ cmd := exec.CommandContext(ctx, bin, "models", "pull", o.Model)
193+ cmd.Stdout, cmd.Stderr = logFile, logFile
194+ if err := cmd.Run(); err != nil {
195+ if ctx.Err() == context.DeadlineExceeded {
196+ return fmt.Errorf("%s was not downloaded within %s — see %s", o.Model, so.Timeout, logPath)
197+ }
198+ return fmt.Errorf("rzb models pull %s failed (%v) — see %s", o.Model, err, logPath)
199+ }
200+ so.Say("%s downloaded", o.Model)
201+ return nil
202+}
203+
204+// lists reports whether GET <base>/v1/models names o.Model.
205+func lists(ctx context.Context, base string, o Options) (bool, error) {
206+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, base+"/v1/models", nil)
207+ if err != nil {
208+ return false, err
209+ }
210+ if o.APIKey != "" {
211+ req.Header.Set("Authorization", "Bearer "+o.APIKey)
212+ }
213+ resp, err := http.DefaultClient.Do(req)
214+ if err != nil {
215+ return false, err
216+ }
217+ defer func() { _ = resp.Body.Close() }()
218+ if resp.StatusCode != http.StatusOK {
219+ return false, fmt.Errorf("rzb: GET /v1/models answered %d (is RZB_API_KEY the server's key?)", resp.StatusCode)
220+ }
221+ var list struct {
222+ Data []struct {
223+ ID string `json:"id"`
224+ } `json:"data"`
225+ }
226+ if err := json.NewDecoder(resp.Body).Decode(&list); err != nil {
227+ return false, fmt.Errorf("GET /v1/models: %w", err)
228+ }
229+ for _, m := range list.Data {
230+ if m.ID == o.Model {
231+ return true, nil
232+ }
233+ }
234+ return false, nil
235+}
added internal/rzbstart/rzbstart_test.go +238 -0
new file mode 100644
@@ -0,0 +1,238 @@
1+package rzbstart
2+
3+import (
4+ "context"
5+ "encoding/json"
6+ "flag"
7+ "net"
8+ "net/http"
9+ "os"
10+ "path/filepath"
11+ "runtime"
12+ "strconv"
13+ "strings"
14+ "testing"
15+ "time"
16+
17+ "mm/internal/serverstart"
18+)
19+
20+// The test binary is also the fake rzb (RZB_FAKE_CACHE set): `serve`
21+// answers /health and a /v1/models that lists the cache — one model id per
22+// line of the file RZB_FAKE_CACHE — and wants RZB_API_KEY when it is set;
23+// `models pull <id>` appends id to the cache, or fails for an id holding
24+// "fail".
25+func TestMain(m *testing.M) {
26+ cache := os.Getenv("RZB_FAKE_CACHE")
27+ if cache == "" {
28+ os.Exit(m.Run())
29+ }
30+ args := os.Args[1:]
31+ switch {
32+ case len(args) >= 3 && args[0] == "models" && args[1] == "pull":
33+ if strings.Contains(args[2], "fail") {
34+ os.Exit(1)
35+ }
36+ f, _ := os.OpenFile(cache, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
37+ _, _ = f.WriteString(args[2] + "\n")
38+ _ = f.Close()
39+ case len(args) >= 1 && args[0] == "serve":
40+ fakeServe(cache, args[1:])
41+ default:
42+ os.Exit(2)
43+ }
44+}
45+
46+func fakeServe(cache string, args []string) {
47+ fs := flag.NewFlagSet("serve", flag.ExitOnError)
48+ host := fs.String("host", "127.0.0.1", "")
49+ port := fs.Int("port", 7920, "")
50+ _ = fs.String("config", "", "")
51+ _ = fs.Parse(args)
52+ key := os.Getenv("RZB_API_KEY")
53+ mux := http.NewServeMux()
54+ mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"status":"ok"}`)) })
55+ mux.HandleFunc("/v1/models", func(w http.ResponseWriter, r *http.Request) {
56+ if key != "" && r.Header.Get("Authorization") != "Bearer "+key {
57+ w.WriteHeader(http.StatusUnauthorized)
58+ return
59+ }
60+ data, _ := os.ReadFile(cache)
61+ var list []map[string]any
62+ for _, id := range strings.Fields(string(data)) {
63+ list = append(list, map[string]any{"id": id, "object": "model", "loaded": false, "kind": "chat"})
64+ }
65+ _ = json.NewEncoder(w).Encode(map[string]any{"object": "list", "data": list})
66+ })
67+ _ = http.ListenAndServe(net.JoinHostPort(*host, strconv.Itoa(*port)), mux)
68+}
69+
70+func freePort(t *testing.T) int {
71+ t.Helper()
72+ l, err := net.Listen("tcp", "127.0.0.1:0")
73+ if err != nil {
74+ t.Fatal(err)
75+ }
76+ defer func() { _ = l.Close() }()
77+ return l.Addr().(*net.TCPAddr).Port
78+}
79+
80+// options for the fake rzb on a free port, as on a Mac; cache holds the
81+// models it starts with.
82+func options(t *testing.T, model string, cache ...string) (Options, *[]string, string) {
83+ t.Helper()
84+ if runtime.GOOS == "windows" {
85+ t.Skip("the fake server relies on process groups and signals")
86+ }
87+ old := goos
88+ goos = "darwin"
89+ t.Cleanup(func() { goos = old })
90+ cacheFile := filepath.Join(t.TempDir(), "cache")
91+ _ = os.WriteFile(cacheFile, []byte(strings.Join(cache, "\n")+"\n"), 0o644)
92+ t.Setenv("RZB_FAKE_CACHE", cacheFile)
93+ t.Setenv("RZB_API_KEY", "")
94+ self, err := os.Executable()
95+ if err != nil {
96+ t.Fatal(err)
97+ }
98+ var lines []string
99+ o := Options{Binary: self, Host: "127.0.0.1", Port: freePort(t), Model: model,
100+ StateDir: t.TempDir(), Timeout: 10 * time.Second,
101+ Report: func(l string) { lines = append(lines, l) }}
102+ t.Cleanup(func() {
103+ if pid := serverstart.RecordedPID(server(o)); pid > 0 {
104+ if p, err := os.FindProcess(pid); err == nil {
105+ _ = p.Kill()
106+ }
107+ }
108+ })
109+ return o, &lines, cacheFile
110+}
111+
112+func base(o Options) string { return serverstart.BaseURL(server(o)) }
113+
114+// A model in the cache: rzb is started, nothing is pulled, the release
115+// stops it.
116+func TestAcquireStartsRzbWithACachedModel(t *testing.T) {
117+ o, lines, _ := options(t, "mlx-community/Qwen3-0.6B-4bit", "mlx-community/Qwen3-0.6B-4bit")
118+ l, err := Acquire(context.Background(), o)
119+ if err != nil || l == nil {
120+ t.Fatalf("Acquire: %v, %v", l, err)
121+ }
122+ if !serverstart.Healthy(base(o)) {
123+ t.Fatal("rzb does not answer after Acquire")
124+ }
125+ got := strings.Join(*lines, "\n")
126+ if !strings.Contains(got, "🐧 starting rzb") || strings.Contains(got, "downloading") {
127+ t.Errorf("report:\n%s", got)
128+ }
129+ l.Release()
130+ if serverstart.Healthy(base(o)) {
131+ t.Error("rzb still runs after the last release")
132+ }
133+}
134+
135+// A model rzb does not list is pulled before Acquire returns, with the
136+// server's key.
137+func TestAcquirePullsAMissingModel(t *testing.T) {
138+ o, lines, cache := options(t, "mlx-community/Qwen3-4B-4bit")
139+ t.Setenv("RZB_API_KEY", "secret")
140+ o.APIKey = "secret"
141+ l, err := Acquire(context.Background(), o)
142+ defer l.Release()
143+ if err != nil {
144+ t.Fatalf("Acquire: %v\n%s", err, strings.Join(*lines, "\n"))
145+ }
146+ data, _ := os.ReadFile(cache)
147+ if !strings.Contains(string(data), "mlx-community/Qwen3-4B-4bit") {
148+ t.Errorf("not pulled; cache:\n%s", data)
149+ }
150+ got := strings.Join(*lines, "\n")
151+ if !strings.Contains(got, "🐧 downloading mlx-community/Qwen3-4B-4bit") || !strings.Contains(got, "🐧 mlx-community/Qwen3-4B-4bit downloaded") {
152+ t.Errorf("report:\n%s", got)
153+ }
154+}
155+
156+// A failed pull is an error naming the log; the lease comes back so the
157+// exit stops the server.
158+func TestAcquireReportsAFailedPull(t *testing.T) {
159+ o, _, _ := options(t, "org/fail-4bit")
160+ l, err := Acquire(context.Background(), o)
161+ if err == nil || !strings.Contains(err.Error(), "rzb models pull org/fail-4bit failed") || !strings.Contains(err.Error(), "rzb.log") {
162+ t.Fatalf("err = %v, want a pull failure naming the log", err)
163+ }
164+ if l == nil {
165+ t.Fatal("no lease: the server would never be stopped")
166+ }
167+ l.Release()
168+}
169+
170+// A short name rzb does not list cannot be pulled: it is not a Hugging
171+// Face id.
172+func TestAcquireRefusesAnUnknownShortName(t *testing.T) {
173+ o, _, _ := options(t, "qwen3")
174+ l, err := Acquire(context.Background(), o)
175+ defer l.Release()
176+ if err == nil || !strings.Contains(err.Error(), "neither declared") {
177+ t.Fatalf("err = %v, want an unknown-model error", err)
178+ }
179+}
180+
181+// Off macOS nothing is started, and the message says what to do from a
182+// container or a sandbox.
183+func TestAcquireRefusesOffMacOS(t *testing.T) {
184+ old := goos
185+ goos = "linux"
186+ t.Cleanup(func() { goos = old })
187+ l, err := Acquire(context.Background(), Options{Host: "127.0.0.1", Port: 7920, StateDir: t.TempDir()})
188+ if l != nil || err == nil || !strings.Contains(err.Error(), "macOS only") || !strings.Contains(err.Error(), "--host 0.0.0.0") {
189+ t.Fatalf("Acquire = %v, %v, want a macOS-only error", l, err)
190+ }
191+}
192+
193+// The command: rzb serve on the address, the config file, then the extra
194+// arguments; a missing config file is an error naming the key.
195+func TestCommand(t *testing.T) {
196+ cfg := filepath.Join(t.TempDir(), "server.yaml")
197+ _ = os.WriteFile(cfg, []byte("models: []\n"), 0o644)
198+ self, _ := os.Executable()
199+ o := Options{Binary: self, Host: "127.0.0.1", Port: 7920, ConfigFile: cfg, Args: []string{"--cors-origin", "*"}}
200+ bin, args, err := command(o)
201+ want := "serve --host 127.0.0.1 --port 7920 --config " + cfg + " --cors-origin *"
202+ if err != nil || bin != self || strings.Join(args, " ") != want {
203+ t.Errorf("command = %s %v (%v), want %s", bin, args, err, want)
204+ }
205+ o.ConfigFile = filepath.Join(t.TempDir(), "missing.yaml")
206+ if _, _, err := command(o); err == nil || !strings.Contains(err.Error(), "razorbill.config") {
207+ t.Errorf("missing config: %v", err)
208+ }
209+}
210+
211+// The binary: the configured one, else rzb on the PATH, else
212+// /usr/local/bin/rzb; none is ErrNotFound.
213+func TestBinary(t *testing.T) {
214+ if runtime.GOOS == "windows" {
215+ t.Skip("shell scripts as fake binaries")
216+ }
217+ dir := t.TempDir()
218+ t.Setenv("PATH", dir)
219+ old := installed
220+ t.Cleanup(func() { installed = old })
221+ installed = filepath.Join(t.TempDir(), "rzb")
222+
223+ if _, err := binary(Options{}); err != ErrNotFound {
224+ t.Errorf("nothing: %v, want ErrNotFound", err)
225+ }
226+ _ = os.WriteFile(installed, []byte("#!/bin/sh\n"), 0o755)
227+ if got, _ := binary(Options{}); got != installed {
228+ t.Errorf("installed only: %s", got)
229+ }
230+ onPath := filepath.Join(dir, "rzb")
231+ _ = os.WriteFile(onPath, []byte("#!/bin/sh\n"), 0o755)
232+ if got, _ := binary(Options{}); got != onPath {
233+ t.Errorf("on PATH: %s, want %s", got, onPath)
234+ }
235+ if _, err := binary(Options{Binary: "/nope/rzb"}); err == nil || !strings.Contains(err.Error(), "razorbill.server") {
236+ t.Errorf("configured missing: %v", err)
237+ }
238+}
new file mode 100644
@@ -0,0 +1,238 @@
1+package rzbstart
2+
3+import (
4+ "context"
5+ "encoding/json"
6+ "flag"
7+ "net"
8+ "net/http"
9+ "os"
10+ "path/filepath"
11+ "runtime"
12+ "strconv"
13+ "strings"
14+ "testing"
15+ "time"
16+
17+ "mm/internal/serverstart"
18+)
19+
20+// The test binary is also the fake rzb (RZB_FAKE_CACHE set): `serve`
21+// answers /health and a /v1/models that lists the cache — one model id per
22+// line of the file RZB_FAKE_CACHE — and wants RZB_API_KEY when it is set;
23+// `models pull <id>` appends id to the cache, or fails for an id holding
24+// "fail".
25+func TestMain(m *testing.M) {
26+ cache := os.Getenv("RZB_FAKE_CACHE")
27+ if cache == "" {
28+ os.Exit(m.Run())
29+ }
30+ args := os.Args[1:]
31+ switch {
32+ case len(args) >= 3 && args[0] == "models" && args[1] == "pull":
33+ if strings.Contains(args[2], "fail") {
34+ os.Exit(1)
35+ }
36+ f, _ := os.OpenFile(cache, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
37+ _, _ = f.WriteString(args[2] + "\n")
38+ _ = f.Close()
39+ case len(args) >= 1 && args[0] == "serve":
40+ fakeServe(cache, args[1:])
41+ default:
42+ os.Exit(2)
43+ }
44+}
45+
46+func fakeServe(cache string, args []string) {
47+ fs := flag.NewFlagSet("serve", flag.ExitOnError)
48+ host := fs.String("host", "127.0.0.1", "")
49+ port := fs.Int("port", 7920, "")
50+ _ = fs.String("config", "", "")
51+ _ = fs.Parse(args)
52+ key := os.Getenv("RZB_API_KEY")
53+ mux := http.NewServeMux()
54+ mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"status":"ok"}`)) })
55+ mux.HandleFunc("/v1/models", func(w http.ResponseWriter, r *http.Request) {
56+ if key != "" && r.Header.Get("Authorization") != "Bearer "+key {
57+ w.WriteHeader(http.StatusUnauthorized)
58+ return
59+ }
60+ data, _ := os.ReadFile(cache)
61+ var list []map[string]any
62+ for _, id := range strings.Fields(string(data)) {
63+ list = append(list, map[string]any{"id": id, "object": "model", "loaded": false, "kind": "chat"})
64+ }
65+ _ = json.NewEncoder(w).Encode(map[string]any{"object": "list", "data": list})
66+ })
67+ _ = http.ListenAndServe(net.JoinHostPort(*host, strconv.Itoa(*port)), mux)
68+}
69+
70+func freePort(t *testing.T) int {
71+ t.Helper()
72+ l, err := net.Listen("tcp", "127.0.0.1:0")
73+ if err != nil {
74+ t.Fatal(err)
75+ }
76+ defer func() { _ = l.Close() }()
77+ return l.Addr().(*net.TCPAddr).Port
78+}
79+
80+// options for the fake rzb on a free port, as on a Mac; cache holds the
81+// models it starts with.
82+func options(t *testing.T, model string, cache ...string) (Options, *[]string, string) {
83+ t.Helper()
84+ if runtime.GOOS == "windows" {
85+ t.Skip("the fake server relies on process groups and signals")
86+ }
87+ old := goos
88+ goos = "darwin"
89+ t.Cleanup(func() { goos = old })
90+ cacheFile := filepath.Join(t.TempDir(), "cache")
91+ _ = os.WriteFile(cacheFile, []byte(strings.Join(cache, "\n")+"\n"), 0o644)
92+ t.Setenv("RZB_FAKE_CACHE", cacheFile)
93+ t.Setenv("RZB_API_KEY", "")
94+ self, err := os.Executable()
95+ if err != nil {
96+ t.Fatal(err)
97+ }
98+ var lines []string
99+ o := Options{Binary: self, Host: "127.0.0.1", Port: freePort(t), Model: model,
100+ StateDir: t.TempDir(), Timeout: 10 * time.Second,
101+ Report: func(l string) { lines = append(lines, l) }}
102+ t.Cleanup(func() {
103+ if pid := serverstart.RecordedPID(server(o)); pid > 0 {
104+ if p, err := os.FindProcess(pid); err == nil {
105+ _ = p.Kill()
106+ }
107+ }
108+ })
109+ return o, &lines, cacheFile
110+}
111+
112+func base(o Options) string { return serverstart.BaseURL(server(o)) }
113+
114+// A model in the cache: rzb is started, nothing is pulled, the release
115+// stops it.
116+func TestAcquireStartsRzbWithACachedModel(t *testing.T) {
117+ o, lines, _ := options(t, "mlx-community/Qwen3-0.6B-4bit", "mlx-community/Qwen3-0.6B-4bit")
118+ l, err := Acquire(context.Background(), o)
119+ if err != nil || l == nil {
120+ t.Fatalf("Acquire: %v, %v", l, err)
121+ }
122+ if !serverstart.Healthy(base(o)) {
123+ t.Fatal("rzb does not answer after Acquire")
124+ }
125+ got := strings.Join(*lines, "\n")
126+ if !strings.Contains(got, "🐧 starting rzb") || strings.Contains(got, "downloading") {
127+ t.Errorf("report:\n%s", got)
128+ }
129+ l.Release()
130+ if serverstart.Healthy(base(o)) {
131+ t.Error("rzb still runs after the last release")
132+ }
133+}
134+
135+// A model rzb does not list is pulled before Acquire returns, with the
136+// server's key.
137+func TestAcquirePullsAMissingModel(t *testing.T) {
138+ o, lines, cache := options(t, "mlx-community/Qwen3-4B-4bit")
139+ t.Setenv("RZB_API_KEY", "secret")
140+ o.APIKey = "secret"
141+ l, err := Acquire(context.Background(), o)
142+ defer l.Release()
143+ if err != nil {
144+ t.Fatalf("Acquire: %v\n%s", err, strings.Join(*lines, "\n"))
145+ }
146+ data, _ := os.ReadFile(cache)
147+ if !strings.Contains(string(data), "mlx-community/Qwen3-4B-4bit") {
148+ t.Errorf("not pulled; cache:\n%s", data)
149+ }
150+ got := strings.Join(*lines, "\n")
151+ if !strings.Contains(got, "🐧 downloading mlx-community/Qwen3-4B-4bit") || !strings.Contains(got, "🐧 mlx-community/Qwen3-4B-4bit downloaded") {
152+ t.Errorf("report:\n%s", got)
153+ }
154+}
155+
156+// A failed pull is an error naming the log; the lease comes back so the
157+// exit stops the server.
158+func TestAcquireReportsAFailedPull(t *testing.T) {
159+ o, _, _ := options(t, "org/fail-4bit")
160+ l, err := Acquire(context.Background(), o)
161+ if err == nil || !strings.Contains(err.Error(), "rzb models pull org/fail-4bit failed") || !strings.Contains(err.Error(), "rzb.log") {
162+ t.Fatalf("err = %v, want a pull failure naming the log", err)
163+ }
164+ if l == nil {
165+ t.Fatal("no lease: the server would never be stopped")
166+ }
167+ l.Release()
168+}
169+
170+// A short name rzb does not list cannot be pulled: it is not a Hugging
171+// Face id.
172+func TestAcquireRefusesAnUnknownShortName(t *testing.T) {
173+ o, _, _ := options(t, "qwen3")
174+ l, err := Acquire(context.Background(), o)
175+ defer l.Release()
176+ if err == nil || !strings.Contains(err.Error(), "neither declared") {
177+ t.Fatalf("err = %v, want an unknown-model error", err)
178+ }
179+}
180+
181+// Off macOS nothing is started, and the message says what to do from a
182+// container or a sandbox.
183+func TestAcquireRefusesOffMacOS(t *testing.T) {
184+ old := goos
185+ goos = "linux"
186+ t.Cleanup(func() { goos = old })
187+ l, err := Acquire(context.Background(), Options{Host: "127.0.0.1", Port: 7920, StateDir: t.TempDir()})
188+ if l != nil || err == nil || !strings.Contains(err.Error(), "macOS only") || !strings.Contains(err.Error(), "--host 0.0.0.0") {
189+ t.Fatalf("Acquire = %v, %v, want a macOS-only error", l, err)
190+ }
191+}
192+
193+// The command: rzb serve on the address, the config file, then the extra
194+// arguments; a missing config file is an error naming the key.
195+func TestCommand(t *testing.T) {
196+ cfg := filepath.Join(t.TempDir(), "server.yaml")
197+ _ = os.WriteFile(cfg, []byte("models: []\n"), 0o644)
198+ self, _ := os.Executable()
199+ o := Options{Binary: self, Host: "127.0.0.1", Port: 7920, ConfigFile: cfg, Args: []string{"--cors-origin", "*"}}
200+ bin, args, err := command(o)
201+ want := "serve --host 127.0.0.1 --port 7920 --config " + cfg + " --cors-origin *"
202+ if err != nil || bin != self || strings.Join(args, " ") != want {
203+ t.Errorf("command = %s %v (%v), want %s", bin, args, err, want)
204+ }
205+ o.ConfigFile = filepath.Join(t.TempDir(), "missing.yaml")
206+ if _, _, err := command(o); err == nil || !strings.Contains(err.Error(), "razorbill.config") {
207+ t.Errorf("missing config: %v", err)
208+ }
209+}
210+
211+// The binary: the configured one, else rzb on the PATH, else
212+// /usr/local/bin/rzb; none is ErrNotFound.
213+func TestBinary(t *testing.T) {
214+ if runtime.GOOS == "windows" {
215+ t.Skip("shell scripts as fake binaries")
216+ }
217+ dir := t.TempDir()
218+ t.Setenv("PATH", dir)
219+ old := installed
220+ t.Cleanup(func() { installed = old })
221+ installed = filepath.Join(t.TempDir(), "rzb")
222+
223+ if _, err := binary(Options{}); err != ErrNotFound {
224+ t.Errorf("nothing: %v, want ErrNotFound", err)
225+ }
226+ _ = os.WriteFile(installed, []byte("#!/bin/sh\n"), 0o755)
227+ if got, _ := binary(Options{}); got != installed {
228+ t.Errorf("installed only: %s", got)
229+ }
230+ onPath := filepath.Join(dir, "rzb")
231+ _ = os.WriteFile(onPath, []byte("#!/bin/sh\n"), 0o755)
232+ if got, _ := binary(Options{}); got != onPath {
233+ t.Errorf("on PATH: %s, want %s", got, onPath)
234+ }
235+ if _, err := binary(Options{Binary: "/nope/rzb"}); err == nil || !strings.Contains(err.Error(), "razorbill.server") {
236+ t.Errorf("configured missing: %v", err)
237+ }
238+}
renamed internal/serverstart/proc_unix.go +4 -4
similarity index 87%
rename from internal/llamastart/proc_unix.go
rename to internal/serverstart/proc_unix.go
@@ -1,6 +1,6 @@
11 //go:build !windows
22
3-package llamastart
3+package serverstart
44
55 import (
66 "errors"
@@ -13,8 +13,8 @@ import (
1313 )
1414
1515 // detach puts the server in its own process group: a Ctrl-C in mm's
16-// terminal does not reach it, and stop can end the router with the model
17-// processes it started.
16+// terminal does not reach it, and stop can end the server with the
17+// processes it started (llama-server's model children).
1818 func detach(cmd *exec.Cmd) {
1919 cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
2020 }
@@ -44,7 +44,7 @@ func stop(pid int) {
4444 _ = syscall.Kill(-pid, syscall.SIGTERM)
4545 deadline := time.Now().Add(stopGrace)
4646 for alive(pid) && time.Now().Before(deadline) {
47- time.Sleep(poll)
47+ time.Sleep(Poll)
4848 }
4949 _ = syscall.Kill(-pid, syscall.SIGKILL)
5050 }
similarity index 87%
rename from internal/llamastart/proc_unix.go
rename to internal/serverstart/proc_unix.go
@@ -1,6 +1,6 @@
1 //go:build !windows1 //go:build !windows
2 2
3-package llamastart3+package serverstart
4 4
5 import (5 import (
6 "errors"6 "errors"
@@ -13,8 +13,8 @@ import (
13 )13 )
14 14
15 // detach puts the server in its own process group: a Ctrl-C in mm's15 // detach puts the server in its own process group: a Ctrl-C in mm's
16-// terminal does not reach it, and stop can end the router with the model16+// terminal does not reach it, and stop can end the server with the
17-// processes it started.17+// processes it started (llama-server's model children).
18 func detach(cmd *exec.Cmd) {18 func detach(cmd *exec.Cmd) {
19 cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}19 cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
20 }20 }
@@ -44,7 +44,7 @@ func stop(pid int) {
44 _ = syscall.Kill(-pid, syscall.SIGTERM)44 _ = syscall.Kill(-pid, syscall.SIGTERM)
45 deadline := time.Now().Add(stopGrace)45 deadline := time.Now().Add(stopGrace)
46 for alive(pid) && time.Now().Before(deadline) {46 for alive(pid) && time.Now().Before(deadline) {
47- time.Sleep(poll)47+ time.Sleep(Poll)
48 }48 }
49 _ = syscall.Kill(-pid, syscall.SIGKILL)49 _ = syscall.Kill(-pid, syscall.SIGKILL)
50 }50 }
renamed internal/serverstart/proc_windows.go +2 -2
similarity index 91%
rename from internal/llamastart/proc_windows.go
rename to internal/serverstart/proc_windows.go
@@ -1,6 +1,6 @@
11 //go:build windows
22
3-package llamastart
3+package serverstart
44
55 import (
66 "os/exec"
@@ -40,7 +40,7 @@ func alive(pid int) bool {
4040 return code == stillActive
4141 }
4242
43-// stop ends the server and the model processes it started: Windows has no
43+// stop ends the server and the processes it started: Windows has no
4444 // SIGTERM, taskkill /T ends the whole tree.
4545 func stop(pid int) {
4646 _ = exec.Command("taskkill", "/T", "/F", "/PID", strconv.Itoa(pid)).Run()
similarity index 91%
rename from internal/llamastart/proc_windows.go
rename to internal/serverstart/proc_windows.go
@@ -1,6 +1,6 @@
1 //go:build windows1 //go:build windows
2 2
3-package llamastart3+package serverstart
4 4
5 import (5 import (
6 "os/exec"6 "os/exec"
@@ -40,7 +40,7 @@ func alive(pid int) bool {
40 return code == stillActive40 return code == stillActive
41 }41 }
42 42
43-// stop ends the server and the model processes it started: Windows has no43+// stop ends the server and the processes it started: Windows has no
44 // SIGTERM, taskkill /T ends the whole tree.44 // SIGTERM, taskkill /T ends the whole tree.
45 func stop(pid int) {45 func stop(pid int) {
46 _ = exec.Command("taskkill", "/T", "/F", "/PID", strconv.Itoa(pid)).Run()46 _ = exec.Command("taskkill", "/T", "/F", "/PID", strconv.Itoa(pid)).Run()
added internal/serverstart/serverstart.go +411 -0
new file mode 100644
@@ -0,0 +1,411 @@
1+// Package serverstart starts a local model server when nothing answers at
2+// an agent's address, and stops it with the last mm session that uses it.
3+// It knows nothing of the server it starts: Server says how to start one
4+// and how to get it ready for the agent's model. internal/llamastart
5+// (llama-server, `llamacpp.autoStart`, ticket 223) and internal/rzbstart
6+// (razorbill, `razorbill.autoStart`, ticket 264) are its two users.
7+//
8+// The lifetime is shared. A small registry per server and address, under
9+// the user's cache directory (<cache>/mm/<Server.Name>/<host>-<port>/),
10+// holds the pid of the server mm started (server.json) and one lease file
11+// per running mm process (leases/<pid>). The last mm to release its lease
12+// stops the server — its whole process group (a process tree on Windows),
13+// since a server may run children (llama-server's model processes). A lease
14+// whose process is gone (a crash) is removed by the next mm that reads the
15+// registry. A server mm did not start — the user's own — has no
16+// server.json: mm takes no lease on it and never stops it. A lock file
17+// keeps two mm starting at the same time from starting two servers.
18+//
19+// lease, err := serverstart.Acquire(ctx, serverstart.Options{
20+// Server: serverstart.Server{Name: "rzb", Emoji: "🐧", Command: cmd},
21+// Host: "127.0.0.1", Port: 7920,
22+// })
23+// defer lease.Release()
24+package serverstart
25+
26+import (
27+ "context"
28+ "encoding/json"
29+ "errors"
30+ "fmt"
31+ "net/http"
32+ "os"
33+ "os/exec"
34+ "path/filepath"
35+ "strconv"
36+ "strings"
37+ "sync"
38+ "time"
39+)
40+
41+// Server is one kind of server: its name, and how to start it and make it
42+// ready. Name is used in the messages ("starting llama-server…"), as the
43+// registry's directory under <cache>/mm/ and as the log file's name
44+// (<Name>.log), so it must stay the same from one mm version to the next.
45+type Server struct {
46+ Name string
47+ Emoji string // the first thing on every report line
48+ // Command returns the executable and its arguments. dir is the
49+ // address's registry directory, where it may write files the server
50+ // reads (llama-server's models preset).
51+ Command func(dir string) (binary string, args []string, err error)
52+ // Ready is called once the server answers at base ("http://host:port"),
53+ // whether this mm started it or shares it: it loads or downloads the
54+ // agent's model. nil = nothing to do. Its error is Acquire's, with the
55+ // lease still returned.
56+ Ready func(ctx context.Context, o Options, base string) error
57+}
58+
59+// Options says which server to start, where, and how to talk about it.
60+type Options struct {
61+ Server Server
62+ // Host and Port are where the server listens: the agent's address.
63+ Host string
64+ Port int
65+ // StateDir holds the registries; "" = <user cache dir>/mm/<Server.Name>.
66+ StateDir string
67+ // Timeout bounds the start, and is the bound Ready is expected to use.
68+ Timeout time.Duration
69+ // Report receives one line per step worth showing; nil = quiet.
70+ Report func(line string)
71+ // Wait shows that mm is waiting (a spinner) until the returned function
72+ // is called; nil = nothing shown.
73+ Wait func(text string) (stop func())
74+}
75+
76+// Lease is this process's use of a server mm started. Release it on exit.
77+// A nil *Lease (no server mm started) releases nothing.
78+type Lease struct {
79+ dir string
80+ name string
81+ emoji string
82+ report func(string)
83+ once sync.Once
84+}
85+
86+// record is server.json: the server mm started at this address.
87+type record struct {
88+ PID int `json:"pid"`
89+ Binary string `json:"binary"`
90+ Args []string `json:"args"`
91+ Started time.Time `json:"started"`
92+}
93+
94+// lockWait bounds the wait for another mm's start; lockStale is the age
95+// past which a lock whose holder still runs is taken anyway.
96+var (
97+ lockWait = time.Minute
98+ lockStale = 2 * time.Minute
99+ stopGrace = 5 * time.Second
100+ // Poll is the step of every wait loop, Ready's included.
101+ Poll = 200 * time.Millisecond
102+)
103+
104+// Acquire makes sure a server answers at o.Host:o.Port and is ready
105+// (o.Server.Ready), starting it when nothing answers, and returns this
106+// process's lease on it. It returns a nil lease and no error when a server
107+// mm did not start already answers there: that one is left alone, and
108+// Ready is not called. On an error after a start, the lease is returned so
109+// that its release stops the server unless another mm uses it.
110+func Acquire(ctx context.Context, o Options) (*Lease, error) {
111+ if o.Timeout <= 0 {
112+ o.Timeout = 10 * time.Minute
113+ }
114+ dir, err := registryDir(o)
115+ if err != nil {
116+ return nil, err
117+ }
118+ base := BaseURL(o)
119+ l := &Lease{dir: dir, name: o.Server.Name, emoji: o.Server.Emoji, report: o.Report}
120+
121+ unlock, err := lock(ctx, dir, o.Server.Name)
122+ if err != nil {
123+ return nil, err
124+ }
125+ rec := readRecord(dir)
126+ if rec != nil && !alive(rec.PID) {
127+ removeRecord(dir)
128+ rec = nil
129+ }
130+ up := Healthy(base)
131+ switch {
132+ case up && rec == nil:
133+ unlock()
134+ return nil, nil // not ours: never stopped
135+ case up:
136+ l.add()
137+ unlock()
138+ o.Say("%s already started by mm (pid %d): shared with this session", o.Server.Name, rec.PID)
139+ default:
140+ if rec != nil { // ours, alive, not answering: hung — replace it
141+ stop(rec.PID)
142+ removeRecord(dir)
143+ }
144+ if err := start(ctx, o, dir, base); err != nil {
145+ unlock()
146+ return nil, err
147+ }
148+ l.add()
149+ unlock()
150+ }
151+ if o.Server.Ready != nil {
152+ if err := o.Server.Ready(ctx, o, base); err != nil {
153+ return l, err
154+ }
155+ }
156+ return l, nil
157+}
158+
159+// Release removes this process's lease and stops the server when no live
160+// lease remains. Safe to call more than once, and on a nil lease.
161+func (l *Lease) Release() {
162+ if l == nil {
163+ return
164+ }
165+ l.once.Do(func() {
166+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
167+ defer cancel()
168+ unlock, err := lock(ctx, l.dir, l.name)
169+ if err != nil {
170+ return // another mm holds it: it will see our lease is stale
171+ }
172+ defer unlock()
173+ _ = os.Remove(filepath.Join(l.dir, "leases", strconv.Itoa(os.Getpid())))
174+ others := liveLeases(l.dir)
175+ rec := readRecord(l.dir)
176+ switch {
177+ case rec == nil:
178+ case others > 0:
179+ l.say("%s kept running: %d other mm session(s) use it", l.name, others)
180+ default:
181+ stop(rec.PID)
182+ removeRecord(l.dir)
183+ l.say("stopped %s (pid %d)", l.name, rec.PID)
184+ }
185+ })
186+}
187+
188+func (l *Lease) add() {
189+ _ = os.WriteFile(filepath.Join(l.dir, "leases", strconv.Itoa(os.Getpid())), nil, 0o644)
190+}
191+
192+func (l *Lease) say(format string, args ...any) {
193+ if l.report != nil {
194+ l.report(strings.TrimSpace(l.emoji + " " + fmt.Sprintf(format, args...)))
195+ }
196+}
197+
198+// Say reports one line, prefixed with the server's emoji.
199+//
200+// o.Say("%s loaded", model) // "🦙 org/m:Q4 loaded"
201+func (o Options) Say(format string, args ...any) {
202+ if o.Report != nil {
203+ o.Report(strings.TrimSpace(o.Server.Emoji + " " + fmt.Sprintf(format, args...)))
204+ }
205+}
206+
207+// WaitFor shows text while mm waits, until the returned function is called.
208+//
209+// done := o.WaitFor("Downloading the model…")
210+// defer done()
211+func (o Options) WaitFor(text string) func() {
212+ if o.Wait == nil {
213+ return func() {}
214+ }
215+ return o.Wait(text)
216+}
217+
218+// BaseURL is the server's root address, "http://host:port" (an IPv6 host
219+// in brackets).
220+func BaseURL(o Options) string { return "http://" + hostPort(o.Host, o.Port) }
221+
222+// LogPath is where the server started for o writes its output; "" when the
223+// registry directory cannot be made.
224+func LogPath(o Options) string {
225+ dir, err := registryDir(o)
226+ if err != nil {
227+ return ""
228+ }
229+ return filepath.Join(dir, o.Server.Name+".log")
230+}
231+
232+// RecordedPID is the pid of the server mm started at o's address, 0 when
233+// the registry records none (no server, or not mm's).
234+func RecordedPID(o Options) int {
235+ dir, err := registryDir(o)
236+ if err != nil {
237+ return 0
238+ }
239+ if r := readRecord(dir); r != nil {
240+ return r.PID
241+ }
242+ return 0
243+}
244+
245+// registryDir is <StateDir>/<host>-<port>, with its leases directory.
246+func registryDir(o Options) (string, error) {
247+ root := o.StateDir
248+ if root == "" {
249+ cache, err := os.UserCacheDir()
250+ if err != nil {
251+ return "", err
252+ }
253+ root = filepath.Join(cache, "mm", o.Server.Name)
254+ }
255+ name := strings.NewReplacer(":", "_", "/", "_", "\\", "_").Replace(o.Host) + "-" + strconv.Itoa(o.Port)
256+ dir := filepath.Join(root, name)
257+ return dir, os.MkdirAll(filepath.Join(dir, "leases"), 0o755)
258+}
259+
260+// start launches the server detached from mm (its own process group, its
261+// output in the log file), records it and waits until /health answers.
262+func start(ctx context.Context, o Options, dir, base string) error {
263+ if o.Server.Command == nil {
264+ return fmt.Errorf("%s: no start command", o.Server.Name)
265+ }
266+ bin, args, err := o.Server.Command(dir)
267+ if err != nil {
268+ return err
269+ }
270+ logPath := LogPath(o)
271+ logFile, err := os.Create(logPath)
272+ if err != nil {
273+ return err
274+ }
275+ cmd := exec.Command(bin, args...)
276+ cmd.Stdout, cmd.Stderr = logFile, logFile
277+ detach(cmd)
278+ if err := cmd.Start(); err != nil {
279+ _ = logFile.Close()
280+ return fmt.Errorf("start %s: %w", bin, err)
281+ }
282+ _ = logFile.Close()
283+ exited := make(chan error, 1)
284+ go func() { exited <- cmd.Wait() }() // reaps it if it ends while mm runs
285+ rec := record{PID: cmd.Process.Pid, Binary: bin, Args: args, Started: time.Now()}
286+ if err := writeRecord(dir, rec); err != nil {
287+ stop(rec.PID)
288+ return err
289+ }
290+ name := o.Server.Name
291+ o.Say("starting %s on %s (pid %d, log %s)", name, hostPort(o.Host, o.Port), rec.PID, logPath)
292+
293+ done := o.WaitFor("Starting " + name + "…")
294+ defer done()
295+ ctx, cancel := context.WithTimeout(ctx, o.Timeout)
296+ defer cancel()
297+ for !Healthy(base) {
298+ select {
299+ case err := <-exited:
300+ removeRecord(dir)
301+ return fmt.Errorf("%s stopped at once (%v) — see %s", name, err, logPath)
302+ case <-ctx.Done():
303+ stop(rec.PID)
304+ removeRecord(dir)
305+ return fmt.Errorf("%s did not answer within %s — see %s", name, o.Timeout, logPath)
306+ case <-time.After(Poll):
307+ }
308+ }
309+ return nil
310+}
311+
312+var healthClient = &http.Client{Timeout: time.Second}
313+
314+// Healthy reports whether GET <base>/health answers 200 within a second.
315+// llama-server and rzb both answer it without a key.
316+func Healthy(base string) bool {
317+ resp, err := healthClient.Get(base + "/health")
318+ if err != nil {
319+ return false
320+ }
321+ _ = resp.Body.Close()
322+ return resp.StatusCode == http.StatusOK
323+}
324+
325+func hostPort(host string, port int) string {
326+ if strings.Contains(host, ":") {
327+ host = "[" + host + "]"
328+ }
329+ return host + ":" + strconv.Itoa(port)
330+}
331+
332+// liveLeases counts the leases whose process still runs, removing the
333+// others (a crashed mm).
334+func liveLeases(dir string) int {
335+ entries, _ := os.ReadDir(filepath.Join(dir, "leases"))
336+ n := 0
337+ for _, e := range entries {
338+ pid, err := strconv.Atoi(e.Name())
339+ if err == nil && alive(pid) {
340+ n++
341+ continue
342+ }
343+ _ = os.Remove(filepath.Join(dir, "leases", e.Name()))
344+ }
345+ return n
346+}
347+
348+func readRecord(dir string) *record {
349+ data, err := os.ReadFile(filepath.Join(dir, "server.json"))
350+ if err != nil {
351+ return nil
352+ }
353+ var r record
354+ if json.Unmarshal(data, &r) != nil || r.PID <= 0 {
355+ return nil
356+ }
357+ return &r
358+}
359+
360+func writeRecord(dir string, r record) error {
361+ data, err := json.MarshalIndent(r, "", " ")
362+ if err != nil {
363+ return err
364+ }
365+ return os.WriteFile(filepath.Join(dir, "server.json"), data, 0o644)
366+}
367+
368+func removeRecord(dir string) { _ = os.Remove(filepath.Join(dir, "server.json")) }
369+
370+// lock takes dir's lock file — created exclusively, holding our pid — and
371+// returns its release. A lock whose holder is gone, or older than
372+// lockStale, is taken over.
373+func lock(ctx context.Context, dir, name string) (func(), error) {
374+ path := filepath.Join(dir, "lock")
375+ ctx, cancel := context.WithTimeout(ctx, lockWait)
376+ defer cancel()
377+ for {
378+ f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644)
379+ if err == nil {
380+ _, _ = f.WriteString(strconv.Itoa(os.Getpid()))
381+ _ = f.Close()
382+ return func() { _ = os.Remove(path) }, nil
383+ }
384+ if !errors.Is(err, os.ErrExist) {
385+ return nil, err
386+ }
387+ if staleLock(path) {
388+ _ = os.Remove(path)
389+ continue
390+ }
391+ select {
392+ case <-ctx.Done():
393+ return nil, fmt.Errorf("another mm is starting %s (lock %s)", name, path)
394+ case <-time.After(Poll):
395+ }
396+ }
397+}
398+
399+func staleLock(path string) bool {
400+ info, err := os.Stat(path)
401+ if err != nil {
402+ return false // gone meanwhile: retry
403+ }
404+ data, _ := os.ReadFile(path)
405+ pid, err := strconv.Atoi(strings.TrimSpace(string(data)))
406+ if err != nil {
407+ // Being written right now, or garbage: only an old one is stale.
408+ return time.Since(info.ModTime()) > lockStale
409+ }
410+ return !alive(pid) || time.Since(info.ModTime()) > lockStale
411+}
new file mode 100644
@@ -0,0 +1,411 @@
1+// Package serverstart starts a local model server when nothing answers at
2+// an agent's address, and stops it with the last mm session that uses it.
3+// It knows nothing of the server it starts: Server says how to start one
4+// and how to get it ready for the agent's model. internal/llamastart
5+// (llama-server, `llamacpp.autoStart`, ticket 223) and internal/rzbstart
6+// (razorbill, `razorbill.autoStart`, ticket 264) are its two users.
7+//
8+// The lifetime is shared. A small registry per server and address, under
9+// the user's cache directory (<cache>/mm/<Server.Name>/<host>-<port>/),
10+// holds the pid of the server mm started (server.json) and one lease file
11+// per running mm process (leases/<pid>). The last mm to release its lease
12+// stops the server — its whole process group (a process tree on Windows),
13+// since a server may run children (llama-server's model processes). A lease
14+// whose process is gone (a crash) is removed by the next mm that reads the
15+// registry. A server mm did not start — the user's own — has no
16+// server.json: mm takes no lease on it and never stops it. A lock file
17+// keeps two mm starting at the same time from starting two servers.
18+//
19+// lease, err := serverstart.Acquire(ctx, serverstart.Options{
20+// Server: serverstart.Server{Name: "rzb", Emoji: "🐧", Command: cmd},
21+// Host: "127.0.0.1", Port: 7920,
22+// })
23+// defer lease.Release()
24+package serverstart
25+
26+import (
27+ "context"
28+ "encoding/json"
29+ "errors"
30+ "fmt"
31+ "net/http"
32+ "os"
33+ "os/exec"
34+ "path/filepath"
35+ "strconv"
36+ "strings"
37+ "sync"
38+ "time"
39+)
40+
41+// Server is one kind of server: its name, and how to start it and make it
42+// ready. Name is used in the messages ("starting llama-server…"), as the
43+// registry's directory under <cache>/mm/ and as the log file's name
44+// (<Name>.log), so it must stay the same from one mm version to the next.
45+type Server struct {
46+ Name string
47+ Emoji string // the first thing on every report line
48+ // Command returns the executable and its arguments. dir is the
49+ // address's registry directory, where it may write files the server
50+ // reads (llama-server's models preset).
51+ Command func(dir string) (binary string, args []string, err error)
52+ // Ready is called once the server answers at base ("http://host:port"),
53+ // whether this mm started it or shares it: it loads or downloads the
54+ // agent's model. nil = nothing to do. Its error is Acquire's, with the
55+ // lease still returned.
56+ Ready func(ctx context.Context, o Options, base string) error
57+}
58+
59+// Options says which server to start, where, and how to talk about it.
60+type Options struct {
61+ Server Server
62+ // Host and Port are where the server listens: the agent's address.
63+ Host string
64+ Port int
65+ // StateDir holds the registries; "" = <user cache dir>/mm/<Server.Name>.
66+ StateDir string
67+ // Timeout bounds the start, and is the bound Ready is expected to use.
68+ Timeout time.Duration
69+ // Report receives one line per step worth showing; nil = quiet.
70+ Report func(line string)
71+ // Wait shows that mm is waiting (a spinner) until the returned function
72+ // is called; nil = nothing shown.
73+ Wait func(text string) (stop func())
74+}
75+
76+// Lease is this process's use of a server mm started. Release it on exit.
77+// A nil *Lease (no server mm started) releases nothing.
78+type Lease struct {
79+ dir string
80+ name string
81+ emoji string
82+ report func(string)
83+ once sync.Once
84+}
85+
86+// record is server.json: the server mm started at this address.
87+type record struct {
88+ PID int `json:"pid"`
89+ Binary string `json:"binary"`
90+ Args []string `json:"args"`
91+ Started time.Time `json:"started"`
92+}
93+
94+// lockWait bounds the wait for another mm's start; lockStale is the age
95+// past which a lock whose holder still runs is taken anyway.
96+var (
97+ lockWait = time.Minute
98+ lockStale = 2 * time.Minute
99+ stopGrace = 5 * time.Second
100+ // Poll is the step of every wait loop, Ready's included.
101+ Poll = 200 * time.Millisecond
102+)
103+
104+// Acquire makes sure a server answers at o.Host:o.Port and is ready
105+// (o.Server.Ready), starting it when nothing answers, and returns this
106+// process's lease on it. It returns a nil lease and no error when a server
107+// mm did not start already answers there: that one is left alone, and
108+// Ready is not called. On an error after a start, the lease is returned so
109+// that its release stops the server unless another mm uses it.
110+func Acquire(ctx context.Context, o Options) (*Lease, error) {
111+ if o.Timeout <= 0 {
112+ o.Timeout = 10 * time.Minute
113+ }
114+ dir, err := registryDir(o)
115+ if err != nil {
116+ return nil, err
117+ }
118+ base := BaseURL(o)
119+ l := &Lease{dir: dir, name: o.Server.Name, emoji: o.Server.Emoji, report: o.Report}
120+
121+ unlock, err := lock(ctx, dir, o.Server.Name)
122+ if err != nil {
123+ return nil, err
124+ }
125+ rec := readRecord(dir)
126+ if rec != nil && !alive(rec.PID) {
127+ removeRecord(dir)
128+ rec = nil
129+ }
130+ up := Healthy(base)
131+ switch {
132+ case up && rec == nil:
133+ unlock()
134+ return nil, nil // not ours: never stopped
135+ case up:
136+ l.add()
137+ unlock()
138+ o.Say("%s already started by mm (pid %d): shared with this session", o.Server.Name, rec.PID)
139+ default:
140+ if rec != nil { // ours, alive, not answering: hung — replace it
141+ stop(rec.PID)
142+ removeRecord(dir)
143+ }
144+ if err := start(ctx, o, dir, base); err != nil {
145+ unlock()
146+ return nil, err
147+ }
148+ l.add()
149+ unlock()
150+ }
151+ if o.Server.Ready != nil {
152+ if err := o.Server.Ready(ctx, o, base); err != nil {
153+ return l, err
154+ }
155+ }
156+ return l, nil
157+}
158+
159+// Release removes this process's lease and stops the server when no live
160+// lease remains. Safe to call more than once, and on a nil lease.
161+func (l *Lease) Release() {
162+ if l == nil {
163+ return
164+ }
165+ l.once.Do(func() {
166+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
167+ defer cancel()
168+ unlock, err := lock(ctx, l.dir, l.name)
169+ if err != nil {
170+ return // another mm holds it: it will see our lease is stale
171+ }
172+ defer unlock()
173+ _ = os.Remove(filepath.Join(l.dir, "leases", strconv.Itoa(os.Getpid())))
174+ others := liveLeases(l.dir)
175+ rec := readRecord(l.dir)
176+ switch {
177+ case rec == nil:
178+ case others > 0:
179+ l.say("%s kept running: %d other mm session(s) use it", l.name, others)
180+ default:
181+ stop(rec.PID)
182+ removeRecord(l.dir)
183+ l.say("stopped %s (pid %d)", l.name, rec.PID)
184+ }
185+ })
186+}
187+
188+func (l *Lease) add() {
189+ _ = os.WriteFile(filepath.Join(l.dir, "leases", strconv.Itoa(os.Getpid())), nil, 0o644)
190+}
191+
192+func (l *Lease) say(format string, args ...any) {
193+ if l.report != nil {
194+ l.report(strings.TrimSpace(l.emoji + " " + fmt.Sprintf(format, args...)))
195+ }
196+}
197+
198+// Say reports one line, prefixed with the server's emoji.
199+//
200+// o.Say("%s loaded", model) // "🦙 org/m:Q4 loaded"
201+func (o Options) Say(format string, args ...any) {
202+ if o.Report != nil {
203+ o.Report(strings.TrimSpace(o.Server.Emoji + " " + fmt.Sprintf(format, args...)))
204+ }
205+}
206+
207+// WaitFor shows text while mm waits, until the returned function is called.
208+//
209+// done := o.WaitFor("Downloading the model…")
210+// defer done()
211+func (o Options) WaitFor(text string) func() {
212+ if o.Wait == nil {
213+ return func() {}
214+ }
215+ return o.Wait(text)
216+}
217+
218+// BaseURL is the server's root address, "http://host:port" (an IPv6 host
219+// in brackets).
220+func BaseURL(o Options) string { return "http://" + hostPort(o.Host, o.Port) }
221+
222+// LogPath is where the server started for o writes its output; "" when the
223+// registry directory cannot be made.
224+func LogPath(o Options) string {
225+ dir, err := registryDir(o)
226+ if err != nil {
227+ return ""
228+ }
229+ return filepath.Join(dir, o.Server.Name+".log")
230+}
231+
232+// RecordedPID is the pid of the server mm started at o's address, 0 when
233+// the registry records none (no server, or not mm's).
234+func RecordedPID(o Options) int {
235+ dir, err := registryDir(o)
236+ if err != nil {
237+ return 0
238+ }
239+ if r := readRecord(dir); r != nil {
240+ return r.PID
241+ }
242+ return 0
243+}
244+
245+// registryDir is <StateDir>/<host>-<port>, with its leases directory.
246+func registryDir(o Options) (string, error) {
247+ root := o.StateDir
248+ if root == "" {
249+ cache, err := os.UserCacheDir()
250+ if err != nil {
251+ return "", err
252+ }
253+ root = filepath.Join(cache, "mm", o.Server.Name)
254+ }
255+ name := strings.NewReplacer(":", "_", "/", "_", "\\", "_").Replace(o.Host) + "-" + strconv.Itoa(o.Port)
256+ dir := filepath.Join(root, name)
257+ return dir, os.MkdirAll(filepath.Join(dir, "leases"), 0o755)
258+}
259+
260+// start launches the server detached from mm (its own process group, its
261+// output in the log file), records it and waits until /health answers.
262+func start(ctx context.Context, o Options, dir, base string) error {
263+ if o.Server.Command == nil {
264+ return fmt.Errorf("%s: no start command", o.Server.Name)
265+ }
266+ bin, args, err := o.Server.Command(dir)
267+ if err != nil {
268+ return err
269+ }
270+ logPath := LogPath(o)
271+ logFile, err := os.Create(logPath)
272+ if err != nil {
273+ return err
274+ }
275+ cmd := exec.Command(bin, args...)
276+ cmd.Stdout, cmd.Stderr = logFile, logFile
277+ detach(cmd)
278+ if err := cmd.Start(); err != nil {
279+ _ = logFile.Close()
280+ return fmt.Errorf("start %s: %w", bin, err)
281+ }
282+ _ = logFile.Close()
283+ exited := make(chan error, 1)
284+ go func() { exited <- cmd.Wait() }() // reaps it if it ends while mm runs
285+ rec := record{PID: cmd.Process.Pid, Binary: bin, Args: args, Started: time.Now()}
286+ if err := writeRecord(dir, rec); err != nil {
287+ stop(rec.PID)
288+ return err
289+ }
290+ name := o.Server.Name
291+ o.Say("starting %s on %s (pid %d, log %s)", name, hostPort(o.Host, o.Port), rec.PID, logPath)
292+
293+ done := o.WaitFor("Starting " + name + "…")
294+ defer done()
295+ ctx, cancel := context.WithTimeout(ctx, o.Timeout)
296+ defer cancel()
297+ for !Healthy(base) {
298+ select {
299+ case err := <-exited:
300+ removeRecord(dir)
301+ return fmt.Errorf("%s stopped at once (%v) — see %s", name, err, logPath)
302+ case <-ctx.Done():
303+ stop(rec.PID)
304+ removeRecord(dir)
305+ return fmt.Errorf("%s did not answer within %s — see %s", name, o.Timeout, logPath)
306+ case <-time.After(Poll):
307+ }
308+ }
309+ return nil
310+}
311+
312+var healthClient = &http.Client{Timeout: time.Second}
313+
314+// Healthy reports whether GET <base>/health answers 200 within a second.
315+// llama-server and rzb both answer it without a key.
316+func Healthy(base string) bool {
317+ resp, err := healthClient.Get(base + "/health")
318+ if err != nil {
319+ return false
320+ }
321+ _ = resp.Body.Close()
322+ return resp.StatusCode == http.StatusOK
323+}
324+
325+func hostPort(host string, port int) string {
326+ if strings.Contains(host, ":") {
327+ host = "[" + host + "]"
328+ }
329+ return host + ":" + strconv.Itoa(port)
330+}
331+
332+// liveLeases counts the leases whose process still runs, removing the
333+// others (a crashed mm).
334+func liveLeases(dir string) int {
335+ entries, _ := os.ReadDir(filepath.Join(dir, "leases"))
336+ n := 0
337+ for _, e := range entries {
338+ pid, err := strconv.Atoi(e.Name())
339+ if err == nil && alive(pid) {
340+ n++
341+ continue
342+ }
343+ _ = os.Remove(filepath.Join(dir, "leases", e.Name()))
344+ }
345+ return n
346+}
347+
348+func readRecord(dir string) *record {
349+ data, err := os.ReadFile(filepath.Join(dir, "server.json"))
350+ if err != nil {
351+ return nil
352+ }
353+ var r record
354+ if json.Unmarshal(data, &r) != nil || r.PID <= 0 {
355+ return nil
356+ }
357+ return &r
358+}
359+
360+func writeRecord(dir string, r record) error {
361+ data, err := json.MarshalIndent(r, "", " ")
362+ if err != nil {
363+ return err
364+ }
365+ return os.WriteFile(filepath.Join(dir, "server.json"), data, 0o644)
366+}
367+
368+func removeRecord(dir string) { _ = os.Remove(filepath.Join(dir, "server.json")) }
369+
370+// lock takes dir's lock file — created exclusively, holding our pid — and
371+// returns its release. A lock whose holder is gone, or older than
372+// lockStale, is taken over.
373+func lock(ctx context.Context, dir, name string) (func(), error) {
374+ path := filepath.Join(dir, "lock")
375+ ctx, cancel := context.WithTimeout(ctx, lockWait)
376+ defer cancel()
377+ for {
378+ f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644)
379+ if err == nil {
380+ _, _ = f.WriteString(strconv.Itoa(os.Getpid()))
381+ _ = f.Close()
382+ return func() { _ = os.Remove(path) }, nil
383+ }
384+ if !errors.Is(err, os.ErrExist) {
385+ return nil, err
386+ }
387+ if staleLock(path) {
388+ _ = os.Remove(path)
389+ continue
390+ }
391+ select {
392+ case <-ctx.Done():
393+ return nil, fmt.Errorf("another mm is starting %s (lock %s)", name, path)
394+ case <-time.After(Poll):
395+ }
396+ }
397+}
398+
399+func staleLock(path string) bool {
400+ info, err := os.Stat(path)
401+ if err != nil {
402+ return false // gone meanwhile: retry
403+ }
404+ data, _ := os.ReadFile(path)
405+ pid, err := strconv.Atoi(strings.TrimSpace(string(data)))
406+ if err != nil {
407+ // Being written right now, or garbage: only an old one is stale.
408+ return time.Since(info.ModTime()) > lockStale
409+ }
410+ return !alive(pid) || time.Since(info.ModTime()) > lockStale
411+}
added internal/serverstart/serverstart_test.go +256 -0
new file mode 100644
@@ -0,0 +1,256 @@
1+package serverstart
2+
3+import (
4+ "context"
5+ "errors"
6+ "flag"
7+ "net"
8+ "net/http"
9+ "net/http/httptest"
10+ "os"
11+ "os/exec"
12+ "path/filepath"
13+ "runtime"
14+ "strconv"
15+ "strings"
16+ "testing"
17+ "time"
18+)
19+
20+// The test binary is also the fake server: with SERVERSTART_FAKE=1 it
21+// answers /health on --port; =hang never answers; =exit stops at once.
22+func TestMain(m *testing.M) {
23+ switch os.Getenv("SERVERSTART_FAKE") {
24+ case "1":
25+ fs := flag.NewFlagSet("fake", flag.ExitOnError)
26+ port := fs.Int("port", 0, "")
27+ _ = fs.Parse(os.Args[1:])
28+ mux := http.NewServeMux()
29+ mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"status":"ok"}`)) })
30+ _ = http.ListenAndServe(net.JoinHostPort("127.0.0.1", strconv.Itoa(*port)), mux)
31+ return
32+ case "hang":
33+ time.Sleep(time.Minute)
34+ return
35+ case "exit":
36+ os.Exit(3)
37+ }
38+ os.Exit(m.Run())
39+}
40+
41+func freePort(t *testing.T) int {
42+ t.Helper()
43+ l, err := net.Listen("tcp", "127.0.0.1:0")
44+ if err != nil {
45+ t.Fatal(err)
46+ }
47+ defer func() { _ = l.Close() }()
48+ return l.Addr().(*net.TCPAddr).Port
49+}
50+
51+// options for a fake server on a free port, the registry in a temp dir;
52+// ready counts the calls of Server.Ready.
53+func options(t *testing.T, mode string) (Options, *[]string, *int) {
54+ t.Helper()
55+ if runtime.GOOS == "windows" {
56+ t.Skip("the fake server relies on process groups and signals")
57+ }
58+ t.Setenv("SERVERSTART_FAKE", mode)
59+ self, err := os.Executable()
60+ if err != nil {
61+ t.Fatal(err)
62+ }
63+ var lines []string
64+ ready := 0
65+ o := Options{Host: "127.0.0.1", Port: freePort(t), StateDir: t.TempDir(), Timeout: 10 * time.Second,
66+ Report: func(l string) { lines = append(lines, l) }}
67+ port := o.Port
68+ o.Server = Server{
69+ Name: "fake-server", Emoji: "🧪",
70+ Command: func(string) (string, []string, error) { return self, []string{"--port", strconv.Itoa(port)}, nil },
71+ Ready: func(context.Context, Options, string) error { ready++; return nil },
72+ }
73+ t.Cleanup(func() {
74+ if pid := RecordedPID(o); pid > 0 {
75+ stop(pid)
76+ }
77+ })
78+ return o, &lines, &ready
79+}
80+
81+// otherSession is a live process standing for another mm: its lease keeps
82+// the server running.
83+func otherSession(t *testing.T, o Options) *exec.Cmd {
84+ t.Helper()
85+ cmd := exec.Command("sleep", "30")
86+ if err := cmd.Start(); err != nil {
87+ t.Fatal(err)
88+ }
89+ t.Cleanup(func() { _ = cmd.Process.Kill(); _ = cmd.Wait() })
90+ dir, _ := registryDir(o)
91+ _ = os.WriteFile(filepath.Join(dir, "leases", strconv.Itoa(cmd.Process.Pid)), nil, 0o644)
92+ return cmd
93+}
94+
95+// Nothing answers: mm starts the server and makes it ready; a second
96+// session shares it; the last live session's release stops it, and a
97+// crashed session's lease does not keep it running.
98+func TestAcquireStartsSharesAndStopsWithTheLastSession(t *testing.T) {
99+ o, lines, ready := options(t, "1")
100+ l1, err := Acquire(context.Background(), o)
101+ if err != nil || l1 == nil {
102+ t.Fatalf("Acquire: %v, %v", l1, err)
103+ }
104+ if !Healthy(BaseURL(o)) || *ready != 1 {
105+ t.Fatalf("after Acquire: healthy %v, ready called %d times", Healthy(BaseURL(o)), *ready)
106+ }
107+ if _, err := os.Stat(LogPath(o)); err != nil || filepath.Base(LogPath(o)) != "fake-server.log" {
108+ t.Errorf("log %s: %v", LogPath(o), err)
109+ }
110+
111+ other := otherSession(t, o)
112+ l1.Release()
113+ l1.Release() // twice: no effect
114+ if !Healthy(BaseURL(o)) {
115+ t.Fatal("a release stopped the server another session uses")
116+ }
117+
118+ l2, err := Acquire(context.Background(), o)
119+ if err != nil || l2 == nil || *ready != 2 {
120+ t.Fatalf("second Acquire: %v, %v (ready %d)", l2, err, *ready)
121+ }
122+ _ = other.Process.Kill()
123+ _ = other.Wait()
124+ l2.Release()
125+ deadline := time.Now().Add(3 * time.Second)
126+ for Healthy(BaseURL(o)) && time.Now().Before(deadline) {
127+ time.Sleep(50 * time.Millisecond)
128+ }
129+ if Healthy(BaseURL(o)) {
130+ t.Fatal("the last release did not stop the server")
131+ }
132+ if RecordedPID(o) != 0 {
133+ t.Error("server.json left behind")
134+ }
135+ got := strings.Join(*lines, "\n")
136+ for _, want := range []string{"🧪 starting fake-server", "🧪 fake-server kept running: 1 other", "🧪 fake-server already started by mm", "🧪 stopped fake-server"} {
137+ if !strings.Contains(got, want) {
138+ t.Errorf("report lacks %q:\n%s", want, got)
139+ }
140+ }
141+}
142+
143+// A server mm did not start answers already: no lease, no Ready, never
144+// stopped.
145+func TestAcquireLeavesAForeignServerAlone(t *testing.T) {
146+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {}))
147+ t.Cleanup(srv.Close)
148+ addr := srv.Listener.Addr().(*net.TCPAddr)
149+ readyCalled := false
150+ o := Options{Host: "127.0.0.1", Port: addr.Port, StateDir: t.TempDir(),
151+ Server: Server{Name: "x", Ready: func(context.Context, Options, string) error { readyCalled = true; return nil }}}
152+ l, err := Acquire(context.Background(), o)
153+ if l != nil || err != nil || readyCalled {
154+ t.Fatalf("Acquire = %v, %v (ready %v), want no lease, no error, no Ready", l, err, readyCalled)
155+ }
156+ l.Release() // nil lease: nothing
157+ if resp, err := http.Get(srv.URL + "/health"); err != nil {
158+ t.Fatal("the foreign server was stopped")
159+ } else {
160+ _ = resp.Body.Close()
161+ }
162+}
163+
164+// Ready's error is Acquire's, and the lease comes back with it so the exit
165+// still stops the server.
166+func TestAcquireReturnsTheLeaseWithReadysError(t *testing.T) {
167+ o, _, _ := options(t, "1")
168+ o.Server.Ready = func(context.Context, Options, string) error { return errors.New("no model") }
169+ l, err := Acquire(context.Background(), o)
170+ if err == nil || err.Error() != "no model" || l == nil {
171+ t.Fatalf("Acquire = %v, %v, want a lease and Ready's error", l, err)
172+ }
173+ l.Release()
174+ if Healthy(BaseURL(o)) {
175+ t.Error("server still running after the release")
176+ }
177+}
178+
179+// A server that never answers is stopped after the timeout.
180+func TestAcquireTimesOut(t *testing.T) {
181+ o, _, _ := options(t, "hang")
182+ o.Timeout = 500 * time.Millisecond
183+ start := time.Now()
184+ _, err := Acquire(context.Background(), o)
185+ if err == nil || !strings.Contains(err.Error(), "fake-server did not answer within") {
186+ t.Fatalf("err = %v, want a timeout", err)
187+ }
188+ if time.Since(start) > 8*time.Second {
189+ t.Errorf("took %s", time.Since(start))
190+ }
191+ if RecordedPID(o) != 0 {
192+ t.Error("server.json left behind")
193+ }
194+}
195+
196+// A server that exits at once is reported with its log, not waited for.
197+func TestAcquireReportsAServerThatStops(t *testing.T) {
198+ o, _, _ := options(t, "exit")
199+ _, err := Acquire(context.Background(), o)
200+ if err == nil || !strings.Contains(err.Error(), "stopped at once") || !strings.Contains(err.Error(), "fake-server.log") {
201+ t.Fatalf("err = %v, want stopped at once + the log", err)
202+ }
203+}
204+
205+// The command's error stops Acquire before anything starts.
206+func TestAcquireReportsTheCommandsError(t *testing.T) {
207+ o, _, _ := options(t, "1")
208+ o.Server.Command = func(string) (string, []string, error) { return "", nil, errors.New("not installed") }
209+ if _, err := Acquire(context.Background(), o); err == nil || err.Error() != "not installed" {
210+ t.Fatalf("err = %v, want the command's error", err)
211+ }
212+}
213+
214+// A lock left by a process that is gone is taken over.
215+func TestStaleLockIsTakenOver(t *testing.T) {
216+ dir := t.TempDir()
217+ dead := exec.Command("true")
218+ _ = dead.Run()
219+ _ = os.WriteFile(filepath.Join(dir, "lock"), []byte(strconv.Itoa(dead.Process.Pid)), 0o644)
220+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
221+ defer cancel()
222+ unlock, err := lock(ctx, dir, "x")
223+ if err != nil {
224+ t.Fatalf("lock: %v", err)
225+ }
226+ unlock()
227+}
228+
229+// The registry lives under <cache>/mm/<Name>/<host>-<port>: llama-server's
230+// path is the one ticket 223 wrote, so leases survive the move.
231+func TestRegistryDirIsNamedAfterTheServer(t *testing.T) {
232+ t.Setenv("XDG_CACHE_HOME", t.TempDir())
233+ t.Setenv("HOME", t.TempDir())
234+ cache, err := os.UserCacheDir()
235+ if err != nil {
236+ t.Skip(err)
237+ }
238+ dir, err := registryDir(Options{Server: Server{Name: "llama-server"}, Host: "::1", Port: 9931})
239+ if err != nil || dir != filepath.Join(cache, "mm", "llama-server", "__1-9931") {
240+ t.Fatalf("registryDir = %s, %v", dir, err)
241+ }
242+}
243+
244+// Say prefixes the emoji; WaitFor without Wait is a no-op.
245+func TestSayAndWaitFor(t *testing.T) {
246+ var got string
247+ o := Options{Server: Server{Emoji: "🐧"}, Report: func(l string) { got = l }}
248+ o.Say("%s loaded", "m")
249+ if got != "🐧 m loaded" {
250+ t.Errorf("Say = %q", got)
251+ }
252+ o.WaitFor("x")()
253+ if BaseURL(Options{Host: "::1", Port: 7920}) != "http://[::1]:7920" {
254+ t.Error("BaseURL does not bracket an IPv6 host")
255+ }
256+}
new file mode 100644
@@ -0,0 +1,256 @@
1+package serverstart
2+
3+import (
4+ "context"
5+ "errors"
6+ "flag"
7+ "net"
8+ "net/http"
9+ "net/http/httptest"
10+ "os"
11+ "os/exec"
12+ "path/filepath"
13+ "runtime"
14+ "strconv"
15+ "strings"
16+ "testing"
17+ "time"
18+)
19+
20+// The test binary is also the fake server: with SERVERSTART_FAKE=1 it
21+// answers /health on --port; =hang never answers; =exit stops at once.
22+func TestMain(m *testing.M) {
23+ switch os.Getenv("SERVERSTART_FAKE") {
24+ case "1":
25+ fs := flag.NewFlagSet("fake", flag.ExitOnError)
26+ port := fs.Int("port", 0, "")
27+ _ = fs.Parse(os.Args[1:])
28+ mux := http.NewServeMux()
29+ mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`{"status":"ok"}`)) })
30+ _ = http.ListenAndServe(net.JoinHostPort("127.0.0.1", strconv.Itoa(*port)), mux)
31+ return
32+ case "hang":
33+ time.Sleep(time.Minute)
34+ return
35+ case "exit":
36+ os.Exit(3)
37+ }
38+ os.Exit(m.Run())
39+}
40+
41+func freePort(t *testing.T) int {
42+ t.Helper()
43+ l, err := net.Listen("tcp", "127.0.0.1:0")
44+ if err != nil {
45+ t.Fatal(err)
46+ }
47+ defer func() { _ = l.Close() }()
48+ return l.Addr().(*net.TCPAddr).Port
49+}
50+
51+// options for a fake server on a free port, the registry in a temp dir;
52+// ready counts the calls of Server.Ready.
53+func options(t *testing.T, mode string) (Options, *[]string, *int) {
54+ t.Helper()
55+ if runtime.GOOS == "windows" {
56+ t.Skip("the fake server relies on process groups and signals")
57+ }
58+ t.Setenv("SERVERSTART_FAKE", mode)
59+ self, err := os.Executable()
60+ if err != nil {
61+ t.Fatal(err)
62+ }
63+ var lines []string
64+ ready := 0
65+ o := Options{Host: "127.0.0.1", Port: freePort(t), StateDir: t.TempDir(), Timeout: 10 * time.Second,
66+ Report: func(l string) { lines = append(lines, l) }}
67+ port := o.Port
68+ o.Server = Server{
69+ Name: "fake-server", Emoji: "🧪",
70+ Command: func(string) (string, []string, error) { return self, []string{"--port", strconv.Itoa(port)}, nil },
71+ Ready: func(context.Context, Options, string) error { ready++; return nil },
72+ }
73+ t.Cleanup(func() {
74+ if pid := RecordedPID(o); pid > 0 {
75+ stop(pid)
76+ }
77+ })
78+ return o, &lines, &ready
79+}
80+
81+// otherSession is a live process standing for another mm: its lease keeps
82+// the server running.
83+func otherSession(t *testing.T, o Options) *exec.Cmd {
84+ t.Helper()
85+ cmd := exec.Command("sleep", "30")
86+ if err := cmd.Start(); err != nil {
87+ t.Fatal(err)
88+ }
89+ t.Cleanup(func() { _ = cmd.Process.Kill(); _ = cmd.Wait() })
90+ dir, _ := registryDir(o)
91+ _ = os.WriteFile(filepath.Join(dir, "leases", strconv.Itoa(cmd.Process.Pid)), nil, 0o644)
92+ return cmd
93+}
94+
95+// Nothing answers: mm starts the server and makes it ready; a second
96+// session shares it; the last live session's release stops it, and a
97+// crashed session's lease does not keep it running.
98+func TestAcquireStartsSharesAndStopsWithTheLastSession(t *testing.T) {
99+ o, lines, ready := options(t, "1")
100+ l1, err := Acquire(context.Background(), o)
101+ if err != nil || l1 == nil {
102+ t.Fatalf("Acquire: %v, %v", l1, err)
103+ }
104+ if !Healthy(BaseURL(o)) || *ready != 1 {
105+ t.Fatalf("after Acquire: healthy %v, ready called %d times", Healthy(BaseURL(o)), *ready)
106+ }
107+ if _, err := os.Stat(LogPath(o)); err != nil || filepath.Base(LogPath(o)) != "fake-server.log" {
108+ t.Errorf("log %s: %v", LogPath(o), err)
109+ }
110+
111+ other := otherSession(t, o)
112+ l1.Release()
113+ l1.Release() // twice: no effect
114+ if !Healthy(BaseURL(o)) {
115+ t.Fatal("a release stopped the server another session uses")
116+ }
117+
118+ l2, err := Acquire(context.Background(), o)
119+ if err != nil || l2 == nil || *ready != 2 {
120+ t.Fatalf("second Acquire: %v, %v (ready %d)", l2, err, *ready)
121+ }
122+ _ = other.Process.Kill()
123+ _ = other.Wait()
124+ l2.Release()
125+ deadline := time.Now().Add(3 * time.Second)
126+ for Healthy(BaseURL(o)) && time.Now().Before(deadline) {
127+ time.Sleep(50 * time.Millisecond)
128+ }
129+ if Healthy(BaseURL(o)) {
130+ t.Fatal("the last release did not stop the server")
131+ }
132+ if RecordedPID(o) != 0 {
133+ t.Error("server.json left behind")
134+ }
135+ got := strings.Join(*lines, "\n")
136+ for _, want := range []string{"🧪 starting fake-server", "🧪 fake-server kept running: 1 other", "🧪 fake-server already started by mm", "🧪 stopped fake-server"} {
137+ if !strings.Contains(got, want) {
138+ t.Errorf("report lacks %q:\n%s", want, got)
139+ }
140+ }
141+}
142+
143+// A server mm did not start answers already: no lease, no Ready, never
144+// stopped.
145+func TestAcquireLeavesAForeignServerAlone(t *testing.T) {
146+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {}))
147+ t.Cleanup(srv.Close)
148+ addr := srv.Listener.Addr().(*net.TCPAddr)
149+ readyCalled := false
150+ o := Options{Host: "127.0.0.1", Port: addr.Port, StateDir: t.TempDir(),
151+ Server: Server{Name: "x", Ready: func(context.Context, Options, string) error { readyCalled = true; return nil }}}
152+ l, err := Acquire(context.Background(), o)
153+ if l != nil || err != nil || readyCalled {
154+ t.Fatalf("Acquire = %v, %v (ready %v), want no lease, no error, no Ready", l, err, readyCalled)
155+ }
156+ l.Release() // nil lease: nothing
157+ if resp, err := http.Get(srv.URL + "/health"); err != nil {
158+ t.Fatal("the foreign server was stopped")
159+ } else {
160+ _ = resp.Body.Close()
161+ }
162+}
163+
164+// Ready's error is Acquire's, and the lease comes back with it so the exit
165+// still stops the server.
166+func TestAcquireReturnsTheLeaseWithReadysError(t *testing.T) {
167+ o, _, _ := options(t, "1")
168+ o.Server.Ready = func(context.Context, Options, string) error { return errors.New("no model") }
169+ l, err := Acquire(context.Background(), o)
170+ if err == nil || err.Error() != "no model" || l == nil {
171+ t.Fatalf("Acquire = %v, %v, want a lease and Ready's error", l, err)
172+ }
173+ l.Release()
174+ if Healthy(BaseURL(o)) {
175+ t.Error("server still running after the release")
176+ }
177+}
178+
179+// A server that never answers is stopped after the timeout.
180+func TestAcquireTimesOut(t *testing.T) {
181+ o, _, _ := options(t, "hang")
182+ o.Timeout = 500 * time.Millisecond
183+ start := time.Now()
184+ _, err := Acquire(context.Background(), o)
185+ if err == nil || !strings.Contains(err.Error(), "fake-server did not answer within") {
186+ t.Fatalf("err = %v, want a timeout", err)
187+ }
188+ if time.Since(start) > 8*time.Second {
189+ t.Errorf("took %s", time.Since(start))
190+ }
191+ if RecordedPID(o) != 0 {
192+ t.Error("server.json left behind")
193+ }
194+}
195+
196+// A server that exits at once is reported with its log, not waited for.
197+func TestAcquireReportsAServerThatStops(t *testing.T) {
198+ o, _, _ := options(t, "exit")
199+ _, err := Acquire(context.Background(), o)
200+ if err == nil || !strings.Contains(err.Error(), "stopped at once") || !strings.Contains(err.Error(), "fake-server.log") {
201+ t.Fatalf("err = %v, want stopped at once + the log", err)
202+ }
203+}
204+
205+// The command's error stops Acquire before anything starts.
206+func TestAcquireReportsTheCommandsError(t *testing.T) {
207+ o, _, _ := options(t, "1")
208+ o.Server.Command = func(string) (string, []string, error) { return "", nil, errors.New("not installed") }
209+ if _, err := Acquire(context.Background(), o); err == nil || err.Error() != "not installed" {
210+ t.Fatalf("err = %v, want the command's error", err)
211+ }
212+}
213+
214+// A lock left by a process that is gone is taken over.
215+func TestStaleLockIsTakenOver(t *testing.T) {
216+ dir := t.TempDir()
217+ dead := exec.Command("true")
218+ _ = dead.Run()
219+ _ = os.WriteFile(filepath.Join(dir, "lock"), []byte(strconv.Itoa(dead.Process.Pid)), 0o644)
220+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
221+ defer cancel()
222+ unlock, err := lock(ctx, dir, "x")
223+ if err != nil {
224+ t.Fatalf("lock: %v", err)
225+ }
226+ unlock()
227+}
228+
229+// The registry lives under <cache>/mm/<Name>/<host>-<port>: llama-server's
230+// path is the one ticket 223 wrote, so leases survive the move.
231+func TestRegistryDirIsNamedAfterTheServer(t *testing.T) {
232+ t.Setenv("XDG_CACHE_HOME", t.TempDir())
233+ t.Setenv("HOME", t.TempDir())
234+ cache, err := os.UserCacheDir()
235+ if err != nil {
236+ t.Skip(err)
237+ }
238+ dir, err := registryDir(Options{Server: Server{Name: "llama-server"}, Host: "::1", Port: 9931})
239+ if err != nil || dir != filepath.Join(cache, "mm", "llama-server", "__1-9931") {
240+ t.Fatalf("registryDir = %s, %v", dir, err)
241+ }
242+}
243+
244+// Say prefixes the emoji; WaitFor without Wait is a no-op.
245+func TestSayAndWaitFor(t *testing.T) {
246+ var got string
247+ o := Options{Server: Server{Emoji: "🐧"}, Report: func(l string) { got = l }}
248+ o.Say("%s loaded", "m")
249+ if got != "🐧 m loaded" {
250+ t.Errorf("Say = %q", got)
251+ }
252+ o.WaitFor("x")()
253+ if BaseURL(Options{Host: "::1", Port: 7920}) != "http://[::1]:7920" {
254+ t.Error("BaseURL does not bracket an IPv6 host")
255+ }
256+}
deleted llama_wiring.go +0 -60
deleted file mode 100644
@@ -1,60 +0,0 @@
1-package main
2-
3-import (
4- "context"
5- "fmt"
6- "os"
7- "os/signal"
8- "syscall"
9-
10- "mm/internal/ask"
11- "mm/internal/config"
12- "mm/internal/engine"
13- "mm/internal/llamastart"
14- "mm/internal/spinner"
15-)
16-
17-// startLlamaServer starts llama-server for a llamacpp agent with
18-// llamacpp.autoStart when nothing answers at its address (ticket 223), and
19-// returns this process's lease on the server mm started — nil when mm did
20-// not start it (nothing to do, or the user's own server answers). A failure
21-// is a warning: mm goes on as without autoStart, and the probe says what
22-// does not answer.
23-func startLlamaServer(ctx context.Context, acpMode bool) *llamastart.Lease {
24- host, port, ok := engine.LlamaStartAddress(config.Cfg)
25- if !ok {
26- return nil
27- }
28- lc := config.Cfg.LlamaCpp
29- timeout := lc.StartTimeout
30- if timeout <= 0 {
31- timeout = config.DefaultLlamaStartTimeout
32- }
33- o := llamastart.Options{
34- Binary: lc.Server, Args: lc.LaunchArgs(), Host: host, Port: port,
35- Model: config.Cfg.Model, Timeout: timeout,
36- // stderr, like autoPull's progress: stdout may carry a -p answer.
37- Report: func(line string) { _, _ = fmt.Fprintln(os.Stderr, line) },
38- }
39- // The spinner in a terminal; in ACP mode (disabled spinner) and in an
40- // agent asked by another one, the report lines only.
41- if !acpMode && ask.Depth() == 0 {
42- o.Wait = func(text string) func() { spinner.Start(text); return spinner.Stop }
43- }
44- // A download can take minutes: Ctrl-C, SIGTERM or SIGHUP meanwhile
45- // stop the start — and the server, unless another mm uses it — then mm.
46- sigCtx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
47- defer stop()
48- // The lease comes back even with an error after a start (the model
49- // failed to load): the exit must still stop the server.
50- lease, err := llamastart.Acquire(sigCtx, o)
51- if sigCtx.Err() != nil && ctx.Err() == nil {
52- _, _ = fmt.Fprintln(os.Stderr, "\n[llamacpp.autoStart: interrupted]")
53- lease.Release()
54- os.Exit(130)
55- }
56- if err != nil {
57- _, _ = fmt.Fprintf(os.Stderr, "[warning: llamacpp.autoStart: %v]\n", err)
58- }
59- return lease
60-}
deleted file mode 100644
@@ -1,60 +0,0 @@
1-package main
2-
3-import (
4- "context"
5- "fmt"
6- "os"
7- "os/signal"
8- "syscall"
9-
10- "mm/internal/ask"
11- "mm/internal/config"
12- "mm/internal/engine"
13- "mm/internal/llamastart"
14- "mm/internal/spinner"
15-)
16-
17-// startLlamaServer starts llama-server for a llamacpp agent with
18-// llamacpp.autoStart when nothing answers at its address (ticket 223), and
19-// returns this process's lease on the server mm started — nil when mm did
20-// not start it (nothing to do, or the user's own server answers). A failure
21-// is a warning: mm goes on as without autoStart, and the probe says what
22-// does not answer.
23-func startLlamaServer(ctx context.Context, acpMode bool) *llamastart.Lease {
24- host, port, ok := engine.LlamaStartAddress(config.Cfg)
25- if !ok {
26- return nil
27- }
28- lc := config.Cfg.LlamaCpp
29- timeout := lc.StartTimeout
30- if timeout <= 0 {
31- timeout = config.DefaultLlamaStartTimeout
32- }
33- o := llamastart.Options{
34- Binary: lc.Server, Args: lc.LaunchArgs(), Host: host, Port: port,
35- Model: config.Cfg.Model, Timeout: timeout,
36- // stderr, like autoPull's progress: stdout may carry a -p answer.
37- Report: func(line string) { _, _ = fmt.Fprintln(os.Stderr, line) },
38- }
39- // The spinner in a terminal; in ACP mode (disabled spinner) and in an
40- // agent asked by another one, the report lines only.
41- if !acpMode && ask.Depth() == 0 {
42- o.Wait = func(text string) func() { spinner.Start(text); return spinner.Stop }
43- }
44- // A download can take minutes: Ctrl-C, SIGTERM or SIGHUP meanwhile
45- // stop the start — and the server, unless another mm uses it — then mm.
46- sigCtx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
47- defer stop()
48- // The lease comes back even with an error after a start (the model
49- // failed to load): the exit must still stop the server.
50- lease, err := llamastart.Acquire(sigCtx, o)
51- if sigCtx.Err() != nil && ctx.Err() == nil {
52- _, _ = fmt.Fprintln(os.Stderr, "\n[llamacpp.autoStart: interrupted]")
53- lease.Release()
54- os.Exit(130)
55- }
56- if err != nil {
57- _, _ = fmt.Fprintf(os.Stderr, "[warning: llamacpp.autoStart: %v]\n", err)
58- }
59- return lease
60-}
modified main.go +7 -6
@@ -278,13 +278,14 @@ func main() {
278278
279279 // Every way out from here on — main returning, exit(), a signal — runs
280280 // onExit: the model's unload (unloadOnExit, ticket 255), then the
281- // llama-server lease (llamacpp.autoStart, ticket 223).
281+ // lease on the server mm started (llamacpp.autoStart, ticket 223;
282+ // razorbill.autoStart, ticket 264).
282283 defer onExit.run()
283- // llamacpp.autoStart (ticket 223): nothing answers at the agent's
284- // address, mm starts llama-server and waits for the model — before the
285- // engine picks its address, so it finds the server it started. It
286- // handles a signal during the start itself; the watch starts after.
287- onExit.release = startLlamaServer(ctx, *acpMode).Release
284+ // autoStart: nothing answers at the agent's address, mm starts
285+ // llama-server or rzb and waits for the model — before the engine
286+ // picks its address, so it finds the server it started. It handles a
287+ // signal during the start itself; the watch starts after.
288+ onExit.release = startLocalServer(ctx, *acpMode).Release
288289 defer watchExitSignals(onExit, *promptMode != "")()
289290
290291 e, err := engine.New(ctx)
@@ -278,13 +278,14 @@ func main() {
278 278
279 // Every way out from here on — main returning, exit(), a signal — runs279 // Every way out from here on — main returning, exit(), a signal — runs
280 // onExit: the model's unload (unloadOnExit, ticket 255), then the280 // onExit: the model's unload (unloadOnExit, ticket 255), then the
281- // llama-server lease (llamacpp.autoStart, ticket 223).281+ // lease on the server mm started (llamacpp.autoStart, ticket 223;
282+ // razorbill.autoStart, ticket 264).
282 defer onExit.run()283 defer onExit.run()
283- // llamacpp.autoStart (ticket 223): nothing answers at the agent's284+ // autoStart: nothing answers at the agent's address, mm starts
284- // address, mm starts llama-server and waits for the model — before the285+ // llama-server or rzb and waits for the model — before the engine
285- // engine picks its address, so it finds the server it started. It286+ // picks its address, so it finds the server it started. It handles a
286- // handles a signal during the start itself; the watch starts after.287+ // signal during the start itself; the watch starts after.
287- onExit.release = startLlamaServer(ctx, *acpMode).Release288+ onExit.release = startLocalServer(ctx, *acpMode).Release
288 defer watchExitSignals(onExit, *promptMode != "")()289 defer watchExitSignals(onExit, *promptMode != "")()
289 290
290 e, err := engine.New(ctx)291 e, err := engine.New(ctx)
modified unload_exit.go +2 -1
@@ -29,7 +29,8 @@ import (
2929 // takes care of it.
3030
3131 // exitUnload unloads the agent's model once, within timeout, then runs
32-// release — the llama-server lease (ticket 223), which may stop the server.
32+// release — the lease on the server mm started (llama-server, ticket 223;
33+// rzb, ticket 264), which may stop the server.
3334 // A zero exitUnload does nothing.
3435 type exitUnload struct {
3536 once sync.Once
@@ -29,7 +29,8 @@ import (
29 // takes care of it.29 // takes care of it.
30 30
31 // exitUnload unloads the agent's model once, within timeout, then runs31 // exitUnload unloads the agent's model once, within timeout, then runs
32-// release — the llama-server lease (ticket 223), which may stop the server.32+// release — the lease on the server mm started (llama-server, ticket 223;
33+// rzb, ticket 264), which may stop the server.
33 // A zero exitUnload does nothing.34 // A zero exitUnload does nothing.
34 type exitUnload struct {35 type exitUnload struct {
35 once sync.Once36 once sync.Once