@north-light/crouter 0.3.349 → 0.3.351
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/bin/crtr-launcher +4 -0
- package/bin/runtime-generation-manifest.mjs +12 -2
- package/dist/api/client.d.ts +50 -7
- package/dist/api/client.js +2 -2
- package/dist/api/dto/analytics.d.ts +184 -0
- package/dist/api/dto/analytics.js +0 -0
- package/dist/api/dto/broker-ops.d.ts +43 -1
- package/dist/api/dto/config.d.ts +11 -0
- package/dist/api/dto/grants.d.ts +14 -0
- package/dist/api/dto/grants.js +0 -0
- package/dist/api/dto/human-requests.d.ts +14 -0
- package/dist/api/dto/memory.d.ts +6 -0
- package/dist/api/dto/modelauth.d.ts +35 -0
- package/dist/api/dto/node-records.d.ts +35 -0
- package/dist/api/dto/node-records.js +0 -0
- package/dist/api/dto/nodes.d.ts +5 -0
- package/dist/api/dto/profiles.d.ts +38 -3
- package/dist/api/dto/worktree.d.ts +11 -0
- package/dist/api/errors.d.ts +23 -1
- package/dist/api/errors.js +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +1 -1
- package/dist/api/node-transport.js +1 -1
- package/dist/api/routes.d.ts +22 -0
- package/dist/api/routes.js +1 -1
- package/dist/build-root.d.ts +6 -1
- package/dist/build-root.js +1 -1
- package/dist/builtin-memory/crouter-sdk/client.md +34 -0
- package/dist/builtin-memory/crouter-sdk/errors.md +2 -0
- package/dist/builtin-memory/crouter-sdk/memory.md +2 -2
- package/dist/builtin-memory/crouter-sdk/streaming.md +21 -0
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/claude-plugin-commands.ts +8 -4
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +39 -118
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.d.ts +6 -1
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.js +41 -27
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +52 -29
- package/dist/cli.js +9 -8
- package/dist/clients/attach/chrome/inbox-strip.js +1 -1
- package/dist/clients/attach/chrome/roster.js +1 -1
- package/dist/clients/attach/config.js +1 -1
- package/dist/clients/attach/overlays/auth.js +2 -2
- package/dist/clients/attach/overlays/graph.js +1 -1
- package/dist/clients/attach/render/tool-calls.js +3 -3
- package/dist/clients/attach/session/connection.js +1 -1
- package/dist/clients/attach/session/profile-files.js +1 -1
- package/dist/clients/attach/viewer.js +1569 -816
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/broker-permissions.d.ts +2 -0
- package/dist/commands/broker-permissions.js +1 -0
- package/dist/commands/canvas-analytics/chart.d.ts +52 -0
- package/dist/commands/canvas-analytics/chart.js +1 -0
- package/dist/commands/canvas-analytics/drilldown.d.ts +34 -0
- package/dist/commands/canvas-analytics/drilldown.js +1 -0
- package/dist/commands/canvas-analytics/format.d.ts +29 -0
- package/dist/commands/canvas-analytics/format.js +1 -0
- package/dist/commands/canvas-analytics/graph-detail.d.ts +2 -0
- package/dist/commands/canvas-analytics/graph-detail.js +2 -0
- package/dist/commands/canvas-analytics/graphs.d.ts +9 -0
- package/dist/commands/canvas-analytics/graphs.js +1 -0
- package/dist/commands/canvas-analytics/memory.d.ts +2 -0
- package/dist/commands/canvas-analytics/memory.js +1 -0
- package/dist/commands/canvas-analytics/overview.d.ts +2 -0
- package/dist/commands/canvas-analytics/overview.js +1 -0
- package/dist/commands/canvas-analytics/shell.d.ts +60 -0
- package/dist/commands/canvas-analytics/shell.js +2 -0
- package/dist/commands/canvas-analytics/time.d.ts +2 -0
- package/dist/commands/canvas-analytics/time.js +1 -0
- package/dist/commands/canvas-analytics/usage.d.ts +2 -0
- package/dist/commands/canvas-analytics/usage.js +1 -0
- package/dist/commands/canvas-analytics/view.d.ts +85 -0
- package/dist/commands/canvas-analytics/view.js +1 -0
- package/dist/commands/canvas-analytics.d.ts +2 -0
- package/dist/commands/canvas-analytics.js +1 -0
- package/dist/commands/canvas-prune.js +1 -1
- package/dist/commands/canvas.js +1 -1
- package/dist/commands/cron.js +5 -5
- package/dist/commands/human/components.d.ts +2 -0
- package/dist/commands/human/components.js +2 -2
- package/dist/commands/human/prompts.js +1 -1
- package/dist/commands/human/queue.js +1 -1
- package/dist/commands/memory/client.d.ts +11 -0
- package/dist/commands/memory/client.js +1 -0
- package/dist/commands/memory/delete.js +1 -1
- package/dist/commands/memory/edit.js +3 -3
- package/dist/commands/memory/find.js +1 -1
- package/dist/commands/memory/history.js +4 -4
- package/dist/commands/memory/lint.js +1 -1
- package/dist/commands/memory/list.d.ts +0 -2
- package/dist/commands/memory/list.js +1 -1
- package/dist/commands/memory/move.js +1 -1
- package/dist/commands/memory/origin.js +1 -1
- package/dist/commands/memory/read.d.ts +0 -5
- package/dist/commands/memory/read.js +3 -3
- package/dist/commands/memory/shared.d.ts +0 -178
- package/dist/commands/memory/shared.js +1 -12
- package/dist/commands/memory/write.js +5 -5
- package/dist/commands/node/bash.js +5 -5
- package/dist/commands/node/create.d.ts +0 -17
- package/dist/commands/node/create.js +2 -3
- package/dist/commands/node/inspect.js +6 -6
- package/dist/commands/node/lifecycle.js +2 -2
- package/dist/commands/node-context.js +2 -2
- package/dist/commands/node-inspect-artifacts.js +6 -6
- package/dist/commands/pkg/browse/catalog.js +1 -1
- package/dist/commands/pkg/browse/model.d.ts +1 -1
- package/dist/commands/pkg/market-manage.js +1 -1
- package/dist/commands/pkg/plugin-manage.js +10 -10
- package/dist/commands/profile/daemon-profiles.d.ts +13 -0
- package/dist/commands/profile/daemon-profiles.js +4 -0
- package/dist/commands/profile/delete.js +1 -1
- package/dist/commands/profile/env.d.ts +6 -0
- package/dist/commands/profile/env.js +2 -2
- package/dist/commands/profile/kind.js +1 -2
- package/dist/commands/profile/list.js +1 -1
- package/dist/commands/profile/meta.js +1 -1
- package/dist/commands/profile/new.js +1 -1
- package/dist/commands/profile/pause.js +1 -1
- package/dist/commands/profile/project.js +1 -1
- package/dist/commands/profile/rename.js +1 -1
- package/dist/commands/profile/show.js +1 -1
- package/dist/commands/profile.js +1 -1
- package/dist/commands/push.js +3 -3
- package/dist/commands/surface-inspect.js +1 -1
- package/dist/commands/sys/branch.js +1 -1
- package/dist/commands/sys/config.js +1 -1
- package/dist/commands/sys/connect.js +3 -3
- package/dist/commands/sys/context/admin/actions.js +1 -1
- package/dist/commands/sys/context/admin/model.d.ts +1 -0
- package/dist/commands/sys/context/admin/model.js +1 -1
- package/dist/commands/sys/context/admin.js +1 -1
- package/dist/commands/sys/context/expose.js +2 -1
- package/dist/commands/sys/context/prompt-review.js +2 -2
- package/dist/commands/sys/context/resolve.js +7 -7
- package/dist/commands/sys/context/sysprompt.js +1 -1
- package/dist/commands/sys/join.d.ts +1 -0
- package/dist/commands/sys/join.js +1 -0
- package/dist/commands/sys/migrate.js +1 -1
- package/dist/commands/sys/panels/models-panel.js +1 -1
- package/dist/commands/sys/panels/profiles-panel.d.ts +0 -1
- package/dist/commands/sys/panels/profiles-panel.js +1 -1
- package/dist/commands/sys/provider-login.js +6 -6
- package/dist/commands/sys/setup-core.d.ts +1 -1
- package/dist/commands/sys/setup-core.js +6 -6
- package/dist/commands/sys/setup-settings-runner.js +1 -1
- package/dist/commands/sys/setup.js +1 -1
- package/dist/commands/sys/spaces.d.ts +1 -0
- package/dist/commands/sys/spaces.js +2 -0
- package/dist/commands/sys/sync-deps.js +2 -2
- package/dist/commands/sys/sync-project-guidance.js +4 -4
- package/dist/commands/sys/sync-skills.js +2 -2
- package/dist/commands/sys/worktrees.d.ts +1 -0
- package/dist/commands/sys/worktrees.js +1 -1
- package/dist/commands/sys.js +1 -1
- package/dist/core/auth-file.js +2 -2
- package/dist/core/bash-job-supervisor.d.ts +6 -0
- package/dist/core/bash-job-supervisor.js +4 -0
- package/dist/core/bash-jobs.d.ts +13 -6
- package/dist/core/bash-jobs.js +8 -7
- package/dist/core/broker-client/transport-relay.d.ts +6 -3
- package/dist/core/broker-client/transport-relay.js +1 -1
- package/dist/core/broker-client/transport-socket.d.ts +6 -1
- package/dist/core/broker-client/transport-socket.js +1 -1
- package/dist/core/canvas/canvas.d.ts +39 -18
- package/dist/core/canvas/canvas.js +21 -20
- package/dist/core/canvas/context-strip.d.ts +20 -0
- package/dist/core/canvas/context-strip.js +5 -0
- package/dist/core/canvas/crons.d.ts +12 -20
- package/dist/core/canvas/crons.js +15 -13
- package/dist/core/canvas/db.js +2 -2
- package/dist/core/canvas/deliveries.d.ts +4 -1
- package/dist/core/canvas/deliveries.js +1 -1
- package/dist/core/canvas/executions.js +1 -1
- package/dist/core/canvas/history.d.ts +2 -1
- package/dist/core/canvas/history.js +17 -18
- package/dist/core/canvas/memory-reads.d.ts +19 -0
- package/dist/core/canvas/memory-reads.js +1 -0
- package/dist/core/canvas/migrations.d.ts +0 -4
- package/dist/core/canvas/migrations.js +99 -32
- package/dist/core/canvas/nav-render.js +1 -1
- package/dist/core/canvas/node-agent-paths.d.ts +8 -0
- package/dist/core/canvas/node-agent-paths.js +1 -0
- package/dist/core/canvas/node-recap.d.ts +2 -2
- package/dist/core/canvas/node-recap.js +2 -2
- package/dist/core/canvas/node-tokens.d.ts +24 -0
- package/dist/core/canvas/node-tokens.js +5 -0
- package/dist/core/canvas/paths.d.ts +16 -19
- package/dist/core/canvas/paths.js +1 -1
- package/dist/core/canvas/render-source.d.ts +2 -2
- package/dist/core/canvas/render-source.js +6 -9
- package/dist/core/canvas/sessions.d.ts +18 -0
- package/dist/core/canvas/sessions.js +4 -1
- package/dist/core/canvas/types.d.ts +22 -6
- package/dist/core/command-hooks/compose.js +1 -1
- package/dist/core/command-hooks/discovery.d.ts +15 -1
- package/dist/core/command-hooks/discovery.js +1 -1
- package/dist/core/command-hooks/help.d.ts +2 -2
- package/dist/core/command-hooks/lifecycle-create.d.ts +1 -1
- package/dist/core/command-hooks/lifecycle-create.js +1 -1
- package/dist/core/command-hooks/transport/exec-invoke.d.ts +2 -0
- package/dist/core/command-hooks/transport/exec-invoke.js +1 -1
- package/dist/core/command-hooks/transport/exec-lifecycle.d.ts +1 -0
- package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -1
- package/dist/core/command-hooks/transport/plan.d.ts +3 -0
- package/dist/core/command-hooks/transport/plan.js +1 -0
- package/dist/core/command-plugins/discovery.js +1 -1
- package/dist/core/command.d.ts +6 -2
- package/dist/core/command.js +6 -6
- package/dist/core/config.d.ts +8 -5
- package/dist/core/config.js +1 -1
- package/dist/core/conversation-store/client-worker.d.ts +1 -0
- package/dist/core/conversation-store/client-worker.js +1 -0
- package/dist/core/conversation-store/client.d.ts +2 -0
- package/dist/core/conversation-store/client.js +2 -0
- package/dist/core/conversation-store/file-store.d.ts +37 -0
- package/dist/core/conversation-store/file-store.js +9 -0
- package/dist/core/conversation-store/index.d.ts +50 -0
- package/dist/core/conversation-store/index.js +1 -0
- package/dist/core/conversation-store/listener.d.ts +4 -0
- package/dist/core/conversation-store/listener.js +3 -0
- package/dist/core/conversation-store/patch.d.ts +1 -0
- package/dist/core/conversation-store/patch.js +1 -0
- package/dist/core/directory/join.d.ts +27 -0
- package/dist/core/directory/join.js +1 -0
- package/dist/core/disk-usage.d.ts +4 -0
- package/dist/core/disk-usage.js +1 -0
- package/dist/core/events/emit.d.ts +2 -0
- package/dist/core/events/emit.js +3 -1
- package/dist/core/feed/feed.js +4 -4
- package/dist/core/feed/messages.d.ts +3 -0
- package/dist/core/feed/messages.js +6 -6
- package/dist/core/fs-utils.d.ts +2 -0
- package/dist/core/fs-utils.js +3 -3
- package/dist/core/grants/local.d.ts +4 -0
- package/dist/core/grants/local.js +1 -0
- package/dist/core/grants/mirror.d.ts +44 -0
- package/dist/core/grants/mirror.js +4 -0
- package/dist/core/grants/on-sync.d.ts +22 -0
- package/dist/core/grants/on-sync.js +1 -0
- package/dist/core/grants/remove.d.ts +7 -0
- package/dist/core/grants/remove.js +1 -0
- package/dist/core/grants/sandboxes.d.ts +7 -0
- package/dist/core/grants/sandboxes.js +1 -0
- package/dist/core/grants/sync.d.ts +12 -0
- package/dist/core/grants/sync.js +1 -0
- package/dist/core/help/memory-extensions.d.ts +3 -0
- package/dist/core/help/memory-extensions.js +2 -0
- package/dist/core/help.d.ts +14 -0
- package/dist/core/help.js +7 -7
- package/dist/core/host-exports/builtins.js +3 -3
- package/dist/core/host-exports/export.js +3 -3
- package/dist/core/human/action-binding.d.ts +2 -0
- package/dist/core/human/action-binding.js +1 -1
- package/dist/core/human/feedback-companion.d.ts +0 -1
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/page-schema.d.ts +1 -1
- package/dist/core/inspector/core.d.ts +2 -0
- package/dist/core/inspector/core.js +1 -1
- package/dist/core/inspector/tui.js +2 -2
- package/dist/core/installed-plugins.js +1 -1
- package/dist/core/io.js +6 -6
- package/dist/core/keybindings/catalog.d.ts +1 -1
- package/dist/core/keybindings/catalog.js +1 -1
- package/dist/core/layout-migrate/index.d.ts +15 -0
- package/dist/core/layout-migrate/index.js +4 -0
- package/dist/core/layout-migrate/paths.d.ts +26 -0
- package/dist/core/layout-migrate/paths.js +1 -0
- package/dist/core/layout-migrate/stored-paths.d.ts +2 -0
- package/dist/core/layout-migrate/stored-paths.js +11 -0
- package/dist/core/layout-migrate/stores.d.ts +17 -0
- package/dist/core/layout-migrate/stores.js +4 -0
- package/dist/core/layout.d.ts +26 -0
- package/dist/core/layout.js +2 -0
- package/dist/core/llm/run.d.ts +60 -0
- package/dist/core/llm/run.js +4 -0
- package/dist/core/memory/cli-selector.d.ts +13 -0
- package/dist/core/memory/cli-selector.js +1 -0
- package/dist/core/memory/history.d.ts +5 -4
- package/dist/core/memory/history.js +6 -6
- package/dist/core/memory/inline-ref-inventory.d.ts +2 -1
- package/dist/core/memory/inline-ref-inventory.js +1 -1
- package/dist/core/memory/lint.js +2 -2
- package/dist/core/memory/mutation-domain.d.ts +2 -2
- package/dist/core/memory/mutation-domain.js +8 -7
- package/dist/core/memory/mutations.js +1 -1
- package/dist/core/memory/service.d.ts +5 -0
- package/dist/core/memory/service.js +2 -2
- package/dist/core/memory-resolver.d.ts +11 -7
- package/dist/core/memory-resolver.js +2 -2
- package/dist/core/model-auth/daemon-login.d.ts +13 -0
- package/dist/core/model-auth/daemon-login.js +1 -0
- package/dist/core/model-auth/flows.d.ts +45 -0
- package/dist/core/model-auth/flows.js +1 -0
- package/dist/core/model-auth/handoff-jti.d.ts +4 -0
- package/dist/core/model-auth/handoff-jti.js +1 -0
- package/dist/core/model-routes.js +1 -1
- package/dist/core/nested-stores.d.ts +2 -1
- package/dist/core/nested-stores.js +1 -2
- package/dist/core/preview-registry.js +2 -2
- package/dist/core/profiles/env-store.js +2 -2
- package/dist/core/profiles/manifest.d.ts +16 -5
- package/dist/core/profiles/manifest.js +1 -1
- package/dist/core/provider-management.js +1 -1
- package/dist/core/review/birth.js +1 -1
- package/dist/core/review/companion.d.ts +0 -2
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/fork.js +2 -2
- package/dist/core/review/realize.js +1 -1
- package/dist/core/review/stage.d.ts +1 -1
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/types.d.ts +1 -1
- package/dist/core/runs/events.d.ts +34 -0
- package/dist/core/runs/events.js +1 -0
- package/dist/core/runs/operations.d.ts +43 -0
- package/dist/core/runs/operations.js +12 -0
- package/dist/core/runtime/bearings-render.d.ts +2 -2
- package/dist/core/runtime/bearings-render.js +11 -11
- package/dist/core/runtime/bearings.js +2 -2
- package/dist/core/runtime/broker/cli-relay.d.ts +5 -0
- package/dist/core/runtime/broker/cli-relay.js +1 -0
- package/dist/core/runtime/broker/client-registry.d.ts +0 -5
- package/dist/core/runtime/broker/client-registry.js +1 -1
- package/dist/core/runtime/broker/daemon-ops.d.ts +28 -1
- package/dist/core/runtime/broker/daemon-ops.js +1 -1
- package/dist/core/runtime/broker/engine-drive.d.ts +0 -2
- package/dist/core/runtime/broker/engine-drive.js +1 -1
- package/dist/core/runtime/broker/fault-retry.d.ts +9 -0
- package/dist/core/runtime/broker/fault-retry.js +1 -1
- package/dist/core/runtime/broker/frame-dispatch.d.ts +5 -9
- package/dist/core/runtime/broker/frame-dispatch.js +1 -1
- package/dist/core/runtime/broker/frame-engine-control.d.ts +3 -2
- package/dist/core/runtime/broker/frame-engine-control.js +1 -1
- package/dist/core/runtime/broker/frame-memory-refs.d.ts +4 -3
- package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
- package/dist/core/runtime/broker/frame-read.js +1 -1
- package/dist/core/runtime/broker/frame-session.js +1 -1
- package/dist/core/runtime/broker/held-deferred-inbox.d.ts +3 -1
- package/dist/core/runtime/broker/held-deferred-inbox.js +1 -1
- package/dist/core/runtime/broker/inbox.d.ts +1 -2
- package/dist/core/runtime/broker/inbox.js +7 -10
- package/dist/core/runtime/broker/model-adapter.d.ts +9 -0
- package/dist/core/runtime/broker/model-adapter.js +2 -0
- package/dist/core/runtime/broker/node-token.d.ts +3 -0
- package/dist/core/runtime/broker/node-token.js +1 -0
- package/dist/core/runtime/broker/read-ops.js +1 -1
- package/dist/core/runtime/broker/rebind.d.ts +2 -0
- package/dist/core/runtime/broker/rebind.js +1 -1
- package/dist/core/runtime/broker/tool-groups.js +1 -1
- package/dist/core/runtime/broker/turn-ignition.d.ts +3 -3
- package/dist/core/runtime/broker/turn-ignition.js +1 -1
- package/dist/core/runtime/broker-cli.js +3 -3
- package/dist/core/runtime/broker-extension-render.d.ts +2 -5
- package/dist/core/runtime/broker-extension-render.js +4 -4
- package/dist/core/runtime/broker-persona-guidance.js +3 -3
- package/dist/core/runtime/broker-protocol.d.ts +7 -8
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/canvas-extensions.d.ts +1 -0
- package/dist/core/runtime/canvas-extensions.js +1 -1
- package/dist/core/runtime/close.d.ts +9 -0
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/fleet.d.ts +1 -1
- package/dist/core/runtime/front-door-login.js +1 -1
- package/dist/core/runtime/front-door.js +2 -2
- package/dist/core/runtime/headless-pi.d.ts +1 -1
- package/dist/core/runtime/headless-pi.js +1 -1
- package/dist/core/runtime/host.d.ts +1 -1
- package/dist/core/runtime/host.js +3 -1
- package/dist/core/runtime/invocation.d.ts +3 -0
- package/dist/core/runtime/kickoff.d.ts +1 -0
- package/dist/core/runtime/kickoff.js +16 -16
- package/dist/core/runtime/launch-target.d.ts +1 -1
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/launch.d.ts +10 -35
- package/dist/core/runtime/launch.js +1 -1
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/memory.d.ts +1 -1
- package/dist/core/runtime/memory.js +1 -1
- package/dist/core/runtime/model-registry.js +1 -1
- package/dist/core/runtime/model-swap.d.ts +17 -19
- package/dist/core/runtime/model-swap.js +1 -1
- package/dist/core/runtime/node-read.js +3 -2
- package/dist/core/runtime/nodes.d.ts +7 -0
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/outcome-document.js +1 -1
- package/dist/core/runtime/package-health.js +2 -2
- package/dist/core/runtime/persona.js +2 -2
- package/dist/core/runtime/pi-vendored.js +1 -1
- package/dist/core/runtime/placement-tmux.d.ts +1 -1
- package/dist/core/runtime/placement-tmux.js +1 -1
- package/dist/core/runtime/placement.js +1 -1
- package/dist/core/runtime/promote.js +1 -1
- package/dist/core/runtime/provider-credential-gate.js +2 -2
- package/dist/core/runtime/recovery-hold.d.ts +2 -0
- package/dist/core/runtime/recovery-hold.js +1 -0
- package/dist/core/runtime/recycle.js +1 -1
- package/dist/core/runtime/reopen.js +1 -1
- package/dist/core/runtime/reset.js +1 -1
- package/dist/core/runtime/revive.d.ts +1 -1
- package/dist/core/runtime/revive.js +2 -3
- package/dist/core/runtime/roadmap.js +4 -4
- package/dist/core/runtime/run-command.d.ts +6 -0
- package/dist/core/runtime/run-command.js +1 -1
- package/dist/core/runtime/session-branch.d.ts +2 -8
- package/dist/core/runtime/session-branch.js +1 -1
- package/dist/core/runtime/session-list-cache.d.ts +6 -22
- package/dist/core/runtime/session-list-cache.js +1 -1
- package/dist/core/runtime/situational-context.js +2 -2
- package/dist/core/runtime/spawn-env.d.ts +6 -6
- package/dist/core/runtime/spawn-env.js +1 -1
- package/dist/core/runtime/spawn.d.ts +5 -0
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/runtime/stop-guard.js +2 -2
- package/dist/core/runtime/stop-signals.d.ts +2 -2
- package/dist/core/runtime/stop-signals.js +1 -1
- package/dist/core/runtime/structured-output.d.ts +10 -4
- package/dist/core/runtime/structured-output.js +4 -4
- package/dist/core/runtime/tmux-bindings.js +3 -3
- package/dist/core/runtime/tmux-driver.d.ts +4 -0
- package/dist/core/runtime/tmux-driver.js +7 -7
- package/dist/core/runtime/view-socket.d.ts +9 -2
- package/dist/core/runtime/view-socket.js +1 -1
- package/dist/core/runtime/warm-pool.js +1 -1
- package/dist/core/scope.d.ts +3 -2
- package/dist/core/scope.js +1 -1
- package/dist/core/scoped-state/db.js +1 -1
- package/dist/core/scoped-state/migrate.js +3 -3
- package/dist/core/scoped-state/profiles.d.ts +2 -1
- package/dist/core/scoped-state/profiles.js +1 -1
- package/dist/core/scoped-state/schema.d.ts +2 -1
- package/dist/core/scoped-state/schema.js +4 -4
- package/dist/core/scopes.d.ts +2 -2
- package/dist/core/scopes.js +1 -1
- package/dist/core/secrets.d.ts +1 -0
- package/dist/core/secrets.js +2 -2
- package/dist/core/spaces/mounts.d.ts +32 -0
- package/dist/core/spaces/mounts.js +1 -0
- package/dist/core/spaces/open-beneath.d.ts +71 -0
- package/dist/core/spaces/open-beneath.js +1 -0
- package/dist/core/spaces/permissions.d.ts +46 -0
- package/dist/core/spaces/permissions.js +1 -0
- package/dist/core/spaces/process.d.ts +27 -0
- package/dist/core/spaces/process.js +1 -0
- package/dist/core/spaces/space.d.ts +8 -0
- package/dist/core/spaces/space.js +2 -0
- package/dist/core/spaces/stop.d.ts +8 -0
- package/dist/core/spaces/stop.js +2 -0
- package/dist/core/spaces/users.d.ts +19 -0
- package/dist/core/spaces/users.js +1 -0
- package/dist/core/subscription-state.d.ts +2 -0
- package/dist/core/subscription-state.js +3 -3
- package/dist/core/substrate/frontmatter-validation.js +1 -1
- package/dist/core/substrate/injected-store.d.ts +28 -3
- package/dist/core/substrate/injected-store.js +2 -1
- package/dist/core/substrate/listings.js +1 -1
- package/dist/core/substrate/memory-events.d.ts +6 -0
- package/dist/core/substrate/memory-events.js +1 -0
- package/dist/core/substrate/on-read-node.js +1 -1
- package/dist/core/substrate/on-read.d.ts +6 -6
- package/dist/core/substrate/on-read.js +5 -5
- package/dist/core/substrate/plan.js +1 -1
- package/dist/core/substrate/render-node.js +1 -1
- package/dist/core/substrate/render.d.ts +4 -3
- package/dist/core/substrate/render.js +38 -38
- package/dist/core/substrate/schema.d.ts +6 -0
- package/dist/core/substrate/schema.js +1 -1
- package/dist/core/tui/panel.js +1 -1
- package/dist/core/user-settings.d.ts +12 -0
- package/dist/core/user-settings.js +1 -1
- package/dist/core/worktree-mutation-async.js +5 -5
- package/dist/core/worktree-quarantine.js +1 -1
- package/dist/core/worktree-remove.d.ts +15 -0
- package/dist/core/worktree-remove.js +1 -0
- package/dist/core/worktree-sweep.js +6 -6
- package/dist/daemon/analytics/compute.d.ts +37 -0
- package/dist/daemon/analytics/compute.js +1 -0
- package/dist/daemon/analytics/scan-worker.d.ts +1 -0
- package/dist/daemon/analytics/scan-worker.js +2 -0
- package/dist/daemon/analytics/scan.d.ts +37 -0
- package/dist/daemon/analytics/scan.js +1 -0
- package/dist/daemon/api/app-listener.d.ts +11 -0
- package/dist/daemon/api/app-listener.js +21 -0
- package/dist/daemon/api/bridge.js +5 -5
- package/dist/daemon/api/handlers/analytics.d.ts +2 -0
- package/dist/daemon/api/handlers/analytics.js +1 -0
- package/dist/daemon/api/handlers/attach.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +2 -2
- package/dist/daemon/api/handlers/bash.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/canvas.d.ts +1 -1
- package/dist/daemon/api/handlers/canvas.js +6 -6
- package/dist/daemon/api/handlers/crons.js +1 -1
- package/dist/daemon/api/handlers/files.d.ts +1 -1
- package/dist/daemon/api/handlers/files.js +1 -1
- package/dist/daemon/api/handlers/health.js +2 -2
- package/dist/daemon/api/handlers/hook-exec.d.ts +2 -0
- package/dist/daemon/api/handlers/hook-exec.js +1 -0
- package/dist/daemon/api/handlers/human-requests.js +1 -1
- package/dist/daemon/api/handlers/inbox.js +1 -1
- package/dist/daemon/api/handlers/llm.d.ts +2 -0
- package/dist/daemon/api/handlers/llm.js +3 -0
- package/dist/daemon/api/handlers/memory-reads.d.ts +4 -0
- package/dist/daemon/api/handlers/memory-reads.js +1 -0
- package/dist/daemon/api/handlers/memory.js +5 -1
- package/dist/daemon/api/handlers/messages.js +2 -2
- package/dist/daemon/api/handlers/modelauth.js +1 -1
- package/dist/daemon/api/handlers/node-outcomes.js +1 -1
- package/dist/daemon/api/handlers/node-records.d.ts +2 -0
- package/dist/daemon/api/handlers/node-records.js +3 -0
- package/dist/daemon/api/handlers/nodes.d.ts +1 -1
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/profiles.d.ts +4 -1
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/reports.js +5 -3
- package/dist/daemon/api/handlers/reviews.d.ts +1 -1
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/handlers/run-routes.d.ts +2 -0
- package/dist/daemon/api/handlers/run-routes.js +1 -0
- package/dist/daemon/api/handlers/runs.d.ts +9 -0
- package/dist/daemon/api/handlers/runs.js +1 -0
- package/dist/daemon/api/handlers/subscriptions.js +1 -1
- package/dist/daemon/api/handlers/worktree.js +1 -1
- package/dist/daemon/api/map.d.ts +10 -4
- package/dist/daemon/api/map.js +2 -2
- package/dist/daemon/api/operations.d.ts +18 -0
- package/dist/daemon/api/operations.js +1 -0
- package/dist/daemon/api/principal.d.ts +42 -0
- package/dist/daemon/api/principal.js +1 -0
- package/dist/daemon/api/router.d.ts +27 -3
- package/dist/daemon/api/router.js +1 -1
- package/dist/daemon/api/server.d.ts +4 -0
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/api/vendor-signin.d.ts +7 -0
- package/dist/daemon/api/vendor-signin.js +77 -0
- package/dist/daemon/api/viewer-presence.d.ts +3 -0
- package/dist/daemon/api/viewer-presence.js +1 -0
- package/dist/daemon/cron/armed-context.d.ts +4 -0
- package/dist/daemon/cron/armed-context.js +1 -1
- package/dist/daemon/cron/escalation.js +3 -3
- package/dist/daemon/cron/lease-recovery.js +1 -1
- package/dist/daemon/cron/sinks.js +2 -2
- package/dist/daemon/cron-run.d.ts +5 -5
- package/dist/daemon/cron-run.js +1 -1
- package/dist/daemon/crtrd.js +8 -7
- package/dist/daemon/delivery/run-delivery.d.ts +4 -0
- package/dist/daemon/delivery/run-delivery.js +1 -1
- package/dist/daemon/fleet.d.ts +1 -1
- package/dist/daemon/fleet.js +6 -6
- package/dist/daemon/human/finish.js +7 -7
- package/dist/daemon/joined-owner.d.ts +5 -0
- package/dist/daemon/joined-owner.js +1 -0
- package/dist/daemon/manage.js +2 -2
- package/dist/daemon/messaging/node-message.js +1 -1
- package/dist/daemon/park-activity.js +1 -1
- package/dist/daemon/reconcilers/bash-deadline.js +1 -1
- package/dist/daemon/reconcilers/broker-supervision.d.ts +1 -1
- package/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/dist/daemon/reconcilers/delivery-lane.js +1 -1
- package/dist/daemon/reconcilers/live-obligation.d.ts +7 -0
- package/dist/daemon/reconcilers/live-obligation.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +20 -1
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
- package/dist/daemon/runs/append-section.d.ts +6 -0
- package/dist/daemon/runs/append-section.js +2 -0
- package/dist/daemon/runs/observer.d.ts +5 -0
- package/dist/daemon/runs/observer.js +4 -0
- package/dist/launcher/bwrap.d.ts +4 -0
- package/dist/launcher/bwrap.js +2 -0
- package/dist/launcher/client.d.ts +2 -0
- package/dist/launcher/client.js +3 -0
- package/dist/launcher/main.d.ts +1 -0
- package/dist/launcher/main.js +3 -0
- package/dist/launcher/netrule.d.ts +1 -0
- package/dist/launcher/netrule.js +1 -0
- package/dist/launcher/seccomp.d.ts +1 -0
- package/dist/launcher/seccomp.js +1 -0
- package/dist/launcher/spec.d.ts +88 -0
- package/dist/launcher/spec.js +1 -0
- package/dist/launcher/users.d.ts +18 -0
- package/dist/launcher/users.js +7 -0
- package/dist/launcher/validate.d.ts +22 -0
- package/dist/launcher/validate.js +1 -0
- package/dist/migrations/corpus.js +3 -3
- package/dist/migrations/runner.js +1 -1
- package/dist/native/linux/addon.node +0 -0
- package/dist/native/linux.d.ts +29 -0
- package/dist/native/linux.js +1 -0
- package/dist/pi-extensions/broker-local.js +2 -2
- package/dist/pi-extensions/canvas-bash-valve.d.ts +1 -3
- package/dist/pi-extensions/canvas-bash-valve.js +4 -7
- package/dist/pi-extensions/canvas-context-intro.d.ts +1 -2
- package/dist/pi-extensions/canvas-context-intro.js +2 -2
- package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
- package/dist/pi-extensions/canvas-inbox-watcher.d.ts +2 -1
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -1
- package/dist/pi-extensions/canvas-passive-context.d.ts +1 -1
- package/dist/pi-extensions/canvas-passive-context.js +11 -11
- package/dist/pi-extensions/canvas-recap.js +6 -6
- package/dist/pi-extensions/canvas-stophook.js +1 -1
- package/dist/pi-extensions/canvas-structured-output.js +4 -4
- package/dist/pi-extensions/canvas-tool-guide.js +1 -1
- package/dist/pi-extensions/system-prompt-entry.d.ts +15 -0
- package/dist/pi-extensions/system-prompt-entry.js +1 -0
- package/dist/shared/env.d.ts +5 -1
- package/dist/shared/env.js +1 -1
- package/dist/shared/strip-cd-prefix.d.ts +1 -0
- package/dist/shared/strip-cd-prefix.js +1 -0
- package/dist/types.d.ts +31 -15
- package/docs/cli/memory-and-preferences.md +3 -1
- package/docs/sdk/client.md +34 -0
- package/docs/sdk/errors.md +2 -0
- package/docs/sdk/memory.md +2 -2
- package/docs/sdk/streaming.md +21 -0
- package/package.json +18 -4
- package/packages/crouter-identity/dist/index.d.ts +54 -0
- package/packages/crouter-identity/dist/index.js +166 -0
- package/packages/crouter-identity/package.json +33 -0
- package/runtime.lock.json +34 -8
- package/scripts/build-native-linux.mjs +16 -0
- package/scripts/install-runtime.mjs +9 -7
- package/scripts/lib/isolation-env.mjs +42 -0
- package/scripts/runtime-smoke.mjs +49 -0
- package/src/native/linux/addon.c +249 -0
- package/dist/core/profiles/state-block.d.ts +0 -4
- package/dist/core/profiles/state-block.js +0 -3
- package/dist/core/runtime/broker/auth-reload.d.ts +0 -41
- package/dist/core/runtime/broker/auth-reload.js +0 -1
- package/dist/core/substrate/cli-context-delivery.d.ts +0 -22
- package/dist/core/substrate/cli-context-delivery.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u=Object.defineProperty;var s=(e,n)=>u(e,"name",{value:n,configurable:!0});import{envHomeOverride as w}from"../../shared/env.js";import{paneLocation as m,ensureSession as P,openNodeWindow as T,splitWindow as f,selectLayout as _}from"./tmux-driver.js";import{BROKER_VIEW_SOCKET_WAIT_MS as S}from"./view-socket.js";import{paneExists as x,paneLocation as h,paneOfNode as g,paneCurrentPath as B,paneSize as V,paneRunning as k,ensureSession as y,openNodeWindow as H,splitWindow as L,closePane as M,currentTmux as N,switchClient as K,selectWindow as b,selectLayout as z,selectPane as F,getPaneOption as Q,setPaneOption as $,breakPane as j,inTmux as q,piCommand as D,shellQuote as G,renameWindow as J,displayPopup as U,windowOfPane as X,respawnPaneSync as Y,respawnPaneInBackground as Z,respawnPaneInPlace as ee,runShellInBackground as ne,paneStartCommand as oe,panePid as ie,windowAlive as te,listLivePanes as re,VIEWER_STAMP_OPTION as ae,stampViewerPaneAsync as se,liveViewerPanes as le,sendAttachControl as ce,displayClientMessage as pe}from"./tmux-driver.js";import{installTmuxBindings as ue}from"./tmux-bindings.js";import{BROKER_VIEW_SOCKET_WAIT_MS as me,waitForBrokerViewSocket as Pe}from"./view-socket.js";function W(){const e=w();return e!==void 0?{CRTR_HOME:e}:{}}s(W,"viewerSplitEnv");function R(e,n,o={}){const l=`crtr surface attach to ${e}`,c={...W(),...o.waitForBroker===!0?{CRTR_ATTACH_WAIT_MS:String(S)}:{},...o.initialWhip===!0?{CRTR_ATTACH_INITIAL_WHIP:"1"}:{}},i=o.cwd??process.cwd();if(o.besidePane!==void 0){const r=f(o.besidePane,{cwd:i,env:c,command:l});if(r===null)return null;const p=m(r),d=p?.session??n,a=p?.window??null;return a!==null&&_(a,"even-horizontal"),{pane:r,session:d,window:a}}P(n,i);const t=T({session:n,name:o.name??e,cwd:i,env:c,command:l});return t===null?null:{pane:t.pane,session:n,window:t.window}}s(R,"openViewerPane");export{me as BROKER_VIEW_SOCKET_WAIT_MS,ae as VIEWER_STAMP_OPTION,j as breakPane,M as closePane,N as currentTmux,pe as displayClientMessage,U as displayPopup,y as ensureSession,Q as getPaneOption,q as inTmux,ue as installTmuxBindings,re as listLivePanes,le as liveViewerPanes,H as openNodeWindow,R as openViewerPane,B as paneCurrentPath,x as paneExists,h as paneLocation,g as paneOfNode,ie as panePid,k as paneRunning,V as paneSize,oe as paneStartCommand,D as piCommand,J as renameWindow,Z as respawnPaneInBackground,ee as respawnPaneInPlace,Y as respawnPaneSync,ne as runShellInBackground,z as selectLayout,F as selectPane,b as selectWindow,ce as sendAttachControl,$ as setPaneOption,G as shellQuote,L as splitWindow,se as stampViewerPaneAsync,K as switchClient,W as viewerSplitEnv,Pe as waitForBrokerViewSocket,te as windowAlive,X as windowOfPane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var V=Object.defineProperty;var r=(e,n)=>V(e,"name",{value:n,configurable:!0});import{envNodeId as $}from"../../shared/env.js";import{getNode as P,fullName as H,deleteNode as
|
|
1
|
+
var V=Object.defineProperty;var r=(e,n)=>V(e,"name",{value:n,configurable:!0});import{envNodeId as $}from"../../shared/env.js";import{getNode as P,fullName as H,deleteNode as b,listNodes as D,subscribersOf as M,openFocusRow as z,closeFocusRow as a,getFocusByNode as k,getFocusByPane as x,getFocusById as J,listFocuses as Q}from"../canvas/index.js";import{nodeHasAssistantMessage as U}from"../canvas/render-source.js";import{headlessBrokerHost as R}from"./host.js";import{fanDoctrineWake as X}from"./close.js";import{paneExists as w,paneLocation as y,closePane as v,currentTmux as j,switchClient as q,selectWindow as G,selectLayout as K,selectPane as T,getPaneOption as Y,setPaneOption as Z,respawnPaneSync as I,windowOfPane as ee,renameWindow as ne}from"./tmux-driver.js";import{openViewerPane as se,viewerSplitEnv as W,waitForBrokerViewSocket as oe}from"./placement-tmux.js";import{newJobId as ie}from"./nodes.js";import{isPidAlive as h}from"../canvas/pid.js";import{splitWindow as be,breakPane as ke,selectLayout as Re,selectPane as Te,focusWindow as We,selectWindow as Se,switchClient as Ae,openNodeWindow as Be,ensureSession as Ee,paneLocation as Ce,paneExists as Le,paneRunning as Ve,paneCurrentPath as $e,currentTmux as He,inTmux as De,paneOfNode as Me,setPaneOption as ze,getPaneOption as Je,piCommand as Qe,shellQuote as Ue,respawnPaneSync as Xe,closePane as je,displayPopup as qe,windowOfPane as Ge,renameWindow as Ke,paneOfWindow as Ye,windowAlive as Ze,listLivePanes as Ie,listLivePanesAsync as en}from"./tmux-driver.js";import{installTmuxBindings as sn}from"./tmux-bindings.js";function g(e){return e===null?null:e.pane!==null&&!w(e.pane)?(a(e.focus_id),null):e}r(g,"liveOrPrune");function p(e){return g(k(e))}r(p,"focusOf");function xe(e){return p(e)!==null}r(xe,"isFocused");function te(e){return g(x(e))}r(te,"focusByPane");function ye(){return new Set(re().map(e=>e.node_id))}r(ye,"focusedNodes");function re(){const e=[];for(const n of Q())g(n)!==null&&e.push(n);return e}r(re,"listFocuses");function le(){return`f-${ie()}`}r(le,"newFocusId");function S(e,n,s,o){const u=x(n);if(u!==null)return u;const t=k(e);if(t!==null)return t;const l=le();return z(l,n,s,e),J(l)}r(S,"registerViewerFocus");function A(e,n,s={}){const o=se(e,n,s);return o===null?null:S(e,o.pane,o.session,o.window)}r(A,"openViewerWindow");function B(e){const n=y(e)?.window??null;n!==null&&K(n,"even-horizontal"),T(e)}r(B,"surfaceNewPane");async function he(e,n){const s=P(e);if(s===null)return{focused:!1,session:null,inPlace:!1,revived:!1};const o=n.pane??process.env.TMUX_PANE??j()?.pane;if(o===void 0||o==="")return{focused:!1,session:null,inPlace:!1,revived:!1};const u=h(s.pi_pid??null),t=n.revive(e),l=!u;if(!await oe(e,t?.launch?.exited))return{focused:!1,session:null,inPlace:!1,revived:l};const d=y(o)?.session??null,N=d??"";if(n.inPlace===!0){const i=p(e);i!==null&&(i.pane!==null&&i.pane!==o&&w(i.pane)&&v(i.pane),a(i.focus_id));const c=x(o);c!==null&&c.node_id!==e&&a(c.focus_id);try{Z(o,"@crtr_node","")}catch{}const _=ee(o),F=c?.node_id,L=F===void 0?W():{...W(),CRTR_ATTACH_ROSTER:F},O=I({pane:o,cwd:s.cwd,env:L,command:`crtr surface attach to ${e}`});return O&&(_!==null&&ne(_,H(s)),S(e,o,d,_)),{focused:O,session:d,inPlace:!0,revived:l}}if(n.newPane===!0){const i=p(e);i!==null&&(i.pane!==null&&w(i.pane)&&v(i.pane),a(i.focus_id));const c=A(e,N,{cwd:s.cwd,besidePane:o});return c===null?{focused:!1,session:null,inPlace:!1,revived:l}:(c.pane!==null&&B(c.pane),{focused:!0,session:c.session,inPlace:!1,revived:l})}const f=p(e);if(f!==null&&f.pane!==null)if(Y(f.pane,"@crtr_node")===e){const i=y(f.pane);if(i!==null)return q(i.session),G(i.session,i.window),T(f.pane),{focused:!0,session:i.session,inPlace:!0,revived:l};a(f.focus_id)}else a(f.focus_id);const m=A(e,N,{cwd:s.cwd,besidePane:o});return m===null?{focused:!1,session:null,inPlace:!1,revived:l}:(m.pane!==null&&B(m.pane),{focused:!0,session:m.session,inPlace:!1,revived:l})}r(he,"focus");function E(e,n){const s=p(e);s!==null&&(s.pane!==null&&s.pane!==n&&w(s.pane)&&v(s.pane),a(s.focus_id))}r(E,"tearDownNode");function ge(e,n){const s=n??p(e)?.pane??null;if(s===null||!w(s))return!1;const o=te(s);o!==null&&a(o.focus_id);const u=v(s);return ue(e),u}r(ge,"detachToBackground");function C(e){const n=P(e);return n===null||n.streaming===!0&&h(n.pi_pid)?!1:!U(n.pi_session_file)}r(C,"isEmptyNode");function ue(e,n,s=!0){return P(e)?.managed_worktree?.state==="open"||!C(e)?!1:(s&&R.teardown(e),E(e,n),b(e).deleted)}r(ue,"reapIfEmpty");function Ne(e={}){const n=e.dryRun??!1,s=$()??"",o=[];for(const u of D()){const t=u.node_id,l=P(t);if(t===s||u.status==="dead"||h(u.pi_pid)||l?.managed_worktree?.state==="open"||!C(t))continue;const d=M(t);!n&&(X(t,d,`Child closed \u2014 ${l?.name??t} (${t}) was closed from the canvas and is no longer running.`,{reason:"child-closed",child:t}),R.teardown(t),E(t),!b(t).deleted)||o.push(t)}return o}r(Ne,"reapEmptyNodes");export{ke as breakPane,je as closePane,He as currentTmux,ge as detachToBackground,qe as displayPopup,Ee as ensureSession,he as focus,te as focusByPane,p as focusOf,We as focusWindow,ye as focusedNodes,Je as getPaneOption,De as inTmux,sn as installTmuxBindings,xe as isFocused,re as listFocuses,Ie as listLivePanes,en as listLivePanesAsync,Be as openNodeWindow,A as openViewerWindow,$e as paneCurrentPath,Le as paneExists,Ce as paneLocation,Me as paneOfNode,Ye as paneOfWindow,Ve as paneRunning,Qe as piCommand,Ne as reapEmptyNodes,ue as reapIfEmpty,S as registerViewerFocus,Ke as renameWindow,Xe as respawnPaneSync,Re as selectLayout,Te as selectPane,Se as selectWindow,ze as setPaneOption,Ue as shellQuote,be as splitWindow,Ae as switchClient,E as tearDownNode,Ze as windowAlive,Ge as windowOfPane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var g=Object.defineProperty;var l=(n,e)=>g(n,"name",{value:e,configurable:!0});import{getNode as m,updateNode as
|
|
1
|
+
var g=Object.defineProperty;var l=(n,e)=>g(n,"name",{value:e,configurable:!0});import{getNode as m,updateNode as x}from"../canvas/index.js";import{transition as E}from"./lifecycle.js";import{ensureDaemon as P}from"../../daemon/manage.js";import{buildLaunchSpec as $,buildLaunchSpecAsync as A}from"./launch.js";import{hasRoadmap as t,seedRoadmap as u,roadmapPath as c}from"./roadmap.js";import{readGoal as f,goalPath as k}from"./kickoff.js";function h(n,e){const d=m(n);if(d===null)throw new Error(`unknown node: ${n}`);const r=e.kind??d.kind,o=e.mode??d.mode,i=e.lifecycle??d.lifecycle,a=e.profileId===void 0?d.profile_id??null:e.profileId;return{node:d,kind:r,mode:o,lifecycle:i,profileId:a,launchOpts:{lifecycle:i,hasManager:d.parent!==null,model:e.model??d.model_override??void 0,modelOverride:e.model!==void 0,modelIntent:e.model===void 0?d.launch?.modelIntent:void 0,modelExact:e.model===void 0?d.launch?.modelExact:void 0,cwd:d.cwd,profileId:a}}}l(h,"reshapeInputs");function w(n,e,d,r,o){o?.();const i=d.node.name===d.node.kind&&d.kind!==d.node.kind;return x(n,{kind:d.kind,mode:d.mode,lifecycle:d.lifecycle,profile_id:d.profileId,launch:r,...i?{name:d.kind}:{},...e.model!==void 0?{model_override:r?.model??e.model}:{}})}l(w,"persistReshape");function s(n,e={},d){const r=h(n,e);return w(n,e,r,$(r.kind,r.mode,r.launchOpts).launch,d)}l(s,"reshapeNode");async function y(n,e={},d){const r=h(n,e),{launch:o}=await A(r.kind,r.mode,r.launchOpts);return w(n,e,r,o,d)}l(y,"reshapeNodeAsync");function N(n,e={}){const d=m(n);if(d===null)throw new Error(`unknown node: ${n}`);let r=!1;return{meta:s(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{},mode:"orchestrator",lifecycle:e.resident===!0?"resident":d.lifecycle},()=>{if(!t(n)){const i=f(n);u(n,i!==null&&i.trim()!==""?{goal:i.trim()}:{}),r=!0}}),roadmapWritten:r,roadmapPath:c(n),goalPath:k(n)}}l(N,"promote");async function O(n,e={}){const d=m(n);if(d===null)throw new Error(`unknown node: ${n}`);let r=!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":d.lifecycle},()=>{if(!t(n)){const i=f(n);u(n,i!==null&&i.trim()!==""?{goal:i.trim()}:{}),r=!0}}),roadmapWritten:r,roadmapPath:c(n),goalPath:k(n)}}l(O,"promoteAsync");async function Y(n,e={},d={}){if(m(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}:{}}),{...R(n,{},d),promoted:e.promote===!0}}l(Y,"requestYieldAsync");function R(n,e={},d={}){const r=d.ensure??P;if(m(n)===null)throw new Error(`unknown node: ${n}`);const i=e.kind!==void 0||e.model!==void 0;let a=!1;return e.promote===!0?(N(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),a=!0):i&&s(n,{...e.kind!==void 0?{kind:e.kind}:{},...e.model!==void 0?{model:e.model}:{}}),r(),E(n,"yield"),{meta:m(n),promoted:a,willRefresh:!0}}l(R,"requestYield");export{N as promote,O as promoteAsync,R as requestYield,Y as requestYieldAsync,s as reshapeNode,y as reshapeNodeAsync};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var m=Object.defineProperty;var o=(r,e)=>m(r,"name",{value:e,configurable:!0});import{ModelRegistry as
|
|
2
|
-
`),process.exit(1)}o(
|
|
1
|
+
var m=Object.defineProperty;var o=(r,e)=>m(r,"name",{value:e,configurable:!0});import{ModelRegistry as p,ModelRuntime as a}from"@earendil-works/pi-coding-agent";import{join as n}from"node:path";import{PoolCredentialStore as c}from"../pool-credential-store.js";import{readProfileEnvVars as d}from"../profiles/env-store.js";import{hasProviderCredential as l}from"../provider-credential.js";import{piAgentDir as f}from"./package-health.js";import{secretsDir as u}from"../layout.js";import{PROVIDER_ENV_KEYS as E}from"./spawn-env.js";const v="crtr: no provider credential; run `crtr sys setup` to log in.";async function w(r=null){const e=d(r);if(Object.values(E).some(i=>(e[i]??process.env[i])?.trim()))return!0;const s=f(),t=await a.create({credentials:new c(n(u(),"auth.json")),modelsPath:n(s,"models.json")});return l(t,new p(t))}o(w,"hasConfiguredProviderCredential");function M(){process.stderr.write(`${v}
|
|
2
|
+
`),process.exit(1)}o(M,"exitForMissingProviderCredential");export{v as NO_PROVIDER_CREDENTIAL_MESSAGE,M as exitForMissingProviderCredential,w as hasConfiguredProviderCredential};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=Object.defineProperty;var t=(e,n)=>o(e,"name",{value:n,configurable:!0});const r=new Set;function d(e){return r.add(e),()=>{r.delete(e)}}t(d,"holdRecovery");function l(e){return r.has(e)}t(l,"isRecoveryHeld");export{d as holdRecovery,l as isRecoveryHeld};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var y=Object.defineProperty;var
|
|
1
|
+
var y=Object.defineProperty;var c=(e,t)=>y(e,"name",{value:t,configurable:!0});import{readdirBeneath as h,readFileBeneath as _,statBeneath as v}from"../spaces/open-beneath.js";import{join as w}from"node:path";import{abortExecution as g,beginExecution as R,getNode as m,setPresence as b,setFocusOccupant as E,fullName as k,recordExecutionPid as S,recordLaunch as x}from"../canvas/index.js";import{nodeAgentDir as B,reportsDir as T}from"../canvas/node-agent-paths.js";import{pushFinal as D}from"../feed/feed.js";import{spawnNode as F,rootOfSpine as N}from"./nodes.js";import{buildLaunchSpecAsync as O,buildPiArgv as P}from"./launch.js";import{focusOf as C,respawnPaneSync as A,setPaneOption as M}from"./placement.js";import{waitForBrokerViewSocket as z,viewerSplitEnv as L}from"./placement-tmux.js";import{headlessBrokerHost as p}from"./host.js";import{boundFleet as U}from"./fleet.js";import{transition as H}from"./lifecycle.js";import{ensureDaemon as V}from"../../daemon/manage.js";import{invokeBirthLifecycleHooks as X}from"./spawn.js";function $(e){try{const t=B(e),n=T(e),o=h(t,n).filter(r=>r.isFile()).map(r=>r.name).filter(r=>r.endsWith(".md"));if(o.length===0)return"";let l="",s=-1;for(const r of o){const i=v(t,w(n,r)).mtimeMs;i>s&&(s=i,l=r)}const d=_(t,w(n,l)).toString("utf8"),a=/^---\n[\s\S]*?\n---\n/.exec(d);return(a!==null?d.slice(a[0].length):d).trim()}catch{return""}}c($,"lastReportBody");async function se(e,t){const n=m(e);if(n===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 l=C(e);try{V()}catch{}const{launch:s}=await O("general","base",{lifecycle:"resident",hasManager:!1,cwd:n.cwd,profileId:n.profile_id}),d=$(e)||`Closed via recycle \u2014 no final summary was authored by ${n.name}.`;let a=[],r=!1;const i=await F({kind:"general",mode:"base",lifecycle:"resident",cwd:n.cwd,name:"general",parent:null,replaces:e,profile_id:n.profile_id,launch:s,beforeCreate:c(async()=>{try{a=(await D(e,d)).deliveredTo,r=!0}catch{}},"beforeCreate")}),u=m(i.node_id);await X(u);const f=P(u);if(f.env={...f.env,CRTR_SUBTREE:N(i.node_id)},!await j(u,f))return{recycled:!1,finalized:r,newRoot:i.node_id,delivered:a};try{p.teardown(e)}catch{}try{b(e,{pane:null,window:null,tmux_session:null})}catch{}if(l!==null)try{E(l.focus_id,i.node_id)}catch{}return{recycled:q(u,o),finalized:r,newRoot:i.node_id,delivered:a}}c(se,"recycleNode");async function j(e,t){const n=R(e.node_id,{daemonEpoch:U().epoch()});t.env={...t.env,CRTR_EXECUTION_ID:n};let o;try{if(o=await p.launch(e.node_id,t,{cwd:e.cwd,name:k(e),resuming:!1}),o.pid===null)throw new Error("broker host returned no pid");if(x(e.node_id,new Date().toISOString()),S(n,e.node_id,o.pid)==="shutdown")throw new Error("broker execution was superseded");if(await z(e.node_id,o.exited))return!0}catch{g(n,{reason:"launch_failed"})}try{W(e.node_id)}catch{}try{p.teardown(e.node_id)}catch{}return!1}c(j,"launchRecycledBroker");function W(e){const t=m(e);(t?.status==="active"||t?.status==="idle")&&H(e,"crash")}c(W,"transitionReplacementToDead");function q(e,t){try{M(t,"@crtr_node","")}catch{}return A({pane:t,cwd:e.cwd,env:L(),command:`crtr surface attach to ${e.node_id}`})}c(q,"respawnRecycledViewer");export{se as recycleNode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=Object.defineProperty;var n=(e,t)=>s(e,"name",{value:t,configurable:!0});import{join as c}from"node:path";import{clearFinalReportIfMatches as l,getFinalReport as p,getNode as f,
|
|
1
|
+
var s=Object.defineProperty;var n=(e,t)=>s(e,"name",{value:t,configurable:!0});import{join as c}from"node:path";import{clearFinalReportIfMatches as l,getFinalReport as p,getNode as f,updateNode as u}from"../canvas/index.js";import{reportsDir as m}from"../canvas/node-agent-paths.js";import{InputError as a}from"../io.js";import{transition as h}from"./lifecycle.js";function o(e){return p(e)}n(o,"currentFinalReport");function d(e,t){const r=c(m(e),t);throw new a({error:"node_finalized",message:`${e} already submitted its canonical final result (${r}) \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 ${e}'s spent latch and re-task it in place.`})}n(d,"throwNodeFinalized");function w(e){throw new a({error:"not_finalized",message:`${e} is not finalized \u2014 --reopen has nothing to clear.`,next:"Drop --reopen."})}n(w,"throwNotFinalized");function R(e){const t=o(e);t!==null&&d(e,t)}n(R,"assertNotFinalized");function g(e){const t=o(e);return t===null&&w(e),t}n(g,"assertFinalizedForReopen");function x(e,t){if(!l(e,t))throw new a({error:"reopen_latch_changed",message:`${e}'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."})}n(x,"commitReopen");function F(e,t){const r=o(e);u(e,{lifecycle:"resident"});const i=f(e);return i!==null&&(i.status==="done"||i.status==="canceled"||i.status==="dead")&&h(e,"revive"),r!==null&&x(e,t??r),r}n(F,"commitReopenResident");function b(e,t){if(t){const r=g(e);F(e,r);return}R(e)}n(b,"assertReopenGate");export{g as assertFinalizedForReopen,R as assertNotFinalized,b as assertReopenGate,x as commitReopen,F as commitReopenResident};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var y=Object.defineProperty;var l=(e,t)=>y(e,"name",{value:t,configurable:!0});import{getNode as p,beginExecution as E,recordExecutionPid as S,abortExecution as h,bindSession as B,recordLaunch as
|
|
1
|
+
var y=Object.defineProperty;var l=(e,t)=>y(e,"name",{value:t,configurable:!0});import{getNode as p,beginExecution as E,recordExecutionPid as S,abortExecution as h,bindSession as B,recordLaunch as b,fullName as k,liveExecutionForNode as F,closeFocusRow as N,view as R}from"../canvas/index.js";import{transition as a}from"./lifecycle.js";import{headlessBrokerHost as v,requestBrokerTeardown as g}from"./host.js";import{boundFleet as O}from"./fleet.js";import{tearDownNode as V,focusOf as D,registerViewerFocus as P,respawnPaneSync as T,windowOfPane as C,renameWindow as L}from"./placement.js";import{viewerSplitEnv as q,waitForBrokerViewSocket as A}from"./placement-tmux.js";import{buildLaunchSpecAsync as H,buildPiArgv as M}from"./launch.js";import{spawnNode as U,rootOfSpine as I}from"./nodes.js";import{invokeBirthLifecycleHooks as W}from"./spawn.js";function X(e){const t=[];for(const o of R(e))try{a(o,"cancel",{reason:"closed"}),g(o),V(o),t.push(o)}catch{}return t}l(X,"reapDescendants");async function te(e,t={}){const o=t.launchBroker??v.launch,s=t.waitForViewSocket??A,w=t.respawnViewer??T,c=t.teardownBroker??v.teardown,r=p(e);if(r===null||r.parent!=null||r.status==="done")return null;const d=D(e),{launch:x}=await H(r.kind,"base",{lifecycle:"resident",hasManager:!1,model:r.model_override??void 0,modelIntent:r.launch?.modelIntent,modelExact:r.launch?.modelExact,cwd:r.cwd,profileId:r.profile_id}),n=await U({kind:r.kind,mode:"base",lifecycle:"resident",cwd:r.cwd,name:r.kind,parent:null,replaces:e,profile_id:r.profile_id,launch:x,modelOverride:r.model_override??void 0});await W(n);const u=M(n,{});u.env={...u.env,CRTR_SUBTREE:I(n.node_id)};const f=E(n.node_id,{daemonEpoch:O().epoch()});u.env={...u.env,CRTR_EXECUTION_ID:f};let m;try{m=await o(n.node_id,u,{cwd:r.cwd,name:k(n),resuming:!1})}catch(i){throw h(f,{reason:"launch_failed"}),a(n.node_id,"crash"),i}if(m.pid==null)return h(f,{reason:"launch_failed"}),a(n.node_id,"crash"),null;if(b(n.node_id,new Date().toISOString()),S(f,n.node_id,m.pid)==="shutdown"){h(f,{reason:"superseded"});try{c(n.node_id)}catch{}return a(n.node_id,"crash"),null}let _=!1;try{_=await s(n.node_id,m.exited)}catch{}if(!_){const i=p(n.node_id);(i?.status==="active"||i?.status==="idle")&&a(n.node_id,"crash");try{c(n.node_id)}catch{}return null}if(X(e),a(e,"finish"),d?.pane!=null){N(d.focus_id),w({pane:d.pane,cwd:r.cwd,env:q(),command:`crtr surface attach to ${n.node_id}`});const i=C(d.pane);i!==null&&L(i,k(n)),P(n.node_id,d.pane,d.session,i)}return c(e),{newNodeId:n.node_id}}l(te,"relaunchRoot");function $(e,t,o){const s=p(e),w={reaped:[],detached:[],reset:!1};if(s===null||s.parent==null)return w;if(t!==void 0){const c=F(e);c!==null&&B(e,{executionId:c.executionId,sessionId:t,transcriptPath:o??null})}return w}l($,"resetRoot");function re(e,t,o){return p(e)===null?{path:"noop"}:($(e,t,o),{path:"reset-child"})}l(re,"handleNewSession");function oe(e,t){if(t!=="quit")return!1;const o=p(e);return o===null||o.status!=="active"&&o.status!=="idle"||o.intent!=null?!1:(a(e,"finish"),!0)}l(oe,"markCleanExitDone");export{re as handleNewSession,oe as markCleanExitDone,X as reapDescendants,te as relaunchRoot,$ as resetRoot};
|
|
@@ -45,7 +45,7 @@ export interface ReviveResult {
|
|
|
45
45
|
resumed: boolean;
|
|
46
46
|
/** Launch handle for the detached broker, so callers can fail fast on its real
|
|
47
47
|
* exit before the socket appears. */
|
|
48
|
-
launch?: ReturnType<typeof headlessBrokerHost.launch
|
|
48
|
+
launch?: Awaited<ReturnType<typeof headlessBrokerHost.launch>>;
|
|
49
49
|
/** Reads a fatal launch fault recorded by THIS revive attempt, scoped via
|
|
50
50
|
* `beginBootFaultAttempt` at the exact clear-then-launch boundary below.
|
|
51
51
|
* Present only when a fresh launch actually happened (absent on the
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)){if(r.trim()==="")continue;const i=JSON.parse(r);if(i.type==="session")return typeof i.cwd!="string"||p(i.cwd)}}catch{}return!0}s($e,"sessionCwdExists");function Se(e,r,i){const n=r.pi_session_file;if(n==null||n===""||!p(n))return{};const t=C(n);return t!==null&&t.node_id!==e&&de(t.pi_pid)?{}:$e(n)?Ee(r,i):{}}s(Se,"resumableSessionArgs");function Ce(e){return O(e)===null&&te(e)===null&&!oe(e)}s(Ce,"isUnstartedBirth");function er(e){const r=R(e);if(r!==null&&r.trim()!=="")return!0;const i=O(e);return i!==null&&i.trim()!==""}s(er,"hasFreshGroundState");async function rr(e,r){const i=await z(e,r,!0);if(i.parked)throw new Error(`reviveNode: internal parked decision for activating revive ${e}`);return i.result}s(rr,"reviveNode");async function ir(e,r,i){return z(e,r,i)}s(ir,"decideAttachRevive");async function z(e,r,i){let n=N(e);if(n===null)throw new Error(`reviveNode: unknown node ${e}`);if(n=N(e)??n,n.final_report!==null)throw new Error(`reviveNode: refusing to revive ${e} \u2014 its finalization latch is set (final_report=${n.final_report}). A final landed between the caller's reopen-gate check and this revive; re-run with --reopen if this retask is still wanted.`);we(n.profile_id);const t=A();if(t.has(e))return g(e,n.intent==="refresh"?"refresh-launch":"revive"),{parked:!1,result:{window:null,session:n.tmux_session??null,resumed:!1,outcome:"already-live"}};if(t.isClaimed(e))return{parked:!1,result:{window:null,session:n.tmux_session??null,resumed:!1,outcome:"already-live"}};if(!i&&n.lifecycle==="resident"&&ee(n))return{parked:!0};if(!t.reserveSlot(e)){if(r.capacity==="refuse")throw ue(B().automaticReviveCap,t.size());return n.frozen_at==null&&(Y(e,new Date().toISOString()),V(e,{reason:"frozen"}),Z({level:"info",event:"broker.frozen",node_id:e,fields:{live_count:t.size(),hard_cap:B().automaticReviveCap}})),{parked:!1,result:{window:null,session:n.tmux_session??null,resumed:!1,outcome:"frozen"}}}try{return{parked:!1,result:await Ne(e,n,r)}}finally{t.releaseReservation(e)}}s(z,"decideRevive");async function Ne(e,r,i){if(!p(r.cwd)){const h=r.fork_from!=null?`Restore ${r.cwd}, then revive the fork normally with \`crtr node lifecycle revive ${e}\`.`:r.managed_worktree?.state==="open"?"Restore or reconcile the recorded checkout, then use the managed-worktree close or abandon recovery.":`Recreate ${r.cwd}, or repair it with \`crtr node config --cwd <path> --node ${e}\`; durable node work resumes in a fresh conversation. Then retry \`crtr node lifecycle revive ${e}\`.`;throw new b({error:"cwd_missing",message:`${e} cannot be revived \u2014 its recorded cwd no longer exists: ${r.cwd}`,next:h})}r.host_kind!=="broker"&&(_(e,{host_kind:"broker"}),r.host_kind="broker"),r.review_binding!=null&&!ve(e)&&(r.pi_session_id!=null||r.pi_session_file!=null)&&(F(e),r.pi_session_id=null,r.pi_session_file=null);const t=r.fork_from!=null&&r.pi_session_id==null,c=r.fork_source_file;if(t&&(typeof c!="string"||!M(c)))throw new b({error:"fork_source_invalid",message:`${e} cannot be revived \u2014 its resolved fork source file is missing or invalid.`,next:`Restore the node's fork source metadata, then retry \`crtr node lifecycle revive ${e}\`.`});const f=t&&typeof c=="string";if(f&&!p(c))throw new b({error:"fork_from_missing",message:`${e} cannot be revived \u2014 its fork source no longer exists: ${c}`,next:`Restore ${c}, or update the node's fork source, then retry \`crtr node lifecycle revive ${e}\`.`});const u=W(e,{daemonEpoch:A().epoch()});try{r.cycles=(r.cycles??0)+1,_(e,{cycles:r.cycles});const U=r.intent==="refresh"||r.cycle_pending===!0?!1:i.resume,v=f?{}:Se(e,r,U),w=v.resumeSessionPath!==void 0,x=w&&v.newCycle===!0,k=w&&!x,E=!w&&(i.wakeReason===void 0||i.wakeReason==="runtime-restart-abort")&&Ce(e),H=f||E,$=r.cycle_pending===!0||x;_(e,{cycle_pending:$}),r.cycle_pending=$,!f&&!w&&(r.pi_session_id!=null||r.pi_session_file!=null)&&(F(e),r.pi_session_id=null,r.pi_session_file=null);let l,a=null;const S=s(()=>({type:"runtime",kind:"kickoff",...r.spawned_by!=null&&r.spawned_by!==""?{spawnedBy:r.spawned_by}:{}}),"birthOrigin");if(f){const o=R(e);l=m(r,{forkFrom:c,...o!=null&&o!==""?{prompt:o}:{}}),o!=null&&o!==""&&(a=S()),pe(e,C(c)?.node_id??null)}else if(k)l=m(r,{...v,...i.wakeReason==="runtime-restart-abort"?{prompt:se}:{}}),i.wakeReason==="runtime-restart-abort"&&(a={type:"runtime",kind:"restart-continuation"});else if(E){const o=R(e)?.trim();l=m(r,o!==void 0&&o!==""?{prompt:o}:{}),o!==void 0&&o!==""&&(a=S()),T(e)}else{const o=ne(r,u);l=m(r,{...v,prompt:ie(r,o,i.wakeReason==="runtime-restart-abort"?void 0:i.wakeReason)}),a=i.wakeReason!==void 0&&i.wakeReason!=="runtime-restart-abort"?{type:"runtime",kind:"wake",wake:i.wakeReason}:{type:"runtime",kind:"revive",cycle:r.cycles??0},T(e)}l.env={...l.env,CRTR_SUBTREE:he(e)},a!==null&&(l.env[ce]=le(a)),g(e,r.intent==="refresh"?"refresh-launch":"revive"),fe(e,{preserveEpisode:!0});const K=ae(e);i.recovery!==!0&&I(e),_e(e);const L=Re(r.cwd,r.profile_id).plans.get("node:start")??[];await xe(L,{node:{id:e,name:r.name,kind:r.kind,mode:r.mode,lifecycle:r.lifecycle,cwd:r.cwd,nodeDir:ge(e),contextDir:ke(e),jobDir:ye(e),reportsDir:be(e)},runtime:{isBirth:H,canvasHome:me(),profile:r.profile_id??null}}),l.env={...l.env,CRTR_EXECUTION_ID:u};let d;try{if(d=P.launch(e,l,{cwd:r.cwd,name:D(r),resuming:k}),d.pid===null)throw new Error(`broker host returned no pid for ${e}`)}catch(o){try{g(e,"crash",{reason:"launch_failed",outcome:{detail:{schema:"crtr.node-outcome-detail/v1",message:o instanceof Error?o.message:String(o)}}}),re(e,Q(e),`Child crashed \u2014 ${D(r)} (${e}) failed to relaunch and is now dead: ${o.message}
|
|
1
|
+
var W=Object.defineProperty;var s=(e,r)=>W(e,"name",{value:r,configurable:!0});import{existsSync as F}from"node:fs";import{conversationIdFromPath as _,conversationStore as k,ConversationNotFoundError as D}from"../conversation-store/index.js";import{isAbsolute as J}from"node:path";import{findNodeBySessionFile as V,getNode as g,updateNode as y,beginExecution as X,recordExecutionPid as Y,abortExecution as b,endLiveExecution as q,unbindSession as O,recordLaunch as Q,setFrozen as Z,clearFrozen as I,fullName as P,subscribersOf as ee}from"../canvas/index.js";import{emitEvent as re}from"../events/emit.js";import{cancelCronsOnWake as ie}from"../canvas/crons.js";import{isParked as ne,transition as R}from"./lifecycle.js";import{fanDoctrineWake as oe}from"./close.js";import{InputError as E}from"../io.js";import{buildPiArgv as w}from"./launch.js";import{buildReviveKickoff as te,drainBearings as se,hasRetainedReports as le,readGoal as x,readYieldMessage as ce,RUNTIME_RESTART_CONTINUATION as ae}from"./kickoff.js";import{readRoadmap as A}from"./roadmap.js";import{encodeKickoffOrigin as ue,KICKOFF_ORIGIN_ENV as fe}from"./stamp/protocol.js";import{headlessBrokerHost as T}from"./host.js";import{boundFleet as B,brokerCapReached as pe,brokerThresholdsForDaemon as z}from"./fleet.js";import{beginBootFaultAttempt as he,clearFault as de}from"../canvas/recovery.js";import{clearContextExposureState as U,initializeForkContextExposure as ve}from"../substrate/injected-store.js";import{forkSourceNode as we,rootOfSpine as me}from"./nodes.js";import{isReviewCompanionBound as _e}from"../review/companion.js";import{assertProfileActive as ke}from"../profiles/manifest.js";import{isPidAlive as ge}from"../canvas/pid.js";import{crtrHome as ye,jobDir as be}from"../canvas/paths.js";import{contextDir as Re,ensureNodeDirs as Ee,nodeAgentDir as xe,reportsDir as Se}from"../canvas/node-agent-paths.js";import{discoverLifecycleHookRegistry as $e}from"../command-hooks/discovery.js";import{invokeLifecycleHooks as Ce}from"../command-hooks/transport/exec-lifecycle.js";function Ne(e,r){const i=e.pi_session_file,n=i?_(i):null;if(n===null)return{};try{const t=k().header(n);return r?{resumeSessionPath:t.path}:{resumeSessionPath:t.path,newCycle:!0}}catch(t){if(t instanceof D)return{};throw t}}s(Ne,"resumeArgs");function H(e){const r=_(e);if(r===null)return!1;try{return k().header(r),!0}catch(i){if(i instanceof D)return!1;throw i}}s(H,"conversationExists");function Fe(e){const r=_(e);if(r===null)return!0;const i=k().header(r).header.cwd;return typeof i!="string"||F(i)}s(Fe,"sessionCwdExists");function De(e,r,i){const n=r.pi_session_file;if(!n||!H(n))return{};const t=V(n);return t!==null&&t.node_id!==e&&ge(t.pi_pid)?{}:Fe(n)?Ne(r,i):{}}s(De,"resumableSessionArgs");function Oe(e){return A(e)===null&&ce(e)===null&&!le(e)}s(Oe,"isUnstartedBirth");function sr(e){const r=x(e);if(r!==null&&r.trim()!=="")return!0;const i=A(e);return i!==null&&i.trim()!==""}s(sr,"hasFreshGroundState");async function lr(e,r){const i=await K(e,r,!0);if(i.parked)throw new Error(`reviveNode: internal parked decision for activating revive ${e}`);return i.result}s(lr,"reviveNode");async function cr(e,r,i){return K(e,r,i)}s(cr,"decideAttachRevive");async function K(e,r,i){let n=g(e);if(n===null)throw new Error(`reviveNode: unknown node ${e}`);if(n=g(e)??n,n.run_id&&g(n.run_id)?.deleting_at)throw new Error("run is deleting");if(n.final_report!==null)throw new Error(`reviveNode: refusing to revive ${e} \u2014 its finalization latch is set (final_report=${n.final_report}). A final landed between the caller's reopen-gate check and this revive; re-run with --reopen if this retask is still wanted.`);ke(n.profile_id);const t=B();if(t.has(e))return R(e,n.intent==="refresh"?"refresh-launch":"revive"),{parked:!1,result:{window:null,session:n.tmux_session??null,resumed:!1,outcome:"already-live"}};if(t.isClaimed(e))return{parked:!1,result:{window:null,session:n.tmux_session??null,resumed:!1,outcome:"already-live"}};if(!i&&n.lifecycle==="resident"&&ne(n))return{parked:!0};if(!t.reserveSlot(e)){if(r.capacity==="refuse")throw pe(z().automaticReviveCap,t.size());return n.frozen_at==null&&(Z(e,new Date().toISOString()),q(e,{reason:"frozen"}),re({level:"info",event:"broker.frozen",node_id:e,fields:{live_count:t.size(),hard_cap:z().automaticReviveCap}})),{parked:!1,result:{window:null,session:n.tmux_session??null,resumed:!1,outcome:"frozen"}}}try{return{parked:!1,result:await Pe(e,n,r)}}finally{t.releaseReservation(e)}}s(K,"decideRevive");async function Pe(e,r,i){if(!F(r.cwd)){const p=r.fork_from!=null?`Restore ${r.cwd}, then revive the fork normally with \`crtr node lifecycle revive ${e}\`.`:r.managed_worktree?.state==="open"?"Restore or reconcile the recorded checkout, then use the managed-worktree close or abandon recovery.":`Recreate ${r.cwd}, or repair it with \`crtr node config --cwd <path> --node ${e}\`; durable node work resumes in a fresh conversation. Then retry \`crtr node lifecycle revive ${e}\`.`;throw new E({error:"cwd_missing",message:`${e} cannot be revived \u2014 its recorded cwd no longer exists: ${r.cwd}`,next:p})}r.host_kind!=="broker"&&(y(e,{host_kind:"broker"}),r.host_kind="broker"),r.review_binding!=null&&!_e(e)&&(r.pi_session_id!=null||r.pi_session_file!=null)&&(O(e),r.pi_session_id=null,r.pi_session_file=null);const t=r.fork_from!=null&&r.pi_session_id==null,c=r.fork_source_file;if(t&&(typeof c!="string"||!J(c)))throw new E({error:"fork_source_invalid",message:`${e} cannot be revived \u2014 its resolved fork source file is missing or invalid.`,next:`Restore the node's fork source metadata, then retry \`crtr node lifecycle revive ${e}\`.`});const f=t&&typeof c=="string";if(f&&!H(c))throw new E({error:"fork_from_missing",message:`${e} cannot be revived \u2014 its fork source no longer exists: ${c}`,next:`Restore ${c}, or update the node's fork source, then retry \`crtr node lifecycle revive ${e}\`.`});const a=X(e,{daemonEpoch:B().epoch()});try{r.cycles=(r.cycles??0)+1,y(e,{cycles:r.cycles});const M=r.intent==="refresh"||r.cycle_pending===!0?!1:i.resume,h=f?{}:De(e,r,M),d=h.resumeSessionPath!==void 0,S=d&&h.newCycle===!0,m=d&&!S,$=!d&&(i.wakeReason===void 0||i.wakeReason==="runtime-restart-abort")&&Oe(e),G=f||$,C=r.cycle_pending===!0||S;y(e,{cycle_pending:C}),r.cycle_pending=C,!f&&!d&&(r.pi_session_id!=null||r.pi_session_file!=null)&&(O(e),r.pi_session_id=null,r.pi_session_file=null);let l,u=null;const N=s(()=>({type:"runtime",kind:"kickoff",...r.spawned_by!=null&&r.spawned_by!==""?{spawnedBy:r.spawned_by}:{}}),"birthOrigin");if(f){const o=x(e);l=w(r,{forkFrom:c,...o!=null&&o!==""?{prompt:o}:{}}),o!=null&&o!==""&&(u=N()),ve(e,we(c)?.node_id??null)}else if(m)l=w(r,{...h,...i.wakeReason==="runtime-restart-abort"?{prompt:ae}:{}}),i.wakeReason==="runtime-restart-abort"&&(u={type:"runtime",kind:"restart-continuation"});else if($){const o=x(e)?.trim();l=w(r,o!==void 0&&o!==""?{prompt:o}:{}),o!==void 0&&o!==""&&(u=N()),U(e)}else{const o=se(r,a);l=w(r,{...h,prompt:te(r,o,i.wakeReason==="runtime-restart-abort"?void 0:i.wakeReason)}),r.run_id&&o.unreadMessageIds?.length&&(l.env.CRTR_KICKOFF_MESSAGE_IDS=JSON.stringify(o.unreadMessageIds)),u=i.wakeReason!==void 0&&i.wakeReason!=="runtime-restart-abort"?{type:"runtime",kind:"wake",wake:i.wakeReason}:{type:"runtime",kind:"revive",cycle:r.cycles??0},U(e)}l.env={...l.env,CRTR_SUBTREE:me(e)},u!==null&&(l.env[fe]=ue(u)),R(e,r.intent==="refresh"?"refresh-launch":"revive"),de(e,{preserveEpisode:!0});const L=he(e);i.recovery!==!0&&ie(e),Ee(e,r.grantee);const j=$e(r.cwd,r.profile_id).plans.get("node:start")??[];await Ce(j,{node:{id:e,name:r.name,kind:r.kind,mode:r.mode,lifecycle:r.lifecycle,cwd:r.cwd,nodeDir:xe(e),contextDir:Re(e),jobDir:be(e),reportsDir:Se(e)},runtime:{isBirth:G,canvasHome:ye(),profile:r.profile_id??null}}),l.env={...l.env,CRTR_EXECUTION_ID:a};let v;try{if(v=await T.launch(e,l,{cwd:r.cwd,name:P(r),resuming:m}),v.pid===null)throw new Error(`broker host returned no pid for ${e}`)}catch(o){try{R(e,"crash",{reason:"launch_failed",outcome:{detail:{schema:"crtr.node-outcome-detail/v1",message:o instanceof Error?o.message:String(o)}}}),oe(e,ee(e),`Child crashed \u2014 ${P(r)} (${e}) failed to relaunch and is now dead: ${o.message}
|
|
3
2
|
|
|
4
|
-
It stays dead until you revive it \u2014 \`crtr node lifecycle revive ${e}\`.`,{reason:"child-crashed",child:e})}catch{}throw
|
|
3
|
+
It stays dead until you revive it \u2014 \`crtr node lifecycle revive ${e}\`.`,{reason:"child-crashed",child:e})}catch{}throw b(a,{reason:"launch_failed"}),new Error(`[broker] refusing to revive ${e}: ${o.message}`)}if(Q(e,new Date().toISOString()),Y(a,e,v.pid)==="shutdown")throw b(a,{reason:"superseded"}),T.teardown(e),new Error(`[broker] refusing to revive ${e}: execution was superseded during launch`);return I(e),{window:null,session:r.tmux_session??null,resumed:m,launch:v,faultExplanation:L.explanation,outcome:"launched"}}catch(p){throw b(a,{reason:"launch_failed"}),p}}s(Pe,"launchRevive");export{cr as decideAttachRevive,sr as hasFreshGroundState,Ne as resumeArgs,lr as reviveNode};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.defineProperty;var r=(e,t)=>n(e,"name",{value:t,configurable:!0});import{join as m}from"node:path";import{contextDir as s,nodeAgentDir as o}from"../canvas/node-agent-paths.js";import{existsBeneath as p,readTextBeneathIfExists as h,writeFileBeneath as u}from"../spaces/open-beneath.js";function a(e){return m(s(e),"roadmap.md")}r(a,"roadmapPath");function l(e){return p(o(e),a(e))}r(l,"hasRoadmap");function w(e){return h(o(e),a(e))}r(w,"readRoadmap");function R(e,t={}){const i=`# Roadmap
|
|
2
2
|
|
|
3
3
|
## Goal
|
|
4
|
-
${
|
|
4
|
+
${t.goal?.trim()??"(the goal you now own)"}
|
|
5
5
|
|
|
6
6
|
## Exit criteria
|
|
7
|
-
${
|
|
7
|
+
${t.exitCriteria?.trim()??'(what "done" looks like)'}
|
|
8
8
|
|
|
9
9
|
## Phases
|
|
10
10
|
(ordered phases from here to done; the current one carries a one-line status)
|
|
11
|
-
`;return
|
|
11
|
+
`;return u(o(e),a(e),i),i}r(R,"seedRoadmap");export{l as hasRoadmap,w as readRoadmap,a as roadmapPath,R as seedRoadmap};
|
|
@@ -22,6 +22,12 @@ export interface RunningCommand {
|
|
|
22
22
|
completion: Promise<RunCommandOnceResult>;
|
|
23
23
|
terminate(): void;
|
|
24
24
|
}
|
|
25
|
+
/** App commands use the broker's mount compiler and the root launcher on Linux.
|
|
26
|
+
* The Mac runs through the existing direct-spawn implementation. */
|
|
27
|
+
export declare function runAppCommand(options: RunCommandOnceOptions & {
|
|
28
|
+
nodeId?: string;
|
|
29
|
+
app: string;
|
|
30
|
+
}): Promise<RunningCommand>;
|
|
25
31
|
/** Start one admitted-PATH bash command in its own process group. The returned
|
|
26
32
|
* handle exposes the pid immediately for callers that must record ownership
|
|
27
33
|
* before waiting for completion; `completion` resolves after the process group
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var H=Object.defineProperty;var a=(e,s)=>H(e,"name",{value:s,configurable:!0});import{spawn as b}from"node:child_process";import{createHash as k}from"node:crypto";import{captureTeardownSnapshot as R,isAnyPidAlive as x,killProcessTreePids as L}from"../canvas/pid.js";import{CRON_DEATH_POLL_MS as B,CRON_KILL_GRACE_MS as G,newHeadCapture as M}from"../../daemon/cron/capture.js";import{resolveAdmittedHostCommand as O}from"./spawn-env.js";import{appProcessSandboxed as K,launchAppProcess as N}from"../spaces/process.js";async function V(e){if(!K())return $(e);const s=Date.now(),d=await N({nodeId:e.nodeId,app:e.app,command:[O("bash",e.env,e.cwd),"-c",e.command],cwd:e.cwd,env:e.env,stdoutBytes:e.headBytes,stderrBytes:e.headBytes});let f=!1,o;const p=a(()=>{d.stop().catch(t=>{console.error(`app command ${d.pid} could not be stopped:`,t)})},"terminate");o=setTimeout(()=>{f=!0,p()},e.timeoutMs),o.unref?.();const i=d.completion.then(t=>({exitCode:t.exitCode,signal:t.signal,stdout:t.stdout,stderr:t.stderr,stdoutTruncated:t.stdoutTruncated,stderrTruncated:t.stderrTruncated,stdoutSha256:t.stdoutSha256,timedOut:f,durationMs:Date.now()-s,processError:null})).finally(()=>{o&&clearTimeout(o)});return{pid:d.pid,completion:i,terminate:p}}a(V,"runAppCommand");function $({command:e,cwd:s,env:d,timeoutMs:f,headBytes:o}){const p=Date.now(),i=b(O("bash",d,s),["-c",e],{cwd:s,env:d,detached:!0,stdio:["ignore","pipe","pipe"]}),t=i.pid??null,T=M(o),h=M(o),P=k("sha256");i.stdout?.on("data",n=>{P.update(n),T.take(n)}),i.stderr?.on("data",n=>h.take(n));let g=!1,w=null,l,v=null,c=!1,y=!1,u,m,C,r,D;const _=new Promise(n=>{D=n}),S=a(()=>{c||l===void 0||(c=!0,u!==void 0&&clearTimeout(u),m!==void 0&&clearTimeout(m),C!==void 0&&clearTimeout(C),D({exitCode:l,signal:v,stdout:T.decode(),stdoutTruncated:T.truncated(),stderr:h.decode(),stderrTruncated:h.truncated(),timedOut:g,durationMs:Date.now()-p,stdoutSha256:P.digest("hex"),processError:w}))},"finish"),A=a(()=>{if(r===void 0||!x(r.tree)){S();return}C=setTimeout(A,B)},"awaitTeardownDeath"),I=a(()=>{t===null||c||(r??=R(t,null),L(r.tree,"SIGTERM",r.identities),m===void 0&&(m=setTimeout(()=>{x(r.tree)&&L(r.tree,"SIGKILL",r.identities),y=!0,l!==void 0&&A()},G),m.unref?.()))},"terminate");return i.on("error",n=>{w===null&&(w=n),t===null&&(l=null,S())}),i.on("close",(n,E)=>{if(!c){if(l=n,v=E,u!==void 0&&clearTimeout(u),r!==void 0&&x(r.tree)){y&&A();return}S()}}),t!==null&&(u=setTimeout(()=>{c||(g=!0,I())},f),u.unref?.()),{pid:t,completion:_,terminate:I}}a($,"runCommandOnce");export{V as runAppCommand,$ as runCommandOnce};
|
|
@@ -3,11 +3,5 @@ export interface HumanForkCoordinates {
|
|
|
3
3
|
sourceSessionId: string;
|
|
4
4
|
leafId: string;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
* source broker's manager. The SDK creates its branch in the supplied session
|
|
9
|
-
* directory, so opening the source through a detached manager directs the staged
|
|
10
|
-
* file straight into the ticket directory. Publication is an exclusive hard link:
|
|
11
|
-
* an existing destination is never read or replaced.
|
|
12
|
-
*/
|
|
13
|
-
export declare function materializeSessionBranchAt(coordinates: HumanForkCoordinates, destination: string): void;
|
|
6
|
+
/** Fork the captured root-to-leaf branch without opening or mutating its live source. */
|
|
7
|
+
export declare function materializeSessionBranch(coordinates: HumanForkCoordinates): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.defineProperty;var s=(e,r)=>n(e,"name",{value:r,configurable:!0});import{conversationIdFromPath as i,conversationStore as t}from"../conversation-store/index.js";function c(e){if(e.sourceSessionId===""||e.leafId==="")throw new Error("session branch coordinates require source session and leaf ids");const r=i(e.sourceFile);if(r===null||r!==e.sourceSessionId)throw new Error("source session id does not match captured coordinates");const o=t();if(o.header(r).header.id!==e.sourceSessionId)throw new Error("source session id does not match captured coordinates");return o.header(o.fork(r,void 0,e.leafId)).path}s(c,"materializeSessionBranch");export{c as materializeSessionBranch};
|
|
@@ -7,10 +7,7 @@ export declare function compactSessionSearchText(text: string): string;
|
|
|
7
7
|
export declare class SessionListCache {
|
|
8
8
|
private readonly cacheFile;
|
|
9
9
|
private cache;
|
|
10
|
-
/**
|
|
11
|
-
* /resume that races the background prewarm (or a second identical open)
|
|
12
|
-
* shares the one running jsonlFiles/stat/build pass instead of queueing a
|
|
13
|
-
* redundant one behind it. */
|
|
10
|
+
/** Share concurrent scans for the same cwd. */
|
|
14
11
|
private inflightDir;
|
|
15
12
|
private loadPromise;
|
|
16
13
|
private buildChain;
|
|
@@ -18,25 +15,12 @@ export declare class SessionListCache {
|
|
|
18
15
|
private persistAgain;
|
|
19
16
|
private persistTimer;
|
|
20
17
|
constructor(cacheFile: string);
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
* streams each file via readline (yields per chunk), so it never blocks the
|
|
24
|
-
* broker loop — pre-warming beats worker threads here. Errors are swallowed
|
|
25
|
-
* by the same paths that guard a normal open. */
|
|
26
|
-
prewarm(sessionDir: string): void;
|
|
27
|
-
/** Sessions for one cwd's session dir (the picker's default `cwd` scope).
|
|
28
|
-
* Single-flight: an identical concurrent cwd open (prewarm ⇄ immediate
|
|
29
|
-
* /resume) shares the in-flight promise rather than repeating the scan.
|
|
30
|
-
* Incompatible cwd/all builds still serialize through the build chain. */
|
|
31
|
-
listDir(sessionDir: string): Promise<WireSessionInfo[]>;
|
|
18
|
+
/** Sessions in the picker's current cwd. */
|
|
19
|
+
listDir(cwd: string): Promise<WireSessionInfo[]>;
|
|
32
20
|
private buildDir;
|
|
33
|
-
/** Sessions across every cwd
|
|
34
|
-
listAll(
|
|
35
|
-
/** Serialize
|
|
36
|
-
* and, cold, scan the same large corpus. Identical cwd opens are already
|
|
37
|
-
* collapsed upstream by `listDir`'s in-flight sharing; chaining serializes
|
|
38
|
-
* the remaining incompatible builds (a cwd scan vs an `all` scan) so they
|
|
39
|
-
* never race map mutation or launch overlapping cold scans. */
|
|
21
|
+
/** Sessions across every cwd (`all` scope). */
|
|
22
|
+
listAll(): Promise<WireSessionInfo[]>;
|
|
23
|
+
/** Serialize cwd and all-scope cache mutations. */
|
|
40
24
|
private build;
|
|
41
25
|
private buildLocked;
|
|
42
26
|
/** Load the persisted cache exactly once, single-flight. Returns a shared
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var T=Object.defineProperty;var c=(t,e)=>T(t,"name",{value:e,configurable:!0});import{readFile as D,rename as N,unlink as C,writeFile as A}from"node:fs/promises";import{resolve as M}from"node:path";import{conversationStore as p,ConversationNotFoundError as F}from"../conversation-store/index.js";const S=1024;function E(t){if(t.length<=S)return t;const e=S/2;return`${t.slice(0,e)} \u2026 ${t.slice(-e)}`}c(E,"compactSessionSearchText");const w=1,P=2e3;function g(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}c(g,"isFiniteNonNeg");function b(t){return t===void 0||typeof t=="string"}c(b,"isOptionalString");function x(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.path=="string"&&typeof e.id=="string"&&typeof e.cwd=="string"&&typeof e.created=="string"&&typeof e.modified=="string"&&g(e.messageCount)&&typeof e.firstMessage=="string"&&typeof e.allMessagesText=="string"&&b(e.name)&&b(e.parentSessionPath)}c(x,"isValidWireInfo");function O(t){if(typeof t!="object"||t===null)return!1;const e=t;return g(e.mtimeMs)&&g(e.size)&&x(e.info)}c(O,"isValidEntry");function _(t){const e=t.content;return typeof e=="string"?e:Array.isArray(e)?e.filter(i=>i.type==="text").map(i=>i.text).join(" "):""}c(_,"extractTextContent");function k(t){const e=t.message;if(!e||!("content"in e))return;const i=e.role;if(i!=="user"&&i!=="assistant")return;const s=e.timestamp;if(typeof s=="number")return s;const n=new Date(t.timestamp).getTime();return Number.isNaN(n)?void 0:n}c(k,"messageActivityTime");function v(t){try{const e=t.header;let i=0,s="";const n=[];let a,h;for(const f of p().read(t.conversation_id).entries){if(f.type==="session_info"&&(a=f.name?.trim()||void 0),f.type!=="message")continue;i++;const y=k(f);typeof y=="number"&&(h=Math.max(h??0,y));const u=f.message;if(!u||!("content"in u))continue;const m=u.role;if(m!=="user"&&m!=="assistant")continue;const d=_(u);d&&(n.push(d),!s&&m==="user"&&(s=d))}const r=typeof e.cwd=="string"?e.cwd:"",o=typeof e.timestamp=="string"?new Date(e.timestamp).getTime():NaN,l=typeof h=="number"&&h>0?new Date(h):Number.isNaN(o)?new Date(t.mtime):new Date(o);return{path:t.path,id:e.id,cwd:r,name:a,parentSessionPath:e.parentSession,created:new Date(e.timestamp).toISOString(),modified:l.toISOString(),messageCount:i,firstMessage:s||"(no messages)",allMessagesText:E(n.join(" "))}}catch(e){if(e instanceof F)return null;throw e}}c(v,"buildWireSessionInfo");class H{static{c(this,"SessionListCache")}cacheFile;cache=new Map;inflightDir=new Map;loadPromise=null;buildChain=Promise.resolve();persisting=!1;persistAgain=!1;persistTimer=null;constructor(e){this.cacheFile=e}listDir(e){const i=M(e),s=this.inflightDir.get(i);if(s)return s;const n=Promise.resolve().then(()=>this.buildDir(i));this.inflightDir.set(i,n);const a=c(()=>{this.inflightDir.get(i)===n&&this.inflightDir.delete(i)},"clear");return n.then(a,a),n}buildDir(e){const i=p().list().filter(s=>s.header.cwd===e);return this.build(i,s=>this.cache.get(s)?.info.cwd===e)}async listAll(){return this.build(p().list(),()=>!0)}build(e,i){const s=this.buildChain.then(()=>this.buildLocked(e,i));return this.buildChain=s.then(()=>{},()=>{}),s}async buildLocked(e,i){await this.ensureLoaded();const s=new Set(e.map(({path:r})=>r));let n=!1;for(const r of this.cache.keys())!s.has(r)&&i(r)&&(this.cache.delete(r),n=!0);const a=new Array(e.length);for(const[r,o]of e.entries()){const l=this.cache.get(o.path);if(l&&l.mtimeMs===o.mtime&&l.size===o.size){a[r]=l.info;continue}const f=v(o);if(n=!0,!f){this.cache.delete(o.path);continue}this.cache.set(o.path,{mtimeMs:o.mtime,size:o.size,info:f}),a[r]=f}n&&this.schedulePersist();const h=a.filter(r=>r!==void 0);return h.sort((r,o)=>new Date(o.modified).getTime()-new Date(r.modified).getTime()),h}ensureLoaded(){return this.loadPromise||(this.loadPromise=this.loadFromDisk()),this.loadPromise}async loadFromDisk(){try{const e=JSON.parse(await D(this.cacheFile,"utf8"));if(e?.version!==w||typeof e.entries!="object")return;for(const[i,s]of Object.entries(e.entries)){if(!O(s)){this.cache.clear();return}this.cache.set(i,s)}}catch{this.cache.clear()}}schedulePersist(){this.persistTimer||(this.persistTimer=setTimeout(()=>{this.persistTimer=null,this.persist()},P),this.persistTimer.unref?.())}async persist(){if(this.persisting){this.persistAgain=!0;return}this.persisting=!0;const e=`${this.cacheFile}.${process.pid}.tmp`;try{const i={};for(const[n,a]of this.cache)i[n]=a;await A(e,JSON.stringify({version:w,entries:i})),await N(e,this.cacheFile)}catch{await C(e).catch(()=>{})}finally{this.persisting=!1,this.persistAgain&&(this.persistAgain=!1,this.persist())}}}export{H as SessionListCache,E as compactSessionSearchText};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,
|
|
1
|
+
var a=Object.defineProperty;var n=(t,r)=>a(t,"name",{value:r,configurable:!0});import{mkdirSync as u}from"node:fs";import{readTextBeneathIfExists as l,writeFileBeneath as m}from"../spaces/open-beneath.js";import{situationalContextPath as e,nodeRunDir as o}from"../canvas/paths.js";import{formatCard as f,parseCard as c}from"../../shared/generated-context.js";import{SITUATIONAL_CONTEXT_CUSTOM_TYPE as P}from"../../shared/generated-context.js";function p(t){return t.trim()===""?"":f("situational",{},t)}n(p,"formatSituationalProse");function d(t,r){const i=r.trim();i!==""&&(u(o(t),{recursive:!0}),m(o(t),e(t),i+`
|
|
2
|
+
`,{atomic:!0}))}n(d,"appendSituationalContext");function x(t){const r=l(o(t),e(t))?.trim()??"";return r!==""?r:null}n(x,"readSituationalContext");function h(t){const r=x(t);return r===null?null:c({content:r})===null?p(r):r}n(h,"situationalContextEnvelope");export{P as SITUATIONAL_CONTEXT_CUSTOM_TYPE,d as appendSituationalContext,p as formatSituationalProse,h as situationalContextEnvelope};
|
|
@@ -8,11 +8,8 @@ export declare const ADMITTED_HOST_PATH_ENV = "CRTR_ADMITTED_HOST_PATH";
|
|
|
8
8
|
* The result is absolute, or null when no PATH entry supplies the command. */
|
|
9
9
|
export declare function resolvePathExecutable(name: string, env: NodeJS.ProcessEnv, cwd: string): string | null;
|
|
10
10
|
export declare function resolveAdmittedHostCommand(name: string, env: NodeJS.ProcessEnv, cwd: string): string;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* `MODEL_PROVIDER_KEYS` in launch.ts (that constant is a provider-ID list —
|
|
14
|
-
* `['anthropic', 'openai']` — not env-var names; conflating the two would
|
|
15
|
-
* silently admit the wrong names the moment either list changes). */
|
|
11
|
+
/** Vendor keys stay with the daemon, even when an explicit profile or host
|
|
12
|
+
* allowlist names one of them. The front-door credential check uses this map. */
|
|
16
13
|
export declare const PROVIDER_ENV_KEYS: Record<ModelProvider, string>;
|
|
17
14
|
/** Sources A–C: the operational base shared by the broker boundary (this
|
|
18
15
|
* module's `buildBrokerEnv`) and cron executor — the single shared definition
|
|
@@ -28,6 +25,8 @@ export declare function buildOperationalEnvBase(opts: {
|
|
|
28
25
|
* `CRTR_PROFILE_ID`. `null`/`''` for no profile. */
|
|
29
26
|
targetProfileId: string | null;
|
|
30
27
|
host?: NodeJS.ProcessEnv;
|
|
28
|
+
/** App runs do not inherit the owner project's explicit host-env allowlist. */
|
|
29
|
+
skipSpawnAllow?: boolean;
|
|
31
30
|
}): NodeJS.ProcessEnv;
|
|
32
31
|
/** Source F — the TARGET profile's manifest `metadata`, each entry surfaced
|
|
33
32
|
* as `CRTR_PROFILE_META_<KEY>` (key uppercased, every non-alphanumeric run
|
|
@@ -41,7 +40,7 @@ export declare function profileMetadataEnv(profileId: string | null): NodeJS.Pro
|
|
|
41
40
|
* `process.cwd()`/`CRTR_PROFILE_ID`, which may be a launcher's or the
|
|
42
41
|
* daemon's own and belong to an unrelated scope), E — the TARGET profile's
|
|
43
42
|
* own `profile env` store (`readProfileEnvVars`, `core/profiles/env-store.ts`)
|
|
44
|
-
* read directly off disk
|
|
43
|
+
* read directly off disk only when the profile belongs to the launched app, regardless of the host env or any
|
|
45
44
|
* `spawnEnv.allow` entry (setting a value there IS the consent to cross this
|
|
46
45
|
* boundary), F — the TARGET profile's manifest metadata as
|
|
47
46
|
* `CRTR_PROFILE_META_*` (`profileMetadataEnv` above), plus D — the trusted,
|
|
@@ -51,4 +50,5 @@ export declare function profileMetadataEnv(profileId: string | null): NodeJS.Pro
|
|
|
51
50
|
* value. Every broker launch (front-door root, managed child, `--root`,
|
|
52
51
|
* every revive/daemon relaunch) funnels through `headlessBrokerHost.launch()`,
|
|
53
52
|
* which calls this. */
|
|
53
|
+
export declare function buildAppProcessEnv(targetCwd: string, targetProfileId: string | null, app: string): NodeJS.ProcessEnv;
|
|
54
54
|
export declare function buildBrokerEnv(inv: PiInvocation): NodeJS.ProcessEnv;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d=Object.defineProperty;var c=(t,e)=>d(t,"name",{value:e,configurable:!0});import{statSync as p}from"node:fs";import{appSpace as E}from"../layout.js";import{delimiter as _,join as T,resolve as m}from"node:path";import{readMergedLaunchConfig as R}from"../config.js";import{readProfileEnvVars as P}from"../profiles/env-store.js";import{loadProfileManifest as A,metadataEnvName as O,readProfileMetadata as h}from"../profiles/manifest.js";import{binShimDirFor as H}from"./bin-contributions.js";import{FRONT_DOOR_ENV as I}from"./front-door-env.js";const N=new Set(["HOME","PATH","SHELL","USER","LOGNAME","TMPDIR","TERM","TERMINFO","COLORTERM","LANG","LANGUAGE","TZ","NO_PROXY","no_proxy","SSH_AUTH_SOCK","CRTR_BASH_VALVE_MS"]),w=["LC_","XDG_","PI_"],l="CRTR_ADMITTED_HOST_PATH";function C(t,e,o){const r=e.PATH;if(r===void 0||r==="")return null;for(const s of r.split(_)){const i=m(o,s===""?".":s,t);try{const n=p(i);if(n.isFile()&&(n.mode&73)!==0)return i}catch{}}return null}c(C,"resolvePathExecutable");function Y(t,e,o){const r=e[l]??e.PATH;if(r===void 0||r==="")throw new Error(`cannot resolve crouter-owned ${t}: the admitted host PATH is empty`);const s=C(t,{PATH:r},o);if(s!==null)return s;throw new Error(`cannot resolve crouter-owned ${t} from the admitted host PATH`)}c(Y,"resolveAdmittedHostCommand");const M=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],u={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY"};function v(t){let e;try{e=new URL(t)}catch{return!1}return!(e.protocol!=="http:"&&e.protocol!=="https:"||e.hostname===""||e.username!==""||e.password!=="")}c(v,"isCredentialFreeProxyValue");function D(t,e){if(!e.includes("*"))return t===e;const o=e.split("*").map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${o}$`).test(t)}c(D,"matchesAllowPattern");function S(t){const e=t.host??process.env,o={};for(const[n,a]of Object.entries(e))a!==void 0&&(N.has(n)||w.some(f=>n.startsWith(f)))&&(o[n]=a);o.PWD=t.targetCwd;for(const n of M){const a=e[n];a!==void 0&&v(a)&&(o[n]=a)}const r=t.skipSpawnAllow?[]:R(t.targetCwd,t.targetProfileId).spawnEnv.allow;if(r.length>0)for(const[n,a]of Object.entries(e))a!==void 0&&r.some(f=>D(n,f))&&(o[n]=a);const s=e[l]??o.PATH;s!==void 0&&s!==""&&(o[l]=s);const i=H(t.targetCwd,t.targetProfileId);if(i!==null){const n=o.PATH;o.PATH=n===void 0||n===""?i:`${i}:${n}`}return o}c(S,"buildOperationalEnvBase");function x(t){const e={};for(const[o,r]of Object.entries(h(t)))e[O(o)]=r;return e}c(x,"profileMetadataEnv");function y(t,e,o){const r=e===null?null:A(e).manifest,s=r!==null&&(r.grantee??"app:terminal")===o,i=S({targetCwd:t,targetProfileId:e,skipSpawnAllow:o!=="app:terminal"}),n=E(o).home,a={...i,...r===null?{}:x(e),...s?P(e):{},HOME:n,PI_CODING_AGENT_DIR:T(n,".pi","agent"),[l]:i[l]};process.platform==="linux"&&delete a.CRTR_RUNTIME_HOME;for(const f of Object.values(u))delete a[f];return a}c(y,"buildAppProcessEnv");function U(t){const e=t.env.CRTR_NODE_CWD??process.cwd(),o=t.env.CRTR_PROFILE_ID||null,r=t.env.CRTR_GRANTEE??"app:terminal",s=y(e,o,r),i={...s,...t.env,HOME:s.HOME,PI_CODING_AGENT_DIR:s.PI_CODING_AGENT_DIR,[l]:s[l],[I]:"1"};process.platform==="linux"&&delete i.CRTR_RUNTIME_HOME;for(const n of Object.values(u))delete i[n];return i}c(U,"buildBrokerEnv");export{l as ADMITTED_HOST_PATH_ENV,u as PROVIDER_ENV_KEYS,y as buildAppProcessEnv,U as buildBrokerEnv,S as buildOperationalEnvBase,x as profileMetadataEnv,Y as resolveAdmittedHostCommand,C as resolvePathExecutable};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SpawnNodeOpts } from './nodes.js';
|
|
1
2
|
import { type WakeOrigin } from './bearings.js';
|
|
2
3
|
import { type NodeMeta, type Mode, type Lifecycle, type OutcomeDeliveryBinding, type ReviewBinding } from '../canvas/index.js';
|
|
3
4
|
import { type ModelRegistryLike, type ModelRequest } from '../model-routes.js';
|
|
@@ -50,6 +51,10 @@ export interface SpawnChildOpts {
|
|
|
50
51
|
model?: string;
|
|
51
52
|
/** Per-run scope allow-list. Omit to inherit the spawner's list. */
|
|
52
53
|
scopes?: string[];
|
|
54
|
+
/** App run identity set at birth; children inherit from the spawner. */
|
|
55
|
+
run?: SpawnNodeOpts['run'];
|
|
56
|
+
/** Commit run rows inside the same transaction as the newborn node. */
|
|
57
|
+
withinCreate?: SpawnNodeOpts['withinCreate'];
|
|
53
58
|
/** Select the profile this node runs under — an exact profile id or a unique
|
|
54
59
|
* manifest name (or the closest match to one), resolved through
|
|
55
60
|
* `resolveProfileOperand`. Omit to INHERIT the
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var G=Object.defineProperty;var a=(e,o)=>G(e,"name",{value:o,configurable:!0});import{accessSync as J,constants as Q}from"node:fs";import{isAbsolute as Y,resolve as Z}from"node:path";import{spawnNode as ee,forkSourceNode as ne,currentNodeContext as oe,rootOfSpine as re,newNodeId as ie,preflightNodeId as te}from"./nodes.js";import{resolveProfileOperand as de}from"../profiles/manifest.js";import{selectProfileForCwd as ae,selectProfileForCwdReadOnly as se}from"../profiles/select.js";import{buildLaunchSpecAsync as j,buildPiArgv as ce}from"./launch.js";import{createManagedWorktreeAsync as le,rollbackManagedWorktreeAsync as fe}from"../worktree-mutation-async.js";import{usage as c,brokerLaunchFailed as O}from"../errors.js";import{writeGoal as ue}from"./kickoff.js";import{appendSituationalContext as me,formatSituationalProse as he}from"./situational-context.js";import{hasRoadmap as we,seedRoadmap as pe}from"./roadmap.js";import{buildWakeBearings as ke}from"./bearings.js";import{encodeKickoffOrigin as _e,KICKOFF_ORIGIN_ENV as ve}from"./stamp/protocol.js";import{beginExecution as ge,crtrHome as ye,getNode as w,fullName as W,jobDir as be,recordExecutionPid as xe,abortExecution as D,setFrozen as Ce}from"../canvas/index.js";import{contextDir as P,nodeAgentDir as I,reportsDir as Fe}from"../canvas/node-agent-paths.js";import{copyTreeBeneath as $e}from"../spaces/open-beneath.js";import{conversationIdFromPath as S,conversationStore as p}from"../conversation-store/index.js";import{boundFleet as Ee,brokerThresholdsForDaemon as Oe}from"./fleet.js";import{emitEvent as Se}from"../events/emit.js";import{openViewerWindow as Re,focusOf as De,windowOfPane as Pe}from"./placement.js";import{waitForBrokerViewSocket as Ie}from"./placement-tmux.js";import{transition as k}from"./lifecycle.js";import{beginBootFaultAttempt as Be}from"../canvas/recovery.js";import{headlessBrokerHost as B}from"./host.js";import{ensureDaemon as Ne}from"../../daemon/manage.js";import{readConfig as Le}from"../config.js";import{modelRequestFromConfig as Te,unregisteredConcreteModel as Ae}from"../model-routes.js";import{openModelRegistry as je}from"./model-registry.js";import{MODEL_SPEC_NEXT as We}from"./model-selection.js";import{initializeForkContextExposure as Me}from"../substrate/injected-store.js";import{discoverLifecycleHookRegistry as He}from"../command-hooks/discovery.js";import{invokeLifecycleHooks as ze}from"../command-hooks/transport/exec-lifecycle.js";function _(e){return{detail:{schema:"crtr.node-outcome-detail/v1",message:e instanceof Error?e.message:String(e)}}}a(_,"launchFailureOutcome");async function Ke(e,o,d){try{return await B.launch(e,o,d)}catch(r){try{k(e,"crash",{reason:"launch_failed",outcome:_(r)})}catch{}const t=r.message;throw O(t.startsWith("[broker]")?t:`[broker] refusing to launch ${e}: ${t}`,"Inspect the cause above, fix the launch recipe or environment, then retry.")}}a(Ke,"launchBrokerOrCrash");function qe(e,o){try{k(e,"crash",{reason:"launch_failed",outcome:_(o)})}catch{}try{B.teardown(e)}catch{}}a(qe,"crashAndTearDown");function Ue(e){const o=p().list().map(({conversation_id:t,path:s})=>({id:t,path:s})),d=o.filter(t=>t.id===e),r=d.length>0?d:o.filter(t=>t.id.startsWith(e));if(r.length===0)throw c(`--fork-from '${e}': no pi session with that id found.`,{next:"Pass a live node id, a real session uuid/prefix, or an absolute .jsonl session path."});if(r.length>1)throw c(`--fork-from '${e}': ambiguous \u2014 ${r.length} sessions match that id prefix; pass the full id or the .jsonl path.`,{next:"Pass the full session uuid or an absolute .jsonl path to disambiguate."});return r[0].path}a(Ue,"resolveSessionUuid");function M(e){const o=e.trim();if(o==="")throw c("--fork-from requires a node id, session file, or session uuid.",{next:"Pass a live node id, an absolute .jsonl session path, or a session uuid/prefix."});if(o.includes("/")||o.endsWith(".jsonl")){const r=S(Y(o)?o:Z(process.cwd(),o));if(r===null)throw c(`--fork-from '${o}': invalid conversation path.`,{next:"Pass a conversation file path or id."});return p().header(r).path}const d=w(o);if(d!==null){const r=d.pi_session_file;if(r==null||r==="")throw c(`node ${o} has no pi session yet \u2014 it has not captured a session FILE to fork from (the broker forks a .jsonl path, not a bare id).`,{next:"Pick a node that has captured a session, or drop --fork-from."});const t=S(r);if(t===null)throw c(`node ${o} has no valid conversation id.`,{next:"Pick a node with a captured conversation."});return p().header(t).path}return Ue(o)}a(M,"resolveForkSource");async function Ve(e,o,d,r={}){return e===null?null:e!==void 0&&e!==""?de(e).profileId:o!==null?w(o)?.profile_id??null:r.readOnlySelection===!0?se(d):ae(d)}a(Ve,"resolveProfileId");function H(e){const o=e.modelIntent===void 0?void 0:`${e.modelIntent.family}/${e.modelIntent.strength}`;return Te(e.model,o,e.modelExact===!0)}a(H,"requestFromLaunch");async function z(e,o,d){if(e===void 0||e.kind==="logical")return;const r=Ae(e,d??await je(),o);if(r!==void 0)throw c(`model '${r.request.spec}' is not registered in this daemon.`,{received:r.request.spec,next:We})}a(z,"assertLaunchModelRegistered");function Xe(e,o,d){const r=e??o??null;if(!d&&r===null)throw new Error("spawnChild requires a calling node (CRTR_NODE_ID) or an explicit parent");return r}a(Xe,"resolveSpawner");async function K(e,o,d){try{Ne()}catch{}const r=oe(),t=e.root===!0,s=Xe(e.parent,r.nodeId??null,t),f=e.mode??"base",x=e.rootLifecycle??(t?"resident":"terminal"),q=t&&x==="resident",C=e.worktree===!0,v=C?e.nodeId??ie():e.nodeId;e.nodeId!==void 0&&te(e.nodeId);const g=await Ve(e.profile,s,e.cwd),N=(await j(e.kind,f,{lifecycle:x,hasManager:!t,model:e.model,modelOverride:e.model!==void 0,cwd:e.cwd,profileId:g})).launch;await z(H(N),{cwd:e.cwd,profileId:g});const u=e.forkFrom!==void 0?M(e.forkFrom):void 0,U=u===void 0?null:ne(u)?.node_id??null;let m,F=e.cwd;try{C&&(m=await le(e.worktreeCwd??e.cwd,v,e.worktreeBase),F=m.path);const y=C?(await j(e.kind,f,{lifecycle:x,hasManager:!t,model:e.model,modelOverride:e.model!==void 0,cwd:F,profileId:g})).launch:N;C&&await z(H(y),{cwd:F,profileId:g});const n=await ee({kind:e.kind,mode:f,lifecycle:x,cwd:F,name:e.name??e.kind,description:e.description,parent:t?null:s,creator:e.creator,spawnedBy:t?s??void 0:void 0,profile_id:g,...e.scopes===void 0?{}:{scopes:e.scopes},...e.run===void 0?{}:{run:e.run},...e.withinCreate===void 0?{}:{withinCreate:e.withinCreate},forkFrom:e.forkFrom,forkSourceFile:u,modelOverride:e.model===void 0?void 0:y.model,...m!==void 0?{managedWorktree:m}:{},...v!==void 0?{nodeId:v}:{},...e.reviewBinding===void 0?{}:{reviewBinding:e.reviewBinding},...e.deadlineAt===void 0?{}:{deadlineAt:e.deadlineAt},...e.outcomeDelivery===void 0?{}:{outcomeDelivery:e.outcomeDelivery},launch:y});if(d?.(n.node_id),e.forkFrom!==void 0)try{Me(n.node_id,U)}catch(i){throw k(n.node_id,"crash",{reason:"launch_failed",outcome:_(i)}),i}if(ue(n.node_id,e.prompt),e.situationalContext!==void 0&&me(n.node_id,he(e.situationalContext)),o!==void 0)try{o(n.node_id)}catch(i){throw k(n.node_id,"crash",{reason:"launch_failed",outcome:_(i)}),i}const R=e.prompt!=="",V=`${R&&e.wakeOrigin!==void 0?`${ke(e.wakeOrigin)}
|
|
2
2
|
|
|
3
|
-
`:""}${e.prompt}`;
|
|
3
|
+
`:""}${e.prompt}`;f==="orchestrator"&&!we(n.node_id)&&pe(n.node_id,{goal:e.prompt.trim()}),await Ge(n);let L;if(u!==void 0)try{const i=S(u);if(i===null)throw new Error(`invalid fork source ${u}`);const l=p().fork(i,n.node_id);L=p().header(l).path}catch(i){throw k(n.node_id,"crash",{reason:"launch_failed",outcome:_(i)}),i}const h=ce(n,{prompt:V,resumeSessionPath:L});if(h.env={...h.env,CRTR_SUBTREE:re(n.node_id)},R){const i=e.wakeOrigin!==void 0?{type:"runtime",kind:"wake",wake:e.wakeOrigin}:{type:"runtime",kind:"kickoff",...n.spawned_by!=null&&n.spawned_by!==""?{spawnedBy:n.spawned_by}:{}};h.env[ve]=_e(i)}const $=Ee();if(!$.reserveSlot(n.node_id))return Ce(n.node_id,new Date().toISOString()),Se({level:"info",event:"broker.frozen",node_id:n.node_id,fields:{live_count:$.size(),hard_cap:Oe().automaticReviveCap}}),{node:w(n.node_id),frozen:!0,window:null,session:null};const X=Be(n.node_id),b=ge(n.node_id,{daemonEpoch:$.epoch()});h.env={...h.env,CRTR_EXECUTION_ID:b};let E;try{E=await Ke(n.node_id,h,{cwd:n.cwd,name:W(n),resuming:!1})}catch(i){throw D(b,{reason:"launch_failed"}),i}finally{$.releaseReservation(n.node_id)}if(E.pid===null){const i=new Error(`broker host returned no pid for ${n.node_id}`);throw D(b,{reason:"launch_failed"}),k(n.node_id,"crash",{reason:"launch_failed",outcome:_(i)}),O(`failed to launch the broker engine for ${n.node_id} (${n.name}) \u2014 the node was not started.`,`Inspect canonical event diagnostics with \`crtr sys logs --node ${n.node_id}\`, then verify the pi engine can start in this environment.`)}if(xe(b,n.node_id,E.pid)==="shutdown")throw D(b,{reason:"superseded"}),B.teardown(n.node_id),O(`broker execution was superseded for ${n.node_id}`,"Retry spawning the node.");if(q&&e.readiness==="await"&&!await Ie(n.node_id,E.exited)){const i=X.explanation();throw qe(n.node_id,new Error(i??`broker view socket never bound for ${n.node_id}`)),O(i!==null?`the root broker ${n.node_id} could not start \u2014 ${i}`:`the root broker ${n.node_id} never bound its view socket \u2014 it was not started.`,i!==null?"Resolve the cause named above, then retry.":`The broker engine exited before binding its view socket. Inspect canonical event diagnostics with \`crtr sys logs --node ${n.node_id}\`, then retry.`)}let T=null,A=null;if(!t&&s!==null&&Le("user").auto_open_child_viewers)try{const i=De(s);if(i!==null&&i.pane!==null&&i.pane!==""){const l=Re(n.node_id,i.session??"",{name:W(n),cwd:e.cwd,besidePane:i.pane,waitForBroker:!0,initialWhip:R});l!==null&&l.pane!==null&&l.pane!==""&&(A=l.session,T=Pe(l.pane))}}catch{}return{node:w(n.node_id),frozen:!1,window:T,session:A}}catch(y){throw m!==void 0&&v!==void 0&&w(v)===null&&await fe(m),y}}a(K,"spawnChildPrepared");async function In(e){return K(e)}a(In,"spawnChild");async function Ge(e){const o=He(e.cwd,e.profile_id).plans.get("node:start")??[];await ze(o,{node:{id:e.node_id,name:e.name,kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,cwd:e.cwd,nodeDir:I(e.node_id),contextDir:P(e.node_id),jobDir:be(e.node_id),reportsDir:Fe(e.node_id)},runtime:{isBirth:!0,canvasHome:ye(),profile:e.profile_id??null}})}a(Ge,"invokeBirthLifecycleHooks");const Je=new Set(["initial-prompt.md","yield-message.md","result.json","jobs"]);async function Bn(e,o){const d=w(e);if(d===null)throw c(`unknown node: ${e}`,{received:e,next:"List nodes and pass the id of a node with a captured pi session."});const r=M(e),t=P(e);try{p().header(S(r)),J(t,Q.R_OK)}catch(s){throw new Error(`cannot fork ${e}: its conversation or context is unreadable \u2014 ${s.message}`)}return K({kind:d.kind,mode:"base",cwd:d.cwd,prompt:"",root:!0,readiness:"await",forkFrom:e,profile:d.profile_id,model:d.model_override??void 0,...o===void 0?{}:{scopes:o}},s=>{const f=P(s);$e(I(e),t,I(s),f,Je)})}a(Bn,"forkNode");export{z as assertLaunchModelRegistered,Bn as forkNode,Ge as invokeBirthLifecycleHooks,M as resolveForkSource,Ve as resolveProfileId,Xe as resolveSpawner,In as spawnChild,K as spawnChildPrepared};
|