samagotchi 0.193.0 → 0.194.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -1
  3. data/docs/bundle-authoring.md +1 -1
  4. data/docs/bundles.md +37 -12
  5. data/docs/cli.md +26 -10
  6. data/docs/configuration.md +71 -5
  7. data/docs/desktop.md +3 -0
  8. data/docs/guardrails.md +11 -1
  9. data/docs/hooks.md +1 -0
  10. data/docs/internals/engine.md +46 -3
  11. data/docs/internals/panes.md +66 -0
  12. data/docs/internals/peers.md +101 -5
  13. data/docs/internals/prompt-caching.md +4 -0
  14. data/docs/internals/session-lifecycle.md +9 -2
  15. data/docs/internals/web-frontend.md +16 -4
  16. data/docs/peers.md +79 -5
  17. data/docs/plugins.md +42 -4
  18. data/docs/sessions.md +15 -6
  19. data/docs/sub-agent.md +6 -4
  20. data/docs/system-one.md +4 -0
  21. data/docs/testing.md +3 -0
  22. data/lib/samagotchi/bridge/card_store.rb +1 -1
  23. data/lib/samagotchi/broadcast/triage_model.rb +17 -0
  24. data/lib/samagotchi/bundles/claude-peer/manifest.yml +8 -5
  25. data/lib/samagotchi/bundles/claude-peer/plugin.rb +24 -5
  26. data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +28 -7
  27. data/lib/samagotchi/bundles/claude-peer/scripts/pair +31 -8
  28. data/lib/samagotchi/bundles/codex-peer/manifest.yml +8 -5
  29. data/lib/samagotchi/bundles/codex-peer/plugin.rb +62 -6
  30. data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +23 -2
  31. data/lib/samagotchi/bundles/codex-peer/scripts/pair +28 -7
  32. data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
  33. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  34. data/lib/samagotchi/chi_invocation.rb +7 -0
  35. data/lib/samagotchi/client.rb +18 -0
  36. data/lib/samagotchi/codex_rollout.rb +93 -0
  37. data/lib/samagotchi/config.rb +15 -6
  38. data/lib/samagotchi/effective_model.rb +28 -2
  39. data/lib/samagotchi/engine/cards.rb +9 -4
  40. data/lib/samagotchi/engine/hooks.rb +8 -0
  41. data/lib/samagotchi/engine/models.rb +180 -7
  42. data/lib/samagotchi/engine/side_requests.rb +72 -13
  43. data/lib/samagotchi/engine/toolkit.rb +1 -1
  44. data/lib/samagotchi/engine/turn_helpers.rb +1 -1
  45. data/lib/samagotchi/engine.rb +11 -8
  46. data/lib/samagotchi/engine_snapshots.rb +16 -3
  47. data/lib/samagotchi/events.rb +1 -0
  48. data/lib/samagotchi/hooks.rb +3 -1
  49. data/lib/samagotchi/host_registry.rb +146 -16
  50. data/lib/samagotchi/idle_client.rb +13 -2
  51. data/lib/samagotchi/idle_recap.rb +33 -3
  52. data/lib/samagotchi/idle_target.rb +27 -7
  53. data/lib/samagotchi/llm/adapter_common.rb +4 -2
  54. data/lib/samagotchi/llm/anthropic_messages.rb +3 -2
  55. data/lib/samagotchi/llm/errors.rb +35 -4
  56. data/lib/samagotchi/llm/model_listing.rb +19 -0
  57. data/lib/samagotchi/llm/openai_chat.rb +3 -2
  58. data/lib/samagotchi/model_binding.rb +46 -4
  59. data/lib/samagotchi/model_catalog.rb +68 -8
  60. data/lib/samagotchi/model_profile.rb +35 -0
  61. data/lib/samagotchi/models_command.rb +8 -4
  62. data/lib/samagotchi/panes/kitty.rb +122 -0
  63. data/lib/samagotchi/panes.rb +185 -0
  64. data/lib/samagotchi/peer_announce.rb +245 -0
  65. data/lib/samagotchi/peer_command.rb +97 -11
  66. data/lib/samagotchi/peer_continue.rb +10 -0
  67. data/lib/samagotchi/peer_mailbox.rb +30 -7
  68. data/lib/samagotchi/peer_pair_here.rb +149 -0
  69. data/lib/samagotchi/peer_presence.rb +434 -0
  70. data/lib/samagotchi/peer_say.rb +17 -10
  71. data/lib/samagotchi/peer_wait_expiry.rb +47 -0
  72. data/lib/samagotchi/plugin/api.rb +12 -1
  73. data/lib/samagotchi/plugin/card.rb +68 -11
  74. data/lib/samagotchi/plugin/context.rb +20 -1
  75. data/lib/samagotchi/plugin/panes.rb +54 -0
  76. data/lib/samagotchi/plugin/peer.rb +52 -10
  77. data/lib/samagotchi/plugin/peer_pairing.rb +290 -0
  78. data/lib/samagotchi/plugin/peer_start.rb +301 -0
  79. data/lib/samagotchi/plugin/peer_start_hook.rb +207 -0
  80. data/lib/samagotchi/plugin/peers.rb +76 -3
  81. data/lib/samagotchi/recap_setup.rb +40 -3
  82. data/lib/samagotchi/self_report.rb +25 -6
  83. data/lib/samagotchi/send_command.rb +6 -6
  84. data/lib/samagotchi/served_lookup.rb +225 -0
  85. data/lib/samagotchi/served_ref.rb +41 -0
  86. data/lib/samagotchi/session_access/contract.rb +6 -0
  87. data/lib/samagotchi/session_access/local.rb +54 -6
  88. data/lib/samagotchi/session_access/remote.rb +4 -4
  89. data/lib/samagotchi/session_access/remote_peers.rb +7 -4
  90. data/lib/samagotchi/session_commands.rb +40 -8
  91. data/lib/samagotchi/session_continue.rb +6 -2
  92. data/lib/samagotchi/session_lifecycle/allowed.rb +4 -2
  93. data/lib/samagotchi/session_manager/delivery.rb +5 -0
  94. data/lib/samagotchi/session_manager/lifecycle.rb +58 -7
  95. data/lib/samagotchi/session_manager/removal.rb +3 -0
  96. data/lib/samagotchi/session_model_settings.rb +7 -3
  97. data/lib/samagotchi/session_stores.rb +9 -0
  98. data/lib/samagotchi/sessions_command.rb +16 -3
  99. data/lib/samagotchi/system_one/http_backend.rb +111 -10
  100. data/lib/samagotchi/system_prompt.rb +11 -4
  101. data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -1
  102. data/lib/samagotchi/terminal_ui/formatting.rb +26 -12
  103. data/lib/samagotchi/terminal_ui/status_row.rb +20 -3
  104. data/lib/samagotchi/terminal_ui.rb +1 -1
  105. data/lib/samagotchi/testing/bundle.rb +6 -2
  106. data/lib/samagotchi/turn_endings.rb +6 -2
  107. data/lib/samagotchi/user_typed.rb +29 -0
  108. data/lib/samagotchi/version.rb +1 -1
  109. data/lib/samagotchi/web/app.rb +8 -20
  110. data/lib/samagotchi/web/participant_review.rb +1 -1
  111. data/lib/samagotchi/web/participant_view.rb +1 -1
  112. data/lib/samagotchi/web/peer_routes.rb +33 -13
  113. data/lib/samagotchi/web/public/app.js +1 -1
  114. data/lib/samagotchi/web/public/card.js +26 -10
  115. data/lib/samagotchi/web/public/context_chips.js +24 -2
  116. data/lib/samagotchi/web/public/copy.js +8 -2
  117. data/lib/samagotchi/web/public/data.js +2 -1
  118. data/lib/samagotchi/web/public/format.js +9 -1
  119. data/lib/samagotchi/web/public/index.html +18 -0
  120. data/lib/samagotchi/web/public/info_bar_model.js +1 -1
  121. data/lib/samagotchi/web/public/model_pick.js +18 -5
  122. data/lib/samagotchi/web/public/model_picker.js +1 -1
  123. data/lib/samagotchi/web/public/peer_chip.js +15 -5
  124. data/lib/samagotchi/web/public/peer_data.js +4 -2
  125. data/lib/samagotchi/web/public/peer_wait.js +36 -0
  126. data/lib/samagotchi/web/public/served_ref.js +9 -0
  127. data/lib/samagotchi/web/public/session_fields.js +1 -0
  128. data/lib/samagotchi/web/public/session_state.js +4 -0
  129. data/lib/samagotchi/web/public/stage_missing.js +23 -6
  130. data/lib/samagotchi/web/public/stream_handlers.js +16 -0
  131. data/lib/samagotchi/web/public/version_notices.js +7 -1
  132. data/lib/samagotchi/web/session_control.rb +19 -10
  133. data/lib/samagotchi/web/session_show.rb +20 -0
  134. data/lib/samagotchi/web/update_ops.rb +2 -2
  135. data/lib/samagotchi/worker/command_queue.rb +3 -0
  136. data/lib/samagotchi/worker/mail.rb +14 -1
  137. data/lib/samagotchi/worker.rb +1 -0
  138. metadata +18 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8b387ef3705f02f31f8b543fc8d85e763a9553ceb2740b4d45df6783fbc7d16
