@north-light/cli 0.3.530 → 0.3.531
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/clients/attach/session/connection.js +1 -1
- package/dist/clients/attach/session/reconnect.js +1 -1
- package/dist/clients/attach/viewer.js +3 -3
- package/dist/core/async-array.d.ts +7 -0
- package/dist/core/async-array.js +1 -0
- package/dist/core/audit.d.ts +1 -1
- package/dist/core/audit.js +2 -2
- package/dist/core/canvas/attention.d.ts +4 -4
- package/dist/core/canvas/attention.js +1 -1
- package/dist/core/canvas/boot.d.ts +4 -4
- package/dist/core/canvas/boot.js +1 -1
- package/dist/core/canvas/canvas.d.ts +59 -59
- package/dist/core/canvas/canvas.js +19 -19
- package/dist/core/canvas/context-strip.js +2 -2
- package/dist/core/canvas/crons.d.ts +27 -27
- package/dist/core/canvas/crons.js +11 -11
- package/dist/core/canvas/daemon-actions.d.ts +10 -10
- package/dist/core/canvas/daemon-actions.js +8 -8
- package/dist/core/canvas/daemon-owner.d.ts +3 -3
- package/dist/core/canvas/daemon-owner.js +2 -2
- package/dist/core/canvas/db.d.ts +19 -30
- package/dist/core/canvas/db.js +3 -2
- package/dist/core/canvas/deliveries.d.ts +16 -16
- package/dist/core/canvas/deliveries.js +24 -24
- package/dist/core/canvas/executions.d.ts +8 -8
- package/dist/core/canvas/executions.js +1 -1
- package/dist/core/canvas/focuses.d.ts +8 -8
- package/dist/core/canvas/focuses.js +1 -1
- package/dist/core/canvas/history.d.ts +3 -3
- package/dist/core/canvas/history.js +9 -9
- package/dist/core/canvas/install-id.d.ts +1 -1
- package/dist/core/canvas/install-id.js +1 -1
- package/dist/core/canvas/managed-worktree-sweep-candidates.d.ts +1 -1
- package/dist/core/canvas/managed-worktree-sweep-candidates.js +2 -2
- package/dist/core/canvas/memory-reads.d.ts +6 -6
- package/dist/core/canvas/memory-reads.js +1 -1
- package/dist/core/canvas/nav-model.d.ts +13 -13
- package/dist/core/canvas/nav-model.js +1 -1
- package/dist/core/canvas/node-agent-paths.d.ts +6 -6
- package/dist/core/canvas/node-agent-paths.js +1 -1
- package/dist/core/canvas/node-tokens.d.ts +7 -7
- package/dist/core/canvas/node-tokens.js +3 -3
- package/dist/core/canvas/outcome-actions.d.ts +5 -5
- package/dist/core/canvas/outcome-actions.js +3 -3
- package/dist/core/canvas/recovery.d.ts +26 -26
- package/dist/core/canvas/recovery.js +2 -2
- package/dist/core/canvas/render-source.d.ts +1 -1
- package/dist/core/canvas/render-source.js +1 -1
- package/dist/core/canvas/sessions.d.ts +10 -10
- package/dist/core/canvas/sessions.js +4 -4
- package/dist/core/canvas/source.js +1 -1
- package/dist/core/canvas/structured-requests.d.ts +15 -15
- package/dist/core/canvas/structured-requests.js +5 -5
- package/dist/core/canvas/tree.d.ts +9 -9
- package/dist/core/canvas/tree.js +5 -5
- package/dist/core/canvas/waits.d.ts +13 -13
- package/dist/core/canvas/waits.js +6 -6
- package/dist/core/canvas/worktrees.d.ts +15 -15
- package/dist/core/canvas/worktrees.js +1 -1
- package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -1
- package/dist/core/conversation-store/file-store.d.ts +7 -7
- package/dist/core/conversation-store/file-store.js +9 -9
- package/dist/core/conversation-store/index.d.ts +16 -14
- package/dist/core/conversation-store/index.js +1 -1
- package/dist/core/conversation-store/listener.js +5 -5
- package/dist/core/conversation-store/patch.d.ts +3 -1
- package/dist/core/conversation-store/patch.js +1 -1
- package/dist/core/feed/feed.js +3 -3
- package/dist/core/feed/inbox.d.ts +2 -2
- package/dist/core/feed/inbox.js +1 -1
- package/dist/core/feed/messages.d.ts +11 -12
- package/dist/core/feed/messages.js +5 -5
- package/dist/core/feed/reports.d.ts +4 -4
- package/dist/core/feed/reports.js +2 -2
- package/dist/core/grants/cover.d.ts +1 -1
- package/dist/core/grants/cover.js +1 -1
- package/dist/core/grants/local.d.ts +1 -1
- package/dist/core/grants/local.js +1 -1
- package/dist/core/grants/mirror.d.ts +19 -19
- package/dist/core/grants/mirror.js +2 -2
- package/dist/core/grants/on-sync.d.ts +1 -1
- package/dist/core/grants/on-sync.js +1 -1
- package/dist/core/grants/remove.js +1 -1
- package/dist/core/grants/sync.js +1 -1
- package/dist/core/graph/access.d.ts +17 -17
- package/dist/core/graph/access.js +3 -3
- package/dist/core/graph/custom.d.ts +16 -16
- package/dist/core/graph/custom.js +9 -9
- package/dist/core/graph/deletion.d.ts +3 -7
- package/dist/core/graph/deletion.js +4 -4
- package/dist/core/graph/documents.d.ts +24 -27
- package/dist/core/graph/documents.js +7 -7
- package/dist/core/graph/edges.d.ts +13 -13
- package/dist/core/graph/edges.js +1 -1
- package/dist/core/graph/events.d.ts +7 -9
- package/dist/core/graph/events.js +8 -8
- package/dist/core/graph/exposures.d.ts +6 -6
- package/dist/core/graph/exposures.js +4 -4
- package/dist/core/graph/jobs.d.ts +6 -8
- package/dist/core/graph/jobs.js +2 -2
- package/dist/core/graph/kinds/action.js +1 -1
- package/dist/core/graph/kinds/custom.js +2 -2
- package/dist/core/graph/kinds/document.d.ts +1 -0
- package/dist/core/graph/kinds/document.js +4 -4
- package/dist/core/graph/kinds/dto.d.ts +2 -2
- package/dist/core/graph/kinds/dto.js +1 -1
- package/dist/core/graph/kinds/job.js +2 -2
- package/dist/core/graph/kinds/kind.d.ts +6 -8
- package/dist/core/graph/kinds/kind.js +1 -1
- package/dist/core/graph/kinds/node.js +5 -5
- package/dist/core/graph/kinds/owner.js +2 -2
- package/dist/core/graph/kinds/registry.d.ts +6 -9
- package/dist/core/graph/kinds/registry.js +1 -1
- package/dist/core/graph/names.d.ts +6 -6
- package/dist/core/graph/names.js +3 -3
- package/dist/core/graph/object-waits.d.ts +4 -7
- package/dist/core/graph/object-waits.js +1 -1
- package/dist/core/graph/objects.d.ts +14 -14
- package/dist/core/graph/objects.js +9 -9
- package/dist/core/graph/package-docs.d.ts +2 -7
- package/dist/core/graph/package-docs.js +5 -5
- package/dist/core/graph/package-kinds.d.ts +2 -5
- package/dist/core/graph/package-kinds.js +1 -1
- package/dist/core/graph/package-reconcile.d.ts +2 -5
- package/dist/core/graph/package-reconcile.js +1 -1
- package/dist/core/graph/reader.d.ts +18 -18
- package/dist/core/graph/reader.js +3 -3
- package/dist/core/graph/receivers.d.ts +4 -4
- package/dist/core/graph/receivers.js +5 -5
- package/dist/core/graph/repo-sync/exchange.d.ts +3 -7
- package/dist/core/graph/repo-sync/exchange.js +2 -2
- package/dist/core/graph/repo-sync/repos.d.ts +7 -5
- package/dist/core/graph/repo-sync/repos.js +3 -3
- package/dist/core/graph/repo-sync/sync.d.ts +3 -6
- package/dist/core/graph/repo-sync/sync.js +2 -2
- package/dist/core/graph/rules.d.ts +5 -5
- package/dist/core/graph/rules.js +3 -3
- package/dist/core/graph/spaces/app.js +1 -1
- package/dist/core/graph/spaces/index.d.ts +4 -5
- package/dist/core/graph/spaces/index.js +1 -1
- package/dist/core/graph/spaces/own-memory.d.ts +4 -4
- package/dist/core/graph/spaces/own-memory.js +1 -1
- package/dist/core/graph/spaces/person.js +3 -3
- package/dist/core/graph/spaces/repo.d.ts +1 -1
- package/dist/core/graph/spaces/repo.js +1 -1
- package/dist/core/graph/watches.d.ts +15 -15
- package/dist/core/graph/watches.js +10 -10
- package/dist/core/human/feedback-companion.d.ts +2 -2
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/feedback.d.ts +3 -3
- package/dist/core/human/feedback.js +1 -1
- package/dist/core/human/requests.d.ts +34 -33
- package/dist/core/human/requests.js +20 -20
- package/dist/core/human/scan.d.ts +2 -2
- package/dist/core/human/scan.js +1 -1
- package/dist/core/human/tickets.d.ts +9 -9
- package/dist/core/human/tickets.js +1 -1
- package/dist/core/llm/app-rungs.d.ts +1 -1
- package/dist/core/llm/app-rungs.js +1 -1
- package/dist/core/llm/run.js +1 -1
- package/dist/core/peer/directory.d.ts +1 -1
- package/dist/core/peer/directory.js +1 -1
- package/dist/core/peer/envelope.d.ts +3 -3
- package/dist/core/peer/envelope.js +1 -1
- package/dist/core/peer/home.d.ts +7 -7
- package/dist/core/peer/home.js +2 -2
- package/dist/core/peer/ingest.d.ts +6 -6
- package/dist/core/peer/ingest.js +1 -1
- package/dist/core/peer/outbox-store.d.ts +14 -14
- package/dist/core/peer/outbox-store.js +5 -5
- package/dist/core/peer/receiver.d.ts +2 -2
- package/dist/core/peer/receiver.js +1 -1
- package/dist/core/peer/stubs.d.ts +10 -10
- package/dist/core/peer/stubs.js +1 -1
- package/dist/core/providers/approval.d.ts +2 -2
- package/dist/core/providers/approval.js +2 -2
- package/dist/core/providers/audit.d.ts +3 -3
- package/dist/core/providers/audit.js +2 -2
- package/dist/core/providers/bundles.js +2 -2
- package/dist/core/providers/call.d.ts +2 -2
- package/dist/core/providers/call.js +1 -1
- package/dist/core/providers/files.d.ts +1 -1
- package/dist/core/providers/files.js +1 -1
- package/dist/core/providers/mint.js +1 -1
- package/dist/core/providers/receipts.d.ts +1 -1
- package/dist/core/providers/receipts.js +2 -2
- package/dist/core/review/birth.js +1 -1
- package/dist/core/review/comments.d.ts +19 -19
- package/dist/core/review/comments.js +5 -5
- package/dist/core/review/companion.d.ts +1 -1
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/document.d.ts +3 -3
- package/dist/core/review/document.js +2 -2
- package/dist/core/review/fork.js +2 -2
- package/dist/core/review/realize.js +1 -1
- package/dist/core/review/remap.d.ts +2 -2
- package/dist/core/review/remap.js +4 -4
- package/dist/core/review/stage.d.ts +1 -1
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/store.d.ts +21 -21
- package/dist/core/review/store.js +1 -1
- package/dist/core/runs/activity.d.ts +1 -1
- package/dist/core/runs/activity.js +5 -5
- package/dist/core/runs/confinement.d.ts +7 -7
- package/dist/core/runs/confinement.js +2 -2
- package/dist/core/runs/events.d.ts +12 -12
- package/dist/core/runs/events.js +4 -4
- package/dist/core/runs/operations.d.ts +11 -11
- package/dist/core/runs/operations.js +5 -5
- package/dist/core/runs/questions.d.ts +10 -10
- package/dist/core/runs/questions.js +3 -3
- package/dist/core/runtime/auth-reload.js +1 -1
- package/dist/core/runtime/bearings.d.ts +5 -5
- package/dist/core/runtime/bearings.js +6 -6
- package/dist/core/runtime/broker-inventory.js +1 -1
- package/dist/core/runtime/broker-request.js +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/close.d.ts +3 -3
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/fleet.d.ts +2 -2
- package/dist/core/runtime/host.d.ts +3 -3
- package/dist/core/runtime/host.js +3 -3
- package/dist/core/runtime/kickoff.d.ts +12 -12
- package/dist/core/runtime/kickoff.js +17 -17
- package/dist/core/runtime/launch-target.d.ts +1 -1
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/ledger.d.ts +3 -3
- package/dist/core/runtime/ledger.js +3 -3
- package/dist/core/runtime/lifecycle.d.ts +1 -1
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/memory-admission.js +1 -1
- package/dist/core/runtime/model-swap.d.ts +2 -2
- package/dist/core/runtime/model-swap.js +1 -1
- package/dist/core/runtime/node-read.d.ts +1 -1
- package/dist/core/runtime/node-read.js +2 -2
- package/dist/core/runtime/nodes.d.ts +6 -6
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/outcome-document.d.ts +1 -1
- package/dist/core/runtime/outcome-document.js +1 -1
- package/dist/core/runtime/persona.d.ts +3 -3
- package/dist/core/runtime/persona.js +2 -2
- package/dist/core/runtime/placement.d.ts +11 -11
- package/dist/core/runtime/placement.js +1 -1
- package/dist/core/runtime/promote.d.ts +3 -3
- package/dist/core/runtime/promote.js +1 -1
- package/dist/core/runtime/recycle.js +1 -1
- package/dist/core/runtime/reopen.d.ts +5 -5
- package/dist/core/runtime/reopen.js +1 -1
- package/dist/core/runtime/reset.d.ts +4 -4
- package/dist/core/runtime/reset.js +1 -1
- package/dist/core/runtime/revive-all.d.ts +2 -2
- package/dist/core/runtime/revive-all.js +1 -1
- package/dist/core/runtime/revive.d.ts +4 -4
- package/dist/core/runtime/revive.js +2 -2
- package/dist/core/runtime/roadmap.d.ts +6 -6
- package/dist/core/runtime/roadmap.js +5 -5
- package/dist/core/runtime/session-branch.d.ts +1 -1
- package/dist/core/runtime/session-branch.js +1 -1
- package/dist/core/runtime/session-list-cache.js +1 -1
- package/dist/core/runtime/situational-live.js +1 -1
- package/dist/core/runtime/spawn.d.ts +2 -2
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/runtime/stop-guard.d.ts +2 -2
- package/dist/core/runtime/stop-guard.js +3 -3
- package/dist/core/runtime/warm-pool.d.ts +2 -2
- package/dist/core/runtime/warm-pool.js +1 -1
- package/dist/core/spaces/mounts.d.ts +2 -2
- package/dist/core/spaces/mounts.js +1 -1
- package/dist/core/spaces/permissions.d.ts +1 -1
- package/dist/core/spaces/permissions.js +1 -1
- package/dist/core/spaces/process.d.ts +1 -1
- package/dist/core/spaces/process.js +1 -1
- package/dist/core/spaces/space.js +1 -1
- package/dist/core/spaces/stop.d.ts +3 -3
- package/dist/core/spaces/stop.js +2 -2
- package/dist/core/spaces/users.d.ts +6 -6
- package/dist/core/spaces/users.js +1 -1
- package/dist/core/storage/attachments.d.ts +2 -2
- package/dist/core/storage/attachments.js +1 -1
- package/dist/core/storage/shares.d.ts +2 -2
- package/dist/core/storage/shares.js +1 -1
- package/dist/core/storage/tables.d.ts +21 -21
- package/dist/core/storage/tables.js +3 -3
- package/dist/core/substrate/delivery/corpus.d.ts +5 -8
- package/dist/core/substrate/delivery/corpus.js +3 -3
- package/dist/core/substrate/delivery/deliver.d.ts +10 -15
- package/dist/core/substrate/delivery/deliver.js +3 -3
- package/dist/core/substrate/delivery/plan.d.ts +2 -12
- package/dist/core/substrate/delivery/plan.js +3 -3
- package/dist/core/substrate/delivery/render-boot.d.ts +4 -4
- package/dist/core/substrate/delivery/render-boot.js +18 -18
- package/dist/core/substrate/delivery/render-event.d.ts +7 -14
- package/dist/core/substrate/delivery/render-event.js +4 -4
- package/dist/core/substrate/subject.d.ts +2 -2
- package/dist/core/substrate/subject.js +1 -1
- package/dist/core/usage/ledger.d.ts +6 -6
- package/dist/core/usage/ledger.js +4 -4
- package/dist/core/worktree-close.js +4 -4
- package/dist/core/worktree-mutation-async.js +7 -7
- package/dist/core/worktree-quarantine.js +1 -1
- package/dist/core/worktree-sweep.d.ts +1 -1
- package/dist/core/worktree-sweep.js +6 -6
- package/dist/core/worktree.d.ts +5 -5
- package/dist/core/worktree.js +13 -13
- package/dist/daemon/analytics/compute.d.ts +2 -2
- package/dist/daemon/analytics/compute.js +1 -1
- package/dist/daemon/api/app-listener.d.ts +4 -4
- package/dist/daemon/api/app-listener.js +13 -13
- package/dist/daemon/api/bridge.js +5 -5
- package/dist/daemon/api/document-listener.js +6 -6
- package/dist/daemon/api/handlers/analytics.js +1 -1
- package/dist/daemon/api/handlers/attach.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +1 -1
- package/dist/daemon/api/handlers/bash.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.d.ts +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/broker-recovery.d.ts +1 -1
- package/dist/daemon/api/handlers/broker-recovery.js +1 -1
- package/dist/daemon/api/handlers/broker-signals.d.ts +2 -2
- package/dist/daemon/api/handlers/broker-signals.js +2 -2
- package/dist/daemon/api/handlers/canvas.d.ts +1 -1
- package/dist/daemon/api/handlers/canvas.js +4 -4
- package/dist/daemon/api/handlers/chat-inventory.js +1 -1
- package/dist/daemon/api/handlers/crons.js +1 -1
- package/dist/daemon/api/handlers/custom-objects.d.ts +4 -4
- package/dist/daemon/api/handlers/custom-objects.js +3 -3
- package/dist/daemon/api/handlers/delivery-retry.js +1 -1
- package/dist/daemon/api/handlers/delivery.js +1 -1
- package/dist/daemon/api/handlers/docs.d.ts +4 -4
- package/dist/daemon/api/handlers/docs.js +1 -1
- package/dist/daemon/api/handlers/feedback-comments.js +3 -3
- package/dist/daemon/api/handlers/files.js +1 -1
- package/dist/daemon/api/handlers/focus.js +1 -1
- package/dist/daemon/api/handlers/health.js +3 -3
- package/dist/daemon/api/handlers/hook-exec.js +1 -1
- package/dist/daemon/api/handlers/human-requests.js +1 -1
- package/dist/daemon/api/handlers/inbox-page.d.ts +1 -1
- package/dist/daemon/api/handlers/inbox-page.js +1 -1
- package/dist/daemon/api/handlers/inbox.d.ts +1 -1
- package/dist/daemon/api/handlers/inbox.js +1 -1
- package/dist/daemon/api/handlers/llm.d.ts +1 -1
- package/dist/daemon/api/handlers/llm.js +3 -3
- package/dist/daemon/api/handlers/memory-reads.js +1 -1
- package/dist/daemon/api/handlers/memory.d.ts +5 -5
- package/dist/daemon/api/handlers/memory.js +5 -5
- package/dist/daemon/api/handlers/messages.js +2 -2
- package/dist/daemon/api/handlers/node-events.d.ts +2 -2
- package/dist/daemon/api/handlers/node-events.js +3 -3
- package/dist/daemon/api/handlers/node-outcomes.js +1 -1
- package/dist/daemon/api/handlers/node-records.js +2 -2
- package/dist/daemon/api/handlers/nodes.d.ts +1 -1
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/objects.js +3 -3
- package/dist/daemon/api/handlers/package-docs.js +1 -1
- package/dist/daemon/api/handlers/plugin-app-token.d.ts +1 -1
- package/dist/daemon/api/handlers/plugin-app-token.js +1 -1
- package/dist/daemon/api/handlers/profiles.d.ts +3 -3
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/providers.d.ts +1 -1
- package/dist/daemon/api/handlers/providers.js +1 -1
- package/dist/daemon/api/handlers/questions.js +1 -1
- package/dist/daemon/api/handlers/reports.d.ts +1 -1
- package/dist/daemon/api/handlers/reports.js +5 -5
- package/dist/daemon/api/handlers/review-comments.js +1 -1
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/handlers/runs.js +1 -1
- package/dist/daemon/api/handlers/structured-requests.js +1 -1
- package/dist/daemon/api/handlers/subscriptions.js +1 -1
- package/dist/daemon/api/handlers/transfer.js +1 -1
- package/dist/daemon/api/map.d.ts +3 -3
- package/dist/daemon/api/map.js +1 -1
- package/dist/daemon/api/principal.d.ts +1 -1
- package/dist/daemon/api/principal.js +1 -1
- package/dist/daemon/api/reader.d.ts +5 -5
- package/dist/daemon/api/reader.js +1 -1
- package/dist/daemon/api/router.d.ts +5 -5
- package/dist/daemon/api/router.js +1 -1
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/broker-signals/bus.d.ts +1 -1
- package/dist/daemon/broker-signals/bus.js +1 -1
- package/dist/daemon/companion-retire.js +1 -1
- package/dist/daemon/cron/armed-context.d.ts +2 -2
- package/dist/daemon/cron/armed-context.js +1 -1
- package/dist/daemon/cron/authority.d.ts +2 -2
- package/dist/daemon/cron/authority.js +1 -1
- package/dist/daemon/cron/disposition.js +1 -1
- package/dist/daemon/cron/ended.d.ts +1 -1
- package/dist/daemon/cron/ended.js +2 -2
- package/dist/daemon/cron/escalation.js +3 -3
- package/dist/daemon/cron/folders.d.ts +1 -1
- package/dist/daemon/cron/folders.js +1 -1
- package/dist/daemon/cron/held.d.ts +1 -1
- package/dist/daemon/cron/held.js +1 -1
- package/dist/daemon/cron/lease-recovery.d.ts +1 -1
- package/dist/daemon/cron/lease-recovery.js +1 -1
- package/dist/daemon/cron/passes.d.ts +2 -2
- package/dist/daemon/cron/passes.js +1 -1
- package/dist/daemon/cron/run-socket.d.ts +1 -1
- package/dist/daemon/cron/run-socket.js +1 -1
- package/dist/daemon/cron/settle.js +1 -1
- package/dist/daemon/cron/sinks.d.ts +1 -1
- package/dist/daemon/cron/sinks.js +2 -2
- package/dist/daemon/cron-run.d.ts +12 -3
- package/dist/daemon/cron-run.js +2 -2
- package/dist/daemon/crtrd.js +6 -6
- package/dist/daemon/delivery/run-delivery.js +1 -1
- package/dist/daemon/due-sources.d.ts +3 -3
- package/dist/daemon/due-sources.js +1 -1
- package/dist/daemon/due.d.ts +3 -3
- package/dist/daemon/due.js +7 -7
- package/dist/daemon/fleet.d.ts +2 -2
- package/dist/daemon/fleet.js +11 -11
- package/dist/daemon/human/finish.js +3 -3
- package/dist/daemon/human/settle.d.ts +1 -1
- package/dist/daemon/human/settle.js +1 -1
- package/dist/daemon/human/sweep.js +1 -1
- package/dist/daemon/joined-owner.d.ts +2 -2
- package/dist/daemon/joined-owner.js +1 -1
- package/dist/daemon/messaging/node-message.js +1 -1
- package/dist/daemon/park-activity.d.ts +2 -2
- package/dist/daemon/park-activity.js +1 -1
- package/dist/daemon/peer/authority.js +1 -1
- package/dist/daemon/peer/forward.d.ts +6 -6
- package/dist/daemon/peer/forward.js +1 -1
- package/dist/daemon/peer/handlers.js +1 -1
- package/dist/daemon/peer/ingress.d.ts +4 -4
- package/dist/daemon/peer/ingress.js +1 -1
- package/dist/daemon/peer/outbox.d.ts +2 -2
- package/dist/daemon/peer/outbox.js +1 -1
- package/dist/daemon/peer/relay-service.js +1 -1
- package/dist/daemon/plugin-objects/read-leaf.d.ts +2 -2
- package/dist/daemon/plugin-objects/read-leaf.js +2 -2
- package/dist/daemon/profile-delete.js +1 -1
- package/dist/daemon/readiness.d.ts +2 -2
- package/dist/daemon/readiness.js +1 -1
- package/dist/daemon/reconcilers/action-lane.d.ts +1 -1
- package/dist/daemon/reconcilers/action-lane.js +1 -1
- package/dist/daemon/reconcilers/bash-deadline.js +2 -2
- package/dist/daemon/reconcilers/broker-supervision.d.ts +1 -1
- package/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/dist/daemon/reconcilers/controller-death.d.ts +1 -1
- package/dist/daemon/reconcilers/controller-death.js +1 -1
- package/dist/daemon/reconcilers/cron-lane.d.ts +1 -1
- package/dist/daemon/reconcilers/cron-lane.js +1 -1
- package/dist/daemon/reconcilers/delivery-lane.d.ts +1 -1
- package/dist/daemon/reconcilers/delivery-lane.js +2 -2
- package/dist/daemon/reconcilers/fault-retry-backstop.d.ts +3 -3
- package/dist/daemon/reconcilers/fault-retry-backstop.js +1 -1
- package/dist/daemon/reconcilers/grove-instance-sweep.d.ts +2 -2
- package/dist/daemon/reconcilers/grove-instance-sweep.js +1 -1
- package/dist/daemon/reconcilers/live-obligation.d.ts +6 -6
- package/dist/daemon/reconcilers/live-obligation.js +1 -1
- package/dist/daemon/reconcilers/managed-worktree-sweep.js +1 -1
- package/dist/daemon/reconcilers/node-deadline.d.ts +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/node-lifecycle/respawn-policy.d.ts +3 -3
- package/dist/daemon/reconcilers/node-lifecycle/respawn-policy.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/terminating.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/wants-execution.d.ts +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/wants-execution.js +1 -1
- package/dist/daemon/reconcilers/pending-review-submit.d.ts +1 -1
- package/dist/daemon/reconcilers/pending-review-submit.js +1 -1
- package/dist/daemon/reconcilers/storage-due-work.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.js +2 -2
- package/dist/daemon/reconcilers/structured-request-lane.d.ts +1 -1
- package/dist/daemon/reconcilers/structured-request-lane.js +1 -1
- package/dist/daemon/review/comment-notify.js +2 -2
- package/dist/daemon/review/companion.d.ts +3 -3
- package/dist/daemon/review/companion.js +1 -1
- package/dist/daemon/review/finish.js +1 -1
- package/dist/daemon/review/sweep.js +1 -1
- package/dist/daemon/run-notices.d.ts +4 -4
- package/dist/daemon/run-notices.js +1 -1
- package/dist/daemon/runs/append-section.d.ts +2 -2
- package/dist/daemon/runs/append-section.js +2 -2
- package/dist/daemon/runs/observer.d.ts +2 -2
- package/dist/daemon/runs/observer.js +2 -2
- package/dist/daemon/structured-requests/boot.d.ts +1 -1
- package/dist/daemon/structured-requests/boot.js +1 -1
- package/dist/daemon/structured-requests/effects.js +1 -1
- package/dist/daemon/structured-requests/sidecar.d.ts +1 -1
- package/dist/daemon/structured-requests/sidecar.js +1 -1
- package/dist/migrations/004-canvas-documents/apply.d.ts +3 -3
- package/dist/migrations/004-canvas-documents/apply.js +1 -1
- package/dist/migrations/004-canvas-documents/index.d.ts +2 -2
- package/dist/migrations/004-canvas-documents/index.js +2 -2
- package/dist/migrations/activation.js +2 -2
- package/docs/public-api.md +11 -0
- package/package.json +3 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=Object.defineProperty;var n=(e,o)=>u(e,"name",{value:o,configurable:!0});import{existsSync as c}from"node:fs";import{getNode as
|
|
1
|
+
var u=Object.defineProperty;var n=(e,o)=>u(e,"name",{value:o,configurable:!0});import{existsSync as c}from"node:fs";import{getNode as a,updateNode as s}from"../canvas/index.js";import{viewSocketPath as f}from"../canvas/paths.js";import{isPidAlive as p}from"../canvas/pid.js";import{oneShotControllerRequest as _}from"./broker-request.js";function M(e){return p(e.pi_pid)&&c(f(e.node_id))}n(M,"isBrokerLive");function g(e,o,t){let d;return _({nodeId:e,what:"the model switch",ackFor:"set_model",frame:n(()=>({type:"set_model",model:o,...t!==void 0?{intent:t}:{}}),"frame"),observe:n(r=>{r.type==="model_changed"&&r.spec!==null&&(d=r.spec)},"observe"),result:n(()=>d??o,"result")})}n(g,"setModelLive");async function v(e,o,t,d){const r=e.launch===void 0?void 0:d?(()=>{const{modelIntent:h,modelExact:E,env:m,...i}=e.launch,{CRTR_MODEL_INTENT:x,...l}=m;return t!==void 0?{...i,model:o,modelIntent:t,env:{...l,CRTR_MODEL_INTENT:`${t.family}/${t.strength}`}}:{...i,model:o,modelExact:!0,env:l}})():{...e.launch,model:o};return await s(e.node_id,{model_override:o,...r!==void 0?{launch:r}:{}})}n(v,"updateModelRecipe");async function L(e,o,t){const d=await a(e);d!==null&&await v(d,o,t,!0)}n(L,"persistDormantModel");export{M as isBrokerLive,L as persistDormantModel,g as setModelLive,v as updateModelRecipe};
|
|
@@ -18,7 +18,7 @@ export interface NodeSessionRead {
|
|
|
18
18
|
* per boot), so it is read from the sidecar the broker captures on every
|
|
19
19
|
* rebind (`<jobDir>/system-prompt.md`), falling back to the one `launch.ts`
|
|
20
20
|
* writes at spawn (`<nodeDir>/system-prompt.md`). */
|
|
21
|
-
export declare function readNodeSession(nodeId: string): NodeSessionRead
|
|
21
|
+
export declare function readNodeSession(nodeId: string): Promise<NodeSessionRead>;
|
|
22
22
|
export interface NodeSnapshotRead {
|
|
23
23
|
nodeId: string;
|
|
24
24
|
snapshot: BrokerSnapshot;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var C=Object.defineProperty;var a=(e,t)=>C(e,"name",{value:t,configurable:!0});import{existsSync as N,readFileSync as j}from"node:fs";import{isBeneathRefusal as F,readFileBeneath as $,readTextBeneathIfExists as x}from"../spaces/open-beneath.js";import{join as p}from"node:path";import{InputError as
|
|
2
|
-
`).join("")})(),systemPrompt:M(e,p(S(e),"system-prompt.md"))??M(e,p(h(e),"system-prompt.md"))}}a(ge,"readNodeSession");function M(e,t){try{return $(h(e),t).toString("utf8")}catch(o){if(F(o))throw o;return null}}a(M,"readRunFileIfPresent");function G(e){try{const t=x(h(e),p(S(e),"tool-summaries.json"));return E(t===null?null:JSON.parse(t))}catch{return{}}}a(G,"readToolGroupSummaries");function q(e){try{const t=x(h(e),p(S(e),"turn-replies.json"));return U(t===null?null:JSON.parse(t))}catch{return{}}}a(q,"readTurnReplies");async function R(e){const t=g(e);if(t===null)throw new
|
|
1
|
+
var C=Object.defineProperty;var a=(e,t)=>C(e,"name",{value:t,configurable:!0});import{existsSync as N,readFileSync as j}from"node:fs";import{isBeneathRefusal as F,readFileBeneath as $,readTextBeneathIfExists as x}from"../spaces/open-beneath.js";import{join as p}from"node:path";import{InputError as c}from"../io.js";import{conversationIdFromPath as y,conversationStore as w,ConversationNotFoundError as A}from"../conversation-store/index.js";import{fullName as T,getNode as g}from"../canvas/index.js";import{nodeRunDir as h,nodeRunJobDir as S,sessionPtrPath as k}from"../canvas/paths.js";import{hydratePersistedAdvertisedCommandMessages as v}from"./advertised-command-invocation.js";import{SessionManager as L}from"./broker-sdk.js";import{openModelRegistry as P}from"./model-registry.js";import{BUILTIN_SLASH_COMMANDS as B}from"./pi-vendored.js";import{cycleAwareMessages as J}from"./session-cycles.js";import{projectTranscript as O}from"./session-visibility.js";import{normalizeToolGroupSummaryRecord as E}from"../../shared/tool-groups.js";import{normalizeTurnReplyRecord as U}from"../../shared/turn-replies.js";async function V(e){if(e!==null)try{return(await P()).find(e.provider,e.modelId)}catch{return}}a(V,"resolveRecordedModel");async function b(e,t){const o=a(async i=>{const n=i?y(i):null;if(n===null)return null;try{return(await w().header(n)).path}catch(l){if(l instanceof A)return null;throw l}},"resolvePath"),s=await o(t);if(s!==null)return s;const r=k(e);return N(r)?await o(j(r,"utf8").trim()):null}a(b,"resolveSessionFile");async function W(e){const t=await g(e);if(t===null)throw new c({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});return await b(e,t.pi_session_file)}a(W,"readableSessionFile");function z(e,t){return{sessionFile:t,sessionId:e,userMessages:0,assistantMessages:0,toolCalls:0,toolResults:0,totalMessages:0,tokens:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},cost:0}}a(z,"emptyStats");function D(e,t,o){const s=z(t,o);s.totalMessages=e.length;for(const r of e)if(r.role==="user")s.userMessages++;else if(r.role==="assistant"){s.assistantMessages++;const i=Array.isArray(r.content)?r.content:[];s.toolCalls+=i.filter(l=>l!==null&&typeof l=="object"&&l.type==="toolCall").length;const n=r.usage;n!==void 0&&(s.tokens.input+=n.input??0,s.tokens.output+=n.output??0,s.tokens.cacheRead+=n.cacheRead??0,s.tokens.cacheWrite+=n.cacheWrite??0,s.cost+=n.cost?.total??0)}else r.role==="toolResult"&&s.toolResults++;return s.tokens.total=s.tokens.input+s.tokens.output+s.tokens.cacheRead+s.tokens.cacheWrite,s}a(D,"statsFromMessages");async function ge(e){const t=await g(e);if(t===null)throw new c({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});const o=await b(e,t.pi_session_file);if(o===null)throw new c({error:"no_session",message:`node has no readable session file: ${e}`,field:"id",next:"Choose a node with captured conversation history."});return{nodeId:e,sessionFile:o,sessionJsonl:await(async()=>{const{header:s,entries:r}=await w().read(y(o));return[s,...r].map(i=>`${JSON.stringify(i)}
|
|
2
|
+
`).join("")})(),systemPrompt:M(e,p(S(e),"system-prompt.md"))??M(e,p(h(e),"system-prompt.md"))}}a(ge,"readNodeSession");function M(e,t){try{return $(h(e),t).toString("utf8")}catch(o){if(F(o))throw o;return null}}a(M,"readRunFileIfPresent");function G(e){try{const t=x(h(e),p(S(e),"tool-summaries.json"));return E(t===null?null:JSON.parse(t))}catch{return{}}}a(G,"readToolGroupSummaries");function q(e){try{const t=x(h(e),p(S(e),"turn-replies.json"));return U(t===null?null:JSON.parse(t))}catch{return{}}}a(q,"readTurnReplies");async function R(e){const t=await g(e);if(t===null)throw new c({error:"not_found",message:`no node: ${e}`,field:"id",next:"List nodes with `crtr node inspect list`."});const o=await b(e,t.pi_session_file);if(o===null)throw new c({error:"no_session",message:`node has no readable session file: ${e}`,field:"id",next:"Choose a node with captured conversation history."});const{header:s,entries:r}=await w().read(y(o)),i=L.inMemory(s.cwd,void 0,[s,...r]),n=i.buildSessionContext();v(n.messages);const l=J(i);l!==void 0&&v(l.map(({message:f})=>f));const u=l===void 0?void 0:O(l,{boundaryReviewId:t.review_binding?.review_id,sessionEntries:i.getEntries()}),m=u?.map(({message:f})=>f)??n.messages;return{sessionFile:o,messages:m,identified:u,model:n.model,thinkingLevel:n.thinkingLevel,sessionId:i.getSessionId(),sessionName:i.getSessionName()}}a(R,"reconstructTranscript");function d(){throw new c({error:"invalid_cursor",message:"cursor must be a base64url-encoded messages cursor.",field:"cursor",next:"Omit cursor to start from the newest messages."})}a(d,"invalidCursor");function H(e,t){/^[A-Za-z0-9_-]+$/u.test(e)||d();let o;try{const r=Buffer.from(e,"base64url").toString("utf8");Buffer.from(r,"utf8").toString("base64url")!==e&&d(),o=JSON.parse(r)}catch{d()}(typeof o!="object"||o===null||o.v!==1||!Number.isSafeInteger(o.before))&&d();const s=o.before;return(s<0||s>t)&&d(),s}a(H,"decodeMessagesCursor");function Y(e){return Buffer.from(JSON.stringify({v:1,before:e}),"utf8").toString("base64url")}a(Y,"encodeMessagesCursor");async function Z(e){const t=await R(e),o={messages:t.messages,...t.identified===void 0?{}:{messageIds:t.identified.map(({id:s})=>s)},messageVisibility:t.identified?.map(({visibility:s})=>s)??t.messages.map(()=>"visible"),turnVisibility:"visible",stats:D(t.messages,t.sessionId,t.sessionFile),state:{model:await V(t.model),thinkingLevel:t.thinkingLevel,isStreaming:!1,isCompacting:!1,steeringMode:"one-at-a-time",followUpMode:"one-at-a-time",sessionFile:t.sessionFile,sessionId:t.sessionId,sessionName:t.sessionName,autoCompactionEnabled:!0,messageCount:t.messages.length,pendingMessageCount:0},display:{statuses:{},widgets:{},title:void 0},queued:{steering:[],followUp:[]},toolGroupSummaries:G(e),turnReplies:q(e)};return{nodeId:e,snapshot:o,commands:B.map(s=>({...s,source:"builtin"}))}}a(Z,"readNodeSnapshot");async function he(e,{cursor:t,limit:o=200}){if(!Number.isSafeInteger(o)||o<1||o>500)throw new c({error:"invalid_limit",message:"limit must be an integer from 1 through 500.",field:"limit",next:"Use a limit from 1 through 500."});if(await W(e)===null)return{messages:[],messageIds:[],messageVisibility:[],nextCursor:null};const{messages:s,identified:r}=await R(e),i=t===void 0?s.length:H(t,s.length);let n=Math.max(0,i-o);for(;n>0&&typeof s[n]=="object"&&s[n]!==null&&s[n].role==="toolResult";)n--;const l=r?.slice(n,i);return{messages:l?.map(({message:u})=>u)??s.slice(n,i),...l===void 0?{}:{messageIds:l.map(({id:u})=>u)},messageVisibility:l?.map(({visibility:u})=>u)??s.slice(n,i).map(()=>"visible"),nextCursor:n===0?null:Y(n)}}a(he,"readNodeMessagesPage");function K(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null).filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(""):""}a(K,"textFromContent");function Q(e){switch(e.role){case"user":return"You";case"assistant":return"Agent";case"toolResult":return"Tool result";default:return typeof e.role=="string"?e.role:"Message"}}a(Q,"roleLabel");function X(e){return Array.isArray(e.content)?e.content.filter(t=>typeof t=="object"&&t!==null&&t.type==="toolCall").map(t=>`Tool: ${typeof t.name=="string"?t.name:"call"}`):[]}a(X,"toolSummaries");async function ye(e){const t=await g(e);if(t===null)throw new c({error:"not_found",message:`no node: ${e}`,field:"node-id",next:"List nodes with `crtr node inspect list`."});const{snapshot:o}=await Z(e),r=[`# ${T(t)}`,"",`Saved transcript \xB7 ${t.status} \xB7 ${t.lifecycle}`,""];for(const i of o.messages){if(typeof i!="object"||i===null)continue;const n=i;if(n.role==="custom"&&n.display===!1)continue;const l=K(n.content),u=typeof n.text=="string"?n.text:"",m=l.trim()?l:u.trim()?u:"",f=X(n);if(!(!m&&f.length===0)){r.push(`## ${Q(n)}`,""),m&&r.push(m,"");for(const _ of f)r.push(`- ${_}`);f.length&&r.push("")}}return r.length===5&&r.push("_No saved messages._",""),r.join(`
|
|
3
3
|
`)}a(ye,"transcriptMarkdown");export{he as readNodeMessagesPage,ge as readNodeSession,Z as readNodeSnapshot,ye as transcriptMarkdown};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DatabaseSync } from 'node:sqlite';
|
|
2
1
|
import { type NodeMeta, type Mode, type Lifecycle, type LaunchSpec, type ManagedWorktree, type OutcomeDeliveryBinding, type ReviewBinding } from '../canvas/index.js';
|
|
2
|
+
import type { CanvasDb } from '../canvas/db.js';
|
|
3
3
|
/** Explicitly set the resolved install id. crtrd calls this once at boot,
|
|
4
4
|
* immediately after `resolveInstallId()` — see crtrd.ts — so a provisioning
|
|
5
5
|
* mismatch fails the daemon loudly at STARTUP rather than lazily on first
|
|
@@ -15,7 +15,7 @@ export declare function newJobId(): string;
|
|
|
15
15
|
* minted node id is a globally-unique NAME that also names the canvas that
|
|
16
16
|
* minted it (see the unified-chat/addressing design's "ID scheme"). crtrd is
|
|
17
17
|
* the sole node minter. */
|
|
18
|
-
export declare function newNodeId(): string
|
|
18
|
+
export declare function newNodeId(): Promise<string>;
|
|
19
19
|
/** Thrown when a caller-specified `--node-id` (or its API twin `node_id`)
|
|
20
20
|
* already names a live node. Distinguishable from every other spawn failure
|
|
21
21
|
* so a caller can treat it as "attach instead of create" per the unified
|
|
@@ -32,13 +32,13 @@ export declare class NodeIdConflictError extends Error {
|
|
|
32
32
|
* valid); the duplicate check is advisory only — a concurrent create can
|
|
33
33
|
* still win the race between this check and the synchronous check-then-
|
|
34
34
|
* create below, which remains the SOLE authoritative decider. */
|
|
35
|
-
export declare function preflightNodeId(nodeId: string): void
|
|
35
|
+
export declare function preflightNodeId(nodeId: string): Promise<void>;
|
|
36
36
|
/** The root of a node's spine: walk the `parent` column up to `parent == null`.
|
|
37
37
|
* Cycle-guarded (parents must not cycle, but never loop forever). Lives in the
|
|
38
38
|
* node layer (not placement) so the env-builder and placement both reach it
|
|
39
39
|
* without an import cycle — `CRTR_SUBTREE` is emitted as `rootOfSpine(nodeId)`
|
|
40
40
|
* at every launch site. */
|
|
41
|
-
export declare function rootOfSpine(nodeId: string): string
|
|
41
|
+
export declare function rootOfSpine(nodeId: string): Promise<string>;
|
|
42
42
|
export interface NodeContext {
|
|
43
43
|
nodeId: string | null;
|
|
44
44
|
kind: string | null;
|
|
@@ -111,7 +111,7 @@ export interface SpawnNodeOpts {
|
|
|
111
111
|
/** Run identity set on an app root; managed children inherit it. */
|
|
112
112
|
run?: Pick<NodeMeta, 'grantee' | 'sub' | 'grant_id' | 'client_id' | 'metadata_json' | 'run_id' | 'event_cursor' | 'usage_json'>;
|
|
113
113
|
/** Additional rows committed atomically with the newborn node. */
|
|
114
|
-
withinCreate?: (db:
|
|
114
|
+
withinCreate?: (db: CanvasDb, row: NodeMeta) => Promise<void> | void;
|
|
115
115
|
/** Managed worktree already created for this node, if any. */
|
|
116
116
|
managedWorktree?: ManagedWorktree;
|
|
117
117
|
/** Absolute wall-clock deadline persisted with the row at birth. */
|
|
@@ -129,7 +129,7 @@ export interface SpawnNodeOpts {
|
|
|
129
129
|
nodeId?: string;
|
|
130
130
|
}
|
|
131
131
|
/** The node that owns the conversation a fork copies, or null when no node does. */
|
|
132
|
-
export declare function forkSourceNode(sourceFile: string): NodeMeta | null
|
|
132
|
+
export declare function forkSourceNode(sourceFile: string): Promise<NodeMeta | null>;
|
|
133
133
|
/** Create a node on the canvas and wire its spawn-time edges.
|
|
134
134
|
*
|
|
135
135
|
* For a child (parent given): the parent auto-subscribes ACTIVE to the child
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var J=Object.defineProperty;var a=(e,t)=>J(e,"name",{value:t,configurable:!0});import{envHomeOverride as K,envRuntimeHomeOverride as X,INBOX_BETWEEN_TURNS_ENV as z,SCOPES_FILE_ENV as V,scopeAllowed as C}from"../../shared/env.js";import{isOwnMemoryScope as Y,validateScopes as Q}from"../scopes.js";import{activeGrant as B,terminalGrant as k}from"../grants/mirror.js";import{grantSnapshotMissing as Z}from"../../daemon/readiness.js";import{appendRunEvent as ee}from"../runs/events.js";import{readConfig as S}from"../config.js";import{InputError as T}from"../io.js";import{ApiError as w}from"../../api/errors.js";import{assertGranteeRunsHere as ne}from"./unsandboxed.js";import{randomBytes as re}from"node:crypto";import{existsSync as P}from"node:fs";import{resolve as te,relative as ie,isAbsolute as H,join as oe,sep as le}from"node:path";import{appSpace as ae}from"../layout.js";import{scopesFilePath as se}from"../canvas/paths.js";import{createNode as de,assertRunNotDeleting as ue,conversationOwner as ce,getNode as c,getRow as fe}from"../canvas/index.js";import{ensureAppSpace as pe}from"../spaces/space.js";import{LAUNCHER_SOCKET as L}from"../../launcher/spec.js";import{resolveInstallId as me}from"../canvas/install-id.js";import{isAppRun as _e}from"../canvas/app-run.js";import{canvasDbPath as ge,contextDir as we}from"../canvas/paths.js";import{conversationIdFromPath as he}from"../conversation-store/index.js";import{usage as U}from"../errors.js";import{assertProfileAvailableForBirth as ve}from"../profiles/deletion-reservation.js";import{loadExactProfileManifest as Re}from"../profiles/manifest.js";import{admitNodeCreate as Ee}from"../command-hooks/lifecycle-create.js";import{getById as ye,nodeObject as I,ownerForGrantee as Ce}from"../graph/objects.js";import{recordActedOn as Ie}from"../graph/edges.js";import{recordWatch as Ne,copyWatchesForFork as ke}from"../graph/watches.js";import{publish as Se}from"../graph/events.js";let O;const j=new Map;function pn(e){O=e}a(pn,"setInstallId");function Te(){if(O!==void 0)return O;const e=ge(),t=j.get(e);if(t!==void 0)return t;const o=me();return j.set(e,o),o}a(Te,"installId");function Oe(){return`${Date.now().toString(36)}-${re(4).toString("hex")}`}a(Oe,"newJobId");function xe(){return`${Te()}-${Oe()}`}a(xe,"newNodeId");const x=128,De=/^[a-z0-9-]+$/;class q extends Error{static{a(this,"NodeIdConflictError")}nodeId;constructor(t){super(`node already exists: ${t}`),this.nodeId=t,this.name="NodeIdConflictError"}}function D(e){if(e.length===0||e.length>x)throw U(`invalid --node-id '${e}': must be 1-${x} characters`,{next:`Pass an id-safe string (lowercase letters, digits, hyphens) of at most ${x} characters.`});if(!De.test(e))throw U(`invalid --node-id '${e}': must contain only lowercase letters, digits, and hyphens (e.g. 'remote42', 'my-node-1')`,{next:"Use only lowercase letters, digits, and hyphens."})}a(D,"validateNodeIdFormat");function mn(e){if(D(e),c(e)!==null)throw new q(e)}a(mn,"preflightNodeId");function be(e){if(D(e),c(e)!==null)throw new q(e);return e}a(be,"validatedExplicitNodeId");function _n(e){let t=e;const o=new Set;for(;;){if(o.has(t))return t;o.add(t);const s=fe(t);if(s===null||s.parent==null)return t;t=s.parent}}a(_n,"rootOfSpine");function gn(){const e=process.env;return{nodeId:e.CRTR_NODE_ID??null,kind:e.CRTR_KIND??null,mode:e.CRTR_MODE??null}}a(gn,"currentNodeContext");function Ae(e){return _e(e)}a(Ae,"inboxBetweenTurns");function wn(e){const t={CRTR_NODE_ID:e.node_id,CRTR_KIND:e.kind,CRTR_MODE:e.mode,CRTR_LIFECYCLE:e.lifecycle,CRTR_NODE_CWD:e.cwd,CRTR_CONTEXT_DIR:we(e.node_id,e.grantee),CRTR_CYCLES:(e.cycles??0).toString(),CRTR_PROFILE_ID:e.profile_id??"",PI_CLAUDE_OAUTH_REINJECT_SCOPE:"never"};e.parent&&(t.CRTR_PARENT_NODE_ID=e.parent),e.run_id&&(t.CRTR_RUN_ID=e.run_id),Ae(e)&&(t[z]="1"),e.scopes!==null&&e.scopes!==void 0&&(t[V]=se(e.node_id)),t.CRTR_GRANTEE=e.grantee??"app:terminal";const o=K();o!==void 0&&o!==""&&(t.CRTR_HOME=o);const s=X();s!==void 0&&s!==""&&(t.CRTR_RUNTIME_HOME=s);const f=process.env.CRTR_SUBTREE;return f!==void 0&&f!==""&&(t.CRTR_SUBTREE=f),{...t,...e.launch?.env??{}}}a(wn,"nodeEnv");function Me(e){const t=he(e),o=t===null?null:ce(t);return o===null?null:c(o)}a(Me,"forkSourceNode");async function hn(e){const t=e.nodeId!==void 0?(D(e.nodeId),e.nodeId):xe(),o=e.parent??null,s=o===null,f=e.spawnedBy??o,m=e.creator??null,b=e.mode??"base",N=e.lifecycle??(s?"resident":"terminal"),h=e.run===void 0?k():null,n={node_id:t,name:e.name??e.kind,description:e.description,cycles:0,created:new Date().toISOString(),cwd:e.cwd,host_kind:"broker",profile_id:e.profile_id??null,kind:e.kind,mode:b,lifecycle:N,persona_ack:{kind:e.kind,mode:b,lifecycle:N},status:"active",parent:o,spawned_by:f,creator:m,fork_from:e.forkFrom,fork_source_file:e.forkSourceFile,review_binding:e.reviewBinding,model_override:e.modelOverride??null,scopes:e.scopes??null,isolated:e.isolated===!0,grantee:e.run?.grantee??"app:terminal",sub:e.run?.sub??h?.sub??null,grant_id:e.run?.grant_id??h?.id??null,client_id:e.run?.client_id??null,metadata_json:s?e.run?.metadata_json??null:null,run_id:s?t:e.run?.run_id??null,event_cursor:s?e.run?.event_cursor??1:null,usage_json:s?e.run?.usage_json??JSON.stringify({input_tokens:0,output_tokens:0,cache_read_tokens:0,cache_write_tokens:0,cost_usd:0}):null,passive_default:e.passiveDefault??!1,...e.managedWorktree!==void 0?{managed_worktree:e.managedWorktree}:{},intent:null,deadline_at:e.deadlineAt??null,pi_session_id:null,pi_session_file:null,launch:e.launch},E=e.scopes===void 0?void 0:Q(e.scopes),v=o===null?null:c(o);if(o!==null&&v===null)throw new Error(`cannot spawn under unknown parent node: ${o}`);if(v?.run_id&&c(v.run_id)?.deleting_at)throw new Error("run is deleting");const u=m===null?null:c(m);if(m!==null&&u===null)throw new Error(`cannot spawn from unknown creator node: ${m}`);if(u?.run_id&&c(u.run_id)?.deleting_at)throw new Error("run is deleting");const A=e.forkSourceFile==null?null:Me(e.forkSourceFile),M=e.replaces==null?null:c(e.replaces),_=v??A??M??u??(f===null?null:c(f)),$=[v,u,A,M,f===null?null:c(f)].some(r=>r?.isolated===!0||r?.run_id!=null&&c(r.run_id)?.isolated===!0);if($&&e.isolated===!1)throw new w(403,"isolated_run","isolation cannot be turned off under an isolated run",{param:"isolated"});if(n.isolated=$||e.isolated===!0,_!==null){const r=u??_;if(u&&_.grantee&&u.grantee&&u.grantee!==_.grantee)throw new w(403,"other_app_run","cannot create under another app's node");const i=u&&u!==_?[_,u]:[_],d=[],g=new Set;for(const l of i){l.scopes!==null&&l.scopes!==void 0&&d.push(l.scopes);const p=l.grantee==="app:terminal"?k():l.grant_id?B(l.grant_id):null;if(p){const R=[...p.resolved];g.add(R),d.push(R)}else if(!(l.grantee==="app:terminal"&&!S("user").runtime?.issuer)){const R=[];g.add(R),d.push(R)}}const y=a(l=>Y(l,r.grantee==="user:local"?"app:terminal":r.grantee??"app:terminal"),"ownMemory"),F=a((l,p)=>y(p)&&g.has(l)||C(l,p),"allowed");if(E!==void 0&&!E.every(l=>d.every(p=>F(p,l))))throw new T({error:"unknown_scope",message:"child scopes must be covered by the creating node, its source and their current grants",received:E,field:"scopes",next:"Request only scopes the creating node currently holds."});if(n.scopes=E??(i.every(l=>l.scopes==null)&&i.every(l=>l.grant_id===r.grant_id&&l.sub===r.sub)?null:i.length===1?_.scopes??null:[...new Set(d.flat().filter(l=>d.every(p=>F(p,l))))]),n.scopes?.includes("crtr:act")&&!C(n.scopes,"crtr:llm"))throw new T({error:"invalid_scope",message:"crtr:act requires crtr:llm",received:n.scopes,field:"scopes",next:"Include crtr:llm or omit crtr:act."});n.grantee=r.grantee==="user:local"?"app:terminal":r.grantee,n.sub=r.sub??(n.grantee==="app:terminal"?h?.sub:null)??null,n.grant_id=r.grant_id??(n.grantee==="app:terminal"?h?.id:null)??null,n.client_id=r.client_id,n.run_id=s?t:r.run_id??null}if(ne(n.grantee),e.run===void 0&&n.grantee==="app:terminal"&&S("user").runtime?.issuer&&h===null)throw Z()?new w(503,"runtime_starting","the first grant snapshot from the directory has not committed"):new w(403,"scope_missing","terminal grant is not active");if(n.isolated){if(process.platform!=="linux"||!P(L))throw new w(400,"isolated_unavailable","isolated nodes require the Linux root launcher");if(e.managedWorktree!==void 0)throw new w(400,"invalid_request","isolated nodes cannot use a worktree",{param:"worktree"});const r=oe(ae(n.grantee??"app:terminal").nodes,t),i=ie(r,te(n.cwd));if(!H(n.cwd)||i===".."||i.startsWith(`..${le}`)||H(i))throw new w(400,"invalid_request","isolated node cwd must be inside its own folder",{param:"cwd"})}if(n.profile_id){const r=Re(n.profile_id).manifest.grantee??"app:terminal";if(r!==n.grantee){const i=`crtr:memory:rw:${r}:profile:${n.profile_id}`,d=n.grantee==="app:terminal"?k():n.grant_id?B(n.grant_id):null;if(!(n.grantee==="app:terminal"&&!S("user").runtime?.issuer)&&(!d||d.grantee!==n.grantee||!C(d.resolved,i))||!C(n.scopes,i))throw new T({error:"scope_missing",message:`missing scope ${i}`,received:n.profile_id,field:"profile",next:"Select a profile covered by this run and its current grant."})}}if(ve(n.profile_id??null),!n.grantee)throw new Error("node creation requires an app");const W=await Ee({kind:n.kind,mode:n.mode,cwd:n.cwd,profile:n.profile_id??null,root:s,parentId:o,requestingNodeId:m,lifecycle:N,replaces:e.replaces??null},n.grantee),G=a((r,i)=>{const d=I(r,i.node_id),g=m??o??e.actor??f??null,y=g!==null&&ye(r,g)?.type==="node"?I(r,g):Ce(r,e.run===void 0?"user:local":i.grantee);Ie(r,y,d),o!==null&&e.subscribe!==!1&&Ne(r,I(r,o),d,"spawn"),e.forkSourceNode&&ke(r,I(r,e.forkSourceNode),d),Se(r,{event:"created",object:d,actor:y,attrs:{name:i.name,kind:i.kind,creator:m??null}})},"recordBirth");try{e.nodeId!==void 0&&be(e.nodeId),await e.beforeCreate?.(),(process.platform!=="linux"||P(L))&&await pe(n.grantee??"app:terminal"),de(n,{outcomeDelivery:e.outcomeDelivery,withinCreate:a((r,i)=>{i.run_id&&i.run_id!==i.node_id&&ue(r,i.run_id),s&&e.run===void 0&&ee(r,t,t,"run.started",{scopes:i.scopes??null,payer:"user",usage:JSON.parse(i.usage_json)}),e.withinCreate?.(r,i),G(r,i)},"withinCreate")})}finally{W()}return n}a(hn,"spawnNode");export{q as NodeIdConflictError,gn as currentNodeContext,Me as forkSourceNode,Ae as inboxBetweenTurns,Oe as newJobId,xe as newNodeId,wn as nodeEnv,mn as preflightNodeId,_n as rootOfSpine,pn as setInstallId,hn as spawnNode};
|
|
1
|
+
var K=Object.defineProperty;var l=(e,t)=>K(e,"name",{value:t,configurable:!0});import{envHomeOverride as X,envRuntimeHomeOverride as z,INBOX_BETWEEN_TURNS_ENV as V,SCOPES_FILE_ENV as Y,scopeAllowed as C}from"../../shared/env.js";import{isOwnMemoryScope as Q,validateScopes as Z}from"../scopes.js";import{activeGrant as B,terminalGrant as k}from"../grants/mirror.js";import{grantSnapshotMissing as ee}from"../../daemon/readiness.js";import{appendRunEvent as ne}from"../runs/events.js";import{readConfig as S}from"../config.js";import{InputError as T}from"../io.js";import{ApiError as g}from"../../api/errors.js";import{assertGranteeRunsHere as re}from"./unsandboxed.js";import{randomBytes as te}from"node:crypto";import{existsSync as P}from"node:fs";import{resolve as ie,relative as ae,isAbsolute as H,join as oe,sep as le}from"node:path";import{appSpace as se}from"../layout.js";import{scopesFilePath as de}from"../canvas/paths.js";import{createNode as ce,assertRunNotDeleting as ue,conversationOwner as fe,getNode as u,getRow as pe}from"../canvas/index.js";import{ensureAppSpace as me}from"../spaces/space.js";import{LAUNCHER_SOCKET as L}from"../../launcher/spec.js";import{resolveInstallId as _e}from"../canvas/install-id.js";import{isAppRun as we}from"../canvas/app-run.js";import{canvasDbPath as ge,contextDir as he}from"../canvas/paths.js";import{conversationIdFromPath as ve}from"../conversation-store/index.js";import{usage as U}from"../errors.js";import{assertProfileAvailableForBirth as Re}from"../profiles/deletion-reservation.js";import{loadExactProfileManifest as ye}from"../profiles/manifest.js";import{admitNodeCreate as Ee}from"../command-hooks/lifecycle-create.js";import{getById as Ce,nodeObject as I,ownerForGrantee as Ie}from"../graph/objects.js";import{recordActedOn as Ne}from"../graph/edges.js";import{recordWatch as ke,copyWatchesForFork as Se}from"../graph/watches.js";import{publish as Te}from"../graph/events.js";import{someAsync as Oe}from"../async-array.js";let O;const j=new Map;function _n(e){O=e}l(_n,"setInstallId");async function xe(){if(O!==void 0)return O;const e=ge(),t=j.get(e);if(t!==void 0)return t;const a=await _e();return j.set(e,a),a}l(xe,"installId");function De(){return`${Date.now().toString(36)}-${te(4).toString("hex")}`}l(De,"newJobId");async function be(){return`${await xe()}-${De()}`}l(be,"newNodeId");const x=128,Ae=/^[a-z0-9-]+$/;class q extends Error{static{l(this,"NodeIdConflictError")}nodeId;constructor(t){super(`node already exists: ${t}`),this.nodeId=t,this.name="NodeIdConflictError"}}function D(e){if(e.length===0||e.length>x)throw U(`invalid --node-id '${e}': must be 1-${x} characters`,{next:`Pass an id-safe string (lowercase letters, digits, hyphens) of at most ${x} characters.`});if(!Ae.test(e))throw U(`invalid --node-id '${e}': must contain only lowercase letters, digits, and hyphens (e.g. 'remote42', 'my-node-1')`,{next:"Use only lowercase letters, digits, and hyphens."})}l(D,"validateNodeIdFormat");async function wn(e){if(D(e),await u(e)!==null)throw new q(e)}l(wn,"preflightNodeId");async function Me(e){if(D(e),await u(e)!==null)throw new q(e);return e}l(Me,"validatedExplicitNodeId");async function gn(e){let t=e;const a=new Set;for(;;){if(a.has(t))return t;a.add(t);const s=await pe(t);if(s===null||s.parent==null)return t;t=s.parent}}l(gn,"rootOfSpine");function hn(){const e=process.env;return{nodeId:e.CRTR_NODE_ID??null,kind:e.CRTR_KIND??null,mode:e.CRTR_MODE??null}}l(hn,"currentNodeContext");function $e(e){return we(e)}l($e,"inboxBetweenTurns");function vn(e){const t={CRTR_NODE_ID:e.node_id,CRTR_KIND:e.kind,CRTR_MODE:e.mode,CRTR_LIFECYCLE:e.lifecycle,CRTR_NODE_CWD:e.cwd,CRTR_CONTEXT_DIR:he(e.node_id,e.grantee),CRTR_CYCLES:(e.cycles??0).toString(),CRTR_PROFILE_ID:e.profile_id??"",PI_CLAUDE_OAUTH_REINJECT_SCOPE:"never"};e.parent&&(t.CRTR_PARENT_NODE_ID=e.parent),e.run_id&&(t.CRTR_RUN_ID=e.run_id),$e(e)&&(t[V]="1"),e.scopes!==null&&e.scopes!==void 0&&(t[Y]=de(e.node_id)),t.CRTR_GRANTEE=e.grantee??"app:terminal";const a=X();a!==void 0&&a!==""&&(t.CRTR_HOME=a);const s=z();s!==void 0&&s!==""&&(t.CRTR_RUNTIME_HOME=s);const f=process.env.CRTR_SUBTREE;return f!==void 0&&f!==""&&(t.CRTR_SUBTREE=f),{...t,...e.launch?.env??{}}}l(vn,"nodeEnv");async function Fe(e){const t=ve(e),a=t===null?null:await fe(t);return a===null?null:await u(a)}l(Fe,"forkSourceNode");async function Rn(e){const t=e.nodeId!==void 0?(D(e.nodeId),e.nodeId):await be(),a=e.parent??null,s=a===null,f=e.spawnedBy??a,m=e.creator??null,b=e.mode??"base",N=e.lifecycle??(s?"resident":"terminal"),h=e.run===void 0?await k():null,n={node_id:t,name:e.name??e.kind,description:e.description,cycles:0,created:new Date().toISOString(),cwd:e.cwd,host_kind:"broker",profile_id:e.profile_id??null,kind:e.kind,mode:b,lifecycle:N,persona_ack:{kind:e.kind,mode:b,lifecycle:N},status:"active",parent:a,spawned_by:f,creator:m,fork_from:e.forkFrom,fork_source_file:e.forkSourceFile,review_binding:e.reviewBinding,model_override:e.modelOverride??null,scopes:e.scopes??null,isolated:e.isolated===!0,grantee:e.run?.grantee??"app:terminal",sub:e.run?.sub??h?.sub??null,grant_id:e.run?.grant_id??h?.id??null,client_id:e.run?.client_id??null,metadata_json:s?e.run?.metadata_json??null:null,run_id:s?t:e.run?.run_id??null,event_cursor:s?e.run?.event_cursor??1:null,usage_json:s?e.run?.usage_json??JSON.stringify({input_tokens:0,output_tokens:0,cache_read_tokens:0,cache_write_tokens:0,cost_usd:0}):null,passive_default:e.passiveDefault??!1,...e.managedWorktree!==void 0?{managed_worktree:e.managedWorktree}:{},intent:null,deadline_at:e.deadlineAt??null,pi_session_id:null,pi_session_file:null,launch:e.launch},y=e.scopes===void 0?void 0:Z(e.scopes),v=a===null?null:await u(a);if(a!==null&&v===null)throw new Error(`cannot spawn under unknown parent node: ${a}`);if(v?.run_id&&(await u(v.run_id))?.deleting_at)throw new Error("run is deleting");const c=m===null?null:await u(m);if(m!==null&&c===null)throw new Error(`cannot spawn from unknown creator node: ${m}`);if(c?.run_id&&(await u(c.run_id))?.deleting_at)throw new Error("run is deleting");const A=e.forkSourceFile==null?null:await Fe(e.forkSourceFile),M=e.replaces==null?null:await u(e.replaces),_=v??A??M??c??(f===null?null:await u(f)),W=[v,c,A,M,f===null?null:await u(f)],$=await Oe(W,async r=>r?.isolated===!0||r?.run_id!=null&&(await u(r.run_id))?.isolated===!0);if($&&e.isolated===!1)throw new g(403,"isolated_run","isolation cannot be turned off under an isolated run",{param:"isolated"});if(n.isolated=$||e.isolated===!0,_!==null){const r=c??_;if(c&&_.grantee&&c.grantee&&c.grantee!==_.grantee)throw new g(403,"other_app_run","cannot create under another app's node");const i=c&&c!==_?[_,c]:[_],d=[],w=new Set;for(const o of i){o.scopes!==null&&o.scopes!==void 0&&d.push(o.scopes);const p=o.grantee==="app:terminal"?await k():o.grant_id?await B(o.grant_id):null;if(p){const R=[...p.resolved];w.add(R),d.push(R)}else if(!(o.grantee==="app:terminal"&&!S("user").runtime?.issuer)){const R=[];w.add(R),d.push(R)}}const E=l(o=>Q(o,r.grantee==="user:local"?"app:terminal":r.grantee??"app:terminal"),"ownMemory"),F=l((o,p)=>E(p)&&w.has(o)||C(o,p),"allowed");if(y!==void 0&&!y.every(o=>d.every(p=>F(p,o))))throw new T({error:"unknown_scope",message:"child scopes must be covered by the creating node, its source and their current grants",received:y,field:"scopes",next:"Request only scopes the creating node currently holds."});if(n.scopes=y??(i.every(o=>o.scopes==null)&&i.every(o=>o.grant_id===r.grant_id&&o.sub===r.sub)?null:i.length===1?_.scopes??null:[...new Set(d.flat().filter(o=>d.every(p=>F(p,o))))]),n.scopes?.includes("crtr:act")&&!C(n.scopes,"crtr:llm"))throw new T({error:"invalid_scope",message:"crtr:act requires crtr:llm",received:n.scopes,field:"scopes",next:"Include crtr:llm or omit crtr:act."});n.grantee=r.grantee==="user:local"?"app:terminal":r.grantee,n.sub=r.sub??(n.grantee==="app:terminal"?h?.sub:null)??null,n.grant_id=r.grant_id??(n.grantee==="app:terminal"?h?.id:null)??null,n.client_id=r.client_id,n.run_id=s?t:r.run_id??null}if(re(n.grantee),e.run===void 0&&n.grantee==="app:terminal"&&S("user").runtime?.issuer&&h===null)throw await ee()?new g(503,"runtime_starting","the first grant snapshot from the directory has not committed"):new g(403,"scope_missing","terminal grant is not active");if(n.isolated){if(process.platform!=="linux"||!P(L))throw new g(400,"isolated_unavailable","isolated nodes require the Linux root launcher");if(e.managedWorktree!==void 0)throw new g(400,"invalid_request","isolated nodes cannot use a worktree",{param:"worktree"});const r=oe(se(n.grantee??"app:terminal").nodes,t),i=ae(r,ie(n.cwd));if(!H(n.cwd)||i===".."||i.startsWith(`..${le}`)||H(i))throw new g(400,"invalid_request","isolated node cwd must be inside its own folder",{param:"cwd"})}if(n.profile_id){const r=ye(n.profile_id).manifest.grantee??"app:terminal";if(r!==n.grantee){const i=`crtr:memory:rw:${r}:profile:${n.profile_id}`,d=n.grantee==="app:terminal"?await k():n.grant_id?await B(n.grant_id):null;if(!(n.grantee==="app:terminal"&&!S("user").runtime?.issuer)&&(!d||d.grantee!==n.grantee||!C(d.resolved,i))||!C(n.scopes,i))throw new T({error:"scope_missing",message:`missing scope ${i}`,received:n.profile_id,field:"profile",next:"Select a profile covered by this run and its current grant."})}}if(Re(n.profile_id??null),!n.grantee)throw new Error("node creation requires an app");const G=await Ee({kind:n.kind,mode:n.mode,cwd:n.cwd,profile:n.profile_id??null,root:s,parentId:a,requestingNodeId:m,lifecycle:N,replaces:e.replaces??null},n.grantee),J=l(async(r,i)=>{const d=await I(r,i.node_id),w=m??a??e.actor??f??null,E=w!==null&&(await Ce(r,w))?.type==="node"?await I(r,w):await Ie(r,e.run===void 0?"user:local":i.grantee);await Ne(r,E,d),a!==null&&e.subscribe!==!1&&await ke(r,await I(r,a),d,"spawn"),e.forkSourceNode&&await Se(r,await I(r,e.forkSourceNode),d),await Te(r,{event:"created",object:d,actor:E,attrs:{name:i.name,kind:i.kind,creator:m??null}})},"recordBirth");try{e.nodeId!==void 0&&await Me(e.nodeId),await e.beforeCreate?.(),(process.platform!=="linux"||P(L))&&await me(n.grantee??"app:terminal"),await ce(n,{outcomeDelivery:e.outcomeDelivery,withinCreate:l(async(r,i)=>{i.run_id&&i.run_id!==i.node_id&&await ue(r,i.run_id),s&&e.run===void 0&&await ne(r,t,t,"run.started",{scopes:i.scopes??null,payer:"user",usage:JSON.parse(i.usage_json)}),await e.withinCreate?.(r,i),await J(r,i)},"withinCreate")})}finally{G()}return n}l(Rn,"spawnNode");export{q as NodeIdConflictError,hn as currentNodeContext,Fe as forkSourceNode,$e as inboxBetweenTurns,De as newJobId,be as newNodeId,vn as nodeEnv,wn as preflightNodeId,gn as rootOfSpine,_n as setInstallId,Rn as spawnNode};
|
|
@@ -56,4 +56,4 @@ export declare function composeNodeOutcomeDocument(args: {
|
|
|
56
56
|
finalReport?: string | null;
|
|
57
57
|
/** Lets the outcome transaction supply a parsed result without a second read. */
|
|
58
58
|
structuredResult?: unknown;
|
|
59
|
-
}): NodeOutcomeDocumentV1
|
|
59
|
+
}): Promise<NodeOutcomeDocumentV1>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var s=(t,e)=>c(t,"name",{value:e,configurable:!0});import{contextDir as f}from"../canvas/node-agent-paths.js";import{readOutputResult as m}from"./structured-output.js";const p=256*1024;function y(t,e){try{return m(t,e)}catch{return}}s(y,"structuredResult");function _(t){if(t===null)return null;try{return JSON.parse(t)}catch{return null}}s(_,"parseDetail");function a(t){if(Buffer.byteLength(t,"utf8")<=1024)return t;const n="\u2026";let r=Buffer.byteLength(n,"utf8"),l="";for(const i of t){const d=Buffer.byteLength(i,"utf8");if(r+d>1024)break;r+=d,l+=i}return`${l}${n}`}s(a,"truncateDescription");async function k(t){const{node:e,outcome:n}=t,r=_(n.detailJson),l=t.finalReport??e.final_report??"",i=a(e.name),d=e.description===void 0?void 0:a(e.description),o=n.kind==="result"?t.structuredResult===void 0?y(e.node_id,e.grantee):t.structuredResult:void 0,u={schema:"crtr.node-outcome/v1",outcomeId:`${e.node_id}:${n.revision}`,nodeId:e.node_id,revision:n.revision,kind:n.kind,reason:n.reason,settledAt:n.at,node:{name:i,...d===void 0?{}:{description:d},kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,status:e.status,terminalReason:e.terminal_reason??null,cwd:e.cwd,createdAt:e.created,parent:e.parent??null,spawnedBy:e.spawned_by??null},...n.kind==="result"?{result:{finalReport:{name:`${e.node_id}/${l}`},...o===void 0?{}:{structuredResult:o}}}:{failure:{message:r?.message??null,faultKind:r?.fault_kind??null,errorClass:r?.error_class??null,respawnFailures:r?.respawn_failures??null,deadline:r?.deadline===void 0?null:{deadlineAt:r.deadline.deadline_at,elapsedMs:r.deadline.elapsed_ms},declined:r?.declined??null}}};return Buffer.byteLength(JSON.stringify(u),"utf8")>p&&u.result?.structuredResult!==void 0&&(delete u.result.structuredResult,u.result.structuredResultOmitted=!0,u.result.structuredResultPath=`${await f(e.node_id,e.grantee)}/result.json`),u}s(k,"composeNodeOutcomeDocument");export{k as composeNodeOutcomeDocument};
|
|
@@ -12,10 +12,10 @@ export interface PersonaDriftResult {
|
|
|
12
12
|
guidance: string;
|
|
13
13
|
}
|
|
14
14
|
/** Build only the non-document framing for a fresh-context transition. */
|
|
15
|
-
export declare function transitionGuidance(nodeId: string, from: Persona, to: Persona): string
|
|
15
|
+
export declare function transitionGuidance(nodeId: string, from: Persona, to: Persona): Promise<string>;
|
|
16
16
|
/** Compare the live persona with the last acknowledged context delivery.
|
|
17
17
|
* `guidance` contains only fresh-context framing; current snapshots supply its
|
|
18
18
|
* documents. An absent or pre-kind acknowledgment cannot fabricate drift. */
|
|
19
|
-
export declare function personaDrift(nodeId: string): PersonaDriftResult | null
|
|
19
|
+
export declare function personaDrift(nodeId: string): Promise<PersonaDriftResult | null>;
|
|
20
20
|
/** Commit the persona state whose context delivery is complete. */
|
|
21
|
-
export declare function commitPersonaAck(nodeId: string, to: Persona): void
|
|
21
|
+
export declare function commitPersonaAck(nodeId: string, to: Persona): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var s=Object.defineProperty;var
|
|
2
|
-
`)}
|
|
1
|
+
var s=Object.defineProperty;var r=(o,e)=>s(o,"name",{value:e,configurable:!0});import{getNode as i,updateNode as c}from"../canvas/index.js";import{readRoadmap as d}from"./roadmap.js";import{orchestratorContextNote as u}from"./bearings.js";async function l(o,e){const t=await d(o)??"(no roadmap yet)",n=[`You are now a ${e.toUpperCase()} ORCHESTRATOR. Your scarce resource is your own context window.`,"Your job is to manage context and delegate \u2014 not to do the goal yourself."];return n.push("","Your roadmap is your document `roadmap`; it loads at every new session of yours. Author it now with `crtr doc edit roadmap`: state the goal and exit criteria, and set the preview to the goal\u2019s first line, using your orchestration protocol. Current contents:","",t,"",u(),"","What promotion changes is how long your documents matter: you now persist across refresh cycles, so the documents you own (`crtr doc write`) carry what this goal needs between your refreshes, and a lesson that should outlive this node gets another owner (`--owner user|repo|profile`).","","Then delegate each unit with `crtr node new --kind <kind>`. When your context fills, run `crtr node yield` to refresh against this roadmap."),n.join(`
|
|
2
|
+
`)}r(l,"orchestrationGuidance");function m(){return"You are HANDS-ON again \u2014 base mode. Do the work yourself in THIS window and finish it here; stop delegating by default. You no longer drive a roadmap, so `crtr node yield` is not your exit. Spawn a child only for a cleanly separable unit, never as your first move."}r(m,"baseModeGuidance");async function f(o,e,t){if(e.mode===t.mode)return"";if(t.mode==="base")return m();const n=await i(o);return await l(o,n?.kind??"general")}r(f,"transitionGuidance");async function g(o){const e=await i(o);if(e===null)return null;const t={kind:e.kind,mode:e.mode,lifecycle:e.lifecycle},n=e.persona_ack,a=n===void 0?t:{kind:n.kind??e.kind,mode:n.mode,lifecycle:n.lifecycle};return a.kind===t.kind&&a.mode===t.mode&&a.lifecycle===t.lifecycle?null:{from:a,to:t,guidance:await f(o,a,t)}}r(g,"personaDrift");async function k(o,e){await c(o,{persona_ack:e})}r(k,"commitPersonaAck");export{k as commitPersonaAck,g as personaDrift,f as transitionGuidance};
|
|
@@ -5,15 +5,15 @@ export type { RespawnPaneOpts } from './tmux-driver.js';
|
|
|
5
5
|
export { installTmuxBindings } from './tmux-bindings.js';
|
|
6
6
|
export type { TmuxInstalledPair, TmuxInstallDiagnostic, TmuxInstallResult } from './tmux-bindings.js';
|
|
7
7
|
/** The viewer a node has on screen, or null. UNIQUE(node_id) ⇒ at most one. */
|
|
8
|
-
export declare function focusOf(nodeId: string): FocusRow | null
|
|
8
|
+
export declare function focusOf(nodeId: string): Promise<FocusRow | null>;
|
|
9
9
|
/** Does this node have a live viewer on screen? */
|
|
10
|
-
export declare function isFocused(nodeId: string): boolean
|
|
10
|
+
export declare function isFocused(nodeId: string): Promise<boolean>;
|
|
11
11
|
/** The viewer realized by a given pane (`%id`), or null. */
|
|
12
|
-
export declare function focusByPane(pane: string): FocusRow | null
|
|
12
|
+
export declare function focusByPane(pane: string): Promise<FocusRow | null>;
|
|
13
13
|
/** The set of node ids that currently have a live viewer. */
|
|
14
|
-
export declare function focusedNodes(): Set<string
|
|
14
|
+
export declare function focusedNodes(): Promise<Set<string>>;
|
|
15
15
|
/** Every live viewer row (GC'ing any whose pane has gone). */
|
|
16
|
-
export declare function listFocuses(): FocusRow[]
|
|
16
|
+
export declare function listFocuses(): Promise<FocusRow[]>;
|
|
17
17
|
/** A reviver: ensure a node's broker ENGINE is alive (idempotent → reviveNode →
|
|
18
18
|
* headlessBrokerHost.launch). Injected so placement.ts need not import revive.ts
|
|
19
19
|
* (which imports placement.ts — a cycle). */
|
|
@@ -40,7 +40,7 @@ export interface FocusResult {
|
|
|
40
40
|
* `window` is accepted for the call contract (spawn passes it) but not stored —
|
|
41
41
|
* the focuses table keys on pane + session only. The attach client self-tags the
|
|
42
42
|
* pane `@crtr_node` on connect, so `nodeInPane` resolves it either way. */
|
|
43
|
-
export declare function registerViewerFocus(nodeId: string, pane: string, session: string | null, window: string | null): FocusRow | null
|
|
43
|
+
export declare function registerViewerFocus(nodeId: string, pane: string, session: string | null, window: string | null): Promise<FocusRow | null>;
|
|
44
44
|
/** Open a surface-attach viewer for `nodeId` and register its viewer focus row —
|
|
45
45
|
* the shared opener used by `focus` (a split beside the caller) and by a --root
|
|
46
46
|
* spawn (a fresh window in the caller's current session). Wraps `ensureSession`
|
|
@@ -58,7 +58,7 @@ export declare function openViewerWindow(nodeId: string, session: string, opts?:
|
|
|
58
58
|
besidePane?: string;
|
|
59
59
|
waitForBroker?: boolean;
|
|
60
60
|
initialWhip?: boolean;
|
|
61
|
-
}): FocusRow | null
|
|
61
|
+
}): Promise<FocusRow | null>;
|
|
62
62
|
export declare function focus(nodeId: string, opts: {
|
|
63
63
|
pane?: string;
|
|
64
64
|
newPane?: boolean;
|
|
@@ -70,7 +70,7 @@ export declare function focus(nodeId: string, opts: {
|
|
|
70
70
|
* on-screen viewer: kill its pane (the window collapses once its last pane goes)
|
|
71
71
|
* and drop its registry row. Best-effort tmux; the DB write always lands. No-op
|
|
72
72
|
* when the node has no viewer. */
|
|
73
|
-
export declare function tearDownNode(nodeId: string, keepPane?: string): void
|
|
73
|
+
export declare function tearDownNode(nodeId: string, keepPane?: string): Promise<void>;
|
|
74
74
|
/** Detach a node from the foreground (the `node lifecycle demote --detach` / Alt+C → D
|
|
75
75
|
* half). Every node is a headless broker — the only thing on screen is its
|
|
76
76
|
* surface-attach viewer pane — so "detach" means STOP FOREGROUNDING it: close the
|
|
@@ -78,7 +78,7 @@ export declare function tearDownNode(nodeId: string, keepPane?: string): void;
|
|
|
78
78
|
* reconnectable by a later `focus`. `pane` is the authoritative pane the caller
|
|
79
79
|
* acts on (the Alt+C menu's `#{pane_id}`); falls back to the node's registered
|
|
80
80
|
* viewer pane. No-op (false) when there is no live viewer pane to close. */
|
|
81
|
-
export declare function detachToBackground(nodeId: string, pane?: string): boolean
|
|
81
|
+
export declare function detachToBackground(nodeId: string, pane?: string): Promise<boolean>;
|
|
82
82
|
/** Reap `nodeId` IFF it is an empty shell (see {@link isEmptyNode}): tear down its
|
|
83
83
|
* broker engine, close any viewer, and hard-delete its row (edges cascade) + dir.
|
|
84
84
|
* The user closing or detaching from a node that never said anything wants it
|
|
@@ -86,7 +86,7 @@ export declare function detachToBackground(nodeId: string, pane?: string): boole
|
|
|
86
86
|
* its node identity so the worktree remains owned and can later be closed.
|
|
87
87
|
* Returns true when it reaped. No-op (false) on a node that produced output,
|
|
88
88
|
* is mid-first-turn, owns an open managed worktree, or no longer exists. */
|
|
89
|
-
export declare function reapIfEmpty(nodeId: string, keepPane?: string, teardown?: boolean): boolean
|
|
89
|
+
export declare function reapIfEmpty(nodeId: string, keepPane?: string, teardown?: boolean): Promise<boolean>;
|
|
90
90
|
/** Sweep the whole canvas for empty shells and reap them — the bulk cleanup
|
|
91
91
|
* behind `crtr canvas prune --empty`, for the husks that accumulated before
|
|
92
92
|
* close/detach learned to reap. Skips: the caller ($CRTR_NODE_ID), dead rows,
|
|
@@ -97,4 +97,4 @@ export declare function reapIfEmpty(nodeId: string, keepPane?: string, teardown?
|
|
|
97
97
|
* without deleting. Returns the reaped (or, under dryRun, reapable) node ids. */
|
|
98
98
|
export declare function reapEmptyNodes(opts?: {
|
|
99
99
|
dryRun?: boolean;
|
|
100
|
-
}): string[]
|
|
100
|
+
}): Promise<string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var V=Object.defineProperty;var
|
|
1
|
+
var V=Object.defineProperty;var s=(e,n)=>V(e,"name",{value:n,configurable:!0});import{envNodeId as $}from"../../shared/env.js";import{getNode as m,fullName as H,deleteNode as R,listNodes as M,openFocusRow as z,closeFocusRow as u,getFocusByNode as T,getFocusByPane as _,getFocusById as D,listFocuses as J}from"../canvas/index.js";import{nodeHasAssistantMessage as Q}from"../canvas/render-source.js";import{headlessBrokerHost as k}from"./host.js";import{publishNotice as U}from"./close.js";import{paneExists as p,paneLocation as x,closePane as P,currentTmux as X,switchClient as j,selectWindow as q,selectLayout as G,selectPane as S,getPaneOption as K,setPaneOption as Y,respawnPaneSync as Z,windowOfPane as I,renameWindow as ee}from"./tmux-driver.js";import{openViewerPane as ne,viewerSplitEnv as W,waitForBrokerViewSocket as ae}from"./placement-tmux.js";import{newJobId as ie}from"./nodes.js";import{isPidAlive as h}from"../canvas/pid.js";import{splitWindow as Oe,breakPane as Re,selectLayout as Te,selectPane as ke,focusWindow as Se,selectWindow as We,switchClient as be,openNodeWindow as Ae,ensureSession as Be,paneLocation as Ee,paneExists as Ce,paneRunning as Le,paneCurrentPath as Ve,currentTmux as $e,inTmux as He,paneOfNode as Me,setPaneOption as ze,getPaneOption as De,piCommand as Je,shellQuote as Qe,respawnPaneSync as Ue,closePane as Xe,displayPopup as je,windowOfPane as qe,renameWindow as Ge,paneOfWindow as Ke,windowAlive as Ye,listLivePanes as Ze,listLivePanesAsync as Ie}from"./tmux-driver.js";import{installTmuxBindings as nn}from"./tmux-bindings.js";async function g(e){return e===null?null:e.pane!==null&&!p(e.pane)?(await u(e.focus_id),null):e}s(g,"liveOrPrune");async function w(e){return await g(await T(e))}s(w,"focusOf");async function ve(e){return await w(e)!==null}s(ve,"isFocused");async function te(e){return await g(await _(e))}s(te,"focusByPane");async function _e(){return new Set((await se()).map(e=>e.node_id))}s(_e,"focusedNodes");async function se(){const e=[];for(const n of await J())await g(n)!==null&&e.push(n);return e}s(se,"listFocuses");function oe(){return`f-${ie()}`}s(oe,"newFocusId");async function b(e,n,a,i){const c=await _(n);if(c!==null)return c;const o=await T(e);if(o!==null)return o;const r=oe();return await z(r,n,a,e),await D(r)}s(b,"registerViewerFocus");async function A(e,n,a={}){const i=ne(e,n,a);return i===null?null:await b(e,i.pane,i.session,i.window)}s(A,"openViewerWindow");function B(e){const n=x(e)?.window??null;n!==null&&G(n,"even-horizontal"),S(e)}s(B,"surfaceNewPane");async function xe(e,n){const a=await m(e);if(a===null)return{focused:!1,session:null,inPlace:!1,revived:!1};const i=n.pane??process.env.TMUX_PANE??X()?.pane;if(i===void 0||i==="")return{focused:!1,session:null,inPlace:!1,revived:!1};const c=h(a.pi_pid??null),o=n.revive(e),r=!c;if(!await ae(e,o?.launch?.exited))return{focused:!1,session:null,inPlace:!1,revived:r};const y=x(i)?.session??null,N=y??"";if(n.inPlace===!0){const t=await w(e);t!==null&&(t.pane!==null&&t.pane!==i&&p(t.pane)&&P(t.pane),await u(t.focus_id));const l=await _(i);l!==null&&l.node_id!==e&&await u(l.focus_id);try{Y(i,"@crtr_node","")}catch{}const v=I(i),F=l?.node_id,L=F===void 0?W():{...W(),CRTR_ATTACH_ROSTER:F},O=Z({pane:i,cwd:a.cwd,env:L,command:`crtr surface attach to ${e}`});return O&&(v!==null&&ee(v,H(a)),await b(e,i,y,v)),{focused:O,session:y,inPlace:!0,revived:r}}if(n.newPane===!0){const t=await w(e);t!==null&&(t.pane!==null&&p(t.pane)&&P(t.pane),await u(t.focus_id));const l=await A(e,N,{cwd:a.cwd,besidePane:i});return l===null?{focused:!1,session:null,inPlace:!1,revived:r}:(l.pane!==null&&B(l.pane),{focused:!0,session:l.session,inPlace:!1,revived:r})}const f=await w(e);if(f!==null&&f.pane!==null)if(K(f.pane,"@crtr_node")===e){const t=x(f.pane);if(t!==null)return j(t.session),q(t.session,t.window),S(f.pane),{focused:!0,session:t.session,inPlace:!0,revived:r};await u(f.focus_id)}else await u(f.focus_id);const d=await A(e,N,{cwd:a.cwd,besidePane:i});return d===null?{focused:!1,session:null,inPlace:!1,revived:r}:(d.pane!==null&&B(d.pane),{focused:!0,session:d.session,inPlace:!1,revived:r})}s(xe,"focus");async function E(e,n){const a=await w(e);a!==null&&(a.pane!==null&&a.pane!==n&&p(a.pane)&&P(a.pane),await u(a.focus_id))}s(E,"tearDownNode");async function he(e,n){const a=n??(await w(e))?.pane??null;if(a===null||!p(a))return!1;const i=await te(a);i!==null&&await u(i.focus_id);const c=P(a);return await re(e),c}s(he,"detachToBackground");async function C(e){const n=await m(e);return n===null||n.streaming===!0&&h(n.pi_pid)?!1:!await Q(n.pi_session_file)}s(C,"isEmptyNode");async function re(e,n,a=!0){return(await m(e))?.managed_worktree?.state==="open"||!await C(e)?!1:(a&&k.teardown(e),await E(e,n),(await R(e)).deleted)}s(re,"reapIfEmpty");async function ge(e={}){const n=e.dryRun??!1,a=$()??"",i=[];for(const c of await M()){const o=c.node_id,r=await m(o);o===a||c.status==="dead"||h(c.pi_pid)||r?.managed_worktree?.state==="open"||!await C(o)||!n&&(await U(o,"notice.close",`Child closed \u2014 ${r?.name??o} (${o}) was closed from the canvas and is no longer running.`,{reason:"child-closed",child:o}),k.teardown(o),await E(o),!(await R(o)).deleted)||i.push(o)}return i}s(ge,"reapEmptyNodes");export{Re as breakPane,Xe as closePane,$e as currentTmux,he as detachToBackground,je as displayPopup,Be as ensureSession,xe as focus,te as focusByPane,w as focusOf,Se as focusWindow,_e as focusedNodes,De as getPaneOption,He as inTmux,nn as installTmuxBindings,ve as isFocused,se as listFocuses,Ze as listLivePanes,Ie as listLivePanesAsync,Ae as openNodeWindow,A as openViewerWindow,Ve as paneCurrentPath,Ce as paneExists,Ee as paneLocation,Me as paneOfNode,Ke as paneOfWindow,Le as paneRunning,Je as piCommand,ge as reapEmptyNodes,re as reapIfEmpty,b as registerViewerFocus,Ge as renameWindow,Ue as respawnPaneSync,Te as selectLayout,ke as selectPane,We as selectWindow,ze as setPaneOption,Qe as shellQuote,Oe as splitWindow,be as switchClient,E as tearDownNode,Ye as windowAlive,qe as windowOfPane};
|
|
@@ -22,7 +22,7 @@ type ReshapeOptions = {
|
|
|
22
22
|
profileId?: string | null;
|
|
23
23
|
};
|
|
24
24
|
/** Synchronous reshape for CLI callers outside the daemon. */
|
|
25
|
-
export declare function reshapeNode(nodeId: string, opts?: ReshapeOptions, beforePersist?: () => void): NodeMeta
|
|
25
|
+
export declare function reshapeNode(nodeId: string, opts?: ReshapeOptions, beforePersist?: () => void): Promise<NodeMeta>;
|
|
26
26
|
/** Daemon-safe reshape: network-backed config resolution happens off its event loop. */
|
|
27
27
|
export declare function reshapeNodeAsync(nodeId: string, opts?: ReshapeOptions, beforePersist?: () => void): Promise<NodeMeta>;
|
|
28
28
|
/** Promote a node to an orchestrator (mode→orchestrator), optionally
|
|
@@ -36,7 +36,7 @@ export declare function promote(nodeId: string, opts?: {
|
|
|
36
36
|
kind?: string;
|
|
37
37
|
resident?: boolean;
|
|
38
38
|
model?: string;
|
|
39
|
-
}): PromoteResult
|
|
39
|
+
}): Promise<PromoteResult>;
|
|
40
40
|
/** Daemon-safe promotion variant; preserves the same validation/seed ordering. */
|
|
41
41
|
export declare function promoteAsync(nodeId: string, opts?: {
|
|
42
42
|
kind?: string;
|
|
@@ -72,5 +72,5 @@ export declare function requestYield(nodeId: string, opts?: {
|
|
|
72
72
|
promote?: boolean;
|
|
73
73
|
}, deps?: {
|
|
74
74
|
ensure?: () => void;
|
|
75
|
-
}): YieldResult
|
|
75
|
+
}): Promise<YieldResult>;
|
|
76
76
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var g=Object.defineProperty;var
|
|
1
|
+
var g=Object.defineProperty;var r=(n,e)=>g(n,"name",{value:e,configurable:!0});import{getNode as o,updateNode as x}from"../canvas/index.js";import{transition as E}from"./lifecycle.js";import{ensureDaemon as R}from"../../daemon/manage.js";import{buildLaunchSpec as $,buildLaunchSpecAsync as A}from"./launch.js";import{ensureRoadmap as m,hasRoadmap as c,roadmapRef as u}from"./roadmap.js";import{readGoal as f,goalPath as w}from"./kickoff.js";async function k(n,e){const i=await o(n);if(i===null)throw new Error(`unknown node: ${n}`);const a=e.kind??i.kind,l=e.mode??i.mode,d=e.lifecycle??i.lifecycle,t=e.profileId===void 0?i.profile_id??null:e.profileId;return{node:i,kind:a,mode:l,lifecycle:d,profileId:t,launchOpts:{lifecycle:d,hasManager:i.parent!==null,model:e.model??i.model_override??void 0,modelOverride:e.model!==void 0,modelIntent:e.model===void 0?i.launch?.modelIntent:void 0,modelExact:e.model===void 0?i.launch?.modelExact:void 0,cwd:i.cwd,profileId:t}}}r(k,"reshapeInputs");async function s(n,e,i,a,l){l?.();const d=i.node.name===i.node.kind&&i.kind!==i.node.kind;return await x(n,{kind:i.kind,mode:i.mode,lifecycle:i.lifecycle,profile_id:i.profileId,launch:a,...d?{name:i.kind}:{},...e.model!==void 0?{model_override:a?.model??e.model}:{}})}r(s,"persistReshape");async function h(n,e={},i){const a=await k(n,e);return await s(n,e,a,$(a.kind,a.mode,a.launchOpts).launch,i)}r(h,"reshapeNode");async function y(n,e={},i){const a=await k(n,e),{launch:l}=await A(a.kind,a.mode,a.launchOpts);return await s(n,e,a,l,i)}r(y,"reshapeNodeAsync");async function N(n,e={}){const i=await o(n);if(i===null)throw new Error(`unknown node: ${n}`);let a=!1;return{meta:await h(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{},mode:"orchestrator",lifecycle:e.resident===!0?"resident":i.lifecycle},async()=>{if(!await c(n)){const d=await f(n);a=await m(n,d!==null&&d.trim()!==""?{goal:d.trim()}:{})}}),roadmapWritten:a,roadmapRef:u(n),goalPath:await w(n)}}r(N,"promote");async function O(n,e={}){const i=await o(n);if(i===null)throw new Error(`unknown node: ${n}`);let a=!1;return{meta:await y(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{},mode:"orchestrator",lifecycle:e.resident===!0?"resident":i.lifecycle},async()=>{if(!await c(n)){const d=await f(n);a=await m(n,d!==null&&d.trim()!==""?{goal:d.trim()}:{})}}),roadmapWritten:a,roadmapRef:u(n),goalPath:await w(n)}}r(O,"promoteAsync");async function Y(n,e={},i={}){if(await o(n)===null)throw new Error(`unknown node: ${n}`);return e.promote===!0?await O(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}):(e.kind!==void 0||e.model!==void 0)&&await y(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),{...await _(n,{},i),promoted:e.promote===!0}}r(Y,"requestYieldAsync");async function _(n,e={},i={}){const a=i.ensure??R;if(await o(n)===null)throw new Error(`unknown node: ${n}`);const d=e.kind!==void 0||e.model!==void 0;let t=!1;return e.promote===!0?(await N(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),t=!0):d&&await h(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),a(),await E(n,"yield"),{meta:await o(n),promoted:t,willRefresh:!0}}r(_,"requestYield");export{N as promote,O as promoteAsync,_ as requestYield,Y as requestYieldAsync,h as reshapeNode,y as reshapeNodeAsync};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=Object.defineProperty;var n=(e,t)=>p(e,"name",{value:t,configurable:!0});import{abortExecution as y,beginExecution as _,getNode as s,setPresence as h,setFocusOccupant as v,fullName as R,recordExecutionPid as b,recordLaunch as E}from"../canvas/index.js";import{pushFinal as k}from"../feed/feed.js";import{newestReportBody as g}from"../feed/reports.js";import{spawnNode as x,rootOfSpine as S}from"./nodes.js";import{buildLaunchSpecAsync as T,buildPiArgv as B}from"./launch.js";import{focusOf as N,respawnPaneSync as O,setPaneOption as P}from"./placement.js";import{waitForBrokerViewSocket as C,viewerSplitEnv as D}from"./placement-tmux.js";import{headlessBrokerHost as u}from"./host.js";import{boundFleet as F}from"./fleet.js";import{transition as z}from"./lifecycle.js";import{ensureDaemon as A}from"../../daemon/manage.js";import{invokeBirthLifecycleHooks as L}from"./spawn.js";async function ae(e,t){const a=await s(e);if(a===null)return{recycled:!1,finalized:!1,newRoot:null,delivered:[]};const o=t??process.env.TMUX_PANE;if(o===void 0||o==="")return{recycled:!1,finalized:!1,newRoot:null,delivered:[]};const w=await N(e);try{A()}catch{}const{launch:f}=await T("general","base",{lifecycle:"resident",hasManager:!1,cwd:a.cwd,profileId:a.profile_id}),m=await g(e)||`Closed via recycle \u2014 no final summary was authored by ${a.name}.`;let c=[],d=!1;const r=await x({kind:"general",mode:"base",lifecycle:"resident",cwd:a.cwd,name:"general",parent:null,replaces:e,profile_id:a.profile_id,launch:f,beforeCreate:n(async()=>{try{c=(await k(e,m)).deliveredTo,d=!0}catch{}},"beforeCreate")}),i=await s(r.node_id);await L(i);const l=B(i);if(l.env={...l.env,CRTR_SUBTREE:await S(r.node_id)},!await U(i,l))return{recycled:!1,finalized:d,newRoot:r.node_id,delivered:c};try{u.teardown(e)}catch{}try{await h(e,{pane:null,window:null,tmux_session:null})}catch{}if(w!==null)try{await v(w.focus_id,r.node_id)}catch{}return{recycled:M(i,o),finalized:d,newRoot:r.node_id,delivered:c}}n(ae,"recycleNode");async function U(e,t){const a=await _(e.node_id,{daemonEpoch:F().epoch()});t.env={...t.env,CRTR_EXECUTION_ID:a};let o;try{if(o=await u.launch(e.node_id,t,{cwd:e.cwd,name:R(e),resuming:!1}),o.pid===null)throw new Error("broker host returned no pid");if(await E(e.node_id,new Date().toISOString()),await b(a,e.node_id,o.pid)==="shutdown")throw new Error("broker execution was superseded");if(await C(e.node_id,o.exited))return!0}catch{await y(a,{reason:"launch_failed"})}try{await H(e.node_id)}catch{}try{u.teardown(e.node_id)}catch{}return!1}n(U,"launchRecycledBroker");async function H(e){const t=await s(e);(t?.status==="active"||t?.status==="idle")&&await z(e,"crash")}n(H,"transitionReplacementToDead");function M(e,t){try{P(t,"@crtr_node","")}catch{}return O({pane:t,cwd:e.cwd,env:D(),command:`crtr surface attach to ${e.node_id}`})}n(M,"respawnRecycledViewer");export{ae as recycleNode};
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* `final_report` fresh — never a caller-supplied snapshot. Throws
|
|
3
3
|
* `node_finalized` when latched; otherwise a no-op (the common case). No
|
|
4
4
|
* side effect either way. */
|
|
5
|
-
export declare function assertNotFinalized(nodeId: string): void
|
|
5
|
+
export declare function assertNotFinalized(nodeId: string): Promise<void>;
|
|
6
6
|
/** Validate a target IS latched (the `--reopen` doorway) and return the exact
|
|
7
7
|
* `final_report` value observed, so the caller can CAS-clear it later via
|
|
8
8
|
* `commitReopen` — once every OTHER fallible precondition the requested
|
|
9
9
|
* operation needs has already passed (e.g. `--fresh`'s recoverable-state
|
|
10
10
|
* check). Throws `not_finalized` when the target has nothing to clear. Pure
|
|
11
11
|
* read — never mutates. */
|
|
12
|
-
export declare function assertFinalizedForReopen(nodeId: string): string
|
|
12
|
+
export declare function assertFinalizedForReopen(nodeId: string): Promise<string>;
|
|
13
13
|
/** Clear `nodeId`'s finalization latch — retract-pointer-only (only
|
|
14
14
|
* `final_report`/`finalized_at`; the report file and every delivered feed
|
|
15
15
|
* event are untouched). CAS'd against `expectedFinalReport` (the value the
|
|
@@ -19,7 +19,7 @@ export declare function assertFinalizedForReopen(nodeId: string): string;
|
|
|
19
19
|
* this throws `reopen_latch_changed` instead of silently clobbering a newer
|
|
20
20
|
* canonical result. Callers MUST NOT proceed to revive/deliver when this
|
|
21
21
|
* throws. */
|
|
22
|
-
export declare function commitReopen(nodeId: string, expectedFinalReport: string): void
|
|
22
|
+
export declare function commitReopen(nodeId: string, expectedFinalReport: string): Promise<void>;
|
|
23
23
|
/** Commit the wider message-delivery reopen: settle the node's lifecycle, then
|
|
24
24
|
* retract a final latch when one exists. Unlike the revive/fresh gate, an
|
|
25
25
|
* unlatched node is valid here.
|
|
@@ -35,7 +35,7 @@ export declare function commitReopen(nodeId: string, expectedFinalReport: string
|
|
|
35
35
|
*
|
|
36
36
|
* Writing lifecycle first leaves a failed latch CAS with the canonical-final
|
|
37
37
|
* pointer intact. Both writes finish before either delivery channel begins. */
|
|
38
|
-
export declare function commitReopenResident(nodeId: string, expectedFinalReport?: string, callerNodeId?: string | null): string | null
|
|
38
|
+
export declare function commitReopenResident(nodeId: string, expectedFinalReport?: string, callerNodeId?: string | null): Promise<string | null>;
|
|
39
39
|
/** Convenience wrapper for a doorway with NO intervening fallible step between
|
|
40
40
|
* the gate check and the reopen clear (`node lifecycle revive` has nothing
|
|
41
41
|
* fallible between the gate and `reviveNode`). Validates and, when `reopen`,
|
|
@@ -46,4 +46,4 @@ export declare function commitReopenResident(nodeId: string, expectedFinalReport
|
|
|
46
46
|
* CAS-clears the latch (side effect) and returns.
|
|
47
47
|
* - `reopen` true + not latched → throws `not_finalized`.
|
|
48
48
|
* - `reopen` false + not latched → no-op (the common case). */
|
|
49
|
-
export declare function assertReopenGate(nodeId: string, reopen: boolean, callerNodeId?: string | null): void
|
|
49
|
+
export declare function assertReopenGate(nodeId: string, reopen: boolean, callerNodeId?: string | null): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var a=(t,e)=>c(t,"name",{value:e,configurable:!0});import{clearFinalReportIfMatches as l,getFinalReport as f,getNode as u,updateNode as p}from"../canvas/index.js";import{subscribersOf as w}from"../canvas/tree.js";import{InputError as o}from"../io.js";import{transition as m}from"./lifecycle.js";import{noticeChangedWhileDone as h}from"./ledger.js";async function s(t){return await f(t)}a(s,"currentFinalReport");function d(t,e){throw new o({error:"node_finalized",message:`${t} already submitted its canonical final result (\`crtr canvas read ${t}/${e}\`) \u2014 reviving it now would hand it a mandate it can never finish, since a second \`push final\` always errors against an already-latched node.`,next:`Re-run this exact command with --reopen to clear ${t}'s spent latch and re-task it in place.`})}a(d,"throwNodeFinalized");function g(t){throw new o({error:"not_finalized",message:`${t} is not finalized \u2014 --reopen has nothing to clear.`,next:"Drop --reopen."})}a(g,"throwNotFinalized");async function R(t){const e=await s(t);e!==null&&d(t,e)}a(R,"assertNotFinalized");async function y(t){const e=await s(t);return e===null&&g(t),e}a(y,"assertFinalizedForReopen");async function x(t,e){if(!await l(t,e))throw new o({error:"reopen_latch_changed",message:`${t}'s finalization latch changed since it was last inspected \u2014 a concurrent --reopen (or a fresh push final) already moved it, so clearing it now would risk erasing a newer canonical result.`,next:"Re-run this exact command \u2014 it will re-inspect the current state before acting."})}a(x,"commitReopen");async function F(t,e){return t==null?!1:(await w(e)).some(i=>i.node_id===t)}a(F,"isManagerOf");async function _(t,e,i){const r=await s(t);await F(i,t)||await p(t,{lifecycle:"resident"});const n=await u(t);return n!==null&&(n.status==="done"||n.status==="canceled"||n.status==="dead")&&(n.status==="done"&&n.last_settled_at!=null&&await h(t,n.last_settled_at),await m(t,"revive")),r!==null&&await x(t,e??r),r}a(_,"commitReopenResident");async function D(t,e,i){if(e){const r=await y(t);await _(t,r,i);return}await R(t)}a(D,"assertReopenGate");export{y as assertFinalizedForReopen,R as assertNotFinalized,D as assertReopenGate,x as commitReopen,_ as commitReopenResident};
|
|
@@ -11,7 +11,7 @@ import { respawnPaneSync } from './placement.js';
|
|
|
11
11
|
* explicit: an abrupt broker teardown fires NO clean `session_shutdown`, so the
|
|
12
12
|
* general quit→done rule does NOT auto-resolve a force-killed descendant — we
|
|
13
13
|
* mark it `canceled` here via the same `cancel` event the close cascade uses. */
|
|
14
|
-
export declare function reapDescendants(rootId: string): string[]
|
|
14
|
+
export declare function reapDescendants(rootId: string): Promise<string[]>;
|
|
15
15
|
/** Injectable host/viewer seam, so the ordinary source test drives relaunchRoot's pure
|
|
16
16
|
* DB transitions without a real broker or tmux. Each field defaults to its
|
|
17
17
|
* production verb. */
|
|
@@ -51,7 +51,7 @@ export interface ResetRootResult {
|
|
|
51
51
|
* `--session <id>` wakes the right conversation. A `/new` on a child is NOT a
|
|
52
52
|
* graph reset — a root's `/new` is handled by relaunchRoot, never here; a root
|
|
53
53
|
* that reaches this is a no-op. */
|
|
54
|
-
export declare function resetRoot(nodeId: string, newSessionId?: string, newSessionFile?: string | null): ResetRootResult
|
|
54
|
+
export declare function resetRoot(nodeId: string, newSessionId?: string, newSessionFile?: string | null): Promise<ResetRootResult>;
|
|
55
55
|
export type HandleNewSessionPath = 'reset-child' | 'noop';
|
|
56
56
|
export interface HandleNewSessionResult {
|
|
57
57
|
path: HandleNewSessionPath;
|
|
@@ -59,10 +59,10 @@ export interface HandleNewSessionResult {
|
|
|
59
59
|
/** The child-side `/new` entry the stophook calls (the root side goes to
|
|
60
60
|
* relaunchRoot directly). The broker already drove the engine-side new_session;
|
|
61
61
|
* this only refreshes the child's session id on the SAME node id. */
|
|
62
|
-
export declare function handleNewSession(nodeId: string, newSessionId: string, newSessionFile?: string | null): HandleNewSessionResult
|
|
62
|
+
export declare function handleNewSession(nodeId: string, newSessionId: string, newSessionFile?: string | null): Promise<HandleNewSessionResult>;
|
|
63
63
|
/** Resolve a cleanly-exiting node to `done`. Returns true iff it transitioned.
|
|
64
64
|
* Guard: only a real quit, and only a node still active|idle with no pending
|
|
65
65
|
* intent — so it never clobbers a node already routed by agent_end to done
|
|
66
66
|
* (push final), refresh (yield), or idle-release. Pure/DB-only (no pi/tmux) so
|
|
67
67
|
* the guard is unit-testable without a live pi. */
|
|
68
|
-
export declare function markCleanExitDone(nodeId: string, reason: unknown): boolean
|
|
68
|
+
export declare function markCleanExitDone(nodeId: string, reason: unknown): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var S=Object.defineProperty;var
|
|
1
|
+
var S=Object.defineProperty;var s=(e,t)=>S(e,"name",{value:t,configurable:!0});import{getNode as f,beginExecution as B,recordExecutionPid as N,abortExecution as v,bindSession as b,recordLaunch as g,fullName as x,liveExecutionForNode as F,closeFocusRow as R,view as O}from"../canvas/index.js";import{transition as r}from"./lifecycle.js";import{headlessBrokerHost as y,requestBrokerTeardown as V}from"./host.js";import{boundFleet as C}from"./fleet.js";import{tearDownNode as D,focusOf as P,registerViewerFocus as T,respawnPaneSync as I,windowOfPane as L,renameWindow as q}from"./placement.js";import{viewerSplitEnv as A,waitForBrokerViewSocket as H}from"./placement-tmux.js";import{buildLaunchSpecAsync as M,buildPiArgv as U}from"./launch.js";import{newNodeId as j,spawnNode as W,rootOfSpine as X}from"./nodes.js";import{appSpace as $}from"../layout.js";import{join as z}from"node:path";import{invokeBirthLifecycleHooks as G}from"./spawn.js";async function J(e){const t=[];for(const i of await O(e))try{await r(i,"cancel",{reason:"closed"}),V(i),await D(i),t.push(i)}catch{}return t}s(J,"reapDescendants");async function se(e,t={}){const i=t.launchBroker??y.launch,l=t.waitForViewSocket??H,p=t.respawnViewer??I,c=t.teardownBroker??y.teardown,a=await f(e);if(a===null||a.parent!=null||a.status==="done")return null;const d=await P(e),h=a.isolated?await j():void 0,_=h?z($(a.grantee??"app:terminal").nodes,h):a.cwd,{launch:E}=await M(a.kind,"base",{lifecycle:"resident",hasManager:!1,model:a.model_override??void 0,modelIntent:a.launch?.modelIntent,modelExact:a.launch?.modelExact,cwd:_,profileId:a.profile_id}),n=await W({nodeId:h,kind:a.kind,mode:"base",lifecycle:"resident",cwd:_,name:a.kind,parent:null,replaces:e,profile_id:a.profile_id,launch:E,modelOverride:a.model_override??void 0});await G(n);const u=U(n,{});u.env={...u.env,CRTR_SUBTREE:await X(n.node_id)};const w=await B(n.node_id,{daemonEpoch:C().epoch()});u.env={...u.env,CRTR_EXECUTION_ID:w};let m;try{m=await i(n.node_id,u,{cwd:_,name:x(n),resuming:!1})}catch(o){throw await v(w,{reason:"launch_failed"}),await r(n.node_id,"crash"),o}if(m.pid==null)return await v(w,{reason:"launch_failed"}),await r(n.node_id,"crash"),null;if(await g(n.node_id,new Date().toISOString()),await N(w,n.node_id,m.pid)==="shutdown"){await v(w,{reason:"superseded"});try{c(n.node_id)}catch{}return await r(n.node_id,"crash"),null}let k=!1;try{k=await l(n.node_id,m.exited)}catch{}if(!k){const o=await f(n.node_id);(o?.status==="active"||o?.status==="idle")&&await r(n.node_id,"crash");try{c(n.node_id)}catch{}return null}if(await J(e),await r(e,"finish"),d?.pane!=null){await R(d.focus_id),p({pane:d.pane,cwd:a.cwd,env:A(),command:`crtr surface attach to ${n.node_id}`});const o=L(d.pane);o!==null&&q(o,x(n)),await T(n.node_id,d.pane,d.session,o)}return c(e),{newNodeId:n.node_id}}s(se,"relaunchRoot");async function K(e,t,i){const l=await f(e),p={reaped:[],detached:[],reset:!1};if(l===null||l.parent==null)return p;if(t!==void 0){const c=await F(e);c!==null&&await b(e,{executionId:c.executionId,sessionId:t,transcriptPath:i??null})}return p}s(K,"resetRoot");async function le(e,t,i){return await f(e)===null?{path:"noop"}:(await K(e,t,i),{path:"reset-child"})}s(le,"handleNewSession");async function ue(e,t){if(t!=="quit")return!1;const i=await f(e);return i===null||i.status!=="active"&&i.status!=="idle"||i.intent!=null?!1:(await r(e,"finish"),!0)}s(ue,"markCleanExitDone");export{le as handleNewSession,ue as markCleanExitDone,J as reapDescendants,se as relaunchRoot,K as resetRoot};
|
|
@@ -35,7 +35,7 @@ export declare function isDisconnected(meta: NodeMeta, isAlive: (pid: number | n
|
|
|
35
35
|
/** Every disconnected node on the canvas — the set a revive-all WOULD relaunch.
|
|
36
36
|
* This is the PREVIEW: it has no side effects, so the command can list the
|
|
37
37
|
* candidates and gate on confirmation before any engine is launched. */
|
|
38
|
-
export declare function listDisconnected(): NodeMeta[]
|
|
38
|
+
export declare function listDisconnected(): Promise<NodeMeta[]>;
|
|
39
39
|
export interface ReviveAllResult {
|
|
40
40
|
/** Node ids whose broker engine reviveAll relaunched (RESUME). */
|
|
41
41
|
revived: string[];
|
|
@@ -54,4 +54,4 @@ export interface ReviveAllResult {
|
|
|
54
54
|
* no-op), so this is a thin orchestrator over `listDisconnected`: revive each
|
|
55
55
|
* with resume:true. One failing node never aborts the sweep — its error is
|
|
56
56
|
* collected and the rest proceed. */
|
|
57
|
-
export declare function reviveAll(include?: (meta: NodeMeta) => boolean): Promise<ReviveAllResult>;
|
|
57
|
+
export declare function reviveAll(include?: (meta: NodeMeta) => Promise<boolean>): Promise<ReviveAllResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty;var
|
|
1
|
+
var t=Object.defineProperty;var i=(e,r)=>t(e,"name",{value:r,configurable:!0});import{listNodes as s,getNode as u}from"../canvas/index.js";import{recordedPidLiveness as c}from"../canvas/pid.js";import{reviveNode as d}from"./revive.js";import{filterAsync as f}from"../async-array.js";const l=["done","canceled"];function a(e){return e.frozen_at==null&&(e.final_report!=null||l.includes(e.status))}i(a,"hasNoNaturalCycle");function p(e,r){return!(e.kind==="human"||r(e.pi_pid)||e.pi_session_id==null&&e.pi_session_file==null||a(e))}i(p,"isDisconnected");async function _(){const e=[];for(const r of await s()){const o=await u(r.node_id);o!==null&&p(o,n=>c(n,o.pi_pid_identity)==="alive")&&e.push(o)}return e}i(_,"listDisconnected");async function N(e=async()=>!0){const r={revived:[],failed:[],frozen:[]};for(const o of await f(await _(),e))try{(await d(o.node_id,{resume:!0,recovery:!0,capacity:"freeze"})).outcome==="frozen"?r.frozen.push(o.node_id):r.revived.push(o.node_id)}catch(n){r.failed.push({node_id:o.node_id,error:n.message})}return r}i(N,"reviveAll");export{l as TERMINAL_BY_CHOICE,a as hasNoNaturalCycle,p as isDisconnected,_ as listDisconnected,N as reviveAll};
|