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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c8e7fa5a6ecf59f94f137ab4b95a76d129a6e2edab94204aab625747a7ffc3d4
|
|
4
|
+
data.tar.gz: 61480eb9e2af49ec87cd51eafaf1a4bd4b3fe0202ff464c126fb971203bd68bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ddd533fc0c541fe9be37a437180bfbdaa62322b9de85b028da971dc2d7a69b6440cf8548110705eb9d91ce9d176544e348fb5d559fe538343eb907c3f7dbd47f
|
|
7
|
+
data.tar.gz: df7ea7ed667b4e5784fc0def947532666374ccf1f8d502a5eaf7d3975f76d4bda79f6b6a4f7b9267436b8dea6096cb44335062bdba285def2623f675f82acb79
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,99 @@ and commands may change between minor versions. How releases are made:
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.189.0] - 2026-11-25
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `chi schedule show ID` lists the schedule's last 20 outcomes, newest first (fired, skipped, failed, missed, your
|
|
16
|
+
enable and disable), each with its reason and session; `list --format json` has them as `history`.
|
|
17
|
+
- `chi schedule edit ID` changes a schedule in place: its title, prompt, recurrence, catch-up or budgets (only the
|
|
18
|
+
flags given), keeping its id, session, mode and counters ([docs/cli.md](docs/cli.md#durable-schedules-chi-schedule)).
|
|
19
|
+
- The schedules bundle (`chi bundle install schedules`): a Schedules page in chi web (`#/p/schedules`): every
|
|
20
|
+
schedule, why one is off and the `chi schedule enable ID` that turns it on, and the recent runs; read-only
|
|
21
|
+
([docs/scheduling.md](docs/scheduling.md#the-schedules-page)).
|
|
22
|
+
- Page scripts get `runtime.schedules`: the schedules read in chi itself, no `chi` command
|
|
23
|
+
([docs/pages.md](docs/pages.md#reading-chis-data-runtime)). A bundle can ship pages (the manifest's `pages:`); your
|
|
24
|
+
own `NAME.rb` replaces a bundle's page, and `chi page rm` refuses one ([docs/pages.md](docs/pages.md#pages-from-a-bundle)).
|
|
25
|
+
- `chi schedule list --format json` gives each schedule's `name`, `state` (on, firing, off) and `off_reason`.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- A schedule turned off by its skip or failure budget notifies the phone whatever ran the tick: a cron
|
|
30
|
+
`chi schedule tick` or a `run-now` too, not only chi web's own tick (chi web pushes it, with `schedule.auto_tick`
|
|
31
|
+
off as well).
|
|
32
|
+
- chi web: pages have their own `pages` pill in the top bar (when there is at least one page, in every view, on a
|
|
33
|
+
desktop and a phone); it opens the Pages list, and appears without a reload when chi makes the first page. All
|
|
34
|
+
sessions no longer shows a Pages group ([docs/pages.md](docs/pages.md#in-chi-web)).
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- `chi schedule cancel|enable|disable` (and the `cancel_schedule` tool) say "no schedule" instead of ok when another
|
|
39
|
+
cancel removed the schedule in between.
|
|
40
|
+
- Pairing claude-peer or codex-peer again removes that peer's old inbox/outbox context sources (their chips).
|
|
41
|
+
- A `schedules.json` that can't be read (not JSON, not a schedules document, a file chi can't open, or a schedule in
|
|
42
|
+
it that doesn't read) no longer leaves its sessions unprotected: the retention sweep deletes nothing that round (it
|
|
43
|
+
tries again at the next sweep interval) and a delete (`chi sessions delete`, `prune`, the web's, `--remote`) is
|
|
44
|
+
refused with "schedules.json is unreadable (…): fix or remove it before deleting sessions". For one schedule that
|
|
45
|
+
doesn't read, the refusal names it and `chi schedule cancel <id>` removes it. A missing file is still no schedules.
|
|
46
|
+
- chi web: when a claim is shown while the Pages list or a page is open, the address bar no longer jumps to the
|
|
47
|
+
session's hash: Back or a Reload now returns you to the page instead of to the session.
|
|
48
|
+
|
|
49
|
+
Update with `chi update` (the new schedules bundle: `chi bundle install schedules`).
|
|
50
|
+
|
|
51
|
+
## [0.188.0] - 2026-11-24
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- `chi peer pair|unpair|say|ls` (also through `--remote`), `claude_read` / `codex_read` for a long message, and chi
|
|
56
|
+
web's `…/peers` routes (a message's text, Unpair, a remote's pair and say).
|
|
57
|
+
|
|
58
|
+
### Changed
|
|
59
|
+
|
|
60
|
+
- **Breaking:** peers (claude-peer, codex-peer) talk to chi through a mailbox, not attached context
|
|
61
|
+
([docs/peers.md](docs/peers.md)). Each message from Claude or Codex is its own note, in order, with its text;
|
|
62
|
+
`chi peer say` prints what chi did with it (`#12 received · woke chi`, or `held: 3 peer turns in a row (peer.turns)
|
|
63
|
+
· waits for the user's next message`), and the peer chip's list says it too. The `claude-inbox` / `claude-outbox`
|
|
64
|
+
(`codex-…`) context sources are gone, with no compatibility. To upgrade:
|
|
65
|
+
1. `chi update` (claude-peer and codex-peer need this chi; an older peer bundle fails to load with "upgrade this
|
|
66
|
+
bundle", and chi starts without it).
|
|
67
|
+
2. In Claude Code: `/claude install-skill`, Replace. In Codex: `/codex install-skill`, and change its
|
|
68
|
+
`writable_roots` line in `config.toml` from `…/samagotchi/context` to `…/samagotchi/mailbox`.
|
|
69
|
+
3. Pair again (`pair with chi <id>`). Until then `/claude` says "paired the old way: pair again".
|
|
70
|
+
- **Breaking:** `context.peer_turns` is renamed `peer.turns` (no alias: an old key in config.yml or the environment is ignored, so
|
|
71
|
+
rename it). `peer.turns: 0` means a peer's message never wakes chi; `context.wake` no longer applies to peers.
|
|
72
|
+
- A continue leaves a peer's pairing with the previous session, as before: the peer is told the new id and pairs
|
|
73
|
+
again; what it said that the old session hadn't read reaches the new one as one note.
|
|
74
|
+
- **Breaking:** plugins: `chi.peer_source` is gone (it raises how to upgrade); a peer bundle declares `chi.peer NAME` and reads
|
|
75
|
+
its pairing with `ctx.peers`.
|
|
76
|
+
- `chi schedule list`: each row names its schedule (its title, or the start of its prompt in quotes), so a
|
|
77
|
+
disabled one is easy to tell apart; the name column is padded to the widest name of the rows printed.
|
|
78
|
+
`list_schedules` names them the same way.
|
|
79
|
+
- chi web: plugin lines and context notes under a turn's answer fold into one closed row, "▸ 3 notes · source-links,
|
|
80
|
+
skills, objectives"; tap it to read them. A warning marks the row. Your prompt, the answer, a peer's answer and a
|
|
81
|
+
note that starts a turn stay as they are.
|
|
82
|
+
- skills (0.1.11): "a step failed, the skill wasn't updated" is a warning now (yellow in the web, `warning:` in the
|
|
83
|
+
terminal).
|
|
84
|
+
- skills (0.1.12): a skill a bundle ships (the pages skill, say) no longer gets the "a step failed, update the skill"
|
|
85
|
+
nudge or warning.
|
|
86
|
+
|
|
87
|
+
### Fixed
|
|
88
|
+
|
|
89
|
+
- The system prompt names the real system memories folder when the config lives outside ~/.config.
|
|
90
|
+
- chi web: a message an agent or visitor sent keeps its "agent NAME" label after a reload.
|
|
91
|
+
- chi send / ask_session: a session whose worker is too old for the message reads "refused: ... restart it", not
|
|
92
|
+
"failed: ...".
|
|
93
|
+
- chi web: after a reload, a plugin's line after a turn stays right under that turn instead of moving below the next
|
|
94
|
+
time divider and notes.
|
|
95
|
+
- chi page: a run that finishes just before its 30 s cut keeps its result instead of "stopped after 30 s", and the
|
|
96
|
+
runner's own "stopped" record is no longer overwritten by "ended without a result"; text in another encoding (a
|
|
97
|
+
Latin-1 file) reads right instead of turning into `�`; a cut run leaves no `output.json.*.tmp` behind; a failed run
|
|
98
|
+
keeps fields a newer chi wrote in the page's output.
|
|
99
|
+
- `chi page`: help names the pages folder it reads, including when `XDG_CONFIG_HOME` is set.
|
|
100
|
+
- chi web: a live wake note opens its turn, as it does after a reload.
|
|
101
|
+
|
|
102
|
+
Update with `chi update` (claude-peer 0.7.0, codex-peer 0.6.0, skills 0.1.12, the dev profile 0.7.11).
|
|
103
|
+
|
|
11
104
|
## [0.187.0] - 2026-11-23
|
|
12
105
|
|
|
13
106
|
### Added
|
|
@@ -6825,7 +6918,9 @@ and long-lived sessions.
|
|
|
6825
6918
|
- A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
|
|
6826
6919
|
hotkey panel that send selected text or the clipboard to your sessions.
|
|
6827
6920
|
|
|
6828
|
-
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.
|
|
6921
|
+
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.189.0...HEAD
|
|
6922
|
+
[0.189.0]: https://github.com/dm1try/samagotchi/compare/v0.188.0...v0.189.0
|
|
6923
|
+
[0.188.0]: https://github.com/dm1try/samagotchi/compare/v0.187.0...v0.188.0
|
|
6829
6924
|
[0.187.0]: https://github.com/dm1try/samagotchi/compare/v0.186.0...v0.187.0
|
|
6830
6925
|
[0.186.0]: https://github.com/dm1try/samagotchi/compare/v0.185.0...v0.186.0
|
|
6831
6926
|
[0.185.0]: https://github.com/dm1try/samagotchi/compare/v0.184.0...v0.185.0
|
data/bin/chi
CHANGED
|
@@ -75,6 +75,8 @@ SUBCOMMANDS = {
|
|
|
75
75
|
"broadcast" => ["samagotchi/broadcast_command", "BroadcastCommand"],
|
|
76
76
|
# live external text attached to sessions (add, push, ls, show, rm, mute)
|
|
77
77
|
"context" => ["samagotchi/context_command", "ContextCommand"],
|
|
78
|
+
# a peer agent's side of a session: pair, unpair, say (what chi did with it), ls
|
|
79
|
+
"peer" => ["samagotchi/peer_command", "PeerCommand"],
|
|
78
80
|
# a message into sessions as the user's (-m)
|
|
79
81
|
"send" => ["samagotchi/send_command", "SendCommand"],
|
|
80
82
|
# answer the question a session waits on, then wait (--question, --option)
|
data/docs/architecture.md
CHANGED
|
@@ -229,8 +229,8 @@ catalogue, never to the class.
|
|
|
229
229
|
- **Single owner:** the process running a session's Engine (its worker, or a `--non-interactive` one-shot) holds a flock on `owner.lock` (`OwnerLock`); a second owner backs off, and the web answers 409 for a session a one-shot owns. That owner is also the one writer of the session's `turn_drawings.jsonl` (a worker's Bridge, a one-shot's own accumulator); a fork's copy of its parent's lines is written before the child's worker spawns.
|
|
230
230
|
- **Status:** `status` is turn state (`idle`/`running`); liveness is the lock. A stop is the `<uuid>/stopped` marker (`Session.mark_stopped`; a resume removes it), which `Session.load` and `.summary_from_file` read as status `stopped`, so no other process rewrites a worker's session file. A resume writes nothing else: the worker, holding the lock, turns a status from before it idle (`Worker#settle_stale_status`: `stopped` with no marker, `error`, a `running` no turn is behind; not a new session's `running` whose first prompt waits), and saves at start whatever the status, which stamps `updated_at` as the resume's save did (a session woken with no turn stays young for the sweep). N-1: a newer spawner starting an older worker (a checkout's chi spawning the installed one) loses that reset; a restart covers it.
|
|
231
231
|
- **Starting:** every spawn marks the session starting (`<uuid>/starting`, `{pid, at}`, `StartingMarker`) until its worker holds the lock: `spawn_worker_for_session` writes it with its own pid before `Process.spawn` and the starter's after (the starter lives until the worker holds the lock, at most `WORKER_START_GRACE`; a spawn that raises or whose starter is gone leaves none), `spawn_session` before the new file is saved, and `Worker#start` removes it. It holds for 60 s at most, and only while the pid it names runs. A resume claims it (`StartingMarker.claim`, a link(2): of resumes racing from any processes one wins), then reads the owner again. A stop marker cancels the hold-off (`start_pending?` = starting and not stop-marked) for a start marked before the stop only: of two sends after a stop, the claim lets one spawn. The stop marker carries its own `at` (`{"at"}`, on the starting marker's clock; `Session.stopped_at`), an older chi's empty one its mtime. The sweep, archive (`:starting`) and delete (refused as an owned session) honour it. N-1: an older spawner writes none for a resume (the owner checks stay); an older worker never leaves one it was given (every worker clears it at start); a leftover one is stale by age or pid (a claim's temp files a kill left, `starting.*`, count as skeleton); a 0.160 spawner or chi web still holds off on a fresh marker under a stop (it reads `starting?` before the stop), until the start ends or 60 s. `SessionManager` keeps only its starters' pids, for chi web's restart to adopt (`live_spawn_pids`), and decides nothing from them.
|
|
232
|
-
- **Deleting:** `delete_session`, the retention sweep and a failed continue's cleanup use `remove_files` for the session JSON, sidecar dir, plugin state, attached context, participant grants, System 1 runs and context-candidate records. `SessionStores` registers the sidecar filenames and the removal categories; `remove_session_files` deletes the whole sidecar directory, so those files need no individual removal path. The JSON and dir go through `remove_session_files`, holding the owner lock (kind `deleting`, which `stop_session` never signals; not waited for: a worker that took it since the check keeps the session) and reading the starting marker again under it (a resume that claimed the start just before keeps the session; one after it sees the lock held). N-1: an older chi's stop reading the owner then would TERM the deleter (chi web, the CLI) in that moment; an older reader shows the kind as unknown. `Session#save` of a session read from its file (or saved once) skips a file that is gone (log `save_skipped_deleted`) rather than recreate it; only a new session's first save creates one.
|
|
233
|
-
- **Worker presence:** whether a worker is up, coming or held off is read once per decision as a `WorkerPresence` (`worker_presence.rb`, a `Data.define`), the deciders' one reader of those facts (display and list rows still read `session_owner` / `WorkerLink` themselves): the owner lock's holder, the stop marker (`stop_marked?`: the only "stopped" a decider reads, never the session file's status), the `starting` marker (`StartingMarker`, `starting?`, `start_pending?`: every spawn writes it, see Starting), the archive marker, the session file's existence, and the `WorkerLink` outcome when asked (never the file itself: a scratch session's flag is read by `WakePolicy`, last). The deciders read it: `resume_session` (tui, owned, `resume_held_off?`), the session inbox's `WakePolicy` (a ring, a push's wake, a note, a fresh verdict, `wake_for_report`, `deliver_turn`'s two liveness checks, `WorkerBoot`'s leave: below), `Local#wake`/`#worker`, `AttachLauncher`, `Schedules#busy_reason
|
|
232
|
+
- **Deleting:** `delete_session`, the retention sweep and a failed continue's cleanup use `remove_files` for the session JSON, sidecar dir, plugin state, attached context, participant grants, System 1 runs and context-candidate records. `SessionStores` registers the sidecar filenames and the removal categories (what a delete removes), `SessionProtection` its protectors (what refuses one: an enabled schedule's anchor, head and target; fail-closed); `remove_session_files` deletes the whole sidecar directory, so those files need no individual removal path. The JSON and dir go through `remove_session_files`, holding the owner lock (kind `deleting`, which `stop_session` never signals; not waited for: a worker that took it since the check keeps the session) and reading the starting marker again under it (a resume that claimed the start just before keeps the session; one after it sees the lock held). N-1: an older chi's stop reading the owner then would TERM the deleter (chi web, the CLI) in that moment; an older reader shows the kind as unknown. `Session#save` of a session read from its file (or saved once) skips a file that is gone (log `save_skipped_deleted`) rather than recreate it; only a new session's first save creates one.
|
|
233
|
+
- **Worker presence:** whether a worker is up, coming or held off is read once per decision as a `WorkerPresence` (`worker_presence.rb`, a `Data.define`), the deciders' one reader of those facts (display and list rows still read `session_owner` / `WorkerLink` themselves): the owner lock's holder, the stop marker (`stop_marked?`: the only "stopped" a decider reads, never the session file's status), the `starting` marker (`StartingMarker`, `starting?`, `start_pending?`: every spawn writes it, see Starting), the archive marker, the session file's existence, and the `WorkerLink` outcome when asked (never the file itself: a scratch session's flag is read by `WakePolicy`, last). The deciders read it: `resume_session` (tui, owned, `resume_held_off?`), the session inbox's `WakePolicy` (a ring, a push's wake, a note, a fresh verdict, `wake_for_report`, `deliver_turn`'s two liveness checks, `WorkerBoot`'s leave: below), `Local#wake`/`#worker`, `AttachLauncher`, `Schedules#busy_reason` (its state's answer through `SessionLifecycle`: `Reading.derive` and `ALLOWED`), archive, delete and the retention sweep. Each keeps its own subset of the facts and their order.
|
|
234
234
|
- **Session inbox:** a delivery into a session (`SessionInbox.deliver(kind, id) { |at| write }`, `session_inbox_delivery.rb`) runs one path: resolve the link (`SessionInbox::Head.resolve`: push and a fresh verdict are pinned to the id named; a send and a note go to the chain's newest link, and for a send (a kind that starts an archived link) a continue of the reached link in flight (`ContinueIntent.in_flight`: `continue.json` written, `continue.lock` held, the successor not saved yet) gives `:continuing` with the successor's id, which chi send asks again for a moment and then refuses; a note needs no such check (`NoteMove` moves or adopts it); a ring's file stays with the parent `parent.json` names and its wake goes one hop, to the link whose `ChildReports` reads that file; only an archived id is walked, with one `Session.list`: `SessionChain::Links#first_live`), refuse before any write (a gone session; a one-turn run's or a scratch session for send and a note), write with the kind's own writer (formats unchanged), read `WorkerPresence` once, and apply the kind's `WakePolicy` row. `decide` reads in one order for every kind: gone, one-turn run (`:owned`), owned (`:live`), the stop marker (`:stopped`: the only "stopped", the file's status never decides; send un-stops), archived (send alone starts one), starting (`:starting`, never a second spawn), the kind never starts (`:none`: a note, a fresh verdict) or wasn't asked to (`:off`), scratch (the session file is read only here), else `:start` through `SessionManager.start_for_inbox` (`resume_session`, its claim on the starting marker; it answers `:woken` only when it spawned the worker, `:starting` when another start won the claim, `:live` when a worker took the lock since). N-1 gap: a session file that says `stopped` with no stop marker (stopped before the marker existed, or a resume whose spawn failed after it cleared the marker) is woken, and an older worker, which has no `Worker#settle_stale_status`, exits on its first pass; the wake still reads `:woken`, and each later ring or push spawns another such worker (bounded by the rings and pushes). Restarting chi on the new version (`chi web`, the workers) closes it. `SessionInbox.wake` is the wake half alone (`wake_for_report`, a failed continue's rings). On it: `ChildRing.ring` (its start on a thread), `Local#context_push`'s wake (its outcome is `ContextPush#wake`, the push line's ending), `NoteDelivery.deliver` (every note writer a person or another session drives: `chi note`, `send_note`, `chi broadcast`, chi web's notes route; `NoteDelivery::Result#id` is the link that has it, `#asked` the one named; `/objectives` passes `pin: true`: its list is its own session's) and `VerifyFresh.forward` (`:fresh_verdict`: the child's parent, pinned, no worker). Send keeps its Bridge/file flow in `SessionManager.deliver_turn`, which resolves nothing (it acts on the id it is given: an archived link gets the message and comes back); chi send resolves the head first (`SessionAccess#head`, remotely `GET /api/sessions/resolve?head=1`), while the web composer, a participant's turn, `delegate` follow-ups, `Plugin::Sessions` and `Schedules` stay on the id they name; its two liveness checks (before the post, after a file's write) read the sender's row (`WakePolicy.for_sender(client_id)`, `ClientId.wake_kind`: a person's — chi send, a web tab, a TUI — is `:send`; a schedule, a plugin, a delegate follow-up and a participant have rows of their own, any other id `:automatic`, which start an idle session but neither un-stop nor start an archived link: refused before the write, `DeliverResult::STOPPED` / `ARCHIVED`) and leave the other refusals to `resume_session`'s wording. One row is not a delivery: `:leave`, `WorkerBoot.run_session_loop`'s successor as a worker leaves (input left after a signal, an idle exit's or `/exit`'s input or rings, a restart), read on a fresh presence once the lock is free: a stop that landed as it left starts none for any way out (`resume_session` would clear the stop; logged `respawn_dropped`, `restart_dropped` for a restart, whose reminders go with it), the input and rings stay for the next start. The notes a spawn writes into the session it starts stay direct `SessionInbox.write_note` calls, pinned by construction: spawn_session's chain note, `ContextMove`'s notes, `Objectives.carry`, `ChildMove`'s note to a moved child. A continue moves the previous link's waiting notes to the new link last in its `before_spawn` (`NoteMove.move`), a failed one gives them back before the link goes (`NoteMove.give_back`), and the new link's worker adopts what the archived links before it get after their continue (`NoteMove.adoption`, from `WorkerInbound#absorb_notes` and `Worker#start`: back along the chain through up to 8 archived links, from each only notes from the creation of the link that continued it, never an objectives list). `write_note` refuses a session with no file and no folder (`Session::NotFound`), so a late writer can't bring back a deleted link's folder.
|
|
235
235
|
- **Retention:** 14 days / 500 cap (env `SAMAGOTCHI_SESSION_RETENTION_DAYS`/`MAX_COUNT`, optional `KEEP_STATUS`), live-owner and starting guard (looked at again right before a session's files go), only when `*.json` present; lazy sweep at most once per `session.sweep_interval_hours` (default 24) from the session hub's full-probe tick (and on `GET /api/sessions`, which the page no longer calls), manual via `bin/chi sessions prune --dry-run`.
|
|
236
236
|
- **Ordering:** `Session.list(sort:,order:,limit:,offset:)` and `GET /api/sessions?sort=&order=&limit=&offset=` default `updated_at desc`; Web UI sort/filter/pagination.
|
|
@@ -371,7 +371,9 @@ proxies the stream and relays the writes. The routes, wire shapes, replay rules,
|
|
|
371
371
|
never pulls from the page: `chi web` runs one `Samagotchi::Web::SessionHub` (a thread inside
|
|
372
372
|
the server, no daemon) that keeps an in-memory projection of the session list and pushes
|
|
373
373
|
changes to every open tab over `GET /api/events` (SSE: a `snapshot` frame on every connect,
|
|
374
|
-
then `session` for an upsert and `session_gone` for a removal, `: ping` while idle, no replay
|
|
374
|
+
then `session` for an upsert and `session_gone` for a removal, `: ping` while idle, no replay;
|
|
375
|
+
and `pages`, no data, when the pages' scripts folder changed: one `File.stat` of `Pages.scripts_dir` a tick, which
|
|
376
|
+
Server.start passes as `pages_dir:`, never on the first look; the page reads `GET /api/pages` again on it).
|
|
375
377
|
The snapshot names chi's version: a tab served by another one (its `<body data-version>`) offers a
|
|
376
378
|
reload in a toast, since an open tab keeps its old JS across a `chi web` upgrade. It also names
|
|
377
379
|
`installed`, the newest chi on this machine (`InstalledVersions`: the highest `samagotchi-<v>.gemspec`
|
|
@@ -514,8 +516,11 @@ model: [internals/remote-sessions.md](internals/remote-sessions.md).
|
|
|
514
516
|
| `POST /api/sessions/:id/answer` (`wait`) | owner | `wait: N` (seconds, at most 30) beside `id`, `selected`, `freeform` | 200 `{status: answered, session_id, id, reply: {the wait's fields, token while it is timeout}}`; a question answered elsewhere first: 200 `{status: not_pending, answered_here: false, …, reply}` (as `chi answer` still waits); a wait that fails after the answer went in: 200 with that `status` and `wait_error` `{error: server_stopping \| not_found \| wait_failed, detail}` in place of `reply`; without `wait` every answer is as before | 400 `invalid_wait`; 404 |
|
|
515
517
|
| `POST /api/sessions/:id/notes` | owner | `text`, `source` (default `cli`, never `broadcast`) | 200 `{status: queued \| waits, session_id, queued}` (`NoteDelivery`) | 409 `owned_by_tui` (`status: refused`); 400 `note_rejected`, `missing_fields`, `invalid_source` |
|
|
516
518
|
| `POST /api/sessions/:id/context` (more bodies) | owner | `{name, push: true, why, hint}` or `{name, cmd, every, why, hint}` beside the page's `{url, why, hint}`; `added_by` `cli`/`agent` (else `web`); `movable` (any body) | 201 `{status: attached, name, movable}` | 400 `invalid_source`; 409 `exists` |
|
|
517
|
-
| `POST /api/sessions/:id/context/:name/push` | owner | `text`, `summary`, `wake`, `hint
|
|
518
|
-
| `GET /api/sessions/:id/peers` | owner | | 200 `{peers: [{name, label,
|
|
519
|
+
| `POST /api/sessions/:id/context/:name/push` | owner | `text`, `summary`, `wake`, `hint` (a source's JSON output, checked the same way) | 200 `{status: pushed, name, before, revision, changed}` | 404 `not_found`; 409 `not_push`; 410 `context_continued` (`next_id`); 400 `invalid_text` |
|
|
520
|
+
| `GET /api/sessions/:id/peers` | owner | | 200 `{peers: [{name, label, paired_at, from, address, can_send, messages, exchanges}]}`: one row per mailbox folder, its newest 20 messages with their receipts and `words`, last 20 joined exchanges, newest first; no text; files only ([internals/peers.md](internals/peers.md)) | 404 `not_found` |
|
|
521
|
+
| `GET /api/sessions/:id/peers/:name/messages/:serial` | owner | | 200 the message (its text) and its receipt | 404 `no_message`; 400 `invalid_peer` |
|
|
522
|
+
| `DELETE /api/sessions/:id/peers/:name` | owner | | 200 `{unpaired}`: the pairing ends, its messages stay | 400 `invalid_peer` |
|
|
523
|
+
| `POST /api/sessions/:id/peers/:name/pair`, `…/say` | owner | pair: `address`, `from`; say: `text`, `summary`, `wake`, `re`, `wait` (≤ 30: the server waits for the receipt) | pair 200 `{status: paired, link}`; say 200 `PeerSay` and its `line` | 409 refused (`continued` + `next_id`, `old_worker`, …, the same shape); 400 bad name, text or wait |
|
|
519
524
|
| `DELETE /api/sessions/:id/context/:name?own=1` | owner | | 200 `{status: detached}`: the session's own only | 409 `project_source` (chi context rm's words); 404 |
|
|
520
525
|
| `POST /api/sessions/:id/stop` | owner | `wait?` (seconds, capped at `SessionManager::STOP_WAIT`, 10: `chi --remote NAME sessions stop` sends it) | 200 `{status: stopped, session_id, released}`: `released`, whether the worker let go within the wait (without one `STOP_WAIT_SECONDS`, 2 s: the page's Stop) | 409 `owned_by_tui` |
|
|
521
526
|
| `DELETE /api/sessions/:id?force=` | owner | `force=true` stops a live worker first (the page sends it) | as before | 409 `worker_running` without it |
|
|
@@ -672,7 +677,8 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
|
|
|
672
677
|
| Session file | `session.rb` (`Session`, `Session::FIELDS`), `session_field.rb` (`SessionField`), `session_paths.rb` (`SessionPaths`), `session_setup.rb` (`SessionSetup`) | A session's `<uuid>.json`: one `SessionField` row per key (default, cast, what the file gets; the codec on its type), from which `Session.new`, `.from_h` and `#to_h` are built; `SessionPaths` is where the file and the session's dir are and the id rule, a leaf `Session` extends (so `ArchiveStore` and `ContextSources` name no `Session` constant; both still require session.rb at load); `SessionSetup` the settings a fork and a continue carry (`.of`), applied by member name; every new-session request (chi's run flags, the one-shot, `chi send --new`, chi web's create) builds its setup with `SessionSetup.from_request`, and `spec/session_setup_entrypoints_spec.rb` holds each entrypoint's cell for each member. See [sessions.md](sessions.md#session-file). |
|
|
673
678
|
| Session config (`--set`) | `session_config.rb` (`SessionConfig`, `SessionConfig::Settings`) | A session's own settings as one value (`Session#settings`, `SessionSetup#settings`): `core`, the `--set KEY=VALUE` values of the core keys marked `session: true` (`Config::Entry`), typed by `Config.coerce!` and read first through `Config.get(key, session:)` (`RecapSetup`; `Engine#session=` rebuilds the recap job, `IdleScheduler#replace_job`), file key `config_settings`; `bundles`, the `--set BUNDLE.KEY=VALUE` values, checked against the manifest's `session_settings:`, laid over `bundles: <name>:` in `ctx.settings` ([plugins.md](plugins.md)), file key `bundle_settings`. `SessionConfig.clash` refuses a bundle setting named like a core one (install, `chi bundle check`). See [configuration.md](configuration.md#per-session-settings). |
|
|
674
679
|
| Plugin API | `plugin/api.rb` (`Plugin::Api`), `plugin/tool_spec.rb` (`Plugin::ToolSpec`: a checked tool declaration, how it is registered), `plugin/loader.rb`, `plugin/context.rb` (`ctx`), `plugin/http.rb` + `plugin/http_transport.rb` (`ctx.http`), `plugin/http_stream.rb` (`ctx.http.stream`) + `plugin/sse_reader.rb`, `plugin/http_errors.rb`, `plugin/secrets.rb` (`Plugin::Secrets`, `ctx.secrets`) + `plugin/sign_in.rb` (`Plugin::SignIn`, `ctx.sign_in`), `plugin/card.rb` (`Plugin::Card`) | What a bundle's plugin registers: tools, commands, annotation actions, hooks, services, toolkits, peer sources; what its handlers get as `ctx` ([plugins.md](plugins.md)). |
|
|
675
|
-
| Peer bundles' base | `plugin/peer.rb` (`Plugin::Peer`) | What claude-peer and codex-peer share (the send
|
|
680
|
+
| Peer bundles' base | `plugin/peer.rb` (`Plugin::Peer`), `plugin/peers.rb` (`ctx.peers`) | What claude-peer and codex-peer share (the send and read tools, the command, the cards, payloads, telling the peer a continue's new id); each bundle's subclass sets its strings and transport ([bundles.md](bundles.md#the-claude-peer-bundle)). |
|
|
681
|
+
| Peers | `peer_mailbox.rb` (`PeerMailbox`: the peer's side, `mailbox/<id>/<peer>/`), `peer_receipts.rb` (`PeerReceipts`: chi's side), `peer_registry.rb` (`chi.peer`), `peer_note.rb`, `peer_say.rb`, `peer_command.rb` (`chi peer`), `peer_roster.rb`, `peer_continue.rb`, `worker_inbound/mail.rb` (`absorb_mail`), `web/peer_routes.rb` | A peer agent's messages: one file each, taken by the worker in order as its notes, a receipt each, the say's line ([internals/peers.md](internals/peers.md)). |
|
|
676
682
|
| Shipped bundles | `bundles/` (`mcp`, `github-pr`, `loop-guard`, `skills`, `source-links`, …) | Bundles that ship with chi. |
|
|
677
683
|
| Hooks | `hooks/registry.rb` (`Hooks::Registry`), `hooks/loader.rb`, `hook_routes.rb` (`HookRoutes`), `event_routes.rb` (`EventRoutes`) | Hook registration and dispatch; what a hook or plugin does beyond reading its event (notice, question, stop, steer) routed to the UIs (cards and notices through one set of routes) ([hooks.md](hooks.md)). |
|
|
678
684
|
| Guardrails | `guardrails.rb`, `guardrails/shell_lex.rb`, `guardrails/data_readers.rb`, `guardrails/rules.rb`, `guardrails/protected_paths.rb`, `guardrails/parent_policy.rb` + `guardrails/parent_approvals.rb`, `guardrail_wiring.rb` | The gate before every tool call: shell lexing (and the commands that only read a heredoc as data), YAML rules, the core checks on chi's own files, approvals, what a parent agent may answer (`guardrails.parent_answers`) ([guardrails.md](guardrails.md)). |
|
|
@@ -682,7 +688,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
|
|
|
682
688
|
| Worker link | `worker_link.rb` (`WorkerLink`: `Live`, `Starting`, `Leaving`, `Skew`, `Stale`, `None`), `worker_sidecar.rb` (`WorkerSidecar`) | Whether a session's worker can be reached and the client for it: every Bridge client asks `WorkerLink.resolve` / `.client` / `.await` (*Worker link* above); `WorkerSidecar` is the `bridge.json` it reads. |
|
|
683
689
|
| Session access | `session_access.rb` (`SessionAccess`: `NewSession`, `SetupWords`, `WaitStart`, `SessionView`, `Created`, `ContextEntry`, `ContextPush`, the errors `RemoteFailed`, `RemoteTooOld`, `Refused`, `BadRequest`), `session_access/local.rb` (`SessionAccess::Local`), `session_access/remote.rb` (`SessionAccess::Remote`), `session_access/http_transport.rb`, `session_access/web_bridge_client.rb` (`SessionAccess::WebBridgeClient`, a remote attach's worker through chi web), `session_access/dispatch.rb` (`SessionAccess::Dispatch`), `session_access/contract.rb` (`SessionAccess::Contract`), `remotes.rb` (`Remotes`), `remote_command.rb` (`chi remote`), `web/session_access_routes.rb` (`Web::SessionAccessRoutes`), `session_access/exchange.rb` (`SessionAccess::Exchange`: the stateless pieces of a send and its wait, for chi send, chi answer and the ask), `session_access/exchange/token.rb` (`Exchange::Token`: a wait as one string), `session_access/ask.rb` (`SessionAccess::Ask`: one message in, its answer out), `web/ask_routes.rb` (`Web::AskRoutes`: the thin-client routes) | The seam between the session commands and where the sessions live: `Local` is this machine's (the `SessionManager`, `ReplyWait`, `NoteDelivery`, `ContextSources` and Bridge calls the commands made); `Remote` is another machine's, the same methods as requests to its chi web's routes of the same name (Bearer token, `HTTPTransport`), results as Local's value objects and refusals as the classes Local's callees raise, built from the fields chi web sends; waits and prefixes run on the server, a wait asked again per 30 s slice. `Dispatch` is bin/chi's front for `--remote NAME` / `CHI_REMOTE` (taken off before the subcommand lookup): it refuses what the contract table lists `local_only` (exit 2, one message) and runs the command with a `Remote` on the `Remotes` entry (`$XDG_CONFIG_HOME/samagotchi/remotes.yml`, 0600). chi web's routes answer from `Local` (*chi web's routes for the session commands* above). Checks that read this machine's config or files (vision, parent answers, the cwd's project, `SAMAGOTCHI_PARENT_SESSION`) stay in the commands and are skipped under a `Remote`, where chi web's create, turn and wait routes run the vision, parent-answers and busy checks with the server's config and the worker checks a parent's answer. See [internals/remote-sessions.md](internals/remote-sessions.md). |
|
|
684
690
|
| Idle work | `idle_scheduler.rb` (`IdleScheduler`), `idle_recap.rb` (`IdleRecap`), `idle_reminders.rb` | One poller for an idle session's recap and reminders. |
|
|
685
|
-
| Attached context | `context_sources.rb` (`ContextSources`), `context_poller.rb`, `context_absorber.rb`, `context_candidates.rb` (`ContextCandidates`: proposed sources, attached on the owner's mention at a turn's start, before the worker's absorb, or in a one-shot's turn; `owner_prompt.rb` decides whose words count)
|
|
691
|
+
| Attached context | `context_sources.rb` (`ContextSources`), `context_poller.rb`, `context_absorber.rb`, `context_candidates.rb` (`ContextCandidates`: proposed sources, attached on the owner's mention at a turn's start, before the worker's absorb, or in a one-shot's turn; `owner_prompt.rb` decides whose words count) | External sources a session keeps fresh ([context.md](context.md)). |
|
|
686
692
|
| LLM context strategies | `llm_context_strategy.rb`, `llm_context_view.rb`, `llm_context_stale.rb`, `llm_context_forget.rb` | What a request sends of the history (none, stale, forget) ([internals/llm-context-forget.md](internals/llm-context-forget.md)). |
|
|
687
693
|
| Session chains | `session_continue.rb` (`SessionContinue`), `session_chain.rb` (`SessionChain`), `session_chain/links.rb` (`SessionChain::Links`), `session_chain/delete.rb` (`SessionChain::Delete`), `session_chain/delete_preview.rb` (`SessionChain::Delete::Preview`), `continued_from.rb` (`ContinuedFrom`) | A session that continues an earlier one. `SessionChain::Links` is the one chain walker (one listing; `latest`, `first_live`, `root`, `next_of`): `SessionChain.latest`/`.next_of`, `SessionInbox::Head` and the schedule tick all ask it. `SessionChain.opener_for` gives the text web `continue →` prefills in the new link: the previous link's own first typed message when that link continues one itself, else nil (the 201's `opener`; not saved). `SessionChain::Delete` plans and deletes a link or its chain; `Delete::Preview` supplies the web delete sheet, and `ContinuedFrom` records what a continue must undo ([sessions.md](sessions.md)). |
|
|
688
694
|
| MCP server | `mcp_server/protocol.rb` (`McpServer::Protocol`: JSON-RPC in both revisions, no transport, no chi), `mcp_server/tools.rb` (`McpServer::Tools`: `chi_sessions`, `chi_ask`, `chi_wait`, `chi_answer` over a SessionAccess backend through `SessionAccess::Ask` and `Exchange`), `mcp_server/text.rb` (`McpServer::Text`: the results' words), `mcp_server/stdio.rb` (`McpServer::Stdio`), `mcp_server/http.rb` (`McpServer::Http`), `mcp_command.rb` (`chi mcp serve`), `web/mcp_route.rb` (`Web::McpRoute`: `POST /api/mcp`, included through SessionAccessRoutes) | chi as an MCP server ([mcp-server.md](mcp-server.md)); not the `mcp` bundle (chi as a client). Only `tools.rb` names `SessionAccess`: another front builds `Protocol.new(tools: Tools.new(access))`. The caller is a parent agent (`cli:send` / `cli:answer`, `SessionAccess::Ask#agent_line`). |
|
data/docs/bundle-authoring.md
CHANGED
|
@@ -58,7 +58,7 @@ plugin:
|
|
|
58
58
|
`bundles: my-bundle:` as a Hash with string keys, once, when the plugin loads. A value a session may set
|
|
59
59
|
(`chi --set my-bundle.KEY=V`, listed in the manifest's `session_settings:`, typed with `{KEY: number}` so a
|
|
60
60
|
value of another type is refused) is read from `ctx.settings` at call time. List what config.yml may set in `settings:`
|
|
61
|
-
(`[greeting]`, or `{greeting: string}`): a typo there then warns. `chi bundle check --set KEY=VALUE` gives the sandboxed load a setting. A bundle can also draw a fenced block in chi web's answers, with no plugin code: `block_renderers:` and a script calling `chi.defineRenderer` ([plugins.md](plugins.md#block-renderers)). A plugin that outgrows one file lists its other top-level `.rb` files under `plugin: parts:` (`client.rb: sha256:`, at most 16; `check --fix` fills the shas, and warns of a top-level `.rb` they don't list): chi loads them in that order, then `plugin.rb`, into one namespace, so a part reopens `class Plugin` and a class body uses only what an earlier part defines; never `require_relative` one ([plugins.md](plugins.md#a-plugin-in-several-files)).
|
|
61
|
+
(`[greeting]`, or `{greeting: string}`): a typo there then warns. `chi bundle check --set KEY=VALUE` gives the sandboxed load a setting. A bundle can also draw a fenced block in chi web's answers, with no plugin code: `block_renderers:` and a script calling `chi.defineRenderer` ([plugins.md](plugins.md#block-renderers)); and ship a page: `pages:` naming a page script in `scripts:` ([plugins.md](plugins.md#pages)). A plugin that outgrows one file lists its other top-level `.rb` files under `plugin: parts:` (`client.rb: sha256:`, at most 16; `check --fix` fills the shas, and warns of a top-level `.rb` they don't list): chi loads them in that order, then `plugin.rb`, into one namespace, so a part reopens `class Plugin` and a class body uses only what an earlier part defines; never `require_relative` one ([plugins.md](plugins.md#a-plugin-in-several-files)).
|
|
62
62
|
|
|
63
63
|
## What a hook sees
|
|
64
64
|
|