samagotchi 0.192.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 (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +128 -1
  3. data/docs/architecture.md +3 -3
  4. data/docs/bundle-authoring.md +1 -1
  5. data/docs/bundles.md +82 -40
  6. data/docs/cli.md +47 -17
  7. data/docs/configuration.md +75 -8
  8. data/docs/context.md +8 -5
  9. data/docs/desktop.md +3 -0
  10. data/docs/guardrails.md +20 -5
  11. data/docs/hooks.md +1 -0
  12. data/docs/internals/bridge.md +3 -1
  13. data/docs/internals/bundles.md +2 -2
  14. data/docs/internals/engine.md +46 -3
  15. data/docs/internals/pages.md +4 -4
  16. data/docs/internals/panes.md +66 -0
  17. data/docs/internals/participants.md +5 -3
  18. data/docs/internals/peers.md +176 -27
  19. data/docs/internals/prompt-caching.md +6 -1
  20. data/docs/internals/remote-sessions.md +6 -0
  21. data/docs/internals/session-lifecycle.md +12 -4
  22. data/docs/internals/web-frontend.md +106 -22
  23. data/docs/internals/working-set.md +5 -1
  24. data/docs/peers.md +150 -27
  25. data/docs/plugins.md +48 -7
  26. data/docs/releasing.md +30 -2
  27. data/docs/scheduling.md +3 -2
  28. data/docs/sessions.md +16 -7
  29. data/docs/sub-agent.md +6 -4
  30. data/docs/system-one.md +4 -0
  31. data/docs/testing.md +38 -3
  32. data/docs/thin-clients.md +27 -11
  33. data/lib/samagotchi/bridge/card_store.rb +1 -1
  34. data/lib/samagotchi/broadcast/triage_model.rb +17 -0
  35. data/lib/samagotchi/bundles/claude-peer/manifest.yml +8 -5
  36. data/lib/samagotchi/bundles/claude-peer/plugin.rb +24 -5
  37. data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +61 -24
  38. data/lib/samagotchi/bundles/claude-peer/scripts/pair +31 -8
  39. data/lib/samagotchi/bundles/codex-peer/manifest.yml +8 -5
  40. data/lib/samagotchi/bundles/codex-peer/plugin.rb +62 -6
  41. data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +57 -19
  42. data/lib/samagotchi/bundles/codex-peer/scripts/pair +28 -7
  43. data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
  44. data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +31 -0
  45. data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
  46. data/lib/samagotchi/bundles/mcp/manifest.yml +2 -2
  47. data/lib/samagotchi/bundles/mcp/plugin.rb +0 -7
  48. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  49. data/lib/samagotchi/chi_invocation.rb +7 -0
  50. data/lib/samagotchi/client.rb +18 -0
  51. data/lib/samagotchi/codex_rollout.rb +93 -0
  52. data/lib/samagotchi/compat.rb +8 -1
  53. data/lib/samagotchi/config.rb +19 -6
  54. data/lib/samagotchi/continue_offer.rb +13 -1
  55. data/lib/samagotchi/delivery.rb +2 -2
  56. data/lib/samagotchi/effective_model.rb +28 -2
  57. data/lib/samagotchi/engine/cards.rb +9 -4
  58. data/lib/samagotchi/engine/hooks.rb +8 -0
  59. data/lib/samagotchi/engine/models.rb +197 -7
  60. data/lib/samagotchi/engine/plugins.rb +2 -0
  61. data/lib/samagotchi/engine/side_requests.rb +72 -13
  62. data/lib/samagotchi/engine/toolkit.rb +1 -1
  63. data/lib/samagotchi/engine/turn_helpers.rb +1 -1
  64. data/lib/samagotchi/engine.rb +11 -8
  65. data/lib/samagotchi/engine_snapshots.rb +16 -3
  66. data/lib/samagotchi/events.rb +1 -0
  67. data/lib/samagotchi/guardrails/pair_boundary.rb +49 -18
  68. data/lib/samagotchi/hooks.rb +3 -1
  69. data/lib/samagotchi/host_registry.rb +146 -16
  70. data/lib/samagotchi/idle_client.rb +13 -2
  71. data/lib/samagotchi/idle_recap.rb +33 -3
  72. data/lib/samagotchi/idle_target.rb +27 -7
  73. data/lib/samagotchi/jsonl_store.rb +13 -2
  74. data/lib/samagotchi/llm/adapter_common.rb +4 -2
  75. data/lib/samagotchi/llm/anthropic_messages.rb +14 -2
  76. data/lib/samagotchi/llm/errors.rb +35 -4
  77. data/lib/samagotchi/llm/model_listing.rb +19 -0
  78. data/lib/samagotchi/llm/openai_chat.rb +8 -2
  79. data/lib/samagotchi/llm/prompt_cache.rb +5 -0
  80. data/lib/samagotchi/model_binding.rb +46 -4
  81. data/lib/samagotchi/model_catalog.rb +68 -8
  82. data/lib/samagotchi/model_profile.rb +35 -0
  83. data/lib/samagotchi/models_command.rb +8 -4
  84. data/lib/samagotchi/pages/launch.rb +1 -1
  85. data/lib/samagotchi/panes/kitty.rb +122 -0
  86. data/lib/samagotchi/panes.rb +185 -0
  87. data/lib/samagotchi/peer_announce.rb +245 -0
  88. data/lib/samagotchi/peer_cold.rb +92 -0
  89. data/lib/samagotchi/peer_command.rb +121 -20
  90. data/lib/samagotchi/peer_continue.rb +42 -16
  91. data/lib/samagotchi/peer_exchanges.rb +7 -0
  92. data/lib/samagotchi/peer_mailbox.rb +50 -10
  93. data/lib/samagotchi/peer_pair_here.rb +149 -0
  94. data/lib/samagotchi/peer_presence.rb +434 -0
  95. data/lib/samagotchi/peer_receipts.rb +33 -6
  96. data/lib/samagotchi/peer_say.rb +46 -21
  97. data/lib/samagotchi/peer_wait_expiry.rb +47 -0
  98. data/lib/samagotchi/plugin/api.rb +13 -1
  99. data/lib/samagotchi/plugin/card.rb +68 -11
  100. data/lib/samagotchi/plugin/context.rb +33 -2
  101. data/lib/samagotchi/plugin/panes.rb +54 -0
  102. data/lib/samagotchi/plugin/peer.rb +170 -63
  103. data/lib/samagotchi/plugin/peer_pairing.rb +290 -0
  104. data/lib/samagotchi/plugin/peer_start.rb +301 -0
  105. data/lib/samagotchi/plugin/peer_start_hook.rb +207 -0
  106. data/lib/samagotchi/plugin/peers.rb +89 -9
  107. data/lib/samagotchi/recap_setup.rb +40 -3
  108. data/lib/samagotchi/self_report.rb +25 -6
  109. data/lib/samagotchi/send_command.rb +6 -6
  110. data/lib/samagotchi/served_lookup.rb +225 -0
  111. data/lib/samagotchi/served_ref.rb +41 -0
  112. data/lib/samagotchi/session_access/contract.rb +6 -0
  113. data/lib/samagotchi/session_access/local.rb +149 -40
  114. data/lib/samagotchi/session_access/remote.rb +4 -4
  115. data/lib/samagotchi/session_access/remote_peers.rb +8 -5
  116. data/lib/samagotchi/session_chain/links.rb +8 -3
  117. data/lib/samagotchi/session_commands.rb +40 -8
  118. data/lib/samagotchi/session_continue.rb +11 -6
  119. data/lib/samagotchi/session_lifecycle/allowed.rb +4 -2
  120. data/lib/samagotchi/session_manager/delivery.rb +5 -0
  121. data/lib/samagotchi/session_manager/lifecycle.rb +58 -7
  122. data/lib/samagotchi/session_manager/removal.rb +3 -0
  123. data/lib/samagotchi/session_manager/spawn.rb +6 -1
  124. data/lib/samagotchi/session_model_settings.rb +7 -3
  125. data/lib/samagotchi/session_stores.rb +25 -11
  126. data/lib/samagotchi/sessions_command.rb +16 -3
  127. data/lib/samagotchi/system_one/http_backend.rb +111 -10
  128. data/lib/samagotchi/system_one/runs.rb +5 -2
  129. data/lib/samagotchi/system_prompt.rb +11 -4
  130. data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -1
  131. data/lib/samagotchi/terminal_ui/formatting.rb +26 -12
  132. data/lib/samagotchi/terminal_ui/status_row.rb +20 -3
  133. data/lib/samagotchi/terminal_ui.rb +1 -1
  134. data/lib/samagotchi/testing/boundary.rb +0 -1
  135. data/lib/samagotchi/testing/bundle.rb +6 -2
  136. data/lib/samagotchi/testing/host.rb +1 -0
  137. data/lib/samagotchi/testing/recorder.rb +3 -0
  138. data/lib/samagotchi/turn_endings.rb +6 -2
  139. data/lib/samagotchi/user_typed.rb +29 -0
  140. data/lib/samagotchi/version.rb +1 -1
  141. data/lib/samagotchi/web/app.rb +8 -20
  142. data/lib/samagotchi/web/participant_review.rb +1 -1
  143. data/lib/samagotchi/web/participant_view.rb +1 -1
  144. data/lib/samagotchi/web/peer_routes.rb +40 -15
  145. data/lib/samagotchi/web/public/agent_rows.js +206 -0
  146. data/lib/samagotchi/web/public/agent_runs.js +595 -0
  147. data/lib/samagotchi/web/public/answer_fold.js +41 -44
  148. data/lib/samagotchi/web/public/app.js +4 -4
  149. data/lib/samagotchi/web/public/block_fix.js +1 -1
  150. data/lib/samagotchi/web/public/card.js +26 -10
  151. data/lib/samagotchi/web/public/cards_place.js +6 -4
  152. data/lib/samagotchi/web/public/context_chips.js +24 -2
  153. data/lib/samagotchi/web/public/copy.js +8 -2
  154. data/lib/samagotchi/web/public/data.js +2 -1
  155. data/lib/samagotchi/web/public/format.js +9 -1
  156. data/lib/samagotchi/web/public/history_reveal.js +5 -2
  157. data/lib/samagotchi/web/public/index.html +56 -2
  158. data/lib/samagotchi/web/public/info_bar_model.js +1 -1
  159. data/lib/samagotchi/web/public/model_pick.js +18 -5
  160. data/lib/samagotchi/web/public/model_picker.js +1 -1
  161. data/lib/samagotchi/web/public/page_view.js +1 -1
  162. data/lib/samagotchi/web/public/pages.css +1 -7
  163. data/lib/samagotchi/web/public/peer_chip.js +15 -5
  164. data/lib/samagotchi/web/public/peer_data.js +4 -2
  165. data/lib/samagotchi/web/public/peer_mailbox_api.js +2 -1
  166. data/lib/samagotchi/web/public/peer_note.js +4 -2
  167. data/lib/samagotchi/web/public/peer_row.js +37 -0
  168. data/lib/samagotchi/web/public/peer_wait.js +36 -0
  169. data/lib/samagotchi/web/public/quiet_notes.js +12 -1
  170. data/lib/samagotchi/web/public/revise_stack.js +5 -2
  171. data/lib/samagotchi/web/public/send_turn.js +11 -3
  172. data/lib/samagotchi/web/public/served_ref.js +9 -0
  173. data/lib/samagotchi/web/public/session_fields.js +1 -0
  174. data/lib/samagotchi/web/public/session_state.js +4 -0
  175. data/lib/samagotchi/web/public/stage_missing.js +23 -6
  176. data/lib/samagotchi/web/public/stream_handlers.js +16 -0
  177. data/lib/samagotchi/web/public/turn_block.js +4 -0
  178. data/lib/samagotchi/web/public/version_notices.js +7 -1
  179. data/lib/samagotchi/web/session_control.rb +19 -10
  180. data/lib/samagotchi/web/session_show.rb +20 -0
  181. data/lib/samagotchi/web/update_ops.rb +2 -2
  182. data/lib/samagotchi/worker/command_queue.rb +3 -0
  183. data/lib/samagotchi/worker/mail.rb +24 -1
  184. data/lib/samagotchi/worker.rb +8 -5
  185. data/lib/samagotchi/worker_inbound/mail.rb +34 -6
  186. data/lib/samagotchi/worker_inbound.rb +11 -3
  187. data/lib/samagotchi/worker_link.rb +13 -1
  188. data/lib/samagotchi/worker_wakes.rb +33 -5
  189. metadata +22 -2
  190. data/lib/samagotchi/web/public/pages_group.js +0 -67
@@ -167,7 +167,7 @@ or `chi web` restart.
167
167
  | `toolkit.kits`, `execute.description`, `llm_context.policy` | Worker start | These are held by the engine's toolkit or tool registry. |
168
168
  | `toolkit.suggest.mode`, `toolkit.suggest.threshold`, `toolkit.suggest.defer_turns`, `toolkit.suggest.defer_tokens` | Worker start | Suggestion settings are config-only and are resolved when the worker runs its audit or on-mode ask. |
169
169
  | `skip_agents_md` | Prompt rebuild | A running engine caches its built prompt; a new worker or `/model` rebuild uses the changed value. |
170
- | `context.*` except `context.every_seconds`, `peer.turns`, `objectives.*`, `llm_context.*` except `llm_context.policy`, `steer.cut_after`, `memory.index_warn_tokens`, `memory.entry_warn_tokens`, `status.line`, `web.participants.*` | Next matching turn, display, poll or write | Readers resolve these settings when they perform that operation. Session-specific LLM context and thinking values remain saved in the session. A participant's grant keeps the expiry and cap it was issued with; `web.participants.*` is what the next invite gets, and the cap and queue of a grant from before caps. |
170
+ | `context.*` except `context.every_seconds`, `peer.turns`, `peer.quiet_minutes`, `objectives.*`, `llm_context.*` except `llm_context.policy`, `steer.cut_after`, `memory.index_warn_tokens`, `memory.entry_warn_tokens`, `status.line`, `web.participants.*` | Next matching turn, display, poll or write | Readers resolve these settings when they perform that operation. Session-specific LLM context and thinking values remain saved in the session. A participant's grant keeps the expiry and cap it was issued with; `web.participants.*` is what the next invite gets, and the cap and queue of a grant from before caps. |
171
171
  | `context.every_seconds` | Next context poll | The poller checks it for each source that has no explicit interval. |
172
172
  | `guardrails.*` | Next tool call or approval | Guardrail rules and disable lists are reloaded when the config file changes; rule settings take effect on that evaluation. `guardrails.parent_answers` is checked when a parent answers a question. |
173
173
  | `system_one.host`, `system_one.model`, `system_one.timeout_ms`, `system_one.runs`, `system_one.judgments` | Next tool call or approval | Each ask reads them. |
@@ -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". |
@@ -2365,7 +2431,8 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2365
2431
  | `context.status_thresholds` | `20,40,60,80` | yes | Percentages that put the estimate into a bucket; the rise into a guidance bucket (from the second up) leaves the model its own `[CONTEXT: …]` line, and the bucket decides the guidance. |
2366
2432
  | `context.every_seconds` | `300` | | How often an attached context source's command runs when it has no `--every` (seconds, at least 30). See [Attached context](context.md). |
2367
2433
  | `context.wake` | `true` | yes | A source whose update says `wake: true` may start a turn in a live, idle session (one per source per 10 minutes, within `session.max_wakes`); so may a session's pushed source's first push. `false`: updates wait as notes for the next turn. Attached context's only: a peer's messages have `peer.turns`. See [Waking](context.md#waking). |
2368
- | `peer.turns` | `3` | yes | Wake turns in a row a peer agent's messages may start (`chi peer say --wake`, a peer a loaded bundle declares), with no message typed in the web or a TUI in between (`chi send` doesn't count); within `session.max_wakes`. Then messages wait as notes, the say's line says so (`held: … (peer.turns)`), and the UIs hear it once. A message whose summary ends its verdicts with `VERDICT OK` wakes once to close the round, counted toward `session.max_wakes` only. `0`: a peer's message never wakes chi. Replaces `context.peer_turns` (no alias: an old key is ignored). See [peers.md](peers.md). |
2434
+ | `peer.turns` | `3` | yes | Wake turns in a row a peer agent's messages may start (`chi peer say --wake`, a peer a loaded bundle declares), with no message typed in the web or a TUI in between (`chi send` doesn't count; the count survives a worker restart); within `session.max_wakes`. Then messages wait as notes, the say's line says so (`held: … (peer.turns)`), and the UIs hear it once. A message whose summary ends its verdicts with `VERDICT OK` wakes once to close the round, counted toward `session.max_wakes` only. `0`: a peer's message never wakes chi. Replaces `context.peer_turns` (no alias: an old key is ignored). See [peers.md](peers.md). |
2435
+ | `peer.quiet_minutes` | `30` | yes | Minutes with no exchange between chi and a peer (no send to it, no message from it, no pairing; the link a continue came from counts too) after which the pairing is dormant: the peer's session may be cold. A send the model starts then asks you first (Send / Don't send) in a turn you started from the web or a TUI, and is refused at once in any other turn (a schedule's, a delegate's, a wake turn, `chi send`'s), the model told that you decide; "Don't send" holds for the rest of the turn. A `/claude …` or `/codex …` you type never asks. The status card says `quiet 2 h: a send from the model asks first`. The pairing stays. `0`: never asks. See [peers.md](peers.md#quiet-pairings). |
2369
2436
  | `context.candidates.mode` | `off` | | The candidate judge: `off` (the default: no conversation text goes to a System 1 host), `audit` (asks System 1 whether the session's work is about each proposed candidate and logs it in `context_candidates.jsonl`; attaches nothing), `on` (the same asks, acted on: attached at `threshold`, a card from `offer_threshold`; see [On mode](context.md#on-mode)). Its host and model are `system_one.host` / `.model`. config.yml only. See [The judge](context.md#the-judge). |
2370
2437
  | `context.candidates.threshold` | `0.8` | | The probability at which the judge attaches a candidate in on mode (a judged line's `would: attach`). config.yml only. |
2371
2438
  | `context.candidates.offer_threshold` | `0.6` | | The probability from which on mode shows the candidate's card, once (`would: offer`, below `threshold`). config.yml only. |
@@ -2390,7 +2457,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
2390
2457
  | `memory.read_max_chars` | `0` | yes | The most characters one `memory_read` result holds. `0`: no fixed cap, a memory is read whole (`max_tool_output_chars` does not apply to `memory_read`, in any form: one name, a comma list, a blank name). A positive value cuts a longer result and ends it with `[cut: N of M chars; the rest is in the memory's .md file in <dir>: read it with start_line]`. `memory:` is its own section. See [Memory](memory.md). |
2391
2458
  | `max_tool_output_chars` | `10000` | yes | Characters of each tool output kept in the conversation (both loops). A longer one is cut: an `execute` result keeps its first and last lines with a gap line between them and is saved whole in the session's folder (`sessions/<id>/tool_output/`; the gap line names the file, and the model reads it there instead of running the command again); any other tool's keeps its head and ends with `[cut: N of M chars; read it in parts]`. `memory_read` is the exception: `memory.read_max_chars` caps it. See [Tool output guardrails](internals/tool-output-limits.md#the-runners-cut-max_tool_output_chars). A top-level key (see below). |
2392
2459
  | `cache.warmup` | `auto` | | `auto`: after a turn, send the next turn's prompt (up to the next message) to a local llama.cpp host on the native loop, so the next turn prefills only its message; never a remote or `api: openai` host. `off`: never. See [prompt caching](internals/prompt-caching.md#the-turn-end-warm-up). |
2393
- | `cache.ttl` | `5m` | | How long Anthropic keeps the prompt-cache breakpoints of a Claude model on a remote host: `5m` (Anthropic's default) or `1h`. A 1h cache write costs 2× the input price (5m: 1.25×), a read the same 0.1×. See "Remote or local". |
2460
+ | `cache.ttl` | `5m` | | How long Anthropic keeps the prompt-cache breakpoints of a Claude model on a remote host: `5m` (Anthropic's default) or `1h`. A 1h cache write costs 2× the input price (5m: 1.25×), a read the same 0.1×. It is also how long after a turn a peer's own message counts as finding the cache cold ([peers.md](peers.md#a-cold-cache)). See "Remote or local". |
2394
2461
  | `cache.key` | `off` | | `session`: send the session id as `prompt_cache_key` to OpenAI's API and OpenRouter, which route and cache by it; no other host gets it. `off`: none. |
2395
2462
  | `retry.max` | `5` | yes | See "Llama Network Retry Behavior". |
2396
2463
  | `retry.base_delay` | `0.5` | yes | |
data/docs/context.md CHANGED
@@ -234,8 +234,9 @@ summary, the hint's link, the text and detach (or mute here, for a project
234
234
  source). The web attaches nothing itself: `chi context add <URL>` does.
235
235
  A paired peer has a chip of its own there, drawn first, and its messages are
236
236
  bubbles from the peer ([peers.md](peers.md), [bundles.md](bundles.md#the-claude-peer-bundle)). A context note sits in
237
- chi web's closed notes row ([cli.md](cli.md#web-markdown-rendering)) unless it starts a turn: a wake's note is that turn's
238
- opening and stays a bubble.
237
+ chi web's closed notes row ([cli.md](cli.md#web-markdown-rendering)), or in the closed line it shares with the
238
+ delegate reports and peers' answers next to it, unless it starts a turn: a wake's note is that turn's opening and
239
+ stays a bubble.
239
240
 
240
241
  ## Waking
241
242
 
@@ -345,8 +346,8 @@ An archived session that nobody continued takes pushes as before; a schedule's a
345
346
 
346
347
  ### Peers and a continue
347
348
 
348
- A peer's pairing and mailbox stay with the old session; the peer is told the
349
- new id and pairs again, and what it said that the old session hadn't read
349
+ A peer's pairing follows the chain (the continue copies it) and its messages
350
+ stay with the old session; what it said that the old session hadn't read
350
351
  reaches the new one as one note: [peers.md](peers.md#continuing-a-session).
351
352
 
352
353
  ## Candidates
@@ -615,7 +616,9 @@ that way for simplicity). Whoever can define a source can run code later, so:
615
616
  in every mode, once at a time (the guardrails bundle's `chi-context-cmd`
616
617
  rule); a parent agent can't approve it for a child. A URL resolved by an
617
618
  installed bundle and `push` aren't asked about: their command is the
618
- bundle's, or there is none.
619
+ bundle's, or there is none. The [coordinator skill](bundles.md#the-coordinator-bundle)
620
+ is a shipped text that has the agent attach sources itself (a script of its own under
621
+ `~/.local/share/chi-watch/`), so its watches ask here.
619
622
  - The file tools can't write the store: `<state dir>/context/` is a protected
620
623
  path (denied), and a shell command that names it asks (`shell-touches-chi`).
621
624
  - The web adds URLs only.
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
@@ -561,14 +561,19 @@ message:
561
561
  `batch`;
562
562
  - owner-voiced tools, which act in the owner's name beyond the turn:
563
563
  `delegate` and any `delegate_*` tool, `register_reminder`,
564
- `cancel_reminder`, `schedule_task`, `list_schedules`, `cancel_schedule`
564
+ `cancel_reminder`, `schedule_task`, `cancel_schedule`
565
565
  (a durable schedule outlives the session and fires on this machine),
566
- `send_note`, `forget_outputs`, `task_create`,
566
+ `send_note`, `ask_session`, `forget_outputs`, `task_create`,
567
567
  `task_stop`, `find_tools` (it loads tools into the session), `objectives`
568
568
  (a move on the owner's list), and
569
- `memory_write` (a memory reaches the owner's later sessions); and the tools
569
+ `memory_write` (a memory reaches the owner's later sessions); the tools
570
570
  that read the owner's background tasks and their output, `task_wait`,
571
- `task_get`, `task_list` (a pair turn starts none);
571
+ `task_get`, `task_list` (a pair turn starts none); and the ones that read
572
+ the owner's other sessions, reminders and schedules and the session's
573
+ attached context: `list_sessions`, `list_reminders`, `list_schedules`,
574
+ `context_read`. Every built-in tool has its place in
575
+ `PairBoundary::TOOL_CLASSES` (a spec fails on one that hasn't); a plugin's
576
+ or an MCP server's tool goes on to the path and command checks;
572
577
  - `ask_user_question`, with the advice to ask in the reply: nobody on the
573
578
  participant's side answers a card.
574
579
 
@@ -1114,7 +1119,7 @@ local Splash server, or the hosted Jev API — and its key is that host's own
1114
1119
  ```yaml
1115
1120
  system_one: # what every use of System 1 shares
1116
1121
  host: splash # the hosts: entry serving /v1/systemone
1117
- 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
1118
1123
  timeout_ms: 2000 # a slower judgment is no judgment
1119
1124
  guardrails:
1120
1125
  system_one: # approvals' own
@@ -1125,6 +1130,16 @@ guardrails:
1125
1130
  min_record: 5 # clean records a rule needs before it is trusted
1126
1131
  ```
1127
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
+
1128
1143
  `SystemOne::Client.from_config(host_registry:, mode:)` reads these on every
1129
1144
  call, so a config.yml change takes effect on the next ask. `mode: off` (the
1130
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:`,
@@ -661,7 +661,9 @@ newer worker; never driven, `wake` answers 409 `worker_newer`); else `Live` (its
661
661
  holder as the caller already read it (nil: free), so one read serves a summary and its status. `WorkerLink.client` is
662
662
  the Live's client or nil; `WorkerLink.await` polls for a new worker's Live (an `until:` check tells a restart's
663
663
  successor from the old worker); chi web's `App#worker_link` / `#await_worker_link` wrap them. The Bridge writes
664
- `pid` and `protocol` with its port and removes its sidecar on stop only when the file still carries its epoch.
664
+ `pid` and `protocol` with its port and removes its sidecar on stop only when the file still carries its epoch. When to
665
+ bump `protocol` (the owner's OK each time; additive changes never) is in docs/releasing.md, "Bumping
666
+ WorkerLink::PROTOCOL"; `spec/worker_link_contract_spec.rb` pins each protocol's sidecar keys, routes and features.
665
667
 
666
668
  The sidecar's `features` array is the worker's capability handshake: clients check a name rather than infer
667
669
  compatibility from its version. `Bridge::FEATURES` advertises:
@@ -23,7 +23,7 @@ read side, never the reverse.
23
23
  <system memories>/.bundles/ MemoryPaths.bundles_dir
24
24
  <name>/manifest.json the install record (Provenance#write, read as InstalledBundles::Record)
25
25
  <name>/manifest.yml the bundle's own manifest as installed (Provenance#write's manifest_from:), its sha
26
- the record's manifest_sha; a dev install links it to the source (DEV_SHA)
26
+ the record's manifest_sha; a dev install links it to the source (`InstalledBundles::Sha::DEV`)
27
27
  <name>/bases/ each file's base for the next upgrade's 3-way merge: as installed, or the
28
28
  bundle's own text after a merge
29
29
  <name>/incoming/ the bundle's text for each file marked conflict, until the file settles (Provenance:
@@ -67,7 +67,7 @@ read side, never the reverse.
67
67
  | `TextMerge` | the text merge: `.merge(base:, ours:, theirs:)` → a `Result` (`status` `:clean` with `text`, `:conflict` with `hunks`, `:failed` with `why`). `git merge-file -p --diff3 --marker-size=20` on temp copies in a temp cwd, with every `GIT_*` that points at a repository or a config unset or at `/dev/null` (it can run inside another tool's hook). git isn't a runtime dependency: none on PATH, or macOS's `/usr/bin/git` with no developer tools behind it (`.apple_stub?`, by `xcode-select -p`; running it pops a dialog), is `:failed`. So is a git past `TIMEOUT` (10 s; its process group is killed: this runs under `SystemBundle`'s lock), and any doubt about the answer: `min(hunks, 127)` against the exit status, a status over 127, a NUL in a side, marker lines that don't pair up (a user's line equal to one), a line no input holds, or an empty answer to non-empty inputs. `Scan` reads the output: a hunk unions (ours, then the entries of theirs that ours lacks) only when the last heading before it, at level 1 or 2 and outside code fences, HTML comments and any hunk, is titled exactly `Changelog` or `Change log`, with nothing but list entries (an item and its indented lines) since that heading and no fence or comment open, and base, ours and theirs each hold only list entries, with every base entry still on both sides: both only added. Any other hunk is a real conflict, and markers never leave the module. An entry is an item and the lines indented deeper under it, nested items too, and the union compares whole entries. `.changed_sections(base, theirs, ours)`: the headings of the sections the bundle changed and the file hasn't got, and whether text under no heading did, which is what names a miss: a conflict's hunks can't, since the whole file stays and the one hunk may be a Changelog line beside a whole new section. `Hunk#heading` counts the places under no heading |
68
68
  | `InstalledBundles::FileStanding` (installed_bundles/file_standing.rb) | the one owner of what chi says of an edited bundle file, used by every surface: `Behind` (`#state`, `#line`: `x.md stays behind 0.8.0: no merge possible (why); missed ## A, ## B, ## C and 2 more`, `would stay` in a dry run), `MergeNote`, `.merged_line`, `.no_merge` (for `LEGACY_BASE` it says chi can't tell whether the file holds edits), `.clauses` (a report's clauses for one bundle), `.behind_count`, `.stay_behind`, `.counts_sentence` (the push), `.still_behind`, `.text` (UTF-8, whatever a name or heading was tagged), `FORCE_TAKES`, `FORCE_MOVES`, `IN_THE_TRASH`. Behind means marked and bytes other than the mark's `incoming_sha` (`.behind?`, read by `InstalledBundles::Record#behind_files` and `Remerge` alike): a file brought level by hand isn't, a missing one is a missing file, and one that can't be read is. An older mark no retry has looked at reads `may be behind` (`Behind#unsure`, and the counts say so), and isn't behind at all when level with its recorded source on disk (`InstalledBundles::Record#behind_file?`). A new surface reads these and adds no wording |
69
69
  | `Remerge` | the retry at the same version, memory files only, for a file marked `conflict` (its `FileState` and `REMERGE` row; a `:decide` cell through `Merger::Upgrade#decision`): `#run(dry_run:)` → a `Result` (`merged`, `settled`, `stamped`, `behind`, `warnings`, `trash_copy`). It merges what merges and settles those entries (`Provenance#resolve_conflicts`, the index line refreshed), checking a merged incoming file against the manifest's sha256, in a dry run too. It leaves `version`, `installed_at` and the assets alone: the Installer would `rm_rf` guardrails, plugin and scripts under live sessions. Every file it leaves is in `behind`, with why: one not shipped now (`MemoryFiles.select`) keeps its mark, base and text; one whose `incoming_sha` isn't the shipped text (a checkout at one VERSION) is left alone, no git runs, and it reads as its mark says; a mark with no digest (older chi) is tried as well, and a real conflict then records it (`Provenance#refresh_marks`, which writes only when the mark would read differently, so a conflict at each start writes nothing). A mark whose digest matches is tried on every run, since the file or git may have changed. `noop` and `keep` settle quietly; `fast_forward` waits for the next upgrade, reading as behind until then; `install` is a missing file, which isn't behind, and a warning says so. A file it can't read or replace stays as it is, saying why. Called from `ShippedUpdate.plan_row`/`apply` (`chi update`) and `SystemBundle.sync`'s equal-version branch, under its lock (each chi start and `chi update`); a bundle chi doesn't ship retries through `chi bundle upgrade`. No marks: nothing is read beyond the record. One marked file costs one git run per Engine start, about 12 ms on the Studio (0.1 ms with none) |
70
- | `Provenance` | the `.bundles/<name>/` dir's write side (an `InstalledBundles::Dir`): `#write` the record + bases (its `files:` is the full list: a key left out is dropped, a nil value keeps the entry with no base; `marks:` are the files left behind, each a `FileStanding::Behind`, and `incoming_dir:` the bundle text each speaks of, recorded as `incoming_sha` and saved at `#incoming_path`; an older mark that stays keeps `legacy_base`), `#resolve_conflicts` (base to the incoming file, mark and its fields (`MARK_FIELDS`) and saved text gone; a file whose incoming copy is gone keeps both), `#refresh_marks` (what a retry found: why, missed, the digest and `legacy_base`, the saved text), `#note_merged` and `#clear_merge_notes(notes)` (`MERGE_NOTE_FIELDS`, kept through `#write`; the saved text is best effort, after the manifest, so it can't leave a plugin under the old record's sha; any other failure writing the record still can, until a retry), `#record` → `InstalledBundles::Record` (the Dir's). `#write(manifest_from: DIR)` keeps `DIR/manifest.yml` at `#kept_manifest_path` (written aside and renamed; for `dev:` a link to its realpath) and records `manifest_sha` (`FileDigest.sha256`, `DEV_SHA` for dev) and `installed_by` (this chi's VERSION); the Installer and `Profile.install` pass their source dir, and a write without it carries the existing record's two fields, the kept file left alone. The in-place edits (`#resolve_conflicts`, `#record_restored`, `#refresh_marks`, `#note_merged`, `#clear_merge_notes`) keep them. The record's mirror of the manifest keys (`requires_chi` … `setting_types`) is still written from the kwargs, exactly as before: an older chi sharing the memories dir (an old worker, chi web, gem or worktree) reads only the record, and without the mirror's `requires_chi` it would load a too-new bundle's plugin. A key a later manifest gains is never mirrored. Any chi without the kept manifest that rewrites a record drops `manifest_sha` and `installed_by` (it rebuilds the record from its own kwargs). `#adopt_manifest(dir, dry_run:)` heals such a record (`InstalledBundles::Record#manifest_unkept?`: no `manifest_sha`, or its file gone): when `dir` is the source of what's installed (its manifest names the bundle at the recorded version; each mirrored key, normalised as `#mirror_fields` records it (the one shape `#write` uses too), equals the record's, a key the record lacks being fine only when `BundleManifest::SINCE` has it, since an older chi couldn't have recorded it (a recorded hook doesn't count: retired); and every recorded plugin, hook, script, rule and unmarked memory sha is that of `dir`'s file; else the why names the key or file) it keeps `dir/manifest.yml` and records `manifest_sha`, nothing else (not `installed_at`, the mirror or `installed_by`); otherwise it returns why and writes nothing. Never for a dev record (its next `install --dev` links the file) |
70
+ | `Provenance` | the `.bundles/<name>/` dir's write side (an `InstalledBundles::Dir`): `#write` the record + bases (its `files:` is the full list: a key left out is dropped, a nil value keeps the entry with no base; `marks:` are the files left behind, each a `FileStanding::Behind`, and `incoming_dir:` the bundle text each speaks of, recorded as `incoming_sha` and saved at `#incoming_path`; an older mark that stays keeps `legacy_base`), `#resolve_conflicts` (base to the incoming file, mark and its fields (`MARK_FIELDS`) and saved text gone; a file whose incoming copy is gone keeps both), `#refresh_marks` (what a retry found: why, missed, the digest and `legacy_base`, the saved text), `#note_merged` and `#clear_merge_notes(notes)` (`MERGE_NOTE_FIELDS`, kept through `#write`; the saved text is best effort, after the manifest, so it can't leave a plugin under the old record's sha; any other failure writing the record still can, until a retry), `#record` → `InstalledBundles::Record` (the Dir's). `#write(manifest_from: DIR)` keeps `DIR/manifest.yml` at `#kept_manifest_path` (written aside and renamed; for `dev:` a link to its realpath) and records `manifest_sha` (`FileDigest.sha256`, `InstalledBundles::Sha::DEV` for dev) and `installed_by` (this chi's VERSION); the Installer and `Profile.install` pass their source dir, and a write without it carries the existing record's two fields, the kept file left alone. The in-place edits (`#resolve_conflicts`, `#record_restored`, `#refresh_marks`, `#note_merged`, `#clear_merge_notes`) keep them. The record's mirror of the manifest keys (`requires_chi` … `setting_types`) is still written from the kwargs, exactly as before: an older chi sharing the memories dir (an old worker, chi web, gem or worktree) reads only the record, and without the mirror's `requires_chi` it would load a too-new bundle's plugin. A key a later manifest gains is never mirrored. Any chi without the kept manifest that rewrites a record drops `manifest_sha` and `installed_by` (it rebuilds the record from its own kwargs). `#adopt_manifest(dir, dry_run:)` heals such a record (`InstalledBundles::Record#manifest_unkept?`: no `manifest_sha`, or its file gone): when `dir` is the source of what's installed (its manifest names the bundle at the recorded version; each mirrored key, normalised as `#mirror_fields` records it (the one shape `#write` uses too), equals the record's, a key the record lacks being fine only when `BundleManifest::SINCE` has it, since an older chi couldn't have recorded it (a recorded hook doesn't count: retired); and every recorded plugin, hook, script, rule and unmarked memory sha is that of `dir`'s file; else the why names the key or file) it keeps `dir/manifest.yml` and records `manifest_sha`, nothing else (not `installed_at`, the mirror or `installed_by`); otherwise it returns why and writes nothing. Never for a dev record (its next `install --dev` links the file) |
71
71
  | `InstalledBundles::Manifest` (installed_bundles/manifest.rb) | the one answer to "this installed bundle's manifest" (`InstalledBundles::Record#manifest`): requires_chi, trust_level, needs, the scripts' names, context providers, block renderers, pages (`pages:`, kept file only: never mirrored, so `[]` from the record), session settings and settings with their types, file descriptions, a profile's includes. Read from the kept `manifest.yml` (`origin: :kept`) when the record's `manifest_sha` is set and the file still has it (`InstalledBundles::Sha.matches?`, so a dev link is never checked), else from the record's `mirror` (`origin: :record`), in these cases: no kept file and no `manifest_sha` (a record from before chi kept it; no problem); no kept file, or something other than a file in its place, while `manifest_sha` is set (`:missing`); a kept file and no `manifest_sha` (a chi without the kept manifest rewrote the record: `problems["manifest.yml"] = :stale`); a kept file with another sha, or one that isn't a YAML mapping (`:edited`); the sha matches (`:kept`). `#standing` is that symbol, `#key_problems` the rest. The kept file is read by `BundleManifest.tolerant` key by key in a fixed order (its comment): a key that doesn't parse under this chi takes the mirror's value if that parses, else empty, with its message in `problems` (a reader that logged it logs that); `block_renderers` is checked against the record's scripts when the kept `scripts:` fails, and an older install's `hooks:` is ignored (no problem row). `description` and `unknown_keys` come only from a kept file; a profile's `includes` is always the record's (its members, identity). The value is deep-frozen, since callers share it. One process-wide cache (a Hash under a Mutex, cleared at `CACHE_LIMIT`) keyed by the record value and the kept file's stat (mtime, size, inode, device; a dev link's target): chi web asks per request, a worker at start and per `ContextProviders.resolve`. `#requires_chi_failure(version = VERSION)` is the one requires_chi gate; `#experimental?`, `#needs?`, `#context_providers?`, `#block_renderers?`, `#pages?` |
72
72
  | `ManifestStanding` (manifest_standing.rb) | the one owner of the words for an installed bundle's `manifest.yml` as `InstalledBundles::Manifest` read it: `.state` (`:kept`, `:legacy`, `:stale`, `:missing`, `:edited`), `.label` (`[kept]` / `[from the install record]`), `.line(bundle, refused:)` (the case and the command: `chi bundle upgrade NAME` (reads it again from a git URL, or a source that didn't match, with why), `chi update keeps it` while untried, the source is gone (`Installer.source_gone_line`), `chi bundle install --dev SOURCE` for a dev record; for a kept one, only the keys whose `BundleManifest::SINCE` floor is above the record's `installed_by`: newer than its installer), `.keep(bundle, source_dir:, dry_run:)` → `Outcome` (the record after, the line, `kept`): `Provenance#adopt_manifest` from `source_dir`, else from the recorded source (a dir; a zip/tar through `PreparedSource`, cleaned up; never a git clone). Read by `ShippedUpdate` (`Row#manifest`, the plan's dry `keep` and apply's), `UpdateCommand#external_rows` (a `kept its manifest` row, else a warn row, before the bundle's re-check, which then sees the kept file) and `chi bundle status NAME` (`BundleCommand#manifest_line`: `Manifest:`, the label, `.status_line`: for a record with a folder source (a bundle chi ships: this chi's shipped copy at the recorded version, which `chi update` reads), a dry `adopt_manifest` first, so the line says whether `chi update` keeps it or why not; an archive isn't extracted there, its line says `chi update tries to keep it`; a profile chi doesn't ship is never kept by `chi update`, so its line names `chi bundle upgrade NAME`) |
73
73
  | `InstalledBundles::Record`, `BundleHook`, `PluginRef` (installed_bundles/record.rb, bundle_hook.rb, plugin_ref.rb) | value objects for the record; tolerant of older records (missing keys read as empty). `InstalledBundles::Record`'s members are identity and state (name, version, scope, source, `installed_at`, `source_commit`, files and their marks, hooks, guardrails, scripts and the plugin with their shas, a profile's `includes`, `dev`, `dir`, the kept manifest's `manifest_sha` and `installed_by`, nil on a record from before it was kept); the manifest keys it records sit in one `mirror` Hash (`MIRROR_KEYS`, frozen: a key a later manifest gains is never mirrored) that only `InstalledBundles::Manifest` reads, so manifest data is read through `#manifest`. `BundleHook` is an older record's hook entry: `.parse` and `#sha256` (what the retire, uninstall and the trash selection read) |
@@ -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
@@ -48,7 +48,7 @@ runner too (its `Pages.script_path`), accepted: the shipped one loads the schedu
48
48
  ## The one launch path
49
49
 
50
50
  `chi page run` does not run the script in its own process. `Launch.run` starts the runner, exactly as chi web's
51
- Refresh will (Build 2), so a page that passes from the terminal passes on Refresh (the spike saw two paths give a
51
+ Refresh does, so a page that passes from the terminal passes on Refresh (the spike saw two paths give a
52
52
  script 152 against 73 preloaded libraries and a stale `PWD`). It costs about 70 ms more per terminal run.
53
53
 
54
54
  1. `Pages.check_name!`, then the script must exist (`Missing`), then `Store.locked(name)`: a non-blocking `flock` on
@@ -58,7 +58,8 @@ script 152 against 73 preloaded libraries and a stale `PWD`). It costs about 70
58
58
  2. `ProcessGroup.spawn(env, RbConfig.ruby, "-I", <this chi's lib>, "-e", 'require "samagotchi/pages/runner"; exit
59
59
  Samagotchi::Pages::Runner.run(ARGV)', NAME, TIMEOUT, DEADLINE, 3 => lock)`, in a group of its own, `chdir:` the
60
60
  pages folder, stdin closed, the lock on fd 3. The env is a worker's changes
61
- (`SessionManager::WorkerCommand#spawn_options`): `ChildEnv.unbundled` (an installed gem's Bundler changes undone),
61
+ (`SessionManager::WorkerCommandPart#spawn_options`, private in `session_manager/worker_command.rb`):
62
+ `ChildEnv.unbundled` (an installed gem's Bundler changes undone),
62
63
  `ChildEnv.unset` (the spawner's guardrails settings and session markers), `Launch.cleared_keys` unset
63
64
  (`CHI_REMOTE`, every `SAMAGOTCHI_WORKER_*` key and the vendor agent markers `AgentCaller::VENDOR_MARKERS`:
64
65
  `CLAUDECODE`, `CODEX_THREAD_ID`, `AI_AGENT`, read from those constants), `Paths.absolute_xdg`, and `PWD` set to the
@@ -187,8 +188,7 @@ pages: `load` shares a read that is out, `reload` asks again, a failed read keep
187
188
  `pages_list.js` (the Pages list, `#/pages`: its hash, its cards in `/api/pages`'s order), `page_view.js` (the header, the states, the calls; an answer for a page no longer open is
188
189
  dropped, `latest.js`), `page_model.js` (the words: meta, the failed and changed lines, Copy the error), `page_blocks.js`
189
190
  (text, walk in a widget host with `drawWalk`, an unknown type as one muted line), `page_table.js` and
190
- `page_table_model.js` (cells, sort, the phone's rows), `pages_group.js` (All sessions' former group, kept for an
191
- older cached app.js until after 0.189.0; nothing new imports it), `page_links.js` (the
191
+ `page_table_model.js` (cells, sort, the phone's rows), `page_links.js` (the
192
192
  delegated click on the turn roots and the page view for `#/p/` anchors), `pages.css`. What a script wrote reaches the
193
193
  page as text or attributes, never as markup, except the server's sanitised `html`.
194
194
 
@@ -0,0 +1,66 @@
1
+ # Panes: the windows agents run in
2
+
3
+ A pane is where an agent's own UI runs and where the human can walk in: today a kitty window. It carries no peer
4
+ message (that is the mailbox, [peers.md](peers.md)). `list`, `find` and `show` find and raise a window; `open`,
5
+ `alive?` and `paste` open a background tab and type into it (claude-peer's and codex-peer's `/<peer> start`,
6
+ `Plugin::PeerStart`).
7
+
8
+ `Samagotchi::Panes` (`lib/samagotchi/panes.rb`), the pure parts in `Panes::Kitty` (`panes/kitty.rb`), ported from the
9
+ desktop helper's `Kitty.swift` as they are:
10
+
11
+ - **The sockets:** `kitty.listen_on`'s `unix:` path with `~`, `$VAR` and `${VAR}` expanded from the env, an unknown
12
+ one kept literal (kitty.conf's `${KITTY_PID}` is a literal file name); the files of its folder named the base,
13
+ the base `-<digits>`, or the base with `{kitty_pid}` filled, sockets only. A plain directory listing, never a glob
14
+ (its braces would read `${KITTY_PID}` as alternation). A lookup asks every socket.
15
+ - **The env:** kitty runs with `KITTY_*` removed (as the helper's `KittyRunner#kittyEnv`), so a worker started from a
16
+ kitty window never talks to that one by its variables. The literal socket name and the absolute `kitty.binary`
17
+ work from a process with no `KITTY_*` (the spike checked it from a stripped env).
18
+ - **Finding a window:** the one whose `foreground_processes[].pid` contains the pid (membership: never
19
+ `windows[].pid`, which is the login wrapper or a launcher's sh). Its title is `windows[].title` (never the tab's:
20
+ a tab holds several windows), cleaned as the helper's `AgentText.cleanTitle` (the status glyph dropped).
21
+ - **Show:** `focus-window --match id:N` on its socket: it brings a background tab forward, and a background OS
22
+ window (checked with `kitty @ ls`'s `is_focused` while the screen was unlocked).
23
+ - **Open:** `open(command:, cwd:, title:)` runs `launch --type=tab --keep-focus --cwd DIR --tab-title TITLE ARGV…`
24
+ on the kitty whose OS window is focused (`ls`'s `is_focused`), else the live socket file with the newest mtime (the
25
+ kitty started last), and returns `PaneRef(driver, key)`, the key `<socket>#<window id>` from the id `launch`
26
+ prints. A tab only: `--type=os-window --keep-focus` doesn't keep the focus (the step-0 spike). `launch` has its own
27
+ 15 s limit (`LAUNCH_SECONDS`; `ls` 2 s, the rest 5 s): one killed early may still open a tab no ref names. No socket answering
28
+ raises `Panes::Unavailable`, the one message "kitty isn't running or `kitty.listen_on` isn't set"; a launch that
29
+ fails or prints no id raises `Panes::Error`.
30
+ - **Alive and paste:** `alive?(ref)` is `ls --match id:N` on the ref's socket. `paste(ref, text, enter:)` is the
31
+ helper's `KittyRunner#send`: `alive?` first (send-text reports nothing for a gone window), then
32
+ `send-text --match id:N --bracketed-paste=disable --stdin` with the text wrapped in `ESC[200~ … ESC[201~` (its own
33
+ markers taken out, as `AgentText.text`), then `send-key --match id:N enter` when `enter`. No in-tree caller pastes
34
+ yet: `/codex start` passes its first prompt as Codex's own argument (`codex [PROMPT]`), which doesn't race the
35
+ TUI's start as a paste would.
36
+ - **Config:** `kitty.listen_on` and `kitty.binary` are read at each call (`Panes.from_config`, `Config.get`); their
37
+ lifecycle is `next_pane_lookup` (the desktop helper still copies them into its launch file).
38
+ - **No kitty** (unset, not running, the pid in no window, the binary missing): nothing found, no error; a row then
39
+ has no Show.
40
+
41
+ `ctx.panes` (`Plugin::Panes`, [plugins.md](../plugins.md)) is the plugin's view: `find(pid:)`, `alive?(ref)`, and
42
+ `show`, `open` and `paste`, which raise `Plugin::Panes::NotTyped` unless the command was typed or tapped by a person
43
+ (`ctx.user_typed?`, `UserTyped`): they act as the user on their screen, so no tool call, `chi send`, agent, participant, schedule, delegate or plugin path reaches them. The seam trusts the request's client id, so it is an accident guard as the guardrails are ([guardrails.md](../guardrails.md#protected-paths)), not a sandbox: a model's shell holding the Bridge's secret could still post as a UI, as it can a `!` line. Nothing derived from `.here` is used to open or
44
+ paste: `/<peer> start` keeps its `PaneRef` in the bundle's own session state (`state.json` under `ctx.session_dir`, a
45
+ `SessionStores` row removed with the session), never in the mailbox. That file is not protected (chi's own tools can
46
+ write it), so a ref is checked on every use instead: `alive?`, `show` and `paste` take a ref only when its socket is
47
+ one of `kitty.listen_on`'s own (`Kitty.sockets`), else they answer as for a closed tab and run no `kitty @`; a paired
48
+ session's `/<peer> show` also needs the paired peer's pid in that window. A continue doesn't carry that state (the
49
+ pairing it does).
50
+
51
+ `/<peer> start` (`Plugin::PeerStart`): the checks (typed, no live pairing, claude-peer's start hook current), then
52
+ the wait (`ctx.peers.wait`), then `open` with `[$SHELL, -l, -c, "exec <start_command>"]` (the account's shell when
53
+ `$SHELL` is unset). An open wait (`/<peer> pair`'s) is kept, not rewritten; a pane error takes back only the wait
54
+ this start wrote (`ctx.peers.stop_waiting(name, mark)`, `PeerPresence.drop_wait`: never another wait nor an announce's
55
+ claimed file), so a refusal leaves no mark of its own. A second start while the wait is open and its tab `alive?` (a
56
+ double tap) is refused, "already starting in kitty tab …"; two at the same moment take turns on a flock
57
+ (`start.lock` in `ctx.session_dir`, held across the checks, the wait and the open: commands run in parallel). The tab
58
+ is checked once more 1.5 s after the launch (`PeerStart.settle_seconds`): gone already (its command not found), the
59
+ start's wait is taken back and the reply names `start_command`. The
60
+ status card's started row (scene 5) shows while the ref is `alive?` and the paired Claude's pid (its `PeerHere`) runs
61
+ in that window, and "its kitty tab is closed" once the ref is gone and so is the pairing's socket.
62
+
63
+ Specs: `spec/panes_spec.rb` (on `spec/fixtures/desktop/fake_kitty`, which answers `ls`, `launch`, `focus-window`,
64
+ `send-text` and `send-key`, and logs the argv, stdin and `KITTY_*` env it got; its canned windows carry pids, its OS
65
+ windows `is_focused`) and `spec/samagotchi/bundles/claude_peer_start_spec.rb`. No spec reaches a running kitty
66
+ ([testing.md](../testing.md)).
@@ -220,7 +220,8 @@ Everything else is `:owner`: `/answer`, `/command`,
220
220
  A participant's turn acts with the session's tools under the owner's guardrails, its asks go to the owner and offer
221
221
  once only, and `Guardrails::PairBoundary` denies secrets, chi itself and chi web on loopback, background and
222
222
  scheduled jobs, the environment and credential printers, git config writes (reads only) and git's hooks,
223
- owner-voiced tools and the owner's task outputs, and the model's own question, and asks before a command that makes
223
+ owner-voiced tools, the owner's task outputs, the owner's other sessions, reminders and schedules and the
224
+ attached context (`PairBoundary::TOOL_CLASSES`), and the model's own question, and asks before a command that makes
224
225
  a link and before a write that may land outside the project, failing closed (a global install or a user config write
225
226
  that names no path, `Guardrails::ImplicitWriters`, and a script read from stdin count; a session at or above home has
226
227
  none: every write asks) ([guardrails](../guardrails.md#a-participants-pair-boundary)).
@@ -921,8 +922,9 @@ participant TUI in v1.
921
922
  an event type it doesn't name is dropped.
922
923
  - A participant's message is a turn of its own, or goes into their own running turn at its next step (chi web, the
923
924
  Bridge, the inbox), never into anyone else's turn and never a cut, a command or a
924
- shell line (chi web, the Bridge, the worker), and runs only on a worker with `pair_turns`: the pair boundary denies secrets and
925
- owner-voiced tools, the owner's guardrails decide the rest, and every ask is the owner's, once only.
925
+ shell line (chi web, the Bridge, the worker), and runs only on a worker with `pair_turns`: the pair boundary denies secrets,
926
+ owner-voiced tools and the owner's readers (tasks, other sessions, reminders, schedules, attached context), the
927
+ owner's guardrails decide the rest, and every ask is the owner's, once only.
926
928
  - No turn an older chi ran read-only runs with tool rights: an invite without `mode: "pair"`, or a Verify fresh child
927
929
  saved otherwise, is refused at the worker (`outdated`), and `Guardrails::ParticipantRefusal` denies every call of
928
930
  any other participant turn that isn't a current invite's.