samagotchi 0.187.0 → 0.189.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 +96 -1
- data/bin/chi +2 -0
- data/docs/architecture.md +13 -7
- data/docs/bundle-authoring.md +1 -1
- data/docs/bundles.md +139 -120
- data/docs/cli.md +46 -8
- data/docs/configuration.md +4 -4
- data/docs/context.md +18 -162
- data/docs/guardrails.md +6 -3
- data/docs/hooks.md +2 -1
- data/docs/internals/attached-context.md +19 -37
- data/docs/internals/bridge.md +1 -0
- data/docs/internals/bundles.md +3 -3
- data/docs/internals/engine.md +2 -2
- data/docs/internals/llm-context-forget.md +5 -6
- data/docs/internals/objectives.md +1 -0
- data/docs/internals/pages.md +71 -21
- data/docs/internals/peers.md +149 -0
- data/docs/internals/remote-sessions.md +7 -4
- data/docs/internals/session-lifecycle.md +19 -6
- data/docs/internals/web-frontend.md +63 -39
- data/docs/internals/web-push.md +12 -6
- data/docs/memory.md +1 -1
- data/docs/pages.md +70 -16
- data/docs/peers.md +144 -0
- data/docs/plugins.md +77 -28
- data/docs/releasing.md +1 -1
- data/docs/scheduling.md +71 -8
- data/docs/sessions.md +12 -8
- data/docs/sub-agent.md +5 -5
- data/docs/testing.md +1 -1
- data/lib/samagotchi/bridge.rb +3 -3
- data/lib/samagotchi/bundle_command/api_calls.rb +2 -1
- data/lib/samagotchi/bundle_command/check.rb +1 -1
- data/lib/samagotchi/bundle_manifest.rb +34 -5
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +11 -18
- data/lib/samagotchi/bundles/claude-peer/plugin.rb +22 -16
- data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +48 -39
- data/lib/samagotchi/bundles/claude-peer/scripts/pair +15 -73
- data/lib/samagotchi/bundles/claude-peer/skill_claude_peer.md +16 -16
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +11 -15
- data/lib/samagotchi/bundles/codex-peer/plugin.rb +35 -24
- data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +51 -40
- data/lib/samagotchi/bundles/codex-peer/scripts/pair +18 -54
- data/lib/samagotchi/bundles/codex-peer/skill_codex_peer.md +16 -16
- data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
- data/lib/samagotchi/bundles/schedules/manifest.yml +11 -0
- data/lib/samagotchi/bundles/schedules/scripts/schedules.rb +159 -0
- data/lib/samagotchi/bundles/skills/manifest.yml +2 -2
- data/lib/samagotchi/bundles/skills/plugin.rb +14 -8
- data/lib/samagotchi/bundles/system/manifest.yml +3 -3
- data/lib/samagotchi/bundles/system/self_map.md +2 -2
- data/lib/samagotchi/bundles/system/skill_pages.md +9 -4
- data/lib/samagotchi/client_id.rb +15 -1
- data/lib/samagotchi/config.rb +8 -7
- data/lib/samagotchi/context_absorber.rb +23 -277
- data/lib/samagotchi/context_sources.rb +17 -69
- data/lib/samagotchi/engine/messages.rb +12 -1
- data/lib/samagotchi/engine/plugins.rb +1 -1
- data/lib/samagotchi/engine.rb +7 -6
- data/lib/samagotchi/engine_peers.rb +0 -3
- data/lib/samagotchi/guardrail_wiring.rb +2 -0
- data/lib/samagotchi/guardrails/chi_dirs.rb +4 -3
- data/lib/samagotchi/guardrails/parent_approvals.rb +6 -5
- data/lib/samagotchi/guardrails/protected_paths.rb +6 -3
- data/lib/samagotchi/inline_widgets.rb +11 -3
- data/lib/samagotchi/installed_bundles/manifest.rb +8 -1
- data/lib/samagotchi/log_line.rb +1 -1
- data/lib/samagotchi/memory_bundle/asset_installer.rb +3 -2
- data/lib/samagotchi/memory_bundle/builder.rb +1 -0
- data/lib/samagotchi/memory_bundle/installed_copy.rb +1 -1
- data/lib/samagotchi/note_move.rb +3 -1
- data/lib/samagotchi/page_command.rb +25 -13
- data/lib/samagotchi/pages/builder.rb +7 -8
- data/lib/samagotchi/pages/bundled.rb +83 -0
- data/lib/samagotchi/pages/launch.rb +22 -4
- data/lib/samagotchi/pages/runner.rb +7 -2
- data/lib/samagotchi/pages/runtime.rb +83 -0
- data/lib/samagotchi/pages/store.rb +29 -7
- data/lib/samagotchi/pages.rb +47 -3
- data/lib/samagotchi/peer_command.rb +192 -0
- data/lib/samagotchi/peer_continue.rb +105 -0
- data/lib/samagotchi/peer_exchanges.rb +3 -3
- data/lib/samagotchi/peer_mailbox.rb +360 -0
- data/lib/samagotchi/peer_note.rb +208 -0
- data/lib/samagotchi/peer_receipts.rb +247 -0
- data/lib/samagotchi/peer_registry.rb +44 -0
- data/lib/samagotchi/peer_roster.rb +79 -0
- data/lib/samagotchi/peer_say.rb +168 -0
- data/lib/samagotchi/plugin/api.rb +29 -21
- data/lib/samagotchi/plugin/context.rb +7 -0
- data/lib/samagotchi/plugin/loader.rb +3 -3
- data/lib/samagotchi/plugin/peer.rb +175 -64
- data/lib/samagotchi/plugin/peers.rb +70 -0
- data/lib/samagotchi/run_options.rb +3 -2
- data/lib/samagotchi/schedule_command.rb +88 -39
- data/lib/samagotchi/schedule_display.rb +101 -0
- data/lib/samagotchi/schedules/busy_part.rb +146 -0
- data/lib/samagotchi/schedules/edit_part.rb +120 -0
- data/lib/samagotchi/schedules/history_part.rb +51 -0
- data/lib/samagotchi/schedules/listing_part.rb +52 -0
- data/lib/samagotchi/schedules/notices_part.rb +116 -0
- data/lib/samagotchi/schedules/protection_part.rb +103 -0
- data/lib/samagotchi/schedules/recurrence.rb +103 -0
- data/lib/samagotchi/schedules.rb +134 -330
- data/lib/samagotchi/session_access/contract.rb +18 -1
- data/lib/samagotchi/session_access/local.rb +140 -14
- data/lib/samagotchi/session_access/remote.rb +6 -3
- data/lib/samagotchi/session_access/remote_peers.rb +75 -0
- data/lib/samagotchi/session_chain/delete.rb +7 -5
- data/lib/samagotchi/session_continue.rb +12 -0
- data/lib/samagotchi/session_inbox_delivery.rb +5 -2
- data/lib/samagotchi/session_lifecycle/allowed.rb +2 -1
- data/lib/samagotchi/session_lifecycle.rb +3 -2
- data/lib/samagotchi/session_manager/delivery.rb +5 -3
- data/lib/samagotchi/session_manager/removal.rb +18 -9
- data/lib/samagotchi/session_manager/spawn.rb +2 -1
- data/lib/samagotchi/session_manager.rb +1 -0
- data/lib/samagotchi/session_protection.rb +99 -0
- data/lib/samagotchi/session_retention.rb +21 -6
- data/lib/samagotchi/session_stores.rb +17 -0
- data/lib/samagotchi/sessions_command.rb +4 -0
- data/lib/samagotchi/steer.rb +1 -1
- data/lib/samagotchi/system_prompt.rb +1 -1
- data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
- data/lib/samagotchi/terminal_ui/formatting.rb +4 -1
- data/lib/samagotchi/testing/boundary.rb +17 -13
- data/lib/samagotchi/testing/bundle.rb +40 -5
- data/lib/samagotchi/testing/install.rb +4 -4
- data/lib/samagotchi/testing/recording_api.rb +2 -1
- data/lib/samagotchi/tools/cancel_schedule.rb +5 -2
- data/lib/samagotchi/tools/context_read.rb +0 -14
- data/lib/samagotchi/tools/list_schedules.rb +8 -3
- data/lib/samagotchi/turn_outcome.rb +41 -0
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +2 -13
- data/lib/samagotchi/web/message_display.rb +4 -2
- data/lib/samagotchi/web/page_routes.rb +13 -8
- data/lib/samagotchi/web/peer_routes.rb +133 -0
- data/lib/samagotchi/web/public/app.js +23 -29
- data/lib/samagotchi/web/public/bubbles.js +2 -2
- data/lib/samagotchi/web/public/cards_place.js +20 -1
- data/lib/samagotchi/web/public/context_chips.js +45 -46
- data/lib/samagotchi/web/public/history_reveal.js +4 -1
- data/lib/samagotchi/web/public/history_shape.js +3 -2
- data/lib/samagotchi/web/public/index.html +24 -2
- data/lib/samagotchi/web/public/notify.js +1 -1
- data/lib/samagotchi/web/public/owner_claim.js +7 -5
- data/lib/samagotchi/web/public/page_links.js +1 -1
- data/lib/samagotchi/web/public/page_view.js +10 -6
- data/lib/samagotchi/web/public/pages.css +9 -2
- data/lib/samagotchi/web/public/pages_group.js +21 -19
- data/lib/samagotchi/web/public/pages_list.js +73 -0
- data/lib/samagotchi/web/public/pages_model.js +54 -0
- data/lib/samagotchi/web/public/pages_wiring.js +66 -0
- data/lib/samagotchi/web/public/peer_chip.js +60 -74
- data/lib/samagotchi/web/public/peer_data.js +13 -11
- data/lib/samagotchi/web/public/peer_links.js +12 -7
- data/lib/samagotchi/web/public/peer_mailbox_api.js +20 -0
- data/lib/samagotchi/web/public/peer_note.js +7 -3
- data/lib/samagotchi/web/public/peer_text.js +4 -4
- data/lib/samagotchi/web/public/quiet_notes.js +199 -0
- data/lib/samagotchi/web/public/revise_stack.js +4 -3
- data/lib/samagotchi/web/public/session_view.js +2 -2
- data/lib/samagotchi/web/public/stream_handlers.js +3 -2
- data/lib/samagotchi/web/public/turn_block.js +7 -3
- data/lib/samagotchi/web/public/turn_events.js +6 -0
- data/lib/samagotchi/web/public/views.js +77 -23
- data/lib/samagotchi/web/push/attention.rb +3 -2
- data/lib/samagotchi/web/push/notifier.rb +4 -3
- data/lib/samagotchi/web/server.rb +3 -1
- data/lib/samagotchi/web/session_access_routes.rb +3 -20
- data/lib/samagotchi/web/session_hub.rb +64 -19
- data/lib/samagotchi/worker/leave.rb +3 -0
- data/lib/samagotchi/worker/mail.rb +73 -0
- data/lib/samagotchi/worker/startup.rb +3 -0
- data/lib/samagotchi/worker/wake_turns.rb +20 -5
- data/lib/samagotchi/worker.rb +12 -6
- data/lib/samagotchi/worker_inbound/mail.rb +214 -0
- data/lib/samagotchi/worker_inbound.rb +43 -46
- data/lib/samagotchi/worker_wakes.rb +26 -21
- metadata +35 -2
- data/lib/samagotchi/peer_sources.rb +0 -58
|
@@ -35,9 +35,9 @@ the next release (its baseline refresh) for the same reason, marked as kept for
|
|
|
35
35
|
sheet still keeps `isChained` and `format.js deleteConfirmText` that way; and `ws_peek.js`'s `PEEK_WIDTH`, which 0.183.0's
|
|
36
36
|
`working_set_view.js` imports though the view is 520 wide always now: `ws_part_peek_mixed_cache.test.js` loads this view
|
|
37
37
|
with 0.183.0's `ws_reader.js` and `ws_peek.js`, and 0.183.0's view with this `ws_reader.js`, from
|
|
38
|
-
`spec/web/public/fixtures/v0.183.0/`). `answer_fold.js`, `details_motion.js`,
|
|
38
|
+
`spec/web/public/fixtures/v0.183.0/`). `answer_fold.js`, `quiet_notes.js`, `details_motion.js`,
|
|
39
39
|
`turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
|
|
40
|
-
`session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from, the session's hash not written while it is open, a session picked leaving it; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_group.js` and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_part_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js`, `peer_text.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
|
|
40
|
+
`session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (The delete sheet, below), `removal_sheet_model.js` (its words: rows, button words, the archive model, the toast; DOM-free), `running_tasks.js` (a delete's or archive's tasks: their line and the toast's suffix; DOM-free, so `stop_sheet.js` and the delete sheet share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `views.js` (the views by hash, in one place: All sessions at `#/sessions` opened, closed and left; a page at `#/p/NAME`, read before the session intent, `hashIntent` calling it `keep`: `body.page-view`, Back to where it was opened from (kept in the history entry's `history.state.from`, so Back and Forward keep it), the session's hash not written while it is open, a session picked leaving it; the Pages list at `#/pages` the same way, `body.pages-list`, and the pages pill pressed on either; the session's `#/s/<id>` written; a hash change applied and selected; app.js makes it after the lists and hands its functions lazily to what it made before), the page's modules `page_route.js`, `page_view.js`, `page_model.js`, `page_blocks.js`, `page_table.js`, `page_table_model.js`, `pages_model.js` (the page's one list of pages), `pages_list.js` (the Pages list at `#/pages`, read by `views.js` beside a page's hash), `pages_wiring.js` (`wirePages`: the pill, the list, the view and the links, one call in app.js), `pages_group.js` (All sessions' former group, kept for an older cached app.js until after 0.189.0) and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_part_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js`, `peer_text.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `peer_mailbox_api.js` (the chip's message and Unpair calls), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `diagram_wiring.js` (`wireDiagrams`: the block host with the viewer as its `openPicture`, the viewer closed on a theme change, the regions' layer given to the viewer; the viewer itself stays made in app.js, which `createSessionView` reads first), `block_regions.js` (a renderer's regions cleaned, pure: [block-renderers.md](block-renderers.md#regions)), `region_hit.js` (their hit test, the arrow keys' nearest region and the reveal under the card, pure), `picture_regions.js` (the regions' layer over the viewer: below, Picture viewer), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
|
|
41
41
|
|
|
42
42
|
## One page, every viewer
|
|
43
43
|
|
|
@@ -60,13 +60,28 @@ their viewer (The viewer, below), their show and stream are filtered (`Web::Part
|
|
|
60
60
|
| **`store.current`** (`session_state.js`: `emptySessionState` / `sessionStateFrom`; per field: `session_fields.js FIELDS`) | the open session's fields, about 40 (info bar, chips, verdicts, timing, worker, stream cursor) | `store.update` / `setStatus` from app.js, `stream_handlers.js`, `session_sync.js`, `session_view.js`, `send_turn.js` (`firstPreview`, `owner`), `session_actions.js` (`status`), `owner_verify.js` (`verdicts`, `verifyFresh`); `forgetSession`'s `replaceCurrent` (`session_view.js`). Two writers in place, on purpose (D8 in `FIELDS`): live_timing.js's `activeTurn`, verdict_fresh.js's running list | the store runs the field's redraws (`FIELDS[key].redraws`) |
|
|
61
61
|
| **`store.sessions`** (the hub's projection) | every card | `store.update({sessions})` from app.js: `openSessionEvents` (`applySessionEvent`), `refresh` (the list fallback), `addCreatedSession`, `views.js applyView` (re-sorted), `replaceSelectedCard` (`setLiveStatus` through `setStatus`, `readTurnEnd`, `setUsedMemories`), the stream's close (`withoutWorker`); `session_actions.js` (`setSessions`) | the store: `lists` and `infoBar`. **Always a new array**; an entry is replaced, never changed in place. `followSelectedSession` copies the open one's owner and worker (`fieldsFromCard`) and, when not streaming, its status (`setStatus(…, "hub")`) into `store.current` |
|
|
62
62
|
| **Factory closures**: the `create*` factories (popovers, panels, views) | each component's own state: open-for, busy, error, its own fetched list | the factory | an `onChange` hook back into app.js, or a getter the factory reads at draw time |
|
|
63
|
-
| **The history DOM** | the conversation as drawn (a running turn's reason bubble, `.bubble.said`, is live only: see A turn opened in the history): which turn a bubble belongs to (`data-turn-id`, `data-answer-turn`), what opens a turn (`TURN_PROMPT`, `bubbles.js`: a prompt or a wake's note, the same turns `Steer.turn_opening?` counts for a card's `turns_since`), an opening's id for a card's and the saved recap's stamp (`data-turn-id` on a prompt, `data-opening-id` on a wake's note or `/continue no`'s reason line; `card_stamps.js` places a snapshot's card after the stamped opening, `recap_stamp.js` the saved recap after the last turn it covers, each by its count (`turns_since`) only without one), kept command bubbles, which texts were shown, unnamed badges, folded answers and long prompts (`.folded`), Revise stamps (`data-revises` on a prompt; a Verify turn's `data-verify`) and the stacks' folded versions (`.stack-hidden`, `.stack-stub.open`); the switcher's version on view is `revise_stack.js`'s own (a copy `.stack-view` before the top answer, the top `.stack-swapped`; never stored) | `bubbles.js`, `cards_place.js`, `question_cards.js`, `turn_block.js`/`stage_view.js`, `answer_fold.js`, `revise_stack.js`, `stream_handlers.js` (a live `turn_completed`'s `revises` and `verify` onto its prompt) | read back as state: `turn_range.js turnElements` (one walker for a turn's elements), `keptCommandBubbles`, `seedSeenFromDom`, `nameUnnamedBadges`/`nameVerdictCards`, `answer_fold.js` and `revise_stack.js` (their observers decorate every path that fills `#history`; the stacks are `stacks()` of the stamps, read again on each change, never a store field), `history_reveal.js revealInHistory` (the one way a jump unfolds what hides its target) |
|
|
63
|
+
| **The history DOM** | the conversation as drawn (a running turn's reason bubble, `.bubble.said`, is live only: see A turn opened in the history): which turn a bubble belongs to (`data-turn-id`, `data-answer-turn`), what opens a turn (`TURN_PROMPT`, `bubbles.js`: a prompt or a wake's note, the same turns `Steer.turn_opening?` counts for a card's `turns_since`), an opening's id for a card's and the saved recap's stamp (`data-turn-id` on a prompt, `data-opening-id` on a wake's note or `/continue no`'s reason line; `card_stamps.js` places a snapshot's card after the stamped opening, `recap_stamp.js` the saved recap after the last turn it covers, each by its count (`turns_since`) only without one), kept command bubbles, which texts were shown, unnamed badges, folded answers and long prompts (`.folded`), the notes rows over a stretch of background items (`.quiet-notes`, open by its `open` class, the items `.quiet-hidden`; never stored), Revise stamps (`data-revises` on a prompt; a Verify turn's `data-verify`) and the stacks' folded versions (`.stack-hidden`, `.stack-stub.open`); the switcher's version on view is `revise_stack.js`'s own (a copy `.stack-view` before the top answer, the top `.stack-swapped`; never stored) | `bubbles.js`, `cards_place.js`, `question_cards.js`, `turn_block.js`/`stage_view.js`, `answer_fold.js`, `quiet_notes.js`, `revise_stack.js`, `stream_handlers.js` (a live `turn_completed`'s `revises` and `verify` onto its prompt) | read back as state: `turn_range.js turnElements` (one walker for a turn's elements), `keptCommandBubbles`, `seedSeenFromDom`, `nameUnnamedBadges`/`nameVerdictCards`, `answer_fold.js`, `quiet_notes.js` and `revise_stack.js` (their observers decorate every path that fills `#history`; the stacks are `stacks()` of the stamps, read again on each change, never a store field), `history_reveal.js revealInHistory` (the one way a jump unfolds what hides its target) |
|
|
64
64
|
| **A drawn turn** (`turn_drawings` of the full read) | every finished turn, as live drew it: `turnGroups` groups by the stamps only, a turn's stamped items (`drawn: <turn_id>`) one group, and `turnHistoryNodes` draws it by feeding its drawing's events to a live turn block offscreen (`turn_block.js drawnTurnNodes`: the block's own handlers, as the stage's), the stage's extras (a reminder, merged lines, a card that waited when it arrived, an answered question) in the order live left them for the history (`turn_settle.js settleOrder`, pure: from the drawing's `part_settled` and question events, whether the turn was opened, and whether a question had a lead-in) and the end as live, then the answer, the merged lines and the steps' texts from their saved items (markdown, refs). Each of its top-level elements carries `data-drawn`: `cards_place.js` leaves that turn's in-turn CardStore entries (`of_turn`) to it, and a kept reminder bubble of that turn (`data-turn-id`) stays out after a resync. chi web sends a drawing for every finished turn (one made from its messages where live wrote none): `drawnGroup` pairs the record the end names (`end.record_id`, by place for a turn saved before turn ids), else by the turn's id, and the answer's `data-answer-turn` is the end's own `turn_id` only (a made-up id, `m…` or `…~N`, keys none: no Revise). Nothing is rebuilt from messages: an item that comes unstamped is a `plain` group drawn as a plain row of its text (its prompt or answer bubble, no steps), the running turn's as expected (`runningTurnId`, the show's `current_turn`: it has no line yet), any other a miss, marked `data-undrawn`, logged once per render (`console.warn`) and counted by the reload check (`undrawn`), never a throw; a drawing with no parts (a minimal line) draws its prompt, answer and end | chi web (the show) | `renderHistory`, the reload check's render |
|
|
65
65
|
| **The cards as data** (`card_registry.js`; app.js `cardRegistry`) | every question, continue offer and plugin card of the open session, keyed as `stage_waiting.js` keys them (`q:<id>`, `c:<id>`, `continue`): its kind and folded text (`card_kinds.js`), status (pending, answered, cancelled; resolved or dropped for the continue offer; asks or shown for a plugin card), `of_turn`, `opening_id`, step, `relayed_to` | `observeCards` around the stream handlers (outside the participant wrap: the page's handler first, then `apply`), so a read's replay feeds it too; `session_view.js renderSessionView` seeds it from the read right before the replay (`seed`: CardStore's listing, the pending question, the continue offer; it replaces), `forgetSession` resets it. Idempotent: a merge per key, a final status never back to pending, the first `of_turn`/`opening_id`/step kept, so seed then replay is what live holds. A question still pending at its turn's end is cancelled (the page cancels the card, no event comes) | an observer: nothing on the page draws from it; its one reader is the opt-in reload check (`reload_check.js`: this turn's entries against a registry seeded from a fresh read). `stage_cuts_parity.test.js` checks it against the stage's waiting cards at each cut, `card_registry.test.js` the events against each cut's seed and replay |
|
|
66
66
|
| **What was opened of a running turn** (`stage_view_memory.js`, in `session_view.js`) | per session, for this tab: the cloud open, the steps opened in it, the working set's reader on an item; a Map of at most 20 sessions, nothing stored or sent (the peek isn't kept: it closes with its popover) | `session_view.js leaveSession`, from `session_sync.js select` and from `forgetSession` itself for the session it drew last (so the start page, `clearSelection`, keeps it too) before its reset (`captureView`); dropped by `endTurnView` | `renderSessionView`, once the read is drawn: put back (`applyView`) only when the read's running turn (`current_turn.turn_id`) is the one saved; taken either way |
|
|
67
67
|
| **localStorage** (`storage.js` `readStored`/`writeStored`, guarded) | per-browser choices only; a session's view settings per session (`session_prefs.js`) | the module that owns the choice | read at start, a session's view settings again when its view is drawn (see Storage keys) |
|
|
68
68
|
| **SSE** | see Streams | the server | events go into the DOM directly (a participant's through `participant_main.js wrapHandlers` first) |
|
|
69
69
|
|
|
70
|
+
**The notes rows** (`quiet_notes.js`): what nobody says in the conversation folds, so a phone shows the prompt and
|
|
71
|
+
the answer, not the background under them. A stretch is a run of `#history` children that match `QUIET` (a
|
|
72
|
+
`.bubble.hook-notice` but the empty-answer line, a `.bubble.note` that is neither a wake's opening `.turn-start` nor a
|
|
73
|
+
`.peer-answer`, so objectives lines too, and a `.bubble.steer-row`); the `.turn-timing` line passes through it, and
|
|
74
|
+
anything else ends it (a prompt, an answer, a card, a peer's answer, a time divider, another fold's row). Each stretch
|
|
75
|
+
gets one `<button class="quiet-notes">` before its first item, closed, and its items get `.quiet-hidden`. The row is a
|
|
76
|
+
sibling tied to its first item (WeakMaps, as `answer_fold.js`'s), not a wrapper: the bubbles stay direct children of
|
|
77
|
+
`#history`, where every walker (`turn_range.js`, `cards_place.js`, the stage's hand-off, the reload check) and the
|
|
78
|
+
other observers expect them; a row something was placed after goes back before its item and keeps its open class.
|
|
79
|
+
A between-turn notice is placed after its turn, not below the next divider (`cards_place.js afterTurnEnd`). Its one
|
|
80
|
+
observer watches `#history`'s own children, and a settle writes only what changed (the copy, answer-fold,
|
|
81
|
+
Revise and objectives observers see class and subtree writes). `revise_stack.js historyTurns`, `history_shape.js
|
|
82
|
+
childItems` and `bubbles.js showRecap`'s walk skip the rows, and `history_reveal.js revealInHistory` opens one over a
|
|
83
|
+
jump's target.
|
|
84
|
+
|
|
70
85
|
The objectives' strip keeps the list in its own closure (`objectives_strip.js`, seeded by `renderSessionView`, reset by
|
|
71
86
|
`forgetSession`, updated by `objectives_updated`): [objectives.md](objectives.md#the-page).
|
|
72
87
|
|
|
@@ -263,7 +278,7 @@ gates are boot-time: a show's narrower `viewer` changes what `viewer.can` answer
|
|
|
263
278
|
| `block_renderers` | a bundle's drawn blocks (the core `chi-ui` drawer stays) | `/api/block_renderers*` |
|
|
264
279
|
| `stop_any_turn` | the stage's Stop turn (`onCancel`) | `POST …/cancel` |
|
|
265
280
|
| `steer_any_turn` | none: the delivery line reads a participant's own `steer_own_turn` instead (`viewerTurn`) | |
|
|
266
|
-
| `pages` | the
|
|
281
|
+
| `pages` | the pages pill (`#pagesBtn`), the Pages list (`#pagesList`, `pages_list.js`), the page view (`#pageView`, `page_view.js`), the `#/p/` link handler (`page_links.js`), all made by `pages_wiring.js`; without it `#/pages` and a `#/p/…` hash are no view | `GET /api/pages` (once at boot, then when the list, All sessions or a page opens, after a Delete, on the hub's `pages` event and a reconnect's snapshot), `GET /api/pages/:name` (a page opened), `POST …/run` (Refresh), `DELETE /api/pages/:name` |
|
|
267
282
|
|
|
268
283
|
A participant's `can` (`Viewer::PARTICIPANT_CAPABILITIES`, in their show's `viewer` and on `<body>`) names
|
|
269
284
|
capabilities of their own, not the owner's: `send` (the composer), `stop_own_turn` (Stop turn on a turn they
|
|
@@ -836,39 +851,45 @@ rendered slice (no `.read-line` in it).
|
|
|
836
851
|
## The peer exchange
|
|
837
852
|
|
|
838
853
|
A send to a paired peer (claude-peer's `claude_send`, codex-peer's) and the peer's answer, linked in the owner's
|
|
839
|
-
conversation ([bundles.md](../bundles.md#the-claude-peer-bundle), In the web
|
|
840
|
-
/api/sessions/:id/peers` (owner only, read from the session's files:
|
|
841
|
-
|
|
842
|
-
`
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
854
|
+
conversation ([bundles.md](../bundles.md#the-claude-peer-bundle), In the web; the store: [peers.md](peers.md)). The
|
|
855
|
+
data is the server's: `GET /api/sessions/:id/peers` (owner only, read from the session's files without a worker: the
|
|
856
|
+
mailbox, the receipts and `PeerExchanges.joined` over `peer_exchanges.jsonl`) gives each peer with a mailbox folder,
|
|
857
|
+
its pairing (`paired_at`, `address`, `can_send`), its newest messages with their receipts and the receipt's words
|
|
858
|
+
(`words`: "held · peer turns"), and its last exchanges, newest first, with their `state` (waiting, answered,
|
|
859
|
+
none_expected, failed) and an answer's `serial` and `verdict`; a send row carries the send's id as its `peer` ref, a
|
|
860
|
+
peer's message note its `peer` hash (`peer`, `label`, `re`, `summary`, `serial`, `verdict`, `agreed`, `box` for a
|
|
861
|
+
mailbox message, and `inline` when the note's content holds the peer's text). The page joins nothing; the one parse is
|
|
862
|
+
`peer_text.js`'s cut of an `inline` note's text block.
|
|
846
863
|
|
|
847
864
|
- `peer_data.js` (state): `listPeers` (an older chi web's 404 is an empty list) and `createPeers`, the page's one model
|
|
848
865
|
of the open session's peers (app.js `peers`, made only with the `context` capability, so a participant's page has
|
|
849
866
|
none): its own closure holds the last read for the open session (`createLatest`: an older read, or one for a
|
|
850
|
-
session left, is dropped); `exchange(id)` (the newest of an id: each send has its own, but an older chi's resend shared one), `answer(name, serial, re)`. It
|
|
851
|
-
|
|
867
|
+
session left, is dropped); `exchange(id)` (the newest of an id: each send has its own, but an older chi's resend shared one), `answer(name, serial, re)`, `peers()`. It
|
|
868
|
+
is the peer chip's only feed, so the page reads it for every session it opens (`hasPeer: () => true`).
|
|
852
869
|
Read again on: the session drawn (`session_view.js renderSessionView`, through `peerLinks.drawn()`), a
|
|
853
870
|
`context_added` with `peer`, a `tool_call_completed` with a peer ref, `command_ran` (a `/claude validate`), window
|
|
854
871
|
focus, and a 60 s tick while an exchange waits; a `turn_completed` redraws without a fetch (`touch()`) (one interval, cleared with the session: `forgetSession` →
|
|
855
872
|
`peerLinks.reset()`). The peer chips read the same model: its `onChange` also calls `contextChips.peersChanged()`, and
|
|
856
|
-
the chips' own load (a session opened
|
|
857
|
-
|
|
873
|
+
the chips' own load (a session opened) calls `peers.refresh({ reuse: true })`. A pairing made from the peer's side
|
|
874
|
+
sends the page nothing: the chip appears at the next read (a focus, a peer note, a send).
|
|
875
|
+
- `peer_mailbox_api.js` (state): `getPeerMessage(id, name, serial)` (a message's text: View latest answer, a
|
|
876
|
+
mailbox note's "Read the full answer") and `unpairPeer(id, name)` (`DELETE …/peers/NAME`).
|
|
858
877
|
- `peer_exchange.js` (pure): `peerRef(row)`, `stateText` (long and the phone's short words, both drawn; CSS picks),
|
|
859
878
|
`pillTemplate` (a button with ↓ once answered, a span otherwise; its title the row's output text).
|
|
860
879
|
- `peer_note.js`: `peerNoteTemplate`, which `turn_html.js noteBubbleTemplate` draws a note with `peer` as. It keeps
|
|
861
880
|
what an opening note has (`bubble note`, `turn-start`, `data-opening-id`, the time title), so `TURN_PROMPT`,
|
|
862
881
|
`card_stamps.js`, `stage_handoff.js OPENING`, `reload_check.js` and `revise_stack.js` (its `.note-text` is the
|
|
863
|
-
summary) read it as any wake note.
|
|
882
|
+
summary) read it as any wake note. A live `context_added` wake note carries `turn_start`/`turn_id`, so live and reload
|
|
883
|
+
agree on its opening. With `peer.inline` the peer's text goes in `.peer-text` under the summary (an
|
|
864
884
|
element of its own, not a `data-peer-slot`, its source in `data-peer-md`): already as markdown when a history
|
|
865
|
-
read sent the note's `peer_html` (`MessageDisplay#peer_text_html`, `
|
|
885
|
+
read sent the note's `peer_html` (`MessageDisplay#peer_text_html`, `PeerNote.text_of`, rendered and
|
|
866
886
|
sanitized as an answer is), else as plain text (a live `context_added`, an older server), the "what chi told the
|
|
867
887
|
agent" fold shows the content without the block, and the bubble carries `data-peer-inline`. Without it (an older
|
|
868
|
-
session,
|
|
888
|
+
session, a message over the cap) the bubble draws as before. A mailbox message's note (its hash has `box`) carries
|
|
889
|
+
`data-peer-box` and no source; an older context answer's keeps its `<peer>-outbox` source as `data-peer-source`.
|
|
869
890
|
- `peer_text.js` (pure): `peerBlock(content)` cuts the text out between the first `[PEER MESSAGE from …]` line and the
|
|
870
|
-
last `[END PEER MESSAGE]` line and undoes the
|
|
871
|
-
(`PEER_FORGED_OPENINGS` and `PEER_FORGED_LINES`, the Ruby `
|
|
891
|
+
last `[END PEER MESSAGE]` line and undoes the `PeerNote.block` mark on forged frame lines
|
|
892
|
+
(`PEER_FORGED_OPENINGS` and `PEER_FORGED_LINES`, the Ruby `PeerNote::FORGED_OPENINGS` and `FORGED_LINES`, and the same line breaks and leads
|
|
872
893
|
as `Steer::FORGED_BREAKS` / `FORGED_LEAD`: `peer_text.test.js` keeps the lists alike and undoes the Ruby specs' cases);
|
|
873
894
|
null without a block.
|
|
874
895
|
- **The slot idiom.** Finished rows are never drawn again and a reload makes them anew, so what arrives later is
|
|
@@ -881,30 +902,33 @@ parse is `peer_text.js`'s cut of an `inline` note's text block.
|
|
|
881
902
|
sent" when its row failed, or once its turn has ended when its peer's list is under the server's cap of 20
|
|
882
903
|
(`EXCHANGES_CAP`) or holds a send drawn before it; else it is unknown and gets no pill, as are the sends of a peer
|
|
883
904
|
the read doesn't name), the ↑ into each answer (none for an answer no send claims) and "Read the full
|
|
884
|
-
answer" into
|
|
905
|
+
answer" into each mailbox message, and into the last of an older pairing's answers of each source, unless that
|
|
906
|
+
bubble is `data-peer-inline` (its text is there). It
|
|
885
907
|
also swaps a plain inline bubble's `.peer-text` (not `.markdown`: one that came with `peer_html` asks nothing) for
|
|
886
908
|
its markdown (`renderMarkdown`, POST /api/render, sanitized there; an
|
|
887
909
|
optional factory dep, so a cached older app.js leaves the text plain), once per element; `history_shape.js` reads a
|
|
888
910
|
`[data-peer-md]` element as its source, so live and an offscreen reload compare alike. Its one delegated click handler on the turn roots does the jumps,
|
|
889
911
|
buttons, never an `href` (the page routes by its hash): ↓ `revealInHistory` + `scrollIntoView` on the answer; ↑
|
|
890
912
|
`refs.js showRow` on the last row of that id before the answer (its `ref:reveal` opens a folded step or the stage's
|
|
891
|
-
cloud); focus moves to the target (`tabindex="-1"`). "Read the full answer" calls `context_chips.js
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
chip, the first state that applies: answers only (
|
|
898
|
-
`
|
|
899
|
-
newest validate/question `waiting`, its age the send's), answered
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
and
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
the
|
|
913
|
+
cloud); focus moves to the target (`tabindex="-1"`). "Read the full answer" calls `context_chips.js
|
|
914
|
+
showMessage(name, serial)` for a mailbox message (its peer chip's popover on that message's text) or
|
|
915
|
+
`showText(source)` for an older answer (that source's own chip), in a task of its own (the click's way to the
|
|
916
|
+
document would close it).
|
|
917
|
+
- `peer_chip.js` (pure): a paired peer in the session bar. `peerGroups(peers)` gives one group per peer of the
|
|
918
|
+
model that is paired (`paired_at`; an unpaired one keeps its messages but has no chip): `{key: "peer:<name>", name,
|
|
919
|
+
label, peer}`. `peerChipModel` is the chip, the first state that applies: answers only (`can_send` false: a pairing
|
|
920
|
+
with no address), can't send (the newest send `failed` and the pairing not renewed since, `paired_at` past the failed
|
|
921
|
+
send's time ends it, `cantSend`), waiting (the newest validate/question `waiting`, its age the send's), answered
|
|
922
|
+
(its newest message unread: no receipt, `held` or `noted`; with the dot), paired. A peer the read doesn't name, an
|
|
923
|
+
older chi web or a send not in the list is never "can't send": only the server's `failed` is. `peerPopoverTemplate`
|
|
924
|
+
is its popover (scene 2 of the design): where chi sends (the address), how it answers, the last 8 exchanges (sends,
|
|
925
|
+
and messages no send claims as `#N · summary`) with `exchangeState`'s words and the answer's receipt words, View
|
|
926
|
+
latest answer, Status card (`peerStatusCommand`: `/<name>` when the session lists it) and Unpair.
|
|
927
|
+
`context_chips.js` draws it: its chips are keyed (`data-name`: a source's name, a peer's `peer:<name>`), peer chips
|
|
928
|
+
first; context rows are never grouped (a `claude-outbox` source is an ordinary chip); an open popover stays while its
|
|
929
|
+
key is among the drawn chips; View latest answer reads the newest message (`api.message`), Unpair confirms once,
|
|
930
|
+
`DELETE`s the pairing and reads the peers again (the chip goes; a failure names itself in a toast); after a detach
|
|
931
|
+
or Unpair that took the focused chip, focus goes to the strip's first chip, else the composer (`focusAway`); an
|
|
908
932
|
exchange row is a button only when its send's row is drawn (`peerLinks.hasSend`) and jumps there
|
|
909
933
|
(`peerLinks.showSend`) after closing the popover. Under 600 px the peer popover is a bottom sheet (`sheetPlace`);
|
|
910
934
|
ordinary chips' popovers stay at their chip.
|
|
@@ -941,7 +965,7 @@ uses `latest.js`.
|
|
|
941
965
|
|
|
942
966
|
| Stream | Opened by | Lifecycle |
|
|
943
967
|
|---|---|---|
|
|
944
|
-
| The hub, `GET /api/events` (`data.js openEvents`) | app.js `openSessionEvents` (scoped by `?dir`) | `snapshot` then `session` / `session_gone` → `applySessionEvent` → `allSessions`; EventSource reconnects itself (a fresh snapshot); `onClosed` (a proxy sign-in on reconnect): probe, reopen after `EVENTS_REOPEN_MS` |
|
|
968
|
+
| The hub, `GET /api/events` (`data.js openEvents`) | app.js `openSessionEvents` (scoped by `?dir`) | `snapshot` then `session` / `session_gone` → `applySessionEvent` → `allSessions`; `pages` (and every snapshot after the first) → `pages_wiring.js` reads the list of pages again; EventSource reconnects itself (a fresh snapshot); `onClosed` (a proxy sign-in on reconnect): probe, reopen after `EVENTS_REOPEN_MS` |
|
|
945
969
|
| A second hub stream, unscoped | `notifications.js` (`allEvents`) on a project's page | the Home Screen app's device tidy-up across projects |
|
|
946
970
|
| The open session, `GET /api/sessions/:id/stream?from_seq=` (`data.js openStream`) | `session_sync.js` `startStream` from `store.current.streamSeq` | events → `stream_handlers.js`. It closes itself on an error; the page resyncs (`resync`: a fresh render and a new stream from its cursor), once at once when it had opened, else after `STREAM_RETRY_MS`. Meanwhile a turn the stage holds reads "reconnecting…" (Quiet, under Frames), and the Bridge's `: ping` is invisible to the page. A re-read that can't reach chi web keeps the history it drew (`resync_reach.js`): the session bar's status chip says "retrying" while `retryResync` tries, "offline" once the tries ran out (`store.current.reach`; short words that fit the chip's reserved width, the full words in its tooltip), but only while no turn runs: during a turn the stage's "reconnecting…" is the one signal (on a phone the bar can hide its status) and the chip keeps the turn's word, and any hub event for the session then re-reads it (`followSelectedSession`); the next drawn re-read clears it. Only a first load (select's "Loading…") shows the error in the history |
|
|
947
971
|
|
data/docs/internals/web-push.md
CHANGED
|
@@ -149,7 +149,7 @@ the top and in `pending_question` / `pending_card`, strings in `last_turn`), `no
|
|
|
149
149
|
3. a top-level turn whose `last_turn["ended_at"]` changed (a delegated child's is its parent's to report):
|
|
150
150
|
a newly recorded verdict is `verdict`, keyed by `"<sid>:<check_turn_id>"`; otherwise `failed`, or `done` when
|
|
151
151
|
`completed` and `seconds` ≥ `DONE_MIN_SECONDS` 10 or its origin is in `UNWATCHED_ORIGINS`
|
|
152
|
-
(`delegate_report`, `context`, `task`), keyed by `"<sid>:<ended_at>"`. A verdict wins over the done/no-event
|
|
152
|
+
(`delegate_report`, `context`, `task`, `peer`: a peer's message's wake turn), keyed by `"<sid>:<ended_at>"`. A verdict wins over the done/no-event
|
|
153
153
|
rule, including for a short turn. A reminder turn follows the same rules (no reminder event of its own).
|
|
154
154
|
- `WAITING` (approval, question, continue, card) are the reasons that stay open until answered: badged, in `open`,
|
|
155
155
|
cleaned up, and pushed only while still open. A failed, done or verdict turn has nothing to answer.
|
|
@@ -186,16 +186,22 @@ from saying it twice across restarts). The key's `chi:` prefix keeps sw.js from
|
|
|
186
186
|
| `updated` | `chi:updated:<X>` | "chi updated to X" / "chi web and 3 sessions restarted; 1 restarts when idle." + the edited files |
|
|
187
187
|
| `restart_failed` | `chi:restart_failed:<X>` | "chi X is installed; chi web didn't restart" / why (a failed `--version` preflight, no wrapper), "Restart chi web in its terminal." |
|
|
188
188
|
|
|
189
|
-
**A disabled schedule's show.** `
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
**A disabled schedule's show.** Any ticker (chi web's, a cron `chi schedule tick`, a `run-now`) that turns a
|
|
190
|
+
recurring schedule off by its budget leaves a `disabled_notice` on its entry (`Schedules#skipped` / `#failed`,
|
|
191
|
+
under the rule `#mark_disabled` shares). The hub claims them with `Schedules#claim_disabled_notices` (a lock-free
|
|
192
|
+
read, then a non-blocking lock that clears each notice before it is emitted: at most once, and once across two chi
|
|
193
|
+
webs, since `@updates_seen` is per process) right after its own tick in `#run_schedule_tick` and once per
|
|
194
|
+
`schedule.tick_interval_minutes` from `#schedule_tick`, auto_tick off too, but never from the seeding
|
|
195
|
+
`scan(tick: false)`, which runs before the Notifier subscribes. `#publish_disabled` emits one `schedule_disabled`
|
|
196
|
+
hub event per claimed notice (under `@monitor` like `publish_notice`): `{id, title, kind: skipped|failed, count,
|
|
197
|
+
reason, session_id, at}`, `session_id` being the resolved target at claim time, else the head, and `at` the
|
|
198
|
+
disabling tick's time. A notice older than a day or whose entry is on again is cleared unpushed. The page's event stream passes it to the tabs, which have no
|
|
193
199
|
listener. The Notifier shows it with reason `schedule`, key and tag `chi:schedule_disabled:<id>:<at>` (`chi:`: not
|
|
194
200
|
a waiting key; `<at>`: a later disable shows again; the same event twice shows once, `@updates_seen`), title
|
|
195
201
|
"Schedule disabled: <title or the id's first 8>", body "skipped 12 times: <reason>" + a line `chi schedule enable
|
|
196
202
|
<short id>`, url `Notifier.session_url` of the session's summary, `/` when it has none. Two exceptions to the rules
|
|
197
203
|
above: it is pushed with a page in front (`UNSEEN_ON_PAGE`: the page has no schedules view), and it gets
|
|
198
|
-
`UPDATE_TTL` (24 h) like an update.
|
|
204
|
+
`UPDATE_TTL` (24 h) like an update. With no chi web running, a cron tick's notice waits in `schedules.json`.
|
|
199
205
|
|
|
200
206
|
`updated` is sent by the **restarted** chi web (its AutoUpdate finds the run at `phase: web`): the exec ends the
|
|
201
207
|
old process, and `Notifier#stop` does not flush the shows still in their hold, so a push queued just before it would
|
data/docs/memory.md
CHANGED
|
@@ -439,7 +439,7 @@ It is a memory like any other: `memory_read`, `chi --mute skill_release`,
|
|
|
439
439
|
skills`, [docs/bundles.md](bundles.md#the-skills-bundle)) adds `/skill save`,
|
|
440
440
|
`/skill list`, `/skill show`, `/skill diff`, keeps older versions with a
|
|
441
441
|
one-line diff after each update, and nudges a model that skips a failing
|
|
442
|
-
step instead of fixing the skill.
|
|
442
|
+
step instead of fixing the skill; a skill a bundle ships is skipped.
|
|
443
443
|
|
|
444
444
|
chi ships one skill itself: `skill_pages` in the system bundle
|
|
445
445
|
(`lib/samagotchi/bundles/system/skill_pages.md`), how to make, check and link a
|
data/docs/pages.md
CHANGED
|
@@ -14,7 +14,7 @@ Say what you want to see and that you want it kept: "make me a page of …", "I'
|
|
|
14
14
|
"keep this as a page". chi follows its shipped pages skill (`skill_pages`, [docs/memory.md](memory.md#skills)): it
|
|
15
15
|
finds the pages folder with `chi self`, writes `NAME.rb` there, runs `chi page run NAME`, compares the stored rows
|
|
16
16
|
with where they came from, fixes what failed, and answers in a line or two with the link `[Title](#/p/NAME)` (with
|
|
17
|
-
Markdown off, the link is plain text: the page is in
|
|
17
|
+
Markdown off, the link is plain text: the page is under the `pages` pill in chi web's top bar). "Change the page …" edits the script
|
|
18
18
|
and runs it again; "remove the page …" is `chi page rm NAME`.
|
|
19
19
|
|
|
20
20
|
- It uses `chi page list`, the read tool, `chi page run` and `chi page rm`, never a shell command that names the pages
|
|
@@ -77,6 +77,50 @@ the script adds them, at most 20.
|
|
|
77
77
|
A rule broken fails the run with a message naming the block and the limit: `table 2: column "cost" has format
|
|
78
78
|
:percent (use :money or :count)`, `table 1 has 13 columns (at most 12)`.
|
|
79
79
|
|
|
80
|
+
## Reading chi's data: `runtime`
|
|
81
|
+
|
|
82
|
+
From chi 0.189.0 a script has **`runtime`** next to `page`: what chi itself knows, read in the page's own process
|
|
83
|
+
from this chi's code (no `chi` on `PATH`, no second boot, nothing changed). A page that never calls it loads none of
|
|
84
|
+
it. On an older chi `runtime` is a `NameError`, and the run fails with it (the last good result kept).
|
|
85
|
+
|
|
86
|
+
- **`runtime.schedules`**: every durable schedule ([scheduling.md](scheduling.md)), the earliest due first. Each has
|
|
87
|
+
the keys `chi schedule list --all --format json` gives a schedule as methods: `id`, `name` (its title, or the start
|
|
88
|
+
of its prompt in quotes), `title`, `mode`, `prompt`, `recurrence_words`, `next_due`, `last_fired`, `last_result`,
|
|
89
|
+
`enabled`, `state` (`on`, `firing` or `off`), `off_reason` (`owner`, `skips`, `failures`, `done`, `missed` or
|
|
90
|
+
`off`; nil unless off), `skips`, `max_skips`, `failures`, `max_failures`, `skip_window`, `anchor`, `head`,
|
|
91
|
+
`created_at`, and `history`: its runs, oldest first, each with `at`, `status`, `detail` and `session_id`. Times are
|
|
92
|
+
ISO 8601 UTC strings, nil when there is none.
|
|
93
|
+
- `runtime.schedules.rows`: every schedule as a table row (all but `history`): `ui.table runtime.schedules.rows,
|
|
94
|
+
columns: { "name" => "Name", "state" => "State" }`.
|
|
95
|
+
- `.warning`: `chi schedule list`'s warning when nothing ticks the schedules, else nil; `.unreadable_ids`: the id of
|
|
96
|
+
each entry of `schedules.json` that doesn't read (nil for one with no id).
|
|
97
|
+
- A `schedules.json` that isn't JSON fails the run with the store's own words (`… is not readable JSON …: fix or
|
|
98
|
+
remove it before changing schedules`). The read takes no lock and writes nothing, though chi's debug log may get a
|
|
99
|
+
line for an entry that doesn't read.
|
|
100
|
+
|
|
101
|
+
`runtime`, like the rest of the page script DSL, is stable for bundles ([plugins.md](plugins.md#stable-for-bundles)).
|
|
102
|
+
|
|
103
|
+
## Pages from a bundle
|
|
104
|
+
|
|
105
|
+
A bundle can ship pages: its manifest's `pages:` names scripts in its `scripts/` ([plugins.md](plugins.md)), each
|
|
106
|
+
`NAME.rb` the page `NAME`. The shipped **schedules** bundle is one: `chi bundle install schedules` adds a
|
|
107
|
+
**Schedules** page ([scheduling.md](scheduling.md#the-schedules-page)).
|
|
108
|
+
|
|
109
|
+
- A bundle's page is listed and runs as yours does (`chi page list` says `schedules bundle`; its JSON carries
|
|
110
|
+
`bundle` and `script`, the path of the script it runs). It shows in chi web after the next list read (a reload, or
|
|
111
|
+
opening the Pages list): an install isn't watched.
|
|
112
|
+
- **Your own `NAME.rb` replaces it**: with `~/.config/samagotchi/pages/schedules.rb` there, that script runs. That is
|
|
113
|
+
how a bundle's page is made your own: copy its script (`script` in `chi page list --format json`) there and change
|
|
114
|
+
it. Removing your copy brings the bundle's page back, as never ran.
|
|
115
|
+
- **It can't be removed**: `chi page rm schedules` exits 1 with `page schedules comes with the schedules bundle:
|
|
116
|
+
uninstall the bundle or write your own ~/.config/samagotchi/pages/schedules.rb`, and chi web has no Delete for it.
|
|
117
|
+
Uninstalling the bundle takes the page away (its stored result stays on disk, unused).
|
|
118
|
+
- A bundle's page lasts as its installed `manifest.yml` does: one edited since lists no page (chi's debug log says
|
|
119
|
+
`bundle_pages_unread`; `chi bundle status NAME` says the file is edited): reinstall the bundle.
|
|
120
|
+
- A bundle's script runs only as installed: one edited since (or missing) runs nothing, and the run fails with
|
|
121
|
+
`bundle schedules's scripts/schedules.rb differs from the installed one (reinstall the bundle)`.
|
|
122
|
+
- When a chi upgrade changes a bundle's script, the page says "The script changed" until a Refresh.
|
|
123
|
+
|
|
80
124
|
## Running
|
|
81
125
|
|
|
82
126
|
- `chi page run NAME` runs the script in a Ruby process of its own and prints a summary of each block: a text's first
|
|
@@ -84,27 +128,33 @@ A rule broken fails the run with a message naming the block and the limit: `tabl
|
|
|
84
128
|
- A run that fails (the script raised, has a syntax error, called `exit`, broke a limit, or printed more than 256 KB of
|
|
85
129
|
blocks) prints `error: line 9: undefined method 'fetch' for nil`, the last lines of what the script wrote to stderr,
|
|
86
130
|
and exits 1. **The result of the last good run is kept**: a bad edit never blanks the page.
|
|
87
|
-
- A run still going at **30 s** is stopped, with everything it started; the error says so.
|
|
131
|
+
- A run still going at **30 s** is stopped, with everything it started; the error says so. One that finished just as
|
|
132
|
+
the cut fires keeps its result. If what started the run
|
|
88
133
|
dies first (a killed terminal or chi web), the run stops itself a few seconds after its 30 s and records the same
|
|
89
134
|
error. Its output then has nowhere to go: a script that prints a lot may fail with `Broken pipe` instead (the last
|
|
90
135
|
good result is kept).
|
|
91
136
|
- One run of a page at a time: a second `chi page run usage` meanwhile exits 1 with `page usage is already running`.
|
|
92
137
|
- `chi page list` shows each page's title and `ran 2 min ago`, `failed 1 h ago (line 9)` or `(never ran)`, with
|
|
93
|
-
`changed` when the script changed since its result was made (the result came from an older script; nothing ran)
|
|
138
|
+
`changed` when the script changed since its result was made (the result came from an older script; nothing ran),
|
|
139
|
+
and the bundle a page comes with. `chi page rm NAME` removes the script and its result (a bundle's page can't be
|
|
140
|
+
removed: [Pages from a bundle](#pages-from-a-bundle)).
|
|
94
141
|
|
|
95
142
|
Exit codes: 0 ran, 1 failed (or no such page, or already running), 2 the command line itself (an unknown flag, a name
|
|
96
143
|
that breaks the rule). See [the CLI](cli.md#commands).
|
|
97
144
|
|
|
98
145
|
## In chi web
|
|
99
146
|
|
|
100
|
-
- **Finding a page.**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
147
|
+
- **Finding a page.** The top bar has a **`pages`** pill as soon as there is a page, in every view and project scope
|
|
148
|
+
(pages are global), on a desktop and a phone alike; with no page it isn't there. It opens the **Pages list**
|
|
149
|
+
(`#/pages`), in place of the session area: a card per page, each with the page's title and `ran 2 min ago`,
|
|
150
|
+
`failed 1 h ago` or `never ran`; a tap opens the page. The pill appears without a reload when chi makes the first
|
|
151
|
+
page (chi web watches the pages folder), and goes when the last one is removed. A `#/p/usage` link in chi's answer
|
|
152
|
+
opens the page in the same tab; a reload or a copied `…/#/p/usage` link opens it too.
|
|
153
|
+
- **The page** shows in place of the session area: Back (to where it was opened from: "Pages" from the list, "Back"
|
|
154
|
+
from an answer's link; with nowhere to go back to, the Pages list), the title,
|
|
106
155
|
when it ran and how long it took, **Refresh** and `⋯` with Delete (it asks once, then removes the script and its
|
|
107
|
-
result). Opening it shows the stored result at once and runs
|
|
156
|
+
result, then shows the Pages list; a bundle's page has no `⋯`). Opening it shows the stored result at once and runs
|
|
157
|
+
nothing.
|
|
108
158
|
- **Refresh** runs the script as `chi page run` does and redraws when the run ends; the button reads "Running…" and
|
|
109
159
|
can't be pressed twice. A run already going (from a terminal, another tab) says "already running". Stopping chi web
|
|
110
160
|
stops a Refresh. A Refresh holds its request until the run ends, up to about 32 s (the 30 s cut and its grace): behind
|
|
@@ -118,12 +168,15 @@ that breaks the rule). See [the CLI](cli.md#commands).
|
|
|
118
168
|
a tap opens the rest as label and value lines; rows keep the script's order there.
|
|
119
169
|
- **A walk** is drawn by the same widget as in an answer; its lanes scroll sideways inside it.
|
|
120
170
|
- **Markdown off** (`web.markdown`, the default): a text block shows as plain text, and a link in chi's answer is plain
|
|
121
|
-
text too, so the
|
|
171
|
+
text too, so the `pages` pill is the way in. A fenced block inside a text block (a `chi-ui` or a mermaid one) stays
|
|
122
172
|
source on a page.
|
|
123
|
-
- **
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
173
|
+
- **What is live**: the list (and with it the pill) is read when chi web opens, when the Pages list, All sessions or a
|
|
174
|
+
page opens, after a Delete, and when a page script is made or removed (a script that writes a file into the pages
|
|
175
|
+
folder, which is its working folder, counts too: each of its runs refreshes the open lists). A page itself is read when it opens and
|
|
176
|
+
after its own Refresh; a run from a terminal shows after the next open or a reload (a first run's "ran" time on the
|
|
177
|
+
list too).
|
|
178
|
+
- Pages are the owner's: a participant ([chi share](cli.md)) sees no `pages` pill, no Pages list, no page, and no page
|
|
179
|
+
route answers their link.
|
|
127
180
|
|
|
128
181
|
## Where a run happens
|
|
129
182
|
|
|
@@ -144,7 +197,8 @@ that breaks the rule). See [the CLI](cli.md#commands).
|
|
|
144
197
|
|
|
145
198
|
## Where things are stored
|
|
146
199
|
|
|
147
|
-
- The script: `~/.config/samagotchi/pages/NAME.rb
|
|
200
|
+
- The script: `~/.config/samagotchi/pages/NAME.rb`; a bundle's in the bundle's own `scripts/` folder under the system
|
|
201
|
+
memories (`.bundles/NAME/scripts/`).
|
|
148
202
|
- The result: `~/.local/state/samagotchi/pages/NAME/output.json` (`$XDG_STATE_HOME`): the title, the blocks of the last
|
|
149
203
|
good run, when it ran, how long it took, the sha256 of the script that made it, and the last failure since, if any.
|
|
150
204
|
Its shape is in [internals/pages.md](internals/pages.md).
|
data/docs/peers.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Peers: another agent beside chi
|
|
2
|
+
|
|
3
|
+
A **peer** is another agent's session the user works with beside chi: a Claude Code session (the claude-peer
|
|
4
|
+
bundle) or a Codex CLI session (codex-peer). chi sends it a part of its work (`claude_send`, `/claude validate`),
|
|
5
|
+
and the peer answers into chi. Each answer is a **message** in the session's **mailbox**: its own note in the
|
|
6
|
+
conversation, in order, with its text. chi says what it did with each one, on the peer's terminal and in the
|
|
7
|
+
peer chip. How it is built: [internals/peers.md](internals/peers.md).
|
|
8
|
+
|
|
9
|
+
## Pairing
|
|
10
|
+
|
|
11
|
+
The peer pairs from its side, with its `chi-peer` skill (`/claude install-skill` or `/codex install-skill`
|
|
12
|
+
installs it). Its pair script runs one command:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
chi peer pair claude <session id> --address <where chi sends> --from "<who paired>"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- `--address` is where chi's sends go: Claude Code's inbox socket, Codex's thread id. A pairing without one
|
|
19
|
+
answers only: the peer can say, chi can't send to it (a peer on another machine with no forwarded socket).
|
|
20
|
+
- Pairing again only replaces the address (a Claude Code restart gives it a new socket).
|
|
21
|
+
- `chi peer unpair claude <id>` ends the pairing. Its messages stay, and chi still reads those it hasn't. The
|
|
22
|
+
peer chip's **Unpair** does the same.
|
|
23
|
+
- `chi peer pair` refuses a session whose live worker is older than the mailbox ("restart the session"), and a
|
|
24
|
+
session that was continued (it names the new id).
|
|
25
|
+
|
|
26
|
+
Which agents are peers is the bundles' to say (`chi.peer NAME` in plugin code), never a file's. A message from
|
|
27
|
+
a name no loaded bundle declared is refused with "no bundle in that session declares peer NAME".
|
|
28
|
+
|
|
29
|
+
## Saying something: `chi peer say`
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
chi peer say claude <id> --wake --re s-ab12cd --summary "validate step 2: VERDICT CHANGES, 2 issues" --wait 8 <<'EOF'
|
|
33
|
+
<the full answer>
|
|
34
|
+
EOF
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- `--wake` or `--nowake` is required: `--wake` asks chi to run a turn for it (a validate's answer, a question's,
|
|
38
|
+
a message chi should act on now); `--nowake` leaves it as a note for chi's next turn.
|
|
39
|
+
- `--re` names the send it answers (the `ref:` line of chi's message); leave it out for a message the peer starts.
|
|
40
|
+
- `--summary` is one line (200 characters); the text is stdin, or `-m TEXT`, up to 1 MiB.
|
|
41
|
+
- `--wait SECONDS` (0 to 30) waits for chi's answer; the skills use 8.
|
|
42
|
+
|
|
43
|
+
It prints one line, which the skills tell the agent to quote to its user:
|
|
44
|
+
|
|
45
|
+
| What chi did | The line |
|
|
46
|
+
|---|---|
|
|
47
|
+
| started a turn | `#12 received · woke chi` |
|
|
48
|
+
| held it | `#12 received · held: 3 peer turns in a row (peer.turns) · waits for the user's next message` |
|
|
49
|
+
| took it as background | `#12 received · noted` |
|
|
50
|
+
| can't say yet | `#12 received · chi is in a turn: it reads this when the turn ends`, `chi is stopped: …`, `this session is archived: …`, `chi's worker isn't running and couldn't be started from here: …` |
|
|
51
|
+
| nothing within the wait | `#12 received · no answer from chi yet` |
|
|
52
|
+
| refused | `refused: no bundle in that session declares peer claude` (exit 1) |
|
|
53
|
+
|
|
54
|
+
Other messages of the same peer held and unread follow: `· also held: #10, #11 (paused)`. A held message is not
|
|
55
|
+
lost: it is a note, and the user's next message lets chi read it. The skills say not to send it again, and not to
|
|
56
|
+
`chi send` past it.
|
|
57
|
+
|
|
58
|
+
A say is refused, with nothing written, for: no such session; a session being deleted; a continued one (`this
|
|
59
|
+
session was continued as <id>: say it there`); not paired (`not paired: run the pair script`); an older worker
|
|
60
|
+
(`restart the session`); 200 messages chi hasn't read yet.
|
|
61
|
+
|
|
62
|
+
Through `--remote NAME` (or `CHI_REMOTE`) the remote's chi web does the say and the wait, and returns the line.
|
|
63
|
+
|
|
64
|
+
## What chi does with a message: the receipts
|
|
65
|
+
|
|
66
|
+
The worker takes the peer's messages in order, between turns, and writes one receipt per message:
|
|
67
|
+
|
|
68
|
+
- `woke` (a turn started for it), `held` with a reason, `noted` (it asked for no turn), `refused`;
|
|
69
|
+
- then `read` once a turn starts with it in the conversation, and `completed`, `failed` or `stopped` when that
|
|
70
|
+
turn ends.
|
|
71
|
+
|
|
72
|
+
Held reasons: `off` (`peer.turns` is 0), `paused` (after a failed wake turn), `continue` (a continue offer waits),
|
|
73
|
+
`max_wakes`, `peer turns`, `queued`, `exit`, `leaving`, `before a turn`.
|
|
74
|
+
|
|
75
|
+
`chi peer ls <id>` lists each peer, its pairing and its newest messages with their receipts; the peer chip's list
|
|
76
|
+
shows the same words (`held · peer turns`, `read`, `completed`).
|
|
77
|
+
|
|
78
|
+
## The budget: `peer.turns`
|
|
79
|
+
|
|
80
|
+
A peer's messages may wake chi `peer.turns` times in a row (default 3) with nothing typed by the user, within
|
|
81
|
+
`session.max_wakes`. Past it they wait as notes, the say's line says so, and the TUI and the web say it once. A
|
|
82
|
+
message whose summary ends its round with `VERDICT OK` wakes chi once more to close it, held only by
|
|
83
|
+
`session.max_wakes`. Only input typed in the web or a TUI resets the count: `chi send` does not, since a peer can
|
|
84
|
+
run it. `peer.turns: 0` means a peer's message never wakes chi. `context.wake` is attached context's only.
|
|
85
|
+
|
|
86
|
+
`peer.turns` replaced `context.peer_turns` (no alias): rename it in config.yml.
|
|
87
|
+
|
|
88
|
+
## Limits
|
|
89
|
+
|
|
90
|
+
- A message's text up to 1 MiB, its summary one line of 200 characters.
|
|
91
|
+
- In the conversation, a note that wakes chi holds the text up to the tool output cap (10,000 characters by
|
|
92
|
+
default); one that doesn't, up to 2,000. A longer one points at the `claude_read` / `codex_read` tool
|
|
93
|
+
(`serial`, `offset`, `limit`), which pages it.
|
|
94
|
+
- 200 messages chi hasn't read: further says are refused until it reads them.
|
|
95
|
+
- The mailbox keeps every message chi hasn't taken, and the newest 50 it has.
|
|
96
|
+
- A continued message is cut at 4 KiB in the new link; run `chi peer ls <previous id>` to read the rest.
|
|
97
|
+
- A `chi peer say` sent at the very moment of a continue may stay with the previous session; run
|
|
98
|
+
`chi peer ls <previous id>` to read it there.
|
|
99
|
+
|
|
100
|
+
## Continuing a session
|
|
101
|
+
|
|
102
|
+
A continue leaves the pairing and the mailbox with the previous link:
|
|
103
|
+
|
|
104
|
+
- the new link's `/claude` init task posts the peer a `moved` message with the new id, and the peer pairs again
|
|
105
|
+
with it, the way it paired before (its skill knows how);
|
|
106
|
+
- a say to the old id is refused, naming the new id;
|
|
107
|
+
- the messages the previous link hadn't read (never taken, or held or noted and not yet read by a turn) reach the
|
|
108
|
+
new link as **one** note, each text in its peer block.
|
|
109
|
+
|
|
110
|
+
## Codex's sandbox
|
|
111
|
+
|
|
112
|
+
Codex's default sandbox writes only where its config allows, and `chi peer pair` and `say` write the mailbox:
|
|
113
|
+
|
|
114
|
+
```toml
|
|
115
|
+
[sandbox_workspace_write]
|
|
116
|
+
writable_roots = ["<state>/samagotchi/mailbox"]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`/codex install-skill` shows the exact line and makes the folder, so the root exists when Codex restarts. A config
|
|
120
|
+
from an older skill names `…/samagotchi/context`: change it. A say from inside the sandbox can't start a stopped
|
|
121
|
+
worker; it prints "couldn't be started from here", and chi reads the message at its next start.
|
|
122
|
+
|
|
123
|
+
## Who can write the mailbox
|
|
124
|
+
|
|
125
|
+
The mailbox is `<state>/samagotchi/mailbox/<session id>/<peer>/`, apart from the sessions folder: the only folder a
|
|
126
|
+
sandboxed peer writes, so it holds nothing chi trusts. chi's own record of each message (the receipts) is in the
|
|
127
|
+
session's own folder, written only by its worker. Every message file is checked before it is read.
|
|
128
|
+
|
|
129
|
+
The say is unauthenticated, as a context push is: any process that can write the mailbox can send as a peer. A
|
|
130
|
+
writer of the mailbox folder can also plant a file with the largest serial and use up a peer's serials (later
|
|
131
|
+
says then fail with "serials are used up"); the folder's writers are trusted that far, as they can delete its
|
|
132
|
+
files. chi's own tools can't write there (the `chi-mailbox` guardrail), and a shell command naming it asks.
|
|
133
|
+
|
|
134
|
+
## Upgrading from an older peer bundle
|
|
135
|
+
|
|
136
|
+
The claude-peer and codex-peer bundles paired through two attached context sources (`<peer>-inbox`,
|
|
137
|
+
`<peer>-outbox`). That is gone, with no compatibility:
|
|
138
|
+
|
|
139
|
+
1. `chi update` (or `chi bundle upgrade claude-peer`); an older bundle that still declares `chi.peer_source` fails
|
|
140
|
+
to load with "upgrade this bundle", and chi starts without it.
|
|
141
|
+
2. In Claude Code: `/claude install-skill`, then **Replace**; in Codex: `/codex install-skill` and change the
|
|
142
|
+
`writable_roots` line.
|
|
143
|
+
3. Pair again. Until then `/claude` says "paired the old way: pair again", and a push to an old `claude-outbox`
|
|
144
|
+
source is an ordinary context note.
|