samagotchi 0.178.0 → 0.179.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 +28 -1
- data/docs/architecture.md +4 -2
- data/docs/bundles.md +16 -7
- data/docs/cli.md +3 -1
- data/docs/context.md +25 -1
- data/docs/guardrails.md +2 -1
- data/docs/internals/attached-context.md +26 -4
- data/docs/internals/background-tasks.md +3 -0
- data/docs/internals/block-renderers.md +2 -2
- data/docs/internals/bridge.md +11 -2
- data/docs/internals/bundles.md +63 -34
- data/docs/internals/engine.md +1 -1
- data/docs/internals/web-frontend.md +18 -1
- data/docs/plugins.md +14 -3
- data/docs/releasing.md +3 -3
- data/docs/scheduling.md +4 -0
- data/docs/sessions.md +8 -2
- data/docs/testing.md +4 -1
- data/lib/samagotchi/block_renderers.rb +12 -14
- data/lib/samagotchi/bootstrap/bundles.rb +2 -2
- data/lib/samagotchi/bootstrap_command.rb +1 -1
- data/lib/samagotchi/bridge/card_wait.rb +34 -0
- data/lib/samagotchi/bridge/turn_accumulator.rb +22 -4
- data/lib/samagotchi/bundle_command/check.rb +10 -10
- data/lib/samagotchi/bundle_command/installed_check.rb +2 -2
- data/lib/samagotchi/bundle_command/try/sandbox.rb +3 -3
- data/lib/samagotchi/bundle_command.rb +17 -17
- data/lib/samagotchi/bundle_manifest.rb +579 -0
- data/lib/samagotchi/bundle_needs.rb +9 -8
- data/lib/samagotchi/bundle_settings_check.rb +9 -8
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +5 -3
- data/lib/samagotchi/bundles/claude-peer/plugin.rb +4 -4
- data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +11 -6
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +5 -3
- data/lib/samagotchi/bundles/codex-peer/plugin.rb +4 -3
- data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +11 -6
- data/lib/samagotchi/bundles/system/manifest.yml +2 -2
- data/lib/samagotchi/bundles/system/memory_guide.md +1 -1
- data/lib/samagotchi/config.rb +2 -2
- data/lib/samagotchi/context_absorber.rb +36 -6
- data/lib/samagotchi/context_note.rb +8 -5
- data/lib/samagotchi/context_providers.rb +30 -27
- data/lib/samagotchi/context_sources.rb +42 -12
- data/lib/samagotchi/engine/messages.rb +1 -1
- data/lib/samagotchi/events.rb +6 -5
- data/lib/samagotchi/guardrail_wiring.rb +20 -21
- data/lib/samagotchi/guardrails/approval.rb +3 -2
- data/lib/samagotchi/guardrails/outside.rb +3 -3
- data/lib/samagotchi/{memory_bundle → installed_bundles}/bundle_hook.rb +1 -1
- data/lib/samagotchi/installed_bundles/dir.rb +129 -0
- data/lib/samagotchi/{memory_bundle → installed_bundles}/file_digest.rb +1 -1
- data/lib/samagotchi/{memory_bundle → installed_bundles}/file_standing.rb +2 -2
- data/lib/samagotchi/{memory_bundle/installed_manifest.rb → installed_bundles/manifest.rb} +21 -21
- data/lib/samagotchi/{memory_bundle → installed_bundles}/plugin_ref.rb +2 -2
- data/lib/samagotchi/{memory_bundle/installed_bundle.rb → installed_bundles/record.rb} +17 -17
- data/lib/samagotchi/installed_bundles/sha.rb +41 -0
- data/lib/samagotchi/installed_bundles/standing.rb +45 -0
- data/lib/samagotchi/installed_bundles.rb +90 -0
- data/lib/samagotchi/memory_bundle/asset_installer.rb +7 -7
- data/lib/samagotchi/memory_bundle/builder.rb +13 -13
- data/lib/samagotchi/memory_bundle/file_state.rb +9 -9
- data/lib/samagotchi/memory_bundle/installed_copy.rb +6 -6
- data/lib/samagotchi/memory_bundle/installer.rb +33 -33
- data/lib/samagotchi/memory_bundle/listing.rb +5 -5
- data/lib/samagotchi/memory_bundle/manifest_standing.rb +7 -7
- data/lib/samagotchi/memory_bundle/merger.rb +15 -15
- data/lib/samagotchi/memory_bundle/profile.rb +8 -8
- data/lib/samagotchi/memory_bundle/provenance.rb +59 -192
- data/lib/samagotchi/memory_bundle/remerge.rb +16 -16
- data/lib/samagotchi/memory_bundle/shas.rb +2 -2
- data/lib/samagotchi/memory_bundle/shipped_history.rb +1 -1
- data/lib/samagotchi/memory_bundle/shipped_update.rb +17 -17
- data/lib/samagotchi/memory_bundle/status.rb +15 -15
- data/lib/samagotchi/memory_bundle/system_bundle.rb +12 -12
- data/lib/samagotchi/memory_bundle/trash.rb +2 -2
- data/lib/samagotchi/memory_bundle/uninstaller.rb +8 -8
- data/lib/samagotchi/memory_bundle.rb +2 -2
- data/lib/samagotchi/memory_command.rb +4 -4
- data/lib/samagotchi/{memory_bundle → memory_index}/entry_size.rb +8 -8
- data/lib/samagotchi/{memory_bundle/index_size.rb → memory_index/size.rb} +6 -6
- data/lib/samagotchi/{memory_bundle/index_sync.rb → memory_index/sync.rb} +5 -5
- data/lib/samagotchi/{memory_bundle/index_updater.rb → memory_index/updater.rb} +2 -2
- data/lib/samagotchi/memory_usage.rb +5 -5
- data/lib/samagotchi/muted_memories.rb +1 -1
- data/lib/samagotchi/peer_exchanges.rb +76 -0
- data/lib/samagotchi/plugin/context.rb +4 -0
- data/lib/samagotchi/plugin/loader.rb +35 -33
- data/lib/samagotchi/plugin/peer.rb +42 -11
- data/lib/samagotchi/project_subfolders.rb +9 -9
- data/lib/samagotchi/reply_wait/target.rb +11 -4
- data/lib/samagotchi/self_report.rb +14 -14
- data/lib/samagotchi/session_access/local.rb +16 -1
- data/lib/samagotchi/session_access/remote.rb +2 -1
- data/lib/samagotchi/session_config.rb +23 -19
- data/lib/samagotchi/session_manager/running_tasks.rb +15 -2
- data/lib/samagotchi/session_retention.rb +13 -4
- data/lib/samagotchi/session_stores.rb +3 -0
- data/lib/samagotchi/system_prompt.rb +4 -4
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +5 -1
- data/lib/samagotchi/terminal_ui/formatting.rb +2 -2
- data/lib/samagotchi/terminal_ui/model_segments_text.rb +5 -5
- data/lib/samagotchi/terminal_ui.rb +4 -1
- data/lib/samagotchi/testing/bundle.rb +3 -3
- data/lib/samagotchi/testing/install.rb +3 -3
- data/lib/samagotchi/testing/sandbox.rb +2 -2
- data/lib/samagotchi/tool_runner.rb +14 -14
- data/lib/samagotchi/tools/memory.rb +22 -22
- data/lib/samagotchi/update_command.rb +4 -4
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +14 -1
- data/lib/samagotchi/web/message_display.rb +6 -0
- data/lib/samagotchi/web/participant_view.rb +1 -1
- data/lib/samagotchi/web/proxy_gate.rb +1 -0
- data/lib/samagotchi/web/public/card_kinds.js +8 -3
- data/lib/samagotchi/web/public/cards_place.js +15 -1
- data/lib/samagotchi/web/public/ctx.js +1 -1
- data/lib/samagotchi/web/public/history_shape.js +3 -0
- data/lib/samagotchi/web/public/turn_block.js +46 -8
- data/lib/samagotchi/web/public/turn_settle.js +117 -0
- data/lib/samagotchi/web/push/notifier.rb +2 -2
- data/lib/samagotchi/web/session_access_routes.rb +21 -1
- data/lib/samagotchi/web/session_hub.rb +20 -4
- data/lib/samagotchi/worker_boot.rb +4 -1
- metadata +19 -12
- data/lib/samagotchi/memory_bundle/manifest.rb +0 -581
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02c5f9b0ce43fa25f771a11ec298032ffa639b9423f5df2e934b376eef808327
|
|
4
|
+
data.tar.gz: 0ff81b27a6bea746ecc98735a23e6cff79db33abcba48684cad5421177cebe73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: abc693ecff041c7c142742487336cd34b16e6738a260a240e3f4194a841fea77bc752ff613d2322ad850f94c0e23fe49034b4765485385d3cb46dba96f2948ea
|
|
7
|
+
data.tar.gz: b7ad5b7323b35f7e748fbe0349f84ccdf2c046691cff8f1ac298369ca741ef0198873a1c7f25ec1cb49835277f8adb54b30e683db72fa027ca823d3e10b20163
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,32 @@ and commands may change between minor versions. How releases are made:
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.179.0] - 2026-11-20
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- A peer's answer names the send it answers: claude-peer and codex-peer messages carry a `ref:` line, the peers'
|
|
16
|
+
chi-peer skills give it back as `re` in their reply (reinstall the skill with `/claude install-skill` or
|
|
17
|
+
`/codex install-skill`), and chi keeps it on the answer's note and the send's row for the web to tie them. The
|
|
18
|
+
model reads the same text as before; an older skill's answer works as before, unlinked.
|
|
19
|
+
- A per-session peer exchange log records sends, transport failures and answer summaries for the owner's web view,
|
|
20
|
+
without storing answer texts.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- The retention sweep, and a `chi scratch` session's cleanup, stop the background tasks a deleted session started
|
|
25
|
+
(logged per task); the sweep now runs off chi web's session list lock.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- A guardrail plugin (`plugin: required: true`) whose bundle's manifest.json doesn't read now denies tool calls,
|
|
30
|
+
as its rules would, instead of only being reported.
|
|
31
|
+
- A reloaded turn keeps an answered question and an asking card (check-in's) in the order they showed live: a card
|
|
32
|
+
that stopped asking mid-turn no longer moves back into its first step, and one still asking no longer jumps above
|
|
33
|
+
the question answered after it.
|
|
34
|
+
|
|
35
|
+
Update with `chi update`.
|
|
36
|
+
|
|
11
37
|
## [0.178.0] - 2026-11-20
|
|
12
38
|
|
|
13
39
|
### Changed
|
|
@@ -6521,7 +6547,8 @@ and long-lived sessions.
|
|
|
6521
6547
|
- A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
|
|
6522
6548
|
hotkey panel that send selected text or the clipboard to your sessions.
|
|
6523
6549
|
|
|
6524
|
-
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.
|
|
6550
|
+
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.179.0...HEAD
|
|
6551
|
+
[0.179.0]: https://github.com/dm1try/samagotchi/compare/v0.178.0...v0.179.0
|
|
6525
6552
|
[0.178.0]: https://github.com/dm1try/samagotchi/compare/v0.177.1...v0.178.0
|
|
6526
6553
|
[0.177.1]: https://github.com/dm1try/samagotchi/compare/v0.177.0...v0.177.1
|
|
6527
6554
|
[0.177.0]: https://github.com/dm1try/samagotchi/compare/v0.176.0...v0.177.0
|
data/docs/architecture.md
CHANGED
|
@@ -504,7 +504,8 @@ model: [internals/remote-sessions.md](internals/remote-sessions.md).
|
|
|
504
504
|
| `POST /api/sessions/:id/wait` | owner | `cursor`, `baseline`, `turn`, `queued`, `ended_before`, `owner_grace`, `timeout` (capped at 30 s) | 200: `ReplyWait::Result`'s fields (`status`: `done`, `waiting_for_answer`, `no_reply`, `error`, `stopped`, `worker_gone`, or `timeout`: ask again; `text`, `file`, `question` as `PendingQuestion#to_file`, `outcome`, `limit`, `error_kind`, `retryable`, `cancel_reason`, `stopped_by`, `kept_steps`, `turn_id`, `origin`; never the session) and `parent_strategy` `{name, allowed, origin}` (`ParentReport.strategy_for`, this server's config.yml) | 400 `invalid_wait`; 503 `server_stopping` |
|
|
505
505
|
| `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` |
|
|
506
506
|
| `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` |
|
|
507
|
-
| `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` |
|
|
507
|
+
| `POST /api/sessions/:id/context/:name/push` | owner | `text`, `summary`, `wake`, `hint`, `re` (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` |
|
|
508
|
+
| `GET /api/sessions/:id/peers` | owner | | 200 `{peers: [{name, label, inbox, outbox, exchanges}]}`: last 20 joined exchanges per peer, newest first; files only | 404 `not_found` |
|
|
508
509
|
| `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 |
|
|
509
510
|
| `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` |
|
|
510
511
|
| `DELETE /api/sessions/:id?force=` | owner | `force=true` stops a live worker first (the page sends it) | as before | 409 `worker_running` without it |
|
|
@@ -655,7 +656,8 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
|
|
|
655
656
|
| Session lifecycle | `session_manager/`, `worker_boot.rb`, the session sidecar files | Marker writers, derived states, lock order, crash repair and the known open windows are mapped in [Session lifecycle](internals/session-lifecycle.md). |
|
|
656
657
|
| Config | `config.rb`, `config/restart_watch.rb` | Every setting as an `Entry`: env, config.yml and CLI layers ([configuration.md](configuration.md)); the notice a worker or chi web gets when config.yml changes a setting it reads only at its start. With `log.rb` it is the bottom layer: nothing it references reaches back to it, so `hosts:` and `models:` entries parse next to their types (`HostConfig.all`, `ModelSettings.all`). |
|
|
657
658
|
| Paths | `paths.rb` (`Paths`) | The XDG base dirs chi's files live under, read from the env on every call: `Paths.state_home` (`$XDG_STATE_HOME`, else `~/.local/state`) and `Paths.config_home` (`$XDG_CONFIG_HOME`, else `~/.config`), both defaults under `Dir.home`; a blank variable counts as unset, a relative one is made absolute from the current directory. `Paths.tilde` shows a path with `~` for the home folder. `SessionManager` hands a spawned worker the spawner's `XDG_STATE_HOME` / `XDG_CONFIG_HOME`, when set, made absolute, so a relative one isn't read from the session's folder. |
|
|
658
|
-
| MemoryBundle | `memory_bundle.rb`, `memory_bundle/{installer,builder,
|
|
659
|
+
| MemoryBundle | `memory_bundle.rb`, `memory_bundle/{installer,builder,provenance,uninstaller,status}.rb` (`Installer`, `Builder`, `Provenance`…) | Installing, upgrading, building and removing bundles of memories, rules, plugins and scripts ([internals/bundles.md](internals/bundles.md)). |
|
|
660
|
+
| Installed bundles | `installed_bundles.rb`, `installed_bundles/{record,manifest,dir,sha,plugin_ref,bundle_hook}.rb` (`InstalledBundles`, `Record`, `Manifest`, `Dir`, `Sha`, `PluginRef`, `BundleHook`) | What is installed, as the runtime reads it: the records, their manifests, one bundle's folder, the shas its files are checked against (`BundleHook`: an older record's retired class-file hook). `bundle_manifest.rb` (`BundleManifest`) is the `manifest.yml` format. |
|
|
659
661
|
| Bundle authoring | `bundle_command.rb` (`BundleCommand`), `bundle_command/{scaffold,check,test_run}.rb`, `bundle_command/try/{run,sandbox,trace}.rb`, `testing.rb` + `testing/` (the test kit) | `chi bundle new`, `check`, `test` and `try`, and the kit a bundle's tests load it with ([bundle-authoring.md](bundle-authoring.md), [internals/bundles.md](internals/bundles.md)). |
|
|
660
662
|
| 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). |
|
|
661
663
|
| 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). |
|
data/docs/bundles.md
CHANGED
|
@@ -1008,13 +1008,20 @@ Claude pairs; without one the bundle costs one tool declaration.
|
|
|
1008
1008
|
refreshes it) and `claude-outbox`, and lists the session's context. A
|
|
1009
1009
|
re-pair keeps Claude's last answer.
|
|
1010
1010
|
3. Claude answers a validate or a question with a JSON push to
|
|
1011
|
-
`claude-outbox` (`text`, `summary`, `wake: true
|
|
1012
|
-
|
|
1013
|
-
|
|
1011
|
+
`claude-outbox` (`text`, `summary`, `wake: true`, and `re`: the `ref:`
|
|
1012
|
+
line of the message it answers), which wakes chi, the first answer too
|
|
1013
|
+
(on chi 0.62 the first one arrives as a note without waking); the model
|
|
1014
|
+
reads it with `context_read claude-outbox`. In chi's own records the
|
|
1015
|
+
answer's note names the send (`re`); an older skill's answer has none and
|
|
1016
|
+
works as before. The session's peer exchange log keeps sends and answer
|
|
1017
|
+
summaries, not answer texts; a new pairing starts a new log.
|
|
1014
1018
|
- **The tool `claude_send(kind, title, text)`**, `kind` being `validate`,
|
|
1015
1019
|
`context` or `question`, writes one JSON line to that socket. The message
|
|
1016
|
-
starts with a header, `chi <id> · <kind> · <title
|
|
1017
|
-
|
|
1020
|
+
starts with a header, `chi <id> · <kind> · <title>`, and a second line,
|
|
1021
|
+
`ref: <send id>` (`s-` and 6 hex, from the kind, title and text as given:
|
|
1022
|
+
the same part sent again has the same id), which Claude's answer gives back
|
|
1023
|
+
so chi can tie it to its send; the tool's row in the web carries the id too.
|
|
1024
|
+
A text up to 4,000 characters follows inline; a longer one goes to a file,
|
|
1018
1025
|
`$XDG_STATE_HOME/samagotchi/plugins/claude-peer/sessions/<id>/<HHMMSS>-<slug>.md`
|
|
1019
1026
|
(removed with the session), and the message names it (`payload: <path>`).
|
|
1020
1027
|
The tool is declared whether or not a Claude is paired, so pairing doesn't
|
|
@@ -1195,8 +1202,10 @@ skill install card) works the same.
|
|
|
1195
1202
|
`sh <bundle>/scripts/pair` attaches `codex-inbox` (the thread id as its
|
|
1196
1203
|
hint, pushed so a re-pair refreshes it) and `codex-outbox`. Run outside
|
|
1197
1204
|
Codex (no `CODEX_THREAD_ID`) it refuses. Codex replies with one JSON push
|
|
1198
|
-
to `codex-outbox` (`text`, `summary`, `wake: true`
|
|
1199
|
-
first answer too (that needs chi 0.63.0; the bundle's
|
|
1205
|
+
to `codex-outbox` (`text`, `summary`, `wake: true`, `re`: the message's `ref:`
|
|
1206
|
+
line), which wakes chi, the first answer too (that needs chi 0.63.0; the bundle's
|
|
1207
|
+
`requires_chi` is `>= 0.70.0`). The session's peer exchange log keeps sends
|
|
1208
|
+
and answer summaries, not answer texts.
|
|
1200
1209
|
- **Peer messages are user turns in Codex.** Claude Code marks an inbox
|
|
1201
1210
|
message as from another session; `codex queue` lands as a plain user
|
|
1202
1211
|
message. So Codex's skill starts with the rule: a message whose first line
|
data/docs/cli.md
CHANGED
|
@@ -156,7 +156,7 @@ The loop for a bundle you're writing (the whole path: [bundle-authoring.md](bund
|
|
|
156
156
|
chi reads the key from it with no reinstall, and `chi update`'s re-check names it too), `requires-chi` (this chi doesn't satisfy it:
|
|
157
157
|
error; missing on a bundle with code: warn), `requires-chi-floor` (warn: the plugin calls an API newer than the
|
|
158
158
|
oldest chi `requires_chi` admits, from `Plugin::Api::SINCE`, or the manifest itself uses a key newer than it, from
|
|
159
|
-
`
|
|
159
|
+
`BundleManifest::SINCE`; an installed bundle gets the unknown-key row but never the floor, as it's the author's fix),
|
|
160
160
|
`trust` (warn: `trust_level: reviewed|trusted` on a
|
|
161
161
|
bundle chi doesn't ship), `clash` (warn: a name chi ships, or one installed from elsewhere; the sandboxed install
|
|
162
162
|
then forces), `install` (each Installer warning, a `needs` one as warn, and each plugin load failure at
|
|
@@ -596,6 +596,8 @@ refused. Its first line says it is a scratch session.
|
|
|
596
596
|
session (`Scratch session deleted.`). `/archive` is refused. The lines typed
|
|
597
597
|
are not added to the prompt history. With `-p … --non-interactive` it is one
|
|
598
598
|
turn in this process, and the session is deleted as the run ends.
|
|
599
|
+
- Cleanup stops the background tasks it started when their process identity can
|
|
600
|
+
be verified; unverifiable or unreadable tasks are left alone and logged.
|
|
599
601
|
- The worker deletes the session too once its terminal is gone (no terminal
|
|
600
602
|
stream left for about 28 s, twice the terminal's reconnect retries, so a
|
|
601
603
|
dropped stream that reconnects keeps it; or none came within 30 s), so a
|
data/docs/context.md
CHANGED
|
@@ -56,7 +56,10 @@ Its output is either:
|
|
|
56
56
|
```
|
|
57
57
|
`summary` (one line, up to 200 characters) goes into the update note;
|
|
58
58
|
`wake: true` asks for a turn ([Waking](#waking)); `hint` replaces the
|
|
59
|
-
source's hint until a later output gives another.
|
|
59
|
+
source's hint until a later output gives another. `re` (optional: a peer's
|
|
60
|
+
answer naming the send it answers, [Peer sources](#peer-sources-the-peer-loop))
|
|
61
|
+
is kept with the revision when it is a short id (`a-z`, `0-9`, `-`, up to 32),
|
|
62
|
+
else dropped; a revision without one clears it. Unknown keys are ignored.
|
|
60
63
|
|
|
61
64
|
A non-zero exit, a timeout, more than 1 MiB or empty output is a failed
|
|
62
65
|
fetch: the last good text stays, and the agent hears once, at the first
|
|
@@ -326,6 +329,20 @@ lower.) Every other source keeps the line above. `context.peer_turns: 0` turns
|
|
|
326
329
|
the loop off: a peer source then wakes like any other. `context_read` names a
|
|
327
330
|
peer source in its header (`Peer: your peer agent Codex's answers …`).
|
|
328
331
|
|
|
332
|
+
Each message chi sends a peer carries a `ref: <id>` line, and the peer's
|
|
333
|
+
answer gives it back as `re` ([the contract](#the-command-contract)). The
|
|
334
|
+
answer's note keeps whose answer it is (the peer, `re`, its summary and
|
|
335
|
+
verdict) for the web to tie it to its send; the model's note reads as it
|
|
336
|
+
did. That holds for a declared peer source, with the loop on or off.
|
|
337
|
+
|
|
338
|
+
**Outside the worker it is by name.** chi web and the CLI load no plugins,
|
|
339
|
+
so where they show a pairing (a context row's `peer`, `leg` and `label`) a
|
|
340
|
+
pushed source of the session's own named `<word>-inbox` or `<word>-outbox` is
|
|
341
|
+
taken for one: `review-outbox` gets a peer chip too, and changed pushes to it
|
|
342
|
+
are logged as answers. That is display and logging only:
|
|
343
|
+
what is a peer's answer, and what may wake chi and how, is still the bundle's
|
|
344
|
+
declaration in the worker, as above.
|
|
345
|
+
|
|
329
346
|
## Movable context
|
|
330
347
|
|
|
331
348
|
A session's own sources go with it to the next session of its work: the next
|
|
@@ -690,5 +707,12 @@ The candidates' log, `context_candidates.jsonl`, sits one level up, beside
|
|
|
690
707
|
the sessions folder (`$XDG_STATE_HOME/samagotchi/`; see
|
|
691
708
|
[The log and the report](#the-log-and-the-report)).
|
|
692
709
|
|
|
710
|
+
Peer exchange metadata lives separately in the session sidecar at
|
|
711
|
+
`$XDG_STATE_HOME/samagotchi/sessions/<id>/peer_exchanges.jsonl`. It records
|
|
712
|
+
sends, transport failures and answer summaries, not answer text. It is
|
|
713
|
+
append-only and uncapped; a continue starts a new log with its new pairing.
|
|
714
|
+
An unchanged text is not a new revision, even if its `re` changes, so it
|
|
715
|
+
does not add an answer to the log.
|
|
716
|
+
|
|
693
717
|
Deleting a session deletes its folder. A source and its snapshot go with
|
|
694
718
|
`chi context rm`; its `.lock` stays (a fetch may still hold it).
|
data/docs/guardrails.md
CHANGED
|
@@ -1452,7 +1452,8 @@ else goes to chi's own rules. It needs nah installed; see its README for the set
|
|
|
1452
1452
|
(`plugin:` `required: true`, for a `chi.on(:before_tool_call, on_error:
|
|
1453
1453
|
:fail_closed)` guard, chi 0.157.0 or newer, [plugins.md](plugins.md#a-guard-that-fails-closed-on_error-fail_closed)),
|
|
1454
1454
|
that fails to load (missing, syntax error, an unmet `requires_chi`, or for a
|
|
1455
|
-
plugin a sha256 that differs from the installed one
|
|
1455
|
+
plugin a sha256 that differs from the installed one, or its bundle's
|
|
1456
|
+
manifest.json that doesn't read) makes chi deny
|
|
1456
1457
|
every tool call. (An older chi's class-file bundle hooks don't load at all,
|
|
1457
1458
|
`fail_closed` or not, [hooks.md](hooks.md#class-file-hooks-are-retired).) A fail-closed hook that raises when called denies that call.
|
|
1458
1459
|
- Other hooks stay fail-open; a load failure is a warning.
|
|
@@ -47,7 +47,7 @@ comment is the file map and [../context.md](../context.md#storage) lists it for
|
|
|
47
47
|
- **Records** (`Data`/value objects): `Source` (definition; `cmd` nil = pushed; `movable` nil derives from
|
|
48
48
|
`push?`), `Snapshot` (last good text, `revision` = SHA-256 of the text, `serial` counting revisions, `error` and
|
|
49
49
|
`error_since`, `wake_serial` = the newest revision that asked to wake, `fetched_at` last success, `checked_at` last
|
|
50
|
-
try), `Subscription` (what one session has had: `seen`/`seen_serial`, `read`, `error_seen`, `wakes_at`),
|
|
50
|
+
try, `re` = the send a peer's answer names, with the revision: nil for none, an older snapshot's too), `Subscription` (what one session has had: `seen`/`seen_serial`, `read`, `error_seen`, `wakes_at`),
|
|
51
51
|
`Candidate`, `Left`, `Moved`/`Stayed`.
|
|
52
52
|
- **Locations.** A `Location` is a folder of sources: a project's (`projects/<project_key>/`, shared by the
|
|
53
53
|
project's workers) or a session's (`sessions/<id>/`, which also holds `subscriptions.json`, the `muted/` and
|
|
@@ -61,8 +61,12 @@ comment is the file map and [../context.md](../context.md#storage) lists it for
|
|
|
61
61
|
still running finds its source gone (`ContextFetch` then writes nothing). Removing a *session* source leaves a
|
|
62
62
|
`declined/<name>` marker (hint inside), which is what stops an auto-attach from bringing it back.
|
|
63
63
|
- **The output contract** is `ContextSources.parse_output` (JSON object with a string `text` is
|
|
64
|
-
`{text, summary, wake, hint}`; anything else is all text; empty or over `TEXT_MAX_BYTES` is `Invalid`), the same for
|
|
65
|
-
a command's stdout and a push. `
|
|
64
|
+
`{text, summary, wake, hint, re}`; anything else is all text; empty or over `TEXT_MAX_BYTES` is `Invalid`), the same for
|
|
65
|
+
a command's stdout and a push. `re` is kept only as a String of `RE_RE`, including when a snapshot is reloaded;
|
|
66
|
+
malformed non-null refs are debug-logged without the answer. `Fetched` and `Snapshot` default `re:` to
|
|
67
|
+
nil, so a caller (a spec, a bundle's) that builds them without it keeps working; the push carries it in three seats
|
|
68
|
+
that change together: `parse_output`, chi web's push route (`SessionAccessRoutes#handle_context_push`'s slice) and
|
|
69
|
+
`SessionAccess::Remote#context_push`'s body (an older chi web drops it: the answer arrives unlinked). `ContextProviders` resolves a URL to a command source from an installed bundle's
|
|
66
70
|
manifest `context_providers:` (read from its provenance, so the CLI and chi web resolve without loading plugins);
|
|
67
71
|
`{url}` is filled at attach, `{bundle_dir}` and `{ruby}` when the command runs.
|
|
68
72
|
- **Protected.** The root is a `ProtectedPaths` entry: the file tools cannot write it, because a source's command
|
|
@@ -117,6 +121,23 @@ as a peer's answers; `peer_label` then needs `context.peer_turns` > 0. A peer de
|
|
|
117
121
|
budget is `WorkerWakes#peer_open?` (reset only by typed input), and an answer whose summary ends in `VERDICT OK`
|
|
118
122
|
(`peer_agrees?`) wakes once with the closing line, counted toward `session.max_wakes` only.
|
|
119
123
|
|
|
124
|
+
**Whose answer a note is.** A text note (and its wake note) of a source `PeerSources` marks as a peer's (`peer_name`:
|
|
125
|
+
a pushed source of the session's own that a loaded bundle declared; *not* gated on `context.peer_turns`, and nil for an
|
|
126
|
+
absorber built without peer sources, `ContextCandidates.deliver_notes`') carries `peer: {peer, label, re, summary, serial,
|
|
127
|
+
verdict, agreed}` (`peer_note`; string keys, nils dropped): `re` the snapshot's, `verdict` the summary's last
|
|
128
|
+
`VERDICT` match when one of `VERDICTS`, `agreed` `peer_agrees?` directly. It is display data, as `objectives` is:
|
|
129
|
+
`ContextNote::KEYS` keeps it (the key-by-key copier is `ChatLoop#plain`), `:context_added` carries it, the reload's note
|
|
130
|
+
items (`Web::MessageDisplay`) carry it with `context_source`, and no wire sends it (role and content only), so the
|
|
131
|
+
note's content, what the model reads, is the same byte for byte. `peer_label` and `Delivery#peer` keep deciding the
|
|
132
|
+
wakes.
|
|
133
|
+
|
|
134
|
+
**Exchange log.** `Plugin::Peer` appends successful sends and transport failures;
|
|
135
|
+
`SessionAccess::Local#context_push` appends changed session outbox answers under the
|
|
136
|
+
source lock, without nesting another lock. Appending failure is logged and does not
|
|
137
|
+
fail a send or push. `PeerExchanges` joins by time and ref, falling back to the
|
|
138
|
+
latest unanswered validate or question for an old skill. An owner-only chi web
|
|
139
|
+
route reads it without a worker; no event or model-visible text changes.
|
|
140
|
+
|
|
120
141
|
## Candidates
|
|
121
142
|
|
|
122
143
|
`ContextCandidates` holds a session's proposed sources (`Candidate`, from `ctx.context.propose`, stored under
|
|
@@ -221,12 +242,13 @@ Keys, all in [../configuration.md](../configuration.md): `context.every_seconds`
|
|
|
221
242
|
| File | Written by | Read by |
|
|
222
243
|
|---|---|---|
|
|
223
244
|
| `context/{projects/<key>,sessions/<id>}/<name>.json` | `chi context add`, a provider, a plugin (`ctx.context.attach`), `ContextCandidates.attach`, `ContextMove` | poller, absorber, `context_read`, chi web |
|
|
224
|
-
| `<name>.snapshot.json` | `ContextFetch`, `chi context push`, `ContextMove` | absorber, `context_read`, chi web chips |
|
|
245
|
+
| `<name>.snapshot.json` (a push's `re` too) | `ContextFetch`, `chi context push`, `ContextMove` | absorber, `context_read`, chi web chips |
|
|
225
246
|
| `<name>.lock` | `ContextFetch` / `Location#locked` | same |
|
|
226
247
|
| `sessions/<id>/subscriptions.json` | the worker (`commit`, `context_read`) only | absorber, chi web (unread dot) |
|
|
227
248
|
| `sessions/<id>/{muted,declined}/<name>` | `chi context mute`, a removal, `ContextMove` | poller, absorber, candidates |
|
|
228
249
|
| `sessions/<id>/candidates/<name>.json` | `ctx.context.propose` | candidates, judge, `/context` |
|
|
229
250
|
| `sessions/<id>/left.json` | `ContextMove` (continue) | `ctx.context.left_behind` |
|
|
230
251
|
| `context_candidates.jsonl` (beside `sessions/`) | `ContextCandidatesLog` | judge (`due?`), choice (`carded?`), `chi context report` |
|
|
252
|
+
| `sessions/<id>/peer_exchanges.jsonl` (session sidecar, not context root) | `Plugin::Peer`, `SessionAccess::Local` | `GET /api/sessions/:id/peers` |
|
|
231
253
|
|
|
232
254
|
Specs: `spec/context_*_spec.rb`; a store under test uses an isolated `XDG_STATE_HOME`.
|
|
@@ -56,6 +56,9 @@ Behavior:
|
|
|
56
56
|
read, so chi web and the CLI run `stop_task` from their own cwd; without a root every path is the relative one. A
|
|
57
57
|
thread the block starts doesn't inherit it (only `create_task` starts waiters, and nothing calls it under a root).
|
|
58
58
|
See [sessions.md](../sessions.md) (Deleting a session).
|
|
59
|
+
- Retention and scratch cleanup use the same rule without asking: verified tasks stopped by them record
|
|
60
|
+
`stopped_by_retention` or `stopped_by_scratch`, not `stopped_by_user`. Unverified and unreadable tasks are not
|
|
61
|
+
signalled and are logged as not stopped. Schedule prune leaves tasks running.
|
|
59
62
|
- A stop of an `execute` (the user's Stop, the limit in kill mode) is done once the shell is reaped and nothing holds the logs: a child that ignores TERM after its shell died gets the KILL.
|
|
60
63
|
- A command still running at `execute.timeout_sec` is handed over as a task (`execute.on_timeout: task`, the default; `kill` stops it instead, and the `!cmd` bang always kills): the result starts `Still running at the 120s limit: moved to a background task, not killed.`, then `task_id: …` and the tails of both logs so far. A command is also handed over early when a person's message waits for the turn's next step (the `message_waiting:` probe, the same `Engine#input_waiting?` as `task_wait`'s): after `Execute::EARLY_HAND_OVER_FLOOR_SEC` (3 s: a short command ends first and its result is the better answer), in the next 0.2 s slice. The first line then reads `Still running at the 4s mark: a message from the user is waiting, so the command moved to a background task, not killed.` (the seconds it had run), and the line after `task_id:` starts `Read the message first.`; the rest is the same hand-over, and the task stays watched. Never in `kill` mode (`execute.on_timeout: kill`, a participant's pair turn, the `!cmd` bang): there the probe is not even read and the command runs to its limit and is killed. A command that can't be adopted at that moment (a record that can't be written) isn't killed early: it runs on to its limit. Everything that matches the first line builds on `Execute::HANDED_OVER` (`Still running at the`) and `Execute::HANDED_OVER_AFTER` (both defined in `ToolNames::Execute`) (`120s limit:` or `4s mark:`): `TaskTranscript.handed_over_id`, `ToolActivity::HANDED_OVER_START`, `TaskWatch` (`limit_sec` for the limit's form, `early_sec` for the mark's, which the finish note words as `handed over by execute after 4s: a message from the user was waiting`) and the web's `task_stop.js`; the slow-commands bundle reads only the limit's form, which is the only one that is a timeout. A timeout during the 1.5 s background grace is a kill (the shell is gone, nothing to hand over). If the record can't be written, the command is killed. `TaskRuntime.adopt` writes a record for the process execute already started, with `handed_over_by: "execute"`. Its logs stay where execute wrote them, so the record's paths are absolute: `output_path` (stdout), `stderr_path` (stderr, a log of its own) and `exit_code_path` (a `task_create` record's `exit_code_path` is absolute too; its `output_path` is relative). `started_at` (and `created_at`) is the spawn time, not the hand-over's; `pid_started` is read at the hand-over, while execute's detach waiter is still running. From there it is an ordinary task: `task_wait`, `task_get`, `task_list` and `task_stop` treat it as any other. Its dir gets a `task` back-pointer file holding the record's absolute path. Once per process, the first `execute` sweeps `…/execute/`: a dir whose logs no process holds is removed when it has no back-pointer and is a day old (chi died mid-command), when its record is gone, or when it is 14 days old. The records live in each project's `tmp/tasks`, which the state dir can't list: hence the back-pointer.
|
|
61
64
|
- `task_wait` and `task_get` show `stderr_path` when the record has one; `task_wait`'s output tail is followed by a `stderr_tail:` of at most 10 lines when that log isn't empty. A `task_create` task has one log (stdout and stderr together) and no `stderr_path`. A `task_wait` result longer than `max_tool_output_chars` keeps its header and the tail's end, with a gap line naming `output_path`, where the whole log already is (and `stderr_path`, when the record has one) (`ToolOutputCut`'s `:head_tail_ref`; nothing is copied; see [Tool output guardrails](tool-output-limits.md#the-runners-cut-max_tool_output_chars)).
|
|
@@ -10,12 +10,12 @@ model. The TUI is untouched: it shows a fence as source.
|
|
|
10
10
|
in document order and zips them with the fragment's `<pre>`s, setting `data-lang` after sanitize's walk. Only the first
|
|
11
11
|
word, downcased, matching `BlockRenderers::LANG`. A count that differs sets nothing. **`web.markdown` off means no
|
|
12
12
|
`<pre data-lang>`, so nothing draws.**
|
|
13
|
-
2. `BlockRenderers.for_installed` (manifest `block_renderers:`, read through `
|
|
13
|
+
2. `BlockRenderers.for_installed` (manifest `block_renderers:`, read through `InstalledBundles::Record#manifest`: the bundle's
|
|
14
14
|
kept `manifest.yml`, else its record's mirror, so chi web needs no plugins, and a bundle installed by a chi that
|
|
15
15
|
didn't know the key draws once a kept manifest is there) lists
|
|
16
16
|
who draws what: `GET /api/block_renderers`, `:owner`. `GET /api/block_renderers/:bundle/:file` serves a file, `:owner`:
|
|
17
17
|
the URL's names go through `BlockRenderers.script_path` (membership in a listed renderer's `load` before any path is
|
|
18
|
-
made), then `
|
|
18
|
+
made), then `InstalledBundles::Dir#file_refusal(:scripts, …)` (the check a context provider's scripts get too); a file with no recorded sha, a missing one or a changed one is 409
|
|
19
19
|
`renderer_changed`, each with its own reason. ETag + `no-cache`, as static files. A `block_renderers:` list that
|
|
20
20
|
doesn't parse is logged once per bundle and problem (each list request and file fetch reads it).
|
|
21
21
|
3. `block_watch.js` (`createBlockWatch`, made by `block_host.js`'s `createBlockHost`, wired in `app.js`; a participant's page
|
data/docs/internals/bridge.md
CHANGED
|
@@ -30,7 +30,7 @@ whose seq a cursor is) and its **secret**; both are published in `bridge.json` (
|
|
|
30
30
|
|
|
31
31
|
A joining UI must draw a turn already half done, and the ring may have dropped its early events. The accumulator
|
|
32
32
|
folds the event log into one hash, `current_turn`: the prompt, `turn_id`, origin, `at`, and ordered `parts`
|
|
33
|
-
(generation, thinking, text, tool, input, steer, reminder, notice, card), plus `pending_question`. A tool part keeps its
|
|
33
|
+
(generation, thinking, text, tool, input, steer, reminder, notice, card, settle), plus `pending_question`. A tool part keeps its
|
|
34
34
|
row fields (`ToolRowFields`), its `tool_id`, its output cut head-and-tail at `ToolOutputCut::WEB_PREVIEW_CHARS` so a
|
|
35
35
|
joined row is the row a reload draws, `elapsed_ms` while it runs (the accumulator times running calls itself, `clock:`)
|
|
36
36
|
and, once finished, the event's `duration_ms` (its own clock only for an older worker's event that has none). A
|
|
@@ -38,7 +38,16 @@ and, once finished, the event's `duration_ms` (its own clock only for an older w
|
|
|
38
38
|
the "asking again" row, a steer's cut, a ✂ row, a question and its answer), so a join replays it through the handler
|
|
39
39
|
that drew it live. A `card` part is a card the turn showed in its step (`in_turn`), its latest version in its first
|
|
40
40
|
one's place; `replay_events` and `join_events` skip it (a running turn's join takes its cards from CardStore), and
|
|
41
|
-
only `replay_events(turn, cards: true)` (a finished turn's drawing) replays it as its `card` event.
|
|
41
|
+
only `replay_events(turn, cards: true)` (a finished turn's drawing) replays it as its `card` event. Since the card
|
|
42
|
+
part keeps only the latest version, an update that ends a card's wait (`Bridge::CardWait.kind`: `asks` for an action
|
|
43
|
+
with a command, else `warn` for level warn, else none; the twin of the page's `card_kinds.js cardWait`, both pinned by
|
|
44
|
+
`spec/shared/card_wait_cases.json`) for another (none, or `warn`) appends a `settle` part at that place:
|
|
45
|
+
`{kind: "settle", of: "card", id:, was: "asks" | "warn", now: nil | "warn"}`. A title-only update, a card that never
|
|
46
|
+
waited and one that starts waiting later get none. `replay_events` replays it as `{type: :part_settled, of:, id:,
|
|
47
|
+
was:, now:}` with or without cards (a join's page that has no such card ignores it; a participant's read drops the
|
|
48
|
+
type). A question needs no settle part: its own `notice` parts (`question_requested`, then `question_answered` or
|
|
49
|
+
`question_cancelled`) are its arrival and its settle. The page orders a finished turn's pieces from these marks
|
|
50
|
+
(`turn_settle.js`, docs/internals/web-frontend.md).
|
|
42
51
|
|
|
43
52
|
At the terminal event, before clearing, the accumulator hands a deep copy of the turn and the end event to its
|
|
44
53
|
`on_turn_end:` hook (the Bridge's `TurnDrawings#append`). The hook runs under the accumulator's mutex and the
|