@openrig/cli 0.7.1 → 0.7.2
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/README.md +5 -5
- package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-core/skills/delegating-work/SKILL.md +1 -1
- package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +90 -9
- package/daemon/assets/skills/rigs/SKILL.md +40 -9
- package/daemon/context-packs/help/help.md +6 -0
- package/daemon/context-packs/help/manifest.yaml +1 -1
- package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
- package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +70 -15
- package/daemon/context-packs/reference/acp-agents.md +77 -0
- package/daemon/context-packs/reference/getting-started.md +82 -10
- package/daemon/context-packs/reference/manifest.yaml +6 -3
- package/daemon/context-packs/reference/rig-spec.md +93 -3
- package/daemon/context-packs/reference/whats-new.md +262 -149
- package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
- package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
- package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
- package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-herdr/SKILL.md +17 -5
- package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
- package/daemon/context-packs/skills/delegating-work/SKILL.md +1 -1
- package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
- package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
- package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
- package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
- package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
- package/daemon/context-packs/skills/openrig-user/SKILL.md +90 -9
- package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
- package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/agent-browser/LICENSE.txt +201 -0
- package/daemon/context-packs/skills/process/agent-browser/OPENRIG.md +13 -29
- package/daemon/context-packs/skills/process/agent-browser/SKILL.md +7 -7
- package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +3 -1
- package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/dogfood/LICENSE.txt +201 -0
- package/daemon/context-packs/skills/process/dogfood/SKILL.md +6 -2
- package/daemon/context-packs/skills/process/dogfood/manifest.yaml +3 -1
- package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/systematic-debugging/LICENSE.txt +21 -0
- package/daemon/context-packs/skills/process/systematic-debugging/SKILL.md +6 -2
- package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +3 -1
- package/daemon/context-packs/skills/process/test-driven-development/LICENSE.txt +21 -0
- package/daemon/context-packs/skills/process/test-driven-development/SKILL.md +5 -1
- package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +3 -1
- package/daemon/context-packs/skills/process/verification-before-completion/LICENSE.txt +21 -0
- package/daemon/context-packs/skills/process/verification-before-completion/SKILL.md +5 -1
- package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +3 -1
- package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
- package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
- package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
- package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
- package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
- package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
- package/daemon/context-packs/world-example/manifest.yaml +1 -1
- package/daemon/context-packs/world-public/manifest.yaml +1 -1
- package/daemon/dist/adapters/claude-code-adapter.d.ts +4 -0
- package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-code-adapter.js +46 -17
- package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
- package/daemon/dist/adapters/claude-resume.d.ts +8 -1
- package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-resume.js +29 -10
- package/daemon/dist/adapters/claude-resume.js.map +1 -1
- package/daemon/dist/adapters/codex-resume.d.ts +10 -4
- package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/codex-resume.js +59 -14
- package/daemon/dist/adapters/codex-resume.js.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts +44 -12
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.js +445 -88
- package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +4 -0
- package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.js +38 -7
- package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/compose-services-adapter.d.ts +16 -0
- package/daemon/dist/adapters/compose-services-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/compose-services-adapter.js +46 -2
- package/daemon/dist/adapters/compose-services-adapter.js.map +1 -1
- package/daemon/dist/adapters/kernel-authority.d.ts +1 -1
- package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
- package/daemon/dist/adapters/kernel-authority.js +13 -2
- package/daemon/dist/adapters/kernel-authority.js.map +1 -1
- package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-runner.js +22 -15
- package/daemon/dist/adapters/pi-runner.js.map +1 -1
- package/daemon/dist/adapters/tmux-server.d.ts +3 -0
- package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux-server.js +11 -2
- package/daemon/dist/adapters/tmux-server.js.map +1 -1
- package/daemon/dist/adapters/tmux.d.ts +38 -0
- package/daemon/dist/adapters/tmux.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux.js +157 -14
- package/daemon/dist/adapters/tmux.js.map +1 -1
- package/daemon/dist/adapters/yolo-mode.d.ts +7 -0
- package/daemon/dist/adapters/yolo-mode.d.ts.map +1 -1
- package/daemon/dist/adapters/yolo-mode.js +8 -0
- package/daemon/dist/adapters/yolo-mode.js.map +1 -1
- package/daemon/dist/build-info.js +3 -3
- package/daemon/dist/codex-auth-surface.d.ts +2 -0
- package/daemon/dist/codex-auth-surface.d.ts.map +1 -0
- package/daemon/dist/codex-auth-surface.js +2 -0
- package/daemon/dist/codex-auth-surface.js.map +1 -0
- package/daemon/dist/daemon-db-path.d.ts.map +1 -1
- package/daemon/dist/daemon-db-path.js +45 -12
- package/daemon/dist/daemon-db-path.js.map +1 -1
- package/daemon/dist/db/all-migrations.d.ts.map +1 -1
- package/daemon/dist/db/all-migrations.js +12 -0
- package/daemon/dist/db/all-migrations.js.map +1 -1
- package/daemon/dist/db/migrations/132_seat_runtime_switches.d.ts +10 -0
- package/daemon/dist/db/migrations/132_seat_runtime_switches.d.ts.map +1 -0
- package/daemon/dist/db/migrations/132_seat_runtime_switches.js +46 -0
- package/daemon/dist/db/migrations/132_seat_runtime_switches.js.map +1 -0
- package/daemon/dist/db/migrations/133_stream_reader_actions.d.ts +8 -0
- package/daemon/dist/db/migrations/133_stream_reader_actions.d.ts.map +1 -0
- package/daemon/dist/db/migrations/133_stream_reader_actions.js +25 -0
- package/daemon/dist/db/migrations/133_stream_reader_actions.js.map +1 -0
- package/daemon/dist/db/migrations/134_claude_token_readings.d.ts +3 -0
- package/daemon/dist/db/migrations/134_claude_token_readings.d.ts.map +1 -0
- package/daemon/dist/db/migrations/134_claude_token_readings.js +21 -0
- package/daemon/dist/db/migrations/134_claude_token_readings.js.map +1 -0
- package/daemon/dist/db/migrations/136_node_launch_recipe.d.ts +9 -0
- package/daemon/dist/db/migrations/136_node_launch_recipe.d.ts.map +1 -0
- package/daemon/dist/db/migrations/136_node_launch_recipe.js +11 -0
- package/daemon/dist/db/migrations/136_node_launch_recipe.js.map +1 -0
- package/daemon/dist/db/migrations/138_node_claude_token_ref.d.ts +3 -0
- package/daemon/dist/db/migrations/138_node_claude_token_ref.d.ts.map +1 -0
- package/daemon/dist/db/migrations/138_node_claude_token_ref.js +8 -0
- package/daemon/dist/db/migrations/138_node_claude_token_ref.js.map +1 -0
- package/daemon/dist/db/migrations/139_node_claude_permissions.d.ts +3 -0
- package/daemon/dist/db/migrations/139_node_claude_permissions.d.ts.map +1 -0
- package/daemon/dist/db/migrations/139_node_claude_permissions.js +5 -0
- package/daemon/dist/db/migrations/139_node_claude_permissions.js.map +1 -0
- package/daemon/dist/domain/bootstrap-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/bootstrap-orchestrator.js +15 -0
- package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
- package/daemon/dist/domain/claim-service.js +1 -1
- package/daemon/dist/domain/claim-service.js.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts +24 -1
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.js +70 -16
- package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
- package/daemon/dist/domain/claude-credential-precedence.d.ts +33 -0
- package/daemon/dist/domain/claude-credential-precedence.d.ts.map +1 -0
- package/daemon/dist/domain/claude-credential-precedence.js +62 -0
- package/daemon/dist/domain/claude-credential-precedence.js.map +1 -0
- package/daemon/dist/domain/claude-managed-launch.d.ts +43 -4
- package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
- package/daemon/dist/domain/claude-managed-launch.js +129 -27
- package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
- package/daemon/dist/domain/claude-permission-rules.d.ts +10 -0
- package/daemon/dist/domain/claude-permission-rules.d.ts.map +1 -0
- package/daemon/dist/domain/claude-permission-rules.js +41 -0
- package/daemon/dist/domain/claude-permission-rules.js.map +1 -0
- package/daemon/dist/domain/claude-seat-token.d.ts +30 -0
- package/daemon/dist/domain/claude-seat-token.d.ts.map +1 -0
- package/daemon/dist/domain/claude-seat-token.js +78 -0
- package/daemon/dist/domain/claude-seat-token.js.map +1 -0
- package/daemon/dist/domain/codex-auth.d.ts +148 -0
- package/daemon/dist/domain/codex-auth.d.ts.map +1 -0
- package/daemon/dist/domain/codex-auth.js +506 -0
- package/daemon/dist/domain/codex-auth.js.map +1 -0
- package/daemon/dist/domain/codex-daemon-support.d.ts +2 -1
- package/daemon/dist/domain/codex-daemon-support.d.ts.map +1 -1
- package/daemon/dist/domain/codex-daemon-support.js +3 -2
- package/daemon/dist/domain/codex-daemon-support.js.map +1 -1
- package/daemon/dist/domain/codex-git-add-dirs.d.ts +1 -1
- package/daemon/dist/domain/codex-git-add-dirs.d.ts.map +1 -1
- package/daemon/dist/domain/codex-network-default.d.ts +2 -1
- package/daemon/dist/domain/codex-network-default.d.ts.map +1 -1
- package/daemon/dist/domain/codex-network-default.js +3 -2
- package/daemon/dist/domain/codex-network-default.js.map +1 -1
- package/daemon/dist/domain/codex-team-workspace.d.ts +5 -0
- package/daemon/dist/domain/codex-team-workspace.d.ts.map +1 -1
- package/daemon/dist/domain/codex-team-workspace.js +37 -0
- package/daemon/dist/domain/codex-team-workspace.js.map +1 -1
- package/daemon/dist/domain/community-harness-first-input.d.ts +7 -0
- package/daemon/dist/domain/community-harness-first-input.d.ts.map +1 -0
- package/daemon/dist/domain/community-harness-first-input.js +16 -0
- package/daemon/dist/domain/community-harness-first-input.js.map +1 -0
- package/daemon/dist/domain/community-harness-presets.d.ts +2 -0
- package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
- package/daemon/dist/domain/community-harness-presets.js +4 -2
- package/daemon/dist/domain/community-harness-presets.js.map +1 -1
- package/daemon/dist/domain/compaction-restore-notice.d.ts +6 -0
- package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -0
- package/daemon/dist/domain/compaction-restore-notice.js +27 -0
- package/daemon/dist/domain/compaction-restore-notice.js.map +1 -0
- package/daemon/dist/domain/context-packs/seat-recap-store.d.ts +14 -0
- package/daemon/dist/domain/context-packs/seat-recap-store.d.ts.map +1 -1
- package/daemon/dist/domain/context-packs/seat-recap-store.js +57 -1
- package/daemon/dist/domain/context-packs/seat-recap-store.js.map +1 -1
- package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
- package/daemon/dist/domain/context-usage-store.js +6 -1
- package/daemon/dist/domain/context-usage-store.js.map +1 -1
- package/daemon/dist/domain/current-work.d.ts +15 -4
- package/daemon/dist/domain/current-work.d.ts.map +1 -1
- package/daemon/dist/domain/current-work.js +26 -13
- package/daemon/dist/domain/current-work.js.map +1 -1
- package/daemon/dist/domain/execution-view.d.ts.map +1 -1
- package/daemon/dist/domain/execution-view.js +5 -2
- package/daemon/dist/domain/execution-view.js.map +1 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.js +3 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.d.ts +1 -0
- package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.js +6 -5
- package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.d.ts +3 -1
- package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.js +11 -9
- package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js +4 -0
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
- package/daemon/dist/domain/managed-restore-read-access.d.ts +20 -0
- package/daemon/dist/domain/managed-restore-read-access.d.ts.map +1 -0
- package/daemon/dist/domain/managed-restore-read-access.js +77 -0
- package/daemon/dist/domain/managed-restore-read-access.js.map +1 -0
- package/daemon/dist/domain/markdown-address.d.ts.map +1 -1
- package/daemon/dist/domain/markdown-address.js +21 -2
- package/daemon/dist/domain/markdown-address.js.map +1 -1
- package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +3 -3
- package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js +11 -8
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
- package/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts.map +1 -1
- package/daemon/dist/domain/model-divergence/model-divergence-monitor.js +18 -1
- package/daemon/dist/domain/model-divergence/model-divergence-monitor.js.map +1 -1
- package/daemon/dist/domain/native-permission-store.d.ts +7 -2
- package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
- package/daemon/dist/domain/native-permission-store.js +13 -8
- package/daemon/dist/domain/native-permission-store.js.map +1 -1
- package/daemon/dist/domain/native-resume-probe.d.ts +2 -0
- package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
- package/daemon/dist/domain/native-resume-probe.js +162 -35
- package/daemon/dist/domain/native-resume-probe.js.map +1 -1
- package/daemon/dist/domain/node-inventory.d.ts +4 -0
- package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
- package/daemon/dist/domain/node-inventory.js +18 -0
- package/daemon/dist/domain/node-inventory.js.map +1 -1
- package/daemon/dist/domain/node-launcher.d.ts +11 -0
- package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/node-launcher.js +41 -6
- package/daemon/dist/domain/node-launcher.js.map +1 -1
- package/daemon/dist/domain/parent-session-env.d.ts +1 -1
- package/daemon/dist/domain/parent-session-env.d.ts.map +1 -1
- package/daemon/dist/domain/parent-session-env.js +3 -1
- package/daemon/dist/domain/parent-session-env.js.map +1 -1
- package/daemon/dist/domain/parked-query.d.ts +3 -0
- package/daemon/dist/domain/parked-query.d.ts.map +1 -1
- package/daemon/dist/domain/parked-query.js +1 -0
- package/daemon/dist/domain/parked-query.js.map +1 -1
- package/daemon/dist/domain/permission-account.d.ts +3 -0
- package/daemon/dist/domain/permission-account.d.ts.map +1 -1
- package/daemon/dist/domain/permission-account.js +17 -3
- package/daemon/dist/domain/permission-account.js.map +1 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +8 -0
- package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.js +15 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
- package/daemon/dist/domain/proof/judgments.d.ts +7 -4
- package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
- package/daemon/dist/domain/proof/judgments.js +12 -8
- package/daemon/dist/domain/proof/judgments.js.map +1 -1
- package/daemon/dist/domain/proof/source-watch.d.ts +6 -1
- package/daemon/dist/domain/proof/source-watch.d.ts.map +1 -1
- package/daemon/dist/domain/proof/source-watch.js +241 -35
- package/daemon/dist/domain/proof/source-watch.js.map +1 -1
- package/daemon/dist/domain/provider/claude-auth-status-reader.d.ts +12 -0
- package/daemon/dist/domain/provider/claude-auth-status-reader.d.ts.map +1 -1
- package/daemon/dist/domain/provider/claude-auth-status-reader.js +4 -4
- package/daemon/dist/domain/provider/claude-auth-status-reader.js.map +1 -1
- package/daemon/dist/domain/provider/claude-seat-switch.d.ts +32 -0
- package/daemon/dist/domain/provider/claude-seat-switch.d.ts.map +1 -0
- package/daemon/dist/domain/provider/claude-seat-switch.js +136 -0
- package/daemon/dist/domain/provider/claude-seat-switch.js.map +1 -0
- package/daemon/dist/domain/provider/claude-token-usage.d.ts +34 -0
- package/daemon/dist/domain/provider/claude-token-usage.d.ts.map +1 -0
- package/daemon/dist/domain/provider/claude-token-usage.js +168 -0
- package/daemon/dist/domain/provider/claude-token-usage.js.map +1 -0
- package/daemon/dist/domain/provider/provider-account-readings.d.ts +7 -6
- package/daemon/dist/domain/provider/provider-account-readings.d.ts.map +1 -1
- package/daemon/dist/domain/provider/provider-account-readings.js +31 -10
- package/daemon/dist/domain/provider/provider-account-readings.js.map +1 -1
- package/daemon/dist/domain/provider/provider-collect.d.ts +3 -0
- package/daemon/dist/domain/provider/provider-collect.d.ts.map +1 -1
- package/daemon/dist/domain/provider/provider-collect.js +3 -2
- package/daemon/dist/domain/provider/provider-collect.js.map +1 -1
- package/daemon/dist/domain/provider/provider-seat-accounts.d.ts +1 -1
- package/daemon/dist/domain/provider/provider-seat-accounts.d.ts.map +1 -1
- package/daemon/dist/domain/provider/provider-seat-accounts.js +29 -2
- package/daemon/dist/domain/provider/provider-seat-accounts.js.map +1 -1
- package/daemon/dist/domain/provider/provider-service-impl.d.ts +38 -4
- package/daemon/dist/domain/provider/provider-service-impl.d.ts.map +1 -1
- package/daemon/dist/domain/provider/provider-service-impl.js +147 -5
- package/daemon/dist/domain/provider/provider-service-impl.js.map +1 -1
- package/daemon/dist/domain/provider/provider-service.d.ts +109 -4
- package/daemon/dist/domain/provider/provider-service.d.ts.map +1 -1
- package/daemon/dist/domain/provider/provider-signals.d.ts +3 -0
- package/daemon/dist/domain/provider/provider-signals.d.ts.map +1 -1
- package/daemon/dist/domain/provider/provider-signals.js +7 -2
- package/daemon/dist/domain/provider/provider-signals.js.map +1 -1
- package/daemon/dist/domain/provider/provider-types.d.ts +61 -5
- package/daemon/dist/domain/provider/provider-types.d.ts.map +1 -1
- package/daemon/dist/domain/provider/reactive-tap.d.ts +4 -0
- package/daemon/dist/domain/provider/reactive-tap.d.ts.map +1 -1
- package/daemon/dist/domain/provider/reactive-tap.js +3 -0
- package/daemon/dist/domain/provider/reactive-tap.js.map +1 -1
- package/daemon/dist/domain/provider/usage-across-hosts.d.ts.map +1 -1
- package/daemon/dist/domain/provider/usage-across-hosts.js +8 -2
- package/daemon/dist/domain/provider/usage-across-hosts.js.map +1 -1
- package/daemon/dist/domain/provider/usage-windows.d.ts +2 -0
- package/daemon/dist/domain/provider/usage-windows.d.ts.map +1 -1
- package/daemon/dist/domain/provider/usage-windows.js +4 -0
- package/daemon/dist/domain/provider/usage-windows.js.map +1 -1
- package/daemon/dist/domain/queue-owner.d.ts +9 -0
- package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
- package/daemon/dist/domain/queue-owner.js +28 -0
- package/daemon/dist/domain/queue-owner.js.map +1 -1
- package/daemon/dist/domain/queue-repository.d.ts +18 -3
- package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.js +94 -10
- package/daemon/dist/domain/queue-repository.js.map +1 -1
- package/daemon/dist/domain/queue-retention.d.ts +1 -1
- package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
- package/daemon/dist/domain/queue-retention.js +6 -1
- package/daemon/dist/domain/queue-retention.js.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.d.ts +14 -3
- package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.js +50 -8
- package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.js +90 -28
- package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
- package/daemon/dist/domain/queue-wake-repository.d.ts +3 -0
- package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-wake-repository.js +5 -1
- package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.d.ts +26 -1
- package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.js +117 -11
- package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
- package/daemon/dist/domain/resume-metadata-refresher.d.ts +11 -2
- package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
- package/daemon/dist/domain/resume-metadata-refresher.js +32 -14
- package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
- package/daemon/dist/domain/resume-token-capture.d.ts +5 -1
- package/daemon/dist/domain/resume-token-capture.d.ts.map +1 -1
- package/daemon/dist/domain/resume-token-capture.js +3 -1
- package/daemon/dist/domain/resume-token-capture.js.map +1 -1
- package/daemon/dist/domain/rig-expansion-service.d.ts.map +1 -1
- package/daemon/dist/domain/rig-expansion-service.js +1 -0
- package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
- package/daemon/dist/domain/rig-repository.d.ts +19 -2
- package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
- package/daemon/dist/domain/rig-repository.js +247 -2
- package/daemon/dist/domain/rig-repository.js.map +1 -1
- package/daemon/dist/domain/rig-teardown.d.ts +1 -1
- package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
- package/daemon/dist/domain/rig-teardown.js +3 -1
- package/daemon/dist/domain/rig-teardown.js.map +1 -1
- package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-codec.js +4 -0
- package/daemon/dist/domain/rigspec-codec.js.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.js +7 -0
- package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts +41 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.js +174 -13
- package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
- package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-schema.js +24 -1
- package/daemon/dist/domain/rigspec-schema.js.map +1 -1
- package/daemon/dist/domain/running-name-guard.d.ts.map +1 -1
- package/daemon/dist/domain/running-name-guard.js +2 -1
- package/daemon/dist/domain/running-name-guard.js.map +1 -1
- package/daemon/dist/domain/runtime-adapter.d.ts +17 -1
- package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-adapter.js.map +1 -1
- package/daemon/dist/domain/runtime-switch-materials.d.ts +77 -0
- package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -0
- package/daemon/dist/domain/runtime-switch-materials.js +253 -0
- package/daemon/dist/domain/runtime-switch-materials.js.map +1 -0
- package/daemon/dist/domain/scope/scope-approve.d.ts +1 -1
- package/daemon/dist/domain/seat-activity-service.d.ts +4 -0
- package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-activity-service.js +17 -0
- package/daemon/dist/domain/seat-activity-service.js.map +1 -1
- package/daemon/dist/domain/seat-attention-reconciler.d.ts +8 -2
- package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
- package/daemon/dist/domain/seat-attention-reconciler.js +31 -2
- package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
- package/daemon/dist/domain/seat-handover-service.js +2 -2
- package/daemon/dist/domain/seat-handover-service.js.map +1 -1
- package/daemon/dist/domain/seat-launch-environment.d.ts +5 -0
- package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
- package/daemon/dist/domain/seat-launch-environment.js +8 -4
- package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts +19 -3
- package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.js +59 -13
- package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.d.ts +9 -2
- package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.js +27 -7
- package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
- package/daemon/dist/domain/seat-runtime-dir.d.ts +17 -0
- package/daemon/dist/domain/seat-runtime-dir.d.ts.map +1 -0
- package/daemon/dist/domain/seat-runtime-dir.js +27 -0
- package/daemon/dist/domain/seat-runtime-dir.js.map +1 -0
- package/daemon/dist/domain/seat-runtime-home.d.ts +42 -0
- package/daemon/dist/domain/seat-runtime-home.d.ts.map +1 -0
- package/daemon/dist/domain/seat-runtime-home.js +89 -0
- package/daemon/dist/domain/seat-runtime-home.js.map +1 -0
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts +220 -0
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -0
- package/daemon/dist/domain/seat-runtime-switch-service.js +593 -0
- package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -0
- package/daemon/dist/domain/seat-skills-pointer.d.ts +5 -0
- package/daemon/dist/domain/seat-skills-pointer.d.ts.map +1 -0
- package/daemon/dist/domain/seat-skills-pointer.js +15 -0
- package/daemon/dist/domain/seat-skills-pointer.js.map +1 -0
- package/daemon/dist/domain/seat-status-service.d.ts +31 -0
- package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-status-service.js +44 -0
- package/daemon/dist/domain/seat-status-service.js.map +1 -1
- package/daemon/dist/domain/seat-structural-activity-service.d.ts +3 -0
- package/daemon/dist/domain/seat-structural-activity-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-structural-activity-service.js +6 -0
- package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
- package/daemon/dist/domain/service-orchestrator.d.ts +7 -0
- package/daemon/dist/domain/service-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/service-orchestrator.js +4 -0
- package/daemon/dist/domain/service-orchestrator.js.map +1 -1
- package/daemon/dist/domain/session-transport.d.ts +19 -1
- package/daemon/dist/domain/session-transport.d.ts.map +1 -1
- package/daemon/dist/domain/session-transport.js +227 -47
- package/daemon/dist/domain/session-transport.js.map +1 -1
- package/daemon/dist/domain/snapshot-capture.d.ts +4 -1
- package/daemon/dist/domain/snapshot-capture.d.ts.map +1 -1
- package/daemon/dist/domain/snapshot-capture.js +4 -1
- package/daemon/dist/domain/snapshot-capture.js.map +1 -1
- package/daemon/dist/domain/snapshot-repository.d.ts +4 -3
- package/daemon/dist/domain/snapshot-repository.d.ts.map +1 -1
- package/daemon/dist/domain/snapshot-repository.js +6 -5
- package/daemon/dist/domain/snapshot-repository.js.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts +3 -0
- package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.js +58 -16
- package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.d.ts +1 -0
- package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.js +1 -0
- package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
- package/daemon/dist/domain/stream-reader-actions.d.ts +49 -0
- package/daemon/dist/domain/stream-reader-actions.d.ts.map +1 -0
- package/daemon/dist/domain/stream-reader-actions.js +104 -0
- package/daemon/dist/domain/stream-reader-actions.js.map +1 -0
- package/daemon/dist/domain/successor-session-launcher.d.ts +35 -1
- package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.js +58 -3
- package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
- package/daemon/dist/domain/terminal/herdr-adapter.d.ts +6 -28
- package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/herdr-adapter.js +16 -66
- package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
- package/daemon/dist/domain/terminal/rex-adapter.d.ts +42 -0
- package/daemon/dist/domain/terminal/rex-adapter.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/rex-adapter.js +228 -0
- package/daemon/dist/domain/terminal/rex-adapter.js.map +1 -0
- package/daemon/dist/domain/terminal/rex-layout.d.ts +26 -0
- package/daemon/dist/domain/terminal/rex-layout.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/rex-layout.js +21 -0
- package/daemon/dist/domain/terminal/rex-layout.js.map +1 -0
- package/daemon/dist/domain/terminal/rex-transport.d.ts +43 -0
- package/daemon/dist/domain/terminal/rex-transport.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/rex-transport.js +176 -0
- package/daemon/dist/domain/terminal/rex-transport.js.map +1 -0
- package/daemon/dist/domain/terminal/terminal-provider.d.ts +11 -0
- package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/terminal-service.d.ts +2 -2
- package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/terminal-service.js +10 -11
- package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
- package/daemon/dist/domain/terminal/tile-attach.d.ts +2 -0
- package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/tile-attach.js +42 -0
- package/daemon/dist/domain/terminal/tile-attach.js.map +1 -0
- package/daemon/dist/domain/terminal/tile-layout.d.ts +32 -0
- package/daemon/dist/domain/terminal/tile-layout.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/tile-layout.js +36 -0
- package/daemon/dist/domain/terminal/tile-layout.js.map +1 -0
- package/daemon/dist/domain/terminal/view-composer.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/view-composer.js +11 -7
- package/daemon/dist/domain/terminal/view-composer.js.map +1 -1
- package/daemon/dist/domain/types.d.ts +61 -0
- package/daemon/dist/domain/types.d.ts.map +1 -1
- package/daemon/dist/domain/types.js.map +1 -1
- package/daemon/dist/domain/wake-recovery.d.ts +16 -0
- package/daemon/dist/domain/wake-recovery.d.ts.map +1 -0
- package/daemon/dist/domain/wake-recovery.js +31 -0
- package/daemon/dist/domain/wake-recovery.js.map +1 -0
- package/daemon/dist/index.d.ts.map +1 -1
- package/daemon/dist/index.js +5 -1
- package/daemon/dist/index.js.map +1 -1
- package/daemon/dist/lib/pane-envelope.d.ts +5 -0
- package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
- package/daemon/dist/lib/pane-envelope.js +8 -1
- package/daemon/dist/lib/pane-envelope.js.map +1 -1
- package/daemon/dist/routes/activity.d.ts.map +1 -1
- package/daemon/dist/routes/activity.js +12 -0
- package/daemon/dist/routes/activity.js.map +1 -1
- package/daemon/dist/routes/agent-images.d.ts.map +1 -1
- package/daemon/dist/routes/agent-images.js +9 -0
- package/daemon/dist/routes/agent-images.js.map +1 -1
- package/daemon/dist/routes/context-packs.d.ts.map +1 -1
- package/daemon/dist/routes/context-packs.js +22 -0
- package/daemon/dist/routes/context-packs.js.map +1 -1
- package/daemon/dist/routes/mission-control.js +2 -2
- package/daemon/dist/routes/mission-control.js.map +1 -1
- package/daemon/dist/routes/provider.d.ts.map +1 -1
- package/daemon/dist/routes/provider.js +83 -3
- package/daemon/dist/routes/provider.js.map +1 -1
- package/daemon/dist/routes/queue.d.ts.map +1 -1
- package/daemon/dist/routes/queue.js +102 -10
- package/daemon/dist/routes/queue.js.map +1 -1
- package/daemon/dist/routes/require-sender-identity.d.ts +10 -8
- package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
- package/daemon/dist/routes/require-sender-identity.js +13 -11
- package/daemon/dist/routes/require-sender-identity.js.map +1 -1
- package/daemon/dist/routes/rigs.js +2 -0
- package/daemon/dist/routes/rigs.js.map +1 -1
- package/daemon/dist/routes/runtime-switch-custody.d.ts +21 -0
- package/daemon/dist/routes/runtime-switch-custody.d.ts.map +1 -0
- package/daemon/dist/routes/runtime-switch-custody.js +55 -0
- package/daemon/dist/routes/runtime-switch-custody.js.map +1 -0
- package/daemon/dist/routes/scope-approve.js +2 -2
- package/daemon/dist/routes/scope-approve.js.map +1 -1
- package/daemon/dist/routes/seat.d.ts.map +1 -1
- package/daemon/dist/routes/seat.js +90 -7
- package/daemon/dist/routes/seat.js.map +1 -1
- package/daemon/dist/routes/sessions.d.ts.map +1 -1
- package/daemon/dist/routes/sessions.js +9 -0
- package/daemon/dist/routes/sessions.js.map +1 -1
- package/daemon/dist/routes/startup.js +15 -5
- package/daemon/dist/routes/startup.js.map +1 -1
- package/daemon/dist/routes/stream.d.ts.map +1 -1
- package/daemon/dist/routes/stream.js +25 -2
- package/daemon/dist/routes/stream.js.map +1 -1
- package/daemon/dist/routes/transport.d.ts.map +1 -1
- package/daemon/dist/routes/transport.js +31 -3
- package/daemon/dist/routes/transport.js.map +1 -1
- package/daemon/dist/seat-recap-store-surface.d.ts +1 -1
- package/daemon/dist/seat-recap-store-surface.d.ts.map +1 -1
- package/daemon/dist/seat-recap-store-surface.js +1 -1
- package/daemon/dist/seat-recap-store-surface.js.map +1 -1
- package/daemon/dist/server.d.ts +2 -0
- package/daemon/dist/server.d.ts.map +1 -1
- package/daemon/dist/server.js +1 -0
- package/daemon/dist/server.js.map +1 -1
- package/daemon/dist/startup.d.ts +5 -0
- package/daemon/dist/startup.d.ts.map +1 -1
- package/daemon/dist/startup.js +106 -28
- package/daemon/dist/startup.js.map +1 -1
- package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
- package/daemon/dist/terminal/TerminalSessionBroker.js +5 -0
- package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
- package/daemon/docs/reference/community-harness-examples/cursor/cursor.yaml +2 -2
- package/daemon/docs/reference/community-harness-examples/cursor/openrig-cursor-launch +7 -0
- package/daemon/docs/reference/community-harness-examples/openclaw/openclaw-gateway.yaml +15 -0
- package/daemon/docs/reference/community-harness-examples/openclaw/openclaw.yaml +5 -2
- package/daemon/docs/reference/community-harness-examples/openclaw/openrig-openclaw-launch +56 -24
- package/daemon/docs/reference/community-harness-presets.md +33 -18
- package/daemon/docs/reference/getting-started.md +82 -10
- package/daemon/docs/reference/health-diagnosis.md +13 -0
- package/daemon/docs/reference/help.md +6 -0
- package/daemon/docs/reference/keeping-a-watch.md +21 -0
- package/daemon/docs/reference/project-workspace.md +18 -0
- package/daemon/docs/reference/publishing-a-rig-bundle.md +11 -0
- package/daemon/docs/reference/quickstart.md +1 -1
- package/daemon/docs/reference/rig-spec.md +93 -3
- package/daemon/docs/reference/sdlc-conventions.md +3 -1
- package/daemon/docs/reference/seat-delivery.md +16 -5
- package/daemon/docs/reference/slack-app-setup.md +1 -1
- package/daemon/docs/reference/terminal-sessions.md +51 -0
- package/daemon/docs/reference/whats-new.md +262 -149
- package/daemon/specs/agents/shared/skills/core/openrig-herdr/SKILL.md +17 -5
- package/daemon/specs/agents/shared/skills/process/agent-browser/LICENSE.txt +201 -0
- package/daemon/specs/agents/shared/skills/process/agent-browser/OPENRIG.md +13 -29
- package/daemon/specs/agents/shared/skills/process/agent-browser/SKILL.md +7 -7
- package/daemon/specs/agents/shared/skills/process/dogfood/LICENSE.txt +201 -0
- package/daemon/specs/agents/shared/skills/process/dogfood/SKILL.md +6 -2
- package/daemon/specs/agents/shared/skills/process/systematic-debugging/LICENSE.txt +21 -0
- package/daemon/specs/agents/shared/skills/process/systematic-debugging/SKILL.md +6 -2
- package/daemon/specs/agents/shared/skills/process/test-driven-development/LICENSE.txt +21 -0
- package/daemon/specs/agents/shared/skills/process/test-driven-development/SKILL.md +5 -1
- package/daemon/specs/agents/shared/skills/process/verification-before-completion/LICENSE.txt +21 -0
- package/daemon/specs/agents/shared/skills/process/verification-before-completion/SKILL.md +5 -1
- package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +18 -1
- package/daemon/specs/rigs/launch/kernel/agents/operator/agent/startup/context.md +3 -0
- package/daemon/specs/rigs/launch/kernel/agents/queue/worker/guidance/role.md +3 -2
- package/dist/build-info.js +3 -3
- package/dist/client.d.ts +8 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +2 -1
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/capture.d.ts.map +1 -1
- package/dist/commands/capture.js +8 -0
- package/dist/commands/capture.js.map +1 -1
- package/dist/commands/chatroom.d.ts.map +1 -1
- package/dist/commands/chatroom.js +6 -0
- package/dist/commands/chatroom.js.map +1 -1
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +29 -23
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +6 -2
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +3 -0
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +47 -0
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/health.js +1 -1
- package/dist/commands/health.js.map +1 -1
- package/dist/commands/launch.js +1 -1
- package/dist/commands/launch.js.map +1 -1
- package/dist/commands/project.d.ts.map +1 -1
- package/dist/commands/project.js +6 -1
- package/dist/commands/project.js.map +1 -1
- package/dist/commands/proof.d.ts.map +1 -1
- package/dist/commands/proof.js +33 -2
- package/dist/commands/proof.js.map +1 -1
- package/dist/commands/provider.d.ts.map +1 -1
- package/dist/commands/provider.js +172 -24
- package/dist/commands/provider.js.map +1 -1
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +154 -30
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/scope.d.ts.map +1 -1
- package/dist/commands/scope.js +5 -2
- package/dist/commands/scope.js.map +1 -1
- package/dist/commands/seat.d.ts.map +1 -1
- package/dist/commands/seat.js +212 -5
- package/dist/commands/seat.js.map +1 -1
- package/dist/commands/skill.d.ts.map +1 -1
- package/dist/commands/skill.js +21 -0
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/stream-outcome.d.ts +586 -1
- package/dist/commands/stream-outcome.d.ts.map +1 -1
- package/dist/commands/stream-outcome.js +38 -1
- package/dist/commands/stream-outcome.js.map +1 -1
- package/dist/commands/stream.d.ts.map +1 -1
- package/dist/commands/stream.js +22 -0
- package/dist/commands/stream.js.map +1 -1
- package/dist/commands/terminal.d.ts +4 -0
- package/dist/commands/terminal.d.ts.map +1 -1
- package/dist/commands/terminal.js +7 -5
- package/dist/commands/terminal.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +7 -1
- package/dist/commands/up.js.map +1 -1
- package/dist/lib/codex-auth.d.ts +1 -147
- package/dist/lib/codex-auth.d.ts.map +1 -1
- package/dist/lib/codex-auth.js +2 -505
- package/dist/lib/codex-auth.js.map +1 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +52 -1
- package/dist/mcp-server.js.map +1 -1
- package/dist/terminal-window-rex.d.ts +6 -0
- package/dist/terminal-window-rex.d.ts.map +1 -0
- package/dist/terminal-window-rex.js +129 -0
- package/dist/terminal-window-rex.js.map +1 -0
- package/dist/terminal-window.d.ts +2 -0
- package/dist/terminal-window.d.ts.map +1 -1
- package/dist/terminal-window.js +19 -7
- package/dist/terminal-window.js.map +1 -1
- package/package.json +1 -1
- package/tui/dist/commands/registry.js +1 -1
- package/tui/dist/commands/registry.js.map +1 -1
- package/tui/dist/daemon-client.d.ts +4 -3
- package/tui/dist/daemon-client.d.ts.map +1 -1
- package/tui/dist/daemon-client.js +5 -4
- package/tui/dist/daemon-client.js.map +1 -1
- package/tui/dist/hydrate.d.ts.map +1 -1
- package/tui/dist/hydrate.js +4 -1
- package/tui/dist/hydrate.js.map +1 -1
- package/tui/dist/live.d.ts.map +1 -1
- package/tui/dist/live.js +6 -4
- package/tui/dist/live.js.map +1 -1
- package/tui/dist/terminals/open-window.d.ts +9 -5
- package/tui/dist/terminals/open-window.d.ts.map +1 -1
- package/tui/dist/terminals/open-window.js +29 -12
- package/tui/dist/terminals/open-window.js.map +1 -1
- package/tui/dist/terminals/terminal-model.d.ts +2 -1
- package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
- package/tui/dist/terminals/terminal-model.js +5 -4
- package/tui/dist/terminals/terminal-model.js.map +1 -1
- package/tui/dist/usage/usage-model.d.ts.map +1 -1
- package/tui/dist/usage/usage-model.js +5 -3
- package/tui/dist/usage/usage-model.js.map +1 -1
- package/ui/dist/assets/{index-Blg-p32B.js → index-DLP1ipGq.js} +1 -1
- package/ui/dist/index.html +1 -1
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
import nodePath from "node:path";
|
|
2
|
+
import { ulid } from "ulid";
|
|
3
|
+
import { SeatStatusService } from "./seat-status-service.js";
|
|
4
|
+
import { SeatLifecycleService } from "./seat-lifecycle-service.js";
|
|
5
|
+
import { SuccessorSessionLauncher } from "./successor-session-launcher.js";
|
|
6
|
+
import { buildRestorePacket } from "./seat-handover-service.js";
|
|
7
|
+
import { NativePermissionStore } from "./native-permission-store.js";
|
|
8
|
+
import { validateNativePermissionSelection } from "./native-permission-selection.js";
|
|
9
|
+
import { AppliedLaunchObservationStore } from "./applied-launch-observation-store.js";
|
|
10
|
+
import { validateResumeToken } from "./resume-token-validation.js";
|
|
11
|
+
import { SnapshotCapture } from "./snapshot-capture.js";
|
|
12
|
+
import { SnapshotRepository } from "./snapshot-repository.js";
|
|
13
|
+
import { CheckpointStore } from "./checkpoint-store.js";
|
|
14
|
+
import { DeliveryGuardError } from "./seat-delivery-guard.js";
|
|
15
|
+
import { seatCodexCorePluginDir, seatCorePluginDir, withPluginDirs } from "./claude-core-plugin-env.js";
|
|
16
|
+
import { planRuntimeSwitchMaterials } from "./runtime-switch-materials.js";
|
|
17
|
+
import { terminatePaneInPlace } from "./pane-cutover.js";
|
|
18
|
+
/**
|
|
19
|
+
* Slice 16: switch one live seat between Codex and Claude Code, successor first (founder
|
|
20
|
+
* decision-20261014-0454-1214-successor-first; built from #1214 by Aschenbath, whose design is the starting point).
|
|
21
|
+
*
|
|
22
|
+
* The seat keeps its address, edges, queue rows and claims. Its successor starts on the target runtime in a staging
|
|
23
|
+
* session beside the current occupant, reads a handover, and confirms it through OpenRig with its own reserved
|
|
24
|
+
* generation. That confirmation is the evidence it can carry on. Only then are the panes exchanged and the seat's
|
|
25
|
+
* configuration committed (one transaction, which also moves the claims); then the predecessor is retired. Before the
|
|
26
|
+
* commit the predecessor holds the seat; after it the successor does; a durable record (`seat_runtime_switches`) lets
|
|
27
|
+
* recovery finish either side without guessing.
|
|
28
|
+
*/
|
|
29
|
+
export const RUNTIME_SWITCH_CONFIRM_TIMEOUT_MS_DEFAULT = 180_000;
|
|
30
|
+
const COSTS = [
|
|
31
|
+
"A new conversation: native history isn't converted; only the handover carries over.",
|
|
32
|
+
"Same address, different terminal: the seat's session and address stay, its pane and scrollback change.",
|
|
33
|
+
"The team file isn't rewritten: the database and rig export show the new runtime, the imported YAML keeps the old one, so a later converge reports a deferred change_runtime.",
|
|
34
|
+
"Source settings are cleared, not mapped: model, effort, Codex profile and an explicit native permission choice. A model or effort the seat's agent spec declares for the source runtime doesn't apply either.",
|
|
35
|
+
"A second process runs on the target's account until cutover.",
|
|
36
|
+
"Messages sent to the seat while it switches are held, not typed; rig send says the seat is switching and until when, and they need sending again afterwards.",
|
|
37
|
+
"A failed switch can leave the target runtime's prepared files (its seat storage and projections).",
|
|
38
|
+
"Codex and Claude Code only, single-pane seats only.",
|
|
39
|
+
];
|
|
40
|
+
export class SeatRuntimeSwitchService {
|
|
41
|
+
deps;
|
|
42
|
+
now;
|
|
43
|
+
sleep;
|
|
44
|
+
constructor(deps) {
|
|
45
|
+
this.deps = deps;
|
|
46
|
+
for (const owner of [deps.rigRepo, deps.sessionRegistry, deps.discoveryRepo, deps.eventBus]) {
|
|
47
|
+
if (owner.db !== deps.db)
|
|
48
|
+
throw new Error("Runtime switch dependencies must share one database.");
|
|
49
|
+
}
|
|
50
|
+
this.now = deps.now ?? (() => new Date());
|
|
51
|
+
this.sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
52
|
+
}
|
|
53
|
+
/** The open (or attention-holding) switch for a seat, as `rig seat status` shows it. */
|
|
54
|
+
openSwitch(nodeId) {
|
|
55
|
+
try {
|
|
56
|
+
return this.deps.db.prepare(`SELECT * FROM seat_runtime_switches WHERE node_id = ?
|
|
57
|
+
AND (phase IN ('preparing', 'confirmed', 'committed') OR attention IS NOT NULL) ORDER BY created_at DESC LIMIT 1`)
|
|
58
|
+
.get(nodeId) ?? null;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async setRuntime(input) {
|
|
65
|
+
const refuse = (code, message, guidance) => ({ ok: false, code, message, ...(guidance ? { guidance } : {}) });
|
|
66
|
+
if (input.runtime !== "codex" && input.runtime !== "claude-code") {
|
|
67
|
+
return refuse("invalid_runtime_settings", "Choose --runtime codex or --runtime claude-code.");
|
|
68
|
+
}
|
|
69
|
+
const target = input.runtime;
|
|
70
|
+
const reason = input.reason?.trim();
|
|
71
|
+
if (!reason)
|
|
72
|
+
return refuse("invalid_runtime_settings", "Give a --reason for the switch; it is recorded with it.");
|
|
73
|
+
const explicit = {};
|
|
74
|
+
for (const key of ["model", "effort", "codexConfigProfile", "permissionMode"]) {
|
|
75
|
+
const value = input[key];
|
|
76
|
+
if (value === undefined)
|
|
77
|
+
continue;
|
|
78
|
+
if (!value.trim() || /[\r\n\0]/.test(value))
|
|
79
|
+
return refuse("invalid_runtime_settings", `${key} must be a non-empty single-line value.`);
|
|
80
|
+
explicit[key] = value.trim();
|
|
81
|
+
}
|
|
82
|
+
if (target !== "codex" && explicit.codexConfigProfile) {
|
|
83
|
+
return refuse("invalid_runtime_settings", "--codex-config-profile applies only when switching to Codex.");
|
|
84
|
+
}
|
|
85
|
+
const { db, rigRepo, sessionRegistry, tmuxAdapter: tmux } = this.deps;
|
|
86
|
+
const status = new SeatStatusService({ rigRepo }).getStatus(input.seatRef);
|
|
87
|
+
if (!status.ok)
|
|
88
|
+
return status;
|
|
89
|
+
const node = rigRepo.getRig(status.status.rig_id)?.nodes.find((candidate) => candidate.logicalId === status.status.logical_id);
|
|
90
|
+
if (!node)
|
|
91
|
+
return refuse("seat_not_found", `No seat ${input.seatRef}.`);
|
|
92
|
+
const guard = tmux.deliveryGuard;
|
|
93
|
+
if (!input.dryRun && guard && !guard.ownsLifecycle(node.id)) {
|
|
94
|
+
try {
|
|
95
|
+
return await guard.lifecycle([node.id], () => this.setRuntime(input));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error instanceof DeliveryGuardError)
|
|
99
|
+
return refuse(error.code, `${error.message} The seat wasn't changed.`);
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const seatRef = `${node.logicalId}@${status.status.rig_name}`;
|
|
104
|
+
const open = this.openSwitch(node.id);
|
|
105
|
+
if (open) {
|
|
106
|
+
return { ...refuse("runtime_switch_pending", `${seatRef} already has a runtime switch ${open.committed_at ? "that committed and still needs finishing"
|
|
107
|
+
: open.phase === "abandoned" ? "whose staged successor hasn't been retired" : "in progress"} (${open.from_runtime} → ${open.to_runtime}, switch ${open.id}).`, `Inspect it with rig seat status ${seatRef}; finish an interrupted one with rig seat set-runtime ${seatRef} --recover.`), switchId: open.id };
|
|
108
|
+
}
|
|
109
|
+
if (node.runtime !== "codex" && node.runtime !== "claude-code") {
|
|
110
|
+
return refuse("runtime_switch_unsupported", `${seatRef} runs ${node.runtime ?? "an unknown runtime"}; only Codex and Claude Code seats can switch.`);
|
|
111
|
+
}
|
|
112
|
+
const binding = sessionRegistry.getBindingForNode(node.id);
|
|
113
|
+
const sessionName = binding?.tmuxSession ?? null;
|
|
114
|
+
const base = { seat: { ref: seatRef, nodeId: node.id, rigId: node.rigId, session: sessionName ?? "" }, from: node.runtime, to: target };
|
|
115
|
+
if (node.runtime === target) {
|
|
116
|
+
if (explicit.model || explicit.effort || explicit.codexConfigProfile || explicit.permissionMode) {
|
|
117
|
+
return refuse("runtime_unchanged", `${seatRef} already runs ${target}.`, "Change settings within one runtime with rig seat set-model, rig seat set-effort or rig seat set-permissions.");
|
|
118
|
+
}
|
|
119
|
+
return { ok: true, dryRun: !!input.dryRun, changed: false, ...base };
|
|
120
|
+
}
|
|
121
|
+
const predecessorGeneration = sessionRegistry.currentOccupantTenure(node.id)?.generationUuid;
|
|
122
|
+
const running = sessionRegistry.getSessionsForRig(node.rigId).filter((session) => session.nodeId === node.id && session.status === "running");
|
|
123
|
+
const unsupported = !sessionName || !binding?.tmuxPane ? "it has no bound tmux pane"
|
|
124
|
+
: binding.attachmentType && binding.attachmentType !== "tmux" ? `it's attached through ${binding.attachmentType}, not tmux`
|
|
125
|
+
: !predecessorGeneration ? "its current occupant generation isn't recorded"
|
|
126
|
+
: running.length !== 1 || running[0].sessionName !== sessionName ? "it doesn't have exactly one running session at its address"
|
|
127
|
+
: !node.cwd || !nodePath.isAbsolute(node.cwd) ? "its working directory isn't an absolute path"
|
|
128
|
+
: null;
|
|
129
|
+
if (unsupported)
|
|
130
|
+
return refuse("runtime_switch_unsupported", `${seatRef} can't switch runtime: ${unsupported}.`);
|
|
131
|
+
try {
|
|
132
|
+
const [panes, windows] = await Promise.all([tmux.listPanes(sessionName), tmux.listWindows(sessionName)]);
|
|
133
|
+
if (windows.length !== 1 || panes.length !== 1 || panes[0].id !== binding.tmuxPane) {
|
|
134
|
+
return refuse("runtime_switch_unsupported", `${seatRef} can't switch runtime: only a single-window, single-pane seat can, and its session has ${windows.length} window(s) and ${panes.length} pane(s).`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return refuse("runtime_switch_unsupported", `${seatRef} can't switch runtime: its session couldn't be read (${error.message}).`);
|
|
139
|
+
}
|
|
140
|
+
if (!this.deps.runtimeAdapters?.[target]) {
|
|
141
|
+
return refuse("runtime_target_unavailable", `${target} isn't available on this daemon, so no successor can start here.`);
|
|
142
|
+
}
|
|
143
|
+
// Settings: the target's explicit permission choice, else member and rig policy. Never the source's selection.
|
|
144
|
+
const permissions = new NativePermissionStore(db);
|
|
145
|
+
let selection = null;
|
|
146
|
+
let sourceSelection = null;
|
|
147
|
+
try {
|
|
148
|
+
sourceSelection = permissions.read(node.id);
|
|
149
|
+
const mode = explicit.permissionMode ?? "inherit";
|
|
150
|
+
if (mode !== "inherit") {
|
|
151
|
+
selection = target === "claude-code" && mode !== "floor" && mode !== "full_bypass"
|
|
152
|
+
? (/^[A-Za-z][A-Za-z0-9_]*$/.test(mode) ? { runtime: "claude-code", mode } : (() => { throw new Error(`"${mode}" isn't a permission mode.`); })())
|
|
153
|
+
: validateNativePermissionSelection(target, mode);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
return refuse("invalid_runtime_settings", error.message);
|
|
158
|
+
}
|
|
159
|
+
let materials;
|
|
160
|
+
try {
|
|
161
|
+
const saved = new SeatLifecycleService({ db, rigRepo, sessionRegistry, eventBus: this.deps.eventBus, tmuxAdapter: tmux }).readStartupContext(node.id, node.cwd);
|
|
162
|
+
if (!saved.ok && node.agentRef)
|
|
163
|
+
return refuse("runtime_target_unavailable", saved.refusal.message);
|
|
164
|
+
materials = planRuntimeSwitchMaterials({ db, node, rigName: status.status.rig_name, canonicalSession: sessionName, runtime: target,
|
|
165
|
+
explicit, saved: saved.ok ? saved.context : null, claudeManagedBlockFile: rigRepo.getRigClaudeManagedBlockFile(node.rigId) ?? undefined,
|
|
166
|
+
resolution: this.deps.materialResolution, openrigHome: this.deps.openrigHome });
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return refuse("runtime_target_unavailable", error.message);
|
|
170
|
+
}
|
|
171
|
+
const dropped = [...materials.dropped, ...(sourceSelection ? [{ setting: "native permission choice", value: `${sourceSelection.runtime}:${sourceSelection.mode}` }] : [])];
|
|
172
|
+
const plan = {
|
|
173
|
+
...base,
|
|
174
|
+
settings: materials.settings,
|
|
175
|
+
permission: selection ? { mode: selection.mode, source: "explicit" } : { mode: "inherit", source: "member_or_rig_policy" },
|
|
176
|
+
dropped,
|
|
177
|
+
costs: COSTS,
|
|
178
|
+
notRun: materials.notRun.map((command) => `startup slash command not run by a switch: ${command}`),
|
|
179
|
+
warnings: materials.warnings,
|
|
180
|
+
};
|
|
181
|
+
if (input.dryRun)
|
|
182
|
+
return { ok: true, dryRun: true, changed: true, ...plan };
|
|
183
|
+
return this.execute({ input: { ...input, reason }, node, seatRef, sessionName: sessionName, predecessorPane: binding.tmuxPane,
|
|
184
|
+
predecessorGeneration: predecessorGeneration, target, materials, selection, plan, restorePolicy: running[0].restorePolicy ?? node.restorePolicy ?? null });
|
|
185
|
+
}
|
|
186
|
+
/** The staged successor's confirmation: only that switch's reserved generation, at the seat it names. */
|
|
187
|
+
confirm(input) {
|
|
188
|
+
const refused = (message) => ({ ok: false, code: "runtime_switch_confirmation_refused", message, switchId: input.switchId });
|
|
189
|
+
const note = input.note?.trim();
|
|
190
|
+
if (!note || note.length > 2000 || /\0/.test(note))
|
|
191
|
+
return refused("Confirm with a --note of up to 2000 characters saying what you'll do first.");
|
|
192
|
+
const row = this.deps.db.prepare("SELECT * FROM seat_runtime_switches WHERE id = ?").get(input.switchId);
|
|
193
|
+
if (!row)
|
|
194
|
+
return refused(`No runtime switch ${input.switchId}.`);
|
|
195
|
+
if (row.committed_at || row.phase !== "preparing")
|
|
196
|
+
return refused(`Switch ${row.id} isn't waiting for a confirmation (it is ${row.phase}).`);
|
|
197
|
+
if (!input.actorSession || input.actorSession !== row.canonical_session || input.generation !== row.successor_generation) {
|
|
198
|
+
return refused(`Only the staged successor of ${row.canonical_session} for switch ${row.id} can confirm it. Nothing was changed.`);
|
|
199
|
+
}
|
|
200
|
+
const changed = this.deps.db.prepare(`UPDATE seat_runtime_switches SET phase = 'confirmed', confirmation_note = ?, confirmed_at = ?,
|
|
201
|
+
updated_at = ? WHERE id = ? AND phase = 'preparing' AND committed_at IS NULL`).run(note, this.now().toISOString(), this.now().toISOString(), row.id);
|
|
202
|
+
if (changed.changes !== 1)
|
|
203
|
+
return refused(`Switch ${row.id} changed while confirming; nothing was recorded.`);
|
|
204
|
+
return { ok: true, switchId: row.id, message: `Confirmed. OpenRig is moving ${row.canonical_session} to you now. Wait for the activation message before acting as the seat.` };
|
|
205
|
+
}
|
|
206
|
+
async execute(ctx) {
|
|
207
|
+
const { db, rigRepo, sessionRegistry, tmuxAdapter: tmux } = this.deps;
|
|
208
|
+
const { node, sessionName, target, materials } = ctx;
|
|
209
|
+
const failed = (message, guidance) => ({ ok: false, code: "runtime_switch_failed", committed: false, message,
|
|
210
|
+
guidance: guidance ?? `${ctx.seatRef} is unchanged on ${node.runtime}. Correct the cause and try again.` });
|
|
211
|
+
// Refuse unreadable target settings before an active switch can hold sends to the current occupant.
|
|
212
|
+
let override;
|
|
213
|
+
try {
|
|
214
|
+
override = new NativePermissionStore(db).launchOverride(node.id, target, {
|
|
215
|
+
selection: ctx.selection, codexProfile: materials.settings.codexConfigProfile.value,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
return failed(error.message);
|
|
220
|
+
}
|
|
221
|
+
const successorGeneration = sessionRegistry.reserveOccupantGeneration();
|
|
222
|
+
if (!successorGeneration)
|
|
223
|
+
return failed("No occupant generation could be reserved for the successor (the tenure ledger is unavailable).");
|
|
224
|
+
// Facts the handover carries, read while the predecessor still holds the seat.
|
|
225
|
+
const screen = await tmux.capturePaneScreen(ctx.predecessorPane).catch(() => null);
|
|
226
|
+
const recap = this.deps.predecessorRecapResolver?.({ nodeId: node.id, runtime: node.runtime, sessionName });
|
|
227
|
+
const authored = this.deps.authoredRecapResolver?.(ctx.seatRef);
|
|
228
|
+
const id = ulid();
|
|
229
|
+
const row = { id, staging_session: `openrig-switch-${id.toLowerCase()}` };
|
|
230
|
+
const stamp = () => this.now().toISOString();
|
|
231
|
+
const confirmTimeoutMs = ctx.input.confirmTimeoutMs ?? RUNTIME_SWITCH_CONFIRM_TIMEOUT_MS_DEFAULT;
|
|
232
|
+
// An upper estimate a waiting send can quote: the successor's start and readiness, then its confirmation window.
|
|
233
|
+
const deadlineAt = new Date(this.now().getTime() + (this.deps.readinessTimeoutMs ?? 60_000) + confirmTimeoutMs + 30_000).toISOString();
|
|
234
|
+
db.prepare(`INSERT INTO seat_runtime_switches (id, node_id, canonical_session, staging_session, predecessor_pane, predecessor_generation,
|
|
235
|
+
successor_generation, from_runtime, to_runtime, reason, requested_by, plan_json, deadline_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
236
|
+
.run(id, node.id, sessionName, row.staging_session, ctx.predecessorPane, ctx.predecessorGeneration, successorGeneration, node.runtime, target, ctx.input.reason, ctx.input.requestedBy ?? null, JSON.stringify(ctx.plan), deadlineAt, stamp(), stamp());
|
|
237
|
+
let successorPane = null;
|
|
238
|
+
const abandon = async (why) => {
|
|
239
|
+
const retired = await this.retireStaging(row.staging_session, node.id, "Uncommitted successor");
|
|
240
|
+
db.prepare(`UPDATE seat_runtime_switches SET phase = 'abandoned', outcome = ?, attention = ?, updated_at = ? WHERE id = ? AND committed_at IS NULL`)
|
|
241
|
+
.run(why, retired.ok ? null : `The staged successor couldn't be retired: ${retired.message}`, stamp(), id);
|
|
242
|
+
tmux.finishLaunchBinding(row.staging_session);
|
|
243
|
+
return { ...failed(`${why}${retired.ok ? "" : ` The staged successor couldn't be retired (${retired.message}); recover with rig seat set-runtime ${ctx.seatRef} --recover.`}`), switchId: id };
|
|
244
|
+
};
|
|
245
|
+
// 1. The successor, on the target runtime, beside the predecessor.
|
|
246
|
+
const policyPosture = rigRepo.getNodePolicyProvenance(node.id)?.launchPosture ?? rigRepo.getRigPolicyProvenance(node.rigId)?.launchPosture ?? "floor";
|
|
247
|
+
const posture = override.launchPosture ?? policyPosture;
|
|
248
|
+
// Codex has no auto mode; it launches at the floor, as its permission resolution says.
|
|
249
|
+
const launchPosture = posture === "auto" && target === "codex" ? "floor" : posture;
|
|
250
|
+
const permissionMode = override.permissionMode ?? (posture === "auto" && target === "claude-code" ? "auto" : undefined);
|
|
251
|
+
const targetNode = { id: node.id, runtime: target };
|
|
252
|
+
const corePluginDir = seatCorePluginDir(targetNode, db, materials.pluginPaths, this.deps.pluginsDir);
|
|
253
|
+
const codexCorePluginDir = seatCodexCorePluginDir(targetNode, db, materials.pluginPaths, this.deps.pluginsDir);
|
|
254
|
+
const launcher = new SuccessorSessionLauncher(tmux, this.deps.discoveryRepo, {
|
|
255
|
+
sessionEnv: this.deps.sessionEnv, runtimeSessionEnv: this.deps.runtimeSessionEnv, runtimeAdapters: this.deps.runtimeAdapters,
|
|
256
|
+
tmuxOptionDefaults: this.deps.tmuxOptionDefaults, readinessTimeoutMs: this.deps.readinessTimeoutMs, sleep: this.deps.sleep,
|
|
257
|
+
});
|
|
258
|
+
const launch = await launcher.stageSuccessor({
|
|
259
|
+
stagingSession: row.staging_session, canonicalSession: sessionName, occupantGeneration: successorGeneration,
|
|
260
|
+
node: { id: node.id, runtime: target, cwd: node.cwd, model: materials.settings.model.value, effort: materials.settings.effort.value,
|
|
261
|
+
advisor: materials.settings.advisor.value, codexConfigProfile: materials.settings.codexConfigProfile.value,
|
|
262
|
+
claudePermissions: override.claudePermissions, kernelAuthority: override.kernelAuthority, teamPermissionDefault: override.teamPermissionDefault,
|
|
263
|
+
nonInterruptive: rigRepo.getRigNonInterruptive(node.rigId), launchPosture, ...(permissionMode ? { permissionMode } : {}),
|
|
264
|
+
seatEnv: withPluginDirs(rigRepo.getEffectiveSeatEnv(node.id), [corePluginDir, target === "claude-code" ? materials.seatSkills.pluginDir : undefined]),
|
|
265
|
+
...((corePluginDir || codexCorePluginDir) && node.cwd ? { seatProjectDir: node.cwd } : {}) },
|
|
266
|
+
onPaneCreated: (pane) => {
|
|
267
|
+
successorPane = pane;
|
|
268
|
+
db.prepare("UPDATE seat_runtime_switches SET successor_pane = ?, updated_at = ? WHERE id = ?").run(pane, stamp(), id);
|
|
269
|
+
},
|
|
270
|
+
staged: { prepare: (binding, adapter) => materials.prepare(binding, adapter),
|
|
271
|
+
binding: { ...materials.bindingAdditions(), runtimeSwitchFrom: { runtime: node.runtime, session: sessionName, pane: ctx.predecessorPane, generation: ctx.predecessorGeneration } } },
|
|
272
|
+
});
|
|
273
|
+
if (!launch.ok) {
|
|
274
|
+
const attention = launch.code === "successor_attention_required" ? " It is waiting at a login, trust or approval prompt." : "";
|
|
275
|
+
return abandon(`The ${target} successor didn't start: ${launch.message}.${attention}`);
|
|
276
|
+
}
|
|
277
|
+
const warnings = [...ctx.plan.warnings, ...(launch.notes ?? [])];
|
|
278
|
+
// 2. The handover, as the successor's first turn; the confirmation it asks for is the evidence it can carry on.
|
|
279
|
+
const queue = db.prepare(`SELECT qitem_id, state, priority, source_session FROM queue_items WHERE destination_session = ?
|
|
280
|
+
AND state IN ('pending', 'in-progress', 'blocked') ORDER BY ts_created, qitem_id`).all(sessionName);
|
|
281
|
+
const packet = [
|
|
282
|
+
`You are ${ctx.seatRef}'s successor on ${target}, staged for runtime switch ${id}. The ${node.runtime} occupant still holds the seat: until OpenRig tells you the switch committed, don't act as the seat (queue changes and sends are refused).`,
|
|
283
|
+
materials.firstTurn,
|
|
284
|
+
buildRestorePacket({ seatRef: ctx.seatRef, reason: ctx.input.reason, departingSession: sessionName, handoverAt: stamp(), capturedContext: screen ?? "",
|
|
285
|
+
...(recap && "recap" in recap ? recap : { recapUnavailableReason: recap?.unavailableReason ?? "no provider recap available" }),
|
|
286
|
+
...(authored ? ("address" in authored ? { authoredRecap: authored } : { authoredRecapAbsentReason: authored.absentReason }) : {}) }),
|
|
287
|
+
`The seat's open queue work (${queue.length} rows; its claims become yours at commit):`,
|
|
288
|
+
...queue.slice(0, 100).map((item) => `- ${item.qitem_id}: ${item.state}, ${item.priority}, from ${item.source_session}`),
|
|
289
|
+
[
|
|
290
|
+
"When you've read this handover and can carry on the seat's work, confirm it, saying what you'll do first:",
|
|
291
|
+
` rig seat set-runtime ${ctx.seatRef} --confirm ${id} --note "<what you'll do first>"`,
|
|
292
|
+
"Then wait for OpenRig's activation message. If you can't carry on (an unusable model, a login or permission problem), don't confirm; the switch then stops and the current occupant keeps the seat.",
|
|
293
|
+
].join("\n"),
|
|
294
|
+
].filter(Boolean).join("\n\n");
|
|
295
|
+
const typed = await tmux.sendText(row.staging_session, packet);
|
|
296
|
+
if (!typed.ok)
|
|
297
|
+
return abandon(`The handover couldn't be typed to the successor: ${typed.message}.`);
|
|
298
|
+
await this.sleep(200);
|
|
299
|
+
const entered = await tmux.sendKeys(row.staging_session, ["Enter"]);
|
|
300
|
+
if (!entered.ok)
|
|
301
|
+
return abandon(`The handover couldn't be submitted to the successor: ${entered.message}.`);
|
|
302
|
+
// 3. Wait for the confirmation (P2's evidence), bounded.
|
|
303
|
+
const timeoutMs = confirmTimeoutMs;
|
|
304
|
+
const pollMs = this.deps.confirmPollMs ?? 1000;
|
|
305
|
+
const deadline = this.now().getTime() + timeoutMs;
|
|
306
|
+
let confirmation = null;
|
|
307
|
+
while (!confirmation) {
|
|
308
|
+
const current = db.prepare("SELECT phase, confirmation_note, confirmed_at FROM seat_runtime_switches WHERE id = ?").get(id);
|
|
309
|
+
if (current.phase === "confirmed" && current.confirmation_note && current.confirmed_at) {
|
|
310
|
+
confirmation = { note: current.confirmation_note, at: current.confirmed_at };
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
if (this.now().getTime() >= deadline) {
|
|
314
|
+
const tail = successorPane ? (await tmux.capturePaneScreen(successorPane).catch(() => null))?.trim().split("\n").slice(-6).join("\n") : null;
|
|
315
|
+
return abandon(`The ${target} successor didn't confirm the handover within ${Math.round(timeoutMs / 1000)} s, so it isn't shown able to carry on.${tail ? ` Its screen ended with:\n${tail}` : ""}`);
|
|
316
|
+
}
|
|
317
|
+
const probe = await tmux.probeSession(row.staging_session).catch(() => ({ state: "unknown" }));
|
|
318
|
+
if (probe.state === "absent")
|
|
319
|
+
return abandon(`The ${target} successor's session ended before it confirmed the handover.`);
|
|
320
|
+
await this.sleep(pollMs);
|
|
321
|
+
}
|
|
322
|
+
// 4. The exchange, then the commit. A pane exchange the commit doesn't follow is undone (by the same exchange).
|
|
323
|
+
const swapped = await tmux.swapRuntimeSwitchPanes({ nodeId: node.id, stagingSession: row.staging_session, canonicalSession: sessionName,
|
|
324
|
+
canonicalPane: ctx.predecessorPane, stagedPane: successorPane });
|
|
325
|
+
if (!swapped.ok)
|
|
326
|
+
return abandon(`The panes couldn't be exchanged: ${swapped.message}.`);
|
|
327
|
+
let committed;
|
|
328
|
+
try {
|
|
329
|
+
committed = this.commit({ ...ctx, id, successorGeneration, successorPane: successorPane, appliedLaunch: launch.appliedLaunch,
|
|
330
|
+
launchResume: launch.resumeToken ? { type: launch.resumeType, token: launch.resumeToken } : null });
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
const back = await tmux.swapRuntimeSwitchPanes({ nodeId: node.id, stagingSession: row.staging_session, canonicalSession: sessionName,
|
|
334
|
+
canonicalPane: successorPane, stagedPane: ctx.predecessorPane });
|
|
335
|
+
if (!back.ok) {
|
|
336
|
+
db.prepare("UPDATE seat_runtime_switches SET attention = ?, updated_at = ? WHERE id = ?")
|
|
337
|
+
.run(`The commit failed (${error.message}) and the panes couldn't be exchanged back: ${back.message}`, stamp(), id);
|
|
338
|
+
return { ...failed(`The commit failed (${error.message}), and the panes couldn't be put back (${back.message}).`, `The ${node.runtime} occupant still holds ${ctx.seatRef} by record. Recover with rig seat set-runtime ${ctx.seatRef} --recover.`), switchId: id };
|
|
339
|
+
}
|
|
340
|
+
return abandon(`The commit failed: ${error.message}.`);
|
|
341
|
+
}
|
|
342
|
+
tmux.deliveryGuard?.rebindLifecycle(node.id);
|
|
343
|
+
for (const step of committed.afterCommit) {
|
|
344
|
+
try {
|
|
345
|
+
step();
|
|
346
|
+
}
|
|
347
|
+
catch { /* the committed record is authoritative */ }
|
|
348
|
+
}
|
|
349
|
+
try {
|
|
350
|
+
this.deps.activityOracle?.declareOccupantSwap(node.id, successorGeneration);
|
|
351
|
+
}
|
|
352
|
+
catch { /* the committed record is authoritative */ }
|
|
353
|
+
for (const event of [...committed.notifications, committed.event])
|
|
354
|
+
this.deps.eventBus.notifySubscribers(event);
|
|
355
|
+
// 5. Retire the predecessor and tell the successor it holds the seat. A failure here leaves the switch committed.
|
|
356
|
+
const finished = await this.finishCommitted({ id, node_id: node.id, canonical_session: sessionName, staging_session: row.staging_session,
|
|
357
|
+
to_runtime: target, from_runtime: node.runtime, successor_generation: successorGeneration });
|
|
358
|
+
return { ok: true, dryRun: false, changed: true, ...ctx.plan, switchId: id, generation: successorGeneration, previousGeneration: ctx.predecessorGeneration,
|
|
359
|
+
claimsMoved: committed.claimsMoved, openRows: queue.length, confirmation, recoveryPending: !finished.ok,
|
|
360
|
+
warnings: finished.ok ? warnings : [...warnings, `The switch committed, but ${finished.message} Finish it with rig seat set-runtime ${ctx.seatRef} --recover.`] };
|
|
361
|
+
}
|
|
362
|
+
commit(ctx) {
|
|
363
|
+
const { db, rigRepo, sessionRegistry, eventBus } = this.deps;
|
|
364
|
+
const { node, materials, target } = ctx;
|
|
365
|
+
const notifications = [];
|
|
366
|
+
const afterCommit = [];
|
|
367
|
+
let claimsMoved = 0;
|
|
368
|
+
const event = db.transaction(() => {
|
|
369
|
+
// The seat must be exactly as the switch found it.
|
|
370
|
+
const binding = sessionRegistry.getBindingForNode(node.id);
|
|
371
|
+
if (binding?.tmuxSession !== ctx.sessionName || binding.tmuxPane !== ctx.predecessorPane
|
|
372
|
+
|| sessionRegistry.currentOccupantTenure(node.id)?.generationUuid !== ctx.predecessorGeneration
|
|
373
|
+
|| db.prepare("SELECT runtime FROM nodes WHERE id = ?").get(node.id)?.runtime !== node.runtime) {
|
|
374
|
+
throw new Error("the seat's binding, occupant or runtime changed during the switch");
|
|
375
|
+
}
|
|
376
|
+
const at = this.now().toISOString();
|
|
377
|
+
const spec = materials.resolvedSpec;
|
|
378
|
+
db.prepare(`UPDATE nodes SET runtime = ?, model = ?, effort = ?, effort_choice = NULL, advisor = ?, codex_config_profile = ?,
|
|
379
|
+
${spec ? "resolved_spec_name = ?, resolved_spec_version = ?, resolved_spec_hash = ?, restore_policy = ?," : ""}
|
|
380
|
+
occupant_lifecycle = 'active', continuity_outcome = 'fresh', handover_result = 'complete', previous_occupant = ?, handover_at = ? WHERE id = ?`)
|
|
381
|
+
.run(target, materials.settings.model.value, materials.settings.effort.value, materials.settings.advisor.value, materials.settings.codexConfigProfile.value, ...(spec ? [spec.name, spec.version, spec.hash, spec.restorePolicy] : []), ctx.sessionName, at, node.id);
|
|
382
|
+
new NativePermissionStore(db).write(node.id, ctx.selection, ctx.input.requestedBy?.trim() || ctx.sessionName, ctx.input.reason);
|
|
383
|
+
db.prepare(`INSERT OR REPLACE INTO node_startup_context (node_id, projection_entries_json, resolved_files_json, startup_actions_json, runtime) VALUES (?, ?, ?, ?, ?)`)
|
|
384
|
+
.run(node.id, JSON.stringify(materials.plan.entries.map((e) => ({ category: e.category, effectiveId: e.effectiveId, sourceSpec: e.sourceSpec, sourcePath: e.sourcePath,
|
|
385
|
+
resourcePath: e.resourcePath, absolutePath: e.absolutePath, resourceType: e.resourceType, mergeStrategy: e.mergeStrategy, target: e.target }))), JSON.stringify(materials.files), JSON.stringify(materials.actions), target);
|
|
386
|
+
db.prepare("UPDATE sessions SET status = 'superseded' WHERE node_id = ? AND status NOT IN ('superseded', 'detached', 'exited')").run(node.id);
|
|
387
|
+
db.prepare("UPDATE bindings SET tmux_pane = ?, tmux_window = NULL, updated_at = datetime('now') WHERE node_id = ?").run(ctx.successorPane, node.id);
|
|
388
|
+
const successor = sessionRegistry.registerClaimedSession(node.id, ctx.sessionName, "handover", ctx.successorGeneration);
|
|
389
|
+
if (sessionRegistry.currentOccupantTenure(node.id)?.generationUuid !== ctx.successorGeneration)
|
|
390
|
+
throw new Error("the successor's generation couldn't be recorded");
|
|
391
|
+
db.prepare("UPDATE sessions SET origin = 'launched', restore_policy = ? WHERE id = ?").run(ctx.restorePolicy, successor.id);
|
|
392
|
+
const hooked = db.prepare("SELECT successor_resume_token FROM seat_runtime_switches WHERE id = ?").get(ctx.id);
|
|
393
|
+
const nativeId = hooked.successor_resume_token ?? ctx.launchResume?.token;
|
|
394
|
+
if (nativeId) {
|
|
395
|
+
const token = validateResumeToken(target, nativeId);
|
|
396
|
+
if (token.ok)
|
|
397
|
+
sessionRegistry.updateResumeToken(successor.id, token.resumeType, token.token, hooked.successor_resume_token ? "hook" : "scrape");
|
|
398
|
+
}
|
|
399
|
+
const observations = new AppliedLaunchObservationStore(db);
|
|
400
|
+
observations.invalidateGeneration(ctx.predecessorGeneration);
|
|
401
|
+
if (ctx.appliedLaunch)
|
|
402
|
+
observations.recordGeneration(ctx.successorGeneration, ctx.appliedLaunch);
|
|
403
|
+
// The claims stay with the seat: moved to the successor before ordinary invalidation could release them.
|
|
404
|
+
claimsMoved = this.deps.queueRepo?.transferClaimsByGeneration(ctx.predecessorGeneration, ctx.successorGeneration, `moved: the seat's runtime switch ${ctx.id} (${node.runtime} → ${target}) committed; the claim is the successor's`) ?? 0;
|
|
405
|
+
this.deps.occupantInvalidator?.invalidateRetiringOccupant({ retiringSessionName: ctx.sessionName, successorSessionName: ctx.sessionName,
|
|
406
|
+
retiringGeneration: ctx.predecessorGeneration });
|
|
407
|
+
db.prepare("UPDATE discovered_sessions SET status = 'vanished', claimed_node_id = NULL WHERE claimed_node_id = ?").run(node.id);
|
|
408
|
+
const discovered = this.deps.discoveryRepo.upsertDiscoveredSession({ tmuxSession: ctx.sessionName, tmuxPane: ctx.successorPane, cwd: node.cwd,
|
|
409
|
+
runtimeHint: target, confidence: "high" });
|
|
410
|
+
this.deps.discoveryRepo.markClaimed(discovered.id, node.id);
|
|
411
|
+
db.prepare(`UPDATE seat_runtime_switches SET phase = 'committed', committed_at = ?, updated_at = ? WHERE id = ? AND phase = 'confirmed'`).run(at, at, ctx.id);
|
|
412
|
+
if (db.prepare("SELECT committed_at FROM seat_runtime_switches WHERE id = ?").get(ctx.id).committed_at !== at) {
|
|
413
|
+
throw new Error("the switch record changed during the commit");
|
|
414
|
+
}
|
|
415
|
+
// The newest default restore describes the committed target, even if the daemon stops right after this.
|
|
416
|
+
new SnapshotCapture({ db, rigRepo, sessionRegistry, eventBus, snapshotRepo: new SnapshotRepository(db), checkpointStore: new CheckpointStore(db) })
|
|
417
|
+
.captureSnapshot(node.rigId, "runtime-switch", { deferNotify: (persisted) => notifications.push(persisted) });
|
|
418
|
+
return eventBus.persistWithinTransaction({ type: "seat.runtime_changed", rigId: node.rigId, nodeId: node.id, switchId: ctx.id, from: node.runtime, to: target,
|
|
419
|
+
reason: ctx.input.reason, requestedBy: ctx.input.requestedBy ?? null, generation: ctx.successorGeneration, previousGeneration: ctx.predecessorGeneration,
|
|
420
|
+
settings: { ...materials.settings }, dropped: ctx.plan.dropped, permissionSelection: ctx.selection ? ctx.selection.mode : "inherit", claimsMoved });
|
|
421
|
+
})();
|
|
422
|
+
return { event, notifications, claimsMoved, afterCommit };
|
|
423
|
+
}
|
|
424
|
+
/** After the commit: retire the predecessor (in the staging session), carry the successor's runtime on the seat's
|
|
425
|
+
* session, and tell the successor it holds the seat. Idempotent enough for recovery to call again. */
|
|
426
|
+
async finishCommitted(row) {
|
|
427
|
+
const { db, tmuxAdapter: tmux } = this.deps;
|
|
428
|
+
const problems = [];
|
|
429
|
+
const retired = await this.retireStaging(row.staging_session, row.node_id, "Predecessor");
|
|
430
|
+
if (!retired.ok)
|
|
431
|
+
problems.push(`the ${row.from_runtime} predecessor couldn't be retired (${retired.message})`);
|
|
432
|
+
const env = await tmux.setRuntimeSwitchEnvironment(row.canonical_session, row.to_runtime, row.successor_generation);
|
|
433
|
+
if (!env.ok)
|
|
434
|
+
problems.push(`the seat's session environment couldn't be updated (${env.message})`);
|
|
435
|
+
tmux.finishLaunchBinding(row.staging_session);
|
|
436
|
+
if (retired.ok) {
|
|
437
|
+
const text = `OpenRig: runtime switch ${row.id} committed. You now hold ${row.canonical_session} on ${row.to_runtime}; the ${row.from_runtime} occupant has retired. Carry on from the handover: the seat's queue rows and claims are yours.`;
|
|
438
|
+
const typed = await tmux.sendText(row.canonical_session, text);
|
|
439
|
+
const entered = typed.ok ? (await this.sleep(200), await tmux.sendKeys(row.canonical_session, ["Enter"])) : typed;
|
|
440
|
+
if (!entered.ok)
|
|
441
|
+
problems.push(`the activation message couldn't be delivered (${entered.message})`);
|
|
442
|
+
}
|
|
443
|
+
const at = this.now().toISOString();
|
|
444
|
+
if (problems.length === 0) {
|
|
445
|
+
db.prepare("UPDATE seat_runtime_switches SET phase = 'finished', outcome = ?, attention = NULL, updated_at = ? WHERE id = ? AND committed_at IS NOT NULL")
|
|
446
|
+
.run(`committed: the seat runs ${row.to_runtime}; the ${row.from_runtime} predecessor retired`, at, row.id);
|
|
447
|
+
return { ok: true };
|
|
448
|
+
}
|
|
449
|
+
const message = `${problems.join("; ")}.`;
|
|
450
|
+
db.prepare("UPDATE seat_runtime_switches SET attention = ?, updated_at = ? WHERE id = ?").run(message, at, row.id);
|
|
451
|
+
return { ok: false, message };
|
|
452
|
+
}
|
|
453
|
+
/** Terminate and remove a staging session this switch created (holding either the uncommitted successor or, after the
|
|
454
|
+
* exchange, the predecessor). Requires the seat's lifecycle lease and the staging session's custody. */
|
|
455
|
+
async retireStaging(stagingSession, _nodeId, label) {
|
|
456
|
+
const tmux = this.deps.tmuxAdapter;
|
|
457
|
+
const probe = await tmux.probeSession(stagingSession).catch(() => ({ state: "unknown" }));
|
|
458
|
+
if (probe.state === "absent")
|
|
459
|
+
return { ok: true };
|
|
460
|
+
if (probe.state !== "present")
|
|
461
|
+
return { ok: false, message: "the staging session's presence couldn't be established" };
|
|
462
|
+
const terminated = await terminatePaneInPlace(tmux, stagingSession, { pollMs: 100, timeoutMs: 3000, sleep: this.sleep }, label);
|
|
463
|
+
if (!terminated.ok)
|
|
464
|
+
return { ok: false, message: terminated.message };
|
|
465
|
+
const removed = await tmux.killSession(stagingSession);
|
|
466
|
+
if (!removed.ok && removed.code !== "session_not_found")
|
|
467
|
+
return { ok: false, message: removed.message };
|
|
468
|
+
return { ok: true };
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Finish an interrupted switch from its durable record, under the seat's lifecycle lease. Before its commit the
|
|
472
|
+
* predecessor holds the seat: an exchanged pane is put back and the staged successor retired. After it the successor
|
|
473
|
+
* holds the seat: the predecessor is retired and the successor told; custody never goes back. Where the panes don't
|
|
474
|
+
* match the record, nothing is touched and the record says why (status shows it).
|
|
475
|
+
*/
|
|
476
|
+
async recover(nodeId) {
|
|
477
|
+
const guard = this.deps.tmuxAdapter.deliveryGuard;
|
|
478
|
+
if (guard && !guard.ownsLifecycle(nodeId)) {
|
|
479
|
+
try {
|
|
480
|
+
return await guard.lifecycle([nodeId], () => this.recover(nodeId));
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
return { ok: false, code: error.code ?? "runtime_switch_pending", message: error.message };
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const row = this.openSwitch(nodeId);
|
|
487
|
+
if (!row)
|
|
488
|
+
return { ok: true, outcome: "No runtime switch needs recovery.", switchId: null };
|
|
489
|
+
const { db, tmuxAdapter: tmux } = this.deps;
|
|
490
|
+
const at = () => this.now().toISOString();
|
|
491
|
+
const stuck = (message) => {
|
|
492
|
+
db.prepare("UPDATE seat_runtime_switches SET attention = ?, updated_at = ? WHERE id = ?").run(message, at(), row.id);
|
|
493
|
+
return { ok: false, code: "runtime_switch_pending", message, switchId: row.id };
|
|
494
|
+
};
|
|
495
|
+
let canonicalPane = null;
|
|
496
|
+
try {
|
|
497
|
+
const panes = await tmux.listPanes(row.canonical_session);
|
|
498
|
+
canonicalPane = panes.length === 1 ? panes[0].id : null;
|
|
499
|
+
}
|
|
500
|
+
catch { /* absent or unreadable: decided below */ }
|
|
501
|
+
const staging = await tmux.probeSession(row.staging_session).catch(() => ({ state: "unknown" }));
|
|
502
|
+
if (staging.state === "unknown")
|
|
503
|
+
return stuck("The staging session's presence couldn't be established; nothing was touched.");
|
|
504
|
+
let stagingPane = null;
|
|
505
|
+
if (staging.state === "present") {
|
|
506
|
+
const panes = await tmux.listPanes(row.staging_session).catch(() => []);
|
|
507
|
+
stagingPane = panes.length === 1 ? panes[0].id : null;
|
|
508
|
+
const adopted = stagingPane ? await tmux.adoptRuntimeSwitchStaging({ nodeId, stagingSession: row.staging_session, pane: stagingPane, generations: [row.successor_generation] })
|
|
509
|
+
: { ok: false, message: "it doesn't have exactly one pane" };
|
|
510
|
+
if (!adopted.ok)
|
|
511
|
+
return stuck(`The staging session ${row.staging_session} can't be taken back: ${adopted.message}`);
|
|
512
|
+
}
|
|
513
|
+
if (!row.committed_at) {
|
|
514
|
+
// Before commit: the predecessor holds the seat.
|
|
515
|
+
const exchanged = canonicalPane !== null && canonicalPane === row.successor_pane && stagingPane === row.predecessor_pane;
|
|
516
|
+
if (exchanged) {
|
|
517
|
+
const back = await tmux.swapRuntimeSwitchPanes({ nodeId, stagingSession: row.staging_session, canonicalSession: row.canonical_session,
|
|
518
|
+
canonicalPane: row.successor_pane, stagedPane: row.predecessor_pane });
|
|
519
|
+
if (!back.ok)
|
|
520
|
+
return stuck(`The panes couldn't be exchanged back: ${back.message}`);
|
|
521
|
+
}
|
|
522
|
+
else if (canonicalPane !== row.predecessor_pane) {
|
|
523
|
+
return stuck(`The seat's pane (${canonicalPane ?? "none"}) is neither the predecessor's nor the successor's; nothing was touched.`);
|
|
524
|
+
}
|
|
525
|
+
const retired = await this.retireStaging(row.staging_session, nodeId, "Uncommitted successor");
|
|
526
|
+
if (!retired.ok)
|
|
527
|
+
return stuck(`The staged successor couldn't be retired: ${retired.message}`);
|
|
528
|
+
tmux.finishLaunchBinding(row.staging_session);
|
|
529
|
+
// An abandoned switch keeps why it stopped; recovery only settles the successor it couldn't retire then.
|
|
530
|
+
const outcome = row.phase === "abandoned" ? `${row.outcome ?? "abandoned before commit"} The staged ${row.to_runtime} successor was retired at recovery.`
|
|
531
|
+
: `interrupted before commit: the ${row.from_runtime} occupant holds the seat; the staged ${row.to_runtime} successor was retired`;
|
|
532
|
+
db.prepare("UPDATE seat_runtime_switches SET phase = 'abandoned', outcome = ?, attention = NULL, updated_at = ? WHERE id = ?").run(outcome, at(), row.id);
|
|
533
|
+
return { ok: true, outcome, switchId: row.id };
|
|
534
|
+
}
|
|
535
|
+
// After commit: the successor holds the seat; finish forward.
|
|
536
|
+
if (canonicalPane !== row.successor_pane) {
|
|
537
|
+
return stuck(`The switch committed, but the seat's pane (${canonicalPane ?? "none"}) isn't the successor's; nothing was touched.`);
|
|
538
|
+
}
|
|
539
|
+
const finished = await this.finishCommitted(row);
|
|
540
|
+
if (!finished.ok)
|
|
541
|
+
return { ok: false, code: "runtime_switch_pending", message: finished.message, switchId: row.id };
|
|
542
|
+
return { ok: true, outcome: `committed: finished; the seat runs ${row.to_runtime}`, switchId: row.id };
|
|
543
|
+
}
|
|
544
|
+
/** Daemon start: finish every interrupted switch, including an abandoned one whose successor wasn't retired. Returns
|
|
545
|
+
* warnings for the ones that still need attention. */
|
|
546
|
+
async recoverAll() {
|
|
547
|
+
let rows = [];
|
|
548
|
+
try {
|
|
549
|
+
rows = this.deps.db.prepare(`SELECT DISTINCT node_id, canonical_session FROM seat_runtime_switches
|
|
550
|
+
WHERE phase IN ('preparing', 'confirmed', 'committed') OR attention IS NOT NULL`).all();
|
|
551
|
+
}
|
|
552
|
+
catch {
|
|
553
|
+
return [];
|
|
554
|
+
}
|
|
555
|
+
const warnings = [];
|
|
556
|
+
for (const row of rows) {
|
|
557
|
+
try {
|
|
558
|
+
const result = await this.recover(row.node_id);
|
|
559
|
+
if (!result.ok)
|
|
560
|
+
warnings.push(`${row.canonical_session}: ${result.message}`);
|
|
561
|
+
}
|
|
562
|
+
catch (error) {
|
|
563
|
+
warnings.push(`${row.canonical_session}: ${error.message}`);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return warnings;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
/** A switch of this seat that committed at or after `since` (a send that waited behind it says the seat moved). */
|
|
570
|
+
export function runtimeSwitchCommittedSince(db, session, since) {
|
|
571
|
+
try {
|
|
572
|
+
const row = db.prepare(`SELECT id, from_runtime, to_runtime, committed_at FROM seat_runtime_switches
|
|
573
|
+
WHERE canonical_session = ? AND committed_at >= ? ORDER BY committed_at DESC LIMIT 1`).get(session, since);
|
|
574
|
+
return row ? { id: row.id, from: row.from_runtime, to: row.to_runtime, committedAt: row.committed_at } : null;
|
|
575
|
+
}
|
|
576
|
+
catch {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
export function runtimeSwitchSummary(db, where) {
|
|
581
|
+
try {
|
|
582
|
+
const row = db.prepare(`SELECT id, phase, from_runtime, to_runtime, committed_at, created_at, deadline_at, attention, outcome FROM seat_runtime_switches
|
|
583
|
+
WHERE ${"nodeId" in where ? "node_id" : "canonical_session"} = ?
|
|
584
|
+
AND (phase IN ('preparing', 'confirmed', 'committed') OR attention IS NOT NULL)
|
|
585
|
+
ORDER BY created_at DESC LIMIT 1`).get("nodeId" in where ? where.nodeId : where.session);
|
|
586
|
+
return row ? { id: row.id, phase: row.phase, from: row.from_runtime, to: row.to_runtime, committed: !!row.committed_at, startedAt: row.created_at,
|
|
587
|
+
deadlineAt: row.deadline_at, attention: row.attention, outcome: row.outcome } : null;
|
|
588
|
+
}
|
|
589
|
+
catch {
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
//# sourceMappingURL=seat-runtime-switch-service.js.map
|