@north-light/crouter 0.3.154 → 0.3.157

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.
Files changed (80) hide show
  1. package/README.md +2 -1
  2. package/dist/api/client.d.ts +1 -4
  3. package/dist/api/client.js +0 -5
  4. package/dist/api/dto/broker.d.ts +1 -1
  5. package/dist/api/dto/nodes.d.ts +0 -15
  6. package/dist/api/routes.d.ts +0 -1
  7. package/dist/api/routes.js +0 -1
  8. package/dist/builtin-views/chat/core.mjs +51 -6
  9. package/dist/builtin-views/chat/tui.mjs +14 -6
  10. package/dist/builtin-views/chat/web.jsx +7 -2
  11. package/dist/clients/attach/__tests__/oauth-dialog-lifecycle.test.js +1 -1
  12. package/dist/clients/attach/chrome/roster.d.ts +1 -1
  13. package/dist/clients/attach/chrome/roster.js +1 -9
  14. package/dist/clients/attach/command.js +5 -5
  15. package/dist/clients/attach/input/controller.d.ts +8 -23
  16. package/dist/clients/attach/input/controller.js +29 -59
  17. package/dist/clients/attach/overlays/dialogs.d.ts +2 -1
  18. package/dist/clients/attach/overlays/graph.d.ts +1 -4
  19. package/dist/clients/attach/overlays/graph.js +7 -25
  20. package/dist/clients/attach/session/context.d.ts +0 -7
  21. package/dist/clients/attach/session/frames.js +8 -1
  22. package/dist/clients/attach/session/input-wiring.d.ts +1 -1
  23. package/dist/clients/attach/session/input-wiring.js +11 -21
  24. package/dist/clients/attach/session/mode.d.ts +3 -4
  25. package/dist/clients/attach/session/mode.js +1 -6
  26. package/dist/clients/attach/session/reconnect.d.ts +3 -3
  27. package/dist/clients/attach/session/reconnect.js +7 -6
  28. package/dist/clients/attach/session/state-sync.d.ts +1 -1
  29. package/dist/clients/attach/session/state-sync.js +2 -2
  30. package/dist/clients/attach/slash/dispatch.d.ts +1 -13
  31. package/dist/clients/attach/slash/dispatch.js +17 -65
  32. package/dist/clients/attach/viewer.js +523 -523
  33. package/dist/clients/web/web-client/shared/protocol.d.ts +3 -5
  34. package/dist/core/__tests__/broker-sdk-wiring.test.js +18 -18
  35. package/dist/core/__tests__/chat-view-reconnect.test.js +23 -44
  36. package/dist/core/__tests__/full/broker-attach-limits.test.js +36 -60
  37. package/dist/core/__tests__/full/broker-attach-stream.test.js +4 -4
  38. package/dist/core/__tests__/full/broker-control-preempt.test.d.ts +1 -0
  39. package/dist/core/__tests__/full/broker-control-preempt.test.js +61 -0
  40. package/dist/core/__tests__/full/broker-dialogs.test.js +62 -121
  41. package/dist/core/__tests__/helpers/broker-clients.js +2 -2
  42. package/dist/core/__tests__/session-model.test.js +26 -15
  43. package/dist/core/keybindings/__tests__/resolve.test.js +1 -1
  44. package/dist/core/keybindings/catalog.d.ts +2 -2
  45. package/dist/core/keybindings/catalog.js +2 -0
  46. package/dist/core/runtime/auth-reload.d.ts +4 -4
  47. package/dist/core/runtime/auth-reload.js +13 -9
  48. package/dist/core/runtime/boot-root.d.ts +2 -2
  49. package/dist/core/runtime/boot-root.js +7 -7
  50. package/dist/core/runtime/broker-protocol.d.ts +27 -23
  51. package/dist/core/runtime/broker-protocol.js +1 -1
  52. package/dist/core/runtime/broker-request.js +11 -5
  53. package/dist/core/runtime/broker.d.ts +13 -21
  54. package/dist/core/runtime/broker.js +186 -151
  55. package/dist/core/runtime/interactive-deliver.js +5 -4
  56. package/dist/core/runtime/model-swap.d.ts +3 -2
  57. package/dist/core/runtime/model-swap.js +4 -3
  58. package/dist/core/runtime/node-read.d.ts +0 -20
  59. package/dist/core/runtime/node-read.js +1 -34
  60. package/dist/core/runtime/resume-root.d.ts +1 -1
  61. package/dist/core/runtime/resume-root.js +6 -6
  62. package/dist/core/runtime/spawn.js +3 -3
  63. package/dist/core/session-model/session-state.d.ts +6 -8
  64. package/dist/core/session-model/session-state.js +16 -6
  65. package/dist/daemon/api/handlers/nodes.js +1 -18
  66. package/dist/daemon/manage.js +2 -2
  67. package/dist/index.d.ts +1 -1
  68. package/dist/web-client/assets/index--SsQYcKu.js +79 -0
  69. package/dist/web-client/assets/{index-CpEl9LTS.css → index-DJhQZoAj.css} +1 -1
  70. package/dist/web-client/index.html +2 -2
  71. package/dist/web-client/sw.js +1 -1
  72. package/docs/compat/hearth-crtr-v1.md +1 -1
  73. package/docs/compat/hearth-crtr-v2.md +1 -1
  74. package/docs/compat/hearth-crtr-v3.md +1 -1
  75. package/docs/compat/hearth-crtr-v4.md +3 -1
  76. package/docs/public-api.md +2 -2
  77. package/package.json +4 -4
  78. package/runtime.lock.json +2 -2
  79. package/dist/web-client/assets/index-BpyZGBhI.js +0 -79
  80. package/docs/compat/hearth-crtr-v5.md +0 -175
