@crouton-kit/crouter 0.3.40 → 0.3.42
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.
- package/dist/build-root.js +1 -0
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/__tests__/provider-rotation.test.ts +472 -9
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +284 -76
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/strip-skills-docs.ts +31 -24
- package/dist/builtin-pi-packages/pi-crtr-extensions/lib/subscription-state.ts +52 -15
- package/dist/clients/attach/attach-cmd.js +720 -747
- package/dist/clients/attach/chat-view.js +11 -0
- package/dist/clients/attach/view-socket.d.ts +8 -1
- package/dist/clients/attach/view-socket.js +15 -1
- package/dist/clients/web/server.js +5 -28
- package/dist/clients/web/web-cmd.js +1 -1
- package/dist/commands/__tests__/revive-now-gate.test.js +60 -0
- package/dist/commands/canvas-rebuild-index.js +5 -5
- package/dist/commands/memory/shared.d.ts +7 -3
- package/dist/commands/memory/shared.js +35 -5
- package/dist/commands/memory/write.js +5 -3
- package/dist/commands/node-snapshot.js +9 -1
- package/dist/commands/node.js +37 -17
- package/dist/commands/push.js +8 -0
- package/dist/commands/revive.d.ts +10 -0
- package/dist/commands/revive.js +28 -10
- package/dist/commands/sys/__tests__/setup-core.test.js +19 -0
- package/dist/commands/sys/doctor.js +1 -1
- package/dist/commands/sys/setup-core.js +3 -2
- package/dist/commands/sys/setup.js +1 -1
- package/dist/commands/worktree.d.ts +2 -0
- package/dist/commands/worktree.js +94 -0
- package/dist/core/__tests__/boot.test.js +4 -4
- package/dist/core/__tests__/canvas.test.js +19 -7
- package/dist/core/__tests__/child-followup.test.js +15 -5
- package/dist/core/__tests__/daemon-boot.test.js +6 -1
- package/dist/core/__tests__/daemon-wedge.test.js +18 -1
- package/dist/core/__tests__/fault-classifier.test.js +30 -0
- package/dist/core/__tests__/fixtures/fake-engine.d.ts +13 -0
- package/dist/core/__tests__/fixtures/fake-engine.js +20 -0
- package/dist/core/__tests__/full/spike-harness.test.js +8 -5
- package/dist/core/__tests__/grace-clock.test.js +18 -2
- package/dist/core/__tests__/host-teardown-process-group.test.js +465 -0
- package/dist/core/__tests__/prune-to-limit.test.js +14 -0
- package/dist/core/__tests__/review-model-floor.test.js +32 -0
- package/dist/core/__tests__/revive.test.js +18 -4
- package/dist/core/__tests__/session-cycles.test.js +77 -0
- package/dist/core/__tests__/worktree.test.js +85 -0
- package/dist/core/canvas/boot.js +12 -7
- package/dist/core/canvas/canvas.d.ts +27 -8
- package/dist/core/canvas/canvas.js +54 -26
- package/dist/core/canvas/db.js +14 -0
- package/dist/core/canvas/history.js +1 -0
- package/dist/core/canvas/paths.d.ts +10 -9
- package/dist/core/canvas/paths.js +10 -9
- package/dist/core/canvas/pid.d.ts +155 -1
- package/dist/core/canvas/pid.js +306 -1
- package/dist/core/canvas/status-glyph.d.ts +7 -0
- package/dist/core/canvas/status-glyph.js +10 -1
- package/dist/core/canvas/types.d.ts +34 -0
- package/dist/core/fault-classifier.js +5 -1
- package/dist/core/profiles/select.d.ts +4 -2
- package/dist/core/profiles/select.js +30 -4
- package/dist/core/runtime/bearings.js +4 -0
- package/dist/core/runtime/branded-host.d.ts +7 -0
- package/dist/core/runtime/branded-host.js +44 -17
- package/dist/core/runtime/broker-sdk.js +28 -68
- package/dist/core/runtime/broker.js +35 -4
- package/dist/core/runtime/host.d.ts +3 -3
- package/dist/core/runtime/host.js +148 -33
- package/dist/core/runtime/launch.d.ts +15 -15
- package/dist/core/runtime/launch.js +58 -4
- package/dist/core/runtime/naming.js +3 -2
- package/dist/core/runtime/nodes.d.ts +3 -1
- package/dist/core/runtime/nodes.js +1 -0
- package/dist/core/runtime/pi-cli.d.ts +2 -0
- package/dist/core/runtime/pi-cli.js +51 -0
- package/dist/core/runtime/placement.d.ts +1 -1
- package/dist/core/runtime/placement.js +5 -2
- package/dist/core/runtime/recap.js +2 -1
- package/dist/core/runtime/revive.d.ts +21 -15
- package/dist/core/runtime/revive.js +87 -52
- package/dist/core/runtime/session-cycles.d.ts +30 -0
- package/dist/core/runtime/session-cycles.js +77 -0
- package/dist/core/runtime/spawn.d.ts +4 -0
- package/dist/core/runtime/spawn.js +152 -100
- package/dist/core/runtime/tmux.d.ts +7 -10
- package/dist/core/runtime/tmux.js +9 -11
- package/dist/core/worktree.d.ts +35 -0
- package/dist/core/worktree.js +158 -0
- package/dist/daemon/crtrd.d.ts +17 -8
- package/dist/daemon/crtrd.js +191 -40
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/pi-extensions/canvas-context-intro.d.ts +1 -0
- package/dist/pi-extensions/canvas-context-intro.js +34 -23
- package/dist/pi-extensions/canvas-stophook.js +11 -5
- package/dist/web-client/assets/{index-CbO8L0mN.js → index-B00YpRQ1.js} +20 -20
- package/dist/web-client/assets/index-DrkcvANq.css +2 -0
- package/dist/web-client/index.html +2 -2
- package/docs/compat/hearth-crtr-v1.md +191 -0
- package/docs/public-api.md +75 -0
- package/package.json +3 -4
- package/dist/core/__tests__/hearth-bootstrap.test.js +0 -136
- package/dist/core/hearth/__tests__/model-auth-guest.test.js +0 -151
- package/dist/core/hearth/config.d.ts +0 -3
- package/dist/core/hearth/config.js +0 -108
- package/dist/core/hearth/guest-env.d.ts +0 -9
- package/dist/core/hearth/guest-env.js +0 -27
- package/dist/core/hearth/index.d.ts +0 -4
- package/dist/core/hearth/index.js +0 -4
- package/dist/core/hearth/model-auth-guest.d.ts +0 -8
- package/dist/core/hearth/model-auth-guest.js +0 -430
- package/dist/core/hearth/provider.d.ts +0 -36
- package/dist/core/hearth/provider.js +0 -10
- package/dist/core/hearth/providers/__tests__/sweep-and-release.test.js +0 -362
- package/dist/core/hearth/providers/blaxel-bootstrap.d.ts +0 -12
- package/dist/core/hearth/providers/blaxel-bootstrap.js +0 -147
- package/dist/core/hearth/providers/blaxel-home.d.ts +0 -60
- package/dist/core/hearth/providers/blaxel-home.js +0 -405
- package/dist/core/hearth/providers/blaxel.d.ts +0 -36
- package/dist/core/hearth/providers/blaxel.js +0 -364
- package/dist/core/hearth/providers/types.d.ts +0 -93
- package/dist/core/hearth/types.d.ts +0 -155
- package/dist/hearth/control-plane/__tests__/error-serialization.test.js +0 -29
- package/dist/hearth/control-plane/__tests__/node-message.test.js +0 -60
- package/dist/hearth/control-plane/__tests__/oauth-serving-marker.test.d.ts +0 -1
- package/dist/hearth/control-plane/__tests__/oauth-serving-marker.test.js +0 -44
- package/dist/hearth/control-plane/__tests__/rate-limit-recurrence.test.d.ts +0 -1
- package/dist/hearth/control-plane/__tests__/rate-limit-recurrence.test.js +0 -49
- package/dist/hearth/control-plane/__tests__/relay-security.test.d.ts +0 -1
- package/dist/hearth/control-plane/__tests__/relay-security.test.js +0 -314
- package/dist/hearth/control-plane/__tests__/scheduler-scan-loop.test.d.ts +0 -1
- package/dist/hearth/control-plane/__tests__/scheduler-scan-loop.test.js +0 -133
- package/dist/hearth/control-plane/__tests__/trigger-delivery.test.d.ts +0 -1
- package/dist/hearth/control-plane/__tests__/trigger-delivery.test.js +0 -170
- package/dist/hearth/control-plane/__tests__/wake-roll.test.d.ts +0 -1
- package/dist/hearth/control-plane/__tests__/wake-roll.test.js +0 -230
- package/dist/hearth/control-plane/__tests__/webhook-ingress.test.d.ts +0 -1
- package/dist/hearth/control-plane/__tests__/webhook-ingress.test.js +0 -167
- package/dist/hearth/control-plane/config.d.ts +0 -21
- package/dist/hearth/control-plane/config.js +0 -77
- package/dist/hearth/control-plane/db.d.ts +0 -30
- package/dist/hearth/control-plane/db.js +0 -561
- package/dist/hearth/control-plane/hearth-target.d.ts +0 -23
- package/dist/hearth/control-plane/hearth-target.js +0 -68
- package/dist/hearth/control-plane/ingress/rate-limit.d.ts +0 -24
- package/dist/hearth/control-plane/ingress/rate-limit.js +0 -100
- package/dist/hearth/control-plane/ingress/route-store.d.ts +0 -31
- package/dist/hearth/control-plane/ingress/route-store.js +0 -61
- package/dist/hearth/control-plane/ingress/webhook-delivery-store.d.ts +0 -41
- package/dist/hearth/control-plane/ingress/webhook-delivery-store.js +0 -69
- package/dist/hearth/control-plane/ingress/webhook-route.d.ts +0 -55
- package/dist/hearth/control-plane/ingress/webhook-route.js +0 -285
- package/dist/hearth/control-plane/main.d.ts +0 -1
- package/dist/hearth/control-plane/main.js +0 -88
- package/dist/hearth/control-plane/node-message.d.ts +0 -31
- package/dist/hearth/control-plane/node-message.js +0 -98
- package/dist/hearth/control-plane/register.d.ts +0 -15
- package/dist/hearth/control-plane/register.js +0 -34
- package/dist/hearth/control-plane/registry.d.ts +0 -22
- package/dist/hearth/control-plane/registry.js +0 -168
- package/dist/hearth/control-plane/relay.d.ts +0 -44
- package/dist/hearth/control-plane/relay.js +0 -711
- package/dist/hearth/control-plane/scheduler/fire-store.d.ts +0 -36
- package/dist/hearth/control-plane/scheduler/fire-store.js +0 -73
- package/dist/hearth/control-plane/scheduler/recurrence.d.ts +0 -7
- package/dist/hearth/control-plane/scheduler/recurrence.js +0 -58
- package/dist/hearth/control-plane/scheduler/scan-loop.d.ts +0 -38
- package/dist/hearth/control-plane/scheduler/scan-loop.js +0 -138
- package/dist/hearth/control-plane/scheduler/schedule-store.d.ts +0 -32
- package/dist/hearth/control-plane/scheduler/schedule-store.js +0 -66
- package/dist/hearth/control-plane/secrets.d.ts +0 -31
- package/dist/hearth/control-plane/secrets.js +0 -134
- package/dist/hearth/control-plane/server.d.ts +0 -27
- package/dist/hearth/control-plane/server.js +0 -482
- package/dist/hearth/control-plane/serving.d.ts +0 -15
- package/dist/hearth/control-plane/serving.js +0 -106
- package/dist/hearth/control-plane/session.d.ts +0 -68
- package/dist/hearth/control-plane/session.js +0 -273
- package/dist/hearth/control-plane/triggers/acl.d.ts +0 -14
- package/dist/hearth/control-plane/triggers/acl.js +0 -52
- package/dist/hearth/control-plane/triggers/audit-store.d.ts +0 -38
- package/dist/hearth/control-plane/triggers/audit-store.js +0 -79
- package/dist/hearth/control-plane/triggers/deliver.d.ts +0 -43
- package/dist/hearth/control-plane/triggers/deliver.js +0 -76
- package/dist/hearth/control-plane/triggers/envelope.d.ts +0 -29
- package/dist/hearth/control-plane/triggers/envelope.js +0 -38
- package/dist/hearth/control-plane/types.d.ts +0 -86
- package/dist/hearth/control-plane/types.js +0 -1
- package/dist/hearth/control-plane/wake.d.ts +0 -86
- package/dist/hearth/control-plane/wake.js +0 -550
- package/dist/web-client/assets/index-DwO46Cs5.css +0 -2
- /package/dist/{core/__tests__/hearth-bootstrap.test.d.ts → commands/__tests__/revive-now-gate.test.d.ts} +0 -0
- /package/dist/{core/hearth/__tests__/model-auth-guest.test.d.ts → commands/sys/__tests__/setup-core.test.d.ts} +0 -0
- /package/dist/core/{hearth/providers/__tests__/sweep-and-release.test.d.ts → __tests__/fault-classifier.test.d.ts} +0 -0
- /package/dist/core/{hearth/providers/types.js → __tests__/host-teardown-process-group.test.d.ts} +0 -0
- /package/dist/core/{hearth/types.js → __tests__/review-model-floor.test.d.ts} +0 -0
- /package/dist/{hearth/control-plane/__tests__/error-serialization.test.d.ts → core/__tests__/session-cycles.test.d.ts} +0 -0
- /package/dist/{hearth/control-plane/__tests__/node-message.test.d.ts → core/__tests__/worktree.test.d.ts} +0 -0
|
@@ -24,18 +24,23 @@
|
|
|
24
24
|
// thing a terminal worker's bearings drop). The prose lives in
|
|
25
25
|
// core/runtime/bearings.ts (shared with the promotion guidance dump).
|
|
26
26
|
//
|
|
27
|
-
// IDEMPOTENT across resumes, but FORK-AWARE
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
27
|
+
// IDEMPOTENT across resumes, but FORK-AWARE and BRANCH-AWARE: the idempotency
|
|
28
|
+
// scan walks only the ACTIVE BRANCH (root-first from the current leaf), not
|
|
29
|
+
// every entry in the file. A `--session` relaunch that is a true resume keeps
|
|
30
|
+
// the same branch, so the scan finds OUR prior bearings (named by OUR node id)
|
|
31
|
+
// and skips — it never accumulates. A post-yield CYCLE roots a fresh branch (the
|
|
32
|
+
// `crtr-cycle` marker), so the scan correctly finds nothing on that fresh branch
|
|
33
|
+
// and injects a new intro, even though an OLDER cycle's intro still sits
|
|
34
|
+
// elsewhere in the same `.jsonl`. A `--fork-from` boot COPIES the source node's
|
|
35
|
+
// whole conversation onto ITS OWN branch (bearings naming the SOURCE's node id,
|
|
36
|
+
// not ours), so the handler must NOT treat that inherited block as ours; it only
|
|
37
|
+
// skips when a bearings block belonging to OUR node is already present on the
|
|
38
|
+
// active branch (exact `details.nodeId` stamp, content-match fallback),
|
|
39
|
+
// otherwise it injects ours — whose identity assertion (leading the
|
|
40
|
+
// <crtr-bearings> block) reasserts the fork's identity over the inherited
|
|
41
|
+
// persona. This is ONE of two reinforcing channels: spawn.ts ALSO prepends the
|
|
42
|
+
// same identity assertion to a fork's kickoff prompt (the turn-triggering
|
|
43
|
+
// message), so the override does not rest on a single trailing custom_message.
|
|
39
44
|
//
|
|
40
45
|
// COLLAPSED BY DEFAULT: a `registerMessageRenderer` keyed to our customType
|
|
41
46
|
// renders the block as a single one-line stub; the full body only appears when
|
|
@@ -166,22 +171,28 @@ export function registerCanvasContextIntro(pi) {
|
|
|
166
171
|
const nodeId = process.env['CRTR_NODE_ID'];
|
|
167
172
|
if (nodeId === undefined || nodeId.trim() === '')
|
|
168
173
|
return; // not a canvas node
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
174
|
+
// Branch-aware idempotency: scan only the ACTIVE branch (root-first from
|
|
175
|
+
// the current leaf), not every entry in the file. A post-yield cycle roots a
|
|
176
|
+
// FRESH branch (the crtr-cycle marker), so scanning the whole file would
|
|
177
|
+
// find a PRIOR cycle's intro and wrongly skip injecting this cycle's own —
|
|
178
|
+
// the node's first turn would lack its crtr-context bearings entirely.
|
|
179
|
+
// Falls back to a whole-file scan only if the engine doesn't expose
|
|
180
|
+
// getBranch (older/degraded engine). Not fooled by a FORK either way: a
|
|
181
|
+
// `--fork-from` boot copies the source's whole conversation onto ITS OWN
|
|
182
|
+
// branch (bearings naming the SOURCE's node id, not ours), so a naive
|
|
183
|
+
// "any crtr-context present?" check would suppress our own intro and let
|
|
184
|
+
// the fork inherit — and impersonate — the source. So we only skip when a
|
|
185
|
+
// bearings block belonging to OUR node is already present on the scanned
|
|
186
|
+
// branch. Primary discriminator: the EXACT `details.nodeId` stamp (machine-
|
|
177
187
|
// readable, copied on fork, never sent to the LLM). Fallback: a substring
|
|
178
188
|
// match on the block text (our id appears in the identity line AND the
|
|
179
189
|
// context-dir path `…/nodes/<nodeId>/context`) — covers legacy blocks
|
|
180
190
|
// persisted before the stamp existed. Either match ⇒ this is our own
|
|
181
191
|
// resume, not an inherited fork block, so skip.
|
|
182
|
-
const
|
|
183
|
-
.
|
|
184
|
-
.
|
|
192
|
+
const scan = typeof ctx.sessionManager.getBranch === 'function'
|
|
193
|
+
? ctx.sessionManager.getBranch()
|
|
194
|
+
: ctx.sessionManager.getEntries();
|
|
195
|
+
const ours = scan.some((e) => e.type === 'custom_message' &&
|
|
185
196
|
e.customType === CONTEXT_INTRO_CUSTOM_TYPE &&
|
|
186
197
|
(e.details?.nodeId === nodeId || entryText(e).includes(nodeId)));
|
|
187
198
|
if (ours)
|
|
@@ -314,16 +314,22 @@ export function registerCanvasStophook(pi) {
|
|
|
314
314
|
}
|
|
315
315
|
// Boot / startup / resume / reload / fork → (re)bind this process to its
|
|
316
316
|
// session id, record our OS pid (the daemon's broker-liveness signal), and
|
|
317
|
-
// CONFIRM any pending refresh-yield. Reaching session_start
|
|
318
|
-
// engine actually booted, so it is now safe to clear
|
|
319
|
-
// refresh shuts the broker down and the daemon
|
|
320
|
-
// leaves intent='refresh' set until this boot
|
|
321
|
-
// relaunch worked; otherwise a failed relaunch
|
|
317
|
+
// CONFIRM any pending refresh-yield / pending cycle. Reaching session_start
|
|
318
|
+
// proves a fresh engine actually booted, so it is now safe to clear
|
|
319
|
+
// intent='refresh' — a refresh shuts the broker down and the daemon
|
|
320
|
+
// relaunches it FRESH, which leaves intent='refresh' set until this boot
|
|
321
|
+
// clears it (the only proof the relaunch worked; otherwise a failed relaunch
|
|
322
|
+
// would look like a success). Clearing `cycle_pending` here is the same
|
|
323
|
+
// proof for reviveNode's cycling-attempt marker (revive.ts) — it is always
|
|
324
|
+
// safe to clear on ANY confirmed boot (cycling, resuming, or fresh), since a
|
|
325
|
+
// pre-session_start crash-retry (crtrd.ts) only needs the flag while boot is
|
|
326
|
+
// still unconfirmed.
|
|
322
327
|
const existing = getNode(nodeId);
|
|
323
328
|
// Identity (session id/file) → meta; runtime (pid, intent) → atomic row setters.
|
|
324
329
|
updateNode(nodeId, {
|
|
325
330
|
pi_session_id: id,
|
|
326
331
|
pi_session_file: sessionFile,
|
|
332
|
+
cycle_pending: false,
|
|
327
333
|
});
|
|
328
334
|
recordPid(nodeId, process.pid);
|
|
329
335
|
if (existing?.intent === 'refresh')
|