samagotchi 0.180.0 → 0.181.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 +46 -1
- data/bin/chi +10 -0
- data/docs/architecture.md +1 -1
- data/docs/bundles.md +7 -2
- data/docs/cli.md +16 -9
- data/docs/configuration.md +24 -4
- data/docs/internals/anthropic.md +4 -3
- data/docs/internals/background-tasks.md +2 -0
- data/docs/internals/block-renderers.md +9 -6
- data/docs/internals/objectives.md +9 -4
- data/docs/internals/web-frontend.md +67 -7
- data/docs/internals/working-set.md +24 -5
- data/docs/memory.md +3 -0
- data/docs/plugins.md +11 -4
- data/docs/sessions.md +1 -1
- data/docs/testing.md +1 -1
- data/lib/samagotchi/bundle_command.rb +4 -1
- data/lib/samagotchi/bundles/known-names/manifest.yml +2 -2
- data/lib/samagotchi/bundles/known-names/plugin.rb +4 -3
- data/lib/samagotchi/bundles/system/config_modification_protocol.md +3 -2
- data/lib/samagotchi/bundles/system/manifest.yml +2 -2
- data/lib/samagotchi/client.rb +8 -1
- data/lib/samagotchi/config.rb +6 -1
- data/lib/samagotchi/core_notice.rb +44 -0
- data/lib/samagotchi/host_address.rb +7 -0
- data/lib/samagotchi/host_config.rb +8 -5
- data/lib/samagotchi/host_registry.rb +26 -8
- data/lib/samagotchi/kernel_loop.rb +3 -2
- data/lib/samagotchi/llm/adapter_common.rb +3 -2
- data/lib/samagotchi/llm/adapters.rb +2 -1
- data/lib/samagotchi/llm/anthropic_assembly.rb +5 -0
- data/lib/samagotchi/llm/anthropic_messages.rb +6 -2
- data/lib/samagotchi/llm/chat_loop.rb +6 -5
- data/lib/samagotchi/llm/errors.rb +41 -3
- data/lib/samagotchi/llm/http.rb +85 -22
- data/lib/samagotchi/llm/openai_chat.rb +20 -3
- data/lib/samagotchi/memory_bundle/status.rb +2 -1
- data/lib/samagotchi/objectives.rb +7 -2
- data/lib/samagotchi/owner_lock.rb +2 -0
- data/lib/samagotchi/plugin/api.rb +4 -1
- data/lib/samagotchi/plugin/context.rb +9 -0
- data/lib/samagotchi/plugin/peer.rb +32 -15
- data/lib/samagotchi/plugin/tool_spec.rb +13 -2
- data/lib/samagotchi/row_refs.rb +14 -3
- data/lib/samagotchi/session_chain/delete.rb +6 -6
- data/lib/samagotchi/session_manager/removal.rb +2 -2
- data/lib/samagotchi/tool_ids.rb +19 -0
- data/lib/samagotchi/tool_runner.rb +8 -4
- data/lib/samagotchi/tools/registry.rb +3 -2
- data/lib/samagotchi/tools/task_runtime.rb +34 -0
- data/lib/samagotchi/turn_stages/objectives.rb +10 -5
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/public/app.js +10 -14
- data/lib/samagotchi/web/public/block_host.js +20 -20
- data/lib/samagotchi/web/public/block_renderers.css +5 -5
- data/lib/samagotchi/web/public/context_chips.js +3 -4
- data/lib/samagotchi/web/public/images.js +1 -1
- data/lib/samagotchi/web/public/index.html +24 -5
- data/lib/samagotchi/web/public/objectives_strip.js +16 -6
- data/lib/samagotchi/web/public/pan_zoom.js +121 -0
- data/lib/samagotchi/web/public/peer_chip.js +3 -3
- data/lib/samagotchi/web/public/peer_data.js +27 -15
- data/lib/samagotchi/web/public/picture_viewer.js +304 -0
- data/lib/samagotchi/web/public/popover_modal.js +3 -2
- data/lib/samagotchi/web/public/session_view.js +4 -0
- data/lib/samagotchi/web/public/working_set.js +9 -3
- data/lib/samagotchi/web/public/working_set_view.js +28 -11
- data/lib/samagotchi/web/public/ws_cards.js +36 -10
- data/lib/samagotchi/web/public/ws_markdown.js +129 -0
- data/lib/samagotchi/web/public/ws_order.js +48 -0
- data/lib/samagotchi/web/public/ws_peek.js +22 -5
- data/lib/samagotchi/web/public/ws_preview.css +41 -1
- data/lib/samagotchi/web/public/ws_reader.js +35 -6
- data/lib/samagotchi/web/public/ws_sections.js +24 -15
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ef194e6af0d4be30d6b98a61f1995582670d7d5823d684733b0f75175b58857a
|
|
4
|
+
data.tar.gz: 94467de696fd0223e72755c109f7fc0dd2c2ae6edf6fa3014ff8bde4f86748cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a019f5cddf59cf801f080f96c8b8d4579504f3f7a712f8d20a9b6010e7ac4d9218f9650c6d7f7630351329b9dadfeb3896a6a52d1b2c95782cd93514f180639
|
|
7
|
+
data.tar.gz: fc52dd4dda346a56abddac22161b42c65014b8bf9cd4dee5196c0412c1a751aab116d4def340f774bde911f7ff7c6e7d6249012804d90edcd67fdf8929bbdd86
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,50 @@ and commands may change between minor versions. How releases are made:
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.181.0] - 2026-11-21
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- In the web, an attached image opens in a full-screen viewer, fitted: pinch, Ctrl/Cmd + scroll or the bar's − and +
|
|
16
|
+
zoom (sharp at every size), a drag or scroll moves, a double tap goes close and back, ✕ or Esc closes. A tap on
|
|
17
|
+
the picture no longer closes it.
|
|
18
|
+
- In the web, one tap on a drawn diagram (a mermaid block) opens it in that viewer, fitted to the screen, to zoom in
|
|
19
|
+
and move around; in the answer it stays fitted to the column (the tap no longer switches it to its natural size).
|
|
20
|
+
On a phone the diagram's rendered | source switch stays shown, faint.
|
|
21
|
+
- In the web, the working set's reader and peek show a memory and a whole read of a `.md` file as rendered
|
|
22
|
+
markdown, with a `rendered | source` switch on the reader's cards (the same small pill on a phone); a memory's
|
|
23
|
+
peek starts at its body, without the front matter. A slice of a file stays numbered source.
|
|
24
|
+
- chi reminds you once on stderr when no core safety bundles are installed, including in a one-shot.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- A background task's folder (`tmp/tasks/`) is added to the repository's `.git/info/exclude`, so `git status`
|
|
29
|
+
doesn't list it.
|
|
30
|
+
- In the web, the working set's peek and reader say an item read in the step still running shows once that step's
|
|
31
|
+
tools finish, rather than "Nothing of it in the conversation yet".
|
|
32
|
+
- `chi bundle status NAME` reports a rule or script with no recorded sha256 as `[unrecorded]`, not `[modified]`.
|
|
33
|
+
- The web's working-set list opens on what chi touched last: "Read in this session" first, newest first (a row's
|
|
34
|
+
step tag is its last touch), the conversation's row, then "From the start", folded to one line with its
|
|
35
|
+
`held twice` count. Rows don't move while the list is open; new ones come in on top.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- The known-names guardrail no longer flags a project's class name in backticks
|
|
40
|
+
(`CoffeeAssistant` for `coffee_assistant`) as a typo.
|
|
41
|
+
- A streamed answer that stops mid-way (no text, reasoning or tool call for `stream_idle_timeout` seconds; default
|
|
42
|
+
120 on remote hosts, off on local) is closed and asked again like a dropped stream, then fails with `the model's
|
|
43
|
+
stream stalled …`, instead of waiting on keep-alives until the read timeout.
|
|
44
|
+
- The objectives strip no longer shows an empty 0/0 bar when every objective is dropped, and disappears at once when
|
|
45
|
+
the list goes away.
|
|
46
|
+
- A continue no longer starts with an empty Objectives bubble when every objective was dropped.
|
|
47
|
+
- Deleting a session no longer sometimes refuses it as in use while chi web is checking it.
|
|
48
|
+
- The peer chip says when no inbox is attached, rather than blaming a remote.
|
|
49
|
+
- Sending a peer the same part twice no longer marks the first, answered send "not sent" in the web: each send has
|
|
50
|
+
its own id.
|
|
51
|
+
|
|
52
|
+
Update with `chi update` (known-names 0.2.1 carries the backtick fix).
|
|
53
|
+
|
|
54
|
+
|
|
11
55
|
## [0.180.0] - 2026-11-20
|
|
12
56
|
|
|
13
57
|
### Added
|
|
@@ -6576,7 +6620,8 @@ and long-lived sessions.
|
|
|
6576
6620
|
- A macOS desktop helper (`chi desktop install`): a "Send to chi" Service and a
|
|
6577
6621
|
hotkey panel that send selected text or the clipboard to your sessions.
|
|
6578
6622
|
|
|
6579
|
-
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.
|
|
6623
|
+
[Unreleased]: https://github.com/dm1try/samagotchi/compare/v0.181.0...HEAD
|
|
6624
|
+
[0.181.0]: https://github.com/dm1try/samagotchi/compare/v0.180.0...v0.181.0
|
|
6580
6625
|
[0.180.0]: https://github.com/dm1try/samagotchi/compare/v0.179.0...v0.180.0
|
|
6581
6626
|
[0.179.0]: https://github.com/dm1try/samagotchi/compare/v0.178.0...v0.179.0
|
|
6582
6627
|
[0.178.0]: https://github.com/dm1try/samagotchi/compare/v0.177.1...v0.178.0
|
data/bin/chi
CHANGED
|
@@ -260,6 +260,10 @@ end
|
|
|
260
260
|
|
|
261
261
|
if options[:web]
|
|
262
262
|
chi_update_hint.call unless web_restarted
|
|
263
|
+
unless web_restarted
|
|
264
|
+
require "samagotchi/core_notice"
|
|
265
|
+
Samagotchi::CoreNotice.show
|
|
266
|
+
end
|
|
263
267
|
require "samagotchi/web/server"
|
|
264
268
|
port = options[:web_port] || Samagotchi::Config.get("web.port")
|
|
265
269
|
markdown = options[:web_markdown]
|
|
@@ -416,6 +420,8 @@ if launch == :attached
|
|
|
416
420
|
exit 1
|
|
417
421
|
end
|
|
418
422
|
|
|
423
|
+
require "samagotchi/core_notice"
|
|
424
|
+
Samagotchi::CoreNotice.show
|
|
419
425
|
require "samagotchi/terminal_ui/attach_launcher"
|
|
420
426
|
begin
|
|
421
427
|
ended = Samagotchi::TerminalUI::AttachLauncher.run(attach: options[:attach], resume: options[:resume],
|
|
@@ -445,6 +451,10 @@ end
|
|
|
445
451
|
|
|
446
452
|
# --non-interactive: the -p prompt's one turn in this process (TerminalUI,
|
|
447
453
|
# the one-shot host); bare, a no-op that creates no session.
|
|
454
|
+
if options[:prompt]
|
|
455
|
+
require "samagotchi/core_notice"
|
|
456
|
+
Samagotchi::CoreNotice.show
|
|
457
|
+
end
|
|
448
458
|
require "samagotchi/cli/exit"
|
|
449
459
|
require "samagotchi/terminal_ui"
|
|
450
460
|
begin
|
data/docs/architecture.md
CHANGED
|
@@ -623,7 +623,7 @@ of chi reads (the prompt is input + cache reads + cache writes), stop reasons to
|
|
|
623
623
|
(`max_tokens` → `length`, `tool_use` → `tool_calls`, `end_turn` → `stop`). A stream is read by content-block index
|
|
624
624
|
from the `data:` lines alone (`event:` lines are not needed); `message_start` / `message_delta` events reach
|
|
625
625
|
`on_delta` with that normalized `usage`, pings not at all, and a block's start or delta counts as shown for the
|
|
626
|
-
first-token
|
|
626
|
+
first-token and stream-idle limits (`message_delta` and `message_stop` restart the idle clock without counting). Both adapters share their model-list cache (`LLM::ModelListing`) and their HTTP plumbing
|
|
627
627
|
(`LLM::AdapterCommon`: timeouts, the paged model list, the SSE line loop, JSON errors). A host's `dialect:`
|
|
628
628
|
(`LLM::Dialect`, `fireworks`) changes the auth header, the thinking `display`, the cache breakpoints and a session
|
|
629
629
|
header; [internals/anthropic.md](internals/anthropic.md) covers the adapter.
|
data/docs/bundles.md
CHANGED
|
@@ -9,6 +9,10 @@ feature they belong to: **source-links** in [hooks.md](hooks.md#the-source-links
|
|
|
9
9
|
every shipped bundle with code does; before known-names 0.2.0 and source-links 0.7.0 they shipped a `hooks/*.rb` file
|
|
10
10
|
(chi no longer loads one: [hooks.md](hooks.md#class-file-hooks-are-retired); `chi update` removes the old file).
|
|
11
11
|
|
|
12
|
+
`chi bootstrap` installs the recommended `core` safety profile. If none of its members has an install record,
|
|
13
|
+
chi prints a reminder to stderr at a session or web launch, including a one-shot, once per state directory. See
|
|
14
|
+
[Bundle profiles](memory.md#bundle-profiles-core-and-dev).
|
|
15
|
+
|
|
12
16
|
## The btw bundle
|
|
13
17
|
|
|
14
18
|
`chi bundle install btw` (or the `dev` profile) installs the bundle shipped with chi. It is written
|
|
@@ -1049,8 +1053,9 @@ Claude pairs; without one the bundle costs one tool declaration.
|
|
|
1049
1053
|
- **The tool `claude_send(kind, title, text)`**, `kind` being `validate`,
|
|
1050
1054
|
`context` or `question`, writes one JSON line to that socket. The message
|
|
1051
1055
|
starts with a header, `chi <id> · <kind> · <title>`, and a second line,
|
|
1052
|
-
`ref: <send id>` (`s-` and 6 hex, from the kind, title and text as given
|
|
1053
|
-
the
|
|
1056
|
+
`ref: <send id>` (`s-` and 6 hex, from the kind, title and text as given
|
|
1057
|
+
and the send itself: each send has its own id, the same part sent again
|
|
1058
|
+
too; an older chi's resend shared one), which Claude's answer gives back
|
|
1054
1059
|
so chi can tie it to its send; the tool's row in the web carries the id too.
|
|
1055
1060
|
A text up to 4,000 characters follows inline; a longer one goes to a file,
|
|
1056
1061
|
`$XDG_STATE_HOME/samagotchi/plugins/claude-peer/sessions/<id>/<HHMMSS>-<slug>.md`
|
data/docs/cli.md
CHANGED
|
@@ -1172,7 +1172,9 @@ A model that can see images gets them these ways:
|
|
|
1172
1172
|
the photo library, and is hidden while a turn runs). Each shows as a chip (× removes it) and is sent with the
|
|
1173
1173
|
message; an image alone is sent as `[image: name]`. A message takes up to 20
|
|
1174
1174
|
images of up to 20 MB each; a toast names the files left out (over a cap, or
|
|
1175
|
-
not an image). Messages show thumbnails; a click opens one
|
|
1175
|
+
not an image). Messages show thumbnails; a click opens one in the
|
|
1176
|
+
picture viewer, fitted to the screen: pinch, Ctrl/Cmd + scroll or the bar's − + zoom, a drag or scroll moves, a
|
|
1177
|
+
double tap goes close and back, ✕ or Esc closes.
|
|
1176
1178
|
- **`chi send --image PATH`** (repeatable, up to 20) with a message, from a
|
|
1177
1179
|
script or another terminal: `chi send --image shot.png -m "why is this red?"
|
|
1178
1180
|
3fa2`. The attached terminal and the web show it like an image typed there.
|
|
@@ -1409,10 +1411,13 @@ session bar shows the `mem N` chip again.
|
|
|
1409
1411
|
(`--mute`) memories included; its dot lights when the set changed since you
|
|
1410
1412
|
last opened it.
|
|
1411
1413
|
- **The list** the three open (a bottom sheet on a phone): always the whole
|
|
1412
|
-
session's set, files grouped by folder (a group opens in place), memories
|
|
1414
|
+
session's set, last touched first, files grouped by folder (a group opens in place), memories
|
|
1413
1415
|
(used, preloaded, muted) and URLs, each with what was done to it (`read ×2`,
|
|
1414
|
-
`read, edited`, `preloaded`) and a step tag (`t2·s3
|
|
1415
|
-
memory) that goes to
|
|
1416
|
+
`read, edited`, `preloaded`) and a step tag (`t2·s3`: where it was last touched; `prompt` for a preloaded
|
|
1417
|
+
memory) that goes to that call. The order is taken when the list opens and holds while it is open: what chi
|
|
1418
|
+
touches meanwhile comes in on top, the other rows stay put. With the session's prompt parts known, "Read in
|
|
1419
|
+
this session" comes first, then the conversation's row, then "From the start" (the system prompt's parts),
|
|
1420
|
+
folded to one line (with its `held twice` count) until you open it; a fold you set is kept for the session. The header's `session | ‹ turn N ›` is a lens:
|
|
1416
1421
|
the chip opens the session, a footprint or the rail opens a turn, and `‹` `›`
|
|
1417
1422
|
step through the turns. In a turn's lens the rows that turn touched are lit,
|
|
1418
1423
|
with that turn's words and step tag (`s3`), the others dimmed; the line under
|
|
@@ -1440,11 +1445,13 @@ session bar shows the `mem N` chip again.
|
|
|
1440
1445
|
stage's rail shows an add queued for its end as a dashed `+ name · next turn`
|
|
1441
1446
|
line.
|
|
1442
1447
|
- **What chi has of an item**: a row's `▸` in the list peeks at it (its latest edit's diff, else its newest
|
|
1443
|
-
read's first lines); `Open the timeline` (also a tool row's
|
|
1444
|
-
the item's timeline over the stage, newest first: reads merged
|
|
1445
|
-
as diffs, what chi no longer has greyed (with `undrop` for your
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
+
read's first lines, or a memory or a whole `.md` file rendered); `Open the timeline` (also a tool row's
|
|
1449
|
+
`timeline` and a file ref's ▾ `What chi has`) puts the item's timeline over the stage, newest first: reads merged
|
|
1450
|
+
into line slices over a strip of the file, edits as diffs, what chi no longer has greyed (with `undrop` for your
|
|
1451
|
+
drop), a changed memory's `Now · diff`. A memory and a whole read of an `.md` file show as rendered markdown (a
|
|
1452
|
+
leading front matter as source above it), with a `rendered | source` switch on the card; a slice of a file stays
|
|
1453
|
+
numbered source, and with markdown off everything is source. `← Stage` or Esc goes back to the same place, ↑↓
|
|
1454
|
+
step through the set; on a phone it is full screen (`‹ Set`, `‹ ›`). Yours only: a participant's list has no `▸`.
|
|
1448
1455
|
|
|
1449
1456
|
Only `read`, `edit`, `write`, `memory_read`, `memory_write` and `web_fetch`
|
|
1450
1457
|
calls that succeeded count; files an `execute` touched don't.
|
data/docs/configuration.md
CHANGED
|
@@ -151,7 +151,7 @@ or `chi web` restart.
|
|
|
151
151
|
| `default.input`, `no_default_input`, `no_interrupt` | Next CLI run | These set up that run's first prompt or turn limit. |
|
|
152
152
|
| `default.max_tokens`, `max_tool_output_chars`, `memory.read_max_chars`, `read.*`, `execute.*` except `execute.description`, `image.*` | Next matching request or tool use | An operation already in progress keeps its resolved limits. |
|
|
153
153
|
| `server.host`, `server.port`, `hosts.*` | Worker start | Includes host addresses, APIs, declared models and host-level settings. Commands (`chi self`, `chi models`, the session lists) and chi web (its model picker, the session cards) read `hosts:` as it is now; a running worker keeps the hosts it started with until it restarts. |
|
|
154
|
-
| `server.open_timeout`, `server.read_timeout`, `server.first_token_timeout` | Worker start | The worker's clients retain the timeouts set when they were built. |
|
|
154
|
+
| `server.open_timeout`, `server.read_timeout`, `server.first_token_timeout`, `server.stream_idle_timeout` | Worker start | The worker's clients retain the timeouts set when they were built. |
|
|
155
155
|
| `model_aliases` | Next model lookup | A session keeps its resolved model unless it is explicitly switched. |
|
|
156
156
|
| `models.<key>.profile` | Session start or `/model` | It is resolved when that model is selected; editing it does not switch the current model's profile by itself. |
|
|
157
157
|
| Other `models.<key>.*` settings | Next turn or model lookup | Sampling, thinking, vision, context, window, price and steer settings are resolved from the file for their next use. |
|
|
@@ -352,8 +352,8 @@ doesn't end in a local suffix (`gpu.example.com`). A name without a dot (`box`)
|
|
|
352
352
|
or ending in `localhost`, `.local`, `.lan`, `.home`, `.home.arpa`, `.internal`,
|
|
353
353
|
`.intranet`, `.localdomain`, `.private`, `.corp`, `.test`, `.box` (`fritz.box`)
|
|
354
354
|
or `.ts.net` (Tailscale) is local: chi doesn't look names up. A remote
|
|
355
|
-
host keeps its model list for 10 minutes, gets a 120-second first-token limit
|
|
356
|
-
and isn't asked for llama.cpp's `/props` (its context window and served model
|
|
355
|
+
host keeps its model list for 10 minutes, gets a 120-second first-token limit
|
|
356
|
+
and a 120-second stream-idle limit, and isn't asked for llama.cpp's `/props` (its context window and served model
|
|
357
357
|
come from its model list and each turn). A local `api: openai` host has no
|
|
358
358
|
`/props`, so `chi self` GETs its `/models` with the same short probe timeouts
|
|
359
359
|
and reports up/down with the ids it serves. `remote: true` or `remote: false` on a
|
|
@@ -919,6 +919,24 @@ hosts:
|
|
|
919
919
|
which applies to every host. With neither set, remote hosts (see "Remote or local" above) get 120 seconds and local
|
|
920
920
|
servers no limit: a long prompt evaluation is normal there, and the read timeout catches a dead server.
|
|
921
921
|
|
|
922
|
+
Once a stream has shown something, a **stream-idle limit** watches the rest: the seconds it may go without showing
|
|
923
|
+
more text, reasoning or a tool call. Keep-alive comments don't count, so an answer that stops mid-way is no longer
|
|
924
|
+
held open until the read timeout. A stalled stream is closed and asked again like a dropped one (`↻ retrying
|
|
925
|
+
(stream dropped) …`, its partial output dropped; see "Retries" below); once those run out the turn fails with `the
|
|
926
|
+
model's stream stalled on host <name>: no output for 120s (stream_idle_timeout); …`. The end of an answer (a finish
|
|
927
|
+
reason, the usage chunk, Anthropic's `message_delta` and `message_stop`) restarts the clock too, so a slow trailing
|
|
928
|
+
usage chunk doesn't void a complete answer.
|
|
929
|
+
|
|
930
|
+
```yaml
|
|
931
|
+
hosts:
|
|
932
|
+
openrouter:
|
|
933
|
+
stream_idle_timeout: 300 # seconds; 0 = off
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
`hosts.<name>.stream_idle_timeout` wins over `server.stream_idle_timeout` (`SAMAGOTCHI_SERVER_STREAM_IDLE_TIMEOUT`),
|
|
937
|
+
which applies to every host. With neither set, remote hosts get 120 seconds and local servers no limit: a local
|
|
938
|
+
server may stream nothing while it buffers a long tool call's arguments.
|
|
939
|
+
|
|
922
940
|
Every chat request carries the session's id as a `Session-Id` header (next to `User-Agent: chi/<version>`). A
|
|
923
941
|
gateway that spreads requests over several providers can key on it to keep one conversation on one provider, so
|
|
924
942
|
prompt caches hit and every turn is answered by the same model. Servers that don't know the header ignore it.
|
|
@@ -1114,7 +1132,8 @@ Transient network failures are retried automatically with exponential backoff.
|
|
|
1114
1132
|
chat loop (an OpenAI-compatible host) drops the partial reply and asks again for the whole step, from the same
|
|
1115
1133
|
conversation, at most twice (at most `retry.max` times when that is smaller: `retry.max: 0` turns it off), after
|
|
1116
1134
|
the same backoff, reported as a retry (`↻ retrying (stream dropped) …`); once those run out the turn fails with
|
|
1117
|
-
the error, as before. A
|
|
1135
|
+
the error, as before. A stream that stalled past its `stream_idle_timeout` is asked again the same way. A refusal,
|
|
1136
|
+
a first-token timeout, a provider error and a cancel are never retried this way.
|
|
1118
1137
|
- Cancellation (`Ctrl-C`) is never retried.
|
|
1119
1138
|
|
|
1120
1139
|
Configuration:
|
|
@@ -2247,6 +2266,7 @@ column says so, a `--kebab-name` flag. The maps (`hosts:`, `models:`,
|
|
|
2247
2266
|
| `server.open_timeout` | `10` | yes | Connection timeout, seconds. |
|
|
2248
2267
|
| `server.read_timeout` | `600` | yes | Read timeout, seconds. |
|
|
2249
2268
|
| `server.first_token_timeout` | 120 remote, off local | | Seconds to the first token; `0` = off. `hosts.<name>.first_token_timeout` wins. |
|
|
2269
|
+
| `server.stream_idle_timeout` | 120 remote, off local | | Seconds a stream that showed something may go without more; `0` = off. `hosts.<name>.stream_idle_timeout` wins. |
|
|
2250
2270
|
| `recap.enabled` | on | | `false` (or `recap: false`) turns the idle recap off. Per session too: `--set recap.enabled=false`, or `/recap off` in the session (see "Per-session settings"). |
|
|
2251
2271
|
| `recap.model` | session's | yes | Model that writes the recap: an id, alias or `host:model` (the host then picks where to ask; a bare id goes where a bare `--model` goes). |
|
|
2252
2272
|
| `recap.host_ref` | session's | yes | A `hosts:` name to ask (`host:` is accepted too, also a host name, not a model ref). |
|
data/docs/internals/anthropic.md
CHANGED
|
@@ -15,7 +15,7 @@ ChatLoop::Run#generate
|
|
|
15
15
|
→ AnthropicWire.translate # system blocks + messages, cache_control placed
|
|
16
16
|
→ AnthropicWire.tools # function schemas → {name, description, input_schema},
|
|
17
17
|
# a deferred one with defer_loading: true
|
|
18
|
-
→ POST {base}/v1/messages # LLM::HTTP: retries, cancel, first-token
|
|
18
|
+
→ POST {base}/v1/messages # LLM::HTTP: retries, cancel, first-token and stream-idle limits
|
|
19
19
|
→ AnthropicAssembly#add per SSE event # → ChatResponse (text, reasoning, tool_calls, usage,
|
|
20
20
|
# finish_reason, provider_content)
|
|
21
21
|
→ a signature 400 (Claude 5.x preserved thinking): AnthropicBindingRecovery#advance, then the same
|
|
@@ -90,8 +90,9 @@ A stream is read from its `data:` lines alone (a gateway that drops the `event:`
|
|
|
90
90
|
index: `message_start` (served model, usage), `content_block_start` (text, thinking, redacted_thinking, tool_use),
|
|
91
91
|
`content_block_delta` (`text_delta`, `thinking_delta`, `signature_delta`, `input_json_delta`), `message_delta`
|
|
92
92
|
(stop reason, `stop_details`, usage). `AnthropicMessages#chat_streamed` passes every event but `ping` to `on_delta`,
|
|
93
|
-
`message_start` and `message_delta` with the usage so far attached (`#with_usage`); a block's start or delta counts as shown for the first-token
|
|
94
|
-
(`.shows?`)
|
|
93
|
+
`message_start` and `message_delta` with the usage so far attached (`#with_usage`); a block's start or delta counts as shown for the first-token and stream-idle limits
|
|
94
|
+
(`.shows?`); `message_delta` and `message_stop` restart the stream-idle clock without counting as shown (`.ending?`), so a
|
|
95
|
+
slow end of a complete answer doesn't stall it. A 200 whose body is a JSON error instead of a stream raises that error (`LLM::AdapterCommon#raise_plain_error`, shared with the OpenAI adapter).
|
|
95
96
|
|
|
96
97
|
`#response` is a `ChatResponse`:
|
|
97
98
|
|
|
@@ -29,6 +29,8 @@ Behavior:
|
|
|
29
29
|
|
|
30
30
|
- `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.
|
|
31
31
|
- Task metadata and output are persisted under `tmp/tasks/`: each task's `tmp/tasks/<id>/task.json` is a `TaskRecord` (`lib/samagotchi/tools/task_record.rb`, a value object: `.from_file` reads it, `#to_file` is the JSON object written, an update is a `#with`). Its keys keep their order; `stderr_path` and `handed_over_by` (a handed-over execute), `stop_requested_by` (a stop under way or done) and `leftovers` (`stopped` or `detached`: what the shell left holding the log, below) are left out until set. `bundles/slow-commands` reads these files on its own, so the shape is a contract.
|
|
32
|
+
- When a task is created in a git worktree, chi adds its `tmp/tasks/` path relative to the repository root to the
|
|
33
|
+
common git directory's `info/exclude`, once. An error is logged and does not prevent the task from starting.
|
|
32
34
|
- 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).
|
|
33
35
|
- 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.
|
|
34
36
|
- Task listing is workspace-scoped (current project only).
|
|
@@ -25,8 +25,8 @@ model. The TUI is untouched: it shows a fence as source.
|
|
|
25
25
|
the first that `claims` the block's language draws it, and a language none claims is left alone. The contract
|
|
26
26
|
(`claims`, `needsDraw`, `draw`, its `reconsider`, `sessionChanged`) is in the module's header. The shared DOM
|
|
27
27
|
helpers live there too: `failBlock` and its `.block-note` (a click copies it), `holdingView`, `rejoin`, the
|
|
28
|
-
toggle's listener; frames, the cache, hang marks, size checks, the
|
|
29
|
-
`block_host.js`. One `MutationObserver` per turn root,
|
|
28
|
+
toggle's listener; frames, the cache, hang marks, size checks, the click that opens the picture viewer and the theme
|
|
29
|
+
redraw stay in `block_host.js`. One `MutationObserver` per turn root,
|
|
30
30
|
filtered to `TEXTS` (`text_roots.js`), so cards, a lead-in bubble, question replies and delegate reports never draw, and
|
|
31
31
|
every path that adds a block to a root is seen the same way. One `IntersectionObserver` per scroller, with an explicit `root`
|
|
32
32
|
(with `root: null`, `rootMargin` doesn't pass an `overflow: auto` in between). Closed `<details>` fire on open. **A
|
|
@@ -42,9 +42,12 @@ model. The TUI is untouched: it shows a fence as source.
|
|
|
42
42
|
shows, never markup, and not in the bubble's `textContent`, which the page's dedupe and an annotation read (`copy.js`'s rule). CSS content can't be selected, so a click on the line copies its words.
|
|
43
43
|
The toggle has an icon and an `aria-label`, no text (`copy.js`'s rule). A jump into the source shows it (`revealInHistory`).
|
|
44
44
|
For a screen reader: the hidden `<pre>` isn't read, so the `<img>`'s alt names the toggle that shows it ("mermaid
|
|
45
|
-
diagram, its source under the Show the source button").
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
diagram, its source under the Show the source button"). In the answer the picture is always fitted to the column. A
|
|
46
|
+
click on it opens the page's picture viewer (`createBlockHost`'s `openPicture`, app.js's `picture_viewer.js`;
|
|
47
|
+
[web-frontend.md](web-frontend.md#picture-viewer)) with its `data:` URL and its size from the viewBox, zoomable and
|
|
48
|
+
movable there; without `openPicture` (an older app.js) a click does nothing. The same is a `.block-zoom` button
|
|
49
|
+
("Open in the viewer": icon, `aria-label`) for the keyboard: before the toggle, shown on keyboard focus only, and
|
|
50
|
+
taking no pointer while hidden; Esc in the viewer gives it the focus back.
|
|
48
51
|
6. Cache: a `Map` on `lang + theme + source`, about 200 entries, holding the `data:` URL; a later `bubble.innerHTML` wipes the
|
|
49
52
|
figure and the observer redraws in the same pass. No `crypto.subtle`: it's undefined on a plain-http LAN address. A system
|
|
50
53
|
theme change redraws through the figure (a hidden `<pre>` never intersects).
|
|
@@ -57,7 +60,7 @@ model. The TUI is untouched: it shows a fence as source.
|
|
|
57
60
|
from `DOMParser`, never a regex over model-influenced XML (exponents, a comment holding `<svg`, a `>` in an attribute, entities and
|
|
58
61
|
prefixes all fooled one), and a vast one isn't decoded. Then the decoded size is checked: over the maximum, or a width or
|
|
59
62
|
height of 0 (WebKit's 0 x 150 for a viewBox it can't hold), the block stays source with its line. `.block-img`'s CSS
|
|
60
|
-
`max-height`
|
|
63
|
+
`max-height` says the same number, a backstop whatever the parsing gets wrong. The decode is bounded too
|
|
61
64
|
(15 s, the mark on until it ends). A very wide picture stays at least 120 px tall and scrolls sideways instead of a sliver.
|
|
62
65
|
|
|
63
66
|
## Security model
|
|
@@ -171,8 +171,10 @@ any call. An add's text can't split on ` | `. The body names the line, for a ter
|
|
|
171
171
|
`Objectives.view` (`List#to_view`) is what the page draws: the items, each with its last move, and `pending`, whether
|
|
172
172
|
the newest list is a file still waiting. The session read (`objectives`, no key with no list) and the live
|
|
173
173
|
`:objectives_updated` carry it. `Engine#announce_objectives` (under the event lock, `TurnStages::Objectives#announce` giving the event) emits when the view differs from the last: after an edit,
|
|
174
|
-
once a list note is in (`add_context_note`), at a turn's end (its moves) and after a rollback between turns. A
|
|
175
|
-
|
|
174
|
+
once a list note is in (`add_context_note`), at a turn's end (its moves) and after a rollback between turns. A list
|
|
175
|
+
that goes away (a rollback, or a canceled or failed turn's kept messages, past the note that set it) emits one event
|
|
176
|
+
with `items: nil`, and the strip's `take` clears (an N-1 page's too); a session with no list before and after emits
|
|
177
|
+
nothing. Between two tabs that is all it takes. A participant gets neither: the event is in
|
|
176
178
|
`ParticipantView::DROPPED`.
|
|
177
179
|
|
|
178
180
|
Idle, an edit lands at once: the worker's anytime path wakes the loop (`@waker.wake`, one extra pass for any anytime
|
|
@@ -185,7 +187,10 @@ command), which absorbs the file. It no longer waits for the fallback tick.
|
|
|
185
187
|
by `forgetSession`. Its edit list is a `chip_popover.js` shell, so a phone gets the bottom sheet and the focus rules.
|
|
186
188
|
Every edit is a line on the command route with `card: true`: no echo, and `commandView` hides a good `/objectives`
|
|
187
189
|
answer that came with that mark, so a tap leaves no bubble, a refusal does. The strip redraws from the event, never
|
|
188
|
-
optimistically.
|
|
190
|
+
optimistically. A list with only dropped objectives draws no strip, as no list (`stripItems` is empty), and
|
|
191
|
+
`hasList()` is false, so the history's /short button hides too. The last one dropped from inside the open edit list
|
|
192
|
+
keeps the list and its strip until the list closes (its Undo stays under the finger); the close redraws the strip
|
|
193
|
+
away. `/objectives undo <id>` brings one back meanwhile.
|
|
189
194
|
- **The entry** (`objectives_entry.js`, from `turn_html.js noteBubbleTemplate`): `Objectives.entry` puts the note's items
|
|
190
195
|
and, against the list before it, `changes` (`Objectives.changes`, display only) on the history item and on
|
|
191
196
|
`context_added`. A first list is pills; a later one a line, `You marked O1 done`. The raw text stays the tooltip.
|
|
@@ -237,7 +242,7 @@ command), which absorbs the file. It no longer waits for the fallback tick.
|
|
|
237
242
|
- **Continue**: `Objectives.carry`, in `SessionContinue`'s `before_spawn`, writes a second note file in the new link,
|
|
238
243
|
after the carry note and any moved context's note, so the list reads as the latest word. It is not in
|
|
239
244
|
`SessionChain.note_text` (capped; the last answer gets what the recap leaves). It reads the previous link fresh,
|
|
240
|
-
with its unabsorbed newest file. A failure is only logged (`continue_objectives_failed`), because it runs inside the
|
|
245
|
+
with its unabsorbed newest file; a list with nothing active or done isn't carried (`List#meant?`). A failure is only logged (`continue_objectives_failed`), because it runs inside the
|
|
241
246
|
continue's rollback. The previous link's other waiting notes move after it (`NoteMove.move`, the step after: moved first, the
|
|
242
247
|
carry would miss a pending edit, and the stale list would be the batch's newest); its objectives notes never move,
|
|
243
248
|
and the new link's worker never adopts one from it (`NoteMove.adoption`), so a list from the archived link can't
|
|
@@ -14,8 +14,8 @@ by `npm run e2e` (`spec/e2e/`). `app.js` has no unit spec of its own; `viewer_bo
|
|
|
14
14
|
**Every module has a size cap, `app.js` its own**: `npm run lint` fails past `max-lines` in `eslint.config.js`
|
|
15
15
|
(counted as `wc -l` counts, comments and blank lines too). Every `public/*.js` module: 1200 (`samagotchi/module-size`,
|
|
16
16
|
about 10% over the largest, `turn_block.js`), so a module near it splits rather than becoming the next `app.js`.
|
|
17
|
-
`app.js` (`samagotchi/app-size`):
|
|
18
|
-
`session_view.js
|
|
17
|
+
`app.js` (`samagotchi/app-size`): 1638, its size once the lightbox went into `picture_viewer.js`; down from 1649, its
|
|
18
|
+
size plus 50 once the session-open flow went into `session_sync.js` and `session_view.js`, itself ratcheted down from 2000, itself down from 2250 when the versions, the owner's claim links and
|
|
19
19
|
Verify, the composer's mode and the strip's hide went into modules of their own. A new feature goes into a module of
|
|
20
20
|
its own, wired from `app.js` in a few lines; a refactor that shrinks `app.js` ratchets its cap down with it. Never
|
|
21
21
|
raise either: extract instead. Ruby's twin is `Samagotchi/FileSize` (docs/testing.md, File size).
|
|
@@ -31,7 +31,7 @@ page. A factory dep a new version stops passing is the same hazard the other way
|
|
|
31
31
|
out of `send_turn.js`, `session_actions.js` and `lists_view.js`); a page loaded before keeps all its old modules
|
|
32
32
|
until a reload, so the risk is a mixed cache, not an open tab. `answer_fold.js`, `details_motion.js`,
|
|
33
33
|
`turn_range.js`, `history_reveal.js`, `latest.js`, `session_payload.js`, `method_api.js`, `session_store.js`,
|
|
34
|
-
`session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (Deleting a chained session, below), `running_tasks.js` (a delete's or archive's 409 `tasks_running`: the tasks' line, the second confirm, the toast's suffix; DOM-free, so `stop_sheet.js` and `delete_sheet.js` share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
|
|
34
|
+
`session_fields.js`, `feature_gates.js`, `revise_stack.js`, `revise_switch.js`, `shell_command.js`, `stale_params.js`, `popover_modal.js`, `more_sheet.js`, `delete_sheet.js` (Deleting a chained session, below), `running_tasks.js` (a delete's or archive's 409 `tasks_running`: the tasks' line, the second confirm, the toast's suffix; DOM-free, so `stop_sheet.js` and `delete_sheet.js` share its cut), `hash_intent.js` (what the hash asks for: session, all, start or keep), `worker_features.js`, `version_notices.js`, `owner_claim.js`, `owner_verify.js`, `composer_mode.js`, `strip_hidden.js`, `block_open.js`, `text_roots.js`, `block_source.js`, `block_frame.js`, `block_host.js`, `block_watch.js`, `card_stamps.js`, `recap_stamp.js` (a saved recap's place by its `opening_id` stamp, else its count), `inline_widgets.js`, `widget_walk.js`, `widget_picks.js`, `history_shape.js` (the history's shape, live against a reload: the e2e reload checks and the opt-in reload check share its normalizer and its `ACCEPTED` allowlist), `turn_pieces.js` (a finished turn's one order and its answer rule: the live hand-off's `handOffOrder` and `turnEnded`, and a reload's `turnHistoryNodes`), `reload_check.js` (the opt-in `web.reload_check`: after the stage's hand-off, the turn against a reload of it, the counts posted; the history without its cards and questions, and those as data: the page's `card_registry.js` against one seeded from the read, this turn's entries, a capped read's missing keys skipped), `turn_drawing.js` (a finished turn's drawing, `turn_drawings` in the show: its fold into steps and its end kind; `turn_block.js` draws it), `stage_stall.js` (the stage's quiet signal), `stage_quiet_clock.js`, `stage_dom.js`, `stage_answer.js`, `stage_pager.js`, `stage_cloud.js`, `stage_handoff.js`, `stage_place.js`, `stage_probe.js` (the stage's features: below, The stage's modules), `card_kinds.js` (what a card waits as, from its data: the kind, approval and folded-row text the stage's registry takes; the node's read is its cross-check), `card_registry.js` (the open session's cards as data, an observer of the stream's card events and a read's seed: Where state lives), `history_end.js` (the stage's one move of pieces to the history's end), `stage_opened.js` (a running turn opened in the history while a card waits: the lead-in bubble, the moves, the end fold), `stage_asking.js` (the stage's docked card and its fold: the docking and lead-in rules, the opening, a waiting card's own toggle, the folded row's text per kind, the fold's choice, reveal and the docked card's fold; `stage_view.js` wires it), `stage_waiting.js` (the stage's waiting cards as data, keyed by `data-qid` / `data-card-id`: kind, docked, approval, the stage's order, the shown card and its pager, the docked card's fold, kept for this tab in `chi_asking_fold:<session>`; `front`, `count`, `shown`, `blocking`), `stage_cards.js` (the cards that wait in the stage: `PENDING`, `ASKS`, `waitsInStage`, read by `stage_model.js placeKind`), `resync_reach.js` (a re-read that can't reach chi web keeps the drawn history; the status chip says retrying / offline, outside a turn), `session_sync.js` (the open session's sync: `select`, `resync` and its retries, the stream's life; the stream handle and the re-read bookkeeping are its own), `session_view.js` (the open session's view: `renderSessionView` draws a read, `forgetSession` resets the page for another session, `readTurnEnd`, `endTurnView`; app.js makes both right after the cards, each reaching the other and the later views through getters), `participant_main.js`, `participant_bar.js`, `viewer_self.js`, `participant_history.js` (a participant's ↑/↓ list), `stage_owner_wait.js`, `participant_revise.js` (a participant's page: The participant's page, below), `ws_timeline.js`, `ws_cards.js`, `ws_peek.js`, `ws_reader.js`, `ws_way_in.js`, `ws_item_sig.js`, `ws_markdown.js` (what chi has of a working-set item: below, The working set's reader), `session_prefs.js` (a session's own view settings, `<key>:<session>`: Storage keys, below), `ws_sections.js` (the working set's head view: its sections from the prompt's parts, [working-set.md](working-set.md), The head view), `ws_order.js` (the working-set list's order: last touched first, held while it is open, [working-set.md](working-set.md), The list's order), `ctx_tokens.js` (the context's token count beside its %: `ctxTokens`, below), `stage_view_memory.js` (what was opened of a running turn, per session, in memory: Where state lives), `peer_data.js`, `peer_exchange.js`, `peer_note.js`, `peer_links.js` (a peer's send and answer in the conversation: The peer exchange, below), `peer_chip.js` (a paired peer's one chip in the session bar: The peer exchange), `picture_viewer.js` (the picture viewer, `#lightbox`: below, Picture viewer), `pan_zoom.js` (its maths, pure), `no_contact_fill.js` (a text field that isn't a contact form: autocomplete off and a name with no contact word, against iOS Safari's AutoFill Contact bar; a template's fields carry the same attributes, and its spec checks the page's markup for them) and the `objectives_*.js` modules are new modules for that reason. The last four `block_*` draw fenced blocks (`block_watch.js` finds and watches them, `block_host.js` is its frame drawer for a bundle's renderers): [block-renderers.md](block-renderers.md). `inline_widgets.js` is its core drawer for `chi-ui` blocks, drawing `widget_walk.js`'s and `widget_picks.js`'s widgets in a shadow root styled by `widgets.css`: [inline-widgets.md](inline-widgets.md).
|
|
35
35
|
|
|
36
36
|
## One page, every viewer
|
|
37
37
|
|
|
@@ -412,12 +412,57 @@ wider; its bottom is 16px less than `--safe-b`, since the session's card floats
|
|
|
412
412
|
session panel has no bottom padding and runs to the screen's bottom, its card at `--dock-bottom`, 16px or the
|
|
413
413
|
indicator's line), a bottom sheet's offset (`chip_popover.js place`: 8px above the indicator, or a keyboard's offset
|
|
414
414
|
alone), the update sheet, the toast's fallback place (in a session `--toast-bottom` already sits it above the card), the
|
|
415
|
-
|
|
415
|
+
picture viewer's padding (its fit's insets) and its ✕'s and bar's offsets, and the signed-out banner (`auth_lost.js`, `env()` itself).
|
|
416
416
|
On phones, the standalone app also has a 12px body inset, keeping its content below iOS 26's blurred band under the
|
|
417
417
|
clock. A new fixed or bottom-anchored piece reads `--safe-*`, never `env()`: the e2e set the names by hand (`web.spec.js`, a portrait phone and a landscape one),
|
|
418
418
|
as Chromium has no insets. The theme-color metas are tokens.css's `--bg-top` per theme up to 600px wide (a phone's page starts from that colour at its top edge, so the status bar meets the top bar with no seam), else its `--bg` (`theme.test.js` pins them). An iOS 26 Home Screen app ignores them for the status bar strip: it paints the strip in the body's `background-color`, so a phone's body gradient keeps a `--bg-top` colour layer under it (black strip without one).
|
|
419
419
|
In a session, the dock (composer card) shares the history's centered column, at most 960px wide; its right edge follows a classic scrollbar (`--history-sb`, 0 with overlay scrollbars; index.html and `dock_reserve.js`).
|
|
420
420
|
|
|
421
|
+
## Picture viewer
|
|
422
|
+
|
|
423
|
+
`picture_viewer.js` (`createPictureViewer`, made once by app.js as `pictures`; `viewer` there is the capabilities
|
|
424
|
+
object) shows a picture over the whole page in `#lightbox`, an opaque surface in `--bg` (a diagram's ink is the
|
|
425
|
+
theme's text colour, which a dark backdrop would hide on the light theme). A click on an attached image's thumbnail
|
|
426
|
+
opens it (its natural size from the loaded thumbnail, else after a `decode()`, showing nothing till then), and so
|
|
427
|
+
does a click on a drawn diagram or its keyboard button (`block_host.js`'s `openPicture`: its `data:` URL and its size
|
|
428
|
+
from the viewBox; [block-renderers.md](block-renderers.md)). It opens
|
|
429
|
+
fitted (`pan_zoom.js fitScale`: inside 24px of padding, the safe areas and the bar, never above 3 ×) and nothing is
|
|
430
|
+
kept: every open starts fitted.
|
|
431
|
+
|
|
432
|
+
- **Zoom is the layout size**: the picture's box (`.pv-pic`, the `<img>` in it at 100%) gets its width and height in
|
|
433
|
+
px, and a 2D `translate` places it. An SVG `<img>` is drawn again at its layout size; a scaled one can be a blurred
|
|
434
|
+
bitmap. No `will-change`, no 3D transform, no animation: a composited layer at the largest size is hundreds of MB.
|
|
435
|
+
The closest is 8 × natural, less when a side would pass 16,000 px or the area 4096² px (`MAX_SHOWN_PIXELS`, iOS
|
|
436
|
+
Safari's canvas cap, as the iPhone's budget); the farthest half of min(fit, 1). A picture smaller than the screen
|
|
437
|
+
on an axis is centred on it, a larger one keeps 60 px of itself on screen.
|
|
438
|
+
- **Gestures**, on the surface (`touch-action: none`, so the page under it never scrolls or zooms): one pointer
|
|
439
|
+
drags, two pinch (pointer capture; a cancel is an up); a pointerdown on ✕ or the bar starts nothing. Plain wheel
|
|
440
|
+
moves, Ctrl/Cmd + wheel zooms at the cursor (a Chromium trackpad pinch is a ctrl + wheel), by `exp(-deltaY ×
|
|
441
|
+
0.01)`, not fixed steps. Safari's `gesturestart`/`change`/`end` are always prevented (they would zoom the page) and
|
|
442
|
+
applied only while no touch pointer is down: that is a Mac trackpad; iOS fires them beside the pointers for a
|
|
443
|
+
finger pinch, and applying both would double it. A double tap or click (two ups without a move within 300 ms)
|
|
444
|
+
goes to max(2.5 × fit, natural) at that point, or back to fit when closer than fit. The `<img>` is never
|
|
445
|
+
dragged natively (`draggable=false`, `dragstart` prevented, `-webkit-user-drag:none`, `pointer-events:none`) and
|
|
446
|
+
has no iOS long-press sheet (`-webkit-touch-callout:none`).
|
|
447
|
+
- **Keys** are on the viewer's element, not the document, and stop there: `+`/`=` and `-` zoom, `0` fits (not with
|
|
448
|
+
Ctrl/Cmd held: the browser's own zoom), arrows move, Esc closes. The page's document listeners (the all-sessions
|
|
449
|
+
Esc, a popover's Esc, the reader's arrows, type-anywhere) never see them. It is a modal dialog ("Picture viewer",
|
|
450
|
+
`popover_modal.js modalDialog`); the surface takes the focus on open.
|
|
451
|
+
- **Closing** is ✕ and Esc only (a tap on the surface starts a drag). The focus goes back to the opener (a
|
|
452
|
+
diagram's button) without scrolling (`focusBack(…, {preventScroll})`, before hiding); a thumbnail takes no focus,
|
|
453
|
+
so after one it is the page's. A window `resize` (an orientation change) refits a fitted view, else re-clamps; it
|
|
454
|
+
is listened to only while open.
|
|
455
|
+
- **It closes by itself**, whatever it shows, on a system theme change (the diagram behind is redrawn; the viewer
|
|
456
|
+
holds the old picture; app.js), on a switch to another session or the start page (`session_view.js
|
|
457
|
+
forgetSession`, given `pictures`; the same session again keeps it) and when the all-sessions view opens (it hides
|
|
458
|
+
`#center`, the viewer's parent; app.js `applyView`). A bubble rewritten or cloned while it is open leaves it as it
|
|
459
|
+
is: it holds its own copy of the URL. The toast may show over it (both z-index 50, the toast later); it is modal by
|
|
460
|
+
`aria-modal`, `#center`'s other children aren't made `inert`.
|
|
461
|
+
- index.html keeps `<div id="lightbox" hidden><img alt=""></div>`: an older cached app.js reads that `<img>`. The
|
|
462
|
+
viewer adopts it (or adds one) and draws ✕ and the bar with lit at the first open. ✕ and the bar are glass cards
|
|
463
|
+
(solid `--bg-panel` under `body.no-glass` and reduced transparency), by `--safe-*`, and the standalone phone
|
|
464
|
+
app's ✕ is 12px lower, below iOS 26's band under the clock.
|
|
465
|
+
|
|
421
466
|
## The stage's modules
|
|
422
467
|
|
|
423
468
|
`stage_view.js` wires the stage: its `refresh`, the lifecycle (`turnStarted` … the hand-off) and the event API app.js
|
|
@@ -675,6 +720,21 @@ forgetSession` (a switch, the start page, + New, a deleted or archived session)
|
|
|
675
720
|
`#center` is never left inert, whatever the next session's GET does; close gives focus back to where it was at the
|
|
676
721
|
open (not after a jump or a reset). Styles: `ws_preview.css`.
|
|
677
722
|
|
|
723
|
+
Markdown in both (`ws_markdown.js`): a memory's text (a read, a write, its overlay, the greyed "what it was") and a
|
|
724
|
+
whole read of an `.md`/`.markdown` file (a slice from line 1 with a `lines.whole` read; in the peek, a whole read
|
|
725
|
+
that isn't a preview) render; a slice stays numbered source (it can start inside a fence, and its line numbers are
|
|
726
|
+
the strip's jumps), an edit or a write its diff, a fetch its text. A leading front matter is taken off and shown as
|
|
727
|
+
source above the HTML (a read of several memories is one text, so only the first body's is). The HTML is
|
|
728
|
+
`markdown_place.js renderMarkdown`'s (app.js passes it to `createWorkingSetPreview`), put in with lit's
|
|
729
|
+
`unsafeHTML` (sanitised on the server); the reader makes the one cache (`createRenderCache`: about 50 texts, HTML
|
|
730
|
+
only, a null not kept so the next draw asks again, one request per text at a time, a text whose JSON body is over
|
|
731
|
+
the route's 64 KiB answered null without a request) and hands it to the peek (`createPeek`'s `md`). HTML that comes
|
|
732
|
+
redraws the reader while an item is open and the peek while one is (`peekChanged`). Until it comes, and without it,
|
|
733
|
+
a card draws its source and has no switch. The reader's cards carry a `rendered | source` switch (`data-wsr="view"`,
|
|
734
|
+
one choice per open item in the reader's closure, back to rendered when another item opens, not stored); the peek
|
|
735
|
+
has none. A slice card carries its first line (`data-first`), which the strip's band jump falls back to on a
|
|
736
|
+
rendered slice (no `.read-line` in it).
|
|
737
|
+
|
|
678
738
|
## The peer exchange
|
|
679
739
|
|
|
680
740
|
A send to a paired peer (claude-peer's `claude_send`, codex-peer's) and the peer's answer, linked in the owner's
|
|
@@ -688,7 +748,7 @@ send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `labe
|
|
|
688
748
|
- `peer_data.js` (state): `listPeers` (an older chi web's 404 is an empty list) and `createPeers`, the page's one model
|
|
689
749
|
of the open session's peers (app.js `peers`, made only with the `context` capability, so a participant's page has
|
|
690
750
|
none): its own closure holds the last read for the open session (`createLatest`: an older read, or one for a
|
|
691
|
-
session left, is dropped); `exchange(id)` (
|
|
751
|
+
session left, is dropped); `exchange(id)` (the newest of an id: each send has its own, but an older chi's resend shared one), `answer(name, serial, re)`. It reads only when the
|
|
692
752
|
session has a peer (a context row with `peer`, a drawn send or answer), so a session without one makes no request.
|
|
693
753
|
Read again on: the session drawn (`session_view.js renderSessionView`, through `peerLinks.drawn()`), a
|
|
694
754
|
`context_added` with `peer`, a `tool_call_completed` with a peer ref, `command_ran` (a `/claude validate`), window
|
|
@@ -708,7 +768,7 @@ send's id as its `peer` ref, a peer's answer note its `peer` hash (`peer`, `labe
|
|
|
708
768
|
slot's title), an answer's ↑ (`.peer-up-slot`) and "Read the full answer" (`.peer-full-slot`), each marked
|
|
709
769
|
`data-peer-slot`, which `history_shape.js` leaves out (an offscreen reload has no model). `peer_links.js` is the
|
|
710
770
|
controller: on the model's `onChange` and after each session draw it renders, with lit, the pill into every slot in
|
|
711
|
-
the history and the stage (two rows of one id show the same newest exchange; an id the read doesn't have reads "not
|
|
771
|
+
the history and the stage (two rows of one id, an older chi's resend, show the same newest exchange; an id the read doesn't have reads "not
|
|
712
772
|
sent" when its row failed, or once its turn has ended when its peer's list is under the server's cap of 20
|
|
713
773
|
(`EXCHANGES_CAP`) or holds a send drawn before it; else it is unknown and gets no pill, as are the sends of a peer
|
|
714
774
|
the read doesn't name), the ↑ into each answer (none for an answer no send claims) and "Read the full
|
|
@@ -790,7 +850,7 @@ reach another device or the server.
|
|
|
790
850
|
| `chi_strip_hidden` (`chi_zen`: the old name, read once) | `strip_hidden.js` | the session strip hidden |
|
|
791
851
|
| `chi_stage_collapsed:<session>` | `stage_asking.js` (through `session_prefs.js`) | the session's stage collapsed or opened by hand (not written from the asking form, whose fold is that question's only); none: the page's default, `<body data-stage-collapsed="1">` (`web.stage_collapsed`), else open |
|
|
792
852
|
| `chi_working_set_collapsed:<session>` | `working_set_rail.js` (through `session_prefs.js`) | the session's working set rail collapsed |
|
|
793
|
-
| `chi_ws_sections_folded:<session>` | `working_set_view.js` (through `session_prefs.js`; the key is `ws_sections.js WS_SECTION_FOLD`) | the working-set list's sections folded by hand, a JSON list of keys (`start`, `read`, `talk`); none: all open |
|
|
853
|
+
| `chi_ws_sections_folded:<session>` | `working_set_view.js` (through `session_prefs.js`; the key is `ws_sections.js WS_SECTION_FOLD`) | the working-set list's sections folded by hand, a JSON list of keys (`start`, `read`, `talk`); none stored: `start` folded (a stored `[]` is all open) |
|
|
794
854
|
| `chi_markdown_tip_dismissed` | `markdown_tip.js` | the markdown tip dismissed |
|
|
795
855
|
| `chi_update_available_shown` | `version_notices.js` | update notices already shown |
|
|
796
856
|
| `chi_notify`, `chi_push_device` | `notifications.js` (an injected storage) | the bell's state, this device's push id |
|
|
@@ -317,7 +317,8 @@ preview for a long one). 400 without a known `kind` and a `key`.
|
|
|
317
317
|
|
|
318
318
|
## The page's overlay
|
|
319
319
|
|
|
320
|
-
The page keeps its row-derived items and their `at`
|
|
320
|
+
The page keeps its row-derived items and their `at` (first entry) and `last` (newest touch) ordinals (the step
|
|
321
|
+
tags' jump path; `itemsOfTurn` moves `last` at every touch, `sessionItems` keeps the latest turn's), and overlays the server's
|
|
321
322
|
`state` and `tokens` by key (`working_set.js overlay`):
|
|
322
323
|
- files by absolute path (the row's `ref.path`; a title fallback won't match, so it stays live);
|
|
323
324
|
- memories by name;
|
|
@@ -356,16 +357,30 @@ passes `working_set_updated` to it, and does nothing when the flag is off. A new
|
|
|
356
357
|
session lens; a footprint (`footClick`) and the rail (`openTurn`) open the lens on their turn. In a turn lens
|
|
357
358
|
(`working_set.js turnLens`, `lensItem`) the rows the turn touched are `lit` and the rest `dim` (`opacity:
|
|
358
359
|
var(--ws-lens-dim)`, a `:root` token in both palettes). A lit row is the session item's state, tokens and actions with
|
|
359
|
-
the turn item's `at`, ops and count (its step tag is the turn's, `s3`; a dimmed row keeps the session's,
|
|
360
|
+
the turn item's `at`, ops and count (its step tag is the turn's, `s3`; a dimmed row keeps the session's, its last
|
|
361
|
+
touch, `t1·s3`; `rowTemplate` picks by the lens class, since a lit row carries the session's `last` too): the
|
|
360
362
|
turn item is passed through, the session item is never overwritten. The header's `session | ‹ turn N ›` steps over the
|
|
361
363
|
finished turns and the running one (`lastTurn()`), `‹` and `›` disabled at the ends; the line under it reads "turn N
|
|
362
364
|
touched A · B new" (new: the session set's first `at` is this turn's, a prompt memory never). A folded inner group
|
|
363
365
|
(`labelsTemplate`) shows its lit members while folded. A new seed that leaves the lens past the last turn, or a reset
|
|
364
366
|
that drops the running turn, puts it back to the session.
|
|
365
367
|
|
|
368
|
+
**The list's order** (`ws_order.js`). The popover's list only: the rail, the footprints and the reader's side list
|
|
369
|
+
(`items()`) keep the set's entry order. `recencyOrder` sorts the items newest `last` (else `at`: an older page's item)
|
|
370
|
+
first, by turn, step, row, stable on ties; an item with neither (a preloaded memory never read, a used memory no row
|
|
371
|
+
explains) goes after the rest in its order, so without parts too those memories end the memories. The order is
|
|
372
|
+
taken when the list opens (`show` with `opening`: the item keys, `openKeys`) and held while it is open
|
|
373
|
+
(`heldOrder`): an item not among them comes in on top, newest first, the others stay where they were drawn, one that
|
|
374
|
+
left the set is gone. The lens buttons, a refresh, a seed's redraw keep it; a footprint or the rail clicked while it
|
|
375
|
+
is open opens it again (`popover.open`), which takes it again; a close drops it. `bodySections` filters by kind and
|
|
376
|
+
`fold` puts a group at its first member's place, so a folded directory group stands at its newest member's place,
|
|
377
|
+
and a new file in a folder already grouped brings the group to the top (accepted: the group moves as one). A turn lens keeps
|
|
378
|
+
the order (lit rows light where they stand). The session lens's step tag (and a dimmed row's) is the last touch:
|
|
379
|
+
its text, its jump and its title ("last touched at turn N (prompt), step S"); a lit row's is the turn's entry.
|
|
380
|
+
|
|
366
381
|
**The head view: sections** (`ws_sections.js headSections`, drawn by `working_set_view.js headTemplate`). With the
|
|
367
382
|
session's `prompt_parts` (the worker's sizes of its system prompt; `promptParts` on the page) the list is what is in
|
|
368
|
-
chi's head, in three sections:
|
|
383
|
+
chi's head, in three sections, drawn as Read, Conversation, From the start (every reader finds a section by its key):
|
|
369
384
|
- **From the start** (`start`): every part in prompt order, the tools part first. A memory part (identity, a model
|
|
370
385
|
note, a preload) IS a memory row: merged with the session set's rows of the same memory, else a row of its own
|
|
371
386
|
(identity: the set never lists it). **The match is scope + name** (`same`): the names match (`memoryName`, which
|
|
@@ -390,7 +405,9 @@ chi's head, in three sections:
|
|
|
390
405
|
the tool schemas out, so without server usage the rest can go negative and the row hides); the "~" says so.
|
|
391
406
|
|
|
392
407
|
**Held twice.** A start memory row whose ops include `read` is held twice: in the prompt and in a read's output. The
|
|
393
|
-
session lens tags it `held twice` (warn tokens)
|
|
408
|
+
session lens tags it `held twice` (warn tokens), and the start header counts them, folded or open (`· N held
|
|
409
|
+
twice`, the section's `twice`, in `--warn-text`: a span of its own after the meta, so on a phone the meta's ellipsis
|
|
410
|
+
cuts the meta first); a turn lens whose items read it lights it amber with a note under it:
|
|
394
411
|
"read again in this turn: already in the prompt, held twice (+X)". A lens lights a merged row by any of its merged
|
|
395
412
|
keys (`lensTouched`), and a part-only start row (no merged item, e.g. `x@system`) by its bare name too: a turn's rows
|
|
396
413
|
come from tool titles, which carry no scope, so in a turn lens a project `x` read lights a system `x`'s own row (lit,
|
|
@@ -401,7 +418,9 @@ drop strikes the row where it stands (today's state words); the server knows an
|
|
|
401
418
|
changed it, so a turn lens has no forget count.
|
|
402
419
|
|
|
403
420
|
**Section folds.** Each section header folds (`data-ws="section"`), per session (`chi_ws_sections_folded:<session>`,
|
|
404
|
-
`session_prefs.js`); none stored:
|
|
421
|
+
`session_prefs.js`); none stored: From the start folded, the rest open (`foldedSections(null)`; the view reads the pref
|
|
422
|
+
with no fallback, so nothing stored is told from a stored `[]`, which is all open). A stored list is used as it is, so
|
|
423
|
+
a session folded or opened by hand keeps that. Conversation has no header to fold: a stored `talk` (an older page's) is
|
|
405
424
|
ignored (`foldedSections`) and the next toggle writes the list without it. Folded, a section shows only the rows the lens lights (the read section's
|
|
406
425
|
lit members flat, without their inner groups). The header carries no size (the name, the lens, the ring
|
|
407
426
|
and ×: one line on a phone at 390 px); the line under it does. The session lens's: "in chi's head now · ~X of Y"
|
data/docs/memory.md
CHANGED
|
@@ -662,6 +662,9 @@ profiles, meta bundles that install a set of them:
|
|
|
662
662
|
|
|
663
663
|
`chi bootstrap` installs `core` and, on a terminal, offers `dev`. An existing
|
|
664
664
|
install gets neither by itself: `chi bundle install core` (or `dev`).
|
|
665
|
+
When no core member has an install record, chi prints a one-line reminder to
|
|
666
|
+
stderr at a session or web launch, including a one-shot. It is shown only once
|
|
667
|
+
per state directory, even if core is later removed.
|
|
665
668
|
|
|
666
669
|
A profile's `manifest.yml` has `includes:` (bundle names) and nothing else to
|
|
667
670
|
install; its dir holds only that file. What installing it does follows one
|