samagotchi 0.191.0 → 0.193.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 +91 -1
- data/docs/architecture.md +8 -7
- data/docs/bundles.md +46 -29
- data/docs/cli.md +37 -15
- data/docs/configuration.md +10 -4
- data/docs/context.md +8 -5
- data/docs/guardrails.md +9 -4
- data/docs/internals/bridge.md +3 -1
- data/docs/internals/bundles.md +2 -2
- data/docs/internals/inline-widgets.md +2 -1
- data/docs/internals/pages.md +4 -4
- data/docs/internals/participants.md +6 -8
- data/docs/internals/peers.md +75 -22
- data/docs/internals/prompt-caching.md +2 -1
- data/docs/internals/remote-sessions.md +9 -0
- data/docs/internals/session-lifecycle.md +36 -21
- data/docs/internals/web-frontend.md +195 -25
- data/docs/internals/working-set.md +5 -1
- data/docs/peers.md +71 -22
- data/docs/plugins.md +7 -4
- data/docs/releasing.md +30 -2
- data/docs/scheduling.md +10 -3
- data/docs/sessions.md +3 -3
- data/docs/testing.md +36 -5
- data/docs/thin-clients.md +114 -12
- data/lib/samagotchi/bridge.rb +2 -3
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +33 -17
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +34 -17
- data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +31 -0
- data/lib/samagotchi/bundles/mcp/manifest.yml +4 -2
- data/lib/samagotchi/bundles/mcp/plugin.rb +7 -405
- data/lib/samagotchi/bundles/mcp/server_config.rb +158 -0
- data/lib/samagotchi/bundles/mcp/sign_in.rb +261 -0
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/client_id.rb +2 -19
- data/lib/samagotchi/compat.rb +6 -5
- data/lib/samagotchi/config.rb +7 -0
- data/lib/samagotchi/continue_offer.rb +13 -1
- data/lib/samagotchi/delivery.rb +3 -7
- data/lib/samagotchi/engine/models.rb +17 -0
- data/lib/samagotchi/engine/plugins.rb +2 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +49 -18
- data/lib/samagotchi/jsonl_store.rb +13 -2
- data/lib/samagotchi/llm/anthropic_messages.rb +11 -0
- data/lib/samagotchi/llm/openai_chat.rb +5 -0
- data/lib/samagotchi/llm/prompt_cache.rb +5 -0
- data/lib/samagotchi/pages/launch.rb +1 -1
- data/lib/samagotchi/peer_cold.rb +92 -0
- data/lib/samagotchi/peer_command.rb +24 -9
- data/lib/samagotchi/peer_continue.rb +32 -16
- data/lib/samagotchi/peer_exchanges.rb +7 -0
- data/lib/samagotchi/peer_mailbox.rb +21 -4
- data/lib/samagotchi/peer_receipts.rb +33 -6
- data/lib/samagotchi/peer_say.rb +34 -16
- data/lib/samagotchi/plugin/api.rb +2 -1
- data/lib/samagotchi/plugin/context.rb +13 -1
- data/lib/samagotchi/plugin/peer.rb +118 -53
- data/lib/samagotchi/plugin/peers.rb +13 -6
- data/lib/samagotchi/schedule_command.rb +1 -0
- data/lib/samagotchi/schedules/prune_part.rb +32 -0
- data/lib/samagotchi/schedules.rb +14 -9
- data/lib/samagotchi/session.rb +7 -0
- data/lib/samagotchi/session_access/local.rb +98 -37
- data/lib/samagotchi/session_access/remote.rb +1 -1
- data/lib/samagotchi/session_access/remote_peers.rb +3 -3
- data/lib/samagotchi/session_chain/links.rb +8 -3
- data/lib/samagotchi/session_continue.rb +15 -7
- data/lib/samagotchi/session_lifecycle.rb +4 -0
- data/lib/samagotchi/session_manager/delivery.rb +0 -6
- data/lib/samagotchi/session_manager/lifecycle.rb +30 -17
- data/lib/samagotchi/session_manager/listing.rb +2 -1
- data/lib/samagotchi/session_manager/removal.rb +7 -5
- data/lib/samagotchi/session_manager/spawn.rb +8 -4
- data/lib/samagotchi/session_manager.rb +4 -0
- data/lib/samagotchi/session_row.rb +2 -0
- data/lib/samagotchi/session_stores.rb +16 -11
- data/lib/samagotchi/session_transition.rb +61 -15
- data/lib/samagotchi/system_one/runs.rb +5 -2
- data/lib/samagotchi/testing/boundary.rb +0 -1
- data/lib/samagotchi/testing/host.rb +1 -0
- data/lib/samagotchi/testing/recorder.rb +3 -0
- data/lib/samagotchi/tools/cancel_schedule.rb +10 -6
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +3 -1
- data/lib/samagotchi/web/ask_create.rb +138 -0
- data/lib/samagotchi/web/ask_routes.rb +56 -9
- data/lib/samagotchi/web/last_ask.rb +78 -0
- data/lib/samagotchi/web/peer_routes.rb +10 -5
- data/lib/samagotchi/web/public/agent_rows.js +206 -0
- data/lib/samagotchi/web/public/agent_runs.js +595 -0
- data/lib/samagotchi/web/public/answer_fold.js +41 -44
- data/lib/samagotchi/web/public/answer_refs.js +3 -9
- data/lib/samagotchi/web/public/answer_write.js +28 -0
- data/lib/samagotchi/web/public/app.js +75 -99
- data/lib/samagotchi/web/public/block_fix.js +30 -12
- data/lib/samagotchi/web/public/cards_place.js +6 -4
- data/lib/samagotchi/web/public/chains.js +3 -1
- data/lib/samagotchi/web/public/command_list.js +5 -3
- data/lib/samagotchi/web/public/composer.js +9 -6
- data/lib/samagotchi/web/public/composer_mount.js +18 -11
- data/lib/samagotchi/web/public/draft_keys.js +10 -0
- data/lib/samagotchi/web/public/drafts.js +278 -0
- data/lib/samagotchi/web/public/history_reveal.js +5 -2
- data/lib/samagotchi/web/public/index.html +38 -2
- data/lib/samagotchi/web/public/owner_claim.js +7 -12
- data/lib/samagotchi/web/public/page_view.js +1 -1
- data/lib/samagotchi/web/public/pages.css +1 -7
- data/lib/samagotchi/web/public/peer_mailbox_api.js +2 -1
- data/lib/samagotchi/web/public/peer_note.js +4 -2
- data/lib/samagotchi/web/public/peer_row.js +37 -0
- data/lib/samagotchi/web/public/prompt_history.js +6 -0
- data/lib/samagotchi/web/public/quiet_notes.js +12 -1
- data/lib/samagotchi/web/public/revise_stack.js +5 -2
- data/lib/samagotchi/web/public/send_turn.js +62 -23
- data/lib/samagotchi/web/public/session_actions.js +80 -16
- data/lib/samagotchi/web/public/session_prefs.js +9 -3
- data/lib/samagotchi/web/public/session_view.js +7 -2
- data/lib/samagotchi/web/public/turn_block.js +4 -0
- data/lib/samagotchi/web/public/turn_events.js +0 -2
- data/lib/samagotchi/web/public/unqueue.js +22 -9
- data/lib/samagotchi/web/public/viewer_self.js +1 -6
- data/lib/samagotchi/web/public/views.js +12 -1
- data/lib/samagotchi/web/session_access_routes.rb +6 -3
- data/lib/samagotchi/web/session_control.rb +4 -2
- data/lib/samagotchi/web/session_create.rb +50 -33
- data/lib/samagotchi/web/session_hub.rb +52 -36
- data/lib/samagotchi/web/session_summary.rb +45 -7
- data/lib/samagotchi/web/start_dir.rb +6 -4
- data/lib/samagotchi/worker/mail.rb +11 -1
- data/lib/samagotchi/worker.rb +7 -5
- data/lib/samagotchi/worker_inbound/mail.rb +34 -6
- data/lib/samagotchi/worker_inbound.rb +11 -3
- data/lib/samagotchi/worker_link.rb +13 -1
- data/lib/samagotchi/worker_presence.rb +22 -6
- data/lib/samagotchi/worker_wakes.rb +33 -5
- metadata +12 -2
- data/lib/samagotchi/web/public/pages_group.js +0 -67
|
@@ -14,7 +14,7 @@ by `npm run e2e` (`spec/e2e/`). `app.js` has no unit spec of its own; `viewer_bo
|
|
|
14
14
|
**Every module has a size cap, `app.js` its own**: `npm run lint` fails past `max-lines` in `eslint.config.js`
|
|
15
15
|
(counted as `wc -l` counts, comments and blank lines too). Every `public/*.js` module: 1200 (`samagotchi/module-size`,
|
|
16
16
|
about 10% over the largest, `turn_block.js`), so a module near it splits rather than becoming the next `app.js`.
|
|
17
|
-
`app.js` (`samagotchi/app-size`): 1577, its size once the views by hash went into `views.js` and the pages' wiring landed; down from 1637, its size once the diagrams' wiring went into `diagram_wiring.js`, itself down from 1638,
|
|
17
|
+
`app.js` (`samagotchi/app-size`): 1547, its size once the composer's writes went into `drafts.js` and continue →'s draft guess went; down from 1577, its size once the views by hash went into `views.js` and the pages' wiring landed; itself down from 1637, its size once the diagrams' wiring went into `diagram_wiring.js`, itself down from 1638,
|
|
18
18
|
its size once the lightbox went into `picture_viewer.js`, itself down from 1649, its
|
|
19
19
|
size plus 50 once the session-open flow went into `session_sync.js` and `session_view.js`, itself ratcheted down from 2000, itself down from 2250 when the versions, the owner's claim links and
|
|
20
20
|
Verify, the composer's mode and the strip's hide went into modules of their own. A new feature goes into a module of
|
|
@@ -35,9 +35,13 @@ 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`, `quiet_notes.js`, `
|
|
38
|
+
`spec/web/public/fixtures/v0.183.0/`). `answer_fold.js`, `quiet_notes.js`, `agent_rows.js` (a delegate report's and a
|
|
39
|
+
peer answer's row: its element and words; `answer_fold.js` re-exports its `reportLabel`, an import cycle neither side
|
|
40
|
+
uses at its top level, `agent_rows.test.js` loads both orders), `agent_runs.js` (the one owner of reports, peer
|
|
41
|
+
answers and notes: The notes rows and the run line, below; it imports only names the last release's `answer_fold.js`
|
|
42
|
+
and `quiet_notes.js` exported, and `quiet_notes.js installQuietNotes` stays for an older cached `app.js`), `details_motion.js`,
|
|
39
43
|
`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 (kept in the history entry's `history.state.from`, so Back and Forward keep it), the session's hash not written while
|
|
44
|
+
`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 a view owns the URL (`keepSessionHash`), 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) and `page_links.js` (a page in chi web: [pages.md](pages.md#chi-web)), `worker_features.js`, `version_notices.js`, `owner_claim.js` (its `showPending` calls the injected `keepSessionHash`, following `views.js`'s rule not to write the session hash while a view owns the URL), `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`, `peer_row.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), `drafts.js` (the composer's drafts: The drafts, below), `draft_keys.js` (their storage keys, so `session_prefs.js` sweeps them without a new export), `answer_write.js` (the answer's live write onto its bubble, kept in its own module so a new `markdown_place.js` or `block_fix.js` importing it never waits on an old `answer_refs.js`) 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
45
|
|
|
42
46
|
## One page, every viewer
|
|
43
47
|
|
|
@@ -60,27 +64,79 @@ their viewer (The viewer, below), their show and stream are filtered (`Web::Part
|
|
|
60
64
|
| **`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
65
|
| **`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
66
|
| **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
|
|
67
|
+
| **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, long prompts, delegate reports and peer answers (`.folded`, each behind its `.answer-fold` row; a report's and a peer answer's `.answer-fold.agent-row`), the notes rows over a stretch of background items (`.quiet-notes`, open by its `open` class, the items `.quiet-hidden`; never stored) and the run lines over a run with a report, a peer answer or a finished steps block in it (`.quiet-notes.agent-line`, its open segment its `data-open`, the closed segments' rows and items `.quiet-hidden`, a block under its line `.in-line`; 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`, `agent_runs.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`, `agent_runs.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
68
|
| **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
69
|
| **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
70
|
| **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 |
|
|
71
|
+
| **The drafts** (`drafts.js`; app.js `drafts`) | the composer's `{text, chips}` per session window (`""` the start page): `#prompt` and the mount's chips are the one on view, a view `forgetSession` swaps | through it only, by the draft's key (the lint block `samagotchi/prompt-writes`): see The drafts | `show(key)` paints the box; a write to the key on view writes the box |
|
|
67
72
|
| **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
73
|
| **SSE** | see Streams | the server | events go into the DOM directly (a participant's through `participant_main.js wrapHandlers` first) |
|
|
69
74
|
|
|
70
|
-
**The notes rows** (`
|
|
71
|
-
the
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
**The notes rows and the run line** (`agent_runs.js`, the one owner; the notes' words are `quiet_notes.js`'s): text
|
|
76
|
+
written for the user starts open, text agents write to each other starts closed, so a phone shows the prompt and the
|
|
77
|
+
answer, not the background under them. Three levels of the same content (the design: the fold-levels mock-up,
|
|
78
|
+
https://claude.ai/artifact/6Pe1GXxBX4qMmdUsZH2FEp): a segment in a shared line, a row, the full text.
|
|
79
|
+
- A delegate report and a peer's answer in `#history`, finished and keyed (`answer_fold.js answerKey`; a live merged
|
|
80
|
+
report has none until a reload: it stays open with no row and ends a run), get a row before their bubble
|
|
81
|
+
(`agent_rows.js` draws it; `.answer-fold.agent-row`), closed by default, opened by hand kept in the fold store's
|
|
82
|
+
`open` list (Storage keys); a tap opens or closes it, its height animated unless the viewer prefers no motion.
|
|
83
|
+
- A run is those items and the quiet items (`QUIET`: a `.bubble.hook-notice` but the empty-answer line, a
|
|
84
|
+
`.bubble.note` that is neither a wake's opening `.turn-start` nor a `.peer-answer`, so objectives lines too, and a
|
|
85
|
+
`.bubble.steer-row`) side by side among `#history`'s children; the `.turn-timing` line and an objectives line after
|
|
86
|
+
a block (`.obj-moves`, `.obj-nomove`: they stay on view) pass through it, anything
|
|
87
|
+
else ends it (a typed prompt, an answer, a card, a time divider, another fold's row). A run of quiet items only gets
|
|
88
|
+
the notes row: `<button class="quiet-notes">` before its first item, "▸ 3 notes · names ⚠ 1", closed, its items
|
|
89
|
+
`.quiet-hidden`. A run of one report or one peer answer only keeps its row. Anything else gets the run line: a
|
|
90
|
+
`<div class="quiet-notes agent-line">` of segment buttons (`.qn-seg`, `data-seg`: `report`, `peer:<name>`, `calls`,
|
|
91
|
+
`notes`), `segments`' words ("N reports", "<peer>: <verdict>", "<peer> answered" with no verdict, "<peer> ×N" for
|
|
92
|
+
several, "N calls", "N notes" with its "⚠ N"), in the mock-up's order (reports, peers, calls, notes; the owner: order
|
|
93
|
+
doesn't matter). The kinds are one table (`KINDS`: per kind its selector, whether one takes part, its segment key and
|
|
94
|
+
words, and whether its row under the line is a row of its own, a note's compact row or the item itself); the same
|
|
95
|
+
table feeds the runs, the segments, the jump's reveal and the observer. One
|
|
96
|
+
segment is open at a time (the line's `data-open`): its rows show under the line (`.in-line`, indented), each closed
|
|
97
|
+
or open as its bubble is. Under a line every row is the mock-up's compact panel row (`.answer-fold.compact`): a peer
|
|
98
|
+
answer's, a report's (`.report-row`: "child <id6>", its first line, its length; alone it is Build 1's `.report` row
|
|
99
|
+
again, `agent_rows.js drawAgentRow` with `inLine`) and one per note (`.note-row`: its name and text, `noteRowWords`;
|
|
100
|
+
a tap shows the note under it, never stored). A settle redraws an item's row only when its open state, its place in
|
|
101
|
+
a line or its text (the observer's) changed. The line is `role="group"` ("agent run"); a tap on a segment that hides
|
|
102
|
+
the focused row moves the focus to that segment. A segment is per peer by the name it shows (`peerName`). One line at every width: CSS shrinks the notes segment first,
|
|
103
|
+
then the calls', then the reports', then the peers', strictly: their `flex-shrink` is 1e15, 1e10, 1e5 and 1, so a
|
|
104
|
+
higher rank gives up nothing (under 1/64 px) until the ranks below are at their padding (a proportional ladder cut
|
|
105
|
+
every segment a little); on a phone the line is 44px tall, a segment's tap area is, and a segment's side padding is
|
|
106
|
+
6px so the mock-up's "1 report · Claude: changes · 2 calls · 2 notes" fits at 390 px.
|
|
107
|
+
- A finished turn's steps block (`STEPS`: `.turn-work.done[data-end="completed"]`, with a call in its `data-calls`,
|
|
108
|
+
which `turn_block.js turnEnded` stamps live and on a reload, so no label parses the summary's words) in a run that
|
|
109
|
+
holds a report or a peer answer is the segment "N calls" (the calls of the run's blocks on view summed: one a
|
|
110
|
+
folded Revise version hides doesn't count). Under the line the block is its own row (`.in-line`, indented): today's
|
|
111
|
+
block, open or closed as it was last left, its summary line with the working set's footprint and its count, a tap
|
|
112
|
+
on it opens or closes the steps. So a footprint in a line is one tap deeper (the owner; [working-set.md](working-set.md)).
|
|
113
|
+
A block alone, or beside notes or a steer row only (a typed turn: owner decision (b)), keeps today's look and cuts
|
|
114
|
+
the notes into a notes row on each side; a cancelled or failed block ends a run and stays visible. A running block
|
|
115
|
+
stays out: the stage's joins at the hand-off; one opened in the history mid-turn (`stage_asking.js openTurn`, its
|
|
116
|
+
`data-opened-turn`) is done at its turn's end but joins only when `stage_handoff.js` drops that mark, the hand-off
|
|
117
|
+
that comes after the end. A block an older cached `turn_block.js` drew has no `data-calls` and stays out.
|
|
118
|
+
- A run inside a superseded Revise version folded to its stub (`revise_stack.js`: every item `.stack-hidden`): its
|
|
119
|
+
line or notes row is hidden with them (`.quiet-hidden`; a segment that had the focus gives it to the stub), and back
|
|
120
|
+
when the stub opens (a jump into it opens the stub first). `revise_stack.js`'s divider walk passes over it as over a
|
|
121
|
+
folded item.
|
|
122
|
+
- A notes row that a report or a peer answer joins becomes the line (a button becomes a div): its open state goes to
|
|
123
|
+
the notes segment, and its focus.
|
|
124
|
+
- Never stored: a reload draws every line and notes row closed; a row opened by hand inside a line shows open once its
|
|
125
|
+
segment is.
|
|
126
|
+
Every row and line is a sibling tied to its first item (WeakMaps), not a wrapper: the bubbles stay direct children of
|
|
77
127
|
`#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;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
128
|
+
other observers expect them; the line has the notes row's class and the item rows `answer_fold.js`'s, so what passes
|
|
129
|
+
over those passes over them (`revise_stack.js historyTurns`, `history_shape.js childItems`, `bubbles.js showRecap`'s
|
|
130
|
+
walk, `cards_place.js afterTurnEnd`). A row or line something was placed after goes back before its item and keeps its
|
|
131
|
+
state. A hidden item's arrival (`ts-arrive`) plays on its row or line. Its one observer watches `#history` (children,
|
|
132
|
+
and class or key changes on them that aren't its own), and a settle writes only what changed (the copy, answer-fold,
|
|
133
|
+
Revise and objectives observers see class and subtree writes). `history_reveal.js revealInHistory` opens a line's
|
|
134
|
+
segment over a jump's target (`agent_runs.js revealRun`) before a notes row's (`quiet_notes.js revealQuiet`).
|
|
135
|
+
A between-turn notice is placed after its turn, not below the next divider (`cards_place.js afterTurnEnd`). A
|
|
136
|
+
between-turn card is not: live it sits where it arrived, after a reload just before the next turn's opening
|
|
137
|
+
(`placeSnapshotCards`), so a card that came before a run lands inside it on a reload and the one line live draws is
|
|
138
|
+
two there (measured: "1 report · Claude ×2 · 3 notes ⚠ 1" live, "Claude ×2 · 2 notes" and "1 report · 1 note ⚠ 1"
|
|
139
|
+
after a reload; the row order drifted the same way before the line).
|
|
84
140
|
|
|
85
141
|
The objectives' strip keeps the list in its own closure (`objectives_strip.js`, seeded by `renderSessionView`, reset by
|
|
86
142
|
`forgetSession`, updated by `objectives_updated`): [objectives.md](objectives.md#the-page).
|
|
@@ -108,6 +164,15 @@ assignment, `++`, `delete` or `Object.assign` into `current`, `store.current` or
|
|
|
108
164
|
(`spec/web/public/lint_session_writes.test.js` runs it on a sample). An alias (`const st = state(); st.x = …`) isn't
|
|
109
165
|
caught: don't write through one.
|
|
110
166
|
|
|
167
|
+
**One writer of the message box**: `drafts.js` (The drafts, below) is the only module that writes `#prompt`'s value,
|
|
168
|
+
and the mounted composer's chips go through it too. The ESLint block `samagotchi/prompt-writes` flags an assignment to
|
|
169
|
+
the box's value by the names the page gives it (`promptEl.value`, `prompt.value`, `composer.el.value`) in every public
|
|
170
|
+
module but `drafts.js`, and `samagotchi/prompt-writes-app` a `composer.setChips(…)` call in app.js (the drafts get the
|
|
171
|
+
mount itself). A later block's `no-restricted-syntax` replaces an earlier one's, so the nine session-writes modules
|
|
172
|
+
carry both lists in their one block, and app.js all three in its own
|
|
173
|
+
(`spec/web/public/lint_prompt_writes.test.js` lints samples by file path through the whole config, and every real
|
|
174
|
+
module). Name-based: an alias of the box, or a chip list the mount changes in place (paste, ×), isn't caught.
|
|
175
|
+
|
|
111
176
|
**Read `store.current` fresh after every await.** A `const cur = store.current` held across an await pins the object
|
|
112
177
|
from before it, which a session switch (`forgetSession`) may have replaced: app.js's `mergeTurnTiming` and
|
|
113
178
|
`refreshTimingFromSession`, `session_view.js`'s `readTurnEnd` and `session_sync.js`'s `resync` read it again after each await. Keep `store.sessions`
|
|
@@ -231,7 +296,8 @@ The redraws, by their store names:
|
|
|
231
296
|
`forgetSession()` (`session_view.js`) is the one reset: `select` and `clearSelection` both call it, so anything per-session that isn't
|
|
232
297
|
in `store.current` (capabilities, the markdown warning and tip, the init row, the Verify claim, the armed Revise,
|
|
233
298
|
the running turn's DOM) is cleared there, and the feature gates are primed for the empty session. A new per-session holder
|
|
234
|
-
(an armed composer anchor like the Verify claim or the Revise) goes into it. The
|
|
299
|
+
(an armed composer anchor like the Verify claim or the Revise) goes into it. The composer's draft is swapped there,
|
|
300
|
+
not cleared (`drafts.show`: The drafts). The armed Verify claim is
|
|
235
301
|
`owner_verify.js`'s holder (`anchor()`, `set(a)`, `clear(a?)`: `clear(a)` lets go only of `a`). The armed Revise
|
|
236
302
|
(`pendingReviseAnchor`) is set only through `setReviseAnchor`, which redraws its chip and the Revise buttons (a
|
|
237
303
|
redraw only it feeds, not a store field).
|
|
@@ -560,7 +626,7 @@ instead. Nothing is kept across a re-render: a block failing again is posted aga
|
|
|
560
626
|
how it went); only the redraw is counted: an answer is read again at most once per turn and block for the page's life
|
|
561
627
|
(the route's 200 `fixed` or the event's), and a block failing after it says a fix didn't help. The stream's `block_fix` handler
|
|
562
628
|
(`stream_handlers.js`, dep `blockFix`) hands the worker's word over: `fixed` re-reads that turn's answer (`getSession(id,
|
|
563
|
-
{tail, turnId})`) and writes the bubble as `
|
|
629
|
+
{tail, turnId})`) and writes the bubble as `answer_write.js`'s `writeAnswer` writes it, which can't find it by its old text; `failed`
|
|
564
630
|
and `dropped` say a fix didn't help. Both 202 answers carry the block's key (`data-block-fix-key`); a keyed event settles
|
|
565
631
|
only that asked block, leaving another block's give-up timer running. A block is marked asked before its POST, since the
|
|
566
632
|
word can come before the 202 (a quick side answer); an event before the 202 or an older worker's keyless 202 keeps the
|
|
@@ -887,6 +953,22 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
|
|
|
887
953
|
agent" fold shows the content without the block, and the bubble carries `data-peer-inline`. Without it (an older
|
|
888
954
|
session, a message over the cap) the bubble draws as before. A mailbox message's note (its hash has `box`) carries
|
|
889
955
|
`data-peer-box` and no source; an older context answer's keeps its `<peer>-outbox` source as `data-peer-source`.
|
|
956
|
+
- **The answer's row** (`agent_runs.js`, drawn by `agent_rows.js`; its key `answer_fold.js answerKey`): every peer answer
|
|
957
|
+
in `#history`, short too, starts closed as one row before its bubble, `<name> <verdict> <summary> N lines` in a plain
|
|
958
|
+
panel box with no chevron (`.answer-fold.peer`; the verdict in the text colour whatever it says). `peer_row.js`
|
|
959
|
+
(pure) gives the words: the verdict as `verdictWord`'s lower-case word, none without one; the summary the peer sent
|
|
960
|
+
without the verdict mark it wrote into it (`summaryWithoutVerdict`: the last `VERDICT X` when X is the server's
|
|
961
|
+
verdict, the punctuation it leaves tidied), else (`.note-text` marked `data-fallback` by `peer_note.js`) the first
|
|
962
|
+
line of the peer's text; N the lines of the peer's own text (`.peer-text`'s `data-peer-md`), never the bubble's copy
|
|
963
|
+
text, and no length without a body. A tap opens the bubble under the same line (the box's top edge; the bubble's
|
|
964
|
+
`.under-row` class drops its own head, verdict and summary, which the row says, keeping the ↑ to the send), a
|
|
965
|
+
second closes it; opened by hand is kept with the reports' in the fold store's `open` list, keyed
|
|
966
|
+
`peer:<name>#<serial>`, else `peer@<opening id>`; with neither, no row and the bubble stays open. A jump into it (the
|
|
967
|
+
send pill's ↓, a claim link) opens it through `history_reveal.js`, not saved. An answer that arrives while a turn
|
|
968
|
+
runs sits in the stage, open (`stage_place.js`), and gets its row at the hand-off; the arrival motion
|
|
969
|
+
(`ts-arrive`) plays on the row, never on the hidden bubble. `revise_stack.js historyTurns` takes the row as its
|
|
970
|
+
note's head, and `cards_place.js afterTurnEnd` walks over it as over the notes. Next to a report, another answer or a
|
|
971
|
+
note it joins their run line (The notes rows and the run line).
|
|
890
972
|
- `peer_text.js` (pure): `peerBlock(content)` cuts the text out between the first `[PEER MESSAGE from …]` line and the
|
|
891
973
|
last `[END PEER MESSAGE]` line and undoes the `PeerNote.block` mark on forged frame lines
|
|
892
974
|
(`PEER_FORGED_OPENINGS` and `PEER_FORGED_LINES`, the Ruby `PeerNote::FORGED_OPENINGS` and `FORGED_LINES`, and the same line breaks and leads
|
|
@@ -933,6 +1015,91 @@ mailbox message, and `inline` when the note's content holds the peer's text). Th
|
|
|
933
1015
|
(`peerLinks.showSend`) after closing the popover. Under 600 px the peer popover is a bottom sheet (`sheetPlace`);
|
|
934
1016
|
ordinary chips' popovers stay at their chip.
|
|
935
1017
|
|
|
1018
|
+
## The drafts
|
|
1019
|
+
|
|
1020
|
+
`drafts.js` (`createDrafts`, app.js `drafts`) owns what the composer holds: one draft (`{text, chips}`) per session
|
|
1021
|
+
window, keyed `""` for the start page, else the session's id (app.js `shownDraft()` is the one on view). It is the
|
|
1022
|
+
only writer of `#prompt`'s value and, through the mount it is handed as its `view` (`composer_mount.js`), of the chips.
|
|
1023
|
+
Every write goes through it by the draft's key: `setText(key, text, {reveal, focus, caretEnd})` (a pick, a quote, a
|
|
1024
|
+
block fix's or a widget's fill, a failed turn's line back, the send's ack, the opener, a recalled ↑/↓ entry through
|
|
1025
|
+
the mount's `setText` hook, a `/` pick through `command_list.js`'s `afterPick(text)`), `putBack(key, text)` (into an
|
|
1026
|
+
empty draft only: unqueue's), `clear(key)` (the text only: the chips stay), `putChips(key, list)`, `move(from, to)`
|
|
1027
|
+
(into an empty draft as it is, else the text under the other's and the chips after; `from` emptied, its saved copy
|
|
1028
|
+
gone), `handOver(from, to, opener)` (continue →: below), `drop(key)` (a deleted session's: forgotten, its previews
|
|
1029
|
+
freed); reads `text(key)`, `chips(key)`, `has(key)`
|
|
1030
|
+
(text or a chip).
|
|
1031
|
+
|
|
1032
|
+
**The box is a view.** `#prompt` and the mount's chip list are the truth for the painted draft; the others are kept in
|
|
1033
|
+
the module's Map (per tab, their text read from storage the first time a key is seen). `show(key)` swaps them: the
|
|
1034
|
+
outgoing draft is taken from the box (a copy of the chips: the mount changes its list in place) and saved, the next
|
|
1035
|
+
one painted (`setChips(list, {revoke: false})`, `fit()`, the ↑/↓ browsing reset); the same key again is a no-op.
|
|
1036
|
+
`session_view.js forgetSession` calls it with `store.selected ?? ""` before `composer.newVisit()` and `applyPrefs()`
|
|
1037
|
+
(the grip's draft class and the fit see the new text), so `select` and `clearSelection` (+ new) both swap; app.js
|
|
1038
|
+
calls it once at boot, before `selectFromHash()`, which always paints (over a value the browser may have restored) and
|
|
1039
|
+
covers a page opened at `/` (the Home Screen app's start URL), where nothing selects. A chip's preview URL is freed on
|
|
1040
|
+
its ×, at its send (`chipsAfterSend`) or when its draft is dropped, never on a swap. An older cached `session_view.js`
|
|
1041
|
+
calls no `show`: the drafts see the shown key differ from the painted one and take the box as that window's draft
|
|
1042
|
+
(today's one box), painting a kept draft only over an empty box.
|
|
1043
|
+
|
|
1044
|
+
**Saved in this browser**: the text, on every write and every input event (`syncFromView`, the box's input listener;
|
|
1045
|
+
no save on leave, nor on `pagehide`: `store.selected` is already the next id by `forgetSession`, and iOS gives no
|
|
1046
|
+
reliable leave event), under `chi_composer_draft:<session>` (`session_prefs.js`, the key from `draft_keys.js`) and the
|
|
1047
|
+
start page's under `chi_start_draft` (one per browser, not per `?dir`). An empty or white-space draft removes its key.
|
|
1048
|
+
Chips live in memory only. While a line is in flight (`sending(key, line)` at the send's `inFlight`, `settle` when it
|
|
1049
|
+
is over or failed), the saved copy is `composerAfterAck` of it: a reload or an iOS kill right after Send doesn't bring
|
|
1050
|
+
the line back to send again.
|
|
1051
|
+
|
|
1052
|
+
**Async writers use the key they started in**: `send_turn.js` (`key` at the send's entry, before the pick's await; on
|
|
1053
|
+
a create's success `move("", s.id)` and `key = s.id` before `await select(s.id)`; the ack's text and chips, a command
|
|
1054
|
+
ack's clear, the reply's clear, an early restore's refill: all to that key, open or not; `openForVisit`, the Verify and
|
|
1055
|
+
Revise restores stay gated on the key being on view), `composer.js createComposerCommands` (the equality clear by the
|
|
1056
|
+
session's id), `unqueue.js` (`putBackTo(text, id)`: into the draft of the session it was queued in when that is empty,
|
|
1057
|
+
"shown" or "stored", the stored case a plain toast naming it). The stream handlers write the open session's
|
|
1058
|
+
(synchronous). A gone session (`session_actions.js leaveGoneSession`, the one place: a send's `not_found`, a re-read's
|
|
1059
|
+
404, the hub's `session_gone`) moves its draft to the start page's before the start page opens, unless a delete from
|
|
1060
|
+
this tab is taking it (the `deleting` set, filled when the sheet's request starts: the open link of a chain deleted
|
|
1061
|
+
whole too); `afterDelete` drops the deleted ids' drafts after its `clearSelection`. If a send's `not_found` belongs to
|
|
1062
|
+
a session that isn't open, `send_turn.js` moves that sent line to the start-page draft and shows a toast naming the
|
|
1063
|
+
gone session instead of leaving it in the gone session's swept draft key.
|
|
1064
|
+
|
|
1065
|
+
**Continue →** (`session_actions.js continueSelected`): right after the 201 (`addCreatedSession`), before it looks at
|
|
1066
|
+
which session is open, `handOverDraft(id, next, created)` = `drafts.handOver(A, A', openerText(created))`: a draft
|
|
1067
|
+
with text or chips moves whole to the new link (A's saved copy gone), an empty one leaves the link the opener. On
|
|
1068
|
+
another session at the answer: the toast's Open, that session's draft untouched; still on A (or back on it): `await
|
|
1069
|
+
select(next)`, then `revealDraft()` (the composer opens, the box takes the focus, the caret at the end). There is no
|
|
1070
|
+
Restore draft and no guess of where a draft came from (the old `draftFrom`/`noteDraft` and `chains.js openerFill`'s
|
|
1071
|
+
rule). A 409 `continued` hands the draft to the link that continues it only into an empty draft of its own, no opener.
|
|
1072
|
+
Chips moved from A go up again to A' at its send (`images.js uploadChips`, by `chip.session`).
|
|
1073
|
+
|
|
1074
|
+
**Swept** with the view settings (`COMPOSER_DRAFT` is in `PREF_KEYS`): only an unscoped list, ids missing from it,
|
|
1075
|
+
never an empty list (the hub answers its first snapshot empty until its first scan: a page reloaded as chi web
|
|
1076
|
+
restarts). A session the hub holds with no summary yet is left out of a snapshot: its draft can go then (accepted).
|
|
1077
|
+
Not kept or swapped: the Verify claim and the armed Revise (cleared on a switch, as before), ↑/↓ history (shared; its
|
|
1078
|
+
place resets on a swap), the delivery line's armed choice (a switch disarms it: `resetTurnView`'s
|
|
1079
|
+
`setTurnRunning(false)` redraws the composer with no running turn, and the line leaves `running`).
|
|
1080
|
+
|
|
1081
|
+
Two tabs on one session: the last writer wins, no cross-tab refresh. A tab reads a key's saved text once and
|
|
1082
|
+
saves on a switch only what it changed since it last read, painted or saved that key (`base`): a tab that only
|
|
1083
|
+
switches away never writes back an older copy over another tab's newer text.
|
|
1084
|
+
|
|
1085
|
+
The sweep now deletes draft **text**, not only view settings: another chi web on the same origin (the same host and
|
|
1086
|
+
port with another state dir, a smoke run on 4567) lists other sessions, and its page's first load sweeps this
|
|
1087
|
+
browser's drafts of the sessions it doesn't know.
|
|
1088
|
+
|
|
1089
|
+
**A mixed cache**: `send_turn.js` and `composer.js` take an older app.js's bag (`el`, `chips()`, `setChips(list)`,
|
|
1090
|
+
`clear()`: the one box) as well as this one's, and app.js still passes those members for an older cached
|
|
1091
|
+
`send_turn.js` (`drafts_mixed_cache.test.js` loads 0.191.0's from `spec/web/public/fixtures/v0.191.0/`); its `select`
|
|
1092
|
+
dep moves the start page's draft to a created session too (an older `send_turn.js` doesn't). The mount's `onWrite`, a
|
|
1093
|
+
no-argument `afterPick` and send_turn's `noteDraft` are an older module's way to say it wrote the box itself: app.js
|
|
1094
|
+
wires them to `syncFromView`. Beside an older app.js, this mount gets no `setText` (↑/↓ recall nothing until a reload),
|
|
1095
|
+
this command list's `afterPick` writes nothing (a Tab pick does nothing), and `unqueue.js` gets no `putBackTo` (today's
|
|
1096
|
+
toasts). An older cached `composer_mount.js` ignores `{revoke: false}`: a swap frees the chips' previews (broken
|
|
1097
|
+
thumbnails until a reload; the upload still works). An older `session_prefs.js` doesn't sweep the drafts until a
|
|
1098
|
+
reload. app.js still passes `fillOpener` (a shim: the hand-over and the reveal, returning no displaced draft) and a
|
|
1099
|
+
no-op `restoreDraft` for an older cached `session_actions.js`, which calls `fillOpener` after its select (without it
|
|
1100
|
+
its continue would toast "Can't continue" though it succeeded); `chains.js openerFill` and `restoredComposer` stay
|
|
1101
|
+
exported, unused, until after the next release.
|
|
1102
|
+
|
|
936
1103
|
## Stale answers
|
|
937
1104
|
|
|
938
1105
|
The page switches sessions, reopens a popover or asks again while a fetch is out. An answer for the old ask must be
|
|
@@ -948,7 +1115,7 @@ On it: `context_chips.js`, `peer_data.js`, `project_picker.js`, `participants_pa
|
|
|
948
1115
|
turn-end re-reads (`session_view.js` `readTurnEnd`, app.js's `refreshTimingFromSession`, `mergeTurnTiming`) and app.js's init-row timers. Still by hand
|
|
949
1116
|
(the id decides more than "drop it"): `session_sync.js` `resync`/`retryResync` (the re-read budget, `resyncAgain`), the stream's
|
|
950
1117
|
close, `session_actions.js` (a continue opens another session on purpose), `send_turn.js` (a failure for another
|
|
951
|
-
session becomes a toast). A new await in a component
|
|
1118
|
+
session becomes a toast; the drafts it writes are by the key it started in: The drafts). A new await in a component
|
|
952
1119
|
uses `latest.js`.
|
|
953
1120
|
|
|
954
1121
|
## API clients
|
|
@@ -991,17 +1158,20 @@ reach another device or the server.
|
|
|
991
1158
|
| `chi_markdown_tip_dismissed` | `markdown_tip.js` | the markdown tip dismissed |
|
|
992
1159
|
| `chi_update_available_shown` | `version_notices.js` | update notices already shown |
|
|
993
1160
|
| `chi_notify`, `chi_push_device` | `notifications.js` (an injected storage) | the bell's state, this device's push id |
|
|
994
|
-
| `
|
|
1161
|
+
| `chi_composer_draft:<session>` | `drafts.js` (through `session_prefs.js`; the key is `draft_keys.js COMPOSER_DRAFT`) | the session's composer draft's text (none while empty; its images are never stored) |
|
|
1162
|
+
| `chi_start_draft` | `drafts.js` (`draft_keys.js START_DRAFT`) | the start page's draft's text, one per browser; outside the sweep |
|
|
1163
|
+
| `chi_answer_fold:<session>` | `answer_fold.js`, `agent_runs.js` (the `open` list), `revise_stack.js` | the answers and long prompts (`<turn id>:prompt`) folded by hand, the delegate reports and peer answers (`peer:<name>#<serial>`, else `peer@<opening id>`) opened by hand (its `open` list), and the Revise stubs unfolded by hand (`stub:<turn id>`) (swept with the session list) |
|
|
995
1164
|
|
|
996
|
-
**A session's view settings** (`session_prefs.js`): the five `<key>:<session>` keys above
|
|
997
|
-
defined in `ws_sections.js`,
|
|
1165
|
+
**A session's view settings** (`session_prefs.js`): the five `<key>:<session>` view keys above and the composer's
|
|
1166
|
+
draft (the fifth's name is defined in `ws_sections.js`, the draft's in `draft_keys.js`, new modules, so
|
|
1167
|
+
`session_prefs.js` exports nothing new: the mixed-cache rule). `read(key, session)` is the
|
|
998
1168
|
session's own value, else the page's default (only the stage fold has one: `web.stage_collapsed` on `<body>`), else
|
|
999
1169
|
the module's; `write(key, session, value)` writes the session's key only; with no session (the start page) the value
|
|
1000
1170
|
stays in memory until a reload. Each module reads its value again when a session's view is drawn (`session_view.js
|
|
1001
1171
|
applyPrefs`: at the end of `forgetSession`, so on a select once the new session is set, and at the start of each
|
|
1002
1172
|
`renderSessionView`): `stage_view.js applyPrefs` (the stage's fold, `stage_asking.js reloadChoice`, and the rail's),
|
|
1003
|
-
`composer_mount.js applyPrefs` (the floor; the fold is read at each call). The list's section folds are read at each draw. One sweep for the
|
|
1004
|
-
(`sweepSessionPrefs`, app.js `sweepFoldsOnce`, next to `sweepAnswerFolds`): only on an unscoped list, since these keys
|
|
1173
|
+
`composer_mount.js applyPrefs` (the floor; the fold is read at each call). The list's section folds are read at each draw. One sweep for the six
|
|
1174
|
+
(`sweepSessionPrefs`, app.js `sweepFoldsOnce`, next to `sweepAnswerFolds`): only on an unscoped, non-empty list, since these keys
|
|
1005
1175
|
hold no project root. The old page-wide keys (`chi_stage_collapsed`, `chi_composer_floor`, `chi_composer_collapsed`,
|
|
1006
1176
|
`chi_working_set_collapsed`, no `:<session>`) are no longer read or written, and left in storage as they were.
|
|
1007
1177
|
|
|
@@ -369,7 +369,11 @@ passes `working_set_updated` to it, and does nothing when the flag is off. A new
|
|
|
369
369
|
unchanged one). A footprint is a `<span>` in its block's summary line, `.turn-work > summary > .tw-sum`, before the
|
|
370
370
|
steps' `.turn-steps`: drawn in the reload's template (`turnHistoryNodes`; a drawn turn's from its drawing's rows, `turnGroups`' steps), prepended at the hand-off
|
|
371
371
|
(`stage_view.js handOff`, while the stage still hides the summary). A click there must not toggle the block:
|
|
372
|
-
`details_motion.js` skips `.ws-foot`, and `footClick` cancels the click
|
|
372
|
+
`details_motion.js` skips `.ws-foot`, and `footClick` cancels the click. A finished block in a run line
|
|
373
|
+
(`agent_runs.js`, [web-frontend.md](web-frontend.md), The notes rows and the run line) is hidden behind the line's
|
|
374
|
+
"N calls" segment, its footprint with it: one tap deeper, the same node in the same summary line (never drawn in
|
|
375
|
+
the line). The chip, the rail and the lens are as without a line, and a step tag's jump (`refs.js showRow`,
|
|
376
|
+
`history_reveal.js`) opens the calls segment before it lands on the row;
|
|
373
377
|
- the rail (`onServer`, the stage's `scheduleRefresh`).
|
|
374
378
|
|
|
375
379
|
**The list's lens.** The expanded list is always the session's set (`sessionSet()`), seen through a lens: `null`
|
data/docs/peers.md
CHANGED
|
@@ -20,8 +20,10 @@ chi peer pair claude <session id> --address <where chi sends> --from "<who paire
|
|
|
20
20
|
- Pairing again only replaces the address (a Claude Code restart gives it a new socket).
|
|
21
21
|
- `chi peer unpair claude <id>` ends the pairing. Its messages stay, and chi still reads those it hasn't. The
|
|
22
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")
|
|
24
|
-
session that was continued
|
|
23
|
+
- `chi peer pair` refuses a session whose live worker is older than the mailbox ("restart the session"). Pairing a
|
|
24
|
+
session that was continued pairs its chain's live link and names it (`3f2a9c1e paired with Claude (session
|
|
25
|
+
1a2b3c4d continued as 3f2a9c1e)`); `unpair` of one ends the old link's pairing and the live link's, and `ls` lists
|
|
26
|
+
the live link's peers, naming it.
|
|
25
27
|
|
|
26
28
|
Which agents are peers is the bundles' to say (`chi.peer NAME` in plugin code), never a file's. A message from
|
|
27
29
|
a name no loaded bundle declared is refused with "no bundle in that session declares peer NAME".
|
|
@@ -29,11 +31,13 @@ a name no loaded bundle declared is refused with "no bundle in that session decl
|
|
|
29
31
|
## Saying something: `chi peer say`
|
|
30
32
|
|
|
31
33
|
```sh
|
|
32
|
-
chi peer say claude <id> --wake --re s-ab12cd --summary "validate step 2: VERDICT CHANGES, 2 issues" --wait 8
|
|
33
|
-
<the full answer>
|
|
34
|
-
EOF
|
|
34
|
+
chi peer say claude <id> --wake --re s-ab12cd --summary "validate step 2: VERDICT CHANGES, 2 issues" --wait 8 < answer.md
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
The skills write the answer to a file first (`$TMPDIR/chi-peer/answer-<ref>.md`) and say it from there, so a say
|
|
38
|
+
refused with "try again in a moment" is run again as it is, without writing the answer twice. They never run it
|
|
39
|
+
again after a `#N received` line or a failure with no line: nothing stops a second write of the same message.
|
|
40
|
+
|
|
37
41
|
- `--wake` or `--nowake` is required: `--wake` asks chi to run a turn for it (a validate's answer, a question's,
|
|
38
42
|
a message chi should act on now); `--nowake` leaves it as a note for chi's next turn.
|
|
39
43
|
- `--re` names the send it answers (the `ref:` line of chi's message); leave it out for a message the peer starts.
|
|
@@ -45,19 +49,21 @@ It prints one line, which the skills tell the agent to quote to its user:
|
|
|
45
49
|
| What chi did | The line |
|
|
46
50
|
|---|---|
|
|
47
51
|
| 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` |
|
|
52
|
+
| held it | `#12 received · held: 3 peer turns in a row (peer.turns) · waits for the user's next message`, `held: chi's cache is cold · waits for the user's next message` |
|
|
49
53
|
| took it as background | `#12 received · noted` |
|
|
50
54
|
| 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
55
|
| nothing within the wait | `#12 received · no answer from chi yet` |
|
|
52
56
|
| refused | `refused: no bundle in that session declares peer claude` (exit 1) |
|
|
53
57
|
|
|
54
|
-
Other messages of the same peer held and unread follow: `· also held: #10, #11 (paused)`. A
|
|
58
|
+
Other messages of the same peer held and unread follow: `· also held: #10, #11 (paused)`. A say to a session that was
|
|
59
|
+
continued goes to its chain's live link (below), and its line ends `· session continued as 3f2a9c1e: answer there`. A held message is not
|
|
55
60
|
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
61
|
`chi send` past it.
|
|
57
62
|
|
|
58
|
-
A say is refused, with nothing written, for: no such session; a session being deleted; a continued one
|
|
59
|
-
session was continued as <id>: say it there
|
|
60
|
-
|
|
63
|
+
A say is refused, with nothing written, for: no such session; a session being deleted; a continued one whose live
|
|
64
|
+
link isn't paired (a chain an older chi continued: `this session was continued as <id>: say it there`, naming that
|
|
65
|
+
link); one being continued right now (`this session is being continued as
|
|
66
|
+
<id>: say it again in a moment`: its new link is not saved yet); one busy with another change (`this session is busy
|
|
61
67
|
with another change; try again in a moment`); not paired (`not paired: run the pair script`); an older worker
|
|
62
68
|
(`restart the session`); 200 messages chi hasn't read yet.
|
|
63
69
|
|
|
@@ -71,8 +77,8 @@ The worker takes the peer's messages in order, between turns, and writes one rec
|
|
|
71
77
|
- then `read` once a turn starts with it in the conversation, and `completed`, `failed` or `stopped` when that
|
|
72
78
|
turn ends.
|
|
73
79
|
|
|
74
|
-
Held reasons: `off` (`peer.turns` is 0), `
|
|
75
|
-
`max_wakes`, `peer turns`, `queued`, `exit`, `leaving`, `before a turn`.
|
|
80
|
+
Held reasons: `off` (`peer.turns` is 0), `cold` (chi's cache is cold: below), `paused` (after a failed wake turn),
|
|
81
|
+
`continue` (a continue offer waits), `max_wakes`, `peer turns`, `queued`, `exit`, `leaving`, `before a turn`.
|
|
76
82
|
|
|
77
83
|
`chi peer ls <id>` lists each peer, its pairing and its newest messages with their receipts; the peer chip's list
|
|
78
84
|
shows the same words (`held · peer turns`, `read`, `completed`).
|
|
@@ -83,7 +89,42 @@ A peer's messages may wake chi `peer.turns` times in a row (default 3) with noth
|
|
|
83
89
|
`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
|
|
84
90
|
message whose summary ends its round with `VERDICT OK` wakes chi once more to close it, held only by
|
|
85
91
|
`session.max_wakes`. Only input typed in the web or a TUI resets the count: `chi send` does not, since a peer can
|
|
86
|
-
run it.
|
|
92
|
+
run it. The count outlives the worker (an idle exit, a restart), so a peer that speaks every 40 minutes is held after
|
|
93
|
+
`peer.turns` wakes as one that speaks every minute is. `peer.turns: 0` means a peer's message never wakes chi.
|
|
94
|
+
`context.wake` is attached context's only.
|
|
95
|
+
|
|
96
|
+
## A cold cache
|
|
97
|
+
|
|
98
|
+
A turn on a cold prompt cache reads the whole conversation again at the write price, where a warm one pays a tenth of
|
|
99
|
+
it. So a message the peer starts on its own (no `--re` naming one of chi's sends) and a `VERDICT OK` closer don't wake
|
|
100
|
+
chi while its cache is cold: they wait as notes for the user's next message (`held: chi's cache is cold`, the chip's
|
|
101
|
+
`held · cold`, and the TUI and the web say it once). "Cold" is all of:
|
|
102
|
+
|
|
103
|
+
- chi's model is a Claude model on a remote host, whose requests carry cache breakpoints, so the host keeps a cache
|
|
104
|
+
with a TTL (through an OpenAI-style host such as OpenRouter, or a remote `api: anthropic` host whose dialect sends
|
|
105
|
+
them); a local model has no remote TTL and is never held, whatever its API;
|
|
106
|
+
- the last turn ended longer ago than `cache.ttl` (5 minutes, or an hour with `1h`);
|
|
107
|
+
- the conversation is over 20,000 tokens (the size the last turn saved); a smaller one is cheap to read again.
|
|
108
|
+
|
|
109
|
+
An answer chi asked for (its `--re` names a send chi made to that peer, in this session or the one it continues,
|
|
110
|
+
that no earlier message answered) wakes chi cold or warm, and so does a batch holding one. Anything chi can't tell (no turn yet, no saved size) counts
|
|
111
|
+
as warm.
|
|
112
|
+
|
|
113
|
+
## Quiet pairings
|
|
114
|
+
|
|
115
|
+
When chi's model sends to a peer it hasn't exchanged anything with for `peer.quiet_minutes` (30 by default; 0 turns
|
|
116
|
+
this off), the peer's own session may have gone cold too, so you decide. "Exchanged" is the pairing, a send to it, or
|
|
117
|
+
a message from it, also in the session this one continues. Then:
|
|
118
|
+
|
|
119
|
+
- in a turn you started from the web or a TUI, you get a question: "Claude last heard from chi 2 h ago: its session
|
|
120
|
+
may be cold. Send?" (Send / Don't send; a parent agent can't answer Send). Don't send holds for the rest of that
|
|
121
|
+
turn, so the model trying again doesn't ask again;
|
|
122
|
+
- in any other turn (a schedule's, a delegate's, a wake turn, `chi send`'s) nobody is there to answer: the send is
|
|
123
|
+
refused at once and the model is told you decide;
|
|
124
|
+
- a `/claude …` or `/codex …` you type never asks.
|
|
125
|
+
|
|
126
|
+
The pairing stays paired; `/claude` (or `/codex`) shows `quiet 2 h: a send from the model asks first`. The timer
|
|
127
|
+
also asks when the peer was busy with its own work and is warm: it can't see the peer's cache.
|
|
87
128
|
|
|
88
129
|
`peer.turns` replaced `context.peer_turns` (no alias): rename it in config.yml.
|
|
89
130
|
|
|
@@ -95,19 +136,27 @@ run it. `peer.turns: 0` means a peer's message never wakes chi. `context.wake` i
|
|
|
95
136
|
(`serial`, `offset`, `limit`), which pages it.
|
|
96
137
|
- 200 messages chi hasn't read: further says are refused until it reads them.
|
|
97
138
|
- The mailbox keeps every message chi hasn't taken, and the newest 50 it has.
|
|
98
|
-
- A continued message is cut at 4 KiB in the new link;
|
|
99
|
-
|
|
100
|
-
|
|
139
|
+
- A continued message is cut at 4 KiB in the new link; the rest stays in the previous session's mailbox, and the
|
|
140
|
+
cut says how chi reads it whole: `claude_read(serial: N, box: "<previous id8>")` (`codex_read` for Codex), which
|
|
141
|
+
reads from the session this one continues.
|
|
142
|
+
- A `chi peer say` at the moment of a continue is refused (`being continued as <id>: say it again in a moment`, or
|
|
143
|
+
busy), nothing written, rather than landing in a mailbox the carry already read (the say holds the session's
|
|
144
|
+
transition lock shared); the peer runs it again.
|
|
101
145
|
|
|
102
146
|
## Continuing a session
|
|
103
147
|
|
|
104
|
-
|
|
148
|
+
The pairing follows the chain, and the peer does nothing:
|
|
149
|
+
|
|
150
|
+
- a continue copies each pairing to the new link as it is (the address, who paired, when), so chi's next send goes
|
|
151
|
+
to the same Claude or Codex session, with the new id in its header;
|
|
152
|
+
- a say, pair, unpair or `ls` to the old id runs on the chain's live link, and the say's line says so
|
|
153
|
+
(`session continued as <id8>: answer there`); a pairing the continue couldn't copy (a chain an older chi
|
|
154
|
+
continued) is refused as before, naming the live link, and the skill pairs again there;
|
|
155
|
+
- the messages stay with the previous link, and those it hadn't read (never taken, or held or noted and not yet
|
|
156
|
+
read by a turn) reach the new link as **one** note, each text in its peer block.
|
|
105
157
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
- a say to the old id is refused, naming the new id;
|
|
109
|
-
- the messages the previous link hadn't read (never taken, or held or noted and not yet read by a turn) reach the
|
|
110
|
-
new link as **one** note, each text in its peer block.
|
|
158
|
+
An answer chi asked for that reaches a new link before its first turn waits as a note, held `before a turn`, as it
|
|
159
|
+
does for any link with no turn yet (a Continue with no prompt): the user's first message lets chi read it.
|
|
111
160
|
|
|
112
161
|
## Codex's sandbox
|
|
113
162
|
|
data/docs/plugins.md
CHANGED
|
@@ -937,6 +937,7 @@ full label, `plugin.rb (bundle my-bundle)`.
|
|
|
937
937
|
| `ctx.cost` | the session's spend so far, read now, as a frozen value: `total` (USD, reported + estimated, side requests included; 0.0 before any), `reported` (by providers, `usage.cost`), `estimated` (from `hosts.<name>.models` prices; a generation is one or the other, never both), `side` (recap, `/btw`, `ask_model`: their share of `total`) and `known?` (false while generations or side requests ran but none was reported or priced, so a limit on it can't be enforced; a session with some priced generations reads known, the unpriced ones counting 0). It includes the running turn's finished generations and what earlier workers of the session spent. Use its methods, not its class. Needs chi 0.83.0 |
|
|
938
938
|
| `ctx.usage` | the session's work so far, read now, as a frozen value: `turns` (finished ones and the running one), `tool_calls` and `tool_calls_by_tool` (every call, running ones included; canonical names: an alias counts under its tool, a `call_tool` call under the inner tool), `steps` (the loop rounds that dispatched tools, `/stats`' iterations) and `active_ms` (`active_minutes` too): work time, the generations' time plus the finished tool calls' time, never the waits between them (a question, an approval, the user's answer to `ask_user_question`), with `tool_ms_by_tool` its tool part by tool, so a waiting tool's time (`task_wait`) can be left out. Its counts are the ones `/stats` and `chi sessions stats` show, earlier workers' included. Use its methods, not its class. Needs chi 0.100.0 (guard it with `ctx.respond_to?(:usage)`) |
|
|
939
939
|
| `ctx.turn_author` | who wrote the running turn when it isn't the session's owner: a participant's `"p:<id>"` (`chi share`); nil for the owner's turns and between turns. Every hook event of such a turn carries the same as `author:`. The handler runs with the owner's power whatever the author ([hooks](hooks.md#participants-turns)): `ctx.secrets` works there, so don't start a sign-in on such a turn. Needs chi 0.105.0 (guard it with `ctx.respond_to?(:turn_author)`) |
|
|
940
|
+
| `ctx.turn_interactive?` | whether the running turn was sent from a screen that shows a question and can answer it now: the owner's web tab or TUI (their first prompt, and a Continue tap on such a turn, too), and a thin client's `POST …/ask` (`web:unnamed`), which can answer a question through `…/answer`. False between turns and for every other turn (`chi send`'s, a schedule's, a delegate's, a wake turn, a participant's, a one-shot run), where a `ctx.ask_user` would wait with nobody to answer it: decide without asking there. The peer bundles' dormant send asks only when it is true. Needs the next chi (guard it with `ctx.respond_to?(:turn_interactive?)`) |
|
|
940
941
|
| `ctx.tool_id` | inside a tool's block, the run's own id (chi's tool id, `"t41"`), the one a two-arg `refs:` lambda got for its row ([Refs on a tool's row](#refs-on-a-tools-row)); nil anywhere else (a hook, a command, a thread the block started) and for a run with none. Needs chi 0.181.0 (guard it with `ctx.respond_to?(:tool_id)`) |
|
|
941
942
|
| `ctx.settings` | the bundle's settings, frozen: config.yml's `bundles: <bundle>:` with the session's own `--set` values laid over it ([Per-session settings](#per-session-settings)); the config alone until the session is bound (in `register` and `chi.ctx`) |
|
|
942
943
|
| `ctx.data_dir` | `$XDG_STATE_HOME/samagotchi/plugins/<bundle>/`, created on first use: what the bundle keeps across sessions |
|
|
@@ -1644,16 +1645,17 @@ a quiet `chi.init` task.
|
|
|
1644
1645
|
ctx.peers.link("claude") # => #<data PeerLink peer="claude", address="/tmp/…sock", paired_at="…", from="…"> or nil
|
|
1645
1646
|
ctx.peers.left_behind("claude") # the previous link's pairing, in a continue's new link; else nil
|
|
1646
1647
|
ctx.peers.message("claude", 12) # => #<data PeerMessage serial=12, text="…", summary="…", wake=true, re="s-ab12cd", at="…"> or nil
|
|
1648
|
+
ctx.peers.message("claude", 3, box: "1a2b3c4d") # box: the note's box, or the continued session's id8 (its mailbox)
|
|
1647
1649
|
ctx.peers.last_message("claude") # the newest message still in the mailbox, or nil
|
|
1648
1650
|
```
|
|
1649
1651
|
|
|
1650
1652
|
What a peer bundle reads of its peer's side of the session (the mailbox,
|
|
1651
1653
|
[peers.md](peers.md)): the pairing (`address` nil: the peer answers only) and
|
|
1652
1654
|
the peer's messages. Read only: the peer pairs and says through `chi peer`,
|
|
1653
|
-
and the worker takes the messages. A continue
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1655
|
+
and the worker takes the messages. A continue copies the pairing to the new
|
|
1656
|
+
link, so its `link` is the previous link's pairing as it was; `left_behind`
|
|
1657
|
+
is the one the previous link keeps (the copy's source; an older chi left the
|
|
1658
|
+
new link unpaired). Needs the next chi.
|
|
1657
1659
|
|
|
1658
1660
|
### Context providers in the manifest
|
|
1659
1661
|
|
|
@@ -1883,6 +1885,7 @@ bundle.set(declared_tools: %w[read]) # ctx.declared_tools (d
|
|
|
1883
1885
|
bundle.set(cost: 2.5) # ctx.cost: reported USD, or { reported:, estimated:, side:, known: }
|
|
1884
1886
|
bundle.set(usage: { tool_calls: 40, active_ms: 600_000 }) # ctx.usage: { turns:, tool_calls:, tool_calls_by_tool:, steps:, active_ms:, tool_ms_by_tool: }
|
|
1885
1887
|
bundle.set(turn_author: "p:p_0123abcd") # a participant's turn: ctx.turn_author, and author: on every event
|
|
1888
|
+
bundle.set(turn_interactive: false) # ctx.turn_interactive? (default true: the owner's turn from a screen)
|
|
1886
1889
|
bundle.set(session_settings: { "cap" => 1 }) # the session's --set values (Bundle.load takes session_settings: too)
|
|
1887
1890
|
bundle.tool_loads.last.names # ctx.load_tools calls; set(load_tools_staged: [...]) limits what they stage
|
|
1888
1891
|
bundle.pair_peer("claude", address: "/tmp/c.sock") # a peer's side, as chi peer pair writes it (ctx.peers.link); address: nil answers only
|