samagotchi 0.172.0 → 0.173.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 +44 -1
- data/docs/architecture.md +16 -5
- data/docs/cli.md +2 -1
- data/docs/configuration.md +1 -1
- data/docs/internals/background-tasks.md +20 -7
- data/docs/internals/bridge.md +2 -2
- data/docs/internals/engine.md +2 -1
- data/docs/internals/participants.md +67 -9
- data/docs/internals/remote-sessions.md +1 -1
- data/docs/internals/web-frontend.md +44 -15
- data/docs/plugins.md +3 -1
- data/docs/sessions.md +2 -2
- data/docs/testing.md +43 -3
- data/lib/samagotchi/bridge.rb +3 -2
- data/lib/samagotchi/bundle_command/try/sandbox.rb +2 -2
- data/lib/samagotchi/bundles/core/manifest.yml +2 -2
- data/lib/samagotchi/bundles/slow-commands/manifest.yml +3 -3
- data/lib/samagotchi/bundles/slow-commands/plugin.rb +3 -3
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/engine/participants.rb +2 -2
- data/lib/samagotchi/engine.rb +0 -1
- data/lib/samagotchi/file_ref.rb +3 -5
- data/lib/samagotchi/guardrails/participant_refusal.rb +1 -1
- data/lib/samagotchi/memory_usage.rb +2 -1
- data/lib/samagotchi/message_parts.rb +5 -3
- data/lib/samagotchi/objectives_backing.rb +6 -10
- data/lib/samagotchi/parent_report.rb +1 -1
- data/lib/samagotchi/participant_prompts.rb +101 -0
- data/lib/samagotchi/participant_turn_mode.rb +1 -1
- data/lib/samagotchi/project_env.rb +7 -5
- data/lib/samagotchi/prompt_history.rb +2 -2
- data/lib/samagotchi/send_command/parent_gate.rb +2 -2
- data/lib/samagotchi/send_command.rb +4 -4
- data/lib/samagotchi/session_command_catalog.rb +210 -0
- data/lib/samagotchi/session_commands.rb +12 -183
- data/lib/samagotchi/session_manager/lifecycle.rb +5 -4
- data/lib/samagotchi/session_manager.rb +2 -1
- data/lib/samagotchi/session_stores.rb +2 -0
- data/lib/samagotchi/spawn_env.rb +75 -0
- data/lib/samagotchi/task_files.rb +51 -0
- data/lib/samagotchi/task_transcript.rb +67 -0
- data/lib/samagotchi/task_watch.rb +8 -6
- data/lib/samagotchi/terminal_ui/attached_loop/composer.rb +3 -3
- data/lib/samagotchi/terminal_ui/attached_loop/questions.rb +2 -2
- data/lib/samagotchi/terminal_ui/attached_loop.rb +3 -3
- data/lib/samagotchi/terminal_ui/input_support.rb +1 -1
- data/lib/samagotchi/testing/boundary.rb +5 -0
- data/lib/samagotchi/tool_activity.rb +63 -79
- data/lib/samagotchi/tool_names.rb +179 -0
- data/lib/samagotchi/tool_view.rb +3 -5
- data/lib/samagotchi/tools/ask_user_question.rb +2 -1
- data/lib/samagotchi/tools/builtins.rb +1 -1
- data/lib/samagotchi/tools/cancel_reminder.rb +2 -1
- data/lib/samagotchi/tools/cancel_schedule.rb +3 -1
- data/lib/samagotchi/tools/context_read.rb +2 -1
- data/lib/samagotchi/tools/delegate.rb +2 -1
- data/lib/samagotchi/tools/delegate_result.rb +2 -1
- data/lib/samagotchi/tools/edit.rb +2 -1
- data/lib/samagotchi/tools/execute.rb +22 -28
- data/lib/samagotchi/tools/forget_outputs.rb +2 -1
- data/lib/samagotchi/tools/leftovers.rb +8 -4
- data/lib/samagotchi/tools/list_reminders.rb +2 -1
- data/lib/samagotchi/tools/list_schedules.rb +3 -1
- data/lib/samagotchi/tools/list_sessions.rb +2 -1
- data/lib/samagotchi/tools/memory.rb +3 -2
- data/lib/samagotchi/tools/objectives_tool.rb +5 -4
- data/lib/samagotchi/tools/read.rb +2 -1
- data/lib/samagotchi/tools/register_reminder.rb +2 -1
- data/lib/samagotchi/tools/schedule_task.rb +3 -1
- data/lib/samagotchi/tools/send_note.rb +2 -1
- data/lib/samagotchi/tools/task_create.rb +2 -1
- data/lib/samagotchi/tools/task_get.rb +2 -1
- data/lib/samagotchi/tools/task_list.rb +2 -1
- data/lib/samagotchi/tools/task_runtime.rb +34 -154
- data/lib/samagotchi/tools/task_stop.rb +2 -1
- data/lib/samagotchi/tools/task_wait.rb +3 -2
- data/lib/samagotchi/tools/web_fetch.rb +2 -1
- data/lib/samagotchi/tools/write.rb +2 -1
- data/lib/samagotchi/turn_checkpoint.rb +1 -1
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +38 -36
- data/lib/samagotchi/web/message_display.rb +1 -7
- data/lib/samagotchi/web/participant_access.rb +12 -4
- data/lib/samagotchi/web/participant_history.rb +68 -0
- data/lib/samagotchi/web/participant_images.rb +2 -1
- data/lib/samagotchi/web/participant_show.rb +5 -5
- data/lib/samagotchi/web/participants_admin.rb +1 -1
- data/lib/samagotchi/web/public/app.js +13 -10
- data/lib/samagotchi/web/public/card_kinds.js +51 -0
- data/lib/samagotchi/web/public/card_registry.js +248 -0
- data/lib/samagotchi/web/public/cards_offscreen.js +3 -3
- data/lib/samagotchi/web/public/cards_place.js +21 -4
- data/lib/samagotchi/web/public/history_shape.js +1 -2
- data/lib/samagotchi/web/public/participant_history.js +27 -0
- data/lib/samagotchi/web/public/question_cards.js +16 -15
- data/lib/samagotchi/web/public/reload_check.js +90 -72
- data/lib/samagotchi/web/public/session_sync.js +4 -2
- data/lib/samagotchi/web/public/session_view.js +6 -1
- data/lib/samagotchi/web/public/stage_asking.js +18 -13
- data/lib/samagotchi/web/public/stage_place.js +144 -0
- data/lib/samagotchi/web/public/stage_probe.js +64 -0
- data/lib/samagotchi/web/public/stage_view.js +52 -104
- data/lib/samagotchi/web/public/stage_waiting.js +28 -17
- data/lib/samagotchi/web/public/task_stop.js +1 -1
- data/lib/samagotchi/web/push_routes.rb +1 -1
- data/lib/samagotchi/web/reload_check_route.rb +5 -2
- data/lib/samagotchi/web/request_body.rb +72 -0
- data/lib/samagotchi/web/server.rb +70 -0
- data/lib/samagotchi/web/session_access_routes.rb +13 -11
- data/lib/samagotchi/web/session_control.rb +21 -15
- data/lib/samagotchi/web/session_create.rb +2 -1
- data/lib/samagotchi/web/session_show.rb +8 -8
- data/lib/samagotchi/web/viewer.rb +7 -2
- data/lib/samagotchi/web/working_set_routes.rb +3 -3
- data/lib/samagotchi/worker.rb +49 -182
- data/lib/samagotchi/worker_exit_claim.rb +102 -0
- data/lib/samagotchi/worker_participant_gate.rb +156 -0
- data/lib/samagotchi/worker_task_wakes.rb +2 -2
- metadata +16 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 858f59d0b9696f081f3f482cb9ae4609bf9ad1793f84567be5aacfc05950cd8e
|
|
4
|
+
data.tar.gz: 902bdba4fbd18fb2faa666402bf37cf2cbe610f6293e7d6107dc8699894ea65c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e2e8ce3d8c6ce27b4844d38fea93ad8603197fe9c61b0ff3275e116a52a658d294ff22348afea3fb5b18943e857173b5ae54565162ae8df5d89c03ee2f7d964
|
|
7
|
+
data.tar.gz: 1f9516d73eb9f34768946891583e18121aa9361f60818025d5d87b557668df6e7bee5497bb59fcc514782d830025c6eb073fc9c717c130f1e9fbccd9d63bc5ba
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,47 @@ and commands may change between minor versions. How releases are made:
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.173.0] - 2026-11-14
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- chi web: a participant's ↑ in the composer recalls their own earlier messages in that session (never the owner's or
|
|
16
|
+
another participant's). Messages they sent before this update aren't recalled, and a new invite starts empty.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- The terminal and chi web start a little faster and use a little less memory: they no longer load the code that runs
|
|
21
|
+
tools (about 40 fewer files).
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Web: after a reload, a second question or approval from the same step of a finished turn no longer repeats the step's
|
|
26
|
+
reply above it, as live.
|
|
27
|
+
- Web: `/api/update`'s answer to a body over 16 KB is `413 too_large`, as every other route's, and a stop whose body
|
|
28
|
+
is over 4 KB is refused instead of using the default wait.
|
|
29
|
+
|
|
30
|
+
### Security
|
|
31
|
+
|
|
32
|
+
- chi web no longer reads a form or file body sent with the page's `?token=` link before checking the token: a large
|
|
33
|
+
one sent to the login page was read into memory or temp files by anyone who could reach chi web.
|
|
34
|
+
- chi web caps every request body: 64 KB unless a route needs more (a turn, an image, a context push). A bigger one
|
|
35
|
+
gets `413 too_large` and the connection is closed, instead of being read whole, so a participant can't fill chi
|
|
36
|
+
web's memory with one request.
|
|
37
|
+
|
|
38
|
+
Update with `chi update` (slow-commands 0.2.6, the core profile 0.4.4).
|
|
39
|
+
|
|
40
|
+
## [0.172.1] - 2026-11-14
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- `execute`: the hint for a background process that left the command's process group and is still running now says chi
|
|
45
|
+
can't stop it and to kill it if it shouldn't run, instead of advising how to keep it running.
|
|
46
|
+
- Web: a card you folded while the turn waits stays folded after a reload or a reconnect when the session has an answered
|
|
47
|
+
question (in its history, or earlier in the same turn); it used to come back unfolded. Answering one card no longer
|
|
48
|
+
unfolds another you folded.
|
|
49
|
+
|
|
50
|
+
Update with `chi update`.
|
|
51
|
+
|
|
11
52
|
## [0.172.0] - 2026-11-14
|
|
12
53
|
|
|
13
54
|
### Changed
|
|
@@ -6347,7 +6388,9 @@ and long-lived sessions.
|
|
|
6347
6388
|
- A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
|
|
6348
6389
|
hotkey panel that send selected text or the clipboard to your sessions.
|
|
6349
6390
|
|
|
6350
|
-
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.
|
|
6391
|
+
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.173.0...HEAD
|
|
6392
|
+
[0.173.0]: https://github.com/dm1try/samagotchi/compare/v0.172.1...v0.173.0
|
|
6393
|
+
[0.172.1]: https://github.com/dm1try/samagotchi/compare/v0.172.0...v0.172.1
|
|
6351
6394
|
[0.172.0]: https://github.com/dm1try/samagotchi/compare/v0.171.0...v0.172.0
|
|
6352
6395
|
[0.171.0]: https://github.com/dm1try/samagotchi/compare/v0.170.0...v0.171.0
|
|
6353
6396
|
[0.170.0]: https://github.com/dm1try/samagotchi/compare/v0.169.0...v0.170.0
|
data/docs/architecture.md
CHANGED
|
@@ -176,7 +176,7 @@ unless mise sets them; never `HOME`, `XDG_*`, `SAMAGOTCHI_*`, `CHI_REMOTE`, `RAC
|
|
|
176
176
|
(`$XDG_STATE_HOME/samagotchi/bin`, only a `chi` that execs `Record#boot_argv(run: CHI_BOOT)`) first on PATH when there
|
|
177
177
|
is a home, `SAMAGOTCHI_PROJECT_ENV` (`mise:<ruby>` or `none:<reason>`, for `chi self`) and
|
|
178
178
|
`SAMAGOTCHI_PROJECT_ENV_ORIG` (the worker's own value of each key it changes). It is merged into: `execute` and
|
|
179
|
-
`task_create` for the owner's turns (`Builtins.project_env`, less `
|
|
179
|
+
`task_create` for the owner's turns (`Builtins.project_env`, less `SpawnEnv::SANITIZED_ENV_KEYS`; never a
|
|
180
180
|
participant's turn), `!cmd` (`SessionCommands#shell`), context sources (`ContextFetch`) and MCP servers (the mcp
|
|
181
181
|
bundle's `server_env`). A worker started from the worker inherits its clean ENV. A `chi` a tool runs (through the shim or not, a fresh
|
|
182
182
|
process with the tools' env) takes the worker's values back from the record in `bin/chi`, before anything reads
|
|
@@ -200,8 +200,8 @@ Each entry point requires what it uses, so a process loads its own part of chi a
|
|
|
200
200
|
|---|---|---|
|
|
201
201
|
| a worker | the boot string's `samagotchi/worker_boot` | the boot, then the Worker, its Engine and Bridge; no TerminalUI, no Reline |
|
|
202
202
|
| `chi <subcommand>`, `chi self`, `chi web push` | `bin/chi`, then the subcommand's file | that command's closure; no `engine.rb`, no Reline (`chi --version` 27 of chi's files, `chi sessions list` about 270) |
|
|
203
|
-
| the attached TUI | `bin/chi` → `terminal_ui/attach_launcher` | the TUI, Reline and its Bridge client; no `engine.rb` |
|
|
204
|
-
| chi web | `bin/chi` → `web/server` | the control plane; no `engine.rb
|
|
203
|
+
| the attached TUI | `bin/chi` → `terminal_ui/attach_launcher` | the TUI, Reline and its Bridge client; no `engine.rb`, no tool that runs (`tools/execute`, `tools/builtins`, `tools/task_runtime`) |
|
|
204
|
+
| chi web | `bin/chi` → `web/server` | the control plane; no `engine.rb`, no tool that runs (as the TUI) |
|
|
205
205
|
| the one-shot (`-p X --non-interactive`) | `bin/chi` → `terminal_ui` | TerminalUI and an Engine of its own |
|
|
206
206
|
| outside callers (a script, `chi bundle try`'s sandbox, the suite's `fork_chi` preload) | `samagotchi` (`lib/samagotchi.rb`) | eager: everything a turn needs |
|
|
207
207
|
|
|
@@ -210,7 +210,18 @@ the `--resume`/`--attach` id check, `samagotchi/terminal_ui` before the one-shot
|
|
|
210
210
|
names**; `autoload` only for a constant defined in one file, never for a namespace other files reopen (that fires
|
|
211
211
|
the autoload from inside the reopening file and ends in a `NameError`). `spec/require_cycle_spec.rb` pins it: no
|
|
212
212
|
`engine.rb` or Reline for `chi --version`, `home`, `sessions list` and `schedule list`, no TerminalUI or Reline in a
|
|
213
|
-
worker
|
|
213
|
+
worker, and (its thin client load budgets) no turn loop, bundle updater, `tools/execute`, `tools/builtins` or
|
|
214
|
+
`tools/task_runtime` for the attached TUI and chi web.
|
|
215
|
+
|
|
216
|
+
The clients name tools and the session commands without loading them. A tool's name and the fixed texts it writes
|
|
217
|
+
into results (`Execute::HANDED_OVER`…) live in `ToolNames` (`tool_names.rb`, no requires), which the tool classes
|
|
218
|
+
read their constants from and the display code (`ToolActivity`, `ToolView`, `FileRef`, `ObjectivesBacking`) reads
|
|
219
|
+
directly. The session commands' names, the built-ins' registry and its class-level reads (`builtin_name`,
|
|
220
|
+
`builtin_registry`, `ui_only_entry`, `ui_only_refusal`, `delete_on_exit?`, `SHELL_BANG_PREFIX`…) live in
|
|
221
|
+
`SessionCommandCatalog` (`session_command_catalog.rb`), which the TUI, chi web, `chi send` and `PromptHistory`
|
|
222
|
+
require; `SessionCommands` (the runner, worker-side: `!cmd` runs `Tools::Execute`) includes it and forwards the
|
|
223
|
+
class methods, so `SessionCommands.x` reads the same. A new client-side read of either goes to the table or the
|
|
224
|
+
catalogue, never to the class.
|
|
214
225
|
|
|
215
226
|
## Session retention & ordering
|
|
216
227
|
|
|
@@ -640,7 +651,7 @@ A map of the parts the overview above doesn't name (paths under `lib/samagotchi/
|
|
|
640
651
|
|
|
641
652
|
| Component | Main file(s) | What it is |
|
|
642
653
|
|---|---|---|
|
|
643
|
-
| Worker | `worker.rb` (`worker_boot.rb`, `worker_idle_exit.rb`, `worker_inbound.rb`, `worker_signals.rb`, `worker_wakes.rb`, `worker_task_wakes.rb`, `task_watch.rb`) | A session's background process: builds the `Engine` and `Bridge`, runs queued turns and the wake turns nobody typed (delegate reports, a background task that finished unseen: [Finish wake](internals/background-tasks.md#finish-wake), attached context), exits when idle. A spawned one traps TERM, HUP and INT (`WorkerSignals`, installed by `WorkerBoot.run_session_loop` when `SAMAGOTCHI_WORKER_PROCESS=1`): the running turn stops as a Stop with reason `signal`, is saved, and the worker leaves (`:signal`, exit 0; a new worker only for input already queued). A running turn is checkpointed at its iteration boundaries (`TurnCheckpoint`, the `interrupted_turn` mark), and the next worker settles a turn its predecessor died in (`TurnCheckpoint.settle`). The session is saved from the turn's thread, Bridge threads and a signal's thread; `Session#save` takes a per-session lock around its snapshot and write, so an older snapshot never lands over a newer one. |
|
|
654
|
+
| Worker | `worker.rb` (`worker_boot.rb`, `worker_idle_exit.rb`, `worker_inbound.rb`, `worker_signals.rb`, `worker_wakes.rb`, `worker_task_wakes.rb`, `task_watch.rb`, `worker_participant_gate.rb`, `worker_exit_claim.rb`) | A session's background process: builds the `Engine` and `Bridge`, runs queued turns and the wake turns nobody typed (delegate reports, a background task that finished unseen: [Finish wake](internals/background-tasks.md#finish-wake), attached context), exits when idle. A spawned one traps TERM, HUP and INT (`WorkerSignals`, installed by `WorkerBoot.run_session_loop` when `SAMAGOTCHI_WORKER_PROCESS=1`): the running turn stops as a Stop with reason `signal`, is saved, and the worker leaves (`:signal`, exit 0; a new worker only for input already queued). A running turn is checkpointed at its iteration boundaries (`TurnCheckpoint`, the `interrupted_turn` mark), and the next worker settles a turn its predecessor died in (`TurnCheckpoint.settle`). The session is saved from the turn's thread, Bridge threads and a signal's thread; `Session#save` takes a per-session lock around its snapshot and write, so an older snapshot never lands over a newer one. `WorkerParticipantGate` is the one seat for "may this participant act" (a queued turn as it starts, the drain, the mid-turn stop, the Continue: [internals/participants.md](internals/participants.md)); `WorkerExitClaim` is the exit claim (`POST /exit`): one lock for the kind being taken and the exit taken. Threads: the gate is loop-thread only (a turn runs on the loop; no lock), the claim is safe from any thread (its own mutex, taken after the event lock). |
|
|
644
655
|
| 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`). |
|
|
645
656
|
| 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. |
|
|
646
657
|
| MemoryBundle | `memory_bundle.rb`, `memory_bundle/{installer,builder,installed_bundle,plugin_ref,bundle_hook}.rb` (`Installer`, `Builder`, `InstalledBundle`, `PluginRef`, `BundleHook`) | Installing, building and reading bundles of memories, rules, plugins and scripts (`BundleHook`: an older record's retired class-file hook). |
|
data/docs/cli.md
CHANGED
|
@@ -1781,7 +1781,8 @@ chi share revoke --all # every link to every session
|
|
|
1781
1781
|
While their own turn runs they can **Stop turn**, and a message goes in at its next step (Alt+Enter keeps it for
|
|
1782
1782
|
after the turn); while yours or another participant's runs, it goes in as their own turn afterwards. When their
|
|
1783
1783
|
turn waits for you (an approval, a question, your Continue) they see that it waits and for what kind of thing,
|
|
1784
|
-
never its content.
|
|
1784
|
+
never its content. ↑ in their composer recalls their own earlier messages in that session (as the conversation
|
|
1785
|
+
shows them; never yours or another participant's). At their cap, in a stopped session, or once their link ended the composer gives way to one line
|
|
1785
1786
|
and the conversation stays readable. They get none of your controls: no new session, list, rename, model, images
|
|
1786
1787
|
(yet), session menu, participants panel, cards or approvals, and no file panel (they ask chi to quote what they
|
|
1787
1788
|
need). They never see tool output or arguments, thinking, approvals or questions, memories, context notes,
|
data/docs/configuration.md
CHANGED
|
@@ -2383,7 +2383,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
|
|
|
2383
2383
|
| `web.host` | `127.0.0.1` | yes | `127.0.0.1`, `::1` or `localhost`; `lan` (this machine's private IPv4 address) or one of its IPv4 addresses also opens `chi web` to the network, with an access token, asked of this machine's 127.0.0.1 too (its `Local:` link carries a one-time code; `chi web --new-token` replaces the token; it is chi web's one access token, also used by `--tunnel` and `web.public_url`/a proxy). Anything else binds `127.0.0.1` with a warning. See [CLI: chi web on your phone](cli.md#chi-web-on-your-phone). |
|
|
2384
2384
|
| `web.markdown` | `false` | yes | Render answers as Markdown in `chi web`. |
|
|
2385
2385
|
| `web.working_set` | `true` | yes | The stage view's working set: the files, memories and URLs a turn brought into the model's context, in a rail in the stage, a footprint as each finished turn's block summary and a `set N` chip in place of the mem chip; `false` brings the mem chip back. `?working_set=1` or `?working_set=0` on the page URL overrides it for that page load. See [CLI: the working set](cli.md#the-working-set). |
|
|
2386
|
-
| `web.reload_check` | `false` | yes | Opt-in: once each finished turn has moved into the history, the page reads the session again (one full read per turn end), draws that turn as a reload would and compares the two, strictly: a known divergence counts as a mismatch too. `chi web` logs one `reload_checked` line per check and a `reload_mismatch` line naming the kinds that differed, `excused` (the known divergences, `history_shape.js` `ACCEPTED`, that would explain them) and `explained` (all of them had one), with `turn_id`, `drawn` (the turn came back from its drawing, so a mismatch with `drawn: true` is a drawing bug), `undrawn` (how many of the reload's rows came without their turn's drawing, the page's plain fallback: 0 unless chi web missed a turn) and the worker's version: counts only, never content. The count is `grep -c reload_mismatch` over `grep -c reload_checked` in chi web's log, split by `excused`. The turn's own cards and
|
|
2386
|
+
| `web.reload_check` | `false` | yes | Opt-in: once each finished turn has moved into the history, the page reads the session again (one full read per turn end), draws that turn as a reload would and compares the two, strictly: a known divergence counts as a mismatch too. `chi web` logs one `reload_checked` line per check and a `reload_mismatch` line naming the kinds that differed, `excused` (the known divergences, `history_shape.js` `ACCEPTED`, that would explain them) and `explained` (all of them had one), with `turn_id`, `drawn` (the turn came back from its drawing, so a mismatch with `drawn: true` is a drawing bug), `undrawn` (how many of the reload's rows came without their turn's drawing, the page's plain fallback: 0 unless chi web missed a turn) and the worker's version: counts only, never content. The count is `grep -c reload_mismatch` over `grep -c reload_checked` in chi web's log, split by `excused`. The turn's own cards and questions are compared as data, apart from the history: what the page's stream said (`card_registry.js`) against what the read lists (CardStore), each card or question of this turn (`of_turn`) by its id, its kind, its status (answered, cancelled, still asking) and its summary line (a card's title); a difference counts as `card` or `question`. Bodies, buttons, folds, the tag a card is drawn in and where it sits are ignored (the history's compare leaves cards and questions out on both sides; their place is the specs'). A read that lists CardStore's cap of cards and questions may have lost an older one: a card the page has and such a read doesn't is no difference. A question the read gives no turn and no opening stamp for (an older worker) leaves the questions out. A page whose `app.js` is older than its `reload_check.js` (a mixed cache) compares no cards: its `reload_checked` line says `cards_compared: false`. Between-turn cards and notices stay with the e2e reload checks. Every open owner tab runs the check; `chi web` logs a turn's first report only, and starts over when it restarts. |
|
|
2387
2387
|
| `web.annotate_presets` | `Agreed\|Could you please elaborate?` | yes | Quick replies next to Annotate in `chi web`, `\|`-separated (a YAML list works too); `""` in the file or on the CLI leaves only Annotate (an empty env value means the default). See [CLI](cli.md#web-annotate-presets). |
|
|
2388
2388
|
| `web.editor` | `vscode` | yes | What a file ref in `chi web` (a file tool row's title, a diff line) opens, for a viewer on this machine: a preset (`vscode`, `vscode-insiders`, `cursor`, `zed`) or a URL template with `{path}` and an optional `{line}`; `none` turns refs off. See [Opening files from chi web](#opening-files-from-chi-web). |
|
|
2389
2389
|
| `web.start_dir` | the folder `chi web` runs in | | The folder `chi web` starts in (`chi web --start-dir DIR` for one run): its page (the printed link, a bare `/`, the LAN link and QR code, the Home Screen app) opens on that folder's project, outside a project (no repository or marked folder) on every session, and a new session from the all view starts there; the header's project picker switches projects. `~` and a relative path (resolved from your home folder) work; one that isn't a folder stops `chi web` from starting. `chi web` never changes its own folder. See [CLI](cli.md). |
|
|
@@ -15,6 +15,19 @@ Recommended workflow:
|
|
|
15
15
|
3. For commands with a reliable completion marker, pass `done_pattern` to return when the recent log tail matches it.
|
|
16
16
|
4. Use `task_get` or `task_list` for nonblocking status checks, and `task_stop` if needed.
|
|
17
17
|
|
|
18
|
+
The code is split by who uses it, so a client that only reads (the attached TUI, chi web, `sessions list`) need not
|
|
19
|
+
load the process code, and does not (`spec/require_cycle_spec.rb`, the thin client load budgets):
|
|
20
|
+
|
|
21
|
+
| Module | Holds | Read by |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| `Tools::TaskRuntime` (`tools/task_runtime.rb`) | the lifecycle: `create_task`, `adopt`, the waiter (`record_exit_status`, `waiter_for`), refresh, `stop_task`, `get_record`, `list_records`, `running_created_in`, the leftovers; all process state (`@waiters`, `@settle_lock`) | the task tools, `execute`, `Bridge`, `HoldStop`, `TaskWatch`, `TurnEndings`, `Worker` |
|
|
24
|
+
| `SpawnEnv` (`spawn_env.rb`) | the env a spawned command gets: `sanitized_spawn_env`, `spawn_env_for` (task_create's `env` checks), `SANITIZED_ENV_KEYS`, `MARKER_ENV_KEYS` | `execute`, `create_task`, `ProjectEnv.spawn_env` (required at call time: `child_env` requires `project_env`) |
|
|
25
|
+
| `TaskFiles` (`task_files.rb`) | where a task's files are: `TASKS_DIR`, `METADATA_FILENAME`, `OUTPUT_FILENAME`, `EXIT_CODE_FILENAME`, `TASK_ID`, `metadata_path`, `task_dir_for`, `command_of` (a record read, no refresh) | `TaskRuntime`, `execute`, `ToolActivity`, `SessionManager`, `chi bundle try`'s sandbox, the slow-commands bundle |
|
|
26
|
+
| `TaskTranscript` (`task_transcript.rb`) | which tasks a conversation started, from its results' text: `created_ids_in`, `created_id`, `handed_over_id`, `RAN_AS_LINE` (matching on `ToolNames::Execute`) | `TaskRuntime.running_created_in`, `Bridge`, `TaskWatch`, `WorkerTaskWakes`, `SessionManager` |
|
|
27
|
+
|
|
28
|
+
`TaskRuntime::TASKS_DIR` and `TaskRuntime::EXIT_CODE_FILENAME` forward to `TaskFiles` for one release (bundles named
|
|
29
|
+
them; the boundary's stable list has both homes until they are removed).
|
|
30
|
+
|
|
18
31
|
Behavior:
|
|
19
32
|
|
|
20
33
|
- `execute`, `task_create` and the `!cmd` shell bang run the command in a non-login shell: `/bin/sh -c` on Linux; on macOS, when `/bin/zsh` is there, `/bin/zsh --emulate sh +o ignore_braces +o sh_glob -o bash_rematch +o bsd_echo -c` (macOS's `/bin/sh` is bash 3.2, which can't parse an apostrophe in a heredoc inside `"$( )"`, the usual commit message shape). That mode reads no rc files and keeps POSIX word splitting, unmatched globs left as is, `{1..3}`, `[[ … =~ (…) ]]` with `BASH_REMATCH`, arrays, `$'…'`, `&>` and echo expanding `\t`. Bash-only builtins and variables (`shopt`, `BASH_VERSION`, `${!prefix*}`, `read -p`) are not there.
|
|
@@ -22,13 +35,13 @@ Behavior:
|
|
|
22
35
|
- A task record keeps its process's pid and start time (`pid_started`). Before `task_stop` signals, the pid must still lead its own process group and must not have started at another time; otherwise the pid was reused by another process, nothing is signalled and the task ends as failed. A start time that can't be read at that moment (a failed `ps`) falls back to the group check, as does a record without `pid_started` (from an older chi). `task_get`, `task_list`, `task_wait`'s polls and the running-task lists (a cancelled turn's note, a worker's restart hold, the finish wake's watch) make the same check, so a task whose pid was reused reads as exited (failed) at once, not as running until a `task_stop`; on macOS that is one `ps` per running task per check (~5 ms).
|
|
23
36
|
- A stop (`task_stop`, the user's Stop of an `execute`, the execute limit in kill mode) TERMs the task's process group, then KILLs it after a grace. The groups its processes started are stopped too: a GNU `timeout N cmd` (without `--foreground`) moves itself and its command to a group of its own. `ProcessGroup.stop` finds them with one `ps -A -o pid=,ppid=,pgid=` (~40 ms on macOS) before the TERM and again before the KILL, walking down from the group's members. A process whose parent already exited (reparented to init, e.g. a setsid'd `cmd &`, or a backgrounded `timeout N cmd &` after its shell exited) is not found by that walk; one still in the task's group is stopped by the leftover rule below, so only one outside the group runs on: a setsid'd `cmd &`, or a backgrounded `timeout N cmd &` (GNU `timeout` moves to a group of its own). Holding the task's log, it is reported detached.
|
|
24
37
|
- Task listing is workspace-scoped (current project only).
|
|
25
|
-
- `execute` runs its command with stdout and stderr in two logs under `$XDG_STATE_HOME/samagotchi/execute/<id>/` (always an absolute path: a relative `XDG_STATE_HOME` is taken from the directory chi started in; outside the workspace: `git status` and `rm -rf tmp` never see them), stdin `/dev/null` and the same `exit_code` wrapper as a task. Its own copies of the logs hold a shared `flock` across the spawn: while a fresh exclusive `flock` fails, some process the command started still has them open. When the shell exits, a background child still holding them (`server &`) gets 1.5 s, then its group is stopped (the result's hint says to start a long job with `task_create` in the foreground, no `&`: a `cmd &` left behind there is stopped too); one holding none (`nohup server >log 2>&1 &`) is left alone. A holder that left the group (setsid) is out of the stop's reach: it runs on, the result ends with the "left running" hint, and its dir stays for it to write to (the sweep removes it once no one holds the logs). Otherwise a finished command's dir is removed. Known gap on Linux: a command that writes through `/dev/stdout` or `/dev/stderr` (`echo b >/dev/stdout`) reopens the log file itself with `O_TRUNC`, so the output before it is lost (macOS dups the descriptor; the fix would be a relay pipe). The check needs the state dir on a local file system: over NFS, `flock` is emulated with `fcntl` locks, which children don't inherit.
|
|
38
|
+
- `execute` runs its command with stdout and stderr in two logs under `$XDG_STATE_HOME/samagotchi/execute/<id>/` (always an absolute path: a relative `XDG_STATE_HOME` is taken from the directory chi started in; outside the workspace: `git status` and `rm -rf tmp` never see them), stdin `/dev/null` and the same `exit_code` wrapper as a task. Its own copies of the logs hold a shared `flock` across the spawn: while a fresh exclusive `flock` fails, some process the command started still has them open. When the shell exits, a background child still holding them (`server &`) gets 1.5 s, then its group is stopped (the result's hint says to start a long job with `task_create` in the foreground, no `&`: a `cmd &` left behind there is stopped too); one holding none (`nohup server >log 2>&1 &`) is left alone. A holder that left the group (setsid) is out of the stop's reach: it runs on, the result ends with the "left running" hint, which says chi can't stop it and to kill it if it shouldn't run, and its dir stays for it to write to (the sweep removes it once no one holds the logs). Otherwise a finished command's dir is removed. Known gap on Linux: a command that writes through `/dev/stdout` or `/dev/stderr` (`echo b >/dev/stdout`) reopens the log file itself with `O_TRUNC`, so the output before it is lost (macOS dups the descriptor; the fix would be a relay pipe). The check needs the state dir on a local file system: over NFS, `flock` is emulated with `fcntl` locks, which children don't inherit.
|
|
26
39
|
- The exit code: the command runs after an EXIT trap that writes the shell's status to the `exit_code` file (`TaskRuntime.wrapped_shell_command`, shared with `task_create`), so `exit N`, a `set -e` failure and a trailing `\` or `|` in the command all record what the shell exited with. The trap runs wherever the shell is when it exits (a `task_create` `cwd`, or a `cd` in the command), so `task_create`'s `exit_code_path` is absolute; its `output_path` stays relative (`tmp/tasks/<id>/output.log`, opened by chi in the worker's cwd before the spawn). A command that sets its own EXIT trap replaces it, and a shell killed by a signal skips it (zsh's sh mode, on TERM, INT and KILL): `execute` still reports the shell's status, and a `task_create` task or a handed-over execute gets its code from chi's waiter while the chi that started it runs (`TaskRuntime.record_exit_status`): the exit status, or `128 + the signal` (TERM → 143), with no new `stop_reason`. A record a refresh already finished without a code in between (`failed`, `process_ended_without_exit_code` or the not-chi's-process reason) is corrected, its `finished_at` kept; a stopped task (its stop flag on disk) is never touched. `process_ended_without_exit_code` is left only when the shell wrote nothing and the chi that started it was gone too.
|
|
27
40
|
- `task_create` applies `execute`'s leftover rule (`Tools::Leftovers`, one implementation: `held?`, the grace, the group stop, the hint wording): `create_task` holds `output.log` with a shared `flock` across the spawn, and a handed-over execute's two logs are already held. When the task's shell exits and a process it started still holds the log (`yes >/dev/null &` with no `wait`), the task stays `running` (so the finish wake's watch and `task_wait` keep waiting) while the waiter of the chi that started it (`TaskRuntime.record_exit_status`) gives it 1.5 s (`LEFTOVER_GRACE_SEC`), then stops the group (TERM, 1 s, KILL; `Leftovers.stop_group`, only while the group still has members: a pgid isn't reused while it has any) and finishes the record in one write: the shell's status and exit code (the leftovers don't make it a failure) and `leftovers: "stopped"`. A holder outside the group with the group empty (a setsid'd `cmd &`, or a backgrounded `timeout N cmd &`: GNU `timeout` without `--foreground` moves itself and its command to a group of its own) is signalled nothing: `leftovers: "detached"`, left running, and the hint says so (`task_stop` can't reach it: kill it if it shouldn't run). A process holding no log (`nohup cmd >f 2>&1 &`) is left alone. `task_get`, `task_wait` (so the finish note too) and `task_list` add the hint line (`Leftovers.task_hint`), ``(a background process kept the task's log open and was stopped; to keep one running, run it in the foreground or end the command with `wait`)`` (or `was left running`), built from the same `Leftovers.hint` as execute's. One settler per task: while that waiter thread lives (`TaskRuntime.waiter_for`, in memory, this process only), a refresh here only reads a held record. With no waiter here (the chi that started it is gone, a worker that exited mid-grace, or another process reading), the next refresh that finds the shell dead and the log held settles it itself: a second look after 0.05 s (two `held?` probes at once read each other as holders), then the stop with a 0.5 s TERM grace and 0.5 s KILL wait (only of a group that still had members at the first look; one gone by the stop with nothing holding the log records no `leftovers`), so that read blocks up to ~1 s plus a `ps`. With no later reader of that cwd's tasks the leftovers run on; records already finished (an older chi's) are never revisited, and an older chi's record (its log never `flock`'d) reads as not held and settles as before. A `task_stop` during the grace stops the group (`Leftovers.stop_group`) and the record ends `stopped` (its stop flag wins over the waiter's write; in one process the two writes share a lock). Cost: one non-blocking `flock` try per log at shell exit (~0.2 ms), the grace only when something holds the log; a refresh of a running record whose shell is dead adds one `flock` try, and one `ps` only when the log is held.
|
|
28
41
|
- 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.
|
|
29
|
-
- 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` (`120s limit:` or `4s mark:`): `
|
|
42
|
+
- 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.
|
|
30
43
|
- `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)).
|
|
31
|
-
- Which tasks are a session's own (a cancelled turn's note, a worker's restart hold, the finish wake below, the web's stop-task button): the ids its `task_create` results and its handed-over executes name (`
|
|
44
|
+
- Which tasks are a session's own (a cancelled turn's note, a worker's restart hold, the finish wake below, the web's stop-task button): the ids its `task_create` results and its handed-over executes name (`TaskTranscript.created_ids_in`, `created_id`). An execute's id is read only after its first line (`Execute::HANDED_OVER`, through `TaskTranscript.handed_over_id`; the web has a JS twin in `task_stop.js`), not from a `task_id:` line inside a run, which the command can print. (A command that prints the `---` separator chi joins a turn's results with, then a hand-over line, still fakes one: a known gap.) Either result may start with the `ran as: …` line of a gate-corrected call.
|
|
32
45
|
- `task_get` returns metadata and `output_path`; use `read` for output contents.
|
|
33
46
|
- `task_wait` accepts `timeout`, `tail_lines` (maximum 100), and `done_pattern` (a regular expression string).
|
|
34
47
|
- `task_wait`'s results: a finished task's status and tail (no `wait_result`), or one still running with
|
|
@@ -42,8 +55,8 @@ Behavior:
|
|
|
42
55
|
again or stop it (`TaskWait::MESSAGE_WAITING_NOTE`), and `waited: Ns`; the task keeps running and stays watched
|
|
43
56
|
(below). A task that finished meanwhile gives its finished result, as after a Stop. A `chi -p` turn has no probe. The same probe ends a blocking `delegate_result` (and `delegate`'s wait) early; see [Sessions: Delegating](../sessions.md).
|
|
44
57
|
- `task_create` accepts `env` as a JSON object string for deterministic overrides such as `PATH`; use an absolute interpreter path when that is simpler. Ruby/Bundler isolation variables remain protected.
|
|
45
|
-
- `execute` and `task_create` both spawn with chi's own Ruby/Bundler setup scrubbed (`
|
|
46
|
-
- `execute` and `task_create` export chi's own markers into the command, set over the model's `env` (which can't set them: `Error: env key is reserved`): `SAMAGOTCHI_PARENT_SESSION` (the session's id, `chi` without one; a chi started there answers as a parent agent), `SAMAGOTCHI_SESSION_MODEL` (the resolved ref the session runs on, read at each call so it follows `/model`; unset when unknown) `SAMAGOTCHI_SESSION_THINKING` (the session's own thinking level; unset when it has none) and `SAMAGOTCHI_SESSION_REASONING_HISTORY` (its own reasoning_history level, the same way). `chi self` reads the last three for its model, thinking level and reasoning history. The four are `ChildEnv::SESSION_MARKERS` (`
|
|
58
|
+
- `execute` and `task_create` both spawn with chi's own Ruby/Bundler setup scrubbed (`SpawnEnv.sanitized_spawn_env`): `RUBYOPT` loses its `-r…bundler/setup` flags (others stay) and `RUBYLIB` and what `bundle exec` sets (`BundlerEnv::VARS`: `BUNDLE_GEMFILE`, `BUNDLE_LOCKFILE`, `BUNDLE_BIN_PATH`, `BUNDLER_VERSION`, `BUNDLER_SETUP`) are unset, so a project's `ruby -e` or `bundle exec` uses its own Gemfile, or none, when chi runs under `bundle exec`. RubyGems requires what `BUNDLER_SETUP` names at boot, whatever `RUBYOPT` says. A project's own settings (`BUNDLE_PATH`, `BUNDLE_WITHOUT`) stay. `task_create` refuses those keys in the model's `env`, its error saying to write `KEY=value cmd` in the command instead; `execute`'s `env` comes from chi's callers (`Builtins`, `!cmd`), not the model, and is set over the scrub. An `execute` handed over at its limit keeps the process it spawned, so the task runs with the same env.
|
|
59
|
+
- `execute` and `task_create` export chi's own markers into the command, set over the model's `env` (which can't set them: `Error: env key is reserved`): `SAMAGOTCHI_PARENT_SESSION` (the session's id, `chi` without one; a chi started there answers as a parent agent), `SAMAGOTCHI_SESSION_MODEL` (the resolved ref the session runs on, read at each call so it follows `/model`; unset when unknown) `SAMAGOTCHI_SESSION_THINKING` (the session's own thinking level; unset when it has none) and `SAMAGOTCHI_SESSION_REASONING_HISTORY` (its own reasoning_history level, the same way). `chi self` reads the last three for its model, thinking level and reasoning history. The four are `ChildEnv::SESSION_MARKERS` (`SpawnEnv::MARKER_ENV_KEYS`), which a spawned worker unsets (`ChildEnv.unset`, merged into its spawn env). A session's worker never inherits them from whoever started it (a `chi send` run by another session's `execute`): its other commands (a user's `!cmd`, an MCP server, a context command) have none.
|
|
47
60
|
- They also pass on a set `XDG_STATE_HOME` / `XDG_CONFIG_HOME` made absolute (`Builtins.xdg_absolute`, via `Paths`), so a chi the command runs in another `cwd` (`chi send`) reads this chi's state and config. These aren't reserved: an XDG dir the model sets in `task_create`'s `env` stays its own.
|
|
48
61
|
- Every runner starts from the session's project env, `ProjectEnv.tools_env`: the overlay a spawned worker computed once at boot (`WorkerBoot.apply_project_env` → `ProjectEnv.compute` → `ProjectEnv.install!`; its folder's `mise env`, and the chi shim's dir first on PATH so `chi` is the chi home's), less `ProjectEnv::TOOLS_DROP` (`RUBYOPT`, `RUBYLIB`, Bundler's: the scrub above sets those). Outside a worker (`ProjectEnv::NONE`) it is `{}`. The sites: `execute` and `task_create` (`Tools::Builtins#project_env`, under the markers and the model's `env`; a participant's turn gets `{}`), the user's `!cmd` (`SessionCommands#shell`), and through `ProjectEnv.spawn_env` (the scrub above, then `tools_env`: what `execute` spawns with, for the runners that don't go through it) a context source's command (`ContextFetch#env_for`) and an MCP server, under the server's own keys (`bundles/mcp/plugin.rb` `server_env`, from mcp 0.7.4; no participant rule: the server is the session's). chi's own process env is never changed, and the project env never enters the prompt. User docs: [Project env](../sessions.md#project-env); the launch side: [How chi launches itself](../architecture.md#how-chi-launches-itself).
|
|
49
62
|
|
|
@@ -51,8 +64,8 @@ Behavior:
|
|
|
51
64
|
|
|
52
65
|
A task the model leaves running (it ends its turn: "I'll check when it's finished") is reported when it ends, so the result doesn't wait for the user's next message. `session.task_wakes` (env `SAMAGOTCHI_SESSION_TASK_WAKES`): `wake` (default), `queue` or `off` (no watch, as before).
|
|
53
66
|
|
|
54
|
-
- **The watch** (`TaskWatch`, `task_watch.rb`) is the Worker's (`WorkerTaskWakes`, `worker_task_wakes.rb`, which writes the notes; the Worker runs the wake turn), in memory: a `--non-interactive` one-shot has none, and a crash loses it (those tasks behave as before). The Worker's Engine observer feeds it the raw `:tool_call_completed` events, the input `Bridge#own_task_ids` reads too. A `task_create` result and an `execute` hand-over add the task (`
|
|
55
|
-
- **The idle tick**: with something watched, each idle pass (after delegate reports, before due reminders) refreshes the watched records (`TaskRuntime.get_record`, one `ps` per running task) and takes the finished ones, keeping only the ids the conversation still holds (`
|
|
67
|
+
- **The watch** (`TaskWatch`, `task_watch.rb`) is the Worker's (`WorkerTaskWakes`, `worker_task_wakes.rb`, which writes the notes; the Worker runs the wake turn), in memory: a `--non-interactive` one-shot has none, and a crash loses it (those tasks behave as before). The Worker's Engine observer feeds it the raw `:tool_call_completed` events, the input `Bridge#own_task_ids` reads too. A `task_create` result and an `execute` hand-over add the task (`TaskTranscript.created_id`: a `task_id:` the command printed doesn't count), the hand-over's limit kept for the note. What shows the model the end removes it: a `task_wait` with a final status, or with `wait_result: pattern_matched` (the model chose its own "done" marker); a `task_get` with a final status; any `task_stop`. `task_list` and a `read` of `output.log` don't: a model that read the log still gets the wake once. Tasks a tool starts inside an anytime command (`/btw` and the like) reach the same observer, so they are watched too.
|
|
68
|
+
- **The idle tick**: with something watched, each idle pass (after delegate reports, before due reminders) refreshes the watched records (`TaskRuntime.get_record`, one `ps` per running task) and takes the finished ones, keeping only the ids the conversation still holds (`TaskTranscript.created_ids_in`: a `!rollback` or a restored turn may have dropped the result that started one; an LLM context strategy can't, since its stale and forget stubs are drawn in the request, never written over the saved result). A note that can't be written puts its task back for the next pass. An empty watch costs nothing. A task that finishes during a turn and is still unseen when the turn ends wakes on the next idle pass. One the user stopped with the web's stop-task button is dropped without a note.
|
|
56
69
|
- **The note** is a context note under its own header (`ContextNote::TASK_HEADER`; `TaskFinishNote`), `note_id: task-<id>`, `source: task <id8>`:
|
|
57
70
|
|
|
58
71
|
```
|
data/docs/internals/bridge.md
CHANGED
|
@@ -415,7 +415,7 @@ The Bridge exposes:
|
|
|
415
415
|
- `POST /session/:id/tasks/stop` — `{task_id}`: stop a background task as the user
|
|
416
416
|
(`TaskRuntime.stop_task by: "user"`, the web's stop-task button on a running `task_wait`;
|
|
417
417
|
web route `POST /api/sessions/:id/tasks/:task_id/stop`). Only a task this conversation's
|
|
418
|
-
`task_create` started, or an `execute` handed over as a task at its limit (`
|
|
418
|
+
`task_create` started, or an `execute` handed over as a task at its limit (`TaskTranscript.created_ids_in` on the
|
|
419
419
|
saved messages, or the running turn's accumulator); answers once the
|
|
420
420
|
task is gone: `200 {status, stop_reason, task_id}`, `404 task_not_found`, `409 not_running`.
|
|
421
421
|
The worker names it in its sidecar features (`task_stop`).
|
|
@@ -461,7 +461,7 @@ The Bridge exposes:
|
|
|
461
461
|
`continue_offered`, `client_connected` (a stream not named by the asker), `reminders`,
|
|
462
462
|
`background_tasks` (with `tasks: [{id, command}]`: the running tasks a finish wake watches), `starting`, or
|
|
463
463
|
`leaving_exit` / `leaving_delete` / `leaving_restart` when another client's exit of another kind is already taken
|
|
464
|
-
(`
|
|
464
|
+
(`WorkerExitClaim#claim`, claimed before a stop-all; the words are `WorkerIdleExit::LEAVING_WORDS`). A second exit of
|
|
465
465
|
the kind already taken is answered `200` as that one.
|
|
466
466
|
- `GET /session/:id/state` — `session_state_snapshot` (JSON), read under the event lock so its `event_seq`/`event_id` match the state.
|
|
467
467
|
- `GET /session/:id/stats` — `Engine#stats_snapshot` for attached `/stats`: the metrics, with the context window and prompt profile asked from the server before the first turn.
|
data/docs/internals/engine.md
CHANGED
|
@@ -558,7 +558,7 @@ Where a participant's author (`"p:<id>"`; `Steer.participant_author?`) goes (the
|
|
|
558
558
|
`ClientId::UNKNOWN`: automatic.
|
|
559
559
|
- **Delivery**: a participant's input always waits for a turn of its own (`SessionInbox.waits_for_turn_end?`), so
|
|
560
560
|
the drain never merges it; their turns count against chi web's `pending_limit` (429 `too_many_turns`).
|
|
561
|
-
`Worker#run_prompt` checks their link (`ParticipantTurnMode`: an older chi's read-only one is `outdated`) and cap (`
|
|
561
|
+
`Worker#run_prompt` checks their link (`ParticipantTurnMode`: an older chi's read-only one is `outdated`) and cap (`WorkerParticipantGate#refusal`) before the turn and after it.
|
|
562
562
|
- **The gate**: `GuardrailWiring#participant_boundary` picks `Guardrails::PairBoundary` for a pair turn, else
|
|
563
563
|
`Guardrails::ParticipantRefusal` (every call denied), by `TurnContext#participant_mode` (guardrails.md). Both are
|
|
564
564
|
no-ops for the owner.
|
|
@@ -794,6 +794,7 @@ are in [architecture.md](../architecture.md)'s file table.
|
|
|
794
794
|
| `tool_runner.rb`, `tool_response.rb`, `tool_row_fields.rb`, `row_refs.rb` | Per call; per batch; row fields; plugin row refs |
|
|
795
795
|
| `tool_output_cut.rb`, `tool_output_files.rb` | The output cap's policies; an execute's saved whole output ([tool-output-limits.md](tool-output-limits.md)) |
|
|
796
796
|
| `tools/tool_surface.rb`, `tools/registry.rb`, `tools/tool_index.rb`, `plugin/tool_spec.rb` | The turn's surface; the Registry; `find_tools` / `call_tool`; a checked plugin tool declaration |
|
|
797
|
+
| `tool_names.rb`, `session_command_catalog.rb`, `session_commands.rb` | Each builtin tool's name and result texts (`ToolNames`, no requires: the tool classes and the display read it); the session commands' names, built-ins' registry and class-level reads the clients require (`SessionCommandCatalog`, no tool); the runner a worker dispatches a command line to (`SessionCommands#run`, which includes the catalogue) |
|
|
797
798
|
| `toolkit.rb`, `toolkit_command.rb`, `toolkit_binding.rb` | Toolkits; `/toolkit`; the Engine's toolkit seam (`#published`, `#apply!`) |
|
|
798
799
|
| `empty_answer_retry.rb`, `prompt_warmup.rb` | The empty-answer and cut retry budget; the turn-end warm-up |
|
|
799
800
|
| `system_prompt.rb`, `prompt_files.rb`, `model_notes.rb` | The system prompt; AGENTS.md and appended files; model notes |
|
|
@@ -163,6 +163,23 @@ the gate asks for it (on the LAN, this machine's loopback too). On a chi web the
|
|
|
163
163
|
401 for a grant's cookie that no longer works clears the cookie, so that browser is the owner's again at its next
|
|
164
164
|
request; on the LAN that browser gets the ended page and opens the owner's link again.
|
|
165
165
|
|
|
166
|
+
The gate reads one body, `POST /api/token`'s, through `traded_token`, under `TRADE_BODY_LIMIT` (a body of 4096
|
|
167
|
+
bytes or more is no token, 401). The page's `?token=` trade reads the query only (`req.GET`): Rack's `req.params`
|
|
168
|
+
would parse a urlencoded body into memory and a multipart one into temp files, before any check, so chi web reads
|
|
169
|
+
every query through `req.GET` (`spec/web/no_body_params_spec.rb` fails on a new `req.params` or `req.POST`). Past
|
|
170
|
+
the gate, every handler reads its body through `Web::RequestBody#request_body`, capped: 64 KB by default; a
|
|
171
|
+
participant's turn and an answer 1 MB (what the Bridge takes, `BRIDGE_BODY_LIMIT`); the owner's turn and new session
|
|
172
|
+
(`OWNER_TURN_BODY_LIMIT`) and a context push 16 MB; an image 20 MB, a text to render 64 KB, `/api/update` 16 KB,
|
|
173
|
+
push 8 KB, a stop's wait and the reload check 4 KB. Over its cap, by its Content-Length (nothing read) or by what
|
|
174
|
+
came (a chunked body: the cap + 1 read), the request gets `#route`'s one **413 `too_large`** ("a request body may be
|
|
175
|
+
up to 64 KB"), with `Connection: close`. Every 4xx (or 5xx) to a request that declared a body (Content-Length > 0 or
|
|
176
|
+
Transfer-Encoding) closes the connection the same way, whichever route or the gate answered it (the gate's 401, a
|
|
177
|
+
participant's 403/404, the image path's own 413 and 429): `Web::Server`'s `CloseOnConnectionClose` turns WEBrick's
|
|
178
|
+
keep-alive off, so it doesn't read the rest of the body before answering, and `LingerAfterAnswer` reads and drops at
|
|
179
|
+
most 4 MB (2 s) after the answer so the client reads it before the close. An unauthenticated big body holds a thread
|
|
180
|
+
at most those 2 s. A 2xx/3xx keeps the connection alive; a hijacked stream is left alone. The image path keeps its own rescue: a participant's
|
|
181
|
+
oversized upload is audited `too_large`, not `internal_error` (`SessionControl#image_upload_bytes`).
|
|
182
|
+
|
|
166
183
|
Then `#route`, for each matching `ROUTES` row:
|
|
167
184
|
|
|
168
185
|
1. A participant on a `/api/sessions/:id…` route whose id isn't their grant's session gets **404 `not_found`**, the
|
|
@@ -186,6 +203,7 @@ row answers another session's id 404, so a new route is covered without a new ex
|
|
|
186
203
|
| `GET /` | participant | the main page (`index.html`) stamped for them (`App#participant_index_data`: their viewer, the grant's session and its title; [web-frontend.md](web-frontend.md#the-participants-page)); the page reads the rest through the show and the stream below |
|
|
187
204
|
| `POST /api/token` | participant | trade a link's one-time code or a pasted token for the `chi_token` cookie (the token is not left in the page URL) |
|
|
188
205
|
| `GET /api/sessions/:id/stream` | participant | the session's stream through `ParticipantStreamFilter` (only `from_seq` and `snapshot` reach the Bridge); it ends within a poll of a revoke or the expiry |
|
|
206
|
+
| `GET /api/sessions/:id/prompt_history` | participant | their own accepted messages in this session for ↑/↓, oldest first, redacted, `{entries}` ([A participant's prompt history](#a-participants-prompt-history)); the owner calling it: a plain 403 (their list is `GET /api/history`, `:owner`) |
|
|
189
207
|
| `GET /api/sessions/:id/working_set` | participant | the working set's project files only (`ParticipantView.working_set`), with `running` |
|
|
190
208
|
| `POST /api/sessions/:id/images` | participant | their upload ([Participant images](#participant-images)): refused at their cap, past their attempts or quota, a bmp/tiff/heic; the reply `{file, name, width, height}` |
|
|
191
209
|
| `GET /api/sessions/:id/images/<name>` | participant | only an image they uploaded, `Cache-Control: no-store`; any other the 404 a missing file gets |
|
|
@@ -211,11 +229,11 @@ ran read-only may run with tool rights here. Whether a participant's turn runs i
|
|
|
211
229
|
`ParticipantTurnMode.of(entry:, session:, now:)`: `:pair` (it runs), `:revoked` (no current entry: none, revoked,
|
|
212
230
|
expired, or anything that isn't an entry), `:outdated` (an older chi's read-only invite, or a participant's Verify fresh
|
|
213
231
|
child saved read-only) or `:not_invited` (no session, or the owner's own Verify fresh child). The worker
|
|
214
|
-
(
|
|
232
|
+
(`WorkerParticipantGate#refusal`: `:outdated` → `outdated`, the other two → `revoked`, no new reason on the wire) and the
|
|
215
233
|
guardrails (`GuardrailWiring#participant_turn_mode`: `:pair` → `PAIR`, else `REFUSED`) both read it; `Grant#state`
|
|
216
234
|
and `Entry#outdated?` use its `invite_mode?`.
|
|
217
235
|
- A grant without it (an older chi's read-only invite) is ended at the gate (`token_outdated`, above), and its
|
|
218
|
-
`participants.json` entry is not active (`Participants::Entry#outdated?`): the worker's
|
|
236
|
+
`participants.json` entry is not active (`Participants::Entry#outdated?`): the worker's `WorkerParticipantGate#refusal`
|
|
219
237
|
refuses its turns with `outdated` (every Bridge and inbox-file turn, and every line the own-turn drain would merge,
|
|
220
238
|
passes there: an older chi web still running and files queued before the upgrade are covered), and the system
|
|
221
239
|
prompt's line and the terminal's count leave it out.
|
|
@@ -281,7 +299,8 @@ Refused before delivery, each audited:
|
|
|
281
299
|
`deliver_turn` as `images:`; the turn's audit line counts them (`images`), accepted or refused by the worker.
|
|
282
300
|
|
|
283
301
|
It goes out with that delivery and `pending_limit` = the grant's queue limit + 1 (the running one), never
|
|
284
|
-
into the owner's prompt history
|
|
302
|
+
into the owner's prompt history: an accepted one goes into their own ([A participant's prompt
|
|
303
|
+
history](#a-participants-prompt-history)). The Bridge counts the author's running and queued turns under its event lock and
|
|
285
304
|
answers 429 `too_many_turns` past it; with no worker, their waiting input files are counted, and the new one
|
|
286
305
|
written, under the session dir's `participants.lock` (`SessionManager.deliver_turn`), so two at once can't both
|
|
287
306
|
pass. The ack is 202 with the worker's
|
|
@@ -305,6 +324,11 @@ worker checks their link (`participants.json`: revoked, expired, an older chi's)
|
|
|
305
324
|
turn is dequeued (`:turn_dequeued`) and audited (`revoked`, `outdated`, `cap_reached`) instead of run, so a revoke also stops what they
|
|
306
325
|
had queued; its settled record (`TurnCheckpoint.record_refused`: canceled, `cancel_reason` the reason) ends their
|
|
307
326
|
wait on it at once, which `ParentReport` reads as status `refused`, exit 1.
|
|
327
|
+
Every one of these asks is one seat, `WorkerParticipantGate` (`worker_participant_gate.rb`, built in `Worker#start`):
|
|
328
|
+
`#refusal` for a queued turn as it starts, a line the drain would merge and the owner's Continue on a participant's
|
|
329
|
+
offer (`ContinueOffer`'s `participant_refused:`), `#turn_stop` for a running pair turn (`Engine#participant_stop`),
|
|
330
|
+
`#refuse` for the dequeue and audit, `#watch` for `:participants_changed`. It runs on the worker's loop thread only
|
|
331
|
+
(a turn runs there too) and takes no lock; `Worker#held_for_offer?` (read from Bridge threads too) is not in it.
|
|
308
332
|
|
|
309
333
|
**The Verify gate.** A worker names `verify` (`VerifyAnchor::FEATURE`, in the Bridge's `FEATURES`) when it understands a
|
|
310
334
|
Verify turn's anchor (`VerifyAnchor`, `{turn_id, quote}`: a UUID and a quote of 1 to 200 characters). A turn carrying an
|
|
@@ -388,12 +412,12 @@ and `ctx.turn_author` names it ([hooks](../hooks.md#participants-turns)).
|
|
|
388
412
|
their $2.00 cap: their turns stop and are refused until you raise it (chi share cap ID p_… AMOUNT)." A turn stops
|
|
389
413
|
mid-turn: before each
|
|
390
414
|
generation (`KernelLoop::Services#generation_guard`, both loops) `Engine#guard_participant_spend` asks the worker's check
|
|
391
|
-
(`
|
|
415
|
+
(`WorkerParticipantGate#turn_stop`: `metrics.spend(author)` counts the running turn's finished generations) and, past
|
|
392
416
|
the cap, stops the turn on the plugins' stop path (`HookRoutes#stop_turn`: "stopped the turn: Alex reached their
|
|
393
417
|
$2.00 cap"), with the owner's notice once per cap. A generation's cost is known only when it ends, so a pair turn
|
|
394
418
|
can overshoot the cap by its last generation (and the side requests it caused); there is no projection of the
|
|
395
419
|
next one. The same check stops a pair turn whose link ended mid-turn (revoked, expired, the session archived):
|
|
396
|
-
"stopped the turn: Alex's link was revoked or expired" (`
|
|
420
|
+
"stopped the turn: Alex's link was revoked or expired" (`WorkerParticipantGate::REVOKED_STOP`). The session-wide `cost-cap` bundle still applies, and its
|
|
397
421
|
question in a participant's turn goes to the owner.
|
|
398
422
|
|
|
399
423
|
**Streams.** A participant's stream is filtered ([below](#what-a-participant-sees)), and it ends with their link:
|
|
@@ -447,7 +471,8 @@ context's fill, the speed, each turn's time and the working set's file names.
|
|
|
447
471
|
Not tool output or arguments, thinking, approvals' and questions' content, memories (text or names), context notes,
|
|
448
472
|
plugin steers, automatic and delegate input, cards, command output, the working set's memories and URLs, cost
|
|
449
473
|
(but their own usage, as their grant's exposure shows it), tokens and cost per model, guardrail judgments,
|
|
450
|
-
host paths or the owner's prompt history
|
|
474
|
+
host paths or the owner's prompt history (their own messages for ↑ come from their own list, redacted:
|
|
475
|
+
[A participant's prompt history](#a-participants-prompt-history)). Every read a participant reaches goes through one module,
|
|
451
476
|
`Web::ParticipantView` (`lib/samagotchi/web/participant_view.rb`), whose every answer is a new hash built from named
|
|
452
477
|
fields: a field added to an event later reaches nobody until it is named there.
|
|
453
478
|
|
|
@@ -627,7 +652,7 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
|
|
|
627
652
|
- **The child is its requester's.** Its session file carries `verify_fresh: {author, mode, of, anchor}`
|
|
628
653
|
(`VerifyFreshOrigin`), saved before its worker starts. `author` is the participant's (`p:<id>`), none for the
|
|
629
654
|
owner. `mode` is `pair` (`Grants::PAIR_MODE`: every live grant's); a child an older chi saved with `review` is refused,
|
|
630
|
-
never run (`VerifyFreshOrigin#pair?`, `
|
|
655
|
+
never run (`VerifyFreshOrigin#pair?`, `WorkerParticipantGate#refusal` `outdated`). Every
|
|
631
656
|
turn of a participant's child is theirs, whoever starts it (the owner typing into it, a continue, a reminder):
|
|
632
657
|
`VerifyFreshOrigin#origin_for` sets the author in `Engine#begin_turn` and in the worker, so their boundary
|
|
633
658
|
(`GuardrailWiring#begin_turn` reads the saved mode, never a lookup), their System 1 skip, their once-only asks to
|
|
@@ -646,7 +671,7 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
|
|
|
646
671
|
card: fails closed.
|
|
647
672
|
- **Spend.** The parent's `verify_fresh.jsonl` (one line per child: `child_id`, `of`, `author`, `at`) is the
|
|
648
673
|
rollup's index: a participant's cap check in chi web (`#participant_saved_spend`), their usage line, and the
|
|
649
|
-
worker's (`
|
|
674
|
+
worker's cap check (`WorkerParticipantGate#refusal`, its spend) add their fresh children's saved spend (`VerifyFresh.children_spend`); a
|
|
650
675
|
child's worker adds the parent's saved spend and its siblings'. A child's spend counts from its turns' ends, as
|
|
651
676
|
a turn's does.
|
|
652
677
|
- **The verdict lands on the card**, never in the parent's conversation: the child's worker writes each verdict
|
|
@@ -661,7 +686,8 @@ owner's machine (`home`, the folders, `project-*`, `back-*`).
|
|
|
661
686
|
participant can't open it). No push
|
|
662
687
|
for a fresh verdict yet (`Attention` pushes a verdict at a turn's end).
|
|
663
688
|
- **The composer** is the owner's, with what is theirs (`participant_main.js`; [web-frontend.md](web-frontend.md#the-participants-page)):
|
|
664
|
-
no `/` list or plugin pills, no ↑/↓
|
|
689
|
+
no `/` list or plugin pills, no model picker; ↑/↓ walks their own messages in this session, never the owner's
|
|
690
|
+
`GET /api/history` ([A participant's prompt history](#a-participants-prompt-history)). Images go
|
|
665
691
|
in as the owner's do (paste, drop, the image button), within their quota ([Participant images](#participant-images));
|
|
666
692
|
a refused upload or send keeps the chips and toasts the server's words. While their own turn runs, a message goes in at its next step on a
|
|
667
693
|
worker with `participant_steer` (Alt+Enter queues it); while anyone else's runs, it goes in as their own turn after
|
|
@@ -718,6 +744,31 @@ the token or its digest.
|
|
|
718
744
|
the local chi web's LAN address when one runs (its `GET /api/info`), else `127.0.0.1` with a line saying it opens on
|
|
719
745
|
this machine only.
|
|
720
746
|
|
|
747
|
+
## A participant's prompt history
|
|
748
|
+
|
|
749
|
+
A participant's ↑/↓ in the composer walks their own messages in this session, as the owner's walks the owner's.
|
|
750
|
+
|
|
751
|
+
- **Recorded at accept.** `ParticipantAccess#participant_turn_result`'s accepted branch (beside its audit line) calls
|
|
752
|
+
`Web::ParticipantHistory#record_participant_prompt`: `ParticipantPrompts.append` under the principal's grant id
|
|
753
|
+
(never a body field: `author` and `client_id` are ignored, `history` counts only as the boolean `false`, an
|
|
754
|
+
image-only send), with the session's grants `Grants` still knows as the live ones. A send chi web refuses (a `!`/`/`
|
|
755
|
+
line, a cut, the cap, too many turns, bad images, a Revise of another's turn), times out on or fails to enqueue
|
|
756
|
+
records nothing. Recorded by design, because chi web accepted them (202), as the owner's `record_history`: a queued
|
|
757
|
+
turn the worker refuses at its start (the cap re-check, an outdated invite), a Revise overtaken at the stamp and a
|
|
758
|
+
queued turn they take back. A failed write never fails the send (`Log.warn`). The owner's `PromptHistory` is never
|
|
759
|
+
read or written for a participant.
|
|
760
|
+
- **Served to its grant only.** `GET /api/sessions/:id/prompt_history` (`:participant`, `:session`: another
|
|
761
|
+
session's id is the router's unknown session first) answers `{entries}` with `Cache-Control: no-store`:
|
|
762
|
+
`ParticipantPrompts.entries` for `principal(req).grant.id`, each through `Redact.text` with their viewer (the
|
|
763
|
+
grant's author, the session folder from `SessionHub#working_directory`, else the saved session's, and
|
|
764
|
+
`owner_secrets`), so a recalled message reads as their conversation shows it (`[redacted]`, a relative path,
|
|
765
|
+
`~`). No query or body is read; entries only (no grant id, name or time). The owner gets a plain 403
|
|
766
|
+
`not_permitted` with no audit line. The page asks for it with `own_prompt_history`
|
|
767
|
+
(`participant_history.js`; [web-frontend.md](web-frontend.md#the-viewer)).
|
|
768
|
+
- **Per invite, from now.** Lists are per grant: a new invite for the same person starts empty, and messages sent
|
|
769
|
+
before this landed aren't in it (no backfill). A swept grant's id reissued in the same session (about 1 in 2³²)
|
|
770
|
+
could inherit a list no append has pruned yet, as `participant_images.json` and `participants.json` today.
|
|
771
|
+
|
|
721
772
|
## Files in the session dir
|
|
722
773
|
|
|
723
774
|
None is in the session JSON (chi web never saves that, and a worker would overwrite a field it added), and
|
|
@@ -747,6 +798,11 @@ invited to has none: its files stay byte for byte as they were.
|
|
|
747
798
|
`images/`: no route serves it): `{images: [{file, grant_id, at}], attempts: {<grant id>: n}}`, which image files
|
|
748
799
|
each grant uploaded and how many uploads each tried. Written whole (`AtomicFile`) under chi web's
|
|
749
800
|
`@participant_images_mutex`. It goes with the session.
|
|
801
|
+
- **`participant_prompts.json`** (0600, `ParticipantPrompts`, chi web only, beside `participants.json`; served only
|
|
802
|
+
through `GET …/prompt_history`, to its grant, redacted): `{prompts: {<grant id>: [text, …]}}`, each grant's accepted
|
|
803
|
+
messages, oldest first, at most 100 of at most 16 KB each (a longer one isn't recorded); the lists of grants the
|
|
804
|
+
grants store no longer knows are pruned on an append; a file that doesn't read is never written over and reads as
|
|
805
|
+
none. Written whole (`AtomicFile`) under chi web's `@participant_prompts_mutex`. It goes with the session.
|
|
750
806
|
- **`participants.lock`** (0600, empty): the lock a participant's turn file is counted and written under when no
|
|
751
807
|
worker runs ([Turns](#turns)).
|
|
752
808
|
|
|
@@ -863,6 +919,8 @@ participant TUI in v1.
|
|
|
863
919
|
older chi's unstamped or read-only message), and never merged into the owner's message.
|
|
864
920
|
- The owner's input is never merged into a participant's running turn (the Bridge queues it, the drain takes only
|
|
865
921
|
the participant's own lines): it runs as the owner's own turn after it.
|
|
922
|
+
- A participant's ↑ list is built from their grant's accepted sends only, keyed by the principal, and served only
|
|
923
|
+
to that grant, redacted; never the owner's prompt history or another participant's messages.
|
|
866
924
|
- A participant stops only a turn they started, named by its id, which the worker compares under its lock.
|
|
867
925
|
- A participant revises only their own answer with only their own turns after it, checked by chi web at the send and
|
|
868
926
|
by the worker at the stamp (`ParticipantRevise`); their Revise never folds anyone else's turn.
|
|
@@ -199,7 +199,7 @@ with a "Machine-local" comment; the rest branch on `@access.remote?` (`SendComma
|
|
|
199
199
|
| `sessions list`'s default project (`ProjectScope.root_for(Dir.pwd)`) | client | every project's; `--scope=project` needs `--cwd` (a folder there) |
|
|
200
200
|
| `context`'s default session (`SAMAGOTCHI_PARENT_SESSION`, `ContextCommand#inside_session`) | client | no default: ids are required (`added_by` still reads it) |
|
|
201
201
|
| A context URL's provider (`ContextProviders.resolve`) | client's bundles | server's bundles (`Remote#context_add_url`) |
|
|
202
|
-
| UI-only slash commands (`
|
|
202
|
+
| UI-only slash commands (`SessionCommandCatalog.ui_only_entry`), `--image` ingest, note text (`SessionInbox.checked_text`), push text (`ContextSources.parse_output`) | client | client too (the server checks note and push text again) |
|
|
203
203
|
| A remote attach's `--attach`/`--resume` id (`Session.resolve_id`), the leftover scratch check, the one-turn run's refusal (`OwnerLock::TUI_BUSY`) | client (bin/chi, `AttachLauncher.connect`) | server: `Remote#resolve`, then `POST …/wake`'s 409s |
|
|
204
204
|
| A new attached session's `--toolkit`, `--set`, `--thinking`, `--llm-context*`, `--parent-answers`, `--model` | client (bin/chi) | server: `POST /api/sessions` with `idle: true` and `SetupWords`; its warnings printed as `send --new` prints them |
|
|
205
205
|
| The status row's default model, the newest chi for the version line, what a parent may pick (exit 3) | client | server: the wake's `default_model`, `installed`, `parent_strategy` (the last read again from `GET …/worker` at report time) |
|