@north-light/crouter 0.3.232 → 0.3.234
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/api/client.js +16 -15
- package/dist/builtin-memory/internal/memory-loading.md +4 -3
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/__tests__/integration/provider-rotation.test.ts +1 -1
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/claude-plugin-commands.ts +14 -17
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/crtr-commands/index.ts +7 -11
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/frontmatter-rules/index.ts +8 -8
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +10 -11
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/pi-shell-runner.ts +2 -2
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.d.ts +3 -3
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.js +7 -7
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +8 -8
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/statusline.ts +6 -6
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/sysprompt-window.ts +3 -3
- package/dist/builtin-pi-packages/pi-crtr-extensions/lib/subscription-state.ts +1 -1
- package/dist/clients/attach/chrome/ticket-panel.js +15 -2
- package/dist/clients/attach/overlays/graph.js +0 -3
- package/dist/clients/attach/overlays/mcp.js +1 -2
- package/dist/clients/attach/render/chat-view.js +0 -12
- package/dist/clients/attach/render/crtr-output.js +0 -2
- package/dist/clients/attach/render/tool-calls.js +0 -6
- package/dist/clients/attach/slash/dispatch.js +8 -11
- package/dist/clients/attach/viewer.js +532 -534
- package/dist/clients/conversation/projection.js +0 -2
- package/dist/clients/inbox/controller.js +22 -3
- package/dist/clients/inbox/review/companion-pane.js +0 -4
- package/dist/clients/inbox/review-adapter.js +0 -7
- package/dist/clients/inbox/tui/slots.d.ts +3 -3
- package/dist/clients/inbox/tui/types.d.ts +2 -2
- package/dist/commands/api-client.js +0 -8
- package/dist/commands/attention.js +0 -8
- package/dist/commands/canvas-browse.js +2 -1
- package/dist/commands/canvas-config.js +0 -10
- package/dist/commands/canvas-history.js +2 -1
- package/dist/commands/cron.js +5 -18
- package/dist/commands/dashboard.js +0 -2
- package/dist/commands/human/feedback.js +2 -1
- package/dist/commands/human/prompts.js +2 -5
- package/dist/commands/human/queue.js +2 -7
- package/dist/commands/human/request.js +0 -14
- package/dist/commands/human/review.js +2 -1
- package/dist/commands/memory/__tests__/command-selector-and-mutation-guards.test.js +4 -4
- package/dist/commands/memory/find.js +2 -2
- package/dist/commands/memory/lint.js +2 -1
- package/dist/commands/memory/read.d.ts +2 -7
- package/dist/commands/memory/read.js +5 -16
- package/dist/commands/memory/shared.d.ts +1 -1
- package/dist/commands/memory/shared.js +7 -10
- package/dist/commands/memory/write.js +4 -3
- package/dist/commands/node/bash.js +2 -1
- package/dist/commands/node/create.js +2 -1
- package/dist/commands/node/inspect.js +0 -6
- package/dist/commands/node/lifecycle.js +4 -13
- package/dist/commands/node/message.js +3 -2
- package/dist/commands/node/subscription.js +2 -1
- package/dist/commands/node/wait.js +4 -3
- package/dist/commands/node-context.js +2 -1
- package/dist/commands/node-lifecycle-revive.js +0 -2
- package/dist/commands/node-worktree.js +2 -1
- package/dist/commands/pkg/browse/actions.d.ts +1 -1
- package/dist/commands/pkg/browse/actions.js +4 -4
- package/dist/commands/pkg/browse/catalog.d.ts +1 -1
- package/dist/commands/pkg/browse/catalog.js +15 -15
- package/dist/commands/pkg/browse/command-view.d.ts +1 -1
- package/dist/commands/pkg/browse/command-view.js +3 -3
- package/dist/commands/pkg/browse/detail-panel.d.ts +1 -1
- package/dist/commands/pkg/browse/detail-panel.js +8 -8
- package/dist/commands/pkg/browse/doc-view.d.ts +1 -1
- package/dist/commands/pkg/browse/doc-view.js +3 -3
- package/dist/commands/pkg/browse/list-panel.d.ts +1 -1
- package/dist/commands/pkg/browse/list-panel.js +3 -3
- package/dist/commands/pkg/browse/model.d.ts +3 -3
- package/dist/commands/pkg/browse/shell.d.ts +2 -2
- package/dist/commands/pkg/browse/shell.js +13 -13
- package/dist/commands/pkg/plugin-manage.js +2 -1
- package/dist/commands/pkg/shared.js +0 -2
- package/dist/commands/profile/delete.js +2 -1
- package/dist/commands/push.js +2 -3
- package/dist/commands/revive.js +0 -2
- package/dist/commands/surface/node/placement.js +2 -1
- package/dist/commands/surface-edit.js +2 -1
- package/dist/commands/sys/config.js +0 -4
- package/dist/commands/sys/daemon.js +0 -10
- package/dist/commands/sys/doctor.js +3 -2
- package/dist/commands/sys/panels/broker-limits-panel.d.ts +2 -2
- package/dist/commands/sys/panels/broker-limits-panel.js +4 -4
- package/dist/commands/sys/panels/dependencies-panel.d.ts +2 -2
- package/dist/commands/sys/panels/dependencies-panel.js +2 -2
- package/dist/commands/sys/panels/keybindings-panel.d.ts +1 -1
- package/dist/commands/sys/panels/keybindings-panel.js +5 -5
- package/dist/commands/sys/panels/models-panel.d.ts +4 -4
- package/dist/commands/sys/panels/models-panel.js +11 -10
- package/dist/commands/sys/panels/plugins-panel.d.ts +2 -2
- package/dist/commands/sys/panels/plugins-panel.js +2 -2
- package/dist/commands/sys/panels/prefs-panel.d.ts +2 -2
- package/dist/commands/sys/panels/prefs-panel.js +4 -4
- package/dist/commands/sys/panels/profiles-panel.d.ts +1 -1
- package/dist/commands/sys/panels/profiles-panel.js +14 -13
- package/dist/commands/sys/panels/provider-panel.d.ts +3 -3
- package/dist/commands/sys/panels/provider-panel.js +8 -8
- package/dist/commands/sys/settings-shell.d.ts +3 -3
- package/dist/commands/sys/settings-shell.js +15 -15
- package/dist/commands/sys/setup-settings-runner.d.ts +3 -3
- package/dist/commands/sys/setup-settings-runner.js +5 -5
- package/dist/commands/sys/setup-wizard.d.ts +4 -4
- package/dist/commands/sys/setup-wizard.js +8 -8
- package/dist/commands/sys/support/prepare.js +4 -4
- package/dist/commands/sys/support/submit.js +2 -2
- package/dist/commands/sys/sync-deps.js +0 -2
- package/dist/commands/sys/sync-project-guidance.js +2 -1
- package/dist/commands/sys/sysprompt.js +2 -1
- package/dist/core/__tests__/boot.test.js +0 -8
- package/dist/core/__tests__/broker-extension-canvas-db-boundary.test.js +23 -1
- package/dist/core/__tests__/canvas-db-boundary.test.d.ts +1 -0
- package/dist/core/__tests__/canvas-db-boundary.test.js +46 -0
- package/dist/core/__tests__/canvas.test.js +1 -1
- package/dist/core/__tests__/child-death-wake.test.js +0 -2
- package/dist/core/__tests__/cron-armed-context-failure.test.d.ts +1 -0
- package/dist/core/__tests__/cron-armed-context-failure.test.js +145 -0
- package/dist/core/__tests__/daemon-wedge.test.js +0 -4
- package/dist/core/__tests__/dead-node-policy-table.test.js +0 -4
- package/dist/core/__tests__/fixtures/fake-engine.js +4 -14
- package/dist/core/__tests__/fixtures/fake-pi-host.js +5 -5
- package/dist/core/__tests__/focuses.test.js +0 -6
- package/dist/core/__tests__/fs-utils.test.d.ts +1 -0
- package/dist/core/__tests__/fs-utils.test.js +50 -0
- package/dist/core/__tests__/helpers/harness.js +1 -1
- package/dist/core/__tests__/inline-memory-refs.test.js +0 -2
- package/dist/core/__tests__/integration/broker-fork-seam.test.js +0 -2
- package/dist/core/__tests__/integration/broker-sdk-wiring.test.js +3 -16
- package/dist/core/__tests__/integration/command-plugins.test.js +0 -24
- package/dist/core/__tests__/integration/deferred-no-wake.test.js +0 -6
- package/dist/core/__tests__/integration/flagship-lifecycle.test.js +0 -26
- package/dist/core/__tests__/integration/live-mutation-verbs.test.js +0 -4
- package/dist/core/__tests__/integration/live-mutation.test.js +1 -5
- package/dist/core/__tests__/integration/refresh-stall-recycle.test.js +1 -5
- package/dist/core/__tests__/integration/revive.test.js +0 -12
- package/dist/core/__tests__/integration/subscription-delivery.test.js +0 -6
- package/dist/core/__tests__/integration/tmux-surface.test.js +24 -8
- package/dist/core/__tests__/integration/worktree-reap.test.js +0 -6
- package/dist/core/__tests__/lifecycle.test.js +0 -18
- package/dist/core/__tests__/memory-resolver-precedence.test.js +1 -1
- package/dist/core/__tests__/migration.test.js +2 -2
- package/dist/core/__tests__/on-read-dedup-resume.test.js +3 -3
- package/dist/core/__tests__/pid-identity-match.test.js +1 -1
- package/dist/core/__tests__/plugin-kinds.test.js +1 -1
- package/dist/core/__tests__/plugin-page-components.test.js +1 -1
- package/dist/core/__tests__/preview-registry-sync.test.js +42 -1
- package/dist/core/__tests__/respawn-throttle.test.js +0 -4
- package/dist/core/__tests__/revive-all.test.js +5 -5
- package/dist/core/__tests__/revive-parked-fresh.test.js +62 -11
- package/dist/core/__tests__/seam/broker-attach-multiclient.test.js +0 -8
- package/dist/core/__tests__/seam/broker-attach-stream.test.js +0 -8
- package/dist/core/__tests__/seam/broker-crash-teardown.test.js +0 -2
- package/dist/core/__tests__/tmux-driver-boundary.test.d.ts +1 -0
- package/dist/core/__tests__/tmux-driver-boundary.test.js +50 -0
- package/dist/core/activity-signal.d.ts +7 -0
- package/dist/core/activity-signal.js +38 -0
- package/dist/core/auto-update.js +2 -1
- package/dist/core/bootstrap.js +2 -1
- package/dist/core/canvas/__tests__/remote-canvas-source.test.js +1 -1
- package/dist/core/canvas/__tests__/remote-transport.test.js +1 -1
- package/dist/core/canvas/__tests__/render-remote.test.js +1 -1
- package/dist/core/canvas/browse/app.js +3 -2
- package/dist/core/canvas/browse/model.d.ts +1 -1
- package/dist/core/canvas/browse/model.js +0 -4
- package/dist/core/canvas/canvas.d.ts +22 -0
- package/dist/core/canvas/canvas.js +50 -18
- package/dist/core/canvas/crons.js +0 -6
- package/dist/core/canvas/db.d.ts +14 -20
- package/dist/core/canvas/db.js +30 -1332
- package/dist/core/canvas/focuses.js +0 -4
- package/dist/core/canvas/history.js +2 -1
- package/dist/core/canvas/migrations.d.ts +20 -0
- package/dist/core/canvas/migrations.js +1339 -0
- package/dist/core/canvas/nav-model.js +1 -11
- package/dist/core/canvas/nav-render.js +0 -8
- package/dist/core/canvas/remote-canvas-source.js +0 -2
- package/dist/core/canvas/render-source.js +31 -13
- package/dist/core/command-manifests/manifest.js +0 -10
- package/dist/core/command-manifests/schema.js +0 -4
- package/dist/core/command-plugins/transport/http-invoke.js +0 -14
- package/dist/core/command.js +0 -4
- package/dist/core/config.js +2 -1
- package/dist/core/feed/inbox.d.ts +10 -0
- package/dist/core/feed/inbox.js +18 -12
- package/dist/core/fs-utils.d.ts +9 -2
- package/dist/core/fs-utils.js +7 -15
- package/dist/core/help.js +0 -8
- package/dist/core/host-exports/export.d.ts +2 -2
- package/dist/core/host-exports/export.js +9 -12
- package/dist/core/human/answer.d.ts +2 -2
- package/dist/core/human/convention.d.ts +2 -5
- package/dist/core/human/convention.js +3 -13
- package/dist/core/human/page-schema.d.ts +2 -2
- package/dist/core/human/page-schema.js +2 -2
- package/dist/core/human/root.js +6 -23
- package/dist/core/human/scan.js +24 -7
- package/dist/core/human/tickets.d.ts +4 -1
- package/dist/core/human/tickets.js +20 -6
- package/dist/core/io.js +0 -12
- package/dist/core/memory/identity.js +0 -4
- package/dist/core/memory/inline-ref-inventory.js +3 -2
- package/dist/core/memory/lint.js +3 -6
- package/dist/core/memory-resolver.d.ts +5 -0
- package/dist/core/memory-resolver.js +14 -12
- package/dist/core/pagination.js +0 -2
- package/dist/core/preview-registry.d.ts +14 -0
- package/dist/core/preview-registry.js +2 -4
- package/dist/core/preview-result-path.js +2 -1
- package/dist/core/profiles/manifest.d.ts +37 -5
- package/dist/core/profiles/manifest.js +44 -24
- package/dist/core/profiles/select.js +0 -4
- package/dist/core/review/signal.js +4 -23
- package/dist/core/review/ticket-filter.d.ts +3 -3
- package/dist/core/review/ticket-filter.js +4 -9
- package/dist/core/runtime/__tests__/engine-route.test.js +1 -1
- package/dist/core/runtime/__tests__/spawn-env.test.js +0 -8
- package/dist/core/runtime/bearings-render.d.ts +56 -0
- package/dist/core/runtime/bearings-render.js +241 -0
- package/dist/core/runtime/bearings.d.ts +2 -17
- package/dist/core/runtime/bearings.js +12 -198
- package/dist/core/runtime/broker/auth-reload.d.ts +39 -0
- package/dist/core/runtime/broker/auth-reload.js +149 -0
- package/dist/core/runtime/broker/engine-drive.d.ts +26 -0
- package/dist/core/runtime/broker/engine-drive.js +257 -0
- package/dist/core/runtime/broker/engine-routing.d.ts +143 -0
- package/dist/core/runtime/broker/engine-routing.js +211 -0
- package/dist/core/runtime/broker/event-projection.js +3 -2
- package/dist/core/runtime/broker/fault-retry.js +5 -4
- package/dist/core/runtime/broker/frame-client.d.ts +38 -0
- package/dist/core/runtime/broker/frame-client.js +129 -0
- package/dist/core/runtime/broker/frame-dispatch.d.ts +12 -189
- package/dist/core/runtime/broker/frame-dispatch.js +89 -1476
- package/dist/core/runtime/broker/frame-engine-control.d.ts +20 -0
- package/dist/core/runtime/broker/frame-engine-control.js +231 -0
- package/dist/core/runtime/broker/frame-memory-refs.d.ts +19 -0
- package/dist/core/runtime/broker/frame-memory-refs.js +41 -0
- package/dist/core/runtime/broker/frame-model-query.d.ts +13 -0
- package/dist/core/runtime/broker/frame-model-query.js +69 -0
- package/dist/core/runtime/broker/frame-read.d.ts +19 -0
- package/dist/core/runtime/broker/frame-read.js +116 -0
- package/dist/core/runtime/broker/frame-replies.d.ts +24 -0
- package/dist/core/runtime/broker/frame-replies.js +64 -0
- package/dist/core/runtime/broker/frame-session.d.ts +34 -0
- package/dist/core/runtime/broker/frame-session.js +203 -0
- package/dist/core/runtime/broker/turn-ignition.d.ts +42 -0
- package/dist/core/runtime/broker/turn-ignition.js +74 -0
- package/dist/core/runtime/broker-extension-render.js +9 -85
- package/dist/core/runtime/broker-protocol.js +0 -4
- package/dist/core/runtime/broker-sdk.js +2 -1
- package/dist/core/runtime/broker.d.ts +1 -1
- package/dist/core/runtime/broker.js +5 -23
- package/dist/core/runtime/fault.js +3 -2
- package/dist/core/runtime/headless-pi.js +3 -2
- package/dist/core/runtime/host.js +2 -3
- package/dist/core/runtime/kickoff.js +0 -4
- package/dist/core/runtime/launch-target.js +2 -1
- package/dist/core/runtime/launch.js +3 -6
- package/dist/core/runtime/lifecycle.js +17 -26
- package/dist/core/runtime/managed-provider-cooling.d.ts +1 -1
- package/dist/core/runtime/naming.js +0 -2
- package/dist/core/runtime/nodes.js +2 -1
- package/dist/core/runtime/persona.js +0 -6
- package/dist/core/runtime/placement-tmux.js +2 -5
- package/dist/core/runtime/placement.js +4 -11
- package/dist/core/runtime/recap.js +4 -3
- package/dist/core/runtime/reopen.js +4 -7
- package/dist/core/runtime/reset.js +0 -4
- package/dist/core/runtime/resume-root.js +0 -2
- package/dist/core/runtime/revive.js +17 -13
- package/dist/core/runtime/session-list-cache.js +2 -2
- package/dist/core/runtime/shell-expansion.js +0 -2
- package/dist/core/runtime/spawn.js +0 -2
- package/dist/core/runtime/stream-watchdog.d.ts +0 -1
- package/dist/core/runtime/stream-watchdog.js +13 -18
- package/dist/core/runtime/tmux-bindings.js +0 -2
- package/dist/core/runtime/tmux-driver.d.ts +12 -0
- package/dist/core/runtime/tmux-driver.js +18 -13
- package/dist/core/runtime/warm-pool.js +0 -4
- package/dist/core/scope.js +4 -3
- package/dist/core/spawn.js +2 -3
- package/dist/core/subscription-state.js +10 -17
- package/dist/core/substrate/__tests__/surface-match-pre-command.test.d.ts +1 -0
- package/dist/core/substrate/__tests__/surface-match-pre-command.test.js +92 -0
- package/dist/core/substrate/frontmatter-validation.js +1 -1
- package/dist/core/substrate/injected-store.d.ts +6 -0
- package/dist/core/substrate/injected-store.js +24 -0
- package/dist/core/substrate/on-read.d.ts +17 -1
- package/dist/core/substrate/on-read.js +36 -2
- package/dist/core/substrate/render.js +0 -12
- package/dist/core/substrate/schema.d.ts +3 -3
- package/dist/core/substrate/schema.js +4 -16
- package/dist/core/substrate/surface-match.d.ts +19 -0
- package/dist/core/substrate/surface-match.js +60 -2
- package/dist/core/termrender/display.js +2 -1
- package/dist/core/tui/page-host.d.ts +3 -3
- package/dist/core/tui/page-host.js +4 -4
- package/dist/core/tui/panel.js +3 -3
- package/dist/core/wake.js +0 -12
- package/dist/core/worktree.js +0 -2
- package/dist/daemon/__tests__/reconciler-signature.test.d.ts +1 -0
- package/dist/daemon/__tests__/reconciler-signature.test.js +36 -0
- package/dist/daemon/api/__tests__/seam/api-server.test.js +2 -16
- package/dist/daemon/api/__tests__/seam/b10-attach-modelauth.test.js +3 -11
- package/dist/daemon/api/__tests__/seam/leaf-api-parity.test.js +0 -6
- package/dist/daemon/api/handlers/attach.js +2 -1
- package/dist/daemon/api/handlers/broker-ops.js +3 -6
- package/dist/daemon/api/handlers/canvas.js +12 -18
- package/dist/daemon/api/handlers/feedback-comments.js +0 -8
- package/dist/daemon/api/handlers/health.js +3 -2
- package/dist/daemon/api/handlers/human-requests.js +0 -10
- package/dist/daemon/api/handlers/human.js +1 -5
- package/dist/daemon/api/handlers/inbox.js +0 -18
- package/dist/daemon/api/handlers/memory.js +1 -1
- package/dist/daemon/api/handlers/messages.js +4 -8
- package/dist/daemon/api/handlers/nodes.js +10 -21
- package/dist/daemon/api/handlers/reports.js +1 -1
- package/dist/daemon/api/handlers/reviews.js +1 -6
- package/dist/daemon/api/map.js +0 -6
- package/dist/daemon/api/router.js +0 -4
- package/dist/daemon/api/server.js +2 -5
- package/dist/daemon/boot-migrations.d.ts +14 -0
- package/dist/daemon/boot-migrations.js +31 -0
- package/dist/daemon/cron/armed-context.d.ts +21 -0
- package/dist/daemon/cron/armed-context.js +100 -0
- package/dist/daemon/cron/capture.d.ts +20 -0
- package/dist/daemon/cron/capture.js +45 -0
- package/dist/daemon/cron/disposition.d.ts +19 -0
- package/dist/daemon/cron/disposition.js +52 -0
- package/dist/daemon/cron/escalation.d.ts +12 -0
- package/dist/daemon/cron/escalation.js +124 -0
- package/dist/daemon/cron/held.d.ts +4 -0
- package/dist/daemon/cron/held.js +20 -0
- package/dist/daemon/cron/lease-recovery.d.ts +3 -0
- package/dist/daemon/cron/lease-recovery.js +119 -0
- package/dist/daemon/cron/live-runs.d.ts +11 -0
- package/dist/daemon/cron/live-runs.js +23 -0
- package/dist/daemon/cron/passes.d.ts +11 -0
- package/dist/daemon/cron/passes.js +78 -0
- package/dist/daemon/cron/settle.d.ts +28 -0
- package/dist/daemon/cron/settle.js +37 -0
- package/dist/daemon/cron/sinks.d.ts +2 -0
- package/dist/daemon/cron/sinks.js +100 -0
- package/dist/daemon/cron-run.d.ts +5 -41
- package/dist/daemon/cron-run.js +193 -882
- package/dist/daemon/crtrd-cli.js +2 -1
- package/dist/daemon/crtrd.js +22 -22
- package/dist/daemon/fleet.js +0 -4
- package/dist/daemon/human/deliver-action.js +2 -1
- package/dist/daemon/human/sweep.js +15 -4
- package/dist/daemon/manage.d.ts +2 -2
- package/dist/daemon/manage.js +4 -13
- package/dist/daemon/pidfile.js +2 -2
- package/dist/daemon/reconcilers/broker-supervision.js +26 -29
- package/dist/daemon/reconcilers/dormant-inbox.d.ts +1 -1
- package/dist/daemon/reconcilers/dormant-inbox.js +2 -1
- package/dist/daemon/reconcilers/live-obligation.js +2 -2
- package/dist/daemon/reconcilers/pending-review-submit.d.ts +1 -1
- package/dist/daemon/reconcilers/pending-review-submit.js +2 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +2 -1
- package/dist/daemon/reconcilers/storage-maintenance.js +2 -1
- package/dist/daemon/review/companion.js +2 -2
- package/dist/daemon/review/sweep.js +8 -3
- package/dist/migrations/001-surfaces-frontmatter.js +0 -6
- package/dist/migrations/corpus.js +2 -5
- package/dist/migrations/registry.js +15 -2
- package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.js +0 -4
- package/dist/pi-extensions/__tests__/pre-command-gate.test.d.ts +1 -0
- package/dist/pi-extensions/__tests__/pre-command-gate.test.js +220 -0
- package/dist/pi-extensions/broker-local.js +2 -1
- package/dist/pi-extensions/canvas-bash-valve.js +3 -17
- package/dist/pi-extensions/canvas-context-intro.js +2 -7
- package/dist/pi-extensions/canvas-doc-substrate.d.ts +14 -0
- package/dist/pi-extensions/canvas-doc-substrate.js +77 -5
- package/dist/pi-extensions/canvas-goal-capture.js +2 -1
- package/dist/pi-extensions/canvas-inbox-watcher.js +5 -12
- package/dist/pi-extensions/canvas-passive-context.js +2 -5
- package/dist/pi-extensions/canvas-preview-result.js +2 -1
- package/dist/pi-extensions/canvas-prompt-scrub.js +2 -1
- package/dist/pi-extensions/canvas-recap.js +3 -16
- package/dist/pi-extensions/canvas-review-boundary.js +2 -5
- package/dist/pi-extensions/canvas-stophook.js +2 -26
- package/dist/pi-extensions/canvas-structured-output.js +2 -1
- package/dist/pi-extensions/canvas-tool-guide.js +2 -1
- package/dist/shared/__tests__/env-boundary.test.d.ts +1 -0
- package/dist/shared/__tests__/env-boundary.test.js +93 -0
- package/dist/shared/env.d.ts +68 -0
- package/dist/shared/env.js +171 -0
- package/package.json +3 -1
- package/runtime.lock.json +2 -2
- package/dist/core/canvas/render.d.ts +0 -47
- package/dist/core/canvas/render.js +0 -245
|
@@ -24,6 +24,28 @@ export declare function updateNode(nodeId: string, patch: Partial<NodeIdentity>)
|
|
|
24
24
|
export declare function setStatus(nodeId: string, status: NodeStatus): void;
|
|
25
25
|
/** Set a node's exit intent. Atomic single-column write. */
|
|
26
26
|
export declare function setIntent(nodeId: string, intent: ExitIntent): void;
|
|
27
|
+
/** Atomically write status and/or intent, gated on an optional from-status set
|
|
28
|
+
* and/or on the row carrying no committed final_report. The lifecycle state
|
|
29
|
+
* machine (runtime/lifecycle.ts) is the one caller: it owns the legality
|
|
30
|
+
* table and the unknown-node/illegal-move/already-finalized-cancel branching,
|
|
31
|
+
* this only performs the single conditional UPDATE it needs. A PRESENT key in
|
|
32
|
+
* `fields` (even `intent: null`) writes that column; an ABSENT key leaves it
|
|
33
|
+
* unchanged. Returns the row-changed count so the caller can distinguish "no
|
|
34
|
+
* such node", "gate failed", and "already applied" without a second query. */
|
|
35
|
+
export declare function transitionStatusIntent(nodeId: string, fields: {
|
|
36
|
+
status?: NodeStatus;
|
|
37
|
+
intent?: ExitIntent;
|
|
38
|
+
}, opts?: {
|
|
39
|
+
fromStatuses?: readonly NodeStatus[];
|
|
40
|
+
requireNoFinalReport?: boolean;
|
|
41
|
+
}): number;
|
|
42
|
+
/** Read a node's committed-final latch pointer. Pure read, no side effect. */
|
|
43
|
+
export declare function getFinalReport(nodeId: string): string | null;
|
|
44
|
+
/** CAS-clear a node's finalization latch (final_report + finalized_at) —
|
|
45
|
+
* retract-pointer-only. Gated on the exact final_report value the caller
|
|
46
|
+
* observed via getFinalReport, so a concurrent clear/refinalize can never be
|
|
47
|
+
* clobbered. Returns true iff the CAS matched and cleared. */
|
|
48
|
+
export declare function clearFinalReportIfMatches(nodeId: string, expectedFinalReport: string): boolean;
|
|
27
49
|
/** Set a node's tmux presence in one atomic write: the durable LOCATION anchor
|
|
28
50
|
* `pane` (the `%pane_id`) plus its derived cache (`tmux_session` + `window`).
|
|
29
51
|
* All three move together — `pane` joins the others inside the single UPDATE so
|
|
@@ -4,20 +4,19 @@
|
|
|
4
4
|
// Source-of-truth split: a node's meta.json is canonical for its own fields;
|
|
5
5
|
// the db row is a queryable index re-derivable from it. The subscribes_to edges
|
|
6
6
|
// are db-authoritative (mutable, many-writers — what WAL is for).
|
|
7
|
+
import { envNodeId } from '../../shared/env.js';
|
|
7
8
|
import { existsSync, readFileSync, readdirSync, realpathSync, rmSync, statSync } from 'node:fs';
|
|
8
9
|
import { join, resolve } from 'node:path';
|
|
9
10
|
import { openDb, withCanvasWrite } from './db.js';
|
|
10
11
|
import { withMetaLock, readMetaObject, writeMetaObjectLocked, writeJsonFileDurably } from './meta-file.js';
|
|
11
12
|
import { isPidAlive, recordedPidLiveness, capturePidIdentities, identitiesMatch, isLegacyTicksIdentity, isBootScopedIdentity, } from './pid.js';
|
|
12
13
|
import { ensureHome, ensureNodeDirs, nodeMetaPath, nodeDir, nodesRoot, jobDir, } from './paths.js';
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
14
|
// meta.json (durable identity — the source of truth for what PERSISTS)
|
|
15
15
|
//
|
|
16
16
|
// One authoritative store per fact: meta.json holds NodeIdentity only; the six
|
|
17
17
|
// runtime fields (status, intent, pi_pid, window, tmux_session, pane) are
|
|
18
18
|
// authoritative in the WAL'd `nodes` row, each mutated by one atomic setter
|
|
19
19
|
// below. getNode() hydrates the two back into the historical NodeMeta view.
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
20
|
/** The identity keys meta.json persists. Listed explicitly so no runtime field
|
|
22
21
|
* can ever leak onto disk even when a fully-hydrated NodeMeta is handed in. */
|
|
23
22
|
const IDENTITY_KEYS = [
|
|
@@ -75,12 +74,10 @@ function readMeta(nodeId) {
|
|
|
75
74
|
function writeMeta(meta) {
|
|
76
75
|
writeJsonFileDurably(nodeMetaPath(meta.node_id), toIdentity(meta));
|
|
77
76
|
}
|
|
78
|
-
// ---------------------------------------------------------------------------
|
|
79
77
|
// row index — identity columns are a derived projection of meta; runtime
|
|
80
78
|
// columns are authoritative. The two have DIFFERENT writers: upsertRow only
|
|
81
79
|
// ever touches identity (so a re-index never clobbers live runtime), while
|
|
82
80
|
// createNode seeds runtime once and the atomic setters own it thereafter.
|
|
83
|
-
// ---------------------------------------------------------------------------
|
|
84
81
|
/** Upsert the IDENTITY columns of a node's row. ON CONFLICT updates identity
|
|
85
82
|
* ONLY — runtime columns (status/intent/pi_pid/window/tmux_session/pane) are left
|
|
86
83
|
* exactly as they are, so re-indexing or an identity edit never disturbs live
|
|
@@ -162,9 +159,7 @@ function runtimeFromRow(nodeId) {
|
|
|
162
159
|
pane: r['pane'] ?? null,
|
|
163
160
|
};
|
|
164
161
|
}
|
|
165
|
-
// ---------------------------------------------------------------------------
|
|
166
162
|
// Nodes
|
|
167
|
-
// ---------------------------------------------------------------------------
|
|
168
163
|
/** Create a node: scaffold its dirs, persist identity to meta.json, and seed the
|
|
169
164
|
* row (identity + runtime from the incoming meta). Returns the hydrated view. */
|
|
170
165
|
export function createNode(meta) {
|
|
@@ -236,13 +231,11 @@ export function updateNode(nodeId, patch) {
|
|
|
236
231
|
upsertRow(next);
|
|
237
232
|
return getNode(nodeId);
|
|
238
233
|
}
|
|
239
|
-
// ---------------------------------------------------------------------------
|
|
240
234
|
// Atomic runtime setters — each one a single-statement UPDATE on the WAL'd row,
|
|
241
235
|
// the authoritative store for live state. No read-modify-write, so concurrent
|
|
242
236
|
// writers of DIFFERENT fields (the daemon stamping pi_pid while a node flips
|
|
243
237
|
// status) can never clobber each other: WAL serializes the two statements.
|
|
244
238
|
// `"window"` is quoted defensively — it is a SQLite keyword.
|
|
245
|
-
// ---------------------------------------------------------------------------
|
|
246
239
|
/** Set a node's status. Atomic single-column write. */
|
|
247
240
|
export function setStatus(nodeId, status) {
|
|
248
241
|
openDb().prepare('UPDATE nodes SET status = ? WHERE node_id = ?').run(status, nodeId);
|
|
@@ -251,6 +244,53 @@ export function setStatus(nodeId, status) {
|
|
|
251
244
|
export function setIntent(nodeId, intent) {
|
|
252
245
|
openDb().prepare('UPDATE nodes SET intent = ? WHERE node_id = ?').run(intent ?? null, nodeId);
|
|
253
246
|
}
|
|
247
|
+
/** Atomically write status and/or intent, gated on an optional from-status set
|
|
248
|
+
* and/or on the row carrying no committed final_report. The lifecycle state
|
|
249
|
+
* machine (runtime/lifecycle.ts) is the one caller: it owns the legality
|
|
250
|
+
* table and the unknown-node/illegal-move/already-finalized-cancel branching,
|
|
251
|
+
* this only performs the single conditional UPDATE it needs. A PRESENT key in
|
|
252
|
+
* `fields` (even `intent: null`) writes that column; an ABSENT key leaves it
|
|
253
|
+
* unchanged. Returns the row-changed count so the caller can distinguish "no
|
|
254
|
+
* such node", "gate failed", and "already applied" without a second query. */
|
|
255
|
+
export function transitionStatusIntent(nodeId, fields, opts = {}) {
|
|
256
|
+
const assignments = [];
|
|
257
|
+
const values = [];
|
|
258
|
+
if (Object.prototype.hasOwnProperty.call(fields, 'status')) {
|
|
259
|
+
assignments.push('status = ?');
|
|
260
|
+
values.push(fields.status ?? null);
|
|
261
|
+
}
|
|
262
|
+
if (Object.prototype.hasOwnProperty.call(fields, 'intent')) {
|
|
263
|
+
assignments.push('intent = ?');
|
|
264
|
+
values.push(fields.intent ?? null);
|
|
265
|
+
}
|
|
266
|
+
const predicates = ['node_id = ?'];
|
|
267
|
+
values.push(nodeId);
|
|
268
|
+
if (opts.fromStatuses !== undefined) {
|
|
269
|
+
predicates.push(`status IN (${opts.fromStatuses.map(() => '?').join(', ')})`);
|
|
270
|
+
values.push(...opts.fromStatuses);
|
|
271
|
+
}
|
|
272
|
+
if (opts.requireNoFinalReport === true)
|
|
273
|
+
predicates.push('final_report IS NULL');
|
|
274
|
+
const result = openDb()
|
|
275
|
+
.prepare(`UPDATE nodes SET ${assignments.join(', ')} WHERE ${predicates.join(' AND ')}`)
|
|
276
|
+
.run(...values);
|
|
277
|
+
return Number(result.changes);
|
|
278
|
+
}
|
|
279
|
+
/** Read a node's committed-final latch pointer. Pure read, no side effect. */
|
|
280
|
+
export function getFinalReport(nodeId) {
|
|
281
|
+
const row = openDb().prepare('SELECT final_report FROM nodes WHERE node_id = ?').get(nodeId);
|
|
282
|
+
return row?.final_report ?? null;
|
|
283
|
+
}
|
|
284
|
+
/** CAS-clear a node's finalization latch (final_report + finalized_at) —
|
|
285
|
+
* retract-pointer-only. Gated on the exact final_report value the caller
|
|
286
|
+
* observed via getFinalReport, so a concurrent clear/refinalize can never be
|
|
287
|
+
* clobbered. Returns true iff the CAS matched and cleared. */
|
|
288
|
+
export function clearFinalReportIfMatches(nodeId, expectedFinalReport) {
|
|
289
|
+
const result = openDb()
|
|
290
|
+
.prepare('UPDATE nodes SET final_report = NULL, finalized_at = NULL WHERE node_id = ? AND final_report = ?')
|
|
291
|
+
.run(nodeId, expectedFinalReport);
|
|
292
|
+
return result.changes > 0;
|
|
293
|
+
}
|
|
254
294
|
/** Set a node's tmux presence in one atomic write: the durable LOCATION anchor
|
|
255
295
|
* `pane` (the `%pane_id`) plus its derived cache (`tmux_session` + `window`).
|
|
256
296
|
* All three move together — `pane` joins the others inside the single UPDATE so
|
|
@@ -387,10 +427,8 @@ export function listNodes(filter) {
|
|
|
387
427
|
}
|
|
388
428
|
return rows.map(rowFrom);
|
|
389
429
|
}
|
|
390
|
-
// ---------------------------------------------------------------------------
|
|
391
430
|
// Warm pool — spare booted roots awaiting a `prefer_warm` claim (see
|
|
392
431
|
// `runtime/warm-pool.ts` for the recipe key and the mint/refill policy).
|
|
393
|
-
// ---------------------------------------------------------------------------
|
|
394
432
|
/** Mark an already-spawned node as an unclaimed spare for `recipeKey`. Hides it
|
|
395
433
|
* from every listing until it is claimed. */
|
|
396
434
|
export function registerWarmSpare(nodeId, recipeKey) {
|
|
@@ -539,9 +577,7 @@ export function listResumableRoots(cwd) {
|
|
|
539
577
|
.all(cwd);
|
|
540
578
|
return rows.map(rowFrom);
|
|
541
579
|
}
|
|
542
|
-
// ---------------------------------------------------------------------------
|
|
543
580
|
// Edges
|
|
544
|
-
// ---------------------------------------------------------------------------
|
|
545
581
|
function addEdge(type, from, to, active) {
|
|
546
582
|
openDb()
|
|
547
583
|
.prepare(`INSERT INTO edges (type, from_id, to_id, active, created)
|
|
@@ -592,9 +628,7 @@ export function subscriptionsOf(subscriber) {
|
|
|
592
628
|
created: r['created'],
|
|
593
629
|
}));
|
|
594
630
|
}
|
|
595
|
-
// ---------------------------------------------------------------------------
|
|
596
631
|
// Graph queries
|
|
597
|
-
// ---------------------------------------------------------------------------
|
|
598
632
|
/** A "view": every node whose output cascades up to `root` via subscriptions —
|
|
599
633
|
* the subscription sub-DAG reachable downward (root → its reports → theirs …).
|
|
600
634
|
* Returns ids excluding root, in BFS order. Cycle-safe. */
|
|
@@ -714,9 +748,7 @@ export function withFreshTerminalGuard(nodeId, isTerminal, body) {
|
|
|
714
748
|
return { kind: 'ran', result: body() };
|
|
715
749
|
});
|
|
716
750
|
}
|
|
717
|
-
// ---------------------------------------------------------------------------
|
|
718
751
|
// Index rebuild
|
|
719
|
-
// ---------------------------------------------------------------------------
|
|
720
752
|
/** Rebuild node rows from on-disk metas (the db node table is a derived index).
|
|
721
753
|
* Only the IDENTITY columns are rebuilt — they are a projection of meta. The
|
|
722
754
|
* runtime columns (status/intent/pi_pid/window/tmux_session/pane) are NOT in meta
|
|
@@ -823,7 +855,7 @@ export function pruneNodes(opts) {
|
|
|
823
855
|
const dryRun = opts.dryRun ?? false;
|
|
824
856
|
const includeStale = opts.includeStale ?? false;
|
|
825
857
|
const cutoff = new Date(Date.now() - opts.ttlDays * 86_400_000).toISOString();
|
|
826
|
-
const selfId =
|
|
858
|
+
const selfId = envNodeId() ?? '';
|
|
827
859
|
const db = openDb();
|
|
828
860
|
const terminal = db
|
|
829
861
|
.prepare(`SELECT node_id, status, created FROM nodes
|
|
@@ -960,7 +992,7 @@ function recencyMs(nodeId, created) {
|
|
|
960
992
|
* reports the candidate set and deletes NOTHING. */
|
|
961
993
|
export function pruneToLimit(opts) {
|
|
962
994
|
const dryRun = opts.dryRun ?? false;
|
|
963
|
-
const selfId =
|
|
995
|
+
const selfId = envNodeId() ?? '';
|
|
964
996
|
const rows = listNodes();
|
|
965
997
|
// Rank ALL nodes by recency DESC, tagging protection as we go. Protection is
|
|
966
998
|
// status-only (active|idle) — NOT gated on pi_pid liveness — so a node whose
|
|
@@ -59,9 +59,7 @@ function cronFrom(r) {
|
|
|
59
59
|
updated: r['updated'],
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
// ---------------------------------------------------------------------------
|
|
63
62
|
// Signal safety
|
|
64
|
-
// ---------------------------------------------------------------------------
|
|
65
63
|
/** The ONLY sanctioned way to signal a cron run's process group from a stored
|
|
66
64
|
* row. Re-captures the CURRENT identity of `run_pid` and signals only when it
|
|
67
65
|
* MATCHES the fingerprint recorded at lease acquisition. Returns whether the
|
|
@@ -101,9 +99,7 @@ export function verifyLeasedCronRun(c) {
|
|
|
101
99
|
return false; // pid genuinely gone
|
|
102
100
|
return identitiesMatch(current, c.run_pid_identity);
|
|
103
101
|
}
|
|
104
|
-
// ---------------------------------------------------------------------------
|
|
105
102
|
// Writes
|
|
106
|
-
// ---------------------------------------------------------------------------
|
|
107
103
|
/** INSERT one cron row from the pinned arm spec, returning its (caller-
|
|
108
104
|
* supplied) `cron_id` plus the ids of any deadline it displaced. Stamps
|
|
109
105
|
* `created`/`updated`; lease fields start idle.
|
|
@@ -301,9 +297,7 @@ export function advanceCron(cron_id, nextFireIso) {
|
|
|
301
297
|
.prepare('UPDATE crons SET fire_at = ?, updated = ? WHERE cron_id = ?')
|
|
302
298
|
.run(nextFireIso, new Date().toISOString(), cron_id);
|
|
303
299
|
}
|
|
304
|
-
// ---------------------------------------------------------------------------
|
|
305
300
|
// Daemon run-executor primitives (src/daemon/cron-run.ts)
|
|
306
|
-
// ---------------------------------------------------------------------------
|
|
307
301
|
/** The daemon's per-tick due query: active, idle, fire_at arrived, in
|
|
308
302
|
* deterministic order. The idle-only filter IS the default `overlap='skip'`
|
|
309
303
|
* behavior — a row whose previous run is still leased is simply not due.
|
package/dist/core/canvas/db.d.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
|
|
3
|
-
* `user_version` tracks how many have been applied. Append only. Journaled
|
|
4
|
-
* entries from `src/migrations/registry.ts` follow the local steps, so a new
|
|
5
|
-
* registry migration lands as the next version. */
|
|
6
|
-
export declare const MIGRATIONS: ReadonlyArray<(db: DatabaseSync) => void>;
|
|
7
|
-
/** Bring `db` up to the latest schema version. Reads `user_version`, runs each
|
|
8
|
-
* pending migration in order, and bumps `user_version` after each so the work
|
|
9
|
-
* is gated and idempotent: re-running is a no-op once `user_version` reaches
|
|
10
|
-
* `MIGRATIONS.length`. Forward-only.
|
|
11
|
-
*
|
|
12
|
-
* ATOMIC AND RESTARTABLE: each step AND its `user_version` bump run inside one
|
|
13
|
-
* `BEGIN IMMEDIATE`/`COMMIT` (SQLite journals `user_version` with the
|
|
14
|
-
* transaction, so a rollback restores it too). An interrupted or failing step
|
|
15
|
-
* therefore leaves the db exactly at the previous version with none of its
|
|
16
|
-
* writes committed — a half-applied step can never wedge every later open. The
|
|
17
|
-
* write lock also serializes concurrent openers; the version is re-read after
|
|
18
|
-
* acquiring it so a step another process just applied is skipped rather than
|
|
19
|
-
* re-run. */
|
|
20
|
-
export declare function migrate(db: DatabaseSync): void;
|
|
2
|
+
export { migrate, MIGRATIONS } from './migrations.js';
|
|
21
3
|
/** Open (or reuse) the canvas db at the current `CRTR_HOME`, initializing the
|
|
22
4
|
* schema and WAL on first open. Keyed by path so tests with distinct homes get
|
|
23
|
-
* independent handles.
|
|
5
|
+
* independent handles.
|
|
6
|
+
*
|
|
7
|
+
* A cache hit trusts the cached handle outright: `crtrd` is this process's
|
|
8
|
+
* sole canvas-db owner (see `crtrd-sole-state-owner`), and nothing outside
|
|
9
|
+
* `openDb`/`closeDb` ever touches `handles` — there is no other actor in this
|
|
10
|
+
* process that could invalidate a live handle out from under it. (A
|
|
11
|
+
* 2026-06-25 revision added a `PRAGMA database_list` liveness probe here that
|
|
12
|
+
* silently closed and reopened the handle on any throw; it shipped alongside
|
|
13
|
+
* an unrelated guest-relay `PATH` fix for the now-removed `hearth` guest
|
|
14
|
+
* bootstrap, named no concrete failure mode in its commit or a test, and that
|
|
15
|
+
* guest-relay path no longer exists. Removed rather than kept-and-logged: a
|
|
16
|
+
* silent boot-path reopen is worse than trusting a handle this process
|
|
17
|
+
* already owns.) */
|
|
24
18
|
export declare function openDb(): DatabaseSync;
|
|
25
19
|
/** Run `body` under the canvas SQLite write lock, joining an outer transaction
|
|
26
20
|
* when the shared connection already owns one. This is the common boundary for
|