@@ -1,175 +0,0 @@
1
- # Hearth ↔ crtr runtime compatibility — v5
2
-
3
- A versioned contract for any external product (originally: `@crouton-kit/hearth`) that runs alongside a crtr install as a separate process/repo and needs a stable surface to pin a crtr package version against. "v5" names the shape described here; a future breaking change to any part of this contract gets a new compatibility document rather than silently rewriting this one.
4
-
5
- ## Status and migration from v4
6
-
7
- v5 is a breaking hard cut of broker singleton control. A client's role is fixed by its `hello`: `observer` is read-only and `controller` is writable. Multiple controller-role clients are independently writable; no client owns a singleton controller slot, and opening, focusing, backgrounding, or disconnecting another client does not change an existing client's role. `request_control`, `release_control`, and `control_changed` do not exist in the current broker protocol.
8
-
9
- The observer `hello` remains valid for the `reload_auth` subset. Its `welcome` frame omits `controller_id`; `role` is the complete per-client authority statement. Sections 1–4 and 6 are unchanged from v4 and are reproduced below so this document remains a complete compatibility snapshot. Section 5 records the current broker handshake and `reload_auth` contract. The historical v4 document remains unchanged.
10
-
11
- ## 1. Import contract
12
-
13
- See `docs/public-api.md` for the full picture. The subset this note assumes:
14
- `general`, `nowIso`, and `BROKER_READ_CAPS`, all imported from the package
15
- root (`@north-light/crouter`). No subpath beyond `.`, `./cli`, `./web` exists
16
- or is supported.
17
-
18
- ## 2. `crtr --json sys version`
19
-
20
- Read-only. Returns an object with at minimum:
21
-
22
- ```json
23
- { "version": "0.3.40" }
24
- ```
25
-
26
- `version` is a required string, a semver matching `package.json#version` of
27
- the installed crtr. A consumer asserting a running crtr's version (e.g. after
28
- a guest image roll) should exec this command in-guest and compare the
29
- returned `version` against the expected target — do not parse `--help` output
30
- or read `package.json` directly, since the installed layout is not a public
31
- contract.
32
-
33
- ## 3. `crtr --json node message send` — immediate delivery
34
-
35
- This leaf delivers an inbox message immediately. Future delivery, deadline waits (`node wait deadline`), and fresh revivals (`node lifecycle revive` for the immediate case) all have separate command paths and are outside this compatibility contract; deferred future delivery and deferred revival are arranged through `crtr cron add` rather than a dedicated leaf (see "Status and migration from v3" above). Typed-output requests (`node message request`) are likewise outside this contract.
36
-
37
- **Invocation:**
38
-
39
- ```
40
- <body on stdin> | crtr --json node message send --to <node-id> [--tier critical|urgent|normal|deferred]
41
- ```
42
-
43
- - `body` — the message text, passed on stdin (or positional).
44
- - `--to <node-id>` — required target (a real node id; `--self` is not
45
- applicable to an external caller).
46
- - `--tier` — optional, one of `critical | urgent | normal | deferred`.
47
- Defaults to `normal` when omitted. Governs how the message is presented at
48
- the target's next turn, not delivery timing.
49
-
50
- **Output** (JSON object, `outputKind: object`):
51
-
52
- | field | type | when present |
53
- |---|---|---|
54
- | `target` | string | always — the target node id |
55
- | `delivered` | boolean | always — `true` once the inbox entry is appended |
56
- | `revived` | boolean | always — whether delivery revived a dormant target |
57
- | `guidance` | string | always — human/agent-readable confirmation text |
58
-
59
- **Delivery semantics — read carefully:** this appends an entry to the
60
- target's `inbox.jsonl` and, if the target is dormant, makes a **best-effort**
61
- attempt to revive it so the message is acted on. Revival is asynchronous —
62
- the command returning `delivered: true` means the inbox write succeeded, not
63
- that the target has processed the message or is now running. A caller must
64
- not block synchronously waiting for a revive to complete as part of this
65
- call; if a caller needs to know the target acted on the message, that is a
66
- separate, out-of-band observation (e.g. polling node status or waiting for
67
- the target to message back), not a guarantee `node message send` makes.
68
-
69
- ## 4. In-guest web port
70
-
71
- `crtr surface web serve --host 127.0.0.1 --port <PRIVATE>` starts crtr's
72
- unified web server (shell SPA, source/command bridge, SSE change lane, and
73
- the browser⇄broker relay) bound to loopback on a private port chosen by the
74
- guest. This is a **private, unauthenticated-by-default loopback surface** —
75
- binding a non-loopback host requires `--token`; a consumer that fronts this
76
- port (reverse-proxying non-model-auth or non-product traffic to it) is
77
- responsible for whatever auth gate sits in front of the public listener. crtr
78
- itself makes no claim about what proxies to this port or how; it only
79
- guarantees the port serves the crtr web UI when bound.
80
-
81
- ## 5. Broker `view.sock` — the `reload_auth` subset
82
-
83
- A minimal, dependency-free client can nudge a live broker to re-read credentials after an external auth flow completes (e.g. a login page that just wrote fresh OAuth tokens to disk) without importing crtr's `ViewSocketClient` or any frame type. This is a v5-stable subset of the full broker wire protocol (`src/core/runtime/broker-protocol.ts`).
84
-
85
- ### 5.1 Socket path resolution
86
-
87
- - Always `<CRTR_HOME>/nodes/<nodeId>/view.sock` (`CRTR_HOME` defaults to
88
- `~/.crouter/canvas`). `CRTR_SOCK_DIR` is not read.
89
-
90
- ### 5.2 Framing
91
-
92
- Newline-delimited JSON. Each frame is one JSON object serialized on a single
93
- line, terminated by `\n`. Write frames to the socket in this form; read
94
- replies the same way (buffer until a `\n`, then `JSON.parse` the line).
95
-
96
- ### 5.3 Handshake — `hello`
97
-
98
- On connect, send:
99
-
100
- ```json
101
- {"type":"hello","role":"observer","client_id":"<any string>"}
102
- ```
103
-
104
- `role: "observer"` remains sufficient for this subset — `reload_auth` is open to an observer because it is an idempotent local credential re-read that does not steer the conversation. The broker replies with a `welcome` frame:
105
-
106
- ```json
107
- {"type":"welcome","snapshot":{...},"role":"observer",...}
108
- ```
109
-
110
- The `welcome` frame omits `controller_id`. The role is fixed by the role sent in `hello`: an observer is read-only and a controller is writable. Multiple controller-role clients may write independently; there is no singleton controller owner or handoff.
111
-
112
- **The `welcome.snapshot` can carry the full message/session history and may
113
- be many megabytes** — the read side is capped generously (`CLIENT_READ_CAPS`:
114
- 256 MiB per frame and per total buffer), not tightly. A `reload_auth`-only
115
- client must tolerate this frame arriving and either parse-and-discard it or
116
- skip it structurally (it is still one JSON line — read and drop it) rather
117
- than assuming the first frame is small.
118
-
119
- ### 5.4 The nudge — `reload_auth`
120
-
121
- Send:
122
-
123
- ```json
124
- {"type":"reload_auth"}
125
- ```
126
-
127
- No other fields. The broker re-reads on-disk auth storage and refreshes its
128
- model registry in response.
129
-
130
- ### 5.5 The reply — `ack`
131
-
132
- ```json
133
- {"type":"ack","for":"reload_auth","ok":true}
134
- ```
135
-
136
- - `for` echoes the frame type that was acted on.
137
- - `ok: true` on success. On failure the broker may instead send an `error`
138
- frame (`{"type":"error","code":"...","message":"..."}`). A minimal client
139
- must read frames until it receives either `{"type":"ack","for":"reload_auth",...}` or `{"type":"error",...}` and IGNORE any non-terminal frames sent in between (notably: `model_changed` broadcasts after the ack). Only the explicit ack or error frame determines the result.
140
-
141
- ### 5.6 What this subset intentionally omits
142
-
143
- No other frame type in this protocol (prompt/steer, session control, model selection, read-op pickers, bash execution, etc.) is part of this v5 note. In particular, `request_control`, `release_control`, and `control_changed` do not exist. A consumer that needs more than the `reload_auth` nudge should import `ViewSocketClient` from the package root rather than hand-rolling a larger client against this doc.
144
-
145
- ## 6. `canvas.db` byte-shape — version 1
146
-
147
- **Read/compat constraint only — never a write contract.** crtr's CLI and
148
- runtime primitives (`spawnChild`, `reviveNode`, `node message send`, etc.) are the only
149
- sanctioned way to mutate canvas state. Documenting the byte-shape below is
150
- for a consumer that needs to *read* or *reason about* the database (e.g.
151
- recovering a home's identity after a guest recreate), not for direct SQL
152
- writes.
153
-
154
- - Opened with Node's built-in `node:sqlite` `DatabaseSync`.
155
- - WAL mode enabled by `openDb()`.
156
- - Forward-only migrations gated by `PRAGMA user_version`, currently through
157
- **v12**. A consumer pinning this contract should treat `user_version` as
158
- the schema version to check, not assume a fixed column set never changes
159
- going forward — this note describes the shape AS OF v12 and will need a later compatibility document if the schema changes in a way external readers depend on.
160
- - **`nodes` table** — identity columns (`id`, and the fields mirrored from
161
- each node's `meta.json`) are derived from `nodes/<id>/meta.json` on disk;
162
- runtime columns (status, lifecycle, etc.) are row-authoritative *while the
163
- local canvas.db exists*, but are **not recoverable from a wiped local DB**
164
- — a rebuild re-derives identity from meta.json but cannot resurrect
165
- transient runtime state that only ever lived in the row.
166
- - **`subscribes_to`** — DB-authoritative edge table (the push/subscription
167
- spine). Not derived from any on-disk file; a wiped DB loses these edges.
168
- - **`spawned_by`** — provenance/audit edges, **re-derived from each node's
169
- `meta.json` during a rebuild** (unlike `subscribes_to`, this one survives a
170
- DB wipe as long as the node directories/meta.json files survive).
171
- - **Auxiliary tables**: `focuses`, `crons`, `cron_runs`, `canvas_meta`.
172
-
173
- A consumer pinning this contract should re-verify §6 against a live crtr
174
- install (`PRAGMA user_version`, `.schema`) whenever bumping its pinned crtr
175
- version, rather than assuming this note tracks every schema change.