bots-garden/mini-mepublic Fork
⑂ 25eea96
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

🛟 Updated.

k33g committed 2026-11-18T08:15:36+01:00 Browse files
25eea96 parent: 4ff1e9a
modified .tickets/issues/0172-nushell-script-client-over-acp-mm-from-a-shell-s.yaml +24 -3
@@ -6,7 +6,7 @@ author:
66 name: k33g
77 email: ph.charriere@gmail.com
88 createdAt: 2026-10-26T06:30:00.000Z
9-updatedAt: 2026-11-11T07:00:55.349Z
9+updatedAt: 2026-11-18T06:56:19.000Z
1010 labels:
1111 - kind::feature
1212 milestone: v2.0.0
@@ -14,6 +14,7 @@ epic: SDK
1414 related:
1515 - 167
1616 - 139
17+ - 222
1718 body: |
1819 ## Goal
1920 Use mm from a Nushell script with structured data (tables, records) instead of text: send a question, get the answer and the tool calls as Nushell values.
@@ -31,7 +32,7 @@ body: |
3132 - `nu` is not installed in this sandbox.
3233
3334 ## Done when
34- - `demos/nushell-acp-client/` holds the client, one example each for not streamed, streamed, cancelled and a permission (agent with `yolo: false`), and README EN + FR with results measured on llmman. The README compares it with plain `mm -p` from Nushell, so the reader knows when ACP is worth it.
35+ - `demo.acp.sdk/nushell/` holds the client, one example each for not streamed, streamed, cancelled and a permission (agent with `yolo: false`), and README EN + FR with results measured on llmman. The README compares it with plain `mm -p` from Nushell, so the reader knows when ACP is worth it.
3536 - Nothing changed in mm's Go code.
3637 tasks:
3738 - id: 1
@@ -82,4 +83,24 @@ tasks:
8283 name: k33g
8384 email: ph.charriere@gmail.com
8485 createdAt: 2026-10-26T06:30:00.000Z
85-comments: []
86+comments:
87+ - id: 1
88+ author:
89+ name: k33g
90+ email: ph.charriere@gmail.com
91+ createdAt: 2026-11-18T06:51:36.000Z
92+ body: |
93+ Moved v2.0.0 → v1.1.1 (user, 2026-11-18: "a ticket for a nushell
94+ client over acp" — this one, not a duplicate). Sibling: #222, the
95+ bash client, where `coproc` gives the two-way pipe this ticket's
96+ study is about. The README of demo.acp.sdk lists the folder as
97+ `demo.acp.sdk/nushell/` (not `demos/nushell-acp-client/` as written
98+ above): to settle when starting.
99+ - id: 2
100+ author:
101+ name: k33g
102+ email: ph.charriere@gmail.com
103+ createdAt: 2026-11-18T06:56:19.000Z
104+ body: |
105+ User (2026-11-18): back to v2.0.0, with #222; the folder is
106+ `demo.acp.sdk/nushell/` (body updated).
@@ -6,7 +6,7 @@ author:
6 name: k33g6 name: k33g
7 email: ph.charriere@gmail.com7 email: ph.charriere@gmail.com
8 createdAt: 2026-10-26T06:30:00.000Z8 createdAt: 2026-10-26T06:30:00.000Z
9-updatedAt: 2026-11-11T07:00:55.349Z9+updatedAt: 2026-11-18T06:56:19.000Z
10 labels:10 labels:
11 - kind::feature11 - kind::feature
12 milestone: v2.0.012 milestone: v2.0.0
@@ -14,6 +14,7 @@ epic: SDK
14 related:14 related:
15 - 16715 - 167
16 - 13916 - 139
17+ - 222
17 body: |18 body: |
18 ## Goal19 ## Goal
19 Use mm from a Nushell script with structured data (tables, records) instead of text: send a question, get the answer and the tool calls as Nushell values.20 Use mm from a Nushell script with structured data (tables, records) instead of text: send a question, get the answer and the tool calls as Nushell values.
@@ -31,7 +32,7 @@ body: |
31 - `nu` is not installed in this sandbox.32 - `nu` is not installed in this sandbox.
32 33
33 ## Done when34 ## Done when
34- - `demos/nushell-acp-client/` holds the client, one example each for not streamed, streamed, cancelled and a permission (agent with `yolo: false`), and README EN + FR with results measured on llmman. The README compares it with plain `mm -p` from Nushell, so the reader knows when ACP is worth it.35+ - `demo.acp.sdk/nushell/` holds the client, one example each for not streamed, streamed, cancelled and a permission (agent with `yolo: false`), and README EN + FR with results measured on llmman. The README compares it with plain `mm -p` from Nushell, so the reader knows when ACP is worth it.
35 - Nothing changed in mm's Go code.36 - Nothing changed in mm's Go code.
36 tasks:37 tasks:
37 - id: 138 - id: 1
@@ -82,4 +83,24 @@ tasks:
82 name: k33g83 name: k33g
83 email: ph.charriere@gmail.com84 email: ph.charriere@gmail.com
84 createdAt: 2026-10-26T06:30:00.000Z85 createdAt: 2026-10-26T06:30:00.000Z
85-comments: []86+comments:
87+ - id: 1
88+ author:
89+ name: k33g
90+ email: ph.charriere@gmail.com
91+ createdAt: 2026-11-18T06:51:36.000Z
92+ body: |
93+ Moved v2.0.0 → v1.1.1 (user, 2026-11-18: "a ticket for a nushell
94+ client over acp" — this one, not a duplicate). Sibling: #222, the
95+ bash client, where `coproc` gives the two-way pipe this ticket's
96+ study is about. The README of demo.acp.sdk lists the folder as
97+ `demo.acp.sdk/nushell/` (not `demos/nushell-acp-client/` as written
98+ above): to settle when starting.
99+ - id: 2
100+ author:
101+ name: k33g
102+ email: ph.charriere@gmail.com
103+ createdAt: 2026-11-18T06:56:19.000Z
104+ body: |
105+ User (2026-11-18): back to v2.0.0, with #222; the folder is
106+ `demo.acp.sdk/nushell/` (body updated).
modified .tickets/issues/0195-sign-the-macos-binary-of-mini-me.yaml +2 -3
@@ -1,12 +1,12 @@
11 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
22 id: 195
33 title: Sign the macOS binary of mini-me
4-state: open
4+state: closed
55 author:
66 name: k33g
77 email: ph.charriere@gmail.com
88 createdAt: 2026-11-07T05:28:39.000Z
9-updatedAt: 2026-11-07T11:16:07.000Z
9+updatedAt: 2026-11-18T07:03:06.124Z
1010 labels:
1111 - kind::chore
1212 epic: Release & distribution
@@ -122,4 +122,3 @@ comments:
122122 Measured on the Mac with `check-wasm-hardened-runtime.sh` and the Developer ID: with the hardened runtime alone, macOS kills the wasmtool tests (`Killed: 9`) at the first wasm module. Without the hardened runtime, 11/11 pass; with the hardened runtime and `com.apple.security.cs.allow-unsigned-executable-memory`, 11/11 pass.
123123
124124 Decision: sign with that entitlement ([macos-entitlements.plist](macos-entitlements.plist)), rather than switching wazero to its interpreter on macOS. It is invisible to the user, at install and at first run, and wasm keeps its speed. `local-ci-02-build.sh` signs with it and checks that the signature carries it. Notarization with the entitlement is not tried yet.
125-
@@ -1,12 +1,12 @@
1 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.1 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2 id: 1952 id: 195
3 title: Sign the macOS binary of mini-me3 title: Sign the macOS binary of mini-me
4-state: open4+state: closed
5 author:5 author:
6 name: k33g6 name: k33g
7 email: ph.charriere@gmail.com7 email: ph.charriere@gmail.com
8 createdAt: 2026-11-07T05:28:39.000Z8 createdAt: 2026-11-07T05:28:39.000Z
9-updatedAt: 2026-11-07T11:16:07.000Z9+updatedAt: 2026-11-18T07:03:06.124Z
10 labels:10 labels:
11 - kind::chore11 - kind::chore
12 epic: Release & distribution12 epic: Release & distribution
@@ -122,4 +122,3 @@ comments:
122 Measured on the Mac with `check-wasm-hardened-runtime.sh` and the Developer ID: with the hardened runtime alone, macOS kills the wasmtool tests (`Killed: 9`) at the first wasm module. Without the hardened runtime, 11/11 pass; with the hardened runtime and `com.apple.security.cs.allow-unsigned-executable-memory`, 11/11 pass.122 Measured on the Mac with `check-wasm-hardened-runtime.sh` and the Developer ID: with the hardened runtime alone, macOS kills the wasmtool tests (`Killed: 9`) at the first wasm module. Without the hardened runtime, 11/11 pass; with the hardened runtime and `com.apple.security.cs.allow-unsigned-executable-memory`, 11/11 pass.
123 123
124 Decision: sign with that entitlement ([macos-entitlements.plist](macos-entitlements.plist)), rather than switching wazero to its interpreter on macOS. It is invisible to the user, at install and at first run, and wasm keeps its speed. `local-ci-02-build.sh` signs with it and checks that the signature carries it. Notarization with the entitlement is not tried yet.124 Decision: sign with that entitlement ([macos-entitlements.plist](macos-entitlements.plist)), rather than switching wazero to its interpreter on macOS. It is invisible to the user, at install and at first run, and wasm keeps its speed. `local-ci-02-build.sh` signs with it and checks that the signature carries it. Notarization with the entitlement is not tried yet.
125-
added .tickets/issues/0222-bash-script-client-over-acp-mm-from-a-shell-scri.yaml +110 -0
new file mode 100644
@@ -0,0 +1,110 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 222
3+title: "Bash script client over ACP: mm from a shell script"
4+state: open
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-18T06:51:36.000Z
9+updatedAt: 2026-11-18T06:56:19.000Z
10+labels:
11+ - kind::feature
12+milestone: v2.0.0
13+epic: SDK
14+related:
15+ - 167
16+ - 172
17+ - 202
18+body: |
19+ Asked by the user (2026-11-18): a bash client over ACP, in v1.1.1.
20+
21+ ## Goal
22+ Use mm from a bash script over ACP: send a question, stream the answer
23+ and the tool calls, cancel, answer permissions — what `mm -p` cannot
24+ do (it gives one final answer, no stream events, no permissions, no
25+ session kept between two questions).
26+
27+ ## Shared ground
28+ Same idea as the other clients of `demo.acp.sdk/` (Node.js #167, Go
29+ #168, Kotlin #187, Node.js SDK #188): drive `mm -acp` over ACP
30+ (JSON-RPC, one message per line on stdin/stdout) with NO change to mm.
31+ The ACP mapping and the limits are in
32+ [demo.acp.sdk/README.en.md](demo.acp.sdk/README.en.md): `initialize`,
33+ `session/new {cwd}`, `session/prompt`, the `session/update`
34+ notifications (`agent_message_chunk`, `agent_thought_chunk`,
35+ `tool_call`, `tool_call_update`), `session/cancel`, answering
36+ `session/request_permission`; the `mm` binary installed, local stdio,
37+ the agent a file (`mm -acp -config <file>`).
38+
39+ ## Specific to bash
40+ - **The two-way pipe**: `coproc MM { mm -acp -config agent.yaml; }`
41+ gives `${MM[0]}` (read mm's stdout) and `${MM[1]}` (write its
42+ stdin) on ONE long-lived process — the session id from
43+ `session/new` can be reused for every `session/prompt`, and mm's
44+ own requests (`session/request_permission`) answered on the same
45+ pipe. Bash 4+ (macOS ships 3.2: Homebrew's bash, to say in the README).
46+ - **JSON**: `jq` to build the requests (`jq -nc --arg …`, never
47+ string concatenation — a question with quotes or newlines must stay
48+ valid) and to read each line (`.id`, `.method`,
49+ `.params.update.sessionUpdate`). `jq` is the one dependency.
50+ - **Reading**: one `read -r line <&"${MM[0]}"` per message; a loop
51+ that dispatches on `method` (notification / request from mm) or `id`
52+ (the answer to ours) until the prompt's answer with its `stopReason`.
53+ - **API as functions to `source`**: `mm_start <agent file> [cwd]`,
54+ `mm_complete "<question>"` (prints the joined text),
55+ `mm_stream "<question>" <callback>` (calls the callback per event:
56+ kind and text), `mm_cancel` (from a trap on Ctrl-C), a permission
57+ hook `MM_PERMISSION` (a function name; default: refuse), `mm_close`.
58+ - Logs: mm writes its banner and warnings on stderr in ACP mode —
59+ redirect it to a file, never mix it with the JSON.
60+
61+ ## Done when
62+ - `demo.acp.sdk/bash/` holds `minime.sh` and one example each: not
63+ streamed, streamed, cancelled, a permission (agent with
64+ `yolo: false`), plus README EN + FR with results measured on a real
65+ model server, and when to prefer plain `mm -p`.
66+ - A test with a fake ACP agent (a script answering the JSON-RPC lines),
67+ so the client is checked without a model.
68+ - The table in `demo.acp.sdk/README.{en,fr}.md` lists it.
69+ - Nothing changed in mm's Go code.
70+tasks:
71+ - id: 1
72+ title: Client minime.sh - coproc, jq, start (initialize + session/new), complete, stream, close
73+ state: open
74+ priority: high
75+ author:
76+ name: k33g
77+ email: ph.charriere@gmail.com
78+ createdAt: 2026-11-18T06:51:36.000Z
79+ - id: 2
80+ title: Cancel (session/cancel from a trap) and the permission hook, refuse by default
81+ state: open
82+ priority: medium
83+ author:
84+ name: k33g
85+ email: ph.charriere@gmail.com
86+ createdAt: 2026-11-18T06:51:36.000Z
87+ - id: 3
88+ title: Examples (not streamed, streamed, cancelled, permission) run on a real model server
89+ state: open
90+ priority: medium
91+ author:
92+ name: k33g
93+ email: ph.charriere@gmail.com
94+ createdAt: 2026-11-18T06:51:36.000Z
95+ - id: 4
96+ title: Test against a fake ACP agent script
97+ state: open
98+ priority: medium
99+ author:
100+ name: k33g
101+ email: ph.charriere@gmail.com
102+ createdAt: 2026-11-18T06:51:36.000Z
103+ - id: 5
104+ title: README EN + FR with measured results and limits (bash 4+, jq); demo.acp.sdk table
105+ state: open
106+ priority: medium
107+ author:
108+ name: k33g
109+ email: ph.charriere@gmail.com
110+ createdAt: 2026-11-18T06:51:36.000Z
new file mode 100644
@@ -0,0 +1,110 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 222
3+title: "Bash script client over ACP: mm from a shell script"
4+state: open
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-18T06:51:36.000Z
9+updatedAt: 2026-11-18T06:56:19.000Z
10+labels:
11+ - kind::feature
12+milestone: v2.0.0
13+epic: SDK
14+related:
15+ - 167
16+ - 172
17+ - 202
18+body: |
19+ Asked by the user (2026-11-18): a bash client over ACP, in v1.1.1.
20+
21+ ## Goal
22+ Use mm from a bash script over ACP: send a question, stream the answer
23+ and the tool calls, cancel, answer permissions — what `mm -p` cannot
24+ do (it gives one final answer, no stream events, no permissions, no
25+ session kept between two questions).
26+
27+ ## Shared ground
28+ Same idea as the other clients of `demo.acp.sdk/` (Node.js #167, Go
29+ #168, Kotlin #187, Node.js SDK #188): drive `mm -acp` over ACP
30+ (JSON-RPC, one message per line on stdin/stdout) with NO change to mm.
31+ The ACP mapping and the limits are in
32+ [demo.acp.sdk/README.en.md](demo.acp.sdk/README.en.md): `initialize`,
33+ `session/new {cwd}`, `session/prompt`, the `session/update`
34+ notifications (`agent_message_chunk`, `agent_thought_chunk`,
35+ `tool_call`, `tool_call_update`), `session/cancel`, answering
36+ `session/request_permission`; the `mm` binary installed, local stdio,
37+ the agent a file (`mm -acp -config <file>`).
38+
39+ ## Specific to bash
40+ - **The two-way pipe**: `coproc MM { mm -acp -config agent.yaml; }`
41+ gives `${MM[0]}` (read mm's stdout) and `${MM[1]}` (write its
42+ stdin) on ONE long-lived process — the session id from
43+ `session/new` can be reused for every `session/prompt`, and mm's
44+ own requests (`session/request_permission`) answered on the same
45+ pipe. Bash 4+ (macOS ships 3.2: Homebrew's bash, to say in the README).
46+ - **JSON**: `jq` to build the requests (`jq -nc --arg …`, never
47+ string concatenation — a question with quotes or newlines must stay
48+ valid) and to read each line (`.id`, `.method`,
49+ `.params.update.sessionUpdate`). `jq` is the one dependency.
50+ - **Reading**: one `read -r line <&"${MM[0]}"` per message; a loop
51+ that dispatches on `method` (notification / request from mm) or `id`
52+ (the answer to ours) until the prompt's answer with its `stopReason`.
53+ - **API as functions to `source`**: `mm_start <agent file> [cwd]`,
54+ `mm_complete "<question>"` (prints the joined text),
55+ `mm_stream "<question>" <callback>` (calls the callback per event:
56+ kind and text), `mm_cancel` (from a trap on Ctrl-C), a permission
57+ hook `MM_PERMISSION` (a function name; default: refuse), `mm_close`.
58+ - Logs: mm writes its banner and warnings on stderr in ACP mode —
59+ redirect it to a file, never mix it with the JSON.
60+
61+ ## Done when
62+ - `demo.acp.sdk/bash/` holds `minime.sh` and one example each: not
63+ streamed, streamed, cancelled, a permission (agent with
64+ `yolo: false`), plus README EN + FR with results measured on a real
65+ model server, and when to prefer plain `mm -p`.
66+ - A test with a fake ACP agent (a script answering the JSON-RPC lines),
67+ so the client is checked without a model.
68+ - The table in `demo.acp.sdk/README.{en,fr}.md` lists it.
69+ - Nothing changed in mm's Go code.
70+tasks:
71+ - id: 1
72+ title: Client minime.sh - coproc, jq, start (initialize + session/new), complete, stream, close
73+ state: open
74+ priority: high
75+ author:
76+ name: k33g
77+ email: ph.charriere@gmail.com
78+ createdAt: 2026-11-18T06:51:36.000Z
79+ - id: 2
80+ title: Cancel (session/cancel from a trap) and the permission hook, refuse by default
81+ state: open
82+ priority: medium
83+ author:
84+ name: k33g
85+ email: ph.charriere@gmail.com
86+ createdAt: 2026-11-18T06:51:36.000Z
87+ - id: 3
88+ title: Examples (not streamed, streamed, cancelled, permission) run on a real model server
89+ state: open
90+ priority: medium
91+ author:
92+ name: k33g
93+ email: ph.charriere@gmail.com
94+ createdAt: 2026-11-18T06:51:36.000Z
95+ - id: 4
96+ title: Test against a fake ACP agent script
97+ state: open
98+ priority: medium
99+ author:
100+ name: k33g
101+ email: ph.charriere@gmail.com
102+ createdAt: 2026-11-18T06:51:36.000Z
103+ - id: 5
104+ title: README EN + FR with measured results and limits (bash 4+, jq); demo.acp.sdk table
105+ state: open
106+ priority: medium
107+ author:
108+ name: k33g
109+ email: ph.charriere@gmail.com
110+ createdAt: 2026-11-18T06:51:36.000Z
added .tickets/issues/0223-llamacpp-start-llama-server-when-it-is-not-runnin.yaml +186 -0
new file mode 100644
@@ -0,0 +1,186 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 223
3+title: "llamacpp: start llama-server when it is not running, stop it with the last mm session"
4+state: open
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-18T07:13:12.000Z
9+updatedAt: 2026-11-18T07:15:06.000Z
10+labels:
11+ - kind::feature
12+milestone: v2.0.0
13+epic: Providers (LLM Engine)
14+related:
15+ - 218
16+ - 219
17+ - 61
18+body: |
19+ ## Asked (user, 2026-11-18)
20+
21+ With `provider: llamacpp`, when llama-server is not running, mm should
22+ start it — as the Llama app (llama.app, #219) does — and stop it when mm
23+ quits, **unless other mm sessions are still using it: the last one
24+ stops it**.
25+
26+ ## Today
27+
28+ - mm only checks: `nothing answers at http://127.0.0.1:9931/v1 — start
29+ it: llama-server -m <model.gguf> --jinja --port 9931 …` (start-up
30+ warning, then the first question fails).
31+ - Addresses since #218: 9931, then 8080, then host.docker.internal:9931.
32+ - `autoPull` (#61) has no download for llamacpp: "start llama-server
33+ with -hf <repo>:<quant>, or put the GGUF in the router's models
34+ directory".
35+ - Unloading (`/unload`) needs llama-server in **router mode** (started
36+ without `-m`).
37+
38+ ## Proposal (to discuss)
39+
40+ - **When:** the agent's address is a local default (no `baseUrl`, or
41+ 127.0.0.1 / localhost) and nothing answers there; never for a remote
42+ `baseUrl`, never from a container or a sandbox (the server is on the
43+ host). Opt-in or opt-out: a key such as `llamacpp: {autoStart: true}`
44+ (to decide; opt-in is safer for v2.0.0).
45+ - **How:** `llama-server --jinja --host 127.0.0.1 --port 9931` in
46+ **router mode** with the model from the agent file
47+ (`-hf <repo>:<quant>` style names download into the Hugging Face
48+ cache, shared with llama.cpp and the Llama app), or a preset / models
49+ directory; extra arguments from the file
50+ (`llamacpp.serverArgs: [-c, "32768"]`). The binary: `llama-server`
51+ on PATH, or a path in the file; a clear error when missing (how to
52+ install: brew, release archive).
53+ - **Readiness:** wait until `GET /models` (or `/health`) answers, with
54+ the spinner ("Starting llama-server…") and a timeout; the model's
55+ download/loading can be long — show progress if llama-server reports
56+ it.
57+ - **Logs:** llama-server's output to a file (e.g. `~/.cache/mm/llama-
58+ server-9931.log`), never on the terminal or the ACP stream; the error
59+ message points to it when the start fails.
60+ - **Shared server, the last session stops it:** a small registry under
61+ the user's cache dir, per address (port): the pid of the server mm
62+ started, and one lease per running mm process (its pid). On exit
63+ (normal, Ctrl-C, `/quit`, ACP close, editor reload) mm removes its
64+ lease; if no live lease remains and the server is the one mm started,
65+ it stops it (SIGTERM, then SIGKILL after a delay). Stale leases (pid
66+ gone, after a crash) are cleaned when read. A file lock guards the
67+ registry (two mm starting at once must not start two servers).
68+ - **A server mm did not start** (the user's own, the Llama app's on
69+ 9931) is never stopped.
70+ - Asked agents (`mmConfigs`, `/ask`, `ask_agent`) are mm processes
71+ too: they take a lease like any other.
72+
73+ ## Open questions
74+
75+ - Opt-in key name and default; what to do on a model change between two
76+ sessions sharing the server (router mode loads both? `--models-max`?).
77+ - Port taken by something that is not llama-server.
78+ - Windows (no SIGTERM; process groups) — in scope or not.
79+ - Interaction with the Llama app (#219), which manages its own server
80+ on 9931: detect it and leave it alone.
81+
82+ ## Acceptance criteria
83+
84+ - llamacpp agent, nothing on 9931/8080, opt-in on: mm starts
85+ llama-server, waits for it, the first question is answered; the log
86+ file holds its output.
87+ - Two mm sessions on the same agent: one server; quitting the first
88+ keeps it, quitting the last stops it. A crash of one session does not
89+ leave the server running forever (stale lease cleaned by the next mm).
90+ - A server mm did not start is never stopped.
91+ - Tests (registry, leases, stale pids, the decision to start or not)
92+ with a fake server binary; docs EN+FR (run-with-llama-cpp, configuration).
93+tasks:
94+ - id: 1
95+ title: Decide - opt-in key, server arguments (router mode, model, extra args), binary lookup
96+ state: open
97+ priority: high
98+ author:
99+ name: k33g
100+ email: ph.charriere@gmail.com
101+ createdAt: 2026-11-18T07:13:12.000Z
102+ - id: 2
103+ title: Start and wait - spawn llama-server detached, log file, readiness on /models with a timeout
104+ state: open
105+ priority: high
106+ author:
107+ name: k33g
108+ email: ph.charriere@gmail.com
109+ createdAt: 2026-11-18T07:13:12.000Z
110+ - id: 3
111+ title: Shared lifetime - registry + file lock, one lease per mm process, the last one stops the server; stale leases cleaned
112+ state: open
113+ priority: high
114+ author:
115+ name: k33g
116+ email: ph.charriere@gmail.com
117+ createdAt: 2026-11-18T07:13:12.000Z
118+ - id: 4
119+ title: Never stop a server mm did not start (the user's, the Llama app's); no start for a remote baseUrl or in a container
120+ state: open
121+ priority: medium
122+ author:
123+ name: k33g
124+ email: ph.charriere@gmail.com
125+ createdAt: 2026-11-18T07:13:12.000Z
126+ - id: 5
127+ title: Tests with a fake llama-server; docs EN+FR (run-with-llama-cpp, configuration)
128+ state: open
129+ priority: medium
130+ author:
131+ name: k33g
132+ email: ph.charriere@gmail.com
133+ createdAt: 2026-11-18T07:13:12.000Z
134+comments:
135+ - id: 1
136+ author:
137+ name: k33g
138+ email: ph.charriere@gmail.com
139+ createdAt: 2026-11-18T07:15:06.000Z
140+ body: |
141+ How the Llama app (#219) starts its server, given by the user
142+ (2026-11-18, macOS):
143+
144+ ```bash
145+ export PATH="$PATH:/opt/homebrew/bin"
146+ export GGML_METAL_NO_RESIDENCY=1
147+ export HF_HUB_CACHE=/Users/k33g/.cache/huggingface/hub
148+ export LLAMA_CACHE=/tmp/llama-empty-cache
149+
150+ /Users/k33g/.local/bin/llama serve \
151+ --models-preset '/Users/k33g/Library/Application Support/Llama/models.ini' \
152+ --log-file /Users/k33g/Library/Logs/Llama/llama-server.log \
153+ --port 9931 \
154+ --models-max 0 \
155+ --models-memory-margin 1024 \
156+ --fit-target 1024 \
157+ --sleep-idle-seconds 300 \
158+ --spec-default
159+ ```
160+
161+ What it tells for this ticket (to check against `llama serve --help`
162+ before relying on any flag):
163+
164+ - The binary is `llama serve` (the `llama` command), not
165+ `llama-server`; mm should look for both.
166+ - **Router mode with a presets file** (`--models-preset models.ini`,
167+ `[org/repo:QUANT]` sections) instead of `-m` / `-hf`: mm could
168+ write its own preset from the agent file's model, or pass the
169+ model on the command line.
170+ - **The Hugging Face cache** (`HF_HUB_CACHE`) holds the models,
171+ shared with llama.cpp and the app; `LLAMA_CACHE` points to an
172+ empty dir so llama.cpp's own cache is not used.
173+ - **Logs to a file** (`--log-file`): the same as the proposal.
174+ - **Memory**: `--models-max 0` (no fixed limit on loaded models),
175+ `--models-memory-margin 1024` and `--fit-target 1024` (fit models
176+ to the free memory, MiB) — a better default than a model count
177+ when two sessions use different models (open question above).
178+ - **`--sleep-idle-seconds 300`**: the server frees the model after
179+ 5 minutes idle, but keeps running — relevant to "the last session
180+ stops it": with this flag, a running but idle server costs little.
181+ - `--spec-default`: speculative decoding defaults (to look up).
182+ - `GGML_METAL_NO_RESIDENCY=1`: a Metal setting (macOS) — to look up
183+ before copying it.
184+ - Port 9931, the default since #218: a server the app started and a
185+ server mm would start compete for it; mm must recognise a server
186+ it did not start and leave it alone.
new file mode 100644
@@ -0,0 +1,186 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 223
3+title: "llamacpp: start llama-server when it is not running, stop it with the last mm session"
4+state: open
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-18T07:13:12.000Z
9+updatedAt: 2026-11-18T07:15:06.000Z
10+labels:
11+ - kind::feature
12+milestone: v2.0.0
13+epic: Providers (LLM Engine)
14+related:
15+ - 218
16+ - 219
17+ - 61
18+body: |
19+ ## Asked (user, 2026-11-18)
20+
21+ With `provider: llamacpp`, when llama-server is not running, mm should
22+ start it — as the Llama app (llama.app, #219) does — and stop it when mm
23+ quits, **unless other mm sessions are still using it: the last one
24+ stops it**.
25+
26+ ## Today
27+
28+ - mm only checks: `nothing answers at http://127.0.0.1:9931/v1 — start
29+ it: llama-server -m <model.gguf> --jinja --port 9931 …` (start-up
30+ warning, then the first question fails).
31+ - Addresses since #218: 9931, then 8080, then host.docker.internal:9931.
32+ - `autoPull` (#61) has no download for llamacpp: "start llama-server
33+ with -hf <repo>:<quant>, or put the GGUF in the router's models
34+ directory".
35+ - Unloading (`/unload`) needs llama-server in **router mode** (started
36+ without `-m`).
37+
38+ ## Proposal (to discuss)
39+
40+ - **When:** the agent's address is a local default (no `baseUrl`, or
41+ 127.0.0.1 / localhost) and nothing answers there; never for a remote
42+ `baseUrl`, never from a container or a sandbox (the server is on the
43+ host). Opt-in or opt-out: a key such as `llamacpp: {autoStart: true}`
44+ (to decide; opt-in is safer for v2.0.0).
45+ - **How:** `llama-server --jinja --host 127.0.0.1 --port 9931` in
46+ **router mode** with the model from the agent file
47+ (`-hf <repo>:<quant>` style names download into the Hugging Face
48+ cache, shared with llama.cpp and the Llama app), or a preset / models
49+ directory; extra arguments from the file
50+ (`llamacpp.serverArgs: [-c, "32768"]`). The binary: `llama-server`
51+ on PATH, or a path in the file; a clear error when missing (how to
52+ install: brew, release archive).
53+ - **Readiness:** wait until `GET /models` (or `/health`) answers, with
54+ the spinner ("Starting llama-server…") and a timeout; the model's
55+ download/loading can be long — show progress if llama-server reports
56+ it.
57+ - **Logs:** llama-server's output to a file (e.g. `~/.cache/mm/llama-
58+ server-9931.log`), never on the terminal or the ACP stream; the error
59+ message points to it when the start fails.
60+ - **Shared server, the last session stops it:** a small registry under
61+ the user's cache dir, per address (port): the pid of the server mm
62+ started, and one lease per running mm process (its pid). On exit
63+ (normal, Ctrl-C, `/quit`, ACP close, editor reload) mm removes its
64+ lease; if no live lease remains and the server is the one mm started,
65+ it stops it (SIGTERM, then SIGKILL after a delay). Stale leases (pid
66+ gone, after a crash) are cleaned when read. A file lock guards the
67+ registry (two mm starting at once must not start two servers).
68+ - **A server mm did not start** (the user's own, the Llama app's on
69+ 9931) is never stopped.
70+ - Asked agents (`mmConfigs`, `/ask`, `ask_agent`) are mm processes
71+ too: they take a lease like any other.
72+
73+ ## Open questions
74+
75+ - Opt-in key name and default; what to do on a model change between two
76+ sessions sharing the server (router mode loads both? `--models-max`?).
77+ - Port taken by something that is not llama-server.
78+ - Windows (no SIGTERM; process groups) — in scope or not.
79+ - Interaction with the Llama app (#219), which manages its own server
80+ on 9931: detect it and leave it alone.
81+
82+ ## Acceptance criteria
83+
84+ - llamacpp agent, nothing on 9931/8080, opt-in on: mm starts
85+ llama-server, waits for it, the first question is answered; the log
86+ file holds its output.
87+ - Two mm sessions on the same agent: one server; quitting the first
88+ keeps it, quitting the last stops it. A crash of one session does not
89+ leave the server running forever (stale lease cleaned by the next mm).
90+ - A server mm did not start is never stopped.
91+ - Tests (registry, leases, stale pids, the decision to start or not)
92+ with a fake server binary; docs EN+FR (run-with-llama-cpp, configuration).
93+tasks:
94+ - id: 1
95+ title: Decide - opt-in key, server arguments (router mode, model, extra args), binary lookup
96+ state: open
97+ priority: high
98+ author:
99+ name: k33g
100+ email: ph.charriere@gmail.com
101+ createdAt: 2026-11-18T07:13:12.000Z
102+ - id: 2
103+ title: Start and wait - spawn llama-server detached, log file, readiness on /models with a timeout
104+ state: open
105+ priority: high
106+ author:
107+ name: k33g
108+ email: ph.charriere@gmail.com
109+ createdAt: 2026-11-18T07:13:12.000Z
110+ - id: 3
111+ title: Shared lifetime - registry + file lock, one lease per mm process, the last one stops the server; stale leases cleaned
112+ state: open
113+ priority: high
114+ author:
115+ name: k33g
116+ email: ph.charriere@gmail.com
117+ createdAt: 2026-11-18T07:13:12.000Z
118+ - id: 4
119+ title: Never stop a server mm did not start (the user's, the Llama app's); no start for a remote baseUrl or in a container
120+ state: open
121+ priority: medium
122+ author:
123+ name: k33g
124+ email: ph.charriere@gmail.com
125+ createdAt: 2026-11-18T07:13:12.000Z
126+ - id: 5
127+ title: Tests with a fake llama-server; docs EN+FR (run-with-llama-cpp, configuration)
128+ state: open
129+ priority: medium
130+ author:
131+ name: k33g
132+ email: ph.charriere@gmail.com
133+ createdAt: 2026-11-18T07:13:12.000Z
134+comments:
135+ - id: 1
136+ author:
137+ name: k33g
138+ email: ph.charriere@gmail.com
139+ createdAt: 2026-11-18T07:15:06.000Z
140+ body: |
141+ How the Llama app (#219) starts its server, given by the user
142+ (2026-11-18, macOS):
143+
144+ ```bash
145+ export PATH="$PATH:/opt/homebrew/bin"
146+ export GGML_METAL_NO_RESIDENCY=1
147+ export HF_HUB_CACHE=/Users/k33g/.cache/huggingface/hub
148+ export LLAMA_CACHE=/tmp/llama-empty-cache
149+
150+ /Users/k33g/.local/bin/llama serve \
151+ --models-preset '/Users/k33g/Library/Application Support/Llama/models.ini' \
152+ --log-file /Users/k33g/Library/Logs/Llama/llama-server.log \
153+ --port 9931 \
154+ --models-max 0 \
155+ --models-memory-margin 1024 \
156+ --fit-target 1024 \
157+ --sleep-idle-seconds 300 \
158+ --spec-default
159+ ```
160+
161+ What it tells for this ticket (to check against `llama serve --help`
162+ before relying on any flag):
163+
164+ - The binary is `llama serve` (the `llama` command), not
165+ `llama-server`; mm should look for both.
166+ - **Router mode with a presets file** (`--models-preset models.ini`,
167+ `[org/repo:QUANT]` sections) instead of `-m` / `-hf`: mm could
168+ write its own preset from the agent file's model, or pass the
169+ model on the command line.
170+ - **The Hugging Face cache** (`HF_HUB_CACHE`) holds the models,
171+ shared with llama.cpp and the app; `LLAMA_CACHE` points to an
172+ empty dir so llama.cpp's own cache is not used.
173+ - **Logs to a file** (`--log-file`): the same as the proposal.
174+ - **Memory**: `--models-max 0` (no fixed limit on loaded models),
175+ `--models-memory-margin 1024` and `--fit-target 1024` (fit models
176+ to the free memory, MiB) — a better default than a model count
177+ when two sessions use different models (open question above).
178+ - **`--sleep-idle-seconds 300`**: the server frees the model after
179+ 5 minutes idle, but keeps running — relevant to "the last session
180+ stops it": with this flag, a running but idle server costs little.
181+ - `--spec-default`: speculative decoding defaults (to look up).
182+ - `GGML_METAL_NO_RESIDENCY=1`: a Metal setting (macOS) — to look up
183+ before copying it.
184+ - Port 9931, the default since #218: a server the app started and a
185+ server mm would start compete for it; mm must recognise a server
186+ it did not start and leave it alone.