@north-light/crouter 0.3.353 → 0.3.355
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.d.ts +35 -25
- package/dist/api/client.js +2 -2
- package/dist/api/dto/broker-ops.d.ts +2 -36
- package/dist/api/dto/canvas.d.ts +8 -13
- package/dist/api/dto/config.d.ts +4 -0
- package/dist/api/dto/delivery.d.ts +61 -0
- package/dist/api/dto/docs.d.ts +135 -0
- package/dist/api/dto/docs.js +1 -0
- package/dist/api/dto/health.d.ts +26 -79
- package/dist/api/dto/node-outcomes.d.ts +1 -3
- package/dist/api/dto/nodes.d.ts +5 -26
- package/dist/api/dto/objects.d.ts +168 -0
- package/dist/api/dto/objects.js +1 -0
- package/dist/api/dto/profiles.d.ts +14 -8
- package/dist/api/dto/reports.d.ts +9 -7
- package/dist/api/dto/reviews.d.ts +11 -3
- package/dist/api/dto/worktree.d.ts +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes.d.ts +14 -12
- package/dist/api/routes.js +1 -1
- package/dist/build-root.js +1 -1
- package/dist/builtin-memory/00-runtime-base/00-authoring.md +10 -5
- package/dist/builtin-memory/02-turn-lifecycle/02-resident.md +1 -0
- package/dist/builtin-memory/04-orchestration-kernel.md +10 -31
- package/dist/builtin-memory/05-kinds/advisor/01-orchestrator.md +1 -1
- package/dist/builtin-memory/05-kinds/explore/00-base.md +2 -2
- package/dist/builtin-memory/05-kinds/explore/01-orchestrator.md +2 -2
- package/dist/builtin-memory/crouter-concepts/INDEX.md +2 -2
- package/dist/builtin-memory/crouter-concepts/lifecycle-and-wakes.md +1 -1
- package/dist/builtin-memory/crouter-concepts/memory.md +15 -15
- package/dist/builtin-memory/crouter-concepts/nodes-and-the-canvas.md +1 -1
- package/dist/builtin-memory/crouter-concepts/profiles-kinds-and-modes.md +5 -5
- package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +1 -1
- package/dist/builtin-memory/crouter-concepts/why-a-daemon.md +1 -1
- package/dist/builtin-memory/crouter-sdk/INDEX.md +2 -2
- package/dist/builtin-memory/crouter-sdk/README.md +5 -6
- package/dist/builtin-memory/crouter-sdk/errors.md +0 -13
- package/dist/builtin-memory/crouter-sdk/guides/README.md +0 -1
- package/dist/builtin-memory/crouter-sdk/guides/event-driven-assistant.md +2 -2
- package/dist/builtin-memory/crouter-sdk/nodes.md +0 -2
- package/dist/builtin-memory/crouter-sdk/resources.md +0 -1
- package/dist/builtin-memory/explore/exploration-doc.md +4 -4
- package/dist/builtin-memory/insights/capture.md +6 -6
- package/dist/builtin-memory/insights/init.md +14 -14
- package/dist/builtin-memory/internal/INDEX.md +4 -4
- package/dist/builtin-memory/internal/agent-shaping.md +20 -20
- package/dist/builtin-memory/internal/examples/imessage-assistant.md +2 -2
- package/dist/builtin-memory/internal/marketplaces.md +2 -2
- package/dist/builtin-memory/internal/memory-loading.md +31 -30
- package/dist/builtin-memory/internal/nodes-and-canvas.md +1 -1
- package/dist/builtin-memory/internal/plugins.md +16 -14
- package/dist/builtin-memory/internal/storage-tiers.md +4 -4
- package/dist/builtin-memory/memory-read-orientation.md +1 -1
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +32 -40
- package/dist/clients/attach/input/controller.js +1 -1
- package/dist/clients/attach/input/ref-autocomplete.js +1 -1
- package/dist/clients/attach/input/titled-editor.js +1 -1
- package/dist/clients/attach/overlays/file-review.d.ts +1 -0
- package/dist/clients/attach/overlays/file-review.js +2 -2
- package/dist/clients/attach/render/chat-view.d.ts +6 -0
- package/dist/clients/attach/render/chat-view.js +2 -2
- package/dist/clients/attach/render/crtr-output.d.ts +1 -2
- package/dist/clients/attach/render/crtr-output.js +17 -17
- package/dist/clients/attach/render/doc-links.d.ts +34 -0
- package/dist/clients/attach/render/doc-links.js +1 -0
- package/dist/clients/attach/render/group-activity.d.ts +8 -8
- package/dist/clients/attach/render/group-activity.js +2 -2
- package/dist/clients/attach/render/group-recap.js +1 -1
- package/dist/clients/attach/render/markdown-source.js +5 -5
- package/dist/clients/attach/render/tool-calls.d.ts +1 -1
- package/dist/clients/attach/session/doc-materialize.d.ts +53 -0
- package/dist/clients/attach/session/doc-materialize.js +3 -0
- package/dist/clients/attach/session/document-links.d.ts +21 -0
- package/dist/clients/attach/session/document-links.js +1 -0
- package/dist/clients/attach/session/file-links.d.ts +2 -0
- package/dist/clients/attach/session/file-links.js +1 -1
- package/dist/clients/attach/session/profile-files.js +1 -1
- package/dist/clients/attach/slash/dispatch.js +1 -1
- package/dist/clients/attach/viewer.js +816 -1561
- package/dist/clients/inbox/review/review-client.d.ts +5 -1
- package/dist/clients/inbox/review/review-client.js +1 -1
- package/dist/commands/api-client.d.ts +2 -0
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/canvas/edges.d.ts +2 -0
- package/dist/commands/canvas/edges.js +2 -0
- package/dist/commands/canvas/list.d.ts +4 -0
- package/dist/commands/canvas/list.js +3 -0
- package/dist/commands/canvas/read.d.ts +8 -0
- package/dist/commands/canvas/read.js +5 -0
- package/dist/commands/canvas/search.d.ts +2 -0
- package/dist/commands/canvas/search.js +3 -0
- package/dist/commands/canvas/unwatch.d.ts +2 -0
- package/dist/commands/canvas/unwatch.js +1 -0
- package/dist/commands/canvas/watch.d.ts +3 -0
- package/dist/commands/canvas/watch.js +1 -0
- package/dist/commands/canvas-analytics.js +1 -1
- package/dist/commands/canvas-history/grep.js +4 -4
- package/dist/commands/canvas-history/read.js +2 -2
- package/dist/commands/canvas-history/search.js +7 -7
- package/dist/commands/canvas-history/shared.d.ts +0 -1
- package/dist/commands/canvas-history/shared.js +1 -1
- package/dist/commands/canvas-history/stats.js +2 -2
- package/dist/commands/canvas-history.js +1 -1
- package/dist/commands/canvas.js +1 -1
- package/dist/commands/doc/delete.d.ts +2 -0
- package/dist/commands/doc/delete.js +1 -0
- package/dist/commands/doc/edit.d.ts +2 -0
- package/dist/commands/doc/edit.js +1 -0
- package/dist/commands/doc/history.d.ts +2 -0
- package/dist/commands/doc/history.js +2 -0
- package/dist/commands/doc/lint.d.ts +2 -0
- package/dist/commands/doc/lint.js +2 -0
- package/dist/commands/doc/list.d.ts +2 -0
- package/dist/commands/doc/list.js +1 -0
- package/dist/commands/doc/move.d.ts +2 -0
- package/dist/commands/doc/move.js +1 -0
- package/dist/commands/doc/read.d.ts +2 -0
- package/dist/commands/doc/read.js +1 -0
- package/dist/commands/doc/shared.d.ts +25 -0
- package/dist/commands/doc/shared.js +2 -0
- package/dist/commands/doc/write.d.ts +2 -0
- package/dist/commands/doc/write.js +1 -0
- package/dist/commands/{memory.d.ts → doc.d.ts} +1 -1
- package/dist/commands/doc.js +1 -0
- package/dist/commands/human/review.js +1 -1
- package/dist/commands/node/bash.js +2 -2
- package/dist/commands/node/create.js +1 -1
- package/dist/commands/node/inspect.js +10 -10
- package/dist/commands/node/lifecycle.js +2 -2
- package/dist/commands/node/outcome.js +1 -1
- package/dist/commands/node/subscription.js +1 -1
- package/dist/commands/node-context.js +2 -2
- package/dist/commands/pkg/browse/catalog.js +1 -1
- package/dist/commands/pkg/browse/doc-view.js +1 -1
- package/dist/commands/pkg/browse/model.d.ts +9 -17
- package/dist/commands/pkg/plugin-inspect.js +1 -1
- package/dist/commands/pkg/plugin-manage.d.ts +4 -8
- package/dist/commands/pkg/plugin-manage.js +15 -17
- package/dist/commands/profile/list.js +1 -1
- package/dist/commands/profile/new.js +1 -1
- package/dist/commands/profile/project.js +1 -1
- package/dist/commands/profile/show.js +1 -1
- package/dist/commands/push.js +3 -3
- package/dist/commands/sys/config.js +1 -1
- package/dist/commands/sys/context/admin/actions.d.ts +18 -43
- package/dist/commands/sys/context/admin/actions.js +1 -2
- package/dist/commands/sys/context/admin/detail-panel.d.ts +17 -25
- package/dist/commands/sys/context/admin/detail-panel.js +2 -1
- package/dist/commands/sys/context/admin/docs-panel.d.ts +7 -6
- package/dist/commands/sys/context/admin/docs-panel.js +1 -1
- package/dist/commands/sys/context/admin/list-view.d.ts +12 -12
- package/dist/commands/sys/context/admin/list-view.js +1 -1
- package/dist/commands/sys/context/admin/model.d.ts +96 -69
- package/dist/commands/sys/context/admin/model.js +1 -1
- package/dist/commands/sys/context/admin/rail-panel.d.ts +7 -5
- package/dist/commands/sys/context/admin/rail-panel.js +1 -1
- package/dist/commands/sys/context/admin/read-view.d.ts +10 -14
- package/dist/commands/sys/context/admin/read-view.js +1 -2
- package/dist/commands/sys/context/admin/shell.d.ts +26 -31
- package/dist/commands/sys/context/admin/shell.js +1 -1
- package/dist/commands/sys/context/admin.js +2 -2
- package/dist/commands/sys/context/doc.js +2 -3
- package/dist/commands/sys/context/expose.js +2 -2
- package/dist/commands/sys/context/prompt-review.js +4 -4
- package/dist/commands/sys/context/resolve.d.ts +92 -65
- package/dist/commands/sys/context/resolve.js +7 -9
- package/dist/commands/sys/context.js +1 -1
- package/dist/commands/sys/doctor.js +1 -1
- package/dist/commands/sys/migrate.js +1 -1
- package/dist/commands/sys/panels/profiles-panel.d.ts +3 -1
- package/dist/commands/sys/panels/profiles-panel.js +1 -1
- package/dist/commands/sys/sync-deps.d.ts +6 -11
- package/dist/commands/sys/sync-deps.js +7 -8
- package/dist/commands/sys/sync-project-guidance.js +5 -4
- package/dist/commands/sys/sync-shared.d.ts +41 -4
- package/dist/commands/sys/sync-shared.js +1 -1
- package/dist/commands/sys/sync-skills.js +2 -2
- package/dist/commands/sys/sync.js +1 -1
- package/dist/core/bash-job-supervisor.d.ts +2 -3
- package/dist/core/bash-job-supervisor.js +3 -3
- package/dist/core/bash-jobs.d.ts +0 -5
- package/dist/core/bash-jobs.js +7 -7
- package/dist/core/bootstrap.js +2 -2
- package/dist/core/canvas/canvas.d.ts +6 -50
- package/dist/core/canvas/canvas.js +16 -21
- package/dist/core/canvas/db.d.ts +4 -1
- package/dist/core/canvas/db.js +2 -2
- package/dist/core/canvas/history.d.ts +11 -39
- package/dist/core/canvas/history.js +9 -20
- package/dist/core/canvas/install-id.d.ts +2 -2
- package/dist/core/canvas/install-id.js +1 -1
- package/dist/core/canvas/memory-reads.d.ts +5 -0
- package/dist/core/canvas/memory-reads.js +1 -1
- package/dist/core/canvas/migrations.js +215 -41
- package/dist/core/canvas/node-agent-paths.js +1 -1
- package/dist/core/canvas/node-tokens.js +1 -1
- package/dist/core/canvas/paths.d.ts +0 -4
- package/dist/core/canvas/paths.js +1 -1
- package/dist/core/canvas/remote-canvas-source.d.ts +0 -1
- package/dist/core/canvas/remote-canvas-source.js +1 -1
- package/dist/core/canvas/render-source.d.ts +9 -6
- package/dist/core/canvas/render-source.js +6 -6
- package/dist/core/canvas/sessions.js +2 -2
- package/dist/core/canvas/source.d.ts +6 -0
- package/dist/core/canvas/tree.d.ts +29 -0
- package/dist/core/canvas/tree.js +12 -0
- package/dist/core/canvas/types.d.ts +0 -20
- package/dist/core/command-plugins/bundle.js +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/conversation-store/listener.js +4 -2
- package/dist/core/feed/feed.d.ts +9 -7
- package/dist/core/feed/feed.js +3 -7
- package/dist/core/feed/inbox.d.ts +3 -5
- package/dist/core/feed/inbox.js +1 -10
- package/dist/core/feed/messages.d.ts +33 -6
- package/dist/core/feed/messages.js +10 -7
- package/dist/core/feed/reports.d.ts +10 -0
- package/dist/core/feed/reports.js +2 -0
- package/dist/core/grants/remove.js +1 -1
- package/dist/core/graph/access.d.ts +24 -0
- package/dist/core/graph/access.js +8 -0
- package/dist/core/graph/bodies.d.ts +6 -0
- package/dist/core/graph/bodies.js +1 -0
- package/dist/core/graph/deletion.d.ts +10 -0
- package/dist/core/graph/deletion.js +5 -0
- package/dist/core/graph/diff.d.ts +4 -0
- package/dist/core/graph/diff.js +4 -0
- package/dist/core/graph/documents.d.ts +167 -0
- package/dist/core/graph/documents.js +10 -0
- package/dist/core/graph/edges.d.ts +25 -0
- package/dist/core/graph/edges.js +1 -0
- package/dist/core/graph/events.d.ts +26 -0
- package/dist/core/graph/events.js +7 -0
- package/dist/core/graph/exposures.d.ts +53 -0
- package/dist/core/graph/exposures.js +4 -0
- package/dist/core/graph/jobs.d.ts +31 -0
- package/dist/core/graph/jobs.js +2 -0
- package/dist/core/graph/names.d.ts +30 -0
- package/dist/core/graph/names.js +3 -0
- package/dist/core/graph/objects.d.ts +55 -0
- package/dist/core/graph/objects.js +9 -0
- package/dist/core/graph/package-docs.d.ts +31 -0
- package/dist/core/graph/package-docs.js +5 -0
- package/dist/core/graph/package-files.d.ts +20 -0
- package/dist/core/graph/package-files.js +2 -0
- package/dist/core/graph/reader.d.ts +21 -0
- package/dist/core/graph/reader.js +3 -0
- package/dist/core/graph/repo-sync/exchange.d.ts +34 -0
- package/dist/core/graph/repo-sync/exchange.js +2 -0
- package/dist/core/graph/repo-sync/identity.d.ts +30 -0
- package/dist/core/graph/repo-sync/identity.js +1 -0
- package/dist/core/graph/repo-sync/index.d.ts +4 -0
- package/dist/core/graph/repo-sync/index.js +1 -0
- package/dist/core/graph/repo-sync/mirror.d.ts +30 -0
- package/dist/core/graph/repo-sync/mirror.js +6 -0
- package/dist/core/graph/repo-sync/ref-format.d.ts +76 -0
- package/dist/core/graph/repo-sync/ref-format.js +2 -0
- package/dist/core/graph/repo-sync/repos.d.ts +17 -0
- package/dist/core/graph/repo-sync/repos.js +3 -0
- package/dist/core/graph/repo-sync/sync.d.ts +42 -0
- package/dist/core/graph/repo-sync/sync.js +2 -0
- package/dist/core/graph/rules.d.ts +26 -0
- package/dist/core/graph/rules.js +3 -0
- package/dist/core/graph/spaces/app.d.ts +3 -0
- package/dist/core/graph/spaces/app.js +1 -0
- package/dist/core/graph/spaces/index.d.ts +19 -0
- package/dist/core/graph/spaces/index.js +1 -0
- package/dist/core/graph/spaces/person.d.ts +5 -0
- package/dist/core/graph/spaces/person.js +2 -0
- package/dist/core/graph/spaces/repo.d.ts +4 -0
- package/dist/core/graph/spaces/repo.js +1 -0
- package/dist/core/graph/types.d.ts +75 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/graph/watches.d.ts +62 -0
- package/dist/core/graph/watches.js +18 -0
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/requests.d.ts +3 -1
- package/dist/core/human/requests.js +6 -6
- package/dist/core/inspector/model.js +2 -2
- package/dist/core/io.js +5 -5
- package/dist/core/layout-migrate/index.d.ts +24 -1
- package/dist/core/layout-migrate/index.js +4 -4
- package/dist/core/layout-migrate/paths.d.ts +4 -0
- package/dist/core/layout-migrate/paths.js +1 -1
- package/dist/core/layout-migrate/stored-paths.d.ts +7 -0
- package/dist/core/layout-migrate/stored-paths.js +11 -11
- package/dist/core/layout-migrate/stores.d.ts +19 -6
- package/dist/core/layout-migrate/stores.js +3 -4
- package/dist/core/manifest.d.ts +0 -2
- package/dist/core/manifest.js +1 -1
- package/dist/core/{memory/extensions.d.ts → plugin-extensions.d.ts} +9 -10
- package/dist/core/plugin-extensions.js +1 -0
- package/dist/core/preview-registry.d.ts +1 -1
- package/dist/core/preview-registry.js +3 -2
- package/dist/core/profiles/manifest.d.ts +7 -7
- package/dist/core/profiles/manifest.js +1 -1
- package/dist/core/profiles/select.js +3 -3
- package/dist/core/review/birth.js +1 -1
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/stage.d.ts +12 -1
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/store.d.ts +2 -0
- package/dist/core/review/store.js +1 -1
- package/dist/core/review/types.d.ts +7 -1
- package/dist/core/runs/events.js +1 -1
- package/dist/core/runs/operations.js +5 -5
- package/dist/core/runs/questions.js +2 -2
- package/dist/core/runtime/bearings-render.d.ts +13 -7
- package/dist/core/runtime/bearings-render.js +12 -12
- package/dist/core/runtime/bearings.d.ts +8 -18
- package/dist/core/runtime/bearings.js +7 -7
- package/dist/core/runtime/broker/daemon-ops.d.ts +7 -12
- package/dist/core/runtime/broker/daemon-ops.js +1 -1
- package/dist/core/runtime/broker/fault-retry.d.ts +2 -0
- package/dist/core/runtime/broker/fault-retry.js +1 -1
- package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
- package/dist/core/runtime/broker/frame-memory-refs.d.ts +7 -2
- package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
- package/dist/core/runtime/broker/inbox.d.ts +1 -4
- package/dist/core/runtime/broker/inbox.js +1 -10
- package/dist/core/runtime/broker/rebind.js +1 -1
- package/dist/core/runtime/broker/retry-card-elision.d.ts +7 -0
- package/dist/core/runtime/broker/retry-card-elision.js +1 -0
- package/dist/core/runtime/broker-extension-render.d.ts +0 -13
- package/dist/core/runtime/broker-extension-render.js +2 -4
- package/dist/core/runtime/broker-persona-guidance.js +3 -3
- package/dist/core/runtime/broker-protocol.d.ts +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/close.d.ts +9 -4
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/kickoff.js +17 -19
- package/dist/core/runtime/launch-target.d.ts +7 -0
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/ledger.d.ts +10 -0
- package/dist/core/runtime/ledger.js +3 -0
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/nodes.d.ts +10 -2
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/outcome-document.d.ts +2 -2
- package/dist/core/runtime/outcome-document.js +1 -1
- package/dist/core/runtime/persona.js +2 -2
- package/dist/core/runtime/placement.js +1 -1
- package/dist/core/runtime/promote.d.ts +2 -2
- package/dist/core/runtime/promote.js +1 -1
- package/dist/core/runtime/prospective-inventory-cli.js +2 -2
- package/dist/core/runtime/recycle.js +1 -1
- package/dist/core/runtime/reopen.js +1 -1
- package/dist/core/runtime/revive.js +2 -2
- package/dist/core/runtime/roadmap.d.ts +20 -9
- package/dist/core/runtime/roadmap.js +10 -6
- package/dist/core/runtime/spawn-env.js +1 -1
- package/dist/core/runtime/spawn.d.ts +5 -3
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/runtime/structured-output.d.ts +3 -1
- package/dist/core/runtime/structured-output.js +4 -4
- package/dist/core/scope.d.ts +1 -32
- package/dist/core/scope.js +1 -1
- package/dist/core/scoped-state/db.js +2 -1
- package/dist/core/scoped-state/migrate.js +2 -2
- package/dist/core/scoped-state/profiles.d.ts +11 -0
- package/dist/core/scoped-state/profiles.js +1 -1
- package/dist/core/scoped-state/schema.d.ts +1 -1
- package/dist/core/scoped-state/schema.js +7 -5
- package/dist/core/spaces/permissions.d.ts +0 -14
- package/dist/core/spaces/permissions.js +1 -1
- package/dist/core/spaces/stop.d.ts +13 -0
- package/dist/core/spaces/stop.js +2 -2
- package/dist/core/storage/tables.d.ts +1 -1
- package/dist/core/substrate/delivery/corpus.d.ts +21 -0
- package/dist/core/substrate/delivery/corpus.js +3 -0
- package/dist/core/substrate/delivery/deliver.d.ts +76 -0
- package/dist/core/substrate/delivery/deliver.js +6 -0
- package/dist/core/substrate/delivery/listings.d.ts +30 -0
- package/dist/core/substrate/delivery/listings.js +7 -0
- package/dist/core/substrate/delivery/match.d.ts +28 -0
- package/dist/core/substrate/delivery/match.js +1 -0
- package/dist/core/substrate/delivery/plan.d.ts +67 -0
- package/dist/core/substrate/delivery/plan.js +3 -0
- package/dist/core/substrate/delivery/render-boot.d.ts +20 -0
- package/dist/core/substrate/delivery/render-boot.js +54 -0
- package/dist/core/substrate/delivery/render-event.d.ts +54 -0
- package/dist/core/substrate/delivery/render-event.js +8 -0
- package/dist/core/substrate/delivery/sub-persona-menu.d.ts +2 -0
- package/dist/core/substrate/delivery/sub-persona-menu.js +6 -0
- package/dist/core/substrate/delivery/types.d.ts +30 -0
- package/dist/core/substrate/delivery/types.js +0 -0
- package/dist/core/substrate/gate-explain.d.ts +0 -13
- package/dist/core/substrate/gate-explain.js +1 -1
- package/dist/core/substrate/schema.d.ts +11 -139
- package/dist/core/substrate/schema.js +1 -1
- package/dist/core/substrate/subject-fields.d.ts +3 -0
- package/dist/core/substrate/subject.d.ts +2 -1
- package/dist/core/substrate/subject.js +1 -1
- package/dist/daemon/api/handlers/app-profiles.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +1 -2
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/canvas.js +5 -5
- package/dist/daemon/api/handlers/daemon.js +1 -1
- package/dist/daemon/api/handlers/delivery.d.ts +2 -0
- package/dist/daemon/api/handlers/delivery.js +1 -0
- package/dist/daemon/api/handlers/{memory.d.ts → docs.d.ts} +1 -1
- package/dist/daemon/api/handlers/docs.js +1 -0
- package/dist/daemon/api/handlers/hook-exec.js +1 -1
- package/dist/daemon/api/handlers/messages.js +2 -2
- package/dist/daemon/api/handlers/node-records.js +2 -2
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/objects.d.ts +2 -0
- package/dist/daemon/api/handlers/objects.js +5 -0
- package/dist/daemon/api/handlers/package-docs.d.ts +2 -0
- package/dist/daemon/api/handlers/package-docs.js +1 -0
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/reports.d.ts +2 -2
- package/dist/daemon/api/handlers/reports.js +4 -4
- package/dist/daemon/api/handlers/reviews.d.ts +4 -1
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/map.d.ts +2 -2
- package/dist/daemon/api/map.js +2 -2
- package/dist/daemon/api/operations.d.ts +1 -1
- package/dist/daemon/api/operations.js +1 -1
- package/dist/daemon/api/reader.d.ts +17 -0
- package/dist/daemon/api/reader.js +1 -0
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/control.d.ts +2 -3
- package/dist/daemon/crtrd.js +8 -6
- package/dist/daemon/fleet.js +4 -4
- package/dist/daemon/reconcilers/bash-deadline.d.ts +11 -1
- package/dist/daemon/reconcilers/bash-deadline.js +2 -1
- package/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/dist/daemon/reconcilers/live-obligation.js +1 -1
- package/dist/daemon/reconcilers/node-deadline.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -0
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
- package/dist/daemon/review/deliver.js +2 -2
- package/dist/daemon/review/finish.js +1 -1
- package/dist/hook-authoring.d.ts +0 -1
- package/dist/hook-authoring.js +3 -3
- package/dist/migrations/004-canvas-documents/apply.d.ts +10 -0
- package/dist/migrations/004-canvas-documents/apply.js +1 -0
- package/dist/migrations/004-canvas-documents/fields.d.ts +24 -0
- package/dist/migrations/004-canvas-documents/fields.js +2 -0
- package/dist/migrations/004-canvas-documents/index.d.ts +16 -0
- package/dist/migrations/004-canvas-documents/index.js +2 -0
- package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +16 -0
- package/dist/migrations/004-canvas-documents/legacy/discover.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/history.d.ts +5 -0
- package/dist/migrations/004-canvas-documents/legacy/history.js +2 -0
- package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +7 -0
- package/dist/migrations/004-canvas-documents/legacy/nested.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +14 -0
- package/dist/migrations/004-canvas-documents/legacy/parse.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/types.d.ts +91 -0
- package/dist/migrations/004-canvas-documents/legacy/types.js +0 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.d.ts +6 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.js +18 -0
- package/dist/migrations/004-canvas-documents/plan.d.ts +102 -0
- package/dist/migrations/004-canvas-documents/plan.js +3 -0
- package/dist/migrations/004-canvas-documents/pointers.d.ts +23 -0
- package/dist/migrations/004-canvas-documents/pointers.js +4 -0
- package/dist/migrations/activation.d.ts +9 -18
- package/dist/migrations/activation.js +2 -2
- package/dist/pi-extensions/broker-local.d.ts +2 -2
- package/dist/pi-extensions/broker-local.js +2 -2
- package/dist/pi-extensions/canvas-bash-valve.js +5 -4
- package/dist/pi-extensions/canvas-context-intro.js +2 -2
- package/dist/pi-extensions/canvas-doc-substrate.d.ts +0 -1
- package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
- package/dist/pi-extensions/canvas-passive-context.js +1 -1
- package/dist/pi-extensions/canvas-recap.js +2 -2
- package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
- package/dist/pi-extensions/canvas-stophook.js +1 -1
- package/dist/prompts/review.js +3 -3
- package/dist/shared/env.d.ts +5 -0
- package/dist/shared/env.js +1 -1
- package/dist/shared/generated-context.js +2 -10
- package/dist/shared/inbox-entry-body.d.ts +22 -0
- package/dist/shared/inbox-entry-body.js +10 -0
- package/dist/{core/memory → shared}/inline-ref-guidance.d.ts +2 -2
- package/dist/shared/inline-ref-guidance.js +2 -0
- package/dist/types.d.ts +3 -1
- package/docs/cli/memory-and-preferences.md +12 -14
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/lifecycle-and-wakes.md +1 -1
- package/docs/concepts/memory.md +15 -15
- package/docs/concepts/nodes-and-the-canvas.md +1 -1
- package/docs/concepts/profiles-kinds-and-modes.md +5 -5
- package/docs/concepts/scopes-and-trust.md +1 -1
- package/docs/concepts/why-a-daemon.md +1 -1
- package/docs/sdk/README.md +5 -6
- package/docs/sdk/errors.md +0 -13
- package/docs/sdk/guides/README.md +0 -1
- package/docs/sdk/nodes.md +0 -2
- package/docs/sdk/resources.md +0 -1
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +11 -11
- package/scripts/lib/isolation-env.mjs +8 -2
- package/dist/api/dto/memory.d.ts +0 -171
- package/dist/api/dto/memory.js +0 -1
- package/dist/builtin-memory/crouter-sdk/guides/app-memory.md +0 -73
- package/dist/builtin-memory/crouter-sdk/memory.md +0 -87
- package/dist/commands/broker-permissions.d.ts +0 -2
- package/dist/commands/broker-permissions.js +0 -1
- package/dist/commands/memory/client.d.ts +0 -11
- package/dist/commands/memory/client.js +0 -1
- package/dist/commands/memory/delete.d.ts +0 -1
- package/dist/commands/memory/delete.js +0 -1
- package/dist/commands/memory/edit.d.ts +0 -1
- package/dist/commands/memory/edit.js +0 -21
- package/dist/commands/memory/find.d.ts +0 -1
- package/dist/commands/memory/find.js +0 -1
- package/dist/commands/memory/history.d.ts +0 -1
- package/dist/commands/memory/history.js +0 -5
- package/dist/commands/memory/lint.d.ts +0 -1
- package/dist/commands/memory/lint.js +0 -1
- package/dist/commands/memory/list.d.ts +0 -1
- package/dist/commands/memory/list.js +0 -1
- package/dist/commands/memory/move.d.ts +0 -1
- package/dist/commands/memory/move.js +0 -1
- package/dist/commands/memory/origin.d.ts +0 -1
- package/dist/commands/memory/origin.js +0 -1
- package/dist/commands/memory/read.d.ts +0 -1
- package/dist/commands/memory/read.js +0 -6
- package/dist/commands/memory/shared.d.ts +0 -22
- package/dist/commands/memory/shared.js +0 -1
- package/dist/commands/memory/write.d.ts +0 -1
- package/dist/commands/memory/write.js +0 -13
- package/dist/commands/memory.js +0 -1
- package/dist/commands/node-inspect-artifacts.d.ts +0 -1
- package/dist/commands/node-inspect-artifacts.js +0 -8
- package/dist/core/help/memory-extensions.d.ts +0 -3
- package/dist/core/help/memory-extensions.js +0 -2
- package/dist/core/memory/cli-selector.d.ts +0 -13
- package/dist/core/memory/cli-selector.js +0 -1
- package/dist/core/memory/doc-link-grammar.d.ts +0 -20
- package/dist/core/memory/doc-link-grammar.js +0 -2
- package/dist/core/memory/extensions.js +0 -1
- package/dist/core/memory/history.d.ts +0 -87
- package/dist/core/memory/history.js +0 -6
- package/dist/core/memory/identity.d.ts +0 -65
- package/dist/core/memory/identity.js +0 -1
- package/dist/core/memory/inline-ref-guidance.js +0 -2
- package/dist/core/memory/inline-ref-inventory.d.ts +0 -9
- package/dist/core/memory/inline-ref-inventory.js +0 -1
- package/dist/core/memory/lint.d.ts +0 -163
- package/dist/core/memory/lint.js +0 -2
- package/dist/core/memory/mutation-domain.d.ts +0 -113
- package/dist/core/memory/mutation-domain.js +0 -12
- package/dist/core/memory/mutations.d.ts +0 -74
- package/dist/core/memory/mutations.js +0 -1
- package/dist/core/memory/project-namespace.d.ts +0 -31
- package/dist/core/memory/project-namespace.js +0 -2
- package/dist/core/memory/repository-association.d.ts +0 -31
- package/dist/core/memory/repository-association.js +0 -1
- package/dist/core/memory/service.d.ts +0 -145
- package/dist/core/memory/service.js +0 -2
- package/dist/core/memory/tree.d.ts +0 -39
- package/dist/core/memory/tree.js +0 -1
- package/dist/core/memory-resolver.d.ts +0 -280
- package/dist/core/memory-resolver.js +0 -2
- package/dist/core/nested-stores.d.ts +0 -18
- package/dist/core/nested-stores.js +0 -1
- package/dist/core/runtime/memory.d.ts +0 -3
- package/dist/core/runtime/memory.js +0 -1
- package/dist/core/substrate/frontmatter-validation.d.ts +0 -11
- package/dist/core/substrate/frontmatter-validation.js +0 -1
- package/dist/core/substrate/gate.d.ts +0 -16
- package/dist/core/substrate/gate.js +0 -1
- package/dist/core/substrate/index.d.ts +0 -18
- package/dist/core/substrate/index.js +0 -1
- package/dist/core/substrate/injected-store.d.ts +0 -75
- package/dist/core/substrate/injected-store.js +0 -2
- package/dist/core/substrate/listings.d.ts +0 -28
- package/dist/core/substrate/listings.js +0 -1
- package/dist/core/substrate/memory-events.d.ts +0 -6
- package/dist/core/substrate/memory-events.js +0 -1
- package/dist/core/substrate/on-read-node.d.ts +0 -6
- package/dist/core/substrate/on-read-node.js +0 -1
- package/dist/core/substrate/on-read.d.ts +0 -101
- package/dist/core/substrate/on-read.js +0 -9
- package/dist/core/substrate/plan.d.ts +0 -94
- package/dist/core/substrate/plan.js +0 -1
- package/dist/core/substrate/render-node.d.ts +0 -12
- package/dist/core/substrate/render-node.js +0 -1
- package/dist/core/substrate/render.d.ts +0 -41
- package/dist/core/substrate/render.js +0 -65
- package/dist/core/substrate/session-cache.d.ts +0 -27
- package/dist/core/substrate/session-cache.js +0 -1
- package/dist/core/substrate/surface-match.d.ts +0 -73
- package/dist/core/substrate/surface-match.js +0 -1
- package/dist/daemon/api/handlers/memory.js +0 -5
- package/dist/migrations/001-surfaces-frontmatter.d.ts +0 -2
- package/dist/migrations/001-surfaces-frontmatter.js +0 -1
- package/dist/migrations/002-profile-project-memory.d.ts +0 -2
- package/dist/migrations/002-profile-project-memory.js +0 -1
- package/dist/migrations/003-repository-root-memory-identity/front-door.d.ts +0 -26
- package/dist/migrations/003-repository-root-memory-identity/front-door.js +0 -11
- package/dist/migrations/003-repository-root-memory-identity/index.d.ts +0 -2
- package/dist/migrations/003-repository-root-memory-identity/index.js +0 -5
- package/dist/migrations/003-repository-root-memory-identity/references.d.ts +0 -95
- package/dist/migrations/003-repository-root-memory-identity/references.js +0 -5
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.d.ts +0 -39
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.js +0 -3
- package/dist/migrations/convergent.d.ts +0 -43
- package/dist/migrations/convergent.js +0 -2
- package/dist/migrations/corpus.d.ts +0 -75
- package/dist/migrations/corpus.js +0 -3
- package/dist/migrations/frontmatter-splice.d.ts +0 -15
- package/dist/migrations/frontmatter-splice.js +0 -8
- package/dist/migrations/profile-manifests.d.ts +0 -30
- package/dist/migrations/profile-manifests.js +0 -2
- package/dist/migrations/registry.d.ts +0 -7
- package/dist/migrations/registry.js +0 -1
- package/dist/migrations/runner.d.ts +0 -43
- package/dist/migrations/runner.js +0 -1
- package/dist/migrations/types.d.ts +0 -211
- package/dist/shared/birth-announcement.d.ts +0 -12
- package/dist/shared/birth-announcement.js +0 -1
- package/docs/sdk/guides/app-memory.md +0 -22
- package/docs/sdk/memory.md +0 -85
- /package/dist/{migrations/types.js → api/dto/delivery.js} +0 -0
- /package/dist/{core/memory → shared}/inline-ref-grammar.d.ts +0 -0
- /package/dist/{core/memory → shared}/inline-ref-grammar.js +0 -0
package/dist/core/bash-jobs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}
|
|
3
|
-
`)}
|
|
4
|
-
`)}catch(f){if(f.code==="EEXIST")return{kind:"retired",logPath:i.jobLog};throw f}try{let f;if(d===`launcher:${
|
|
5
|
-
`)}catch(b){if(b.code!=="EEXIST")throw b}return{kind:"stopped",signaled:f,pgid:
|
|
1
|
+
var k=Object.defineProperty;var r=(t,e)=>k(t,"name",{value:e,configurable:!0});import{randomBytes as w}from"node:crypto";import{closeSync as N,openSync as L,readSync as $,statSync as R}from"node:fs";import{dirname as g,join as a}from"node:path";import{captureTeardownSnapshot as T,isAnyPidAlive as I,isPidAlive as _,killProcessTreePids as j}from"./canvas/pid.js";import{launcherRequest as F}from"../launcher/client.js";import{LaunchRefused as O}from"../launcher/spec.js";import{createFileBeneath as B,existsBeneath as C,readdirBeneath as v,readFileBeneath as z,renameBeneath as X,unlinkBeneath as G,writeFileBeneath as y}from"./spaces/open-beneath.js";const H=280;function q(t){if(typeof t!="string"||/[\p{Cc}\p{Cf}]/u.test(t))return null;const e=t.trim();return e===""?null:Buffer.byteLength(e,"utf8")<=H?e:null}r(q,"normalizeBashJobPurpose");function m(t){return a(t,"jobs")}r(m,"bashJobsDir");function p(t,e){return z(g(t),e).toString("utf8")}r(p,"readJobText");function S(t){return v(g(t),m(t)).map(e=>e.name)}r(S,"jobIds");function c(t,e){return C(t.root,e)}r(c,"has");function x(t,e){try{G(t,e)}catch(n){if(n.code!=="ENOENT")throw n}}r(x,"unlinkIfPresent");function at(t){return typeof t=="string"&&t!==""&&t!=="."&&t!==".."&&/^[A-Za-z0-9._~-]+$/u.test(t)&&Buffer.byteLength(t,"utf8")<=128}r(at,"isSafeBashJobId");function l(t,e){const n=a(m(t),e);return{jobId:e,root:g(t),dir:n,cmdSh:a(n,"cmd.sh"),jobLog:a(n,"job.log"),jobExit:a(n,"job.exit"),jobRun:a(n,"job.run"),jobBg:a(n,"job.bg"),jobDone:a(n,"job.done"),jobPgid:a(n,"job.pgid"),jobPgidIdentity:a(n,"job.pgid-identity"),jobPurpose:a(n,"purpose"),jobDeadline:a(n,"job.deadline")}}r(l,"bashJobPaths");function U(t,e){try{const n=Number(p(t,l(t,e).jobPgid).trim());return Number.isInteger(n)&&n>1?n:void 0}catch{return}}r(U,"readJobPgid");function W(t,e){try{const n=p(t,l(t,e).jobPgidIdentity).trim();return n===""?void 0:n}catch{return}}r(W,"readJobPgidIdentity");function K(t,e){try{return q(p(t,l(t,e).jobPurpose))}catch{return null}}r(K,"readJobPurpose");const P=10,Y=19;function E(t){return a(m(t),"niceness")}r(E,"bashNicenessPath");function ct(t){try{const e=Number(p(t,E(t)).trim());return!Number.isInteger(e)||e<0||e>Y?P:e}catch{return P}}r(ct,"readBashNiceness");function dt(t,e){y(g(t),E(t),`${Math.trunc(e)}
|
|
2
|
+
`)}r(dt,"writeBashNiceness");function Z(t,e){try{const n=Number(p(t,l(t,e).jobDeadline).trim());return Number.isFinite(n)?n:void 0}catch{return}}r(Z,"readJobDeadlineMs");function Q(t,e){y(t.root,t.jobDeadline,`${Math.trunc(e)}
|
|
3
|
+
`)}r(Q,"writeJobDeadlineMs");function ft(t){try{x(t.root,t.jobDeadline)}catch{}}r(ft,"clearJobDeadline");function lt(t,e){if(e===`launcher:${t}`)return _(t);try{return process.kill(-t,0),!0}catch(n){return n.code==="EPERM"}}r(lt,"isBashJobProcessGroupAlive");async function V(t,e){const n=T(t,e);if(n.reused||n.tree.length===0)return!1;const o=[...n.tree].reverse(),u=I(o);return j(o,"SIGTERM",n.identities),await new Promise(i=>setTimeout(i,400)),j(o,"SIGKILL",n.identities),u}r(V,"cancelBashJobProcessTree");async function ht(t,e,n=!1,o,u){const i=l(t,e);if(!c(i,i.dir))return{kind:"missing"};if(!c(i,i.jobBg)&&!(n&&c(i,i.jobRun))||c(i,i.jobExit))return{kind:"retired",logPath:i.jobLog};const s=U(t,e),d=W(t,e);if(s===void 0||d===void 0)return{kind:"not-stoppable",logPath:i.jobLog};const h=a(i.dir,"job.stop");try{B(i.root,h,u===void 0?"":`${u}
|
|
4
|
+
`)}catch(f){if(f.code==="EEXIST")return{kind:"retired",logPath:i.jobLog};throw f}try{let f;if(d===`launcher:${s}`){if(o===void 0)throw new Error("launcher job stop requires its owning node");try{if(!("ok"in await F({operation:"stop",pid:s,nodeId:o})))throw new Error("launcher did not stop job");f=!0}catch(b){if(!(b instanceof O&&b.refusal==="invalid_spec"))throw b;f=!1}}else f=await V(s,d);try{B(i.root,i.jobExit,`143
|
|
5
|
+
`)}catch(b){if(b.code!=="EEXIST")throw b}return{kind:"stopped",signaled:f,pgid:s,logPath:i.jobLog}}catch(f){throw x(i.root,h),f}}r(ht,"stopBackgroundBashJob");function bt(t,e){if(e<=0)return[];const n=64*1024;let o;try{const u=R(t).size,i=Math.max(0,u-n),s=Buffer.alloc(Math.min(u,n));o=L(t,"r"),$(o,s,0,s.length,i);const d=s.toString("utf8"),h=(i>0?d.slice(d.indexOf(`
|
|
6
6
|
`)+1):d).split(`
|
|
7
|
-
`);return h[h.length-1]===""&&h.pop(),h.slice(-e)}catch{return[]}finally{
|
|
8
|
-
`).map(n=>n.trim()).find(n=>n!=="")??"").replace(/\s+/g," ")}
|
|
7
|
+
`);return h[h.length-1]===""&&h.pop(),h.slice(-e)}catch{return[]}finally{o!==void 0&&N(o)}}r(bt,"tailJobLog");function pt(){return`${Date.now()}-${w(4).toString("hex")}`}r(pt,"newBashJobId");function M(t){const e=t.indexOf("-");if(e<=0||e===t.length-1)return;const n=Number(t.slice(0,e));return Number.isFinite(n)?n:void 0}r(M,"jobStartedAtMs");function gt(t){const e=Math.max(0,Math.floor(t/1e3));if(e<60)return`${e}s`;const n=Math.floor(e/60),o=e%60;if(n<60)return`${n}m ${String(o).padStart(2,"0")}s`;const u=Math.floor(n/60),i=n%60;return`${u}h ${String(i).padStart(2,"0")}m`}r(gt,"formatBashElapsed");function mt(t){return(t.split(`
|
|
8
|
+
`).map(n=>n.trim()).find(n=>n!=="")??"").replace(/\s+/g," ")}r(mt,"bashJobCommandLine");function A(t,e=!1){let n;try{n=S(t)}catch{return[]}const o=[];for(const u of n){const i=M(u);if(i===void 0)continue;const s=l(t,u);let d;try{if(!c(s,s.jobBg)&&!(e&&c(s,s.jobRun))||c(s,s.jobExit))continue;d=p(t,s.cmdSh)}catch{continue}o.push({jobId:u,command:d,purpose:K(t,u),startedAtMs:i,logPath:s.jobLog,deadlineAtMs:Z(t,u)??null})}return o.sort((u,i)=>u.startedAtMs-i.startedAtMs)}r(A,"activeBackgroundBashJobs");function jt(t,e){return A(t).filter(n=>n.deadlineAtMs!==null&&e>=n.deadlineAtMs)}r(jt,"expiredAutoBackgroundBashJobs");function Bt(t,e){if(!Number.isFinite(e)||e<=0)return 0;let n=0;for(const o of A(t))if(o.deadlineAtMs!==null)try{Q(l(t,o.jobId),o.deadlineAtMs+e),n+=1}catch{}return n}r(Bt,"shiftAutoBackgroundBashDeadlines");function D(t){try{return X(t.root,t.jobRun,t.jobBg),"backgrounded"}catch(e){if(e.code!=="ENOENT")throw e;return c(t,t.jobBg)?"already-backgrounded":c(t,t.jobDone)?"finished":"missing"}}r(D,"backgroundBashJob");function J(t){let e;try{e=S(t)}catch{return[]}return e.flatMap(n=>{const o=l(t,n);try{return c(o,o.cmdSh)&&c(o,o.jobLog)&&c(o,o.jobRun)?[o]:[]}catch{return[]}})}r(J,"runningBashJobs");function yt(t){let e;for(const n of J(t)){const o=M(n.jobId);o!==void 0&&(e===void 0||o<e)&&(e=o)}return e}r(yt,"oldestRunningBashJobStartedAtMs");function St(t){const e=[];for(const n of J(t))D(n)==="backgrounded"&&e.push(n);return e}r(St,"backgroundRunningBashJobs");export{P as DEFAULT_BASH_NICENESS,Y as MAX_BASH_NICENESS,A as activeBackgroundBashJobs,D as backgroundBashJob,St as backgroundRunningBashJobs,mt as bashJobCommandLine,l as bashJobPaths,m as bashJobsDir,E as bashNicenessPath,V as cancelBashJobProcessTree,ft as clearJobDeadline,jt as expiredAutoBackgroundBashJobs,gt as formatBashElapsed,lt as isBashJobProcessGroupAlive,at as isSafeBashJobId,M as jobStartedAtMs,pt as newBashJobId,q as normalizeBashJobPurpose,yt as oldestRunningBashJobStartedAtMs,ct as readBashNiceness,Z as readJobDeadlineMs,U as readJobPgid,W as readJobPgidIdentity,K as readJobPurpose,Bt as shiftAutoBackgroundBashDeadlines,ht as stopBackgroundBashJob,bt as tailJobLog,dt as writeBashNiceness,Q as writeJobDeadlineMs};
|
package/dist/core/bootstrap.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=Object.defineProperty;var t=(e,r)=>n(e,"name",{value:r,configurable:!0});import{homedir as
|
|
2
|
-
`)}}}t(
|
|
1
|
+
var n=Object.defineProperty;var t=(e,r)=>n(e,"name",{value:r,configurable:!0});import{homedir as s}from"node:os";import{join as c}from"node:path";import{findProjectScopeRoot as p,userScopeRoot as i}from"./scope.js";import{ensureScopeInitialized as u}from"./config.js";import{initializeFreshScopedStore as f}from"./scoped-state/migrate.js";import{CRTR_DIR_NAME as m}from"../types.js";import{envDebug as S}from"../shared/env.js";const d=new Set(["help","--help","-h","--version","-v"]);function h(e){const r=e[2];return r===void 0||r==="sys"&&e[3]==="migrate"?!0:d.has(r)}t(h,"shouldSkipForArgv");function w(e){try{if(process.env.CRTR_NO_AUTO_INIT==="1"||h(e)||(f({kind:"user",root:i()}),p()!==null))return;const r=process.cwd();if(r===s())return;const o=c(r,m);if(o===i())return;u("project",o)}catch(r){if(S()){const o=r instanceof Error?r.message:String(r);process.stderr.write(`crtr: project-init error: ${o}
|
|
2
|
+
`)}}}t(w,"ensureProjectScope");export{w as ensureProjectScope};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
import type { ExitIntent, Lifecycle, Mode, NodeIdentity,
|
|
2
|
+
import type { ExitIntent, Lifecycle, Mode, NodeIdentity, NodeMeta, NodeOutcomeKind, NodeRow, NodeStatus, TerminalReason } from './types.js';
|
|
3
3
|
export interface OutcomeDeliveryBinding {
|
|
4
4
|
actionName: string;
|
|
5
5
|
argv: string[];
|
|
@@ -99,8 +99,6 @@ export declare function recordRespawnAttempt(nodeId: string, attempt: {
|
|
|
99
99
|
}): void;
|
|
100
100
|
export declare function listNodesByProfile(profileId: string): NodeMeta[];
|
|
101
101
|
/** All rows, optionally filtered by status and terminal execution traces. Unclaimed warm spares are excluded. */
|
|
102
|
-
/** Every node's durable memory-resolution coordinates, including unclaimed warm-pool spares. */
|
|
103
|
-
export declare function listNodeMemoryTargets(): NodeMemoryTarget[];
|
|
104
102
|
export declare function updateNodeTelemetry(nodeId: string, telemetry: {
|
|
105
103
|
tokensIn: number;
|
|
106
104
|
contextTokens: number | null;
|
|
@@ -211,19 +209,6 @@ export interface RosterRow {
|
|
|
211
209
|
/** Every node's lean roster row, oldest first — a single scan indexed by
|
|
212
210
|
* `idx_nodes_created`, with no per-row hydration or N+1 query. */
|
|
213
211
|
export declare function rosterNodes(): RosterRow[];
|
|
214
|
-
/** One `subscribes_to` edge, both endpoints — the roster's topology half. */
|
|
215
|
-
export interface RosterEdge {
|
|
216
|
-
from_id: string;
|
|
217
|
-
to_id: string;
|
|
218
|
-
active: boolean;
|
|
219
|
-
created: string;
|
|
220
|
-
}
|
|
221
|
-
/** Every `subscribes_to` edge (passive + multiple preserved, never collapsed) —
|
|
222
|
-
* a single scan indexed by `idx_edges_from`/`idx_edges_to` (composite
|
|
223
|
-
* `(type, from_id|to_id)`, so a bare `type` predicate still uses one of
|
|
224
|
-
* them). Paired with `rosterNodes()` as the roster's exactly-two-query
|
|
225
|
-
* contract. */
|
|
226
|
-
export declare function rosterEdges(): RosterEdge[];
|
|
227
212
|
/** Resumable ROOT conversations pinned to `cwd`, most-recently-created first.
|
|
228
213
|
* A "root" is the top of a spine (`parent IS NULL`) that is a real
|
|
229
214
|
* conversation (not a `kind:'human'` ask) and still resumable (`active`/`idle`,
|
|
@@ -231,32 +216,7 @@ export declare function rosterEdges(): RosterEdge[];
|
|
|
231
216
|
* `crtr -c`/`-r` resume: cwd is the key (the Claude-Code mental model — "my
|
|
232
217
|
* last session HERE"), so it never teleports across projects. */
|
|
233
218
|
export declare function listResumableRoots(cwd: string): NodeRow[];
|
|
234
|
-
|
|
235
|
-
* emit; passive accumulates pointers without a wake. Mutable; callable by anyone. */
|
|
236
|
-
export declare function subscribe(subscriber: string, publisher: string, active?: boolean): void;
|
|
237
|
-
/** Drop a subscription edge. */
|
|
238
|
-
export declare function unsubscribe(subscriber: string, publisher: string): void;
|
|
239
|
-
/** Flip an existing subscription's wake behavior. */
|
|
240
|
-
export declare function setSubscriptionActive(subscriber: string, publisher: string, active: boolean): void;
|
|
241
|
-
/** Record the audit-only `child spawned_by parent` edge. */
|
|
242
|
-
export declare function recordSpawn(child: string, parent: string): void;
|
|
243
|
-
/** Who subscribes to `publisher` — the targets a push fans out to. */
|
|
244
|
-
export declare function subscribersOf(publisher: string): SubscriptionRef[];
|
|
245
|
-
/** Who `subscriber` subscribes to — its reports / the nodes feeding it. */
|
|
246
|
-
export declare function subscriptionsOf(subscriber: string): SubscriptionRef[];
|
|
247
|
-
/** A "view": every node whose output cascades up to `root` via subscriptions —
|
|
248
|
-
* the subscription sub-DAG reachable downward (root → its reports → theirs …).
|
|
249
|
-
* Returns ids excluding root, in BFS order. Cycle-safe. */
|
|
250
|
-
export declare function view(root: string): string[];
|
|
251
|
-
/** Stop-guard primitive: does this node hold an *active* subscription to a node
|
|
252
|
-
* that's still live (active|idle) — i.e. something that can actually wake it?
|
|
253
|
-
* If so, stopping is a legitimate await; if not, it must finish or escalate. */
|
|
254
|
-
export declare function hasActiveLiveSubscription(nodeId: string): boolean;
|
|
255
|
-
/** Whether a LIVE node still subscribes to this one. The mirror of
|
|
256
|
-
* `hasActiveLiveSubscription`: that asks what can still wake this node, this
|
|
257
|
-
* asks what this node still owes — a subscriber that is itself active or idle
|
|
258
|
-
* is waiting on a report this node has not delivered. */
|
|
259
|
-
export declare function hasLiveSubscriber(nodeId: string): boolean;
|
|
219
|
+
export * from './tree.js';
|
|
260
220
|
/** Whether a node explicitly awaits a controller that can still deliver. A
|
|
261
221
|
* parent relationship never implies this wait; the node must declare it. */
|
|
262
222
|
export declare function hasLiveMessageWait(nodeId: string): boolean;
|
|
@@ -346,8 +306,7 @@ export declare function nodeFiles(nodeId: string): NodeFiles;
|
|
|
346
306
|
/** Remove every directory a deleted node owned. A conversation another node
|
|
347
307
|
* still references keeps its file, and so its conversations directory. */
|
|
348
308
|
export declare function removeNodeFiles(files: NodeFiles): void;
|
|
349
|
-
/**
|
|
350
|
-
* GCs its edges) and remove its on-disk `nodes/<id>/` dir. The single-node
|
|
309
|
+
/** Delete ONE node with what it owns ({@link deleteNodeWithOwned}) and remove its on-disk `nodes/<id>/` dir. The single-node
|
|
351
310
|
* analogue of {@link pruneNodes}, for IMMEDIATE reaping — e.g. an empty node the
|
|
352
311
|
* user closed or detached from. An open managed worktree is never deleted: its
|
|
353
312
|
* node retains the ownership needed for `node worktree close`. Pure persisted-state
|
|
@@ -362,9 +321,8 @@ export declare function deleteNodes(nodeIds: readonly string[]): string[];
|
|
|
362
321
|
/** Retention sweep: remove TERMINAL nodes (status dead | done | canceled) whose
|
|
363
322
|
* last activity ({@link lastActivityMs}) is older than `ttlDays`, bounding the
|
|
364
323
|
* otherwise-unbounded growth of node rows + dirs. Only {@link isCollectible}
|
|
365
|
-
* rows qualify, and never one `held` claims.
|
|
366
|
-
*
|
|
367
|
-
* on-disk `nodes/<id>/` dir is removed too.
|
|
324
|
+
* rows qualify, and never one `held` claims. Each node is deleted with what it
|
|
325
|
+
* owns ({@link deleteNodeWithOwned}); the on-disk `nodes/<id>/` dir is removed too.
|
|
368
326
|
*
|
|
369
327
|
* With `includeStale`, ALSO prunes nominally-live (active | idle) nodes past the
|
|
370
328
|
* TTL whose process is provably gone and that nothing will bring back: no live
|
|
@@ -372,8 +330,7 @@ export declare function deleteNodes(nodeIds: readonly string[]): string[];
|
|
|
372
330
|
* not frozen, not in respawn backoff, not an app run, not held, and never the CALLER
|
|
373
331
|
* ($CRTR_NODE_ID). Without the flag, active | idle are NEVER touched.
|
|
374
332
|
*
|
|
375
|
-
*
|
|
376
|
-
* removals follow after COMMIT — the fs isn't transactional, and by then
|
|
333
|
+
* Each node's rows change in its own transaction. Dir removals follow after COMMIT — the fs isn't transactional, and by then
|
|
377
334
|
* the rows are gone, so a re-run never re-finds a half-deleted node. `dryRun`
|
|
378
335
|
* reports the candidate set and deletes NOTHING. */
|
|
379
336
|
export declare function pruneNodes(opts: {
|
|
@@ -402,4 +359,3 @@ export declare function pruneToLimit(opts: {
|
|
|
402
359
|
held: (nodeId: string) => boolean;
|
|
403
360
|
dryRun?: boolean;
|
|
404
361
|
}): PruneResult;
|
|
405
|
-
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
var
|
|
1
|
+
var V=Object.defineProperty;var r=(e,n)=>V(e,"name",{value:n,configurable:!0});import{envNodeId as v}from"../../shared/env.js";import{rmdirSync as K,rmSync as G,statSync as Q}from"node:fs";import{dirname as X,join as k,resolve as Z}from"node:path";import{removeTreeBeneath as j}from"../spaces/open-beneath.js";import{emitEvent as ee}from"../events/emit.js";import{openDb as l,withCanvasWrite as _}from"./db.js";import{conversationStore as ne,ConversationNotFoundError as te}from"../conversation-store/index.js";import{activateArmedExternalActionDelivery as oe,armExternalActionDelivery as re,hasUnseenWakeMail as ie}from"./deliveries.js";import{findNodeBySessionFileSql as se}from"./sessions.js";import{hydrateFault as ae}from"./recovery.js";import{hasUnreconciledWorktree as le,openWorktree as de,readWorktree as ue,worktreeFromRow as ce}from"./worktrees.js";import{isPidAlive as _e,isPidPresent as x,recordedPidLiveness as pe}from"./pid.js";import{ensureHome as fe,jobDir as Ee,nodeDir as me,nodeRunDir as W}from"./paths.js";import{appForNode as Ne,ensureNodeDirs as we,nodeAgentDir as ge}from"./node-agent-paths.js";import{appSpace as b}from"../layout.js";import{createObject as ye,getById as F,ownerForGrantee as H,setObjectKind as Re,setObjectName as Se}from"../graph/objects.js";import{deleteNodeWithOwned as he}from"../graph/deletion.js";function E(e,n){if(e==null)return null;const t=JSON.stringify(e);if(t===void 0)throw new TypeError(`${n} must be JSON-serializable`);return t}r(E,"jsonValue");function P(e,n,t){re(e,{destinationId:t.actionName,adapter:{adapter:"subprocess",argv:t.argv,cwd:t.cwd,config_origin:t.configOrigin,payload:t.payload??null},idempotencyKey:`node-outcome:${n}`})}r(P,"insertArmedOutcomeDelivery");function Je(e,n){if(e.prepare("SELECT deleting_at FROM nodes WHERE node_id = ?").get(n)?.deleting_at)throw new Error("run is deleting")}r(Je,"assertRunNotDeleting");function Oe(e,n){const t=H(n,e.grantee??"app:terminal");ye(n,{id:e.node_id,type:"node",kind:e.kind,owner:t.rowid,privacy:"public",name:e.name,preview:""}),n.prepare(`INSERT INTO nodes (node_id, description, title, icon, cycles, mode, lifecycle, cwd, host_kind, profile_id, parent, spawned_by, creator, fork_from, fork_source_file, created, passive_default, cycle_pending, model_override, persona_ack_json, review_binding_json, launch_config_json, scopes_json, status, intent, waiting_for, final_report, finalized_at, deadline_at, "window", tmux_session, pane, sub, grant_id, client_id, metadata_json, run_id, event_cursor, usage_json, deleting_at) VALUES (${Array(40).fill("?").join(", ")})`).run(e.node_id,e.description??null,e.title??null,e.icon??null,e.cycles??null,e.mode,e.lifecycle,e.cwd,e.host_kind??null,e.profile_id??null,e.parent??null,e.spawned_by??null,e.creator??null,e.fork_from??null,e.fork_source_file??null,e.created,e.passive_default===!0?1:0,e.cycle_pending===!0?1:0,e.model_override??null,E(e.persona_ack,"persona_ack"),E(e.review_binding,"review_binding"),E(e.launch,"launch"),E(e.scopes,"scopes"),e.status??"active",e.intent??null,e.waiting_for??null,e.final_report??null,e.finalized_at??null,e.deadline_at??null,e.window??null,e.tmux_session??null,e.pane??null,e.sub??null,e.grant_id??null,e.client_id??null,e.metadata_json??null,e.run_id??null,e.event_cursor??null,e.usage_json??null,e.deleting_at??null)}r(Oe,"seedRow");function U(e){if(e.fault_id==null)return null;const n=Object.entries(e).filter(([t])=>t.startsWith("fault_")).map(([t,o])=>[t==="fault_id"?t:t.slice(6),o]);return ae(Object.fromEntries(n))}r(U,"faultFrom");function f(e){const n={node_id:e.node_id,name:e.name,description:e.description??void 0,cycles:e.cycles??void 0,kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,status:e.status,cwd:e.cwd,host_kind:e.host_kind??null,profile_id:e.profile_id??null,scopes:e.scopes_json==null?null:JSON.parse(e.scopes_json),grantee:e.grantee,sub:e.sub??null,grant_id:e.grant_id??null,client_id:e.client_id??null,metadata_json:e.metadata_json??null,run_id:e.run_id??null,event_cursor:e.event_cursor??null,last_activity_at:e.last_activity_at??null,usage_json:e.usage_json??null,deleting_at:e.deleting_at??null,parent:e.parent??null,created:e.created,intent:e.intent??null,waiting_for:e.waiting_for??null,frozen_at:e.frozen_at??null,respawn_failures:e.respawn_failures??0,respawn_not_before:e.respawn_not_before??null,launched_at:e.launched_at??null,last_settled_at:e.last_settled_at??null,terminal_reason:e.terminal_reason??null,final_report:e.final_report??null,finalized_at:e.finalized_at??null,outcome_kind:e.outcome_kind??null,outcome_reason:e.outcome_reason??null,outcome_at:e.outcome_at??null,outcome_revision:e.outcome_revision??0,outcome_detail_json:e.outcome_detail_json??null,deadline_at:e.deadline_at??null,telemetry_tokens_in:e.telemetry_tokens_in??null,telemetry_context_tokens:e.telemetry_context_tokens??null,telemetry_last_activity:e.telemetry_last_activity??null,telemetry_updated_at:e.telemetry_updated_at??null,pi_pid:e.pi_pid??null,pi_pid_identity:e.pi_pid_identity??null,window:e.window??null,tmux_session:e.tmux_session??null,pane:e.pane??null,fault:null,streaming:!1},t=x(n.pi_pid),o=U(e);return n.fault=o?.link==="pi\u2192provider"&&o.retry.by==="daemon"&&o.retry.disposition==="auto"&&!t?null:o,n.streaming=e.turn_open_at!==null&&e.turn_closed_at===null&&t,n}r(f,"rowFrom");function C(e,n=ue(e.node_id)){return{...f(e),title:e.title??void 0,icon:e.icon??void 0,spawned_by:e.spawned_by??null,creator:e.creator??null,fork_from:e.fork_from??null,fork_source_file:e.fork_source_file??null,passive_default:e.passive_default===1,cycle_pending:e.cycle_pending===1,model_override:e.model_override??null,scopes:e.scopes_json==null?null:JSON.parse(e.scopes_json),persona_ack:e.persona_ack_json==null?void 0:JSON.parse(e.persona_ack_json),review_binding:e.review_binding_json==null?void 0:JSON.parse(e.review_binding_json),launch:e.launch_config_json==null?void 0:JSON.parse(e.launch_config_json),pi_session_id:e.pi_session_id??null,pi_session_file:e.pi_session_file??null,...n===null?{}:{managed_worktree:n}}}r(C,"metaFrom");function Ye(e,n={}){return fe(),_(t=>{Oe(e,t),e.managed_worktree!==void 0&&e.managed_worktree!==null&&de(e.node_id,e.managed_worktree,t),n.outcomeDelivery!==void 0&&P(t,e.node_id,n.outcomeDelivery),n.withinCreate?.(t,e)}),we(e.node_id),m(e.node_id)}r(Ye,"createNode");function m(e){const n=l().prepare("SELECT * FROM node_rows WHERE node_id = ?").get(e);return n===void 0?null:C(n)}r(m,"getNode");function qe(e){return Z(e)}r(qe,"canonicalSessionFile");function Ve(e){const n=se(e);return n===null?null:m(n)}r(Ve,"findNodeBySessionFile");function Ke(e){const n=l().prepare("SELECT * FROM node_rows WHERE node_id = ?").get(e);return n?f(n):null}r(Ke,"getRow");function Ge(e){const n=l().prepare("SELECT * FROM node_rows WHERE pane = ?").get(e);return n?f(n):null}r(Ge,"getRowByPane");function Qe(e){return l().prepare(`SELECT * FROM node_rows
|
|
2
2
|
WHERE deadline_at IS NOT NULL AND outcome_at IS NULL
|
|
3
3
|
AND deadline_at <= ? AND status IN ('active','idle') AND kind != 'human'
|
|
4
|
-
ORDER BY deadline_at, created, node_id`).all(e).map(
|
|
5
|
-
WHERE profile_id = ? AND deadline_at IS NOT NULL AND status IN ('active', 'idle')`).all(e),i=t.prepare("UPDATE nodes SET deadline_at = ? WHERE node_id = ? AND deadline_at = ?");let s=0;for(const
|
|
4
|
+
ORDER BY deadline_at, created, node_id`).all(e).map(f)}r(Qe,"dueNodeDeadlines");function Xe(e,n){return Number(l().prepare("UPDATE nodes SET deadline_at = ? WHERE node_id = ?").run(n,e).changes)===1}r(Xe,"setNodeDeadline");function Ze(e,n){return!Number.isFinite(n)||n<=0?0:_(t=>{const o=t.prepare(`SELECT node_id, deadline_at FROM nodes
|
|
5
|
+
WHERE profile_id = ? AND deadline_at IS NOT NULL AND status IN ('active', 'idle')`).all(e),i=t.prepare("UPDATE nodes SET deadline_at = ? WHERE node_id = ? AND deadline_at = ?");let s=0;for(const a of o){const d=Date.parse(a.deadline_at);Number.isNaN(d)||(s+=Number(i.run(new Date(d+n).toISOString(),a.node_id,a.deadline_at).changes))}return s})}r(Ze,"shiftProfileNodeDeadlines");function en(e,n,t){const o=`SELECT o.rowid FROM objects o JOIN identities i ON i.object = o.owner
|
|
6
|
+
WHERE o.type = 'node' AND i.scheme = 'local-user' AND i.external_id = 'user:local'`,s=e.prepare(`${o} LIMIT 1`).get()!==void 0?Number(e.prepare(`UPDATE objects SET owner = ? WHERE rowid IN (${o})`).run(H(e,"app:terminal").rowid).changes):0;return Number(e.prepare("UPDATE nodes SET sub = ? WHERE sub = 'user:local'").run(n).changes)+s+Number(e.prepare(`UPDATE nodes SET sub = ? WHERE sub IS NULL AND node_id IN (
|
|
7
|
+
SELECT o.id FROM objects o JOIN identities i ON i.object = o.owner
|
|
8
|
+
WHERE o.type = 'node' AND i.scheme = 'app' AND i.external_id = 'app:terminal')`).run(n).changes)+Number(e.prepare("UPDATE nodes SET grant_id = NULL WHERE grant_id = ?").run(t).changes)}r(en,"rewriteLocalNodeIdentity");function R(e,n){if(e==null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="bigint"||e instanceof Uint8Array)return e;throw new TypeError(`${n} must be a SQLite scalar`)}r(R,"sqlInput");function nn(e,n){const t=[],o=r((s,a=s)=>{Object.prototype.hasOwnProperty.call(n,s)&&t.push([a,R(n[s],s)])},"add");o("description"),o("title"),o("icon"),o("cycles"),o("mode"),o("lifecycle"),o("cwd"),o("host_kind"),o("profile_id"),o("parent"),o("spawned_by"),o("creator"),o("fork_from"),o("fork_source_file"),o("model_override"),Object.prototype.hasOwnProperty.call(n,"passive_default")&&t.push(["passive_default",n.passive_default===!0?1:0]),Object.prototype.hasOwnProperty.call(n,"cycle_pending")&&t.push(["cycle_pending",n.cycle_pending===!0?1:0]),Object.prototype.hasOwnProperty.call(n,"persona_ack")&&t.push(["persona_ack_json",E(n.persona_ack,"persona_ack")]),Object.prototype.hasOwnProperty.call(n,"review_binding")&&t.push(["review_binding_json",E(n.review_binding,"review_binding")]),Object.prototype.hasOwnProperty.call(n,"scopes")&&t.push(["scopes_json",E(n.scopes,"scopes")]),Object.prototype.hasOwnProperty.call(n,"launch")&&t.push(["launch_config_json",E(n.launch,"launch")]);const i=r(s=>Object.prototype.hasOwnProperty.call(n,s),"has");return _(s=>{const a=F(s,e);if(a===null||a.type!=="node")throw new Error(`unknown node: ${e}`);if(i("name")&&Se(s,a,R(n.name,"name")),i("kind")&&Re(s,a,R(n.kind,"kind")),t.length===0)return;if(s.prepare(`UPDATE nodes SET ${t.map(([c])=>`${c} = ?`).join(", ")} WHERE node_id = ?`).run(...t.map(([,c])=>c),e).changes!==1)throw new Error(`unknown node: ${e}`)}),m(e)}r(nn,"updateNode");function tn(e,n){l().prepare("UPDATE nodes SET status = ? WHERE node_id = ?").run(n,e)}r(tn,"setStatus");function on(e,n){l().prepare("UPDATE nodes SET intent = ? WHERE node_id = ?").run(n??null,e)}r(on,"setIntent");function rn(e,n,t={}){if(t.outcome===void 0){const i=[],s=[];Object.prototype.hasOwnProperty.call(n,"status")&&(i.push("status = ?"),s.push(n.status??null)),Object.prototype.hasOwnProperty.call(n,"intent")&&(i.push("intent = ?"),s.push(n.intent??null)),Object.prototype.hasOwnProperty.call(n,"terminal_reason")&&(i.push("terminal_reason = ?"),s.push(n.terminal_reason??null));const a=["node_id = ?"];s.push(e),t.fromStatuses!==void 0&&(a.push(`status IN (${t.fromStatuses.map(()=>"?").join(", ")})`),s.push(...t.fromStatuses)),t.requireNoFinalReport===!0&&a.push("final_report IS NULL");const d=l().prepare(`UPDATE nodes SET ${i.join(", ")} WHERE ${a.join(" AND ")}`).run(...s);return Number(d.changes)}const o=t.outcome;return _(i=>{const s=[],a=[];Object.prototype.hasOwnProperty.call(n,"status")&&(s.push("status = ?"),a.push(n.status??null)),Object.prototype.hasOwnProperty.call(n,"intent")&&(s.push("intent = ?"),a.push(n.intent??null)),Object.prototype.hasOwnProperty.call(n,"terminal_reason")&&(s.push("terminal_reason = ?"),a.push(n.terminal_reason??null));const d=r((w,u)=>o.supersede===!0?"?":`CASE WHEN outcome_at IS NULL THEN ? ELSE ${u} END`,"outcomeValue");s.push(`outcome_kind = ${d(o.kind,"outcome_kind")}`,`outcome_reason = ${d(o.reason,"outcome_reason")}`,`outcome_detail_json = ${d(o.detailJson,"outcome_detail_json")}`,`outcome_revision = ${o.supersede===!0?"outcome_revision + 1":"CASE WHEN outcome_at IS NULL THEN outcome_revision + 1 ELSE outcome_revision END"}`,`outcome_at = ${d(o.at,"outcome_at")}`),a.push(o.kind,o.reason,o.detailJson,o.at);const c=["node_id = ?"];a.push(e),t.fromStatuses!==void 0&&(c.push(`status IN (${t.fromStatuses.map(()=>"?").join(", ")})`),a.push(...t.fromStatuses)),t.requireNoFinalReport===!0&&c.push("final_report IS NULL");const p=i.prepare(`UPDATE nodes SET ${s.join(", ")} WHERE ${c.join(" AND ")}`).run(...a);if(Number(p.changes)===0)return 0;const y=i.prepare("SELECT outcome_at FROM nodes WHERE node_id = ?").get(e);return(o.supersede===!0||y.outcome_at===o.at)&&o.documentJson!==null&&o.documentJson!==void 0&&oe(i,{idempotencyKey:`node-outcome:${e}`,label:e,bodyJson:o.documentJson,supersede:o.supersede===!0}),Number(p.changes)})}r(rn,"transitionStatusIntent");function sn(e){return l().prepare("SELECT final_report FROM nodes WHERE node_id = ?").get(e)?.final_report??null}r(sn,"getFinalReport");function an(e,n){return l().prepare("UPDATE nodes SET final_report = NULL, finalized_at = NULL WHERE node_id = ? AND final_report = ?").run(e,n).changes>0}r(an,"clearFinalReportIfMatches");function ln(e,n){l().prepare('UPDATE nodes SET tmux_session = ?, "window" = ?, pane = ? WHERE node_id = ?').run(n.tmux_session??null,n.window??null,n.pane??null,e)}r(ln,"setPresence");function dn(e,n){l().prepare("UPDATE nodes SET launched_at = ?, frozen_at = NULL, respawn_not_before = NULL WHERE node_id = ?").run(n,e)}r(dn,"recordLaunch");function un(e,n){l().prepare("UPDATE nodes SET last_settled_at = ? WHERE node_id = ?").run(n,e)}r(un,"recordSettledTurn");function cn(e,n){l().prepare("UPDATE nodes SET frozen_at = ? WHERE node_id = ?").run(n,e)}r(cn,"setFrozen");function _n(e){l().prepare("UPDATE nodes SET frozen_at = NULL WHERE node_id = ?").run(e)}r(_n,"clearFrozen");function pn(e,n){l().prepare("UPDATE nodes SET respawn_failures = ?, respawn_not_before = ? WHERE node_id = ?").run(n.failures,n.notBefore,e)}r(pn,"recordRespawnAttempt");const N="node_id NOT IN (SELECT node_id FROM warm_pool)",I=["state","cleanup_state","path","branch","repo_root","base_ref","base_sha","created_at","closed_at","next_attempt_at","attempts","quarantined","sweep_reason","sweep_detail","sweep_last_at","sweep_observed_json","abandoned_json","land_intent_json","disposal_json"];function Te(e){return e.worktree_state===null?null:ce(Object.fromEntries(I.map(n=>[n,e[`worktree_${n}`]])))}r(Te,"worktreeFromProjection");function fn(e){const n=I.map(o=>`w.${o} AS worktree_${o}`).join(", ");return l().prepare(`SELECT n.*, ${n} FROM node_rows n LEFT JOIN worktrees w ON w.node_id = n.node_id WHERE n.profile_id = ? ORDER BY n.created`).all(e).map(o=>C(o,Te(o)))}r(fn,"listNodesByProfile");function En(e,n){l().prepare(`UPDATE nodes
|
|
6
9
|
SET telemetry_tokens_in = ?,
|
|
7
10
|
telemetry_context_tokens = COALESCE(?, telemetry_context_tokens),
|
|
8
11
|
telemetry_last_activity = COALESCE(?, telemetry_last_activity),
|
|
9
12
|
telemetry_updated_at = ?
|
|
10
13
|
WHERE node_id = ?
|
|
11
|
-
AND (telemetry_updated_at IS NULL OR telemetry_updated_at < ?)`).run(n.tokensIn,n.contextTokens,n.lastActivity,n.updatedAt,e,n.updatedAt)}r(
|
|
14
|
+
AND (telemetry_updated_at IS NULL OR telemetry_updated_at < ?)`).run(n.tokensIn,n.contextTokens,n.lastActivity,n.updatedAt,e,n.updatedAt)}r(En,"updateNodeTelemetry");function mn(){return l().prepare(`SELECT
|
|
12
15
|
node_id, name, description, cycles, kind, status, frozen_at,
|
|
13
16
|
telemetry_context_tokens, telemetry_last_activity,
|
|
14
17
|
pi_pid, turn_open_at, turn_closed_at,
|
|
@@ -16,29 +19,21 @@ var Y=Object.defineProperty;var r=(e,n)=>Y(e,"name",{value:n,configurable:!0});i
|
|
|
16
19
|
fault_operation_id, fault_anchor_entry_id, fault_retry_disposition,
|
|
17
20
|
fault_retry_by, fault_retry_attempt, fault_retry_max, fault_retry_next_at,
|
|
18
21
|
fault_provider_error_json
|
|
19
|
-
FROM node_rows WHERE ${N} ORDER BY created`).all().map(n=>{const t=n.pi_pid??null,o=
|
|
22
|
+
FROM node_rows WHERE ${N} ORDER BY created`).all().map(n=>{const t=n.pi_pid??null,o=x(t),i=U(n);return{node_id:n.node_id,name:n.name,description:n.description??null,cycles:n.cycles??null,kind:n.kind,status:n.status,frozen_at:n.frozen_at??null,pi_pid:t,telemetry_context_tokens:n.telemetry_context_tokens??null,telemetry_last_activity:n.telemetry_last_activity??null,fault:i?.link==="pi\u2192provider"&&i.retry.by==="daemon"&&i.retry.disposition==="auto"&&!o?null:i,streaming:n.turn_open_at!==null&&n.turn_closed_at===null&&o}})}r(mn,"graphNodes");function Le(e){const n=[N],t=[];if(e?.status!==void 0){const i=Array.isArray(e.status)?e.status:[e.status];n.push(`status IN (${i.map(()=>"?").join(",")})`),t.push(...i)}return e?.withRecordedPid===!0&&n.push("pi_pid IS NOT NULL"),e?.withRecordedPidOrFrozen===!0&&n.push("(pi_pid IS NOT NULL OR frozen_at IS NOT NULL)"),l().prepare(`SELECT * FROM node_rows WHERE ${n.join(" AND ")} ORDER BY created`).all(...t).map(f)}r(Le,"listNodes");function Nn(){return l().prepare(`SELECT * FROM node_rows
|
|
20
23
|
WHERE ${N} AND kind != 'human'
|
|
21
24
|
AND (status IN ('active', 'idle') OR (status IN ('done', 'canceled', 'dead') AND (pi_pid IS NOT NULL OR frozen_at IS NOT NULL)))
|
|
22
|
-
ORDER BY created`).all().map(
|
|
25
|
+
ORDER BY created`).all().map(f)}r(Nn,"listNodesForSupervision");function wn(){return l().prepare(`SELECT node_id, name, created FROM node_rows WHERE ${N} ORDER BY created`).all()}r(wn,"listNodeIdentities");function gn(e,n){_(t=>{t.prepare("INSERT OR REPLACE INTO warm_pool (node_id, recipe_key, created) VALUES (?, ?, ?)").run(e,n,new Date().toISOString())})}r(gn,"registerWarmSpare");function yn(e){return _(n=>n.prepare("DELETE FROM warm_pool WHERE node_id = ?").run(e).changes>0)}r(yn,"unregisterWarmSpare");function S(e,n){const t=`SELECT w.node_id AS node_id, w.recipe_key AS recipe_key, w.created AS created,
|
|
23
26
|
n.status AS status, n.pi_pid AS pi_pid, n.pi_pid_identity AS pi_pid_identity
|
|
24
|
-
FROM warm_pool w JOIN node_rows n ON n.node_id = w.node_id`+(n===void 0?"":" WHERE w.recipe_key = ?")+" ORDER BY w.created";return(n===void 0?e.prepare(t).all():e.prepare(t).all(n)).map(i=>({node_id:i.node_id,recipe_key:i.recipe_key,created:i.created,status:i.status,pi_pid:i.pi_pid??null,pi_pid_identity:i.pi_pid_identity??null}))}r(S,"warmSpareRowsFor");function
|
|
25
|
-
FROM
|
|
27
|
+
FROM warm_pool w JOIN node_rows n ON n.node_id = w.node_id`+(n===void 0?"":" WHERE w.recipe_key = ?")+" ORDER BY w.created";return(n===void 0?e.prepare(t).all():e.prepare(t).all(n)).map(i=>({node_id:i.node_id,recipe_key:i.recipe_key,created:i.created,status:i.status,pi_pid:i.pi_pid??null,pi_pid_identity:i.pi_pid_identity??null}))}r(S,"warmSpareRowsFor");function Rn(){return S(l())}r(Rn,"listWarmSpares");function Sn(e){return l().prepare("SELECT 1 FROM warm_pool WHERE node_id = ?").get(e)!==void 0}r(Sn,"isWarmSpare");function M(e){return e.status!=="active"&&e.status!=="idle"?!1:pe(e.pi_pid,e.pi_pid_identity)==="alive"}r(M,"spareIsClaimable");function hn(e,n,t={}){return _(o=>{const i=S(o,e).find(M);return i===void 0||o.prepare("DELETE FROM warm_pool WHERE node_id = ?").run(i.node_id).changes===0?null:(o.prepare("UPDATE nodes SET created = ?, deadline_at = ? WHERE node_id = ?").run(n,t.deadlineAt??null,i.node_id),t.outcomeDelivery!==void 0&&P(o,i.node_id,t.outcomeDelivery),i.node_id)})}r(hn,"claimWarmSpare");function On(e){return S(l(),e).filter(M).length}r(On,"warmSpareCount");function Tn(e){return l().prepare("SELECT node_id FROM nodes WHERE parent = ? ORDER BY created").all(e).map(n=>n.node_id)}r(Tn,"childrenOf");function Ln(){return l().prepare(`SELECT node_id, name, kind, mode, lifecycle, status, cwd, host_kind, parent, created
|
|
28
|
+
FROM node_rows WHERE ${N} ORDER BY created`).all().map(e=>({node_id:e.node_id,name:e.name,kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,status:e.status,cwd:e.cwd,host_kind:e.host_kind??null,parent:e.parent??null,created:e.created}))}r(Ln,"rosterNodes");function Dn(e){return l().prepare(`SELECT * FROM node_rows
|
|
26
29
|
WHERE parent IS NULL AND kind != 'human'
|
|
27
30
|
AND status IN ('active','idle') AND cwd = ?
|
|
28
31
|
AND ${N}
|
|
29
|
-
ORDER BY created DESC`).all(e).map(
|
|
30
|
-
VALUES (?, ?, ?, ?, ?)
|
|
31
|
-
ON CONFLICT(type, from_id, to_id) DO UPDATE SET active=excluded.active`).run(e,n,t,o?1:0,new Date().toISOString())}r(C,"addEdge");function Tn(e,n,t=!0){C("subscribes_to",e,n,t)}r(Tn,"subscribe");function Dn(e,n){a().prepare("DELETE FROM edges WHERE type = ? AND from_id = ? AND to_id = ?").run("subscribes_to",e,n)}r(Dn,"unsubscribe");function Ln(e,n,t){a().prepare("UPDATE edges SET active = ? WHERE type = ? AND from_id = ? AND to_id = ?").run(t?1:0,"subscribes_to",e,n)}r(Ln,"setSubscriptionActive");function vn(e,n){C("spawned_by",e,n,!0)}r(vn,"recordSpawn");function An(e){return a().prepare(`SELECT from_id AS node_id, active, created FROM edges
|
|
32
|
-
WHERE type = 'subscribes_to' AND to_id = ? ORDER BY created`).all(e).map(n=>({node_id:n.node_id,active:n.active===1,created:n.created}))}r(An,"subscribersOf");function I(e){return a().prepare(`SELECT to_id AS node_id, active, created FROM edges
|
|
33
|
-
WHERE type = 'subscribes_to' AND from_id = ? ORDER BY created`).all(e).map(n=>({node_id:n.node_id,active:n.active===1,created:n.created}))}r(I,"subscriptionsOf");function bn(e){const n=new Set([e]),t=[],o=I(e).map(i=>i.node_id);for(;o.length>0;){const i=o.shift();if(!n.has(i)){n.add(i),t.push(i);for(const s of I(i))n.has(s.node_id)||o.push(s.node_id)}}return t}r(bn,"view");function kn(e){return a().prepare(`SELECT 1 FROM edges e JOIN nodes n ON n.node_id = e.to_id
|
|
34
|
-
WHERE e.type = 'subscribes_to' AND e.from_id = ? AND e.active = 1
|
|
35
|
-
AND n.status IN ('active', 'idle') LIMIT 1`).get(e)!==void 0}r(kn,"hasActiveLiveSubscription");function xn(e){return a().prepare(`SELECT 1 FROM edges e JOIN nodes n ON n.node_id = e.from_id
|
|
36
|
-
WHERE e.type = 'subscribes_to' AND e.to_id = ? AND e.active = 1
|
|
37
|
-
AND n.status IN ('active', 'idle') LIMIT 1`).get(e)!==void 0}r(xn,"hasLiveSubscriber");function Wn(e){const n=E(e)?.waiting_for;if(n==null)return!1;const t=E(n);return t!==null&&(t.status==="active"||t.status==="idle")}r(Wn,"hasLiveMessageWait");function jn(e,n){a().prepare("UPDATE nodes SET waiting_for = ?, waiting_for_generation = waiting_for_generation + 1 WHERE node_id = ?").run(n,e)}r(jn,"setMessageWait");function Fn(e,n,t){return _(o=>{const i=o.prepare("SELECT waiting_for_generation FROM nodes WHERE node_id = ? AND waiting_for = ?").get(e,n),s=t();return n!==null&&i!==void 0&&o.prepare("UPDATE nodes SET waiting_for = NULL WHERE node_id = ? AND waiting_for = ? AND waiting_for_generation = ?").run(e,n,i.waiting_for_generation),s})}r(Fn,"deliverAndSettleMessageWait");function Hn(e,n,t){return _(o=>{const i=o.prepare(`SELECT waiter.waiting_for, waiter.waiting_for_generation, target.status AS controller_status
|
|
32
|
+
ORDER BY created DESC`).all(e).map(f)}r(Dn,"listResumableRoots");export*from"./tree.js";function An(e){const n=m(e)?.waiting_for;if(n==null)return!1;const t=m(n);return t!==null&&(t.status==="active"||t.status==="idle")}r(An,"hasLiveMessageWait");function vn(e,n){l().prepare("UPDATE nodes SET waiting_for = ?, waiting_for_generation = waiting_for_generation + 1 WHERE node_id = ?").run(n,e)}r(vn,"setMessageWait");function kn(e,n,t){return _(o=>{const i=o.prepare("SELECT waiting_for_generation FROM nodes WHERE node_id = ? AND waiting_for = ?").get(e,n),s=t();return n!==null&&i!==void 0&&o.prepare("UPDATE nodes SET waiting_for = NULL WHERE node_id = ? AND waiting_for = ? AND waiting_for_generation = ?").run(e,n,i.waiting_for_generation),s})}r(kn,"deliverAndSettleMessageWait");function jn(e,n,t){return _(o=>{const i=o.prepare(`SELECT waiter.waiting_for, waiter.waiting_for_generation, target.status AS controller_status
|
|
38
33
|
FROM nodes AS waiter LEFT JOIN nodes AS target ON target.node_id = waiter.waiting_for
|
|
39
|
-
WHERE waiter.node_id = ?`).get(e),s=i?.controller_status==="active"||i?.controller_status==="idle";if(i?.waiting_for!==n||s)return null;const
|
|
40
|
-
AND NOT EXISTS (SELECT 1 FROM sessions s WHERE s.node_id = n.node_id) LIMIT 1`);for(const i of e)if(!(t.get(i)!==void 0||o.get(i)!==void 0))try{
|
|
34
|
+
WHERE waiter.node_id = ?`).get(e),s=i?.controller_status==="active"||i?.controller_status==="idle";if(i?.waiting_for!==n||s)return null;const a=t();return o.prepare("UPDATE nodes SET waiting_for = NULL WHERE node_id = ? AND waiting_for = ? AND waiting_for_generation = ?").run(e,n,i.waiting_for_generation),a})}r(jn,"settleDeadMessageWait");function xn(e,n,t){return _(o=>{const i=o.prepare("SELECT status, final_report, frozen_at FROM nodes WHERE node_id = ?").get(e);return i===void 0?{kind:"missing"}:n(i)?{kind:"terminal",status:i.status,final_report:i.final_report}:{kind:"ran",result:t()}})}r(xn,"withFreshTerminalGuard");function g(e){return le(e)}r(g,"hasUnreconciledManagedWorktree");function $(e,n={}){return!["done","dead","canceled"].includes(e.status)||e.pi_pid!==null||e.frozen_at!==null||g(e.node_id)||e.node_id===v()||(e.run_id??null)!==null?!1:n.pastTtl===!0||!["crashed","stranded",null].includes(e.terminal_reason??null)}r($,"isCollectible");function h(e){if(e.length===0)return[];const n=e.map(()=>"?").join(",");return l().prepare(`SELECT DISTINCT session_id FROM sessions WHERE node_id IN (${n}) AND session_id IS NOT NULL`).all(...e).map(({session_id:o})=>o)}r(h,"nodeConversationIds");function O(e){const n=l(),t=n.prepare("SELECT 1 FROM sessions WHERE session_id = ? LIMIT 1"),o=n.prepare(`SELECT 1 FROM nodes n WHERE n.fork_source_file LIKE '%\\_' || ? || '.jsonl' ESCAPE '\\'
|
|
35
|
+
AND NOT EXISTS (SELECT 1 FROM sessions s WHERE s.node_id = n.node_id) LIMIT 1`);for(const i of e)if(!(t.get(i)!==void 0||o.get(i)!==void 0))try{ne().delete(i)}catch(s){if(!(s instanceof te))throw s}}r(O,"deleteNodeConversations");function T(e,n){const t=F(e,n);return t===null||t.deleted_at!==null?!1:(he(e,t),!0)}r(T,"deleteNodeObject");function L(e){return{nodeId:e,app:m(e)===null?null:Ne(e)}}r(L,"nodeFiles");function z({nodeId:e,app:n}){n!==null&&j(b(n).nodes,ge(e,n)),j(X(W(e)),W(e))}r(z,"removeNodeAppTrees");function B({nodeId:e}){return[me(e)]}r(B,"nodeOwnedDirs");function J({nodeId:e,app:n}){if(n!==null)try{K(k(b(n).conversations,e))}catch(t){if(!["ENOENT","ENOTEMPTY"].includes(t.code??""))throw t}}r(J,"removeNodeConversationDir");function D(e){z(e);for(const n of B(e))G(n,{recursive:!0,force:!0});J(e)}r(D,"removeNodeFiles");function Wn(e){if(g(e))return{deleted:!1};const n=L(e),t=h([e]),o=_(i=>(T(i,e),{deleted:!0}));return O(t),D(n),o}r(Wn,"deleteNode");function bn(e){const n=[...new Set(e)];if(n.length===0)return[];const t=n.filter(g);if(t.length>0)throw new Error(`refusing to delete nodes with unreconciled managed worktrees: ${t.join(", ")}`);const o=n.map(L),i=h(n),s=n.map(()=>"?").join(","),d=l().prepare(`SELECT node_id FROM nodes WHERE node_id IN (${s}) ORDER BY created`).all(...n).map(({node_id:c})=>c).filter(c=>_(p=>T(p,c)));O(i);for(const c of d){const p=o[n.indexOf(c)];A(p,()=>D(p))}return d}r(bn,"deleteNodes");function Fn(e){const n=e.dryRun??!1,t=e.includeStale??!1,o=Date.now()-e.ttlDays*864e5,i=new Date(o).toISOString(),s=v()??"",a=l(),d=r(u=>q(u)<o,"quiet"),c=r(u=>({node_id:u.node_id,status:u.status,created:u.created}),"toPruned"),p=a.prepare(`SELECT * FROM node_rows
|
|
41
36
|
WHERE status IN ('dead', 'done', 'canceled') AND created < ?
|
|
42
|
-
ORDER BY created`).all(i).map(
|
|
37
|
+
ORDER BY created`).all(i).map(f).filter(u=>$(u,{pastTtl:!0})&&d(u)&&!e.held(u.node_id)).map(c),y=t?a.prepare(`SELECT * FROM node_rows
|
|
43
38
|
WHERE status IN ('active', 'idle') AND created < ?
|
|
44
|
-
ORDER BY created`).all(i).map(
|
|
39
|
+
ORDER BY created`).all(i).map(f).filter(u=>u.node_id!==s&&!_e(u.pi_pid??null)&&(u.frozen_at??null)===null&&(u.respawn_not_before??null)===null&&u.intent!=="idle-release"&&(u.run_id??null)===null&&!ie(u.node_id)&&!g(u.node_id)&&d(u)&&!e.held(u.node_id)).map(c):[],w=[...p,...y];return n||w.length===0?{pruned:w,dryRun:n}:(Y(w,e.removeDirs),{pruned:w,dryRun:n})}r(Fn,"pruneNodes");function Y(e,n){if(e.length===0)return;const t=e.map(i=>L(i.node_id)),o=h(e.map(i=>i.node_id));for(const i of e)_(s=>T(s,i.node_id));if(O(o),n!==void 0){for(const i of t)A(i,()=>{z(i),J(i)});n(t.flatMap(B));return}for(const i of t)A(i,()=>D(i))}r(Y,"deletePrunedNodes");function A(e,n){try{n()}catch(t){ee({level:"error",event:"canvas.node_files.remove_failed",error:t,fields:{node_id:e.nodeId}})}}r(A,"eachNodeBestEffort");function q(e){let n=0;for(const t of[e.created,e.launched_at,e.last_settled_at,e.finalized_at,e.outcome_at,e.last_activity_at]){if(t==null)continue;const o=Date.parse(t);Number.isFinite(o)&&o>n&&(n=o)}try{const t=Q(k(Ee(e.node_id),"telemetry.json"),{throwIfNoEntry:!1});t!==void 0&&t.mtimeMs>n&&(n=t.mtimeMs)}catch{}return n}r(q,"lastActivityMs");function Hn(e){const n=e.dryRun??!1,t=Le(),o=t.filter(d=>$(d)&&!e.held(d.node_id)),i=t.length-o.length,s=Math.max(0,e.maxNodes-i),a=o.map(d=>({row:d,recency:q(d)})).sort((d,c)=>c.recency-d.recency).slice(s).map(({row:d})=>({node_id:d.node_id,status:d.status,created:d.created}));return n||a.length===0?{pruned:a,dryRun:n}:(Y(a),{pruned:a,dryRun:n})}r(Hn,"pruneToLimit");export{Je as assertRunNotDeleting,qe as canonicalSessionFile,Tn as childrenOf,hn as claimWarmSpare,an as clearFinalReportIfMatches,_n as clearFrozen,Ye as createNode,Wn as deleteNode,bn as deleteNodes,kn as deliverAndSettleMessageWait,Qe as dueNodeDeadlines,Ve as findNodeBySessionFile,sn as getFinalReport,m as getNode,Ke as getRow,Ge as getRowByPane,mn as graphNodes,An as hasLiveMessageWait,$ as isCollectible,Sn as isWarmSpare,q as lastActivityMs,wn as listNodeIdentities,Le as listNodes,fn as listNodesByProfile,Nn as listNodesForSupervision,Dn as listResumableRoots,Rn as listWarmSpares,L as nodeFiles,Fn as pruneNodes,Hn as pruneToLimit,dn as recordLaunch,pn as recordRespawnAttempt,un as recordSettledTurn,gn as registerWarmSpare,D as removeNodeFiles,en as rewriteLocalNodeIdentity,Ln as rosterNodes,cn as setFrozen,on as setIntent,vn as setMessageWait,Xe as setNodeDeadline,ln as setPresence,tn as setStatus,jn as settleDeadMessageWait,Ze as shiftProfileNodeDeadlines,rn as transitionStatusIntent,yn as unregisterWarmSpare,nn as updateNode,En as updateNodeTelemetry,On as warmSpareCount,xn as withFreshTerminalGuard};
|
package/dist/core/canvas/db.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DatabaseSync } from 'node:sqlite';
|
|
1
|
+
import { DatabaseSync, type StatementSync } from 'node:sqlite';
|
|
2
2
|
export { migrate, MIGRATIONS } from './migrations.js';
|
|
3
3
|
/** Open (or reuse) the canvas db at the current `CRTR_HOME`, configuring WAL
|
|
4
4
|
* but never changing its schema. Keyed by path so tests with distinct homes get
|
|
@@ -24,3 +24,6 @@ export declare function openDb(): DatabaseSync;
|
|
|
24
24
|
export declare function withCanvasWrite<T>(body: (db: DatabaseSync) => T): T;
|
|
25
25
|
/** Close and forget the handle for the current home. Mainly for tests. */
|
|
26
26
|
export declare function closeDb(): void;
|
|
27
|
+
/** `db.prepare(sql)`, compiled once per connection: for statements run once per row of a fan-out,
|
|
28
|
+
* where compiling costs more than executing. Holds compiled SQL only, never results. */
|
|
29
|
+
export declare function prepared(db: DatabaseSync, sql: string): StatementSync;
|
package/dist/core/canvas/db.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`;
|
|
1
|
+
var a=Object.defineProperty;var r=(t,e)=>a(t,"name",{value:e,configurable:!0});import{DatabaseSync as p}from"node:sqlite";import{appendFileSync as u}from"node:fs";import{canvasDbPath as s,ensureHome as f}from"./paths.js";import{initializeEmptyLayout as m}from"../layout.js";import{migrate as E,MIGRATIONS as I}from"./migrations.js";const o=new Map;function x(){const t=process.env.CRTR_DB_OPEN_LEDGER;if(t)try{const e=`${new Date().toISOString()} ${process.pid} ${process.argv[1]??"<unknown>"}
|
|
2
|
+
`;u(t,e)}catch{}}r(x,"recordOpenLedger");function g(){const t=s(),e=o.get(t);if(e)return e;m(),f(),x();const n=new p(t);return n.exec("PRAGMA busy_timeout = 5000;"),n.exec("PRAGMA journal_mode = WAL;"),n.exec("PRAGMA foreign_keys = ON;"),o.set(t,n),n}r(g,"openDb");function y(t){const e=g();if(e.isTransaction)return t(e);e.exec("BEGIN IMMEDIATE");try{const n=t(e);return e.exec("COMMIT"),n}catch(n){try{e.exec("ROLLBACK")}catch{}throw n}}r(y,"withCanvasWrite");function D(){const t=s(),e=o.get(t);e&&(e.close(),o.delete(t))}r(D,"closeDb");const i=new WeakMap;function w(t,e){let n=i.get(t);n||i.set(t,n=new Map);let c=n.get(e);return c||n.set(e,c=t.prepare(e)),c}r(w,"prepared");export{I as MIGRATIONS,D as closeDb,E as migrate,g as openDb,w as prepared,y as withCanvasWrite};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodeStatus } from './types.js';
|
|
2
|
-
export type HistorySource = '
|
|
2
|
+
export type HistorySource = 'inbox' | 'transcript';
|
|
3
3
|
/** Every origin token `--origin` accepts. `human` is a person at a front door;
|
|
4
4
|
* the rest mirror the runtime origin kinds; `unknown` is a message that
|
|
5
5
|
* carries no stamp at all — its own bucket, never folded into another, since
|
|
@@ -8,31 +8,27 @@ export type HistorySource = 'report' | 'doc' | 'roadmap' | 'meta' | 'inbox' | 't
|
|
|
8
8
|
export declare const ORIGIN_TOKENS: readonly ["human", "inbox", "wake", "revive", "restart-continuation", "stop-guard", "park", "recovery", "context-nudge", "kickoff", "unknown"];
|
|
9
9
|
/** Message roles carried by a transcript artifact. */
|
|
10
10
|
export declare const MESSAGE_ROLES: readonly ["user", "assistant", "toolResult"];
|
|
11
|
-
/** One searchable unit of
|
|
12
|
-
*
|
|
11
|
+
/** One searchable unit of a past conversation: an inbox entry or a transcript
|
|
12
|
+
* message. */
|
|
13
13
|
export interface HistoryArtifact {
|
|
14
14
|
/** Stable handle passed verbatim to `history read` — `<node-id>:<relpath>`. */
|
|
15
15
|
ref: string;
|
|
16
16
|
nodeId: string;
|
|
17
|
-
/**
|
|
17
|
+
/** `inbox/<n>` or `session/<n>`. */
|
|
18
18
|
relpath: string;
|
|
19
19
|
source: HistorySource;
|
|
20
|
-
/** final | update | urgent — reports only. */
|
|
21
|
-
reportKind?: string;
|
|
22
20
|
/** ISO 8601 artifact timestamp. */
|
|
23
21
|
ts: string;
|
|
24
22
|
/** Sort key: epoch ms of ts. */
|
|
25
23
|
tsMs: number;
|
|
26
|
-
/**
|
|
24
|
+
/** A one-line label for the entry or message. */
|
|
27
25
|
title: string;
|
|
28
26
|
nodeName: string;
|
|
29
27
|
nodeKind: string;
|
|
30
28
|
nodeStatus: NodeStatus;
|
|
31
29
|
nodeCwd: string;
|
|
32
30
|
nodeDesc: string;
|
|
33
|
-
/**
|
|
34
|
-
path: string | null;
|
|
35
|
-
/** Frontmatter-stripped body, loaded once and cached. Empty on read error. */
|
|
31
|
+
/** The full body. */
|
|
36
32
|
loadBody: () => string;
|
|
37
33
|
/** What drove this message to arrive. Set ONLY on inbound artifacts — a
|
|
38
34
|
* user-role transcript message or an inbox entry — because origin is a
|
|
@@ -57,8 +53,6 @@ export interface ScopeFilter {
|
|
|
57
53
|
}
|
|
58
54
|
export interface CorpusFilter {
|
|
59
55
|
types?: HistorySource[];
|
|
60
|
-
/** Narrow reports to one report-kind (final | update). Implies type report. */
|
|
61
|
-
reportKind?: string;
|
|
62
56
|
/** Node kinds (developer, spec, …). */
|
|
63
57
|
kinds?: string[];
|
|
64
58
|
/** Node lifecycle statuses. */
|
|
@@ -77,11 +71,6 @@ export interface CorpusFilter {
|
|
|
77
71
|
* CRTR_NODE_ID via the canvas data layer), falling back to the process cwd
|
|
78
72
|
* when not run as a node. */
|
|
79
73
|
export declare function callerCwd(): string;
|
|
80
|
-
/** The history ref of a node's newest report, or null when it left none.
|
|
81
|
-
* Report filenames lead with a compact timestamp, so the lexicographic maximum
|
|
82
|
-
* is the latest one. Callers use this to hand a reader something they can
|
|
83
|
-
* actually open (`crtr canvas history read <ref>`) instead of a bare node id. */
|
|
84
|
-
export declare function newestReportRef(nodeId: string): string | null;
|
|
85
74
|
/** Build the searchable artifact set for a scope + corpus filter. Node facets
|
|
86
75
|
* are applied against the db rows first (cheap); only surviving nodes' files
|
|
87
76
|
* are read. */
|
|
@@ -101,32 +90,15 @@ export interface ResolvedRef {
|
|
|
101
90
|
nodeId: string;
|
|
102
91
|
relpath: string;
|
|
103
92
|
source: HistorySource;
|
|
104
|
-
reportKind?: string;
|
|
105
93
|
ts: string;
|
|
106
94
|
nodeName: string;
|
|
107
|
-
/**
|
|
95
|
+
/** Rendered body. */
|
|
108
96
|
body: string;
|
|
109
|
-
/**
|
|
97
|
+
/** The verbatim record (session bytes or jsonl line); null for an inbox entry. */
|
|
110
98
|
raw: string | null;
|
|
111
99
|
path: string | null;
|
|
112
100
|
}
|
|
113
|
-
/** Resolve a `<node-id
|
|
114
|
-
* node
|
|
115
|
-
*
|
|
101
|
+
/** Resolve a `<node-id>:inbox/<n>`, `<node-id>:session` or
|
|
102
|
+
* `<node-id>:session/<n>` handle to its content. Returns null when the node is
|
|
103
|
+
* unknown, the ref names another corpus, or the entry does not exist. */
|
|
116
104
|
export declare function resolveRef(ref: string): ResolvedRef | null;
|
|
117
|
-
/** Enumerate one node's artifacts (for `history show`). */
|
|
118
|
-
export declare function nodeArtifacts(nodeId: string, types?: HistorySource[]): HistoryArtifact[];
|
|
119
|
-
export interface CorpusStats {
|
|
120
|
-
cwd: string;
|
|
121
|
-
nodes: number;
|
|
122
|
-
reports: number;
|
|
123
|
-
docs: number;
|
|
124
|
-
/** ISO date min → max across all artifacts, or null when empty. */
|
|
125
|
-
span: {
|
|
126
|
-
from: string;
|
|
127
|
-
to: string;
|
|
128
|
-
} | null;
|
|
129
|
-
}
|
|
130
|
-
/** Bounded per-cwd aggregate for the branch `-h` `<corpus>` block. Counts files
|
|
131
|
-
* on disk without reading bodies. */
|
|
132
|
-
export declare function corpusStats(cwd: string): CorpusStats;
|