4
- data.tar.gz: 149c444f36be679f218eab0f31552129675cac92d0af19f874a6398e2d3e71fb
3
+ metadata.gz: cd9df1796b9a6819a4c332ecf68acd9fe6334d8d7e0fd0b1569c1379ada2d2c9
4
+ data.tar.gz: 00e00dcf029423a9e49b1f112926f687a7e5cdc1cac9033d4ec89d21591b1063
5
5
  SHA512:
6
- metadata.gz: d4cb3bcfa83d458e9123a25dfe3ea96d10714e7553f397a8198459340b75a01ef754df95dad13d942f0ef14b1306bfee89574b6a80a63ae96cf3f0eecb018dae
7
- data.tar.gz: f52b92219301a36ff951369ccad3acdb966351fc03094f911549dbf94917a32ecfd231e140617463e4b7972ef88ed4260519db0e1d99405cef44e28c6757659f
6
+ metadata.gz: 56e89c0f06cfd5906f5fbfb0ac1e2a8b5b6aa17a68a19b6b22e26529c716e108863cacbc40d39ea4272bdbba33f9417164384f67e3e8e72f1b339d379de125c0
7
+ data.tar.gz: 558295c0be257d570772bc54de08203acefc55538c237af46e79dca5f2d55ead84ce1e79489cd90a4060b18d8b5fc25e0ae0d8b9a526704fd5b4065be207e3c3
data/CHANGELOG.md CHANGED
@@ -8,6 +8,81 @@ and commands may change between minor versions. How releases are made:
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.194.0] - 2026-11-29
12
+
13
+ ### Added
14
+
15
+ - Pairing chi with Claude Code without copying an id: `/claude pair` pairs the one Claude Code session open in the
16
+ project, else waits 10 minutes (the next Claude you start pairs on its own) and lists them, each with Show (its
17
+ kitty window to the front) and Pair; in Claude, "pair with chi" with no id pairs the session that waits, else
18
+ the project's one live session (a session paired with another open Claude is refused: unpair there first). A
19
+ `/claude pair` whose paired Claude is gone (its socket missing) ends that pairing and says so. The waiting chip
20
+ counts down and has Cancel; a wait that runs out says so in one line. With claude-peer's start hook (the skill
21
+ card's **Add the start hook…** shows the merged settings as a diff; its Add merges it into Claude Code's
22
+ settings.json on your tap) a `claude --resume` or `/clear` keeps the pairing. `/codex pair` waits for "pair with
23
+ chi" in Codex. New: `chi peer announce`, `chi peer pair --here`, `--peer-session`. Update with `chi update`
24
+ (claude-peer, codex-peer).
25
+ - `/claude start`: chi opens a background kitty tab titled `claude · chi <id8>` in the session's folder, running
26
+ Claude Code, which pairs on its own when it starts (it needs the start hook and kitty's remote control,
27
+ `kitty.listen_on`; the command is the new setting `bundles: claude-peer: start_command:`, default `claude`). `/claude`
28
+ then says "Paired · started by chi" with Show (`/claude show`), and "Its kitty tab is closed" with Start one in kitty
29
+ after; the chip reads "Claude · ended" once the paired Claude is gone. `/codex start` opens Codex the same way with the first prompt "pair with chi" (one Codex turn). Both run only
30
+ from your typing or tap (no tool call, `chi send`, agent, schedule or delegate reaches them). Update with `chi update` (claude-peer, codex-peer).
31
+ - codex-peer's start hook: the `/codex install-skill` card's **Add the start hook…** shows the merged
32
+ `~/.codex/hooks.json` (or `$CODEX_HOME`'s) as a diff, and its Add appends `chi peer announce codex` there on your tap
33
+ (never `config.toml`, every other hook kept in its place). With it, a new Codex in the project pairs with a session
34
+ that waits (`/codex pair`, `/codex start`) at its first message, whatever it says; a `codex exec` or a resume never
35
+ takes the wait (chi reads the session's rollout, checked on Codex 0.172.0), and a Codex subagent should not (untested:
36
+ the check fails closed unless its `thread_source` and `originator` match); a `/new` likely takes it, as a new window
37
+ does. Codex asks you to review
38
+ the hook at its next start (Review hooks, or `/hooks`) and skips it until you trust it; a `/codex start` tab stops
39
+ on that screen the first time (Show it). "pair with chi" in a Codex already paired says paired, even with two live
40
+ chi sessions in the project. Update with `chi update` (codex-peer).
41
+ - Plugins: `ctx.card(rows:)` (a list to pick from, each row with its own buttons), `ctx.peers.pair`, `here`,
42
+ `wait`, `claim`, `stop_waiting`, `ctx.panes` (`find`, `show`, and `open`, `alive?`, `paste` for a background kitty
43
+ tab, only under the user-typed seam), `ctx.user_typed?` and the `:peer_wait_ended` event.
44
+ - A model can be `host:served` (`main:served`; a bare `served` is the default host's): the one model the host's
45
+ `/v1/models` lists now. A session saves `served`, so it and its schedules follow when you load another model;
46
+ each turn names the model it ran on, and a change says `host main now serves Y (was X)`. Settings, notes, prices
47
+ and guardrails go by the model that runs. A host listing none or several refuses it. An alias named `served` is
48
+ ignored. Upgrade every chi that shares your config.yml before writing `served` into it: an older chi sends
49
+ `served` as a model id.
50
+ - `system_one.model: served` judges with whatever `system_one.host` serves now; a judgment the host refuses as not
51
+ served is asked again once with the model it lists. Approvals' clean record stays as it is across a change (as
52
+ after a hand edit), and each change logs `system_one_model_changed`. An older chi with `system_one.model: served`
53
+ gets no judgment at all (every approval goes to you), with only a log line saying why.
54
+ - `recap.model`, `broadcast.triage_model` and `ctx.ask_model(model:)` (btw, block fixes, the objectives' check)
55
+ take `served` too, and the session's own served model is followed between turns: each asks the model the host
56
+ lists now. A recap or `ctx.ask_model` the host refuses as not served is asked once more with the new one; a
57
+ broadcast lists the host just before it asks. A `recap.model: main:served` is no longer resolved once at start.
58
+ - chi web's model picker, `chi models` and `/models` offer `host:served` for a host serving one model, as that
59
+ host's first row (`served`, now `<id>`; `chi models --format json` marks it `served: true`), and a served session
60
+ shows the id it runs on: `served · <id>` in the info bar, `model=main:served·<id>` in the status row,
61
+ `main:served → <id>` in `/model` and `chi self`, a `model:` line in `/stats`. A worker from before this release
62
+ shows `main:served` as it is until it restarts.
63
+
64
+ ### Changed
65
+
66
+ - A turn refused because its model isn't served names the model the host serves now and how to follow it
67
+ (`; host main serves Y now: /model main:served follows it`); nothing switches on its own.
68
+ - `kitty.listen_on` and `kitty.binary` are read live by the worker too (claude-peer's Show), besides the desktop
69
+ helper's copy.
70
+
71
+ - A stopped session's refusals say how to start it again: an agent's `chi sessions restart` and `chi send` on a stopped
72
+ session end "ask your user to start it: `chi --resume ID`, or a message from a terminal or the web", and a peer's
73
+ say reads `chi is stopped: it reads this when its user starts it (chi --resume <id8>)` (with `--remote`,
74
+ `chi --remote NAME --resume …`). The rule is the same: only the owner's message starts a stopped session.
75
+ - `chi sessions restart` and the web's Restart start a stopped session again (one being stopped, once its stop
76
+ finishes); an agent's restart still asks its user, and chi web's restart after an update leaves stopped sessions
77
+ stopped.
78
+
79
+ ### Fixed
80
+
81
+ - Web: a `chi-ui` block chi couldn't draw no longer stays on "asking for a fix…" when the fix fails: it says "a fix
82
+ didn't help", and its Ask in chat puts the sentence in the composer again (it did nothing).
83
+
84
+ Update with `chi update` (claude-peer 0.9.0, codex-peer 0.8.0, the dev profile 0.7.12).
85
+
11
86
  ## [0.193.0] - 2026-11-29
12
87
 
13
88
  ### Added
@@ -7074,7 +7149,8 @@ and long-lived sessions.
7074
7149
  - A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
7075
7150
  hotkey panel that send selected text or the clipboard to your sessions.
7076
7151
 
7077
- [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.193.0...HEAD
7152
+ [Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.194.0...HEAD
7153
+ [0.194.0]: https://github.com/dm1try/samagotchi/compare/v0.193.0...v0.194.0
7078
7154
  [0.193.0]: https://github.com/dm1try/samagotchi/compare/v0.192.0...v0.193.0
7079
7155
  [0.192.0]: https://github.com/dm1try/samagotchi/compare/v0.191.0...v0.192.0
7080
7156
  [0.191.0]: https://github.com/dm1try/samagotchi/compare/v0.190.1...v0.191.0
@@ -64,7 +64,7 @@ value of another type is refused) is read from `ctx.settings` at call time. List
64
64
 
65
65
  `chi.on(event) { |event, ctx| … }` gets a Hash. The events, in a turn's order: `session_start`, `before_turn`,
66
66
  `before_generation`, `generation_progress`, `after_generation`, `before_tool_call`, `question_asked`, `after_tool_call`,
67
- `after_turn`, `session_end` (the fields of each: [hooks.md, Hook Events](hooks.md#hook-events)). A symbol not in
67
+ `after_turn`, `session_end`, between turns `peer_wait_ended` (fields: [hooks.md](hooks.md#hook-events)). A symbol not in
68
68
  that list is never fired (`check` warns). The two a bundle wants most, for an `execute`:
69
69
 
70
70
  ```ruby
data/docs/bundles.md CHANGED
@@ -1120,7 +1120,13 @@ validate or as context, and Claude's answer comes back into chi. This is
1120
1120
  Claude with the context it has, not a fresh review run. Nothing runs until a
1121
1121
  Claude pairs; without one the bundle costs one tool declaration.
1122
1122
 
1123
- - **Pairing is Claude's.** chi can't see Claude's inbox, so Claude pairs:
1123
+ - **Pairing:** `/claude pair` in chi, or "pair with chi" in Claude, no id copied ([peers.md](peers.md#pairing)).
1124
+ `/claude pair` pairs the one Claude Code session open in this project, else waits 10 minutes and lists them
1125
+ (a row each, its kitty window's title, folder and age, with Show and Pair); `/claude pair <id8>` pairs a row,
1126
+ `/claude show <id8>` brings its window to the front (only from your typing or tap), `/claude unpair` ends the
1127
+ pairing or the wait. `/claude start` opens a background kitty tab running Claude Code (the setting
1128
+ `start_command`, default `claude`), which pairs when it starts; `/claude show` alone brings that tab to the front
1129
+ ([peers.md](peers.md#pairing)). Claude lists itself with the start hook (step 1). Either way the pairing is one
1124
1130
  `chi peer pair claude <id> --address <socket>`, the address being its
1125
1131
  per-session inbox socket (`CLAUDE_CODE_MESSAGING_SOCKET`, Claude Code
1126
1132
  2.1.224 or later); its answers come back as messages in the session's
@@ -1134,10 +1140,16 @@ Claude pairs; without one the bundle costs one tool declaration.
1134
1140
  guardrail sees it: the button is your consent. The card also offers the
1135
1141
  Claude Code permission rule `Read(~/.local/state/samagotchi/plugins/claude-peer/**)`
1136
1142
  (your state folder), so Claude isn't asked before reading a long part's
1137
- file; chi never writes Claude's settings.
1138
- 2. In Claude Code you say "pair with chi <id or chi web URL>". The skill runs
1139
- `sh <bundle>/scripts/pair <id or URL>`, one `chi peer pair`. A re-pair
1140
- after a Claude restart only refreshes the socket; Claude's messages stay.
1143
+ file. Its **Add the start hook…** (`/claude install-hook`) shows the merged settings as a diff, and that card's
1144
+ **Add the start hook** (`/claude install-hook --yes`) merges one `SessionStart` hook, `[
1145
+ "$CLAUDE_CODE_SESSION_ATTENDED" = 1 ] && <chi> peer announce claude 2>/dev/null || true`, into
1146
+ `$CLAUDE_CONFIG_DIR/settings.json` (else `~/.claude/settings.json`), every other key kept, its mode kept, and
1147
+ a symlinked settings.json written at the file it points to (the link stays);
1148
+ chi never changes Claude's settings without that tap (not from
1149
+ a tool call or `chi send`). The status card says when the hook points at a chi that is gone.
1150
+ 2. In Claude Code you say "pair with chi" (an id or chi web URL when several chi sessions run in the project).
1151
+ The skill runs `sh <bundle>/scripts/pair [<id or URL>]`, one `chi peer pair`. With the start hook a Claude
1152
+ restart or `/clear` keeps the pairing; without it, pair again after a restart. Claude's messages stay.
1141
1153
  3. Claude answers a validate or a question with `chi peer say claude <id>
1142
1154
  --wake --re <the ref: line> --summary … --wait 8`, which wakes chi, and
1143
1155
  quotes to you the line it prints (`#12 received · woke chi`, or why chi
@@ -1184,13 +1196,15 @@ Claude pairs; without one the bundle costs one tool declaration.
1184
1196
  validate or question; one that answers no send has no link back. A `/claude validate …` you type gets no link in the
1185
1197
  conversation (command bubbles aren't kept), its answer still names it.
1186
1198
  - **The session bar** has one chip for the pairing, `Claude · …`, first among
1187
- the context chips, fed by chi web's `GET …/peers` (the mailbox): `paired`;
1199
+ the context chips, fed by chi web's `GET …/peers` (the mailbox): `ended` first, once the paired Claude is gone
1200
+ (its inbox socket missing, which chi web checks on each read; its status card, from the popover's Status card,
1201
+ has Start one in kitty and Unpair); `paired`;
1188
1202
  `waiting 2m` (a validate or question has no answer yet, its age the send's);
1189
1203
  `answered 3m` with the unread dot (a message no turn has read yet: held or
1190
1204
  noted);
1191
1205
  `can't send` (the last send didn't go through: the Claude session ended or
1192
- restarted, pair again from Claude, which ends it; chi web can't probe the
1193
- socket, so a dead inbox shows only after a send hits it); `answers only`,
1206
+ restarted, pair again from Claude, which ends it: a socket that is there but
1207
+ refuses shows only after a send hits it); `answers only`,
1194
1208
  dashed (a pairing with no address: through a remote). Its popover (a bottom
1195
1209
  sheet on a phone) says where chi sends and how it answers, lists the last
1196
1210
  exchanges (time, kind · title or a message's `#N · summary`, `waiting 2m` /
@@ -1390,7 +1404,7 @@ skill install card, the web's linked send and answer: "Codex answered") works th
1390
1404
  (absolute: config.toml doesn't expand `~`), `--yes` makes the folder so the
1391
1405
  root exists when Codex restarts, and the pair script names the line when a
1392
1406
  write is refused ("Operation not permitted"). chi never edits Codex's
1393
- config. Reading a payload file needs nothing: the default sandbox reads
1407
+ config.toml. Reading a payload file needs nothing: the default sandbox reads
1394
1408
  anywhere. With chi on this machine no network is needed: a say writes
1395
1409
  files, and chi wakes on them (a stopped worker can't be started from inside
1396
1410
  the sandbox: the say says so, and chi reads the message at its next start). Through a remote it is the other way
@@ -1399,9 +1413,20 @@ skill install card, the web's linked send and answer: "Codex answered") works th
1399
1413
  bundle's `scripts/chi-peer-SKILL.md` to
1400
1414
  `$CODEX_HOME/skills/chi-peer/SKILL.md` (else `~/.codex/…`), with the
1401
1415
  installed `scripts/pair` path, the payload folder and the writable root
1402
- written in; in Codex you say "pair with chi <id or chi web URL>", and
1403
- `sh <bundle>/scripts/pair` runs `chi peer pair codex <id> --address
1404
- <thread id>` (a re-pair refreshes it). Run outside Codex (no
1416
+ written in; in Codex you say "pair with chi" (with an id or chi web URL
1417
+ when several chi sessions run in the project), and `sh <bundle>/scripts/pair`
1418
+ runs `chi peer pair codex [<id>|--here] --address <thread id> --peer-session <thread id>` (a re-pair
1419
+ refreshes it). `/codex pair` makes the chi session wait 10 minutes for
1420
+ that; Codex doesn't list itself, so there is no list and no Show. `/codex start` opens Codex in a background
1421
+ kitty tab (the setting `start_command`, default `codex`) with the first prompt "pair with chi": one Codex turn,
1422
+ with or without the start hook. The card's **Add the start hook…** (`/codex install-hook`) shows the merged
1423
+ `$CODEX_HOME/hooks.json` (else `~/.codex/hooks.json`) as a diff, and that card's **Add the start hook**
1424
+ (`/codex install-hook --yes`, only on your tap: not from a tool call or `chi send`) appends one `SessionStart`
1425
+ group, `<chi> peer announce codex 2>/dev/null || true`, every other hook kept in its place; never `config.toml`.
1426
+ With it, a new interactive Codex in the project pairs with a waiting session at its first message (never a
1427
+ `codex exec` or a resume; a subagent should not, untested), and the skill's "pair with chi" then says paired. Codex asks you to review
1428
+ the hook at its next start (Review hooks, or `/hooks`) and skips it until you trust it; a `/codex start` tab
1429
+ stops on that screen the first time (Show it). See [peers.md](peers.md) (Codex's start hook). Run outside Codex (no
1405
1430
  `CODEX_THREAD_ID`) it refuses. Codex replies with `chi peer say codex <id>
1406
1431
  --wake --re <the ref: line> --summary … --wait 8` and quotes the line to
1407
1432
  you. The note holds the message's text as claude-peer's does, and Codex can
data/docs/cli.md CHANGED
@@ -22,7 +22,7 @@
22
22
  - `chi note [--source NAME] [-m TEXT] (ID|PREFIX)... | --all` — add a context note (TEXT or stdin) to sessions: background the model sees on its next turn; it starts no turn (see [Sessions: Context notes](sessions.md#context-notes))
23
23
  - `chi broadcast [-m TEXT] [--all] [--dry-run]`, `chi broadcast log [--last N] [--format json]`, `chi broadcast deliver BROADCAST_ID (ID|PREFIX)...` — share one piece of information (TEXT or stdin) with every session it may concern, as a context note from `broadcast` (see [Broadcast](broadcast.md))
24
24
  - `chi context <add|push|ls|show|refresh|rm|mute|unmute> …` — attach live external text to sessions (a command chi runs every so often, or text pushed in); the model gets a short note when it changes and reads it with `context_read`; `chi context add <URL>` attaches a GitHub PR with the github-pr bundle; `chi context push NAME -m TEXT` (the long form is `--message TEXT`) gives a `--push` source its new text, read from stdin when no `-m` is given (see [Attached context](context.md))
25
- - `chi peer pair|unpair|say|ls …` — a peer agent's side of a session (a Claude Code or Codex session paired with it; see [Peers](peers.md)): `pair NAME ID [--address ADDR] [--from TEXT]` pairs (a continued session's chain's live link, named; refused for a live worker older than the mailbox: restart it), `unpair NAME ID` ends the pairing (its messages stay), `say NAME ID (--wake|--nowake) [--summary TEXT] [--re REF] [-m TEXT] [--wait SECONDS]` leaves a message and prints what chi did with it (`#12 received · woke chi`, `held: … · waits for the user's next message`, `noted`, or why it can't say yet), `ls ID [--format json]` the session's peers, their messages and receipts. A refusal exits 1 (nothing written), a usage error 2; `--remote` runs it through that machine's chi web, which waits for the say
25
+ - `chi peer pair|unpair|say|ls …` — a peer agent's side of a session (a Claude Code or Codex session paired with it; see [Peers](peers.md)): `pair NAME ID [--address ADDR] [--from TEXT] [--peer-session ID]` pairs (a continued session's chain's live link, named; refused for a live worker older than the mailbox: restart it; `--peer-session`: the peer's own session id, which a resume refreshes by), `pair NAME --here --address ADDR …` pairs with no id (the session that waits for NAME in this folder's project, else the project's live session paired with this peer already, by its peer session or this address (said paired, nothing written), else the project's one live session, else exit 1 with the candidates; a session paired with another peer already, or one another pairing is taking now, exits 1 too: `--here` never replaces a pairing; this machine only), `announce NAME` is a peer's start hook: `announce claude` Claude Code's (lists this Claude here from the hook's stdin and `CLAUDE_*` env, refreshes its pairings, takes a waiting session), `announce codex` Codex's (from the hook's stdin alone: a fresh interactive Codex, read from its rollout's first line, takes the waiting session; a `codex exec`, a resume or a subagent never does); it prints only lines for the peer's start context, exit 0 always; this machine only, `unpair NAME ID` ends the pairing (its messages stay), `say NAME ID (--wake|--nowake) [--summary TEXT] [--re REF] [-m TEXT] [--wait SECONDS]` leaves a message and prints what chi did with it (`#12 received · woke chi`, `held: … · waits for the user's next message`, `noted`, or why it can't say yet), `ls ID [--format json]` the session's peers, their messages and receipts. A refusal exits 1 (nothing written), a usage error 2; `--remote` runs it through that machine's chi web, which waits for the say
26
26
  - `chi context report [--days N]` — the candidate judge's counts from `context_candidates.jsonl`: candidates proposed, mentioned, attached or declined by you; the judge's asks; what it would attach per threshold, and how that agrees with what you did (this machine only; see [The log and the report](context.md#the-log-and-the-report))
27
27
  - `chi send [-m TEXT] [--image PATH]... [--cut | --queue] [--as NAME] (ID|PREFIX)...` — send a message to sessions as if typed there (from an agent, as that agent: `--as NAME` or its marker, see [An agent's messages](sub-agent.md#an-agents-messages-driver-and-visitor); `--new --driver NAME` names a new session's driver): a turn starts (or a running one takes it at its next step; `--cut` asks it to cut long thinking for it; `--queue` runs it as a turn of its own after the running one, and `--queue --wait` waits for that turn's own answer); piped stdin goes above `-m` as quoted context, and `--image` attaches images (see [Sessions: Sending a message](sessions.md#sending-a-message)); to a session that was continued it goes to its chain's newest link (`3f9a1c2e → 7b2d41aa (continued) sent`; the old link stays archived; one being continued right now waits up to 10 s for its new link, then `refused: session 3f9a1c2e is being continued as 7b2d41aa-…; send again in a moment`), so a chain's first id is a stable address; `--new` starts a session with it instead (`--new --continues ID|last:ID` the next link of that session's chain, see [Session chains](sessions.md#session-chains)), and `--wait` prints the answer (`--wait ID` with no message waits for the next reply without sending — to an idle session whose last turn already ended, that ended turn's reply or end comes back; `--wait --turn T ID` with no message waits for exactly turn T, whether running, queued or last ended; `--format json` includes its `turn_id` when known, for waiting again after exit 3 or 4; exit 3 a question waits, its options on stderr; exit 4 `--timeout` passed with the turn still running; see [Starting a session](sessions.md#starting-a-session))
28
28
  - `chi answer ID --question QID (--option N|LABEL)... [--text T] [--timeout S] [--format json]` (or `--dismiss`) — answer the question a session waits on (the one `chi send --wait` exited 3 with), then wait and print what comes next as `chi send --wait` does: the reply (0), the next question (3), still running after `--timeout` (4). `--option` is 1-based or the label, repeated on a multi-select question; `--text` is free text, or a Deny's reason; `--dismiss` leaves it unanswered and the model finishes its reply. A question no longer open (the web answered first) isn't answered again: it waits for that turn's reply. An option the question doesn't offer exits 2; a worker that is gone exits 1 (`send the task again: chi send --wait -m "…" ID`). What a parent may pick follows `guardrails.parent_answers`, or the session's own `parent_answers` when stricter (`soft`, the default: a deny, a plain answer, Continue and "Allow once"; `standard`: no allow; `hard`: no Continue either), never a wider scope or an allow on chi's own config; a refused pick exits 1 with what to answer instead (a convention, not a security boundary; see [Guardrails](guardrails.md#answers-from-a-parent-agent))
@@ -213,10 +213,15 @@ $ chi models
213
213
  gemma-4 # the default (default.model), first
214
214
  splash:incoai/Qwen3.8-27B-Splash # another host's id: host:id
215
215
  openrouter:qwen/qwen3.8-27b
216
+ main:served → Qwen3.8-27B-Splash # a host listing one model: what it serves now
216
217
  small -> box:gemma-small # an alias and the ref it resolves to
217
218
  $ chi models qwen # only the names containing "qwen" (any case)
218
219
  ```
219
220
 
221
+ - A host whose own `/v1/models` lists exactly one id also offers `host:served` (printed `host:served → <id>`, its
222
+ host's first name), which follows whatever that host serves; `--model main:served` takes it (see
223
+ [configuration](configuration.md#the-model-a-host-serves-now-served)). A host listing several or none offers none.
224
+
220
225
  - A host's ids declared under `hosts.<name>.models` (see
221
226
  [configuration](configuration.md#models-a-host-serves-but-doesnt-list)) come first under that host, listed or not,
222
227
  as plain names like any other. They stay when the host fails, and its stderr warning says so
@@ -226,7 +231,8 @@ $ chi models qwen # only the names containing "qwen" (any case)
226
231
  - Each run lists anew (no cache); `--timeout S` caps the wait for the hosts (default 4 s). A host that fails or doesn't
227
232
  answer in time is noted on stderr (`chi models: box: no answer in 4 s`).
228
233
  - `--format json` prints one object: `default` (and `default_typed` when it was set as an alias), `default_host`,
229
- `models` (`name`, `host`, `id`, and `configured: true` on an id declared under `hosts.<name>.models`,
234
+ `models` (`name`, `host`, `id`, `served: true` on a `host:served` row (its `id` the one the host lists),
235
+ `configured: true` on an id declared under `hosts.<name>.models`,
230
236
  `unavailable: true` too when that host failed to list its models), `aliases` (`name`, `ref`, `host`) and `warnings`. The desktop helper's model
231
237
  chooser reads it.
232
238
  - Exit 0 when any host listed its models, 1 when none did (the default and declared names still print), 2 on a
@@ -550,7 +556,7 @@ invalid option (exit 1).
550
556
  | `--attach SESSION_ID` | Attach to a session's worker, waking one if it has exited. |
551
557
  | `--remote NAME` | Before a session command (`chi --remote studio send …`) or the run flags (`chi --remote studio --attach ID`, `--resume ID`, `--dir DIR -p TEXT`): run it against that remote's sessions, through its chi web; beats `CHI_REMOTE`. Commands and flags that run on this machine only exit 2. See [Remote sessions](#remote-sessions). |
552
558
  | `--dir DIR` | With `--remote`: a new session's folder on that machine, its absolute path (required for a new session there). Without `--remote` it exits 2: cd there instead. |
553
- | `--model NAME` | Use this model for the run (overrides the configured default and a resumed session's model). |
559
+ | `--model NAME` | Use this model for the run (overrides the configured default and a resumed session's model). `host:served` (`main:served`) is whatever that host serves now, checked at each turn's start (configuration.md, "The model a host serves now"); `/model main:served` moves a session onto it. |
554
560
  | `--thinking LEVEL` | This session's own thinking level: `off`, `low`, `medium` or `high`, saved in the session and first in the order (`default` unsets it). On `--resume` or `--attach` it is set at once, through a `/thinking` on an attached worker. With `chi web` it is instead the default for the sessions its workers run, below a session's own (as env `SAMAGOTCHI_THINKING_LEVEL` is). See "Thinking" in configuration.md. |
555
561
  | `--toolkit NAME`, `--tool NAME`, `--no-tool NAME` | A new session's toolkit, the tools its prompts declare: `full` (every built-in and plugin tool), `lean`, `child`, one of config's `toolkit.kits` or a bundle's (without `--toolkit`: config's `toolkit.default`), with tools declared on top of it (`--tool`) or left out (`--no-tool`); both repeatable, a comma list too. Saved in the session as given; a respawned worker, a fork and a continue keep it. Ignored with `--attach`/`--resume` (one line, as `--memory`); `/toolkit` changes it. Not on `chi web` (config's `toolkit.default` covers its sessions). See [Toolkits](configuration.md#toolkits). |
556
562
  | `--parent-answers LEVEL` | A new session's own `guardrails.parent_answers` (`hard`, `standard` or `soft`): what a parent agent may answer on its questions. It may only tighten config.yml's: the stricter of the two applies, and a looser one is saved as given with a warning (`--parent-answers soft is looser than config.yml's guardrails.parent_answers: standard; standard applies`). Saved in the session; a respawned worker, a fork and a continue keep it, a `delegate` child takes its parent's. Ignored with `--attach`/`--resume` (one line, as `--toolkit`); refused with `chi web`. Only you loosen it: `/parent-answers` in the terminal or the web. See [Guardrails](guardrails.md#answers-from-a-parent-agent). |
@@ -791,12 +797,21 @@ approval, queued prompt, or running background task; otherwise it says to run
791
797
  `chi sessions stop ID`, then send any prompt. That fallback drops reminders,
792
798
  and may lose a running `/btw` and other in-memory state. A session with no running worker needs no restart (its next
793
799
  prompt starts one on the newest chi), and an older worker without restart
794
- support needs `chi sessions stop ID`. A stopped session, or one being stopped
795
- (`chi sessions stop`), is refused at once without asking its worker: "can't
796
- restart: the session is stopped; only its owner's message starts it again (on
797
- the newest chi)". The Web UI's
798
- `POST /api/sessions/:id/restart` does the same (409 with `reason` and `detail`
799
- when it can't). An attached
800
+ support needs `chi sessions stop ID`. A stopped session (`chi sessions stop`)
801
+ is started again, as `chi --resume ID` does without a terminal: "Started session
802
+ ID again on chi X." (or "Starting session ID again; its worker is still
803
+ starting."); one being stopped starts once its worker has left, or, if it is
804
+ still leaving after 10 s, "is still stopping; restart it again in a moment".
805
+ Its delegates the stop stopped stay stopped. Run by an agent (the markers `chi
806
+ send` reads: CLAUDECODE, CODEX_THREAD_ID, AI_AGENT, a chi session's shell) the
807
+ restart of a stopped session is refused at once: "can't restart: the session is
808
+ stopped; only its owner's message starts it again (on the newest chi); ask your
809
+ user to start it: `chi --resume ID`, or a message from a terminal or the web"
810
+ (`chi --remote NAME --resume ID` with `--remote`), since only its owner starts a
811
+ stopped session. chi web's restart after an update leaves stopped sessions
812
+ stopped. The Web UI's `POST /api/sessions/:id/restart` does the same (a body
813
+ `{"start_stopped": false}` is an agent's; 409 with `reason` and `detail` when it
814
+ can't; `was_stopped: true` in the 200 when it started a stopped session). An attached
800
815
  terminal says at the join, in one `chi>` line, when the worker or the terminal
801
816
  runs an older chi than the newest installed (the worker moves with `chi
802
817
  sessions restart ID`, the terminal with `/detach` and `chi --attach ID`), and
@@ -2021,6 +2036,7 @@ In interactive assist mode, you can switch the request model without restarting:
2021
2036
  - `/model --default <name>`: set session model and persist as new default (`default.model`) in `config.yml` for future sessions (supports `host:model` full ref). It writes only the file: an exported `SAMAGOTCHI_DEFAULT_MODEL` (or `--model`) still wins over it.
2022
2037
  - `/model <name> --alias <alias>`: create alias for current effective model (alias value may be bare or `host:model`).
2023
2038
  - `/model`: show the effective model (and default when diverged: `runtime model: <effective> (default: <default>, profile=<name>, <source>)`, e.g. `profile=qwen36, server (chat_template)`). When the session's prompt carries model notes the line ends with `; notes: model_notes_deepseek (system, 612 chars)`; a switch's `runtime model set to …` names the new model's ([Memory](memory.md#model-notes)).
2039
+ - `/model main:served`: follow whatever host `main` serves now (configuration.md, "The model a host serves now"); a bare `/model` then shows `runtime model: main:served → <id>`, the id it runs on now.
2024
2040
  - `/model clear` (or `default`/`none`/`off`): clear the session override, reverting to the configured default.
2025
2041
  - Once the session has a model reply, a switch to another model asks first from a web tab or a TUI (the new model
2026
2042
  has no cache of the conversation): the reply names the line with `--yes` that applies it, flags and all
@@ -2029,7 +2045,7 @@ In interactive assist mode, you can switch the request model without restarting:
2029
2045
  - `/guardrails`: the guardrail rules (by source), what failed to load, your stored approvals, and System 1's
2030
2046
  recent auto-allows; `/guardrails revoke N` removes approval N and `/guardrails wrong [N]` flags an auto-allow
2031
2047
  this session should have been asked about (see [Guardrails](guardrails.md)).
2032
- - `/models`: list model ids aggregated across all `hosts:` (an alias shows next to its id: a bare alias on every host listing the id, a `host:model` one only under its host; grouped `host (host:port):` with per-host `unreachable` warnings, e.g. an unset `api_key_env`; lists cached 60s, 10 minutes for a remote host; lazy — no startup prefill). Ids the host declares under `hosts.<name>.models` come first, as `rr/x (config)`, and don't count toward the cap; an unreachable host keeps them, under its warning, as `rr/x (config, host down)`. At most 20 ids per host, then `… and N more`; `/models <text>` lists every id containing `<text>` (any case), e.g. `/models qwen` on OpenRouter.
2048
+ - `/models`: list model ids aggregated across all `hosts:` (an alias shows next to its id: a bare alias on every host listing the id, a `host:model` one only under its host; grouped `host (host:port):` with per-host `unreachable` warnings, e.g. an unset `api_key_env`; lists cached 60s, 10 minutes for a remote host; lazy — no startup prefill). Ids the host declares under `hosts.<name>.models` come first, as `rr/x (config)`, and don't count toward the cap; an unreachable host keeps them, under its warning, as `rr/x (config, host down)`. At most 20 ids per host, then `… and N more`; `/models <text>` lists every id containing `<text>` (any case), e.g. `/models qwen` on OpenRouter. A host whose own listing names exactly one id starts with `served → <id>` (with its aliases, e.g. `(alias: splash)` for `splash: main:served`), the name `host:served` takes; an alias of `host:served` is never listed as an orphan.
2033
2049
 
2034
2050
  Notes:
2035
2051
 
@@ -182,7 +182,8 @@ or `chi web` restart.
182
182
  | `broadcast.*` | Next `chi broadcast` | Each broadcast invocation reads its targeting and triage settings. |
183
183
  | `update.gem`, `update.bundles`, `update.desktop` | Next `chi update` | The command reads which components to update when it runs. |
184
184
  | `update.notify`, `update.check_hours`, `update.min_age_hours`, `update.auto`, `update.restart` | `chi web` start | The update checker starts with chi web; restart it to apply changes. |
185
- | `kitty.*`, `tmux.*` | `chi desktop upgrade` or desktop update | These settings are copied into the desktop helper's launch file. |
185
+ | `kitty.listen_on`, `kitty.binary` | Next pane lookup; `chi desktop upgrade` or desktop update for the helper | Read live by the worker each time it looks for a pane (`/claude pair`'s list, `/claude show`, `/claude start`'s tab: [Panes](internals/panes.md)); copied by `chi desktop upgrade` into the desktop helper's launch file. |
186
+ | `kitty.agents`, `tmux.*` | `chi desktop upgrade` or desktop update | These settings are copied into the desktop helper's launch file. |
186
187
  | `model.profile`, `reasoning_history` | Not from config.yml | These are CLI/environment settings; `models:` and `hosts:` provide their model- and host-specific forms. |
187
188
 
188
189
  ### Per-session settings
@@ -238,7 +239,9 @@ A few environment variables are not settings (no config.yml key, no flag):
238
239
  A model's settings come in layers, and the first one set wins. Every surface reads them the same way: a turn,
239
240
  `/model` and `/stats`, `chi self`, the web's chips and the start page's ⚙ panel, and a session list's ctx %. A
240
241
  `models:` entry is looked up under each name the model goes by, the most specific first: the name as typed (an
241
- alias), the alias's target (`host:id`), the part after a host prefix, then the id the host is asked for.
242
+ alias), the alias's target (`host:id`), the part after a host prefix, then the id the host is asked for. A `served` model
243
+ (`main:served`, below) is looked up under the id its host serves now: key per-family settings by that id, not by
244
+ `served` or an alias of it (an alias's entry would apply to every model the host loads).
242
245
 
243
246
  | Setting | Order, first set wins |
244
247
  |---|---|
@@ -1039,6 +1042,66 @@ alias, `/model`, `chi send --new --model`, the web's new-session model and a
1039
1042
  delegate's model. Any other unknown prefix (`nosuch:x`) is sent to the default
1040
1043
  host as the model id.
1041
1044
 
1045
+ ### The model a host serves now (`served`)
1046
+
1047
+ A local server that serves one model at a time (Splash, a single-model llama-server or vLLM) can be named by
1048
+ what it serves now instead of by an id: `host:served` (`main:served`; a bare `served` is the default host's). Then
1049
+ a model swap on the server needs no config edit, and the sessions (and their schedules) follow it.
1050
+
1051
+ ```yaml
1052
+ default:
1053
+ model: main:served
1054
+ model_aliases:
1055
+ splash: main:served
1056
+ ```
1057
+
1058
+ - **What it resolves to:** the one id the host's own `/v1/models` lists now. The declared ids
1059
+ (`hosts.<name>.models`, below) never count. A host that lists none or several (OpenRouter, a gateway,
1060
+ api.anthropic.com) refuses it: the turn fails with `host main lists 3 models (a, b, c); served needs exactly one:
1061
+ pick one with /model`.
1062
+ - **Saved as written:** a session saves `main:served`, never the id, so a resumed, continued, forked or scheduled
1063
+ session resolves again. Each turn records the model it ran on (`/stats` has a segment per id).
1064
+ - **Checked at each turn's start:** one short `GET /v1/models` before the turn's prompt is built (a few ms on a
1065
+ local host; never on a page or Bridge read, which show the id last listed). A change works like a `/model` nobody
1066
+ typed: the prompt is rebuilt, the overlays, notes and profile follow, and the turn shows `host main now serves Y
1067
+ (was X)`. A `--profile` given at start stays.
1068
+ - **A swap mid-turn:** the host refuses the next request, and the turn fails with `host main no longer serves X (it
1069
+ serves Y now): send again to continue on Y`. The next turn follows.
1070
+ - **A host that is down** keeps the id last known (the turn then fails as before, `can't reach host main …`).
1071
+ - **Settings key by the id it runs** (sampling, thinking, window, profile, prices, model notes, overlays,
1072
+ `guardrails.small_models`), as if you had typed that id.
1073
+ - **The system prompt** names both: "this session runs on main:q8 (main:served: whatever host main serves; …)".
1074
+ - **Thinking replay on `api: anthropic`** (the `splash-msg` host above, where `reasoning_history` defaults to `all`):
1075
+ a served change replays the earlier turns' thinking to the new model as `/model` does.
1076
+ - **The word is reserved:** an alias named `served` is ignored with a warning at start.
1077
+ - **Sessions pinned to an explicit id don't follow**: a turn the host refuses as not served fails as before, and
1078
+ when the host lists one other model now the line ends `; host main serves Y now: /model main:served follows it`
1079
+ (one short listing; nothing switches). `/model main:served` moves the session.
1080
+ - **Side requests follow too:** System 1 (`system_one.model: served`), `recap.model`, `broadcast.triage_model`,
1081
+ `ctx.ask_model(model:)` (btw, a block fix, the objectives' check) take `served` like a session's model. They
1082
+ list the host at most every 30 s (a broadcast lists once, in its own process, and a recap asks the id last
1083
+ listed), and a host that refuses the id as not served is listed again and asked once more with the new one
1084
+ (not a broadcast's), within what is left of the first ask's time. A host that is down fails these fast for 30 s
1085
+ after a failed listing (a turn's start always lists). A `base_url:` recap or triage names no host, so
1086
+ `served` means nothing there.
1087
+ - **Where you see it:** chi web's model picker, `chi models` and `/models` offer `host:served` for a host whose own
1088
+ listing names exactly one model, as its host's first row: the picker shows `served` with `now <id>` (its tooltip
1089
+ says the id is as of the hosts' last listing, up to 60 s old), `chi models` prints `main:served → <id>`,
1090
+ `/models` prints `served → <id>` under the host, with any alias of it (`--format json` marks the row
1091
+ `served: true`). A host listing none or several gets no such row. A served session's info bar shows
1092
+ `served · <id>` (its tooltip `main:served → <id>`), the status row `model=main:served·<id>`, `/model`
1093
+ `runtime model: main:served → <id>`, `/stats` a `model:` line `main:served (now <id>)`, and `chi self`
1094
+ `main:served → <id>` (or why it can't run). The id is what the session ran on last (a session no worker runs:
1095
+ its last turn's), and changes at the next generation after a swap.
1096
+ - **Aliases of one model count as several:** Splash's `--served-model-name` names are listed as more
1097
+ `/v1/models` entries (each with `root:` the loaded id), and such a host is refused like any other listing
1098
+ several. Pick one id with `/model`, or drop the extra names.
1099
+
1100
+ Upgrade every chi that reads this config.yml before writing `served` into it: an older chi sends `served` as the
1101
+ model id, and its turns fail.
1102
+
1103
+ This is not the `served:` key of a declared model (next section), which lists the ids a gateway may answer with.
1104
+
1042
1105
  ### Models a host serves but doesn't list
1043
1106
 
1044
1107
  A gateway can serve ids its `/v1/models` never lists (round-robin aliases such
@@ -1391,6 +1454,9 @@ The desktop helper (`chi desktop`) can also paste into agent CLIs (claude,
1391
1454
  codex, …) running in [kitty](https://sw.kovidgoyal.net/kitty/) windows or
1392
1455
  tmux panes. It lists kitty's only with `kitty.listen_on` set: copy the value of `listen_on` from
1393
1456
  your `kitty.conf` as it is (kitty must also have `allow_remote_control` on).
1457
+ The same two settings let a session's worker find a Claude's window (claude-peer's Show) and open a background tab
1458
+ (`/claude start`, `/codex start`; the command it runs is the bundle setting `bundles: claude-peer: start_command:`, a
1459
+ shell line, default `claude`): see [peers.md](peers.md#pairing).
1394
1460
 
1395
1461
  ```yaml
1396
1462
  kitty:
@@ -2281,7 +2347,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2281
2347
 
2282
2348
  | Setting | Default | CLI | What it does |
2283
2349
  |---|---|---|---|
2284
- | `default.model` | (required) | `--model` | The model a new session starts with; `host:model` pins a host. |
2350
+ | `default.model` | (required) | `--model` | The model a new session starts with; `host:model` pins a host; `host:served` is whatever that host serves now (The model a host serves now). |
2285
2351
  | `default.input` | none | | Text pre-filled at the first prompt (a trailing space is kept); `--no-default-input` skips it. See [CLI](cli.md). |
2286
2352
  | `default.max_tokens` | server's | yes | Most tokens one generation may produce (`n_predict` on a native llama.cpp host; OpenRouter: 32768 when unset). |
2287
2353
  | `model.profile` | none | `--profile` | Prompt profile for every model (`qwen36`, `gemma4`); env and CLI only. See "Prompt profile". |
@@ -2292,7 +2358,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2292
2358
  | `server.first_token_timeout` | 120 remote, off local | | Seconds to the first token; `0` = off. `hosts.<name>.first_token_timeout` wins. |
2293
2359
  | `server.stream_idle_timeout` | 120 remote, off local | | Seconds a stream that showed something may go without more; `0` = off. `hosts.<name>.stream_idle_timeout` wins. |
2294
2360
  | `recap.enabled` | on | | `false` (or `recap: false`) turns the idle recap off. Per session too: `--set recap.enabled=false`, or `/recap off` in the session (see "Per-session settings"). |
2295
- | `recap.model` | session's | yes | Model that writes the recap: an id, alias or `host:model` (the host then picks where to ask; a bare id goes where a bare `--model` goes). |
2361
+ | `recap.model` | session's | yes | Model that writes the recap: an id, alias or `host:model` (the host then picks where to ask; a bare id goes where a bare `--model` goes). `main:served` (or `served` with `recap.host_ref`) asks what the host serves now (the id last listed; a not-served refusal lists and asks once more). |
2296
2362
  | `recap.host_ref` | session's | yes | A `hosts:` name to ask (`host:` is accepted too, also a host name, not a model ref). |
2297
2363
  | `recap.base_url` | none | yes | An OpenAI API base to ask instead (`http://h:8081/v1`). |
2298
2364
  | `recap.inactivity` | `180` | yes | Idle seconds before a recap. |
@@ -2341,7 +2407,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2341
2407
  | `guardrails.system_one.threshold` | `0.8` | | The probability an auto-allow needs. config.yml only. |
2342
2408
  | `guardrails.system_one.min_record` | `5` | | How many clean records a rule needs before System 1 is trusted for it: labelled asks of that rule at the threshold the user allowed. config.yml only. |
2343
2409
  | `system_one.host` | none | | The `hosts:` entry serving `/v1/systemone` (a local Splash, or the hosted Jev API); unset: no judgment, by any use of System 1, so nothing auto-allows and every ask goes to the user. Moved from `guardrails.system_one.host`: while any of host, model and timeout_ms is still under `guardrails.system_one`, chi warns and nothing is judged. config.yml only. |
2344
- | `system_one.model` | none | | The judgment model; unset uses the host's first model, and a host that names none has no judgment. Moved from `guardrails.system_one.model`. config.yml only. |
2410
+ | `system_one.model` | none | | The judgment model; `served` is the one model `system_one.host` lists now (re-listed at most every 30 s; a not-served 422 is asked again once with the new id); unset uses the host's first model, and a host that names none has no judgment. Moved from `guardrails.system_one.model`. config.yml only. |
2345
2411
  | `system_one.timeout_ms` | `2000` | | Milliseconds one judgment may take; a slower one is no judgment and the ask goes to the user. Moved from `guardrails.system_one.timeout_ms`. config.yml only. |
2346
2412
  | `system_one.runs` | `on` | | Save each System 1 ask and what came of it, under the state dir, as long as sessions last (see [System 1's saved runs](system-one.md)); `off` stops saving. config.yml only. |
2347
2413
  | `log.file` | state dir | yes | See "Debug Log File". |
data/docs/desktop.md CHANGED
@@ -150,6 +150,9 @@ and it lands in a session running there.
150
150
 
151
151
  ## Agents in kitty and tmux
152
152
 
153
+ The helper keeps its own list of kitty windows; chi's worker reads kitty itself for claude-peer's Show
154
+ ([internals/panes.md](internals/panes.md): the same `kitty.listen_on` and `kitty.binary`, read live there).
155
+
153
156
  The panel can also send to agent CLIs (claude, codex, gemini, aider, …) running in
154
157
  [kitty](https://sw.kovidgoyal.net/kitty/) windows or [tmux](https://github.com/tmux/tmux) panes, next to chi
155
158
  sessions. Each is off until you set it up; both can be on.
data/docs/guardrails.md CHANGED
@@ -1119,7 +1119,7 @@ local Splash server, or the hosted Jev API — and its key is that host's own
1119
1119
  ```yaml
1120
1120
  system_one: # what every use of System 1 shares
1121
1121
  host: splash # the hosts: entry serving /v1/systemone
1122
- model: Qwen3.8-Flash-Next-GSQ-RCO-GGUF:Q2_0 # else the host's first model
1122
+ model: Qwen3.8-Flash-Next-GSQ-RCO-GGUF:Q2_0 # or served (what the host serves now); else the host's first model
1123
1123
  timeout_ms: 2000 # a slower judgment is no judgment
1124
1124
  guardrails:
1125
1125
  system_one: # approvals' own
@@ -1130,6 +1130,16 @@ guardrails:
1130
1130
  min_record: 5 # clean records a rule needs before it is trusted
1131
1131
  ```
1132
1132
 
1133
+ `system_one.model: served` judges with whatever `system_one.host` serves now (the one id its `/v1/models` lists,
1134
+ as `host:served` does for a session: [configuration.md](configuration.md#the-model-a-host-serves-now-served)).
1135
+ `HttpBackend#target` and `/guardrails` read the id last listed, with no request; an ask lists again when that is
1136
+ older than 30 s, within `timeout_ms`. A host that swapped models answers the ask `422 model X is not served by
1137
+ this endpoint`: the ask re-lists and is asked again once with the new id while 300 ms of `timeout_ms` are left.
1138
+ A host listing none or several models is no judgment, and `/guardrails` says why. The clean record stays
1139
+ model-blind (as a hand edit of `system_one.model` keeps it): each change of the judge logs
1140
+ `system_one_model_changed` (warn, once per change per process), and each saved run names the id that answered.
1141
+ Unset still means the host's first declared model.
1142
+
1133
1143
  `SystemOne::Client.from_config(host_registry:, mode:)` reads these on every
1134
1144
  call, so a config.yml change takes effect on the next ask. `mode: off` (the
1135
1145
  default) or no `system_one.host` means there is no client at all. Anything else is no
data/docs/hooks.md CHANGED
@@ -64,6 +64,7 @@ The plugin class must respond to `#call(event)` — duck-typed, no base class re
64
64
  | `:question_asked` | A question of the model's own (`ask_user_question`) or an approval of its tool call is about to open, on the turn's thread (not a hook's or plugin's `ask_user`, a relayed delegate approval, the step-limit question, a `--non-interactive` run or a stored approval: none of those fire it) | `{ type: :question_asked, kind: "question" \| "approval", text: "..." (the reply that asks, as the lead-in bubble shows it: no thoughts, no tool-call markup), question: {...} (the question's fields, frozen: question/options/header…, an approval's approval: facts too; no id yet), refs: (see [Refs on a question](#refs-on-a-question-display-only)) }` |
65
65
  | `:after_tool_call` | After tool execution | `{ type: :after_tool_call, iteration: N, tool: "read", output: "..." (the text the model gets: capped at max_tool_output_chars (a memory_read's cap is memory.read_max_chars, 0: none); a cut one has a [cut: …] line, at its end, or for an execute result between its head and its tail, the whole output saved in the session's tool_output/ folder), status: "ok" \| "error" \| "blocked" \| "stopped", call: {...} (the call that ran, as the gate left it), elapsed_ms: N (the tool's own run, without an approval wait; nil for a denied call), result: "..." (the tool's own text: no "[read]" lead, no "ran as:" line, never cut) }`; `stopped` is a `task_wait` the turn's Stop ended (the task runs on) or whose task was stopped. Match on `result:`, not `output:`: it is what the tool said (`Error: command timed out after 120s` for an execute killed at its limit in kill mode, `Samagotchi::Tools::Execute::TIMEOUT_PREFIX`; `Still running at the 120s limit: …` for one handed over as a task, `Samagotchi::Tools::Execute::HANDED_OVER`) |
66
66
  | `:session_end` | After each turn `:after_turn` fires for, after it (turn-level lifecycle) | `{ type: :session_end, session_id: "..." }` |
67
+ | `:peer_wait_ended` | Between turns, in a session's worker: its `/<peer> pair` wait ran out with no peer (`PeerWaitExpiry`; the peer bundles say so with `ctx.notify`) | `{ type: :peer_wait_ended, peer: "claude", session_id: "...", minutes: 10 }` |
67
68
 
68
69
  Every event also carries the hook runtime (next section): `hook:` (the label
69
70
  of the hook about to run) and the callables `notify:`, `ask_user:`,
@@ -36,9 +36,9 @@ Engine#run_turn(session, prompt, on_event:, …, origin:, continue:, resumed:, r
36
36
  | Step | Where | What it owns |
37
37
  |---|---|---|
38
38
  | `begin_turn` | `engine.rb` | A Verify turn's claim checked (`@verify_anchors.verified`, the sessions dir given); `session.status = RUNNING`; used memories absorbed; the `TurnContext` built **whole** (`new_turn_context`: `GuardrailWiring#begin_turn` gives git, participant and mode; `id:` the caller's or a new uuid; `settings` nil until `generate`), then `TurnState#begin!` publishes it with the controller (a new `CancellationController` when none is given), sink and `input_waiting:` peek in one step; a recap in flight invalidated. `run_turn` sets `turn.resumed` / `turn.resume_from` only on a continue. |
39
- | `prepare_turn` | `engine.rb` | `:turn_started` (an image error raised after it); the toolkit suggestion's `start`; `refresh_profile!`; `turn.prepared_settings = turn_settings(session)` and `refuse_images!`; **STOP CHECK A** (abandons the suggestion `:canceled`); `announce_guardrail_failures`, `start_init_tasks!` / `await_init_tasks`, `apply_staged_tools!`; the suggestion's `settle`, the judge's `start`, the objectives' `incoming`; `apply_toolkit!` (`Registry#toolkit`, `ToolIndex#refresh!`, a prompt rebuild when it changed, a warn per stranded plugin tool); `refresh_participants!`; **STOP CHECK B** (before the hooks run or a reminder is used up); `:session_start` (first turn) and `:before_turn` hooks; `turn_messages`. Its ensure abandons the suggestion `:failed` (nothing once settled) and calls `finish`. |
39
+ | `prepare_turn` | `engine.rb` | `served_turn_start` → `follow_served!` (`engine/models.rb`, a `served` model only: `HostRegistry#refresh_served!` max_age 0, one bounded `GET /v1/models`; a change since `ModelBinding#served_id` pins the new id and resets as `/model` does; before the emit, so `cut_after` is the new model's); `:turn_started` (an image error raised after it, then the served refusal or listing error, else the `host main now serves Y (was X)` notice); the toolkit suggestion's `start`; `refresh_profile!`; `turn.prepared_settings = turn_settings(session)` and `refuse_images!`; **STOP CHECK A** (abandons the suggestion `:canceled`); `announce_guardrail_failures`, `start_init_tasks!` / `await_init_tasks`, `apply_staged_tools!`; the suggestion's `settle`, the judge's `start`, the objectives' `incoming`; `apply_toolkit!` (`Registry#toolkit`, `ToolIndex#refresh!`, a prompt rebuild when it changed, a warn per stranded plugin tool); `refresh_participants!`; **STOP CHECK B** (before the hooks run or a reminder is used up); `:session_start` (first turn) and `:before_turn` hooks; `turn_messages`. Its ensure abandons the suggestion `:failed` (nothing once settled) and calls `finish`. |
40
40
  | `turn_messages` | `engine.rb` | System head + history + due reminders (`:reminder_injected`; none in a participant's turn) + the user message (not on a continue) + the plugins' staged tool loads (`append_tool_loads`, `engine/toolkit.rb`). `turn.messages` is set first and grown in place, so a failure meanwhile keeps what is there. |
41
- | `generate` | `engine.rb` | One `EffectiveModel` **after the hooks** (which may switch the model): `sync_kernel_client!`, the settings completed (`model_name`, `window_setting`, `llm_context`, `price`, `loads_tools`), the turn's `ToolSurface` built, `turn.context.with(…)` published by `TurnState#replace_context`; `turn.limit` (`IterationLimit.for`); `backend(model).complete(…, pending_input: turn_drain(pending_input), reasoning_since:, context:)`. |
41
+ | `generate` | `engine.rb` | One `EffectiveModel` **after the hooks** (which may switch the model; `generate_model`: a served model with no pin yet is listed, max_age 30, and pinned): `sync_kernel_client!`, the settings completed (`model_name`, `window_setting`, `llm_context`, `price`, `loads_tools`), the turn's `ToolSurface` built, `turn.context.with(…)` published by `TurnState#replace_context`; `turn.limit` (`IterationLimit.for`); `backend(model).complete(…, pending_input: turn_drain(pending_input), reasoning_since:, context:)`. |
42
42
  | `complete_turn` / `end_turn` | `engine/turn_end.rb`, `engine.rb` | See "Turn ends" below. |
43
43
  | `@turn_warmup.after` | `TurnStages::Warmup` | Local llama.cpp, native loop only: prefills the next turn's prompt (prompt-caching.md, "The turn-end warm-up"). Never fails the turn. |
44
44
  | `release_turn` | `engine/turn_end.rb` | `TurnState#finish!`, `SteerCut#finished!`, probe cancel swapped back, the context window cache dropped (the next turn asks the server again), steers left logged as dropped, activity recorded, turn-scoped hooks cleared. Then, after the flag is released, the judge's cards and `show_objective_proposals` (the objectives' `finally`: a completed turn's proposal cards shown, any other's dropped). |
@@ -395,7 +395,50 @@ a bare id to another host, and another process's saved model lists change what a
395
395
  the hooks) and one in `generate` (after them); `system_prompt`, `steer_cut_after` and the warm-up take their own;
396
396
  `stats_snapshot` and `session_state_snapshot` (`EngineSnapshots`, `engine_snapshots.rb`) one each.
397
397
  - Never resolved (they hold on a broken resolve): `effective_model_ref`, `bare_model_name`, `guardrail_model_name`,
398
- `sync_model_key!`, `served_model(probe: false)`.
398
+ `sync_model_key!`, `served_model(probe: false)`, `model_switched_since_last_turn?`.
399
+ - **The id a host is sent has one source**: `HostRegistry#sent_model_id(raw)` (`#bare_name` is its alias), read
400
+ from the parsed ref only (the alias applied, a known host prefix off; no resolve, no model index or saved list,
401
+ no request), and equal to `resolve(raw).bare_model`. Readers that hold an `EffectiveModel` take `#bare` (the
402
+ wire in `generate`, `append_tool_loads`' `tool_changes?`, `served_model_for` with a model); the never-resolving
403
+ ones take `sent_model_id` (`bare_model_name`, so `guardrail_model_name` and `ModelBinding#sync_model_key!`;
404
+ `served_model_for` without a model, `Web::App#saved_served_model`, `Web::ParticipantReview`, `SelfReport`'s
405
+ overlay key and notes, and `IdleTarget.resolve` for a recap or triage setting that names a host). A turn's
406
+ generations are counted under `EffectiveModel#turn_ref` (`generation_model_ref`), and the switch check compares
407
+ `HostRegistry#turn_ref` without a resolve; both are the stored ref (`ModelRef#ref`), except for a served ref.
408
+ - **A served ref** (`main:served`, `ServedRef`; configuration.md, "The model a host serves now"): the id is the one
409
+ the host's own listing has (`ServedLookup`, one per `HostRegistry`). Every reader above stays request-free and
410
+ never raises: `sent_model_id`, `resolve` and `turn_ref` read `ServedLookup#cached` (the last listing, the
411
+ adapter's fresh list, the saved `model_lists.json` with exactly one id), else the word `served`. Only a turn's
412
+ start lists (`HostRegistry#refresh_served!`). **The turn pins its id**: `ModelBinding#served_id` (seeded at
413
+ build and by `switch_model!` with the cached id, moved by `#follow!`), passed by `SessionModelSettings` and
414
+ `ModelBinding#resolve_profile` to `EffectiveModel.of(…, served_id:)` and by `bare_model_name` (so
415
+ `guardrail_model_name`, the notes, the overlay key) to `sent_model_id(…, served_id:)`; a side ask's re-list moves
416
+ the lookup only. `turn_ref` is `host:<id>`, so `/stats` segments per id; `lookup_names` leaves `served` and
417
+ `main:served` out (an alias of it stays). A turn the host refuses as not served (`BadRequest#model_not_served?`)
418
+ fails with `ModelsPart#served_failure_line` (a forced re-list names the new id, once per error: the turn's note
419
+ via `TurnEndings`' `served_line:`, its end event and the one-shot share it). A hook that switches to a served
420
+ model after the start gets its own listing in `generate_model` (the start's choice is `@served_start_choice`).
421
+ An explicit id's not-served turn keeps `failure_summary`'s line and adds `ModelsPart#explicit_served_hint` (one
422
+ bounded listing of that host, kept per error; none when it lists the refused id or several).
423
+ The listing is bounded (1 s open, 2 s read, no retry) and a Stop cuts it (`Client.probe_cancel`).
424
+ Side asks list too, at most every 30 s, and retry once on a not-served refusal when a forced re-list names
425
+ another id (`IdleClient.not_served?`, the `SummarizeError`'s cause): `SideRequestsPart#ask_side_model` (and
426
+ `session_model_recap_target`, the recap's default), `RecapSetup`'s `served_target` with `IdleRecap`'s
427
+ `retarget:` (`IdleTarget.host_named?` is false for a served model, so it is resolved per attempt; an attempt
428
+ reads the id last listed and never lists, since it runs on the idle scheduler's thread; the retry lists on the
429
+ summarize thread), `Broadcast::TriageModel` (one listing, max_age 0, no retry), and System 1's `HttpBackend`
430
+ (its listing capped by what is left of `timeout_ms` and cut by the judgment's Stop; `ServedLookup#cached_refusal`
431
+ lets `#target` refuse with no request). A retry gets what is left of the first ask's timeout. `ServedLookup`
432
+ remembers a failed listing for 30 s (`FAILED_TTL`) for callers with `max_age` > 0, so a down host fails them
433
+ fast; a turn's start (max_age 0) always lists.
434
+ The UIs read the id with no request: `EffectiveModel#served_id` (the pin, else the lookup), as the session
435
+ state's `model_served` (`EngineSnapshots`), `/stats`' `served_ref`/`model_served`, `Engine#served_model_id`
436
+ (`/model`'s `main:served → <id>`, a `:command_ran`'s `model_served`); after that they follow each
437
+ `:generation_completed`'s `requested_model` (the sent id) while the model is served: an id came with it
438
+ (`model_served`; an alias of main:served too, whose `:command_ran` `model_name` is the alias typed) or it is a
439
+ served ref (`ServedRef.stored?`, `served_ref.js isServedRef`). The info bar's `served · <id>` needs only the id. chi web without a worker takes the last turn record's `model_ref`
440
+ (`SessionShow#saved_model_served`). The pickers' row is `ModelCatalog`'s (`served_row`: a `HostListing` whose
441
+ own ids are exactly one, `ServedLookup.one_id`; `web_models` names a served default by it).
399
442
  - Readers on other threads: the Bridge (`/state`, `/stats`, the SSE reset, a steer's cut wait), the worker's
400
443
  command thread, the recap thread, plugin threads.
401
444
  - `ModelChoice` (`ModelBinding#choice`) holds the name and the typed name as **one value**, so a reader never pairs