samagotchi 0.183.0 → 0.185.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +84 -1
- data/docs/architecture.md +12 -11
- data/docs/bundles.md +63 -36
- data/docs/cli.md +10 -1
- data/docs/configuration.md +3 -2
- data/docs/context.md +76 -10
- data/docs/guardrails.md +7 -2
- data/docs/hooks.md +1 -0
- data/docs/internals/block-renderers.md +4 -2
- data/docs/internals/bridge.md +7 -3
- data/docs/internals/bundles.md +6 -2
- data/docs/internals/engine.md +2 -1
- data/docs/internals/llm-context-forget.md +6 -0
- data/docs/internals/participants.md +5 -2
- data/docs/internals/prompt-caching.md +8 -1
- data/docs/internals/remote-sessions.md +22 -4
- data/docs/internals/session-lifecycle.md +1 -1
- data/docs/internals/web-frontend.md +37 -15
- data/docs/internals/web-push.md +11 -0
- data/docs/internals/working-set.md +238 -6
- data/docs/mcp-server.md +11 -3
- data/docs/memory.md +2 -1
- data/docs/plugins.md +6 -6
- data/docs/scheduling.md +19 -0
- data/docs/sessions.md +13 -3
- data/docs/sub-agent.md +48 -3
- data/docs/thin-clients.md +38 -12
- data/lib/samagotchi/agent_caller.rb +97 -0
- data/lib/samagotchi/bridge.rb +7 -7
- data/lib/samagotchi/bridge_client.rb +12 -4
- data/lib/samagotchi/bundle_command/check.rb +20 -2
- data/lib/samagotchi/bundle_manifest.rb +5 -1
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +14 -8
- data/lib/samagotchi/bundles/claude-peer/plugin.rb +3 -3
- data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +49 -30
- data/lib/samagotchi/bundles/claude-peer/scripts/pair +2 -2
- data/lib/samagotchi/bundles/claude-peer/scripts/pair-remote +123 -0
- data/lib/samagotchi/bundles/claude-peer/skill_claude_peer.md +11 -3
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +10 -8
- data/lib/samagotchi/bundles/codex-peer/plugin.rb +3 -3
- data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +29 -8
- data/lib/samagotchi/bundles/codex-peer/scripts/pair +1 -1
- data/lib/samagotchi/bundles/codex-peer/skill_codex_peer.md +11 -3
- data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
- data/lib/samagotchi/bundles/mcp/http_client.rb +96 -54
- data/lib/samagotchi/bundles/mcp/manifest.yml +2 -2
- data/lib/samagotchi/bundles/system/manifest.yml +2 -2
- data/lib/samagotchi/bundles/system/self_map.md +9 -2
- data/lib/samagotchi/client_id.rb +61 -1
- data/lib/samagotchi/command_intake.rb +16 -8
- data/lib/samagotchi/context_absorber.rb +212 -46
- data/lib/samagotchi/delivery.rb +15 -0
- data/lib/samagotchi/driver_command.rb +68 -0
- data/lib/samagotchi/engine/block_fix.rb +2 -2
- data/lib/samagotchi/engine/session.rb +14 -6
- data/lib/samagotchi/engine/turn_helpers.rb +4 -3
- data/lib/samagotchi/engine.rb +13 -5
- data/lib/samagotchi/engine_peers.rb +6 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +1 -1
- data/lib/samagotchi/mcp_command.rb +7 -2
- data/lib/samagotchi/mcp_server/http.rb +3 -3
- data/lib/samagotchi/mcp_server/protocol.rb +23 -4
- data/lib/samagotchi/mcp_server/stdio.rb +1 -0
- data/lib/samagotchi/mcp_server/tools.rb +11 -4
- data/lib/samagotchi/model_notes.rb +34 -12
- data/lib/samagotchi/objectives_track.rb +2 -1
- data/lib/samagotchi/owner_prompt.rb +5 -1
- data/lib/samagotchi/parent_report.rb +9 -5
- data/lib/samagotchi/plugin/peer.rb +10 -4
- data/lib/samagotchi/prompt_files.rb +11 -4
- data/lib/samagotchi/prompt_layout.rb +88 -0
- data/lib/samagotchi/prompt_part.rb +82 -20
- data/lib/samagotchi/reply_wait.rb +16 -4
- data/lib/samagotchi/schedule_command.rb +18 -4
- data/lib/samagotchi/schedules.rb +49 -14
- data/lib/samagotchi/send_command/parent_gate.rb +3 -1
- data/lib/samagotchi/send_command.rb +45 -8
- data/lib/samagotchi/session.rb +9 -1
- data/lib/samagotchi/session_access/ask.rb +58 -14
- data/lib/samagotchi/session_access/contract.rb +2 -0
- data/lib/samagotchi/session_access/exchange.rb +5 -2
- data/lib/samagotchi/session_access/local.rb +13 -3
- data/lib/samagotchi/session_access/remote.rb +18 -2
- data/lib/samagotchi/session_access.rb +4 -2
- data/lib/samagotchi/session_command_catalog.rb +8 -0
- data/lib/samagotchi/session_commands.rb +9 -0
- data/lib/samagotchi/session_continue.rb +4 -1
- data/lib/samagotchi/session_inbox.rb +17 -0
- data/lib/samagotchi/session_inbox_delivery.rb +4 -2
- data/lib/samagotchi/session_manager/delivery.rb +58 -9
- data/lib/samagotchi/session_manager/spawn.rb +7 -1
- data/lib/samagotchi/steer.rb +95 -20
- data/lib/samagotchi/system_prompt.rb +196 -161
- data/lib/samagotchi/terminal_ui/formatting.rb +12 -2
- data/lib/samagotchi/tool_activity.rb +4 -0
- data/lib/samagotchi/tool_declarations.rb +22 -1
- data/lib/samagotchi/tool_names.rb +4 -0
- data/lib/samagotchi/toolkit.rb +3 -2
- data/lib/samagotchi/tools/ask_session.rb +208 -0
- data/lib/samagotchi/tools/builtin_calls.rb +1 -0
- data/lib/samagotchi/tools/builtins.rb +5 -0
- data/lib/samagotchi/tools/memory.rb +11 -3
- data/lib/samagotchi/turn_checkpoint.rb +19 -2
- data/lib/samagotchi/turn_stages/context_judge.rb +3 -1
- data/lib/samagotchi/turn_stages/objectives.rb +4 -2
- data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +3 -0
- data/lib/samagotchi/turn_stages/warmup.rb +2 -2
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/visitor.rb +37 -0
- data/lib/samagotchi/web/app.rb +2 -3
- data/lib/samagotchi/web/ask_routes.rb +95 -23
- data/lib/samagotchi/web/mcp_route.rb +7 -4
- data/lib/samagotchi/web/message_display.rb +15 -2
- data/lib/samagotchi/web/public/app.js +1 -1
- data/lib/samagotchi/web/public/block_fix.js +11 -3
- data/lib/samagotchi/web/public/delete_sheet.js +20 -18
- data/lib/samagotchi/web/public/history_shape.js +3 -1
- data/lib/samagotchi/web/public/index.html +8 -0
- data/lib/samagotchi/web/public/peer_links.js +27 -4
- data/lib/samagotchi/web/public/peer_note.js +19 -3
- data/lib/samagotchi/web/public/peer_text.js +45 -0
- data/lib/samagotchi/web/public/picture_regions.js +2 -2
- data/lib/samagotchi/web/public/removal_sheet_model.js +3 -4
- data/lib/samagotchi/web/public/running_tasks.js +0 -16
- data/lib/samagotchi/web/public/session_actions.js +0 -9
- data/lib/samagotchi/web/public/turn_events.js +19 -0
- data/lib/samagotchi/web/public/working_set_view.js +178 -23
- data/lib/samagotchi/web/public/ws_part_peek.js +277 -0
- data/lib/samagotchi/web/public/ws_peek.js +3 -1
- data/lib/samagotchi/web/public/ws_preview.css +30 -0
- data/lib/samagotchi/web/public/ws_reader.js +7 -3
- data/lib/samagotchi/web/public/ws_sections.js +37 -7
- data/lib/samagotchi/web/push/notifier.rb +33 -6
- data/lib/samagotchi/web/server.rb +1 -1
- data/lib/samagotchi/web/session_control.rb +1 -1
- data/lib/samagotchi/web/session_create.rb +11 -7
- data/lib/samagotchi/web/session_hub.rb +26 -4
- data/lib/samagotchi/web/working_set_routes.rb +93 -5
- data/lib/samagotchi/worker/command_queue.rb +5 -2
- data/lib/samagotchi/worker/senders.rb +79 -0
- data/lib/samagotchi/worker.rb +21 -18
- data/lib/samagotchi/worker_inbound.rb +12 -4
- data/lib/samagotchi/worker_link.rb +2 -2
- data/lib/samagotchi/worker_participant_gate.rb +1 -3
- data/lib/samagotchi/worker_wakes.rb +12 -0
- data/lib/samagotchi/working_set.rb +162 -90
- data/lib/samagotchi/working_set_locator.rb +221 -0
- data/lib/samagotchi/working_set_own_changes.rb +221 -0
- data/lib/samagotchi/working_set_part.rb +281 -0
- metadata +13 -1
|
@@ -43,6 +43,23 @@ else that changes it does: a later `execute` (`sed`, `git checkout`), the user's
|
|
|
43
43
|
edit that changed the file anyway leaves the earlier stamp, so the file shows stale. On a filesystem with 1 s mtimes a
|
|
44
44
|
same-size edit in the same second goes unseen (APFS keeps nanoseconds).
|
|
45
45
|
|
|
46
|
+
A memory item follows chi's own changes too (`WorkingSet.build` passes the runs it already walked to
|
|
47
|
+
`WorkingSet::OwnChanges.from_runs`: no second walk; built only when a memory item needs it). A memory whose latest run
|
|
48
|
+
is a `memory_read` and whose stamped files differ stays `live` when every file that differs (the entry, its overlay)
|
|
49
|
+
holds chi's own later change: an `edit` or `write` of the file (its stamp), or a `memory_write` (by content, since
|
|
50
|
+
`memory_write` leaves no stamp). That is the heartbeat case, a memory read once and then edited all session. It runs
|
|
51
|
+
only after `memory_differs`' early answers: a name that now resolves to another file or overlay (a project `x` chi
|
|
52
|
+
wrote now shadowing the read's system `x`) or is gone stays `stale`, conservative. A memory whose latest run is a
|
|
53
|
+
`memory_write` is `stale` when the file it wrote (`<scope dir>/<name>.md`: system from `root`, project from the item's
|
|
54
|
+
read stamp's `project_dir`; a project memory only written has none and stays `live`) no longer holds chi's latest own
|
|
55
|
+
change of it (the write's content, or a later `edit`/`write` of the file by its stamp): one you edit after chi's write. A remove, an overlay write or a description-only write keeps today's `live`. Only a path
|
|
56
|
+
`MemoryGuard.memory_paths?` lets through is read: a stamp's file outside the memories folder counts as no own change
|
|
57
|
+
(stale, as before), never read. Cost in the worker: once any memory item's latest run is a `memory_write` (so every step
|
|
58
|
+
after a session's first one) or a memory item is found stale, one pass over the runs already in memory, testing the tool
|
|
59
|
+
name before anything else (about 0.1 ms at 350 runs on the Studio; testing `failed?` first, which copies each output,
|
|
60
|
+
cost about 1.5 ms); a stat per memory item already found stale, a `File.binread` per memory item whose latest run is a
|
|
61
|
+
`memory_write`.
|
|
62
|
+
|
|
46
63
|
## The projection: `WorkingSet.build`
|
|
47
64
|
|
|
48
65
|
`Samagotchi::WorkingSet.build(conversation, cwd:, strategy:, stat: File.method(:stat), pins: [])` (`lib/samagotchi/working_set.rb`)
|
|
@@ -246,7 +263,8 @@ projection), on both loops. It costs one model step; a model may skip it (the no
|
|
|
246
263
|
directory; a memory name `memory_read` rejects or that neither scope holds), an item holding the user's drop
|
|
247
264
|
(`undrop_first`: undrop brings it back without a step), one already in the system prompt and with no working-set
|
|
248
265
|
output (`in_prompt`: nothing to add; matched by name and scope, `Tools::MemoryRead.prompt_memory?` over
|
|
249
|
-
`Engine#prompt_memories`, a bare name or an unscoped prompt entry by name only), and one the model has whole (`already_sent`: live, a read of it sent
|
|
266
|
+
`Engine#prompt_memories`, a bare name or an unscoped prompt entry by name only), and one the model has whole (`already_sent`: live, a read of it sent; a memory chi read and then changed itself
|
|
267
|
+
is live, so its add is refused as a file chi edited is). The
|
|
250
268
|
prompt-only refusal doesn't apply when the set holds a read of that memory: a stale or forgotten item may still be
|
|
251
269
|
added as the web row's `refresh`. **`unadd`** takes a pending add back (free); without one it is refused
|
|
252
270
|
(`not_added`).
|
|
@@ -297,7 +315,9 @@ now (`WorkingSet::Now`: `text`, `diff`, `gone`): each name that read read, from
|
|
|
297
315
|
overlay stamped with it appended as `Tools::MemoryRead.call` appends it (`Model-specific guidance (<key>):`, the key
|
|
298
316
|
off the overlay's file name), and a missing name's `Error:` tail kept; `diff` is `TextDiff.unified` of what the read
|
|
299
317
|
sent against that (`EditPreview`'s shape, so `diff_view.js` draws it; an empty `text` is "no change"). `gone` when a
|
|
300
|
-
file is; nil without a stamp.
|
|
318
|
+
file is; nil without a stamp. Each name is a `WorkingSet::Locator` of origin `:run` ([Prompt parts as sent](#prompt-parts-as-sent), The locator):
|
|
319
|
+
every name is resolved first (refused: nil; no entry answers: gone), then read, and `memory_now` keeps the join and
|
|
320
|
+
the diff.
|
|
301
321
|
|
|
302
322
|
**The route.** `GET /api/sessions/:id/working_set/item?kind=&key=` (`WorkingSetRoutes#handle_working_set_item`,
|
|
303
323
|
`:owner, :session`: a participant gets 403 from `not_permitted_for`) answers `timeline.to_h`, and with `&now=1` for a
|
|
@@ -388,13 +408,14 @@ chi's head, in three sections, drawn as Read, Conversation, From the start (ever
|
|
|
388
408
|
server, `overlay`); a scope either side lacks (an older worker's part or item, an item the server hasn't stamped)
|
|
389
409
|
matches by name alone, as before scopes. So a project `x` read beside a system `x` in the prompt is two rows: the
|
|
390
410
|
read stays in Read as a plain read (not "prompt", never held twice), and the part's own row gets the key `x@system`
|
|
391
|
-
(no collision with the read's `x`), its words its scope ("preloaded · system") and, like identity's, no actions
|
|
392
|
-
peek. A note and a preload of one name and scope stay one row with both sizes; of two scopes, two rows. The start
|
|
411
|
+
(no collision with the read's `x`), its words its scope ("preloaded · system") and, like identity's, no actions;
|
|
412
|
+
its ▸ is the prompt peek ([Prompt parts as sent](#prompt-parts-as-sent)). A note and a preload of one name and scope stay one row with both sizes; of two scopes, two rows. The start
|
|
393
413
|
section tracks the items it shows by identity, not by key. It keeps the memory row's peek, state and the drop/pin rules of a preloaded memory (not
|
|
394
414
|
droppable or pinnable until read). Its tokens are the part's, plus `+X` for the read's (the item's server tokens: a
|
|
395
415
|
preloaded row carries none of its own, so the two never double-count). Other parts are read-only `part` rows: a
|
|
396
|
-
label, a sub (the tools part's "N declared"; dropped on a phone), `~tokens`, no actions,
|
|
397
|
-
them.
|
|
416
|
+
label, a sub (the tools part's "N declared"; dropped on a phone), `~tokens`, no actions, and a ▸ that opens what chi
|
|
417
|
+
was sent ([Prompt parts as sent](#prompt-parts-as-sent)); a turn lens dims them. Each start row carries the keys of
|
|
418
|
+
the parts it stands for (`partKeys`, `partSizes`: a note also preloaded has two).
|
|
398
419
|
- **Read in this session** (`read`): today's files / memories / urls folds (`bodySections`), minus the memories the
|
|
399
420
|
start section shows. Its meta: held (not struck) and out (forgotten or dropped); its tokens the held items'.
|
|
400
421
|
- **Conversation** (`talk`): one row at section level, "Conversation · N turns ~X" (`headSections` still returns the
|
|
@@ -484,3 +505,214 @@ The secondary text and the rail's rule read through their own tokens, a step bri
|
|
|
484
505
|
base tokens on the light one: `--ws-faint` (the counts, the ops text, step tags; `--text-muted` on dark, `--text-faint`
|
|
485
506
|
on light), `--ws-muted` (the rail's head, the list's `files · n` rows, the drop/pin buttons; `--text-3` / `--text-muted`),
|
|
486
507
|
`--ws-rule` (the rail's left rule; `--border-strong` / `--border`) and `--ws-act-border` (the buttons' border).
|
|
508
|
+
|
|
509
|
+
## Prompt parts as sent
|
|
510
|
+
|
|
511
|
+
Every "From the start" row opens what chi was sent for its part: a slice of the prompt the session already keeps,
|
|
512
|
+
never a copy.
|
|
513
|
+
|
|
514
|
+
**The head and the places.** `Engine#turn_messages` puts the built prompt at `messages[0]`
|
|
515
|
+
(`ContextNote.with_system_head`: `{role: "system", content:}` with no `kind`, `ContextNote.system_head?`) and
|
|
516
|
+
`end_turn` saves it with the turn. Each `prompt_parts` entry says where it sits in that prompt (`PromptPart`, built by
|
|
517
|
+
`PromptLayout` beside the build): `at` (where its lead starts), `len` (lead included), `lead` (the length of what chi
|
|
518
|
+
adds before the item's own text: the identity line, a note's `## name`, the first note of a scope its heading, a
|
|
519
|
+
preload's "this memory is required … memory name: x" line, a file's header, a plugin's `From b (n):`, an index's
|
|
520
|
+
`Project memories:`; none for base, the kit and the volatile lines), so the slice is `head[at, len]` and the item's
|
|
521
|
+
own text `head[at + lead, len - lead]`. Joins between items fall in no span. `chars` is not `len`: a section's first
|
|
522
|
+
part is charged its joins. `digest` is 12 hex of SHA-256 over the item's own text, `head` 16 hex of the whole prompt
|
|
523
|
+
(the same on every part of a build). The tools part has a place only where the declarations are in the prompt: inside
|
|
524
|
+
the base text on a native non-Gemma profile (base's slice leaves them out, and so does its digest), after the
|
|
525
|
+
rstripped prompt on Gemma (an item running into the rstrip is cut at it); on a chat host they are a request field and
|
|
526
|
+
the part has none. `params` say how to fetch an item again: a memory's `requested_scope` (nil for a bare name),
|
|
527
|
+
`model_key`, `fallback_model_key`, `project_dir`, `system_dir` as the build read them; a file's `path`; the tools'
|
|
528
|
+
`[{name, chars}]` (chat: each schema's JSON; native Gemma declarations: each one's text; Qwen's one JSON list gives no
|
|
529
|
+
per-tool length, so names only). The items are recorded where the builders render them
|
|
530
|
+
(`SystemPrompt::Section#items`), so a place can't drift from the bytes. Cost: about 80 bytes a part plus 100–200 for
|
|
531
|
+
a fetchable part's params, 2–3 KB a session, in the file, every snapshot, reset frame and owner show; one SHA-256 of
|
|
532
|
+
the prompt and one per item per changed build.
|
|
533
|
+
|
|
534
|
+
**The key.** A part is named from the parts list alone: `PromptPart.keys` (`kind:ref`, the label without a ref,
|
|
535
|
+
`@scope` when it has one, `#n` for the nth repeat: a duplicate preload is `preloads:x#2`); `ws_sections.js startRows`
|
|
536
|
+
has the twin, both held to `spec/shared/prompt_part_keys.json`.
|
|
537
|
+
|
|
538
|
+
**The route.** `GET /api/sessions/:id/working_set/part?key=` (`WorkingSetRoutes#handle_working_set_part`, `:owner,
|
|
539
|
+
:session`: a participant gets 403, and `Web::ParticipantShow` sends no parts) reads the parts and `messages[0]` from
|
|
540
|
+
one source: a live worker's snapshot frame (`session_state_snapshot.prompt_parts`, `snapshot.messages`), else the
|
|
541
|
+
session file. No Bridge route, no worker feature: one session-file parse. `WorkingSetPart.answer` then: tools always
|
|
542
|
+
answer `{part, tools}` (names and sizes, saved with the part); otherwise case C's table, the first that holds winning,
|
|
543
|
+
its words in `WorkingSetPart::WORDS` (the page shows them as given, `note`, with a `reason`):
|
|
544
|
+
|
|
545
|
+
| # | Condition | `reason` | Source text under it? |
|
|
546
|
+
|---|---|---|---|
|
|
547
|
+
| 1 | the part has no `at`, a live worker of an older chi (its snapshot's `chi_version`; none said: older) | `older_worker` | no |
|
|
548
|
+
| 2 | the part has no `at`, no live worker or one of this chi (a fresh worker keeps the file's parts until a turn) | `older_chi` | no |
|
|
549
|
+
| 3 | `messages[0]` is not a system head | `no_prompt` | no |
|
|
550
|
+
| 4 | the head's digest differs from the part's `head`, a turn runs | `running` (`changed`) | yes, a fetchable part |
|
|
551
|
+
| 5 | the head's digest differs, idle (`!rollback`, a failed turn's old head, an older chi's run) | `idle` (`changed`) | yes, a fetchable part |
|
|
552
|
+
|
|
553
|
+
Else `{part, sent: {text, lead}}`. Mid-turn the snapshot's messages lag the turn, but parts are recorded at its start,
|
|
554
|
+
so the slice is exact unless the prompt was rebuilt (4). A memory file with invalid UTF-8 is scrubbed in the saved
|
|
555
|
+
head, so its session stays in 5: accepted.
|
|
556
|
+
|
|
557
|
+
**The locator.** Every "now" the working set shows is fetched by one resolver, `WorkingSet::Locator`
|
|
558
|
+
(`working_set_locator.rb`, `Data.define(:origin, :kind, :ref, :scope, :params)`; loaded only when a fetch runs, for the
|
|
559
|
+
testing kit's file budget): "where a held text came from and how to fetch it again". `#fetch` has three outcomes: nil
|
|
560
|
+
(refused, or nothing to fetch), a `WorkingSet::Now` with `gone`, a `Now` with its text (diff nil). `#composed` is the
|
|
561
|
+
same fetch with the files it read (`Locator::Composed`: `now`, `files` of `Locator::Source` `{path, role: :base |
|
|
562
|
+
:overlay, key}`, at most two); a gone prompt memory names the base it was sent from (identity's saved `system_dir`, a
|
|
563
|
+
preload's built `scope`'s folder, a note's `requested_scope`'s). A note's overlay is found by
|
|
564
|
+
`ModelNotes.overlay_path`, the build's own lookup (its label keeps the key as given). Its guard follows
|
|
565
|
+
`origin`, and the two stay apart:
|
|
566
|
+
|
|
567
|
+
- `:run`, a `memory_read` stamp's entry (`WorkingSet.memory_now`): resolved with chi web's own `MemoryPaths.system_dir`,
|
|
568
|
+
any saved folder ignored; a path-only stamp (or one whose project folder is outside the root) reads its stamped
|
|
569
|
+
paths; a `read:` stand-in reads the files.
|
|
570
|
+
- `:prompt`, a prompt part's `params` (cases 4 and 5, `&now=1`, the stale states): a memory resolves with the saved
|
|
571
|
+
keys, `requested_scope` and folders only when the saved `system_dir` and `project_dir` are inside chi web's own
|
|
572
|
+
`MemoryPaths.system_dir`, and every path it may look at (the files resolved; a note's file and each saved key's
|
|
573
|
+
overlay, before any is stat'd) passes `memory_paths?`; identity and preloads through `Tools::MemoryRead.resolve` and
|
|
574
|
+
`.compose`, a note through `ModelNotes.body_at` (the composers the build used, so an unchanged memory's text has the
|
|
575
|
+
build's digest). An AGENTS.md is read only when it is on the session `working_directory`'s chain
|
|
576
|
+
(`PromptFiles.agents_paths`, `PromptFiles.content`). An appended file is never fetched (as sent from the head only);
|
|
577
|
+
base, the kit, a plugin's section, an index and the session lines are chi's own text: the line alone. Nothing is
|
|
578
|
+
recomputed: no model key, no folder (a model switch rebuilds the prompt, so the saved keys describe the sent text).
|
|
579
|
+
|
|
580
|
+
The path guard both share is `WorkingSet::MemoryGuard` (in `working_set.rb`: `#build`'s stale check of a read memory
|
|
581
|
+
uses it at load). A file or URL row has no locator: its timeline is the conversation's text, and its stale check is a
|
|
582
|
+
`stat` against its stamp.
|
|
583
|
+
|
|
584
|
+
**Stale prompt parts.** `WorkingSetPart.states(parts, root:, cwd:)` names the parts whose source changed since chi
|
|
585
|
+
was sent it, `[{key, state: "stale"}]` (the stale ones only): a part whose locator fetches text with a different
|
|
586
|
+
`PromptPart.digest_of` from its saved `digest`, or finds the source gone. A digest covers exactly the text the fetch
|
|
587
|
+
returns, so it catches an edit, shadowing (a bare preload now answered by the project scope), an overlay added or
|
|
588
|
+
removed, and a file deleted (gone). It does not catch what changes which parts exist rather than a part's text: a
|
|
589
|
+
note that newly applies (or whose `models:` line no longer matches), a new AGENTS.md in the chain, a memory muted
|
|
590
|
+
after the build. Only fetchable kinds get a state (identity, preloads, notes, AGENTS.md): never an index (it changes at
|
|
591
|
+
every memory write), an appended file, chi's own text, or a part an older chi built (no digest). Cost: about 0.8 ms per
|
|
592
|
+
GET for 11 fetchable parts (the Studio, warm cache; `find_dot_git` is stat-only).
|
|
593
|
+
|
|
594
|
+
**chi's own change of a stale part (`by_chi`).** Given the same source's `messages` (and `running`),
|
|
595
|
+
`WorkingSetPart.states` adds `by_chi: {tool_id, step, op, current}` to a stale part chi changed itself; the state
|
|
596
|
+
stays `"stale"`. The own changes are `WorkingSet::OwnChanges` (`working_set_own_changes.rb`): the latest successful
|
|
597
|
+
change per file still in the stored conversation, so its text is still sent in the call's arguments (`op`
|
|
598
|
+
`memory_write`, `remove`, `write`, `edit`; `step` is `PairedRun#step`). A `memory_write` counts by its output: "saved
|
|
599
|
+
to SCOPE scope" (keyed scope + name), "Model overlay 'x' for KEY saved" (+ the key: the handler's model key, never an
|
|
600
|
+
argument), "removed from" (a remove; "its dangling index line was dropped" is none); never a description-only write
|
|
601
|
+
("(file unchanged)"), the index, or a failed, denied or interrupted run (`WorkingSet.failed?`). An `edit` or `write`
|
|
602
|
+
counts by its `FileRef` path and stamp. Each file the part was read from (`Locator#composed`, at most two) maps to its
|
|
603
|
+
latest own change: a memory's by the saved folder it sits in (`File.dirname(path) == dir`: a project's folder is
|
|
604
|
+
inside the system one), a file tool's by basename then `realpath`. A change is current while the file holds what it
|
|
605
|
+
left: a `memory_write`'s content byte for byte (`File.binread`; a model note's or an overlaid memory's text never
|
|
606
|
+
digests to its file, so the compare is per file), a remove's absence, an edit's stamp (`WorkingSet.differs?`).
|
|
607
|
+
|
|
608
|
+
`current: true` (the row's `✎ edited`) when every file holds chi's change or what was sent, and one holds chi's. "What
|
|
609
|
+
was sent" is the part's sent slice (`sent_of`, only when `messages[0]` is the head the parts were built with), split
|
|
610
|
+
with the text now at `Tools::MemoryRead.overlay_tail` (the overlay's key now, else the build's `model_key`, then
|
|
611
|
+
`fallback_model_key`): the base's text against the body, the overlay's against the tail, and no overlay now must mean
|
|
612
|
+
no tail sent (a project `x` chi wrote now answering a bare preload that was sent with a system overlay is stale). A
|
|
613
|
+
gone part is current only by chi's current remove of the base it was sent from. Otherwise, when chi changed one of the
|
|
614
|
+
files, `current: false` (it changed again after chi's change; or the head is not the build's, case C 4–5, where
|
|
615
|
+
nothing proves the other file unchanged). Rolled back (the call's entries gone, the file still chi's text), interrupted,
|
|
616
|
+
or someone else's change: no `by_chi`. A merged row (a note also preloaded) gets an answer per part.
|
|
617
|
+
|
|
618
|
+
An `edit` is checked harder than its stamp (a stricter reading of D2, the code review's M2): `edit` replaces its
|
|
619
|
+
`old_text` wherever it still matches, so it can land over a change chi never saw, and the stamp then holds. A part
|
|
620
|
+
whose current change of a file is an `edit` is current only when undoing chi's edits of that file, newest first
|
|
621
|
+
(`OwnChanges.undoes_to?`: each `new_text` found exactly once and put back to its `old_text`), reaches the sent side
|
|
622
|
+
exactly (stripped, as a prompt file is), or chi's own `memory_write` of it before those edits. Otherwise there is no
|
|
623
|
+
`by_chi`, so the row stays plain `stale` and the now tab shows the diff. A range edit (`start_line`), an empty
|
|
624
|
+
`new_text` or a `write` among them can't be undone: plain `stale` too. An `edit` or `write` with no stamp (an older
|
|
625
|
+
session's) gives no `by_chi`, never `current: false`. Read rows and file rows keep the stamp rule (D1, as file rows
|
|
626
|
+
always had).
|
|
627
|
+
|
|
628
|
+
Known limit: own changes have no build point. A write from before the prompt's build counts when the file comes back to
|
|
629
|
+
its text (chi writes A; someone writes B; a restart builds the prompt with B; someone writes A back): the row reads
|
|
630
|
+
`✎ edited` though the newer prompt says B. Rare; a session that recorded the message index of the head's build could
|
|
631
|
+
ignore earlier changes.
|
|
632
|
+
|
|
633
|
+
While a turn runs (`running`), only a `current: true` goes out: the GET's messages may lag the turn, so chi's newest
|
|
634
|
+
write may not be in them, and "changed again" could name chi's own change. A row chi changes in the running turn reads
|
|
635
|
+
`stale` until a GET's messages hold the write (D5); in the browser check (2026-11-22, the fake model) the row already
|
|
636
|
+
read `✎ edited` in a later step of the same turn, so the lag seems to be the writing step only (inferred, not traced in
|
|
637
|
+
the worker), and the hand-off's GET settles it either way. Guard: only the Locator's files are read (`binread`, `stat`); no path a call
|
|
638
|
+
or an output names is read, and an overlay key is `[a-z0-9-]+`. Cost: nothing new for a GET with no stale part; with one,
|
|
639
|
+
one `paired_runs` walk (about 3 ms at 600–750 messages on the Studio, about twice on the laptop), the messages'
|
|
640
|
+
top-level keys symbolized (`WorkingSetPart.symbolized`, shared with `working_set_source`), and at most two reads or
|
|
641
|
+
stats per stale part. A stale part stays stale for the worker's life, so each GET of such a session pays it.
|
|
642
|
+
|
|
643
|
+
The carrier is chi web's `GET …/working_set` alone: `handle_working_set` adds `parts:` for the owner whichever of its
|
|
644
|
+
three sources answered (the running turn's set, an idle worker's, a build from the file), from the parts the part
|
|
645
|
+
route reads (`#prompt_source`: the live snapshot frame's, else the file's), so a stopped session, a live idle worker
|
|
646
|
+
and an older (0.183.0) worker all get them. No field means none stale. No event field, no worker change; a
|
|
647
|
+
participant's answer never has it (`ParticipantView.working_set` rebuilds `{items, at}`). The page asks the GET each
|
|
648
|
+
time the list opens. A `:working_set_updated` event carries no parts: the page keeps the session's last GET's states on
|
|
649
|
+
the event's set (`working_set_view.js takeServer`), and a GET an event overtook still gives its parts. The page asks
|
|
650
|
+
the GET again when the session's parts are rebuilt (their heads or digests change, `sessionChanged`) and at a turn's
|
|
651
|
+
hand-off when it holds states or the list is open, so a rebuilt prompt's states go.
|
|
652
|
+
|
|
653
|
+
Stale lasts in a live worker until chi rebuilds its prompt: `SystemPrompt#built_for` caches the build until
|
|
654
|
+
`#reset!` (a model switch, a participants change, a plugin's `prompt_changed!`, a toolkit change). An outside edit,
|
|
655
|
+
and chi's own `memory_write` of a preloaded memory, do not reset it, so the worker keeps sending the old text across
|
|
656
|
+
turns until one of those or a restart. Someone else's change reads `stale`; chi's own (a current `by_chi`) reads
|
|
657
|
+
`✎ edited`, since the new text is in chi's conversation; while the turn that made it still runs it may read `stale`
|
|
658
|
+
until a GET's messages hold the write (see `by_chi` above).
|
|
659
|
+
|
|
660
|
+
**The source now.** `GET …/working_set/part?key=&now=1` adds, beside the sent slice, `now: {text, diff, gone}`: the
|
|
661
|
+
locator's text (scrubbed to valid UTF-8 before JSON) and `TextDiff.unified` of the sent text against it (nil when
|
|
662
|
+
gone), and `rebuild`: when chi's prompt gets the source now, `restart` with a live worker (it keeps its prompt until it
|
|
663
|
+
is next built) or `next_turn` without one (the next turn builds it). Under cases 4 and 5 the answer stays as above (the
|
|
664
|
+
source now, no diff: nothing sent to diff against; no `rebuild`, their words say when). Parts without a locator have no
|
|
665
|
+
`now`. An older chi web sends no `rebuild`, and the page leaves its line out.
|
|
666
|
+
|
|
667
|
+
**The page.** `ws_part_peek.js` (made by `ws_reader.js` with the reader's markdown cache, handed to the view as
|
|
668
|
+
`peek.part`): the peek's head "in the prompt · sent with every request", the text (a memory's and an `.md` file's
|
|
669
|
+
rendered), chi's lead folded under "chi adds a line before it", no foot buttons; tools as names and sizes; case C's
|
|
670
|
+
line with the source now under it. A row of several holds gets one tab per hold, its kind and size (`note · ~0.9k`,
|
|
671
|
+
`preload · ~1.2k`, `in the prompt · ~1.4k`), and `read · t1·s1` for an item that was read: the item peek, first. One
|
|
672
|
+
peek open at a time. The popover is 520 wide open or closed.
|
|
673
|
+
|
|
674
|
+
The GET's `parts` reach the start rows as `headSections`' `states` option (`startRows`: `partStates` beside
|
|
675
|
+
`partKeys`, `partStale` when one is). A stale row says `stale` in `--warn-text` (`.ws-pstale`) in place of its words,
|
|
676
|
+
which move to its title ("model note · changed after chi's prompt was built"); a memory row whose read is stale too
|
|
677
|
+
still says one `stale`, its title and its now tab naming both ("read changed · prompt text changed"). Its peek gets a `now · changed` tab right after the stale hold (`warn`):
|
|
678
|
+
the `&now=1` answer, drawn as "<label> changed after chi's prompt was built" with the diff's `+a −d` and
|
|
679
|
+
`diff_view.js`'s diff ("no change" once it was edited back), or "Its source is gone now." It opens first unless the row
|
|
680
|
+
has a read. No new export: an older `ws_sections.js` ignores `states`, and the 0.183.0 page ignores the field.
|
|
681
|
+
|
|
682
|
+
**chi's own change on the page.** The view reads the GET's `by_chi` itself, off `server.parts` (`working_set_view.js
|
|
683
|
+
ownRow`: an older cached `ws_sections.js` has no `partKeys`, build 2's maps states to `"stale"` or none): a stale part
|
|
684
|
+
whose `by_chi.current` is true becomes `"edited"` in the row's `partStates`, and a row none of whose parts is still
|
|
685
|
+
stale is edited. It reads `✎` (the file rows' `.e`), then `<span class="st ws-pedited"><span class="ws-pwords">preloaded
|
|
686
|
+
· </span>edited</span>` (`removed` for a remove) in `--text-2`, not the warn colour; for AGENTS.md `project instructions ·
|
|
687
|
+
edited`. Its title: "preloaded · chi edited it at turn 3, step 2: the new text is in its conversation; its prompt
|
|
688
|
+
still sends the old text until it is next built" (a remove: "… chi removed it at turn 3, step 2: its prompt still sends
|
|
689
|
+
it until it is next built"). Its tag after the tokens is the call's place, found by `tool_id` over every turn's items
|
|
690
|
+
(`ws_timeline.js placeOf`), drawn as the read rows' jump (`.ws-step.ws-own`, `data-ws="jump"`); without a place, a
|
|
691
|
+
plain `step N` (the server's step). A memory row whose read is stale says the read's `stale` as before; the
|
|
692
|
+
both-causes words ("read changed · prompt text changed") need a read op, so a memory chi only wrote and someone changed
|
|
693
|
+
after reads "changed after chi's prompt was built" (its item is stale by D1, faded). A row whose part carries `by_chi`
|
|
694
|
+
and whose item has no read gets no `read` tab (the item peek of chi's write): its edited tab, or its now tab with the
|
|
695
|
+
"chi edited it at …" line, opens first. In a turn lens the call's tag replaces the lit row's step tag. A merged row
|
|
696
|
+
(a note also preloaded) stays `stale` while any part is stale without a current change; each part gets its own tab.
|
|
697
|
+
On a phone's sheet the part words go (`.ws-popover.sheet .ws-pwords{display:none}`, D7): `✎ edited` alone, the name
|
|
698
|
+
keeps its room; a part row keeps `edited` where it drops its sub text, and the tabs wrap.
|
|
699
|
+
|
|
700
|
+
The peek (`ws_part_peek.js`) gives an edited part the tab `edited · t3·s2` (`removed · t3·s2`) right after its hold, in
|
|
701
|
+
place of the now tab; it opens first unless the row has a read. Its body is the `&now=1` answer: the head "chi edited
|
|
702
|
+
`<label>` at t3·s2" with the diff's `+a −d`, the diff sent → now, and one line, "Its prompt still sends the old text with
|
|
703
|
+
every request; chi has the new text from its edit.", followed by "The prompt gets it when it is next built (a restart,
|
|
704
|
+
a model switch)." (`rebuild: "restart"`) or "The prompt gets it when it is next built (at its next turn)."
|
|
705
|
+
(`"next_turn"`); none without `rebuild`. A remove's tab: "chi removed it at t3·s2; its prompt still sends it until it
|
|
706
|
+
is next built." A stale now tab gets the rebuild line under the diff: "chi gets the new text when its prompt is next
|
|
707
|
+
built (a restart, a model switch)." or "chi gets the new text at its next turn."; with `by_chi.current === false`,
|
|
708
|
+
above it (warn) "chi edited it at t3·s2; it changed again after that.". The words are constants beside `BOTH_CHANGED`
|
|
709
|
+
(`REBUILD_LIVE`, `REBUILD_NEXT`, `STILL_SENT`, `PROMPT_GETS`). No new export: an older cached peek given `"edited"`
|
|
710
|
+
sees no stale and shows the sent text only (`v0.183.0` has no `ws_part_peek.js`, so that pairing gets a fixture once
|
|
711
|
+
0.184.0 is tagged); the 0.183.0 page and view ignore `by_chi`; a new page against an older chi web (no `by_chi`, no
|
|
712
|
+
`rebuild`) draws build 2's stale with no rebuild line.
|
|
713
|
+
|
|
714
|
+
**Compat.** An older page ignores the fields and the route; a build-2 page maps any state but `"stale"` to none, so
|
|
715
|
+
`by_chi` rides beside `state: "stale"` (no new state value) and such a page draws today's `stale`; an older chi reading a newer file drops the fields
|
|
716
|
+
(`PromptPart.from_h`), and its own save drops them (cases 1–2). The corpus's `compat-prompt` session has a head and
|
|
717
|
+
placed parts (`ReleaseTools.write_compat_corpus!`, read in `spec/compat/readers_spec.rb`); in the wire samples the head
|
|
718
|
+
is `CompatWire::SYSTEM_PROMPT`, so the digest never matches and a wire reader asserts the fallback.
|
data/docs/mcp-server.md
CHANGED
|
@@ -47,7 +47,11 @@ host isn't left waiting on that call.
|
|
|
47
47
|
| `chi_wait` | `token` | keeps waiting for a turn that was still running |
|
|
48
48
|
| `chi_answer` | `session`, `question_id`, `option?` / `options?` / `text?` | answers the question a session waits on, then waits |
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
`chi_ask` with `/continue yes` follows the continued turn: its answer, or a `chi_wait` token while it runs.
|
|
51
|
+
|
|
52
|
+
A call waits at most 25 seconds (a `chi_ask` or `chi_answer` 35 in all, under Claude Code HTTP's 60 s). Under `chi
|
|
53
|
+
--remote NAME` (stdio, where no host has a 60 s limit) a session whose worker is slow can take about a minute: the
|
|
54
|
+
other chi web makes its own tries. Then:
|
|
51
55
|
|
|
52
56
|
- the turn still runs: `Still running. Call chi_wait with this token to keep waiting.` with a `token`;
|
|
53
57
|
- a question waits: the question, its numbered options and `Call chi_answer with session, question_id and option
|
|
@@ -63,10 +67,14 @@ with `isError: true` and chi's own words; only an unknown tool is a protocol err
|
|
|
63
67
|
## Who the caller is
|
|
64
68
|
|
|
65
69
|
The host is an agent driving a session, as `chi send --wait` and `chi answer` are (see [chi as a
|
|
66
|
-
sub-agent](sub-agent.md)): its messages go in as
|
|
70
|
+
sub-agent](sub-agent.md)): its messages go in as an agent's, its answers and a `/continue yes` as `chi answer`'s.
|
|
67
71
|
So `guardrails.parent_answers` holds it (see [Guardrails](guardrails.md#answers-from-a-parent-agent)): what it may
|
|
68
72
|
pick on an approval or a step-limit question, and whether it may continue a turn that ran out of iterations. The
|
|
69
|
-
page shows its turns
|
|
73
|
+
page shows its turns as an agent's: on stdio (`chi mcp serve`) named by the host's marker in its environment
|
|
74
|
+
(`CLAUDECODE` gives "agent claude", see [driver and visitor](sub-agent.md#an-agents-messages-driver-and-visitor)),
|
|
75
|
+
else "agent mcp"; over HTTP (`POST /api/mcp`) always "agent mcp". Whether Claude Code exports `CLAUDECODE` to the
|
|
76
|
+
stdio servers it starts is up to Claude Code: without it the host is "agent mcp". A session the host didn't create
|
|
77
|
+
takes its messages as a visitor's (one header line, counted toward `session.max_wakes`).
|
|
70
78
|
|
|
71
79
|
`chi_ask` takes a message for the model, not a command: a line starting with `!` (a shell line) or with `/` (a
|
|
72
80
|
session command; `/continue …` is the one exception) is refused. That is narrower than `chi send` on purpose: a
|
data/docs/memory.md
CHANGED
|
@@ -155,7 +155,8 @@ Each memory entry may have a companion file named `<name>.<model-key>.md` in the
|
|
|
155
155
|
- **Key derivation**: The harness normalizes the model name sent to the server, without its host prefix (`box:qwen3.6-35b-a3b` keys as `qwen3.6-35b-a3b`; an alias keys as its target, and the alias's own key is read when the target has no overlay) (lowercase, replace non-alphanumeric with `-`, squeeze dashes) to derive the file key. For example, `qwen3.6-35b-a3b` → `qwen3-6-35b-a3b`.
|
|
156
156
|
- **Saving overlays**: Pass `current_model_only: true` to `memory_write` (the harness resolves the model key automatically). This writes the content as `<name>.<model-key>.md` and skips index maintenance. The guardrails bundle asks before a model writes one (`model-overlay-write`). Habits of a model in general go in a [model note](#model-notes), which can name a family or all small models.
|
|
157
157
|
- **Which key is mine**: the system prompt's `Model:` line names the session's model key, and `chi self` (via `execute`) has a `model key` row; both follow `/model`.
|
|
158
|
-
- **In the system prompt**: the identity memory and the preloaded memories (`--memory`, config `memories:`) get their overlays too, as `memory_read` gives them; after `/model` the rebuilt prompt carries the new model's.
|
|
158
|
+
- **In the system prompt**: the identity memory and the preloaded memories (`--memory`, config `memories:`) get their overlays too, as `memory_read` gives them; after `/model` the rebuilt prompt carries the new model's. Each prompt part saves the keys and folders its build resolved with, so the web's working set re-resolves it the same way (an overlay added or removed since, or a project memory now shadowing a system one, makes its "From the start" row `stale`; a source chi changed itself, with `memory_write` or an `edit`, reads `✎ edited`
|
|
159
|
+
and links the call, not `stale`; see [working-set.md](internals/working-set.md#prompt-parts-as-sent)).
|
|
159
160
|
- **Dormancy**: Overlays are only active under the matching model key; other models see the base entry only.
|
|
160
161
|
- **Invariant**: The base entry is the contract. Overlays only add model-specific guidance and never contradict the base protocol.
|
|
161
162
|
- **In a bundle**: ship `<name>.<key>.md` next to `<name>.md` (ship the base too; an overlay with no base anywhere installs with a warning and loads only once the base exists; one whose base is only among your installed memories is taken as an overlay of it, with a warning naming it). The overlay gets no `index.md` line, so other models don't see it, and `chi bundle status` reads it `ok (model overlay)`; `chi bundle build FILES...` brings a named memory's overlays along.
|
data/docs/plugins.md
CHANGED
|
@@ -31,7 +31,7 @@ plugin:
|
|
|
31
31
|
# required: true # optional: a guardrail plugin; if it fails to load, every tool call is
|
|
32
32
|
# denied (see chi.on's on_error: :fail_closed; chi 0.157.0 or newer)
|
|
33
33
|
# parts: # optional: more .rb files of the plugin, loaded in this order before file:
|
|
34
|
-
# client.rb: sha256:… # (see "A plugin in several files" below; needs
|
|
34
|
+
# client.rb: sha256:… # (see "A plugin in several files" below; needs chi 0.183.0)
|
|
35
35
|
requires_chi: ">= 0.1.28" # optional: a gem-style requirement (">= 0.1.28, < 0.2"); the bundle's rules check it too
|
|
36
36
|
# every key below has a chi floor: check warns when requires_chi admits a chi that never read it
|
|
37
37
|
# requires_chi_next: true # shipped bundles only, ignored by chi: rake release:bump raises requires_chi
|
|
@@ -108,7 +108,7 @@ plugin:
|
|
|
108
108
|
- A part is a `.rb` name in the bundle's top directory, not the plugin file's own nor another part's, in any case
|
|
109
109
|
(`Plugin.rb` beside `plugin.rb` is one file on a case-insensitive disk), listed once; at most 16. It is installed
|
|
110
110
|
beside the plugin file in `plugin/`, checked like it at every load, and listed by `chi bundle status`, `diff`,
|
|
111
|
-
`build` and `uninstall`.
|
|
111
|
+
`build` and `uninstall`. `chi bundle check` warns when a `.rb` in a subdirectory would be left out of the install.
|
|
112
112
|
- chi evaluates the parts **in the listed order**, then the plugin file, all into the same fresh module, so they
|
|
113
113
|
share one namespace. Only the plugin file names the class chi builds; a part usually reopens it
|
|
114
114
|
(`class Plugin; class HttpClient …`).
|
|
@@ -119,8 +119,8 @@ plugin:
|
|
|
119
119
|
- Not `require_relative`: a file pulled in that way skips the sha256 check, is cached by Ruby across reloads (a
|
|
120
120
|
reload would keep the old classes) and defines its constants outside the bundle's namespace.
|
|
121
121
|
- A bundle that uses `parts:` should require a chi that reads them (`requires_chi`): an older chi would install the
|
|
122
|
-
plugin file alone. `chi bundle check` warns of a
|
|
123
|
-
|
|
122
|
+
plugin file alone. `chi bundle check` warns of a `requires_chi` below 0.183.0, the
|
|
123
|
+
release that brings parts. A record written that way is refused at load with `bundle NAME's
|
|
124
124
|
plugin parts aren't installed (reinstall the bundle)`.
|
|
125
125
|
|
|
126
126
|
## The API: `register(chi)`
|
|
@@ -956,7 +956,7 @@ full label, `plugin.rb (bundle my-bundle)`.
|
|
|
956
956
|
| `ctx.judge(name, state:)`, `ctx.judge_later(name, state:) { |result| … }`, `ctx.judgments` | a cheap System 1 question this bundle declared, saved as a run: see [Judgments](#judgments-chijudgment-and-ctxjudge) |
|
|
957
957
|
| `ctx.sign_in(title:, button:, timeout: 300, port: nil, path: "/callback", cancel: nil) { \|redirect_uri\| address }` | send the owner to an address and get back where the browser was sent: see [Sign-in](#sign-in-ctxsign_in) |
|
|
958
958
|
| `ctx.secrets` | the bundle's tokens, kept apart from its data files (`get`, `set`, `delete`, `update`): see [Secrets](#secrets-ctxsecrets) |
|
|
959
|
-
| `ctx.http` | an HTTP client for calling services (`get`, `post_json`, `request`): see [Calling services](#calling-services-ctxhttp) |
|
|
959
|
+
| `ctx.http` | an HTTP client for calling services (`get`, `post_json`, `request`, `stream`): see [Calling services](#calling-services-ctxhttp) |
|
|
960
960
|
| `ctx.sessions` | fork, send to, read, list and stop other sessions: see [Other sessions](#other-sessions-ctxsessions) |
|
|
961
961
|
| `ctx.toolkit` | the name of the session's toolkit (`full` for a session from before toolkits); nil with no session |
|
|
962
962
|
| `ctx.declared_tools` | the tool names the session's next turn declares (its toolkit resolved, with its own adds and removes): ask this, not the name, whether a tool is there. Your bundle's own `chi.tool` tools are in it only on a kit that declares them (`full`, an `add:`); elsewhere they are reachable, not declared (the testing kit answers every tool, as on full, unless `bundle.set(declared_tools: […])`) |
|
|
@@ -1065,7 +1065,7 @@ A card from a thread of your own (a sign-in's result, a server's state) that a t
|
|
|
1065
1065
|
lands in that turn's block, which the web collapses when the turn ends. `between_turns: true` keeps it out: while a
|
|
1066
1066
|
turn runs it is shown as an anytime command's card is (outside the turn's block, marked `anytime: true`), else as
|
|
1067
1067
|
any card between turns. It is the rule chi's own sign-in cards follow. The test kit records it on the card
|
|
1068
|
-
(`between_turns: true`). The keyword needs
|
|
1068
|
+
(`between_turns: true`). The keyword needs chi 0.183.0 or newer (an older one raises `ArgumentError`).
|
|
1069
1069
|
|
|
1070
1070
|
A worker keeps its last 20 cards (questions included) and, apart, its
|
|
1071
1071
|
last 20 hook notices, for a UI that joins later; a question still waiting
|
data/docs/scheduling.md
CHANGED
|
@@ -194,6 +194,25 @@ disables the entry and `chi schedule list` says why. **Any successful firing res
|
|
|
194
194
|
both counters**, so twelve skips spread over months do not kill a healthy weekly
|
|
195
195
|
schedule. `list` prints the skip budget as a time window — 12 skips at a 5 minute
|
|
196
196
|
tick is about an hour of patience, which is what the count really measures.
|
|
197
|
+
`chi schedule enable` resets both counters too: a schedule turned back on gets its
|
|
198
|
+
whole budget again, not one skip.
|
|
199
|
+
|
|
200
|
+
A recurring schedule the owner has disabled stays off when an in-flight skip or
|
|
201
|
+
failure is recorded. A `date` one-off is the exception: a skip or failure puts its
|
|
202
|
+
moment back and re-enables it. `run-now` still tries a disabled schedule, but a
|
|
203
|
+
refusal records its result without moving the skip or failure counters.
|
|
204
|
+
|
|
205
|
+
The tick line that disabled an entry ends `(disabled)` (`chi schedule tick`,
|
|
206
|
+
`run-now`), and `tick --format json` gives that outcome `"disabled": true`
|
|
207
|
+
(`Schedules::Outcome#disabled`). When **chi web's** tick (`schedule.auto_tick`)
|
|
208
|
+
disables a recurring schedule, the phone gets one notification
|
|
209
|
+
([Phone notifications](configuration.md#phone-notifications-web-push)): "Schedule
|
|
210
|
+
disabled: Heartbeat", "skipped 12 times: <the last reason>" and the `chi schedule
|
|
211
|
+
enable <id>` that turns it back on; a tap opens its session. It shows even with a chi
|
|
212
|
+
web page in front and waits a day for a phone that is offline. Nothing notifies for a
|
|
213
|
+
cron tick or `chi schedule run-now` (only chi web pushes), a `--dry-run`, your own
|
|
214
|
+
`chi schedule disable`, or a `date` one-off (spent when it fires; one that then fails
|
|
215
|
+
stays disabled with the failure in `chi schedule list`).
|
|
197
216
|
|
|
198
217
|
An accepted delivery is **pending**, not fired: `schedules.json` records its
|
|
199
218
|
session and turn id, and the next tick follows that turn's own outcome, even if a
|
data/docs/sessions.md
CHANGED
|
@@ -39,7 +39,7 @@ Retention and manual prune/clean silently stop each deleted session's verified b
|
|
|
39
39
|
|
|
40
40
|
**Always attached:** every interactive `chi` (plain, `-p`, `--resume ID`, `--attach ID`, `chi scratch`) runs its session in a background worker and attaches to it; there is no setting for it. The worker runs in the session's `working_directory`, so `!commands` and tools see the directory the session was started in. Only `chi -p TEXT --non-interactive` runs its one turn in this process; while it does, the session can't be attached ("in use by a one-turn chi --non-interactive run or an older chi's terminal"). See [CLI: Sharing a session](cli.md#sharing-a-session).
|
|
41
41
|
|
|
42
|
-
**Who may wake a session:** every turn delivery names its sender (`SessionManager.deliver_turn` requires `client_id`), and the sender's kind picks what it may do to the worker (`ClientId.wake_kind`, `SessionInbox::WakePolicy.for_sender`). A person — `chi send`, a web tab, an attached terminal — starts an idle session, un-stops a stopped one and brings back an archived link. Nobody's message goes into a session being deleted (409 `session_deleting`, *Deleting a session* above). A schedule's firing, a plugin's `ctx.sessions.send`, a `delegate` follow-up, a participant's turn and any sender chi doesn't name start an idle session only: a session its owner stopped or archived refuses them (409 `session_stopped`, "the session is stopped; only its owner's message starts it again", or `session_archived`, "…brings it back"), nothing written. A schedule counts that as a skip (and skips a stopped session at its check, [scheduling.md](scheduling.md)); `delegate` says it as `Error: session <id8> refused: …`; a plugin gets `Error`. A turn already handed to a live worker is that worker's, as before. chi web's owner turn and command routes name a body that carries no `client_id` as `web:unnamed` (a web tab's rights).
|
|
42
|
+
**Who may wake a session:** every turn delivery names its sender (`SessionManager.deliver_turn` requires `client_id`), and the sender's kind picks what it may do to the worker (`ClientId.wake_kind`, `SessionInbox::WakePolicy.for_sender`). A person — `chi send`, a web tab, an attached terminal — starts an idle session, un-stops a stopped one and brings back an archived link. Nobody's message goes into a session being deleted (409 `session_deleting`, *Deleting a session* above). A schedule's firing, a plugin's `ctx.sessions.send`, a `delegate` follow-up, a participant's turn, an agent's `chi send` (`agent:<name>`, [driver and visitor](sub-agent.md#an-agents-messages-driver-and-visitor)), another session's `ask_session` and any sender chi doesn't name start an idle session only: a session its owner stopped or archived refuses them (409 `session_stopped`, "the session is stopped; only its owner's message starts it again", or `session_archived`, "…brings it back"), nothing written. A schedule counts that as a skip (and skips a stopped session at its check, [scheduling.md](scheduling.md)); `delegate` says it as `Error: session <id8> refused: …`; a plugin gets `Error`. A turn already handed to a live worker is that worker's, as before. chi web's owner turn and command routes name a body that carries no `client_id` as `web:unnamed` (a web tab's rights).
|
|
43
43
|
|
|
44
44
|
**Which chi a worker runs:** a new or woken worker runs the newest chi installed for this Ruby (`gem 'samagotchi', '>= 0.a'`, prereleases count), whoever starts it: a `chi web` or terminal still on an older chi starts it on the newest one, so a stale process doesn't spread old code. A worker already running keeps its version until it is restarted. Should the newest install fail to load, the worker runs the starter's own version and logs `boot_fallback` (its stdio is `/dev/null`). Under `bundle exec` the worker drops Bundler's env first, so it activates the newest gem too. Two consequences: a wrapper pin (`chi _0.17.0_ web`) pins only that process, not the workers it starts; and a source checkout (`bin/chi` in a worktree, `bundle exec`) starts its workers on its own `lib/`, but a session it made that is later woken by an installed chi (`chi web`, `chi send`) runs the installed code. The names an older starter hands a newer worker (the boot line, its env keys, `input/` files, the session JSON fields and the Bridge routes sessions use on each other) are pinned in `spec/worker_contract_spec.rb`. A chi newer than 0.130.0 keeps the top-level keys it doesn't know (a newer chi's fields) when it saves a session, after its own, and doesn't act on them; `written_by` names the chi that saved the file last, and a worker woken on a file a newer chi saved logs `newer_writer`. chi 0.130.0 and older drop those keys: a session a newer chi made loses its newer fields when an older chi wakes or saves it (for example `chi --attach` from a project whose Ruby has an older chi). Keep the chi in every Ruby you run it from newer than 0.130.0.
|
|
45
45
|
|
|
@@ -149,7 +149,7 @@ chi sessions clean --dry-run --days 7 # test sessions older than 7 da
|
|
|
149
149
|
| `project_id` | A marked project's id (its `.chi/project.yml`'s `id:`), saved beside `project_root`: the session's project context sources are keyed by it, so they follow a moved folder. Absent for any other project. | creation |
|
|
150
150
|
| `preloaded_memory_names`, `muted_memory_names` | `--memory` and `--mute`, written before the worker starts so a respawn builds the same prompt; copied by a fork and a continue. A fork drops the reserved `system/delegated` memory so its `parent_id` does not make it a delegate; a continuation of a delegate child drops it because the new link is not a delegate. | creation |
|
|
151
151
|
| `prompt_notes` | The model notes the system prompt carried at its last build (`[{name, scope, chars, digest}]`, see [Memory](memory.md#model-notes)). | the Engine, at each prompt build |
|
|
152
|
-
| `prompt_parts` | The sizes of the parts the system prompt was made of at its last build (`[{kind, label, chars, tokens, ref, scope?}]`: a `tools` part first, then one per memory, file and plugin section in prompt order, the indexes one per scope; tokens at `chars / 4`; no text). `scope` is a memory part's, `project` or `system` (identity `system`, a model note its own, a preload the scope that answered its read); other parts and an older file leave it out, and the page then matches the part to the set's memory by name alone. A `/model` switch records `[]` until the next build. The web's head view lists them; an older file or worker has none and reads as `[]` (a missing field is the old case, the page draws without the part rows). | the Engine, at each prompt build |
|
|
152
|
+
| `prompt_parts` | The sizes of the parts the system prompt was made of at its last build (`[{kind, label, chars, tokens, ref, scope?}]`: a `tools` part first, then one per memory, file and plugin section in prompt order, the indexes one per scope; tokens at `chars / 4`; no text). `scope` is a memory part's, `project` or `system` (identity `system`, a model note its own, a preload the scope that answered its read); other parts and an older file leave it out, and the page then matches the part to the set's memory by name alone. A `/model` switch records `[]` until the next build. Each part also says where it sits in the prompt the build made (`at`, `len` with its `lead`, a 12-hex `digest` of its own text, the build's 16-hex `head` digest) and how to fetch it again (`params`: a memory's requested scope, overlay keys and folders, a file's path, the tools' names and sizes), each left out when nil; the prompt itself is `messages[0]` (a `system` message with no `kind`), so chi web's part route slices it rather than keeping a copy ([working-set.md](internals/working-set.md#prompt-parts-as-sent)). About 2–3 KB a session, in the file and every snapshot. An older chi reads the parts and drops the new fields. The web's head view lists them; an older file or worker has none and reads as `[]` (a missing field is the old case, the page draws without the part rows). | the Engine, at each prompt build (never the turn-end warm-up's) |
|
|
153
153
|
| `parent_id` | The session that delegated this one or forked it (`ctx.sessions.fork`); `null` otherwise. See [Delegating](#delegating). | `SessionManager.spawn_session`; `ChildMove` writes a `parent.json` beside it instead of this file |
|
|
154
154
|
| `scratch` | A `chi scratch` session, deleted when its terminal leaves. | creation |
|
|
155
155
|
| `last_turn` | How the last turn ended (`LastTurn`), for a parent's wait and the web's notifications. | the Engine, at a turn's end |
|
|
@@ -175,6 +175,16 @@ chi sessions clean --dry-run --days 7 # test sessions older than 7 da
|
|
|
175
175
|
|
|
176
176
|
A context note is text pushed into a session as background: not a prompt, and it starts no turn.
|
|
177
177
|
|
|
178
|
+
Its model's twin is `send_note` (a note to another session). To ask another session something and get its
|
|
179
|
+
answer back, the model has `ask_session` instead: `ask_session(session:, question:)` runs the question as a turn
|
|
180
|
+
of its own there (queued behind a running one), labelled `session <id8>` and read as `[Question from another chi
|
|
181
|
+
session (<id8>), asked by its model; not your user's message. …]`, a visitor's turn counted toward that session's
|
|
182
|
+
`session.max_wakes`. The answer is the tool's result; one call waits up to 35 s, then gives a token that
|
|
183
|
+
`ask_session(token:)` waits on. A session that waits on a question for its user is not answered (the asker says
|
|
184
|
+
so to its user). A stopped or archived session, one a one-turn run holds, a scratch session, the asker itself and a
|
|
185
|
+
`/` or `!` line are refused; a worker older than `ask_session` is refused too (restart it). It is in the toolkits
|
|
186
|
+
that hold `send_note` but a delegate child's, and not in a scratch session.
|
|
187
|
+
|
|
178
188
|
```sh
|
|
179
189
|
chi note [--source NAME] [-m TEXT] (ID|PREFIX)... | --all
|
|
180
190
|
pbpaste | chi note --source slack 3f2a 8c1d
|
|
@@ -327,7 +337,7 @@ pbpaste | chi send 3fa2 # the clipboard is the messa
|
|
|
327
337
|
```
|
|
328
338
|
|
|
329
339
|
- With both stdin and `-m`, stdin is context: each line becomes a `> ` quote (as web annotations quote a selection), then a blank line, then the message. With only one, it goes in as is. A terminal on stdin is ignored. Both empty is a usage error; over 16 KiB is refused, never cut.
|
|
330
|
-
- It goes through the same path as the web composer (`SessionManager.deliver_turn`): the worker's Bridge when it is up, so every attached UI shows it as your message (client id `cli:send`, shown like any user message); the input file when the worker is on its way out. During a running turn it is merged into that turn at the next step, like a message typed then, and cuts nothing. `--cut` asks for a cut, as `/cut TEXT` in a terminal does: a generation that has streamed only thinking for `steer.cut_after` seconds (per host/model: `steer_cut_after`) is cut (now, or once its thinking passes that), and the step starts again with the message. To an idle session `--cut` sends normally. `--cut --wait` into a running turn is refused like any `--wait` there (`busy: a turn is running`). `--queue` (not with `--cut`, a usage error) keeps the message for after the running turn: it runs as a turn of its own then (as `/queue TEXT` does), and a plain message sent after it still goes in at the running turn's next step. To an idle session it runs at once (it still goes as a queue, so a turn another client starts first never takes it as a steer). A worker older than queueing would steer it instead, so it is refused (to an idle session too) (`refused: this session's worker predates queueing, …; restart it`, exit 1) and nothing is sent; `chi sessions restart ID` and send again.
|
|
340
|
+
- It goes through the same path as the web composer (`SessionManager.deliver_turn`): the worker's Bridge when it is up, so every attached UI shows it as your message (client id `cli:send`, shown like any user message; from an agent, `agent:NAME`, labelled "agent NAME", a driver's or a visitor's: [driver and visitor](sub-agent.md#an-agents-messages-driver-and-visitor)); the input file when the worker is on its way out. During a running turn it is merged into that turn at the next step, like a message typed then, and cuts nothing. `--cut` asks for a cut, as `/cut TEXT` in a terminal does: a generation that has streamed only thinking for `steer.cut_after` seconds (per host/model: `steer_cut_after`) is cut (now, or once its thinking passes that), and the step starts again with the message. To an idle session `--cut` sends normally. `--cut --wait` into a running turn is refused like any `--wait` there (`busy: a turn is running`). `--queue` (not with `--cut`, a usage error) keeps the message for after the running turn: it runs as a turn of its own then (as `/queue TEXT` does), and a plain message sent after it still goes in at the running turn's next step. To an idle session it runs at once (it still goes as a queue, so a turn another client starts first never takes it as a steer). A worker older than queueing would steer it instead, so it is refused (to an idle session too) (`refused: this session's worker predates queueing, …; restart it`, exit 1) and nothing is sent; `chi sessions restart ID` and send again.
|
|
331
341
|
- A session with no worker gets one started (like `--attach` or the web composer). A session a one-turn `chi --non-interactive` run has refuses it. Bridges listen on 127.0.0.1: another machine's sessions are reached through its chi web, `chi --remote NAME send …` ([Remote sessions](cli.md#remote-sessions)).
|
|
332
342
|
- Fire and forget: it returns once the message is queued and never prints the answer; that shows in whatever is attached. A guardrail "ask" waits for a UI to answer it, so with nothing attached the turn stalls there until one attaches (`chi --attach ID`).
|
|
333
343
|
- `--image PATH` (repeatable, up to 20) sends images with the message, as the web composer's chips do. Each file is read once before anything is sent (bmp, tiff and heic converted to png, large ones downscaled, as for `@path`); a missing file or one that isn't an image stops the send (exit 1; with `--wait --format json`, an `error` line) and nothing is sent; more than 20 is a usage error (exit 2). Each session gets its own copy in `<session>/images/`. Text is still required (`-m` or stdin; context alone counts), also with `--wait`. The session's model must see images: one known not to (the host's model list says text-only, `vision: false` in `models:` or `hosts:`, a native llama.cpp without a vision model) is refused before anything is sent, with the reason (`<id> refused: gemma can't take images (…); send text only or switch the model (/model)`); the other sessions of the same send still get it, and the exit is 1. With `--new` nothing is started. When chi can't tell (a native host whose `/props` doesn't answer, a list that doesn't say), the message is sent as before and a text-only model fails the turn in the session. A running turn doesn't take images mid-turn: the message runs as the next turn, and the line says `(runs after the current turn)`. With `--new` the session starts idle with the message as its preview, then the message goes in as its first turn once its worker is up (`<id> started with 1 image`); if the worker doesn't come up in 5 s the session is kept, with its id on the `failed:` line.
|
data/docs/sub-agent.md
CHANGED
|
@@ -26,7 +26,9 @@ The other direction, chi sending a part of its work to a Claude Code session
|
|
|
26
26
|
you already work with (to validate, as context, or with a question), is the
|
|
27
27
|
[claude-peer bundle](bundles.md#the-claude-peer-bundle): Claude pairs with the
|
|
28
28
|
chi session, chi's `claude_send` tool or `/claude` writes to Claude's inbox,
|
|
29
|
-
and Claude's answer comes back as attached context
|
|
29
|
+
and Claude's answer comes back as attached context, its whole text in a note
|
|
30
|
+
of chi's conversation (Claude can also tell chi something unasked, which wakes
|
|
31
|
+
chi under the same count). The
|
|
30
32
|
[codex-peer bundle](bundles.md#the-codex-peer-bundle) does the same with a
|
|
31
33
|
Codex CLI session (`codex_send`, `/codex`, through `codex queue`). The peer's
|
|
32
34
|
answers wake chi in a short loop (fix or disagree, send again) until it says
|
|
@@ -38,11 +40,54 @@ A client with no chi of its own (an iOS Shortcut, a script) can do the same
|
|
|
38
40
|
over HTTP: one `POST …/ask` to chi web, then a wait token until the answer
|
|
39
41
|
comes ([Thin clients](thin-clients.md)). An agent uses `chi send` and `chi
|
|
40
42
|
answer` (with `--remote NAME` for another machine) whenever it can run chi.
|
|
41
|
-
Over HTTP it must send `"client_id": "
|
|
43
|
+
Over HTTP it must send `"client_id": "agent:NAME"` on an ask and
|
|
42
44
|
`"client_id": "cli:answer"` on an answer: without them its lines are the
|
|
43
45
|
owner's and `guardrails.parent_answers` does not hold them ([An agent over
|
|
44
46
|
HTTP](thin-clients.md#an-agent-over-http)).
|
|
45
47
|
|
|
48
|
+
## An agent's messages: driver and visitor
|
|
49
|
+
|
|
50
|
+
An agent's `chi send` goes in as the agent, not as you: `agent:claude`, labelled
|
|
51
|
+
"agent claude" in the web and the terminal. Who it is: chi's own marker first
|
|
52
|
+
(`SAMAGOTCHI_PARENT_SESSION`, which chi's `execute` and tasks set: `agent:chi-<id8>`,
|
|
53
|
+
even over `--as`, said on stderr), then `chi send --as NAME` (lowercase letters,
|
|
54
|
+
digits, `-` and `_`, up to 32), then `CLAUDECODE` (`claude`), `CODEX_THREAD_ID`
|
|
55
|
+
(`codex`), `AI_AGENT` (its value). With none of these it is yours, `cli:send`, as
|
|
56
|
+
before: a pipe alone is not a marker, so your own script or cron line stays yours.
|
|
57
|
+
The id is self-declared, as `cli:send` is: a convention for an honest agent, not a
|
|
58
|
+
security boundary. Every Claude Code session is `claude` unless it passes `--as`.
|
|
59
|
+
|
|
60
|
+
An agent's message can't restart a stopped session (`refused: the session is
|
|
61
|
+
stopped; only its owner's message starts it again`), bring back an archived one,
|
|
62
|
+
or run a `!` line (refused with the shell-line text). It may send session commands
|
|
63
|
+
(`/model x`, `/thinking low`); its `/continue yes` goes in as `chi answer`'s, held to
|
|
64
|
+
`guardrails.parent_answers`.
|
|
65
|
+
|
|
66
|
+
- **The driver.** The agent that created a session (`chi send --new` from Claude
|
|
67
|
+
Code), or the one you named (`chi send --new --driver NAME`, `/driver NAME` at a
|
|
68
|
+
terminal or the web), drives it: its messages are as `chi send`'s were. No extra
|
|
69
|
+
line, never counted; each resets the wake budget and releases the delegate
|
|
70
|
+
reports held back, as your message does (but never brings back an archived
|
|
71
|
+
session). A continue keeps the chain's driver; a fork and a delegate child have
|
|
72
|
+
none. Sessions an agent started before this change have no driver: name it with
|
|
73
|
+
`/driver claude` once.
|
|
74
|
+
- **A visitor.** Any other agent's message, and another chi session's
|
|
75
|
+
`ask_session` question, is a visitor's: its turn opens with one line naming it
|
|
76
|
+
(`[From the agent codex, sent with chi send; your user did not type this.]`), it
|
|
77
|
+
is not taken as your prompt (no objectives audit, toolkit suggestion or context
|
|
78
|
+
candidates for it), and it counts toward `session.max_wakes` (10 in a row), the
|
|
79
|
+
budget delegate, task and context wake turns use: after ten wake turns a
|
|
80
|
+
visitor's message is refused, and the reverse. Your next message resets the
|
|
81
|
+
count. A refused visitor turn ends a `--wait` with exit 1, status `refused`,
|
|
82
|
+
`cancel_reason: max_wakes` and the sentence `session.max_wakes turns ran in a
|
|
83
|
+
row with no message from this session's owner; it runs again after their next
|
|
84
|
+
message`; a `chi send` without `--wait` is told nothing (it printed `sent`). You
|
|
85
|
+
hear it once per stretch in the session's UIs. A visitor's line merged into a
|
|
86
|
+
running turn is not counted (the step limit bounds that turn).
|
|
87
|
+
|
|
88
|
+
Against an older worker or chi web (no `agent_sender` feature) an agent's message
|
|
89
|
+
goes as `chi send`'s, today's behaviour.
|
|
90
|
+
|
|
46
91
|
## The commands
|
|
47
92
|
|
|
48
93
|
```sh
|
|
@@ -80,7 +125,7 @@ Exit codes, both commands:
|
|
|
80
125
|
| 3 | `question` | chi waits for an answer: `question`, `answer_with` |
|
|
81
126
|
| 3 | `waiting_for_owner` | (a participant's wait, `chi --remote NAME send --wait` with their link's token) their turn waits on the session's owner: a question or an approval it raised, or the owner's step-limit Continue; wait again |
|
|
82
127
|
| 4 | `running` | `--timeout` passed; the turn goes on, wait again |
|
|
83
|
-
| 1 | `refused` |
|
|
128
|
+
| 1 | `refused` | the queued turn was refused before it ran, no turn ran for it: `cancel_reason` `max_wakes` (an agent's message as a visitor, past `session.max_wakes`: [driver and visitor](#an-agents-messages-driver-and-visitor)), or for a participant's wait `revoked` (their link was revoked or expired), `outdated` (their link is an older chi's read-only one) or `cap_reached` (they spent their cap) |
|
|
84
129
|
| 1 | `failed`, `canceled`, `limit`, `removed`, `no_answer`, `error`, `worker_gone`, `stopped` | `detail` says what happened (`limit`: the turn ran out of steps and nobody can be asked, e.g. an older worker; `chi send ID -m '/continue yes'` continues it, except under `guardrails.parent_answers: hard`, where a parent's `/continue yes` is refused as its `chi answer --option Continue` is; `removed`: the `--queue` message waited for was taken back before it ran, no turn ran for it). `failed` adds `error_kind` (the provider error's kind: `credits`, `credits_held`, `rate_limited`, `server`, `auth`, `connection`, …) and `retryable` when known; `canceled` adds `cancel_reason` (`user`: a Stop in the web; `session_stopped`: a session stop, `chi sessions stop` or the web's; `worker_stopped`: the turn waited for (a `--queue` message's, a message's to an idle session, the running turn a message merged into or a plain `--wait` saw running) died with its worker (detail "its worker exited mid-turn"), settled by the next one; `hook`; `ctrl_c`; `manual`) and `stopped_by` (the hook that stopped it, e.g. `loop-guard`) when known |
|
|
85
130
|
| 2 | (no JSON) | usage error, or an option the question doesn't offer |
|
|
86
131
|
| 130 | `running` | Ctrl-C; the turn goes on |
|