@caupulican/pi-adaptative 0.81.39 → 0.81.41
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/CHANGELOG.md +77 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +3 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +4 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +9 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +290 -107
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +357 -122
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +2 -2
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +31 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts +15 -0
- package/dist/core/agent-directory-layout.d.ts.map +1 -0
- package/dist/core/agent-directory-layout.js +72 -0
- package/dist/core/agent-directory-layout.js.map +1 -0
- package/dist/core/agent-paths.d.ts +25 -2
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +79 -4
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +293 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -0
- package/dist/core/agent-session-contracts.js +26 -0
- package/dist/core/agent-session-contracts.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +400 -79
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +74 -518
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +370 -1432
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +3 -2
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +6 -28
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +20 -12
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js +8 -25
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +8 -10
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
- package/dist/core/autonomy/lane-private-paths.js +16 -0
- package/dist/core/autonomy/lane-private-paths.js.map +1 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +48 -9
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +14 -0
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +38 -0
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts +1 -2
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/risk-assessment.js +1 -123
- package/dist/core/autonomy/risk-assessment.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +4 -4
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js +16 -29
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +7 -7
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +9 -9
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +56 -236
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +141 -1273
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts +16 -0
- package/dist/core/bedrock-sso-login.d.ts.map +1 -0
- package/dist/core/bedrock-sso-login.js +98 -0
- package/dist/core/bedrock-sso-login.js.map +1 -0
- package/dist/core/capability-contract.d.ts +4 -0
- package/dist/core/capability-contract.d.ts.map +1 -0
- package/dist/core/capability-contract.js +28 -0
- package/dist/core/capability-contract.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +90 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +452 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/compaction-support.d.ts +13 -17
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +3 -3
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -2
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +34 -2
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts +8 -2
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +158 -35
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +9 -11
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +6 -8
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts +3 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +10 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -1
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +16 -37
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +5 -3
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +4 -5
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +2 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
- package/dist/core/delegation/managed-lane-controller.js +217 -0
- package/dist/core/delegation/managed-lane-controller.js.map +1 -0
- package/dist/core/delegation/session-worker-claim.d.ts +44 -0
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-claim.js +98 -0
- package/dist/core/delegation/session-worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +7 -5
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +20 -4
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/{worker-result.d.ts → worker-claim.d.ts} +13 -13
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/{worker-result.js → worker-claim.js} +61 -51
- package/dist/core/delegation/worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.js +861 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
- package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-request.js +2 -0
- package/dist/core/delegation/worker-delegation-request.js.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
- package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-execution-policy.js +160 -0
- package/dist/core/delegation/worker-execution-policy.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
- package/dist/core/delegation/worker-lane-projection.js +100 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
- package/dist/core/delegation/worker-lifecycle.js +339 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.js +90 -0
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.js +113 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +25 -14
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +122 -53
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts +3 -0
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-label.js +11 -0
- package/dist/core/delegation/worker-task-label.js.map +1 -0
- package/dist/core/doctor.d.ts +8 -0
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +32 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts +6 -0
- package/dist/core/extension-import-authority.d.ts.map +1 -0
- package/dist/core/extension-import-authority.js +10 -0
- package/dist/core/extension-import-authority.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +52 -18
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +20 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +2 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +2 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/storage.d.ts +8 -0
- package/dist/core/extensions/storage.d.ts.map +1 -0
- package/dist/core/extensions/storage.js +28 -0
- package/dist/core/extensions/storage.js.map +1 -0
- package/dist/core/extensions/types.d.ts +78 -21
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +1 -15
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +9 -37
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +53 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
- package/dist/core/foreground-recovery-controller.js +111 -0
- package/dist/core/foreground-recovery-controller.js.map +1 -0
- package/dist/core/gateways/channel-provider.d.ts +3 -0
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +31 -6
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +14 -9
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +47 -75
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +11 -0
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -0
- package/dist/core/goals/compact-goal-context.js +59 -0
- package/dist/core/goals/compact-goal-context.js.map +1 -0
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +27 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +28 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +90 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +2 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +52 -11
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +4 -29
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +4 -32
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +8 -18
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +9 -179
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +43 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +102 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-record.d.ts +17 -0
- package/dist/core/goals/goal-record.d.ts.map +1 -0
- package/dist/core/goals/goal-record.js +31 -0
- package/dist/core/goals/goal-record.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +11 -9
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +10 -8
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +42 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-session-controller.js +128 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -0
- package/dist/core/goals/goal-state.d.ts +46 -25
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +91 -24
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +9 -10
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +60 -75
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +20 -12
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +133 -33
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input-controller.d.ts +47 -0
- package/dist/core/human-input-controller.d.ts.map +1 -0
- package/dist/core/human-input-controller.js +181 -0
- package/dist/core/human-input-controller.js.map +1 -0
- package/dist/core/human-input.d.ts +100 -0
- package/dist/core/human-input.d.ts.map +1 -0
- package/dist/core/human-input.js +362 -0
- package/dist/core/human-input.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -0
- package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
- package/dist/core/install-telemetry.js.map +1 -0
- package/dist/core/keybindings.d.ts +17 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +24 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +2 -4
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +9 -29
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js +1 -6
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +2 -4
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js +9 -29
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +1 -1
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +4 -4
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +0 -19
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +1 -19
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -5
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +17 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +38 -25
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +1 -4
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +1 -156
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -1
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +2 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +5 -5
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +23 -0
- package/dist/core/model-tool-protocol.d.ts.map +1 -0
- package/dist/core/model-tool-protocol.js +43 -0
- package/dist/core/model-tool-protocol.js.map +1 -0
- package/dist/core/models/adaptation-store.d.ts +4 -6
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +95 -83
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +2 -12
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +84 -57
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts +34 -0
- package/dist/core/models/host-state-store.d.ts.map +1 -0
- package/dist/core/models/host-state-store.js +86 -0
- package/dist/core/models/host-state-store.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +24 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
- package/dist/core/orchestration/agent-resume.js +90 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +61 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
- package/dist/core/orchestration/capability-gateway.js +152 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -0
- package/dist/core/orchestration/contracts.d.ts +343 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -0
- package/dist/core/orchestration/contracts.js +135 -0
- package/dist/core/orchestration/contracts.js.map +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/delegation-ledger.js +200 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -0
- package/dist/core/orchestration/event-store.d.ts +83 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -0
- package/dist/core/orchestration/event-store.js +560 -0
- package/dist/core/orchestration/event-store.js.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.js +37 -0
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
- package/dist/core/orchestration/model-binding.d.ts +15 -0
- package/dist/core/orchestration/model-binding.d.ts.map +1 -0
- package/dist/core/orchestration/model-binding.js +29 -0
- package/dist/core/orchestration/model-binding.js.map +1 -0
- package/dist/core/orchestration/policy-compiler.d.ts +49 -0
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
- package/dist/core/orchestration/policy-compiler.js +191 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -0
- package/dist/core/orchestration/policy-gate.d.ts +18 -0
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
- package/dist/core/orchestration/policy-gate.js +24 -0
- package/dist/core/orchestration/policy-gate.js.map +1 -0
- package/dist/core/orchestration/profile-registry.d.ts +51 -0
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
- package/dist/core/orchestration/profile-registry.js +393 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -0
- package/dist/core/orchestration/profile-store.d.ts +31 -0
- package/dist/core/orchestration/profile-store.d.ts.map +1 -0
- package/dist/core/orchestration/profile-store.js +136 -0
- package/dist/core/orchestration/profile-store.js.map +1 -0
- package/dist/core/orchestration/risk-budget.d.ts +9 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
- package/dist/core/orchestration/risk-budget.js +48 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +168 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime.js +1600 -0
- package/dist/core/orchestration/task-runtime.js.map +1 -0
- package/dist/core/orchestration/work-state-projection.d.ts +32 -0
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
- package/dist/core/orchestration/work-state-projection.js +116 -0
- package/dist/core/orchestration/work-state-projection.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.js +179 -0
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.js +109 -0
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +20 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts +11 -0
- package/dist/core/process-identity.d.ts.map +1 -0
- package/dist/core/process-identity.js +26 -0
- package/dist/core/process-identity.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts +14 -3
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/codes.js.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
- package/dist/core/process-matrix/resume-launcher.js +62 -0
- package/dist/core/process-matrix/resume-launcher.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +37 -22
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +399 -76
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts +5 -2
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js +123 -14
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts +10 -7
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js +45 -14
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts +8 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +23 -5
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +6 -8
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -29
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +5 -5
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +5 -2
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +6 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts +7 -0
- package/dist/core/request-auth.d.ts.map +1 -0
- package/dist/core/request-auth.js +8 -0
- package/dist/core/request-auth.js.map +1 -0
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +1 -6
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts +33 -0
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
- package/dist/core/research/lane-model-resolver.js +65 -0
- package/dist/core/research/lane-model-resolver.js.map +1 -0
- package/dist/core/research/model-fitness-controller.d.ts +38 -0
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
- package/dist/core/research/model-fitness-controller.js +106 -0
- package/dist/core/research/model-fitness-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -4
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js +7 -7
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +62 -0
- package/dist/core/research/research-lane-controller.d.ts.map +1 -0
- package/dist/core/research/research-lane-controller.js +292 -0
- package/dist/core/research/research-lane-controller.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +2 -4
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js +10 -46
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +23 -8
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts +6 -0
- package/dist/core/risk-classifier.d.ts.map +1 -0
- package/dist/core/risk-classifier.js +233 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +41 -23
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +365 -253
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +68 -25
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts +9 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.js +241 -0
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +27 -0
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -0
- package/dist/core/secrets/secret-dotenv.js +183 -0
- package/dist/core/secrets/secret-dotenv.js.map +1 -0
- package/dist/core/secrets/secret-vault-format.d.ts +112 -0
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault-format.js +397 -0
- package/dist/core/secrets/secret-vault-format.js.map +1 -0
- package/dist/core/secrets/secret-vault.d.ts +72 -0
- package/dist/core/secrets/secret-vault.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault.js +671 -0
- package/dist/core/secrets/secret-vault.js.map +1 -0
- package/dist/core/session-analytics.d.ts +4 -23
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +67 -70
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-image-store.d.ts +33 -0
- package/dist/core/session-image-store.d.ts.map +1 -0
- package/dist/core/session-image-store.js +283 -0
- package/dist/core/session-image-store.js.map +1 -0
- package/dist/core/session-role.d.ts +11 -4
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +24 -5
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts +34 -0
- package/dist/core/session-snapshot.d.ts.map +1 -0
- package/dist/core/session-snapshot.js +68 -0
- package/dist/core/session-snapshot.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +31 -0
- package/dist/core/session-supervision-runtime.d.ts.map +1 -0
- package/dist/core/session-supervision-runtime.js +97 -0
- package/dist/core/session-supervision-runtime.js.map +1 -0
- package/dist/core/session-tree-navigator.d.ts +4 -6
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +4 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +81 -29
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +2 -4
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +10 -28
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts +20 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -0
- package/dist/core/tasks/task-projection.js +47 -0
- package/dist/core/tasks/task-projection.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +4 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +28 -11
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -0
- package/dist/core/tool-capability-policy.js +86 -0
- package/dist/core/tool-capability-policy.js.map +1 -0
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +8 -2
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +89 -0
- package/dist/core/tool-protocol-controller.d.ts.map +1 -0
- package/dist/core/tool-protocol-controller.js +512 -0
- package/dist/core/tool-protocol-controller.js.map +1 -0
- package/dist/core/tool-recovery-log-records.d.ts +2 -3
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +9 -35
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts +21 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +3 -7
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +97 -138
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +124 -0
- package/dist/core/tools/ask-question.d.ts.map +1 -0
- package/dist/core/tools/ask-question.js +693 -0
- package/dist/core/tools/ask-question.js.map +1 -0
- package/dist/core/tools/bash.d.ts +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +59 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +31 -3
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +148 -29
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +15 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +106 -23
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +1 -0
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -8
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +2 -63
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts +10 -8
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +106 -28
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +2 -2
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +40 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +124 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +36 -3
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +3 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +26 -0
- package/dist/core/tools/run-process.d.ts.map +1 -0
- package/dist/core/tools/run-process.js +138 -0
- package/dist/core/tools/run-process.js.map +1 -0
- package/dist/core/tools/search-command-guard.d.ts +14 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -0
- package/dist/core/tools/search-command-guard.js +333 -0
- package/dist/core/tools/search-command-guard.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts +38 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -0
- package/dist/core/tools/secret-store.js +412 -0
- package/dist/core/tools/secret-store.js.map +1 -0
- package/dist/core/tools/shell-command-parser.d.ts +16 -0
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -0
- package/dist/core/tools/shell-command-parser.js +113 -0
- package/dist/core/tools/shell-command-parser.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +2 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +99 -0
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +3 -5
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +4 -4
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +4 -6
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +6 -2
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +4 -4
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts +10 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
- package/dist/core/util/bounded-jsonl.js +75 -0
- package/dist/core/util/bounded-jsonl.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +5 -0
- package/dist/core/util/value-guards.d.ts.map +1 -0
- package/dist/core/util/value-guards.js +12 -0
- package/dist/core/util/value-guards.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +3 -3
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js +10 -5
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +149 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +4 -6
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +186 -28
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +4 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +60 -1
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +7 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +44 -6
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +55 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -0
- package/dist/modes/interactive/components/activity-lane.js +304 -0
- package/dist/modes/interactive/components/activity-lane.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +19 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/expandable-text.d.ts +12 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-text.js +17 -0
- package/dist/modes/interactive/components/expandable-text.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +15 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +30 -21
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +23 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +6 -6
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +19 -11
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +53 -20
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +3 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts +16 -0
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/usage-action-selector.js +46 -0
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -0
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js +5 -4
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +77 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +15 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +27 -19
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts +6 -2
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js +10 -5
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +74 -0
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-event-controller.js +328 -0
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +22 -24
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +245 -595
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -1
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts +20 -0
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -0
- package/dist/modes/interactive/loaded-resources-view.js +147 -0
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +7 -7
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +21 -0
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js +8 -2
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts +1 -5
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +0 -5
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +27 -8
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +150 -64
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js +16 -6
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
- package/dist/modes/interactive/session-replacement-errors.js +15 -0
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +1 -1
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts +34 -0
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -0
- package/dist/modes/interactive/usage-commands.js +225 -0
- package/dist/modes/interactive/usage-commands.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +82 -23
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +138 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -13
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +52 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +8 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +5 -3
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/work-directory.d.ts +11 -0
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js +30 -9
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +38 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +28 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +62 -2
- package/docs/harness-architecture.md +156 -0
- package/docs/keybindings.md +11 -1
- package/docs/process-matrix.md +59 -26
- package/docs/providers.md +9 -1
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +125 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +10 -3
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +14 -0
- package/docs/ui-reference/orchestration-before.txt +13 -0
- package/docs/ui-reference/orchestration-reference.txt +16 -0
- package/docs/usage.md +22 -2
- package/docs/work-directory.md +19 -8
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/question.ts +34 -245
- package/examples/extensions/questionnaire.ts +41 -407
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +13 -13
- package/package.json +4 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -46
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -113
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js.map +0 -1
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js.map +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { buildLaneToolManifests } from "../orchestration/lane-tool-manifests.js";
|
|
3
|
+
import { ExecutionPolicyCompiler } from "../orchestration/policy-compiler.js";
|
|
4
|
+
import { intersectRiskBudgets } from "../orchestration/risk-budget.js";
|
|
5
|
+
import { getToolCapabilityPolicy } from "../tool-capability-policy.js";
|
|
6
|
+
const READ_TOOL_NAMES = ["read", "grep", "find", "ls"];
|
|
7
|
+
const WRITE_TOOL_NAMES = ["write", "edit"];
|
|
8
|
+
function pathContains(scope, candidate) {
|
|
9
|
+
const relative = path.relative(scope, candidate);
|
|
10
|
+
return relative === "" || (!relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative));
|
|
11
|
+
}
|
|
12
|
+
function intersectPathScopes(admittedPaths, currentPaths) {
|
|
13
|
+
const intersections = admittedPaths.flatMap((admitted) => currentPaths.flatMap((current) => {
|
|
14
|
+
if (pathContains(admitted, current))
|
|
15
|
+
return [current];
|
|
16
|
+
if (pathContains(current, admitted))
|
|
17
|
+
return [admitted];
|
|
18
|
+
return [];
|
|
19
|
+
}));
|
|
20
|
+
return [...new Set(intersections.map((entry) => path.resolve(entry)))];
|
|
21
|
+
}
|
|
22
|
+
export function workerExecutionAuthorityFromPlan(plan) {
|
|
23
|
+
return {
|
|
24
|
+
capabilities: [...plan.requiredCapabilities],
|
|
25
|
+
toolNames: plan.toolManifests.map((manifest) => manifest.toolName),
|
|
26
|
+
readPaths: [...plan.readPaths],
|
|
27
|
+
writePaths: [...plan.writePaths],
|
|
28
|
+
deniedPaths: [...plan.deniedPaths],
|
|
29
|
+
budget: { ...plan.budget },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Apply live revocations to admitted authority without allowing later settings to widen it. */
|
|
33
|
+
export function narrowWorkerExecutionPlan(admitted, current) {
|
|
34
|
+
const admittedTools = new Set(admitted.toolNames);
|
|
35
|
+
const admittedCapabilities = new Set(admitted.capabilities);
|
|
36
|
+
const toolManifests = current.toolManifests.filter((manifest) => admittedTools.has(manifest.toolName) &&
|
|
37
|
+
manifest.capabilities.every((capability) => admittedCapabilities.has(capability)));
|
|
38
|
+
const requiredCapabilities = [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))];
|
|
39
|
+
const grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));
|
|
40
|
+
const readEnabled = requiredCapabilities.some((capability) => capability === "filesystem.read" || capability === "worktree.read");
|
|
41
|
+
const writeEnabled = grantedTools.has("write") || grantedTools.has("edit");
|
|
42
|
+
return {
|
|
43
|
+
toolManifests,
|
|
44
|
+
requiredCapabilities,
|
|
45
|
+
readPaths: readEnabled ? intersectPathScopes(admitted.readPaths, current.readPaths) : [],
|
|
46
|
+
writePaths: writeEnabled ? intersectPathScopes(admitted.writePaths, current.writePaths) : [],
|
|
47
|
+
deniedPaths: [...new Set([...admitted.deniedPaths, ...current.deniedPaths].map((entry) => path.resolve(entry)))],
|
|
48
|
+
readMemory: grantedTools.has("memory"),
|
|
49
|
+
writeEnabled,
|
|
50
|
+
processEnabled: grantedTools.has("run_process"),
|
|
51
|
+
budget: intersectRiskBudgets(admitted.budget, current.budget),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function buildWorkerExecutionPlan(args) {
|
|
55
|
+
const grantsRead = args.profile.capabilityCeiling.includes("filesystem.read") ||
|
|
56
|
+
args.profile.capabilityCeiling.includes("worktree.read");
|
|
57
|
+
const writeEligible = args.settings.writeEnabled &&
|
|
58
|
+
args.settings.writePaths.length > 0 &&
|
|
59
|
+
(args.profile.capabilityCeiling.includes("filesystem.write") ||
|
|
60
|
+
args.profile.capabilityCeiling.includes("worktree.mutate"));
|
|
61
|
+
const memoryEligible = args.memoryEnabled &&
|
|
62
|
+
args.profile.toolNames.includes("memory") &&
|
|
63
|
+
args.profile.capabilityCeiling.includes("memory.query");
|
|
64
|
+
const processEligible = args.profile.executionPolicy !== undefined &&
|
|
65
|
+
(args.profile.capabilityCeiling.includes("process.exec") ||
|
|
66
|
+
args.profile.capabilityCeiling.includes("tests.execute"));
|
|
67
|
+
const enabledToolNames = [
|
|
68
|
+
...(grantsRead ? READ_TOOL_NAMES : []),
|
|
69
|
+
...(writeEligible ? WRITE_TOOL_NAMES : []),
|
|
70
|
+
...(memoryEligible ? ["memory"] : []),
|
|
71
|
+
...(processEligible ? ["run_process"] : []),
|
|
72
|
+
];
|
|
73
|
+
const toolManifests = buildLaneToolManifests(args.profile, enabledToolNames);
|
|
74
|
+
const grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));
|
|
75
|
+
const readEnabled = toolManifests.some((manifest) => manifest.capabilities.some((capability) => capability === "filesystem.read" || capability === "worktree.read"));
|
|
76
|
+
const writeEnabled = grantedTools.has("write") || grantedTools.has("edit");
|
|
77
|
+
const readMemory = grantedTools.has("memory");
|
|
78
|
+
const processEnabled = grantedTools.has("run_process");
|
|
79
|
+
const budget = intersectRiskBudgets(args.profile.budget, ...(args.settings.maxUsd > 0 ? [{ maxCostUsd: args.settings.maxUsd }] : []), ...(args.foregroundMaxCostUsd !== undefined ? [{ maxCostUsd: args.foregroundMaxCostUsd }] : []), ...(args.settings.maxWallClockMs > 0 ? [{ maxWallClockMs: args.settings.maxWallClockMs }] : []));
|
|
80
|
+
return {
|
|
81
|
+
toolManifests,
|
|
82
|
+
requiredCapabilities: [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))],
|
|
83
|
+
readPaths: readEnabled ? [path.resolve(args.cwd)] : [],
|
|
84
|
+
writePaths: writeEnabled
|
|
85
|
+
? args.settings.writePaths.map((entry) => path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(args.cwd, entry))
|
|
86
|
+
: [],
|
|
87
|
+
deniedPaths: args.deniedPaths.map((entry) => path.resolve(entry)),
|
|
88
|
+
readMemory,
|
|
89
|
+
writeEnabled,
|
|
90
|
+
processEnabled,
|
|
91
|
+
budget: { ...budget, maxToolCalls: budget.maxToolCalls ?? 6 },
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function compileWorkerExecutionGrant(args) {
|
|
95
|
+
const compiled = new ExecutionPolicyCompiler().compile({
|
|
96
|
+
objectiveId: args.target.objectiveId,
|
|
97
|
+
taskId: args.target.taskId,
|
|
98
|
+
attemptId: args.target.attemptId,
|
|
99
|
+
subjectId: `in-process:${args.target.attemptId}`,
|
|
100
|
+
role: args.profile.role,
|
|
101
|
+
requiredCapabilities: args.plan.requiredCapabilities,
|
|
102
|
+
requestedCapabilities: args.plan.requiredCapabilities,
|
|
103
|
+
authorityCapabilities: args.profile.capabilityCeiling,
|
|
104
|
+
requestedTools: args.plan.toolManifests.map((manifest) => manifest.toolName),
|
|
105
|
+
toolManifests: args.plan.toolManifests,
|
|
106
|
+
readPaths: args.plan.readPaths,
|
|
107
|
+
writePaths: args.plan.writePaths,
|
|
108
|
+
deniedPaths: args.plan.deniedPaths,
|
|
109
|
+
requestedBudget: args.plan.budget,
|
|
110
|
+
authorityBudget: args.plan.budget,
|
|
111
|
+
policyVersion: "worker-profile-v1",
|
|
112
|
+
});
|
|
113
|
+
if (compiled.outcome !== "allow")
|
|
114
|
+
return { ok: false, reasonCodes: compiled.reasonCodes };
|
|
115
|
+
return { ok: true, grant: compiled.grant };
|
|
116
|
+
}
|
|
117
|
+
/** Compile the host's durable authority record before an externally managed process is launched. */
|
|
118
|
+
export function compileManagedProcessExecutionGrant(args) {
|
|
119
|
+
const manifests = [];
|
|
120
|
+
const unknownTools = [];
|
|
121
|
+
for (const toolName of [...new Set(args.allowedTools)]) {
|
|
122
|
+
const policy = getToolCapabilityPolicy(toolName);
|
|
123
|
+
const capability = policy?.capabilityCandidates[0];
|
|
124
|
+
if (!policy || !capability) {
|
|
125
|
+
unknownTools.push(toolName);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
manifests.push({
|
|
129
|
+
toolName,
|
|
130
|
+
moduleSpecifier: `managed-process:${toolName}`,
|
|
131
|
+
capabilities: [capability],
|
|
132
|
+
roles: [args.role],
|
|
133
|
+
enforcements: [policy.enforcement],
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (unknownTools.length > 0)
|
|
137
|
+
return { ok: false, reasonCodes: unknownTools.map((name) => `unknown_tool:${name}`) };
|
|
138
|
+
const capabilities = [...new Set(manifests.flatMap((manifest) => manifest.capabilities))];
|
|
139
|
+
const readEnabled = capabilities.some((capability) => capability === "filesystem.read" || capability === "worktree.read");
|
|
140
|
+
const compiled = new ExecutionPolicyCompiler().compile({
|
|
141
|
+
...args.target,
|
|
142
|
+
subjectId: `managed:${args.laneId}:${args.authorizationId}`,
|
|
143
|
+
role: args.role,
|
|
144
|
+
requiredCapabilities: capabilities,
|
|
145
|
+
requestedCapabilities: capabilities,
|
|
146
|
+
authorityCapabilities: capabilities,
|
|
147
|
+
requestedTools: manifests.map((manifest) => manifest.toolName),
|
|
148
|
+
toolManifests: manifests,
|
|
149
|
+
readPaths: readEnabled ? [path.resolve(args.cwd)] : [],
|
|
150
|
+
writePaths: args.writePaths.map((entry) => path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(args.cwd, entry)),
|
|
151
|
+
deniedPaths: args.deniedPaths.map((entry) => path.resolve(entry)),
|
|
152
|
+
requestedBudget: args.budget,
|
|
153
|
+
authorityBudget: args.budget,
|
|
154
|
+
policyVersion: "managed-process-v1",
|
|
155
|
+
});
|
|
156
|
+
if (compiled.outcome !== "allow")
|
|
157
|
+
return { ok: false, reasonCodes: compiled.reasonCodes };
|
|
158
|
+
return { ok: true, grant: compiled.grant };
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=worker-execution-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-execution-policy.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-execution-policy.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAU7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAU,CAAC;AAChE,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,CAAU,CAAC;AAcpD,SAAS,YAAY,CAAC,KAAa,EAAE,SAAiB,EAAW;IAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACjD,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;AAAA,CACrH;AAED,S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,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;AAAA,CAC3C","sourcesContent":["import path from \"node:path\";\nimport type {\n\tExecutionGrant,\n\tHarnessCapability,\n\tOrchestrationProfile,\n\tRiskBudget,\n\tToolCapabilityManifest,\n\tWorkerExecutionAuthorityContract,\n\tWorkerRole,\n} from \"../orchestration/contracts.ts\";\nimport { buildLaneToolManifests } from \"../orchestration/lane-tool-manifests.ts\";\nimport { ExecutionPolicyCompiler } from \"../orchestration/policy-compiler.ts\";\nimport { intersectRiskBudgets } from \"../orchestration/risk-budget.ts\";\nimport type { ResolvedWorkerDelegationSettings } from \"../settings-manager.ts\";\nimport { getToolCapabilityPolicy } from \"../tool-capability-policy.ts\";\n\nconst READ_TOOL_NAMES = [\"read\", \"grep\", \"find\", \"ls\"] as const;\nconst WRITE_TOOL_NAMES = [\"write\", \"edit\"] as const;\n\nexport interface WorkerExecutionPlan {\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\trequiredCapabilities: readonly HarnessCapability[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\treadMemory: boolean;\n\twriteEnabled: boolean;\n\tprocessEnabled: boolean;\n\tbudget: RiskBudget;\n}\n\nfunction pathContains(scope: string, candidate: string): boolean {\n\tconst relative = path.relative(scope, candidate);\n\treturn relative === \"\" || (!relative.startsWith(`..${path.sep}`) && relative !== \"..\" && !path.isAbsolute(relative));\n}\n\nfunction intersectPathScopes(admittedPaths: readonly string[], currentPaths: readonly string[]): string[] {\n\tconst intersections = admittedPaths.flatMap((admitted) =>\n\t\tcurrentPaths.flatMap((current) => {\n\t\t\tif (pathContains(admitted, current)) return [current];\n\t\t\tif (pathContains(current, admitted)) return [admitted];\n\t\t\treturn [];\n\t\t}),\n\t);\n\treturn [...new Set(intersections.map((entry) => path.resolve(entry)))];\n}\n\nexport function workerExecutionAuthorityFromPlan(plan: WorkerExecutionPlan): WorkerExecutionAuthorityContract {\n\treturn {\n\t\tcapabilities: [...plan.requiredCapabilities],\n\t\ttoolNames: plan.toolManifests.map((manifest) => manifest.toolName),\n\t\treadPaths: [...plan.readPaths],\n\t\twritePaths: [...plan.writePaths],\n\t\tdeniedPaths: [...plan.deniedPaths],\n\t\tbudget: { ...plan.budget },\n\t};\n}\n\n/** Apply live revocations to admitted authority without allowing later settings to widen it. */\nexport function narrowWorkerExecutionPlan(\n\tadmitted: WorkerExecutionAuthorityContract,\n\tcurrent: WorkerExecutionPlan,\n): WorkerExecutionPlan {\n\tconst admittedTools = new Set(admitted.toolNames);\n\tconst admittedCapabilities = new Set(admitted.capabilities);\n\tconst toolManifests = current.toolManifests.filter(\n\t\t(manifest) =>\n\t\t\tadmittedTools.has(manifest.toolName) &&\n\t\t\tmanifest.capabilities.every((capability) => admittedCapabilities.has(capability)),\n\t);\n\tconst requiredCapabilities = [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))];\n\tconst grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));\n\tconst readEnabled = requiredCapabilities.some(\n\t\t(capability) => capability === \"filesystem.read\" || capability === \"worktree.read\",\n\t);\n\tconst writeEnabled = grantedTools.has(\"write\") || grantedTools.has(\"edit\");\n\treturn {\n\t\ttoolManifests,\n\t\trequiredCapabilities,\n\t\treadPaths: readEnabled ? intersectPathScopes(admitted.readPaths, current.readPaths) : [],\n\t\twritePaths: writeEnabled ? intersectPathScopes(admitted.writePaths, current.writePaths) : [],\n\t\tdeniedPaths: [...new Set([...admitted.deniedPaths, ...current.deniedPaths].map((entry) => path.resolve(entry)))],\n\t\treadMemory: grantedTools.has(\"memory\"),\n\t\twriteEnabled,\n\t\tprocessEnabled: grantedTools.has(\"run_process\"),\n\t\tbudget: intersectRiskBudgets(admitted.budget, current.budget),\n\t};\n}\n\nexport function buildWorkerExecutionPlan(args: {\n\tprofile: OrchestrationProfile;\n\tsettings: ResolvedWorkerDelegationSettings;\n\tcwd: string;\n\tdeniedPaths: readonly string[];\n\tforegroundMaxCostUsd?: number;\n\tmemoryEnabled: boolean;\n}): WorkerExecutionPlan {\n\tconst grantsRead =\n\t\targs.profile.capabilityCeiling.includes(\"filesystem.read\") ||\n\t\targs.profile.capabilityCeiling.includes(\"worktree.read\");\n\tconst writeEligible =\n\t\targs.settings.writeEnabled &&\n\t\targs.settings.writePaths.length > 0 &&\n\t\t(args.profile.capabilityCeiling.includes(\"filesystem.write\") ||\n\t\t\targs.profile.capabilityCeiling.includes(\"worktree.mutate\"));\n\tconst memoryEligible =\n\t\targs.memoryEnabled &&\n\t\targs.profile.toolNames.includes(\"memory\") &&\n\t\targs.profile.capabilityCeiling.includes(\"memory.query\");\n\tconst processEligible =\n\t\targs.profile.executionPolicy !== undefined &&\n\t\t(args.profile.capabilityCeiling.includes(\"process.exec\") ||\n\t\t\targs.profile.capabilityCeiling.includes(\"tests.execute\"));\n\tconst enabledToolNames = [\n\t\t...(grantsRead ? READ_TOOL_NAMES : []),\n\t\t...(writeEligible ? WRITE_TOOL_NAMES : []),\n\t\t...(memoryEligible ? ([\"memory\"] as const) : []),\n\t\t...(processEligible ? ([\"run_process\"] as const) : []),\n\t];\n\tconst toolManifests = buildLaneToolManifests(args.profile, enabledToolNames);\n\tconst grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));\n\tconst readEnabled = toolManifests.some((manifest) =>\n\t\tmanifest.capabilities.some((capability) => capability === \"filesystem.read\" || capability === \"worktree.read\"),\n\t);\n\tconst writeEnabled = grantedTools.has(\"write\") || grantedTools.has(\"edit\");\n\tconst readMemory = grantedTools.has(\"memory\");\n\tconst processEnabled = grantedTools.has(\"run_process\");\n\tconst budget = intersectRiskBudgets(\n\t\targs.profile.budget,\n\t\t...(args.settings.maxUsd > 0 ? [{ maxCostUsd: args.settings.maxUsd }] : []),\n\t\t...(args.foregroundMaxCostUsd !== undefined ? [{ maxCostUsd: args.foregroundMaxCostUsd }] : []),\n\t\t...(args.settings.maxWallClockMs > 0 ? [{ maxWallClockMs: args.settings.maxWallClockMs }] : []),\n\t);\n\treturn {\n\t\ttoolManifests,\n\t\trequiredCapabilities: [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))],\n\t\treadPaths: readEnabled ? [path.resolve(args.cwd)] : [],\n\t\twritePaths: writeEnabled\n\t\t\t? args.settings.writePaths.map((entry) =>\n\t\t\t\t\tpath.isAbsolute(entry) ? path.resolve(entry) : path.resolve(args.cwd, entry),\n\t\t\t\t)\n\t\t\t: [],\n\t\tdeniedPaths: args.deniedPaths.map((entry) => path.resolve(entry)),\n\t\treadMemory,\n\t\twriteEnabled,\n\t\tprocessEnabled,\n\t\tbudget: { ...budget, maxToolCalls: budget.maxToolCalls ?? 6 },\n\t};\n}\n\nexport function compileWorkerExecutionGrant(args: {\n\ttarget: { objectiveId: string; taskId: string; attemptId: string };\n\tprofile: OrchestrationProfile;\n\tplan: WorkerExecutionPlan;\n}): { ok: true; grant: ExecutionGrant } | { ok: false; reasonCodes: readonly string[] } {\n\tconst compiled = new ExecutionPolicyCompiler().compile({\n\t\tobjectiveId: args.target.objectiveId,\n\t\ttaskId: args.target.taskId,\n\t\tattemptId: args.target.attemptId,\n\t\tsubjectId: `in-process:${args.target.attemptId}`,\n\t\trole: args.profile.role,\n\t\trequiredCapabilities: args.plan.requiredCapabilities,\n\t\trequestedCapabilities: args.plan.requiredCapabilities,\n\t\tauthorityCapabilities: args.profile.capabilityCeiling,\n\t\trequestedTools: args.plan.toolManifests.map((manifest) => manifest.toolName),\n\t\ttoolManifests: args.plan.toolManifests,\n\t\treadPaths: args.plan.readPaths,\n\t\twritePaths: args.plan.writePaths,\n\t\tdeniedPaths: args.plan.deniedPaths,\n\t\trequestedBudget: args.plan.budget,\n\t\tauthorityBudget: args.plan.budget,\n\t\tpolicyVersion: \"worker-profile-v1\",\n\t});\n\tif (compiled.outcome !== \"allow\") return { ok: false, reasonCodes: compiled.reasonCodes };\n\treturn { ok: true, grant: compiled.grant };\n}\n\n/** Compile the host's durable authority record before an externally managed process is launched. */\nexport function compileManagedProcessExecutionGrant(args: {\n\ttarget: { objectiveId: string; taskId: string; attemptId: string };\n\tlaneId: string;\n\tauthorizationId: string;\n\trole: WorkerRole;\n\tallowedTools: readonly string[];\n\twritePaths: readonly string[];\n\tcwd: string;\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n}): { ok: true; grant: ExecutionGrant } | { ok: false; reasonCodes: readonly string[] } {\n\tconst manifests: ToolCapabilityManifest[] = [];\n\tconst unknownTools: string[] = [];\n\tfor (const toolName of [...new Set(args.allowedTools)]) {\n\t\tconst policy = getToolCapabilityPolicy(toolName);\n\t\tconst capability = policy?.capabilityCandidates[0];\n\t\tif (!policy || !capability) {\n\t\t\tunknownTools.push(toolName);\n\t\t\tcontinue;\n\t\t}\n\t\tmanifests.push({\n\t\t\ttoolName,\n\t\t\tmoduleSpecifier: `managed-process:${toolName}`,\n\t\t\tcapabilities: [capability],\n\t\t\troles: [args.role],\n\t\t\tenforcements: [policy.enforcement],\n\t\t});\n\t}\n\tif (unknownTools.length > 0) return { ok: false, reasonCodes: unknownTools.map((name) => `unknown_tool:${name}`) };\n\tconst capabilities = [...new Set(manifests.flatMap((manifest) => manifest.capabilities))];\n\tconst readEnabled = capabilities.some(\n\t\t(capability) => capability === \"filesystem.read\" || capability === \"worktree.read\",\n\t);\n\tconst compiled = new ExecutionPolicyCompiler().compile({\n\t\t...args.target,\n\t\tsubjectId: `managed:${args.laneId}:${args.authorizationId}`,\n\t\trole: args.role,\n\t\trequiredCapabilities: capabilities,\n\t\trequestedCapabilities: capabilities,\n\t\tauthorityCapabilities: capabilities,\n\t\trequestedTools: manifests.map((manifest) => manifest.toolName),\n\t\ttoolManifests: manifests,\n\t\treadPaths: readEnabled ? [path.resolve(args.cwd)] : [],\n\t\twritePaths: args.writePaths.map((entry) =>\n\t\t\tpath.isAbsolute(entry) ? path.resolve(entry) : path.resolve(args.cwd, entry),\n\t\t),\n\t\tdeniedPaths: args.deniedPaths.map((entry) => path.resolve(entry)),\n\t\trequestedBudget: args.budget,\n\t\tauthorityBudget: args.budget,\n\t\tpolicyVersion: \"managed-process-v1\",\n\t});\n\tif (compiled.outcome !== \"allow\") return { ok: false, reasonCodes: compiled.reasonCodes };\n\treturn { ok: true, grant: compiled.grant };\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LaneRecord } from "../autonomy/lane-tracker.ts";
|
|
2
|
+
import type { AttemptRuntimeState, TaskRuntimeProjection } from "../orchestration/task-runtime.ts";
|
|
3
|
+
export declare const ACTIVE_WORKER_ATTEMPT_STATUSES: ReadonlySet<string>;
|
|
4
|
+
export declare function isManagedWorkerAttempt(attempt: AttemptRuntimeState): boolean;
|
|
5
|
+
export declare function selectedWorkerAttempt(snapshot: TaskRuntimeProjection, taskId: string): AttemptRuntimeState | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* One-way compatibility projection from durable orchestration state. A LaneRecord is never read
|
|
8
|
+
* back to decide lifecycle, retry, verification, or notification transitions.
|
|
9
|
+
*/
|
|
10
|
+
export declare function projectWorkerLaneRecord(snapshot: TaskRuntimeProjection, taskId: string): LaneRecord | undefined;
|
|
11
|
+
/** Latest durable turn for each externally managed logical lane. */
|
|
12
|
+
export declare function projectManagedWorkerLaneRecords(snapshot: TaskRuntimeProjection): LaneRecord[];
|
|
13
|
+
export declare function selectedManagedWorkerAttempt(snapshot: TaskRuntimeProjection, logicalLaneId: string): AttemptRuntimeState | undefined;
|
|
14
|
+
//# sourceMappingURL=worker-lane-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-lane-projection.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-lane-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,6BAA6B,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGnG,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAA4C,CAAC;AAE5G,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAE5E;AAWD,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,qBAAqB,EAC/B,MAAM,EAAE,MAAM,GACZ,mBAAmB,GAAG,SAAS,CAQjC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CA2C/G;AAED,oEAAoE;AACpE,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,qBAAqB,GAAG,UAAU,EAAE,CAkB7F;AAED,wBAAgB,4BAA4B,CAC3C,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,EAAE,MAAM,GACnB,mBAAmB,GAAG,SAAS,CAQjC","sourcesContent":["import type { LaneRecord, LaneTerminalStatus } from \"../autonomy/lane-tracker.ts\";\nimport type { AttemptRuntimeState, TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { deriveWorkerTaskLabel } from \"./worker-task-label.ts\";\n\nexport const ACTIVE_WORKER_ATTEMPT_STATUSES: ReadonlySet<string> = new Set([\"queued\", \"leased\", \"running\"]);\n\nexport function isManagedWorkerAttempt(attempt: AttemptRuntimeState): boolean {\n\treturn attempt.dispatch.executionKind === \"managed-process\";\n}\n\nfunction terminalStatus(attempt: AttemptRuntimeState): LaneTerminalStatus {\n\tif (attempt.status === \"completed\") return \"succeeded\";\n\tif (attempt.status === \"cancelled\") return \"canceled\";\n\tconst reasonCode = attempt.result?.reasonCode ?? attempt.reasonCode ?? \"\";\n\tif (reasonCode.includes(\"budget\")) return \"budget_exhausted\";\n\tif (reasonCode.includes(\"timeout\")) return \"timeout\";\n\treturn \"failed\";\n}\n\nexport function selectedWorkerAttempt(\n\tsnapshot: TaskRuntimeProjection,\n\ttaskId: string,\n): AttemptRuntimeState | undefined {\n\tconst task = snapshot.tasks[taskId];\n\tif (!task) return undefined;\n\tconst attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);\n\treturn (\n\t\t[...attempts].reverse().find((attempt) => attempt && ACTIVE_WORKER_ATTEMPT_STATUSES.has(attempt.status)) ??\n\t\tattempts.at(-1)\n\t);\n}\n\n/**\n * One-way compatibility projection from durable orchestration state. A LaneRecord is never read\n * back to decide lifecycle, retry, verification, or notification transitions.\n */\nexport function projectWorkerLaneRecord(snapshot: TaskRuntimeProjection, taskId: string): LaneRecord | undefined {\n\tconst task = snapshot.tasks[taskId];\n\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\tif (!task || !attempt) return undefined;\n\tconst managed = isManagedWorkerAttempt(attempt);\n\tconst objective = snapshot.objectives[task.task.objectiveId];\n\tconst awaitingVerification =\n\t\tattempt.result?.nextAction === \"independent_verification_required\" && task.verification === undefined;\n\tconst status = awaitingVerification\n\t\t? \"running\"\n\t\t: task.verification\n\t\t\t? task.verification.verdict === \"accepted\"\n\t\t\t\t? \"succeeded\"\n\t\t\t\t: \"failed\"\n\t\t\t: attempt.status === \"queued\"\n\t\t\t\t? \"queued\"\n\t\t\t\t: attempt.status === \"leased\" || attempt.status === \"running\"\n\t\t\t\t\t? \"running\"\n\t\t\t\t\t: terminalStatus(attempt);\n\tconst reasonCode = task.verification?.reasonCode ?? attempt.result?.reasonCode ?? attempt.reasonCode;\n\tconst genericTitle = `Delegated ${task.task.role} work`;\n\tconst label = deriveWorkerTaskLabel(\n\t\ttask.task.title === genericTitle ? task.task.description : task.task.title,\n\t\tgenericTitle,\n\t);\n\tconst goalId = objective?.objective.objectiveId.startsWith(\"goal:\")\n\t\t? objective.objective.objectiveId.slice(\"goal:\".length)\n\t\t: undefined;\n\treturn {\n\t\tlaneId: managed ? (attempt.dispatch.logicalLaneId ?? taskId) : taskId,\n\t\ttype: managed ? \"tmux-worker\" : \"worker\",\n\t\tstatus,\n\t\tlabel,\n\t\tprofileId: attempt.dispatch.profileId,\n\t\t...(reasonCode ? { reasonCode } : {}),\n\t\t...(attempt.status !== \"queued\" ? { startedAt: attempt.createdAt } : {}),\n\t\t...(status === \"queued\" || status === \"running\"\n\t\t\t? {}\n\t\t\t: { completedAt: task.verification?.completedAt ?? attempt.updatedAt }),\n\t\t...(attempt.result?.usage.costUsd !== undefined ? { costUsd: attempt.result.usage.costUsd } : {}),\n\t\t...(goalId ? { goalId } : {}),\n\t\t...(attempt.dispatch.worktreeLaneKey ? { worktreeLaneKey: attempt.dispatch.worktreeLaneKey } : {}),\n\t};\n}\n\n/** Latest durable turn for each externally managed logical lane. */\nexport function projectManagedWorkerLaneRecords(snapshot: TaskRuntimeProjection): LaneRecord[] {\n\tconst latest = new Map<string, { sequence: number; createdAt: string; record: LaneRecord }>();\n\tfor (const taskId of Object.keys(snapshot.tasks)) {\n\t\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\t\tif (!attempt || !isManagedWorkerAttempt(attempt)) continue;\n\t\tconst record = projectWorkerLaneRecord(snapshot, taskId);\n\t\tif (!record) continue;\n\t\tconst sequence = attempt.dispatch.dispatchSequence ?? 1;\n\t\tconst current = latest.get(record.laneId);\n\t\tif (\n\t\t\t!current ||\n\t\t\tsequence > current.sequence ||\n\t\t\t(sequence === current.sequence && attempt.createdAt.localeCompare(current.createdAt) > 0)\n\t\t) {\n\t\t\tlatest.set(record.laneId, { sequence, createdAt: attempt.createdAt, record });\n\t\t}\n\t}\n\treturn [...latest.values()].map((entry) => entry.record);\n}\n\nexport function selectedManagedWorkerAttempt(\n\tsnapshot: TaskRuntimeProjection,\n\tlogicalLaneId: string,\n): AttemptRuntimeState | undefined {\n\treturn Object.values(snapshot.attempts)\n\t\t.filter((attempt) => isManagedWorkerAttempt(attempt) && attempt.dispatch.logicalLaneId === logicalLaneId)\n\t\t.sort((left, right) => {\n\t\t\tconst sequence = (left.dispatch.dispatchSequence ?? 1) - (right.dispatch.dispatchSequence ?? 1);\n\t\t\treturn sequence !== 0 ? sequence : left.createdAt.localeCompare(right.createdAt);\n\t\t})\n\t\t.at(-1);\n}\n"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { deriveWorkerTaskLabel } from "./worker-task-label.js";
|
|
2
|
+
export const ACTIVE_WORKER_ATTEMPT_STATUSES = new Set(["queued", "leased", "running"]);
|
|
3
|
+
export function isManagedWorkerAttempt(attempt) {
|
|
4
|
+
return attempt.dispatch.executionKind === "managed-process";
|
|
5
|
+
}
|
|
6
|
+
function terminalStatus(attempt) {
|
|
7
|
+
if (attempt.status === "completed")
|
|
8
|
+
return "succeeded";
|
|
9
|
+
if (attempt.status === "cancelled")
|
|
10
|
+
return "canceled";
|
|
11
|
+
const reasonCode = attempt.result?.reasonCode ?? attempt.reasonCode ?? "";
|
|
12
|
+
if (reasonCode.includes("budget"))
|
|
13
|
+
return "budget_exhausted";
|
|
14
|
+
if (reasonCode.includes("timeout"))
|
|
15
|
+
return "timeout";
|
|
16
|
+
return "failed";
|
|
17
|
+
}
|
|
18
|
+
export function selectedWorkerAttempt(snapshot, taskId) {
|
|
19
|
+
const task = snapshot.tasks[taskId];
|
|
20
|
+
if (!task)
|
|
21
|
+
return undefined;
|
|
22
|
+
const attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);
|
|
23
|
+
return ([...attempts].reverse().find((attempt) => attempt && ACTIVE_WORKER_ATTEMPT_STATUSES.has(attempt.status)) ??
|
|
24
|
+
attempts.at(-1));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One-way compatibility projection from durable orchestration state. A LaneRecord is never read
|
|
28
|
+
* back to decide lifecycle, retry, verification, or notification transitions.
|
|
29
|
+
*/
|
|
30
|
+
export function projectWorkerLaneRecord(snapshot, taskId) {
|
|
31
|
+
const task = snapshot.tasks[taskId];
|
|
32
|
+
const attempt = selectedWorkerAttempt(snapshot, taskId);
|
|
33
|
+
if (!task || !attempt)
|
|
34
|
+
return undefined;
|
|
35
|
+
const managed = isManagedWorkerAttempt(attempt);
|
|
36
|
+
const objective = snapshot.objectives[task.task.objectiveId];
|
|
37
|
+
const awaitingVerification = attempt.result?.nextAction === "independent_verification_required" && task.verification === undefined;
|
|
38
|
+
const status = awaitingVerification
|
|
39
|
+
? "running"
|
|
40
|
+
: task.verification
|
|
41
|
+
? task.verification.verdict === "accepted"
|
|
42
|
+
? "succeeded"
|
|
43
|
+
: "failed"
|
|
44
|
+
: attempt.status === "queued"
|
|
45
|
+
? "queued"
|
|
46
|
+
: attempt.status === "leased" || attempt.status === "running"
|
|
47
|
+
? "running"
|
|
48
|
+
: terminalStatus(attempt);
|
|
49
|
+
const reasonCode = task.verification?.reasonCode ?? attempt.result?.reasonCode ?? attempt.reasonCode;
|
|
50
|
+
const genericTitle = `Delegated ${task.task.role} work`;
|
|
51
|
+
const label = deriveWorkerTaskLabel(task.task.title === genericTitle ? task.task.description : task.task.title, genericTitle);
|
|
52
|
+
const goalId = objective?.objective.objectiveId.startsWith("goal:")
|
|
53
|
+
? objective.objective.objectiveId.slice("goal:".length)
|
|
54
|
+
: undefined;
|
|
55
|
+
return {
|
|
56
|
+
laneId: managed ? (attempt.dispatch.logicalLaneId ?? taskId) : taskId,
|
|
57
|
+
type: managed ? "tmux-worker" : "worker",
|
|
58
|
+
status,
|
|
59
|
+
label,
|
|
60
|
+
profileId: attempt.dispatch.profileId,
|
|
61
|
+
...(reasonCode ? { reasonCode } : {}),
|
|
62
|
+
...(attempt.status !== "queued" ? { startedAt: attempt.createdAt } : {}),
|
|
63
|
+
...(status === "queued" || status === "running"
|
|
64
|
+
? {}
|
|
65
|
+
: { completedAt: task.verification?.completedAt ?? attempt.updatedAt }),
|
|
66
|
+
...(attempt.result?.usage.costUsd !== undefined ? { costUsd: attempt.result.usage.costUsd } : {}),
|
|
67
|
+
...(goalId ? { goalId } : {}),
|
|
68
|
+
...(attempt.dispatch.worktreeLaneKey ? { worktreeLaneKey: attempt.dispatch.worktreeLaneKey } : {}),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Latest durable turn for each externally managed logical lane. */
|
|
72
|
+
export function projectManagedWorkerLaneRecords(snapshot) {
|
|
73
|
+
const latest = new Map();
|
|
74
|
+
for (const taskId of Object.keys(snapshot.tasks)) {
|
|
75
|
+
const attempt = selectedWorkerAttempt(snapshot, taskId);
|
|
76
|
+
if (!attempt || !isManagedWorkerAttempt(attempt))
|
|
77
|
+
continue;
|
|
78
|
+
const record = projectWorkerLaneRecord(snapshot, taskId);
|
|
79
|
+
if (!record)
|
|
80
|
+
continue;
|
|
81
|
+
const sequence = attempt.dispatch.dispatchSequence ?? 1;
|
|
82
|
+
const current = latest.get(record.laneId);
|
|
83
|
+
if (!current ||
|
|
84
|
+
sequence > current.sequence ||
|
|
85
|
+
(sequence === current.sequence && attempt.createdAt.localeCompare(current.createdAt) > 0)) {
|
|
86
|
+
latest.set(record.laneId, { sequence, createdAt: attempt.createdAt, record });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return [...latest.values()].map((entry) => entry.record);
|
|
90
|
+
}
|
|
91
|
+
export function selectedManagedWorkerAttempt(snapshot, logicalLaneId) {
|
|
92
|
+
return Object.values(snapshot.attempts)
|
|
93
|
+
.filter((attempt) => isManagedWorkerAttempt(attempt) && attempt.dispatch.logicalLaneId === logicalLaneId)
|
|
94
|
+
.sort((left, right) => {
|
|
95
|
+
const sequence = (left.dispatch.dispatchSequence ?? 1) - (right.dispatch.dispatchSequence ?? 1);
|
|
96
|
+
return sequence !== 0 ? sequence : left.createdAt.localeCompare(right.createdAt);
|
|
97
|
+
})
|
|
98
|
+
.at(-1);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=worker-lane-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-lane-projection.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-lane-projection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,CAAC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CAAC,CAAC;QAC/E,CAAC;IACF,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAAA,CACzD;AAED,MAAM,UAAU,4BAA4B,CAC3C,QAA+B,EAC/B,aAAqB,EACa;IAClC,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;SACrC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,KAAK,aAAa,CAAC;SACxG,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC;QAChG,OAAO,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAAA,CACjF,CAAC;SACD,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAAA,CACT","sourcesContent":["import type { LaneRecord, LaneTerminalStatus } from \"../autonomy/lane-tracker.ts\";\nimport type { AttemptRuntimeState, TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { deriveWorkerTaskLabel } from \"./worker-task-label.ts\";\n\nexport const ACTIVE_WORKER_ATTEMPT_STATUSES: ReadonlySet<string> = new Set([\"queued\", \"leased\", \"running\"]);\n\nexport function isManagedWorkerAttempt(attempt: AttemptRuntimeState): boolean {\n\treturn attempt.dispatch.executionKind === \"managed-process\";\n}\n\nfunction terminalStatus(attempt: AttemptRuntimeState): LaneTerminalStatus {\n\tif (attempt.status === \"completed\") return \"succeeded\";\n\tif (attempt.status === \"cancelled\") return \"canceled\";\n\tconst reasonCode = attempt.result?.reasonCode ?? attempt.reasonCode ?? \"\";\n\tif (reasonCode.includes(\"budget\")) return \"budget_exhausted\";\n\tif (reasonCode.includes(\"timeout\")) return \"timeout\";\n\treturn \"failed\";\n}\n\nexport function selectedWorkerAttempt(\n\tsnapshot: TaskRuntimeProjection,\n\ttaskId: string,\n): AttemptRuntimeState | undefined {\n\tconst task = snapshot.tasks[taskId];\n\tif (!task) return undefined;\n\tconst attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);\n\treturn (\n\t\t[...attempts].reverse().find((attempt) => attempt && ACTIVE_WORKER_ATTEMPT_STATUSES.has(attempt.status)) ??\n\t\tattempts.at(-1)\n\t);\n}\n\n/**\n * One-way compatibility projection from durable orchestration state. A LaneRecord is never read\n * back to decide lifecycle, retry, verification, or notification transitions.\n */\nexport function projectWorkerLaneRecord(snapshot: TaskRuntimeProjection, taskId: string): LaneRecord | undefined {\n\tconst task = snapshot.tasks[taskId];\n\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\tif (!task || !attempt) return undefined;\n\tconst managed = isManagedWorkerAttempt(attempt);\n\tconst objective = snapshot.objectives[task.task.objectiveId];\n\tconst awaitingVerification =\n\t\tattempt.result?.nextAction === \"independent_verification_required\" && task.verification === undefined;\n\tconst status = awaitingVerification\n\t\t? \"running\"\n\t\t: task.verification\n\t\t\t? task.verification.verdict === \"accepted\"\n\t\t\t\t? \"succeeded\"\n\t\t\t\t: \"failed\"\n\t\t\t: attempt.status === \"queued\"\n\t\t\t\t? \"queued\"\n\t\t\t\t: attempt.status === \"leased\" || attempt.status === \"running\"\n\t\t\t\t\t? \"running\"\n\t\t\t\t\t: terminalStatus(attempt);\n\tconst reasonCode = task.verification?.reasonCode ?? attempt.result?.reasonCode ?? attempt.reasonCode;\n\tconst genericTitle = `Delegated ${task.task.role} work`;\n\tconst label = deriveWorkerTaskLabel(\n\t\ttask.task.title === genericTitle ? task.task.description : task.task.title,\n\t\tgenericTitle,\n\t);\n\tconst goalId = objective?.objective.objectiveId.startsWith(\"goal:\")\n\t\t? objective.objective.objectiveId.slice(\"goal:\".length)\n\t\t: undefined;\n\treturn {\n\t\tlaneId: managed ? (attempt.dispatch.logicalLaneId ?? taskId) : taskId,\n\t\ttype: managed ? \"tmux-worker\" : \"worker\",\n\t\tstatus,\n\t\tlabel,\n\t\tprofileId: attempt.dispatch.profileId,\n\t\t...(reasonCode ? { reasonCode } : {}),\n\t\t...(attempt.status !== \"queued\" ? { startedAt: attempt.createdAt } : {}),\n\t\t...(status === \"queued\" || status === \"running\"\n\t\t\t? {}\n\t\t\t: { completedAt: task.verification?.completedAt ?? attempt.updatedAt }),\n\t\t...(attempt.result?.usage.costUsd !== undefined ? { costUsd: attempt.result.usage.costUsd } : {}),\n\t\t...(goalId ? { goalId } : {}),\n\t\t...(attempt.dispatch.worktreeLaneKey ? { worktreeLaneKey: attempt.dispatch.worktreeLaneKey } : {}),\n\t};\n}\n\n/** Latest durable turn for each externally managed logical lane. */\nexport function projectManagedWorkerLaneRecords(snapshot: TaskRuntimeProjection): LaneRecord[] {\n\tconst latest = new Map<string, { sequence: number; createdAt: string; record: LaneRecord }>();\n\tfor (const taskId of Object.keys(snapshot.tasks)) {\n\t\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\t\tif (!attempt || !isManagedWorkerAttempt(attempt)) continue;\n\t\tconst record = projectWorkerLaneRecord(snapshot, taskId);\n\t\tif (!record) continue;\n\t\tconst sequence = attempt.dispatch.dispatchSequence ?? 1;\n\t\tconst current = latest.get(record.laneId);\n\t\tif (\n\t\t\t!current ||\n\t\t\tsequence > current.sequence ||\n\t\t\t(sequence === current.sequence && attempt.createdAt.localeCompare(current.createdAt) > 0)\n\t\t) {\n\t\t\tlatest.set(record.laneId, { sequence, createdAt: attempt.createdAt, record });\n\t\t}\n\t}\n\treturn [...latest.values()].map((entry) => entry.record);\n}\n\nexport function selectedManagedWorkerAttempt(\n\tsnapshot: TaskRuntimeProjection,\n\tlogicalLaneId: string,\n): AttemptRuntimeState | undefined {\n\treturn Object.values(snapshot.attempts)\n\t\t.filter((attempt) => isManagedWorkerAttempt(attempt) && attempt.dispatch.logicalLaneId === logicalLaneId)\n\t\t.sort((left, right) => {\n\t\t\tconst sequence = (left.dispatch.dispatchSequence ?? 1) - (right.dispatch.dispatchSequence ?? 1);\n\t\t\treturn sequence !== 0 ? sequence : left.createdAt.localeCompare(right.createdAt);\n\t\t})\n\t\t.at(-1);\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { LaneRecord } from "../autonomy/lane-tracker.ts";
|
|
2
|
+
import type { GoalState } from "../goals/goal-state.ts";
|
|
3
|
+
import type { ExecutionGrant, WorkerExecutionContract, WorkerResultContract } from "../orchestration/contracts.ts";
|
|
4
|
+
import { DelegationOrchestrationLedger, type PrepareDelegationInput, type PrepareManagedDelegationInput, type StartedDelegationAttempt } from "../orchestration/delegation-ledger.ts";
|
|
5
|
+
import type { AttemptRuntimeState, TaskRuntimeProjection } from "../orchestration/task-runtime.ts";
|
|
6
|
+
export type PendingVerificationRecovery = {
|
|
7
|
+
action: "dispatch";
|
|
8
|
+
subjectTaskId: string;
|
|
9
|
+
implementationProfileId: string;
|
|
10
|
+
summary: string;
|
|
11
|
+
artifactUris: readonly string[];
|
|
12
|
+
verifierExecutionContract?: WorkerExecutionContract;
|
|
13
|
+
} | {
|
|
14
|
+
action: "reconcile";
|
|
15
|
+
subjectTaskId: string;
|
|
16
|
+
verifierTaskId: string;
|
|
17
|
+
verifierAttemptId: string;
|
|
18
|
+
verdict: "accepted" | "rejected" | "inconclusive";
|
|
19
|
+
reasonCode: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Sole owner of in-process worker lifecycle state. LaneRecord is a compatibility/UI projection;
|
|
23
|
+
* all transitions are committed through DurableTaskRuntime before the projection is returned.
|
|
24
|
+
*/
|
|
25
|
+
export declare class WorkerLifecycle {
|
|
26
|
+
readonly ledger: DelegationOrchestrationLedger;
|
|
27
|
+
private nextLaneNumber;
|
|
28
|
+
constructor(options: {
|
|
29
|
+
agentDir: string;
|
|
30
|
+
sessionId: string;
|
|
31
|
+
});
|
|
32
|
+
prepare(input: Omit<PrepareDelegationInput, "laneId">, laneId?: string): {
|
|
33
|
+
record: LaneRecord;
|
|
34
|
+
attempt: AttemptRuntimeState;
|
|
35
|
+
};
|
|
36
|
+
prepareManaged(input: PrepareManagedDelegationInput & {
|
|
37
|
+
leaseTtlMs: number;
|
|
38
|
+
compileGrant(target: {
|
|
39
|
+
objectiveId: string;
|
|
40
|
+
taskId: string;
|
|
41
|
+
attemptId: string;
|
|
42
|
+
}): ExecutionGrant;
|
|
43
|
+
}): {
|
|
44
|
+
record: LaneRecord;
|
|
45
|
+
attempt: AttemptRuntimeState;
|
|
46
|
+
handle: StartedDelegationAttempt;
|
|
47
|
+
created: boolean;
|
|
48
|
+
};
|
|
49
|
+
synchronizeGoalState(goal: GoalState): LaneRecord[];
|
|
50
|
+
start(laneId: string, leaseTtlMs: number): StartedDelegationAttempt;
|
|
51
|
+
bindGrant(attemptId: string, grant: ExecutionGrant): void;
|
|
52
|
+
finish(result: WorkerResultContract, options?: {
|
|
53
|
+
notify?: boolean;
|
|
54
|
+
}): LaneRecord;
|
|
55
|
+
reconcileVerification(args: {
|
|
56
|
+
subjectTaskId: string;
|
|
57
|
+
verifierTaskId: string;
|
|
58
|
+
verifierAttemptId: string;
|
|
59
|
+
verdict: "accepted" | "rejected" | "inconclusive";
|
|
60
|
+
reasonCode: string;
|
|
61
|
+
}): LaneRecord;
|
|
62
|
+
cancel(laneId: string, reasonCode: string): LaneRecord | undefined;
|
|
63
|
+
recoverQueued(): Array<{
|
|
64
|
+
record: LaneRecord;
|
|
65
|
+
attempt: AttemptRuntimeState;
|
|
66
|
+
verificationOfTaskId?: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Close crash windows between implementation completion, verifier dispatch, and reconciliation. */
|
|
69
|
+
getPendingVerificationRecoveries(): PendingVerificationRecovery[];
|
|
70
|
+
getTask(taskId: string): TaskRuntimeProjection["tasks"][string] | undefined;
|
|
71
|
+
getTaskRuntimeSnapshot(): TaskRuntimeProjection;
|
|
72
|
+
getRecords(): LaneRecord[];
|
|
73
|
+
getManagedRecords(): LaneRecord[];
|
|
74
|
+
getAllRecords(): LaneRecord[];
|
|
75
|
+
getRecord(laneId: string): LaneRecord | undefined;
|
|
76
|
+
getManagedRecord(laneId: string): LaneRecord | undefined;
|
|
77
|
+
getManagedAttempt(laneId: string): AttemptRuntimeState | undefined;
|
|
78
|
+
getManagedHandle(laneId: string): StartedDelegationAttempt | undefined;
|
|
79
|
+
getActiveAttempt(laneId: string): AttemptRuntimeState | undefined;
|
|
80
|
+
getRunningCount(profileId?: string): number;
|
|
81
|
+
getPendingTerminalNotifications(): Array<{
|
|
82
|
+
notificationId: string;
|
|
83
|
+
record: LaneRecord;
|
|
84
|
+
}>;
|
|
85
|
+
getTerminalNotification(laneId: string): {
|
|
86
|
+
notificationId: string;
|
|
87
|
+
status: "pending" | "delivered";
|
|
88
|
+
record: LaneRecord;
|
|
89
|
+
} | undefined;
|
|
90
|
+
markNotificationsDelivered(notificationIds: readonly string[]): void;
|
|
91
|
+
private ensureTerminalNotifications;
|
|
92
|
+
private enqueueTerminalNotification;
|
|
93
|
+
private requireActiveAttempt;
|
|
94
|
+
private startedHandle;
|
|
95
|
+
private startPreparedManagedAttempt;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=worker-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,w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AC,GAAG,SAAS,CAE1E;IAED,sBAAsB,IAAI,qBAAqB,CAE9C;IAED,UAAU,IAAI,UAAU,EAAE,CAQzB;IAED,iBAAiB,IAAI,UAAU,EAAE,CAEhC;IAED,aAAa,IAAI,UAAU,EAAE,CAE5B;IAED,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAEhD;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAEvD;IAED,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAEjE;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS,CAGrE;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAEhE;IAED,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAU1C;IAED,+BAA+B,IAAI,KAAK,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,CAAC,CAWvF;IAED,uBAAuB,CACtB,MAAM,EAAE,MAAM,GACZ;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,GAAG,SAAS,CAS7F;IAED,0BAA0B,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAEnE;IAED,OAAO,CAAC,2BAA2B;IAUnC,OAAO,CAAC,2BAA2B;IAenC,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,2BAA2B;CAmBnC","sourcesContent":["import type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { GoalState } from \"../goals/goal-state.ts\";\nimport type { ExecutionGrant, WorkerExecutionContract, WorkerResultContract } from \"../orchestration/contracts.ts\";\nimport {\n\tDelegationOrchestrationLedger,\n\ttype PrepareDelegationInput,\n\ttype PrepareManagedDelegationInput,\n\ttype StartedDelegationAttempt,\n} from \"../orchestration/delegation-ledger.ts\";\nimport type { AttemptRuntimeState, TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { verifierWorkerExecutionContract } from \"../orchestration/worker-execution-contract.ts\";\nimport {\n\tACTIVE_WORKER_ATTEMPT_STATUSES,\n\tisManagedWorkerAttempt,\n\tprojectManagedWorkerLaneRecords,\n\tprojectWorkerLaneRecord,\n\tselectedManagedWorkerAttempt,\n\tselectedWorkerAttempt,\n} from \"./worker-lane-projection.ts\";\n\nexport type PendingVerificationRecovery =\n\t| {\n\t\t\taction: \"dispatch\";\n\t\t\tsubjectTaskId: string;\n\t\t\timplementationProfileId: string;\n\t\t\tsummary: string;\n\t\t\tartifactUris: readonly string[];\n\t\t\tverifierExecutionContract?: WorkerExecutionContract;\n\t }\n\t| {\n\t\t\taction: \"reconcile\";\n\t\t\tsubjectTaskId: string;\n\t\t\tverifierTaskId: string;\n\t\t\tverifierAttemptId: string;\n\t\t\tverdict: \"accepted\" | \"rejected\" | \"inconclusive\";\n\t\t\treasonCode: string;\n\t };\n\n/**\n * Sole owner of in-process worker lifecycle state. LaneRecord is a compatibility/UI projection;\n * all transitions are committed through DurableTaskRuntime before the projection is returned.\n */\nexport class WorkerLifecycle {\n\treadonly ledger: DelegationOrchestrationLedger;\n\tprivate nextLaneNumber: number;\n\n\tconstructor(options: { agentDir: string; sessionId: string }) {\n\t\tthis.ledger = new DelegationOrchestrationLedger(options);\n\t\tconst snapshot = this.ledger.runtime.getSnapshot();\n\t\tconst highest = Object.keys(snapshot.tasks).reduce((current, taskId) => {\n\t\t\tconst suffix = /^worker-(\\d+)$/.exec(taskId)?.[1];\n\t\t\treturn suffix ? Math.max(current, Number(suffix)) : current;\n\t\t}, 0);\n\t\tthis.nextLaneNumber = highest + 1;\n\t}\n\n\tprepare(\n\t\tinput: Omit<PrepareDelegationInput, \"laneId\">,\n\t\tlaneId?: string,\n\t): {\n\t\trecord: LaneRecord;\n\t\tattempt: AttemptRuntimeState;\n\t} {\n\t\tlet selectedLaneId = laneId;\n\t\tif (!selectedLaneId) {\n\t\t\tconst snapshot = this.ledger.runtime.getSnapshot();\n\t\t\twhile (snapshot.tasks[`worker-${this.nextLaneNumber}`]) this.nextLaneNumber += 1;\n\t\t\tselectedLaneId = `worker-${this.nextLaneNumber++}`;\n\t\t}\n\t\tconst attempt = this.ledger.prepare({ ...input, laneId: selectedLaneId });\n\t\tconst record = this.getRecord(selectedLaneId);\n\t\tif (!record) throw new Error(`Durable worker '${selectedLaneId}' was not projected after enqueue.`);\n\t\treturn { record, attempt };\n\t}\n\n\tprepareManaged(\n\t\tinput: PrepareManagedDelegationInput & {\n\t\t\tleaseTtlMs: number;\n\t\t\tcompileGrant(target: { objectiveId: string; taskId: string; attemptId: string }): ExecutionGrant;\n\t\t},\n\t): {\n\t\trecord: LaneRecord;\n\t\tattempt: AttemptRuntimeState;\n\t\thandle: StartedDelegationAttempt;\n\t\tcreated: boolean;\n\t} {\n\t\tconst before = selectedManagedWorkerAttempt(this.ledger.runtime.getSnapshot(), input.laneId);\n\t\tif (before?.dispatch.dispatchSequence === input.dispatchSequence) {\n\t\t\tif (\n\t\t\t\tbefore.dispatch.provider !== \"legacy\" &&\n\t\t\t\t(before.dispatch.instructions !== input.instructions ||\n\t\t\t\t\tbefore.dispatch.profileId !== input.profileId ||\n\t\t\t\t\tbefore.dispatch.provider !== input.provider ||\n\t\t\t\t\tbefore.dispatch.worktreeLaneKey !== input.worktreeLaneKey ||\n\t\t\t\t\tbefore.dispatch.authorizationId !== input.authorizationId)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Managed worker '${input.laneId}' turn ${input.dispatchSequence} was re-reported with conflicting dispatch data.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (before.status === \"queued\") {\n\t\t\t\tconst handle = this.startPreparedManagedAttempt(before, input.leaseTtlMs, input.compileGrant);\n\t\t\t\tconst record = this.getManagedRecord(input.laneId);\n\t\t\t\tif (!record) throw new Error(`Managed worker '${input.laneId}' was not projected.`);\n\t\t\t\treturn {\n\t\t\t\t\trecord,\n\t\t\t\t\tattempt: this.ledger.runtime.getSnapshot().attempts[before.attemptId]!,\n\t\t\t\t\thandle,\n\t\t\t\t\tcreated: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst record = this.getManagedRecord(input.laneId);\n\t\t\tif (!record) throw new Error(`Managed worker '${input.laneId}' was not projected.`);\n\t\t\tif (!before.lease) throw new Error(`Managed worker '${input.laneId}' has no durable lease.`);\n\t\t\treturn {\n\t\t\t\trecord,\n\t\t\t\tattempt: before,\n\t\t\t\thandle: this.startedHandle(before),\n\t\t\t\tcreated: false,\n\t\t\t};\n\t\t}\n\t\tif (before && ACTIVE_WORKER_ATTEMPT_STATUSES.has(before.status)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Managed worker '${input.laneId}' cannot dispatch turn ${input.dispatchSequence} while turn ${before.dispatch.dispatchSequence ?? 1} is active.`,\n\t\t\t);\n\t\t}\n\t\tconst attempt = this.ledger.prepareManaged(input);\n\t\tconst handle = this.startPreparedManagedAttempt(attempt, input.leaseTtlMs, input.compileGrant);\n\t\tconst record = this.getManagedRecord(input.laneId);\n\t\tif (!record) throw new Error(`Managed worker '${input.laneId}' was not projected after dispatch.`);\n\t\treturn { record, attempt: this.ledger.runtime.getSnapshot().attempts[attempt.attemptId]!, handle, created: true };\n\t}\n\n\tsynchronizeGoalState(goal: GoalState): LaneRecord[] {\n\t\tconst before = new Map(this.getRecords().map((record) => [record.laneId, record.status]));\n\t\tthis.ledger.synchronizeGoalState(goal);\n\t\treturn this.getRecords().filter((record) => {\n\t\t\tconst previous = before.get(record.laneId);\n\t\t\treturn (\n\t\t\t\t(previous === \"queued\" || previous === \"running\") &&\n\t\t\t\trecord.status !== \"queued\" &&\n\t\t\t\trecord.status !== \"running\"\n\t\t\t);\n\t\t});\n\t}\n\n\tstart(laneId: string, leaseTtlMs: number): StartedDelegationAttempt {\n\t\tconst attempt = this.requireActiveAttempt(laneId);\n\t\treturn this.ledger.start(attempt.attemptId, leaseTtlMs);\n\t}\n\n\tbindGrant(attemptId: string, grant: ExecutionGrant): void {\n\t\tthis.ledger.runtime.bindAttemptGrant(attemptId, grant);\n\t}\n\n\tfinish(result: WorkerResultContract, options: { notify?: boolean } = {}): LaneRecord {\n\t\tthis.ledger.runtime.finishAttempt(result);\n\t\tconst record = this.getRecord(result.taskId);\n\t\tif (!record) throw new Error(`Durable worker '${result.taskId}' was not projected after completion.`);\n\t\tif (options.notify !== false) this.enqueueTerminalNotification(record);\n\t\treturn record;\n\t}\n\n\treconcileVerification(args: {\n\t\tsubjectTaskId: string;\n\t\tverifierTaskId: string;\n\t\tverifierAttemptId: string;\n\t\tverdict: \"accepted\" | \"rejected\" | \"inconclusive\";\n\t\treasonCode: string;\n\t}): LaneRecord {\n\t\tthis.ledger.runtime.finishVerification({\n\t\t\ttaskId: args.subjectTaskId,\n\t\t\tverifierTaskId: args.verifierTaskId,\n\t\t\tverifierAttemptId: args.verifierAttemptId,\n\t\t\tverdict: args.verdict,\n\t\t\treasonCode: args.reasonCode,\n\t\t});\n\t\tconst subject = this.getRecord(args.subjectTaskId);\n\t\tif (!subject) throw new Error(`Verified worker '${args.subjectTaskId}' was not projected.`);\n\t\tthis.enqueueTerminalNotification(subject);\n\t\treturn subject;\n\t}\n\n\tcancel(laneId: string, reasonCode: string): LaneRecord | undefined {\n\t\tconst attempt = this.getActiveAttempt(laneId);\n\t\tif (!attempt) return this.getRecord(laneId);\n\t\tthis.ledger.cancel(attempt.attemptId, reasonCode);\n\t\tconst record = this.getRecord(laneId);\n\t\tif (record) this.enqueueTerminalNotification(record);\n\t\treturn record;\n\t}\n\n\trecoverQueued(): Array<{\n\t\trecord: LaneRecord;\n\t\tattempt: AttemptRuntimeState;\n\t\tverificationOfTaskId?: string;\n\t}> {\n\t\treturn this.ledger.recoverQueuedDispatches().flatMap((attempt) => {\n\t\t\tif (isManagedWorkerAttempt(attempt)) return [];\n\t\t\tconst record = this.getRecord(attempt.taskId);\n\t\t\tconst task = this.ledger.runtime.getSnapshot().tasks[attempt.taskId]?.task;\n\t\t\treturn record\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trecord,\n\t\t\t\t\t\t\tattempt,\n\t\t\t\t\t\t\t...(task?.verificationOfTaskId ? { verificationOfTaskId: task.verificationOfTaskId } : {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: [];\n\t\t});\n\t}\n\n\t/** Close crash windows between implementation completion, verifier dispatch, and reconciliation. */\n\tgetPendingVerificationRecoveries(): PendingVerificationRecovery[] {\n\t\tconst snapshot = this.ledger.runtime.getSnapshot();\n\t\treturn Object.values(snapshot.tasks).flatMap<PendingVerificationRecovery>((subject) => {\n\t\t\tif (subject.verification) return [];\n\t\t\tconst implementationAttempt = selectedWorkerAttempt(snapshot, subject.task.taskId);\n\t\t\tif (implementationAttempt?.result?.nextAction !== \"independent_verification_required\") return [];\n\t\t\tconst verifier = Object.values(snapshot.tasks)\n\t\t\t\t.filter((candidate) => candidate.task.verificationOfTaskId === subject.task.taskId)\n\t\t\t\t.sort((left, right) => left.task.createdAt.localeCompare(right.task.createdAt))\n\t\t\t\t.at(-1);\n\t\t\tif (!verifier) {\n\t\t\t\tconst verifierExecutionContract = implementationAttempt.dispatch.executionContract\n\t\t\t\t\t? verifierWorkerExecutionContract(implementationAttempt.dispatch.executionContract)\n\t\t\t\t\t: undefined;\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\taction: \"dispatch\" as const,\n\t\t\t\t\t\tsubjectTaskId: subject.task.taskId,\n\t\t\t\t\t\timplementationProfileId: implementationAttempt.dispatch.profileId,\n\t\t\t\t\t\tsummary: implementationAttempt.result.summary,\n\t\t\t\t\t\tartifactUris: implementationAttempt.result.artifacts.map((artifact) => artifact.uri),\n\t\t\t\t\t\t...(verifierExecutionContract ? { verifierExecutionContract } : {}),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\tconst verifierAttempt = selectedWorkerAttempt(snapshot, verifier.task.taskId);\n\t\t\tif (!verifierAttempt || ACTIVE_WORKER_ATTEMPT_STATUSES.has(verifierAttempt.status)) return [];\n\t\t\tconst review = verifierAttempt.result?.evidence.find(\n\t\t\t\t(evidence) => evidence.kind === \"review\" && evidence.metadata?.subjectTaskId === subject.task.taskId,\n\t\t\t);\n\t\t\tconst verdictValue = review?.metadata?.verdict;\n\t\t\tconst verdict =\n\t\t\t\treview?.trusted && (verdictValue === \"accepted\" || verdictValue === \"rejected\")\n\t\t\t\t\t? verdictValue\n\t\t\t\t\t: \"inconclusive\";\n\t\t\tconst reasonCodesValue = review?.metadata?.reasonCodes;\n\t\t\tconst reasonCodes = Array.isArray(reasonCodesValue)\n\t\t\t\t? reasonCodesValue.filter((reasonCode): reasonCode is string => typeof reasonCode === \"string\")\n\t\t\t\t: [];\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\taction: \"reconcile\" as const,\n\t\t\t\t\tsubjectTaskId: subject.task.taskId,\n\t\t\t\t\tverifierTaskId: verifier.task.taskId,\n\t\t\t\t\tverifierAttemptId: verifierAttempt.attemptId,\n\t\t\t\t\tverdict,\n\t\t\t\t\treasonCode:\n\t\t\t\t\t\tverdict === \"accepted\"\n\t\t\t\t\t\t\t? \"independent_verification_accepted\"\n\t\t\t\t\t\t\t: verdict === \"rejected\"\n\t\t\t\t\t\t\t\t? `independent_verification_rejected:${reasonCodes.join(\",\") || \"unspecified\"}`\n\t\t\t\t\t\t\t\t: `independent_verification_inconclusive:${verifierAttempt.reasonCode ?? verifierAttempt.result?.reasonCode ?? \"interrupted\"}`,\n\t\t\t\t},\n\t\t\t];\n\t\t});\n\t}\n\n\tgetTask(taskId: string): TaskRuntimeProjection[\"tasks\"][string] | undefined {\n\t\treturn this.ledger.runtime.getSnapshot().tasks[taskId];\n\t}\n\n\tgetTaskRuntimeSnapshot(): TaskRuntimeProjection {\n\t\treturn this.ledger.runtime.getSnapshot();\n\t}\n\n\tgetRecords(): LaneRecord[] {\n\t\tconst snapshot = this.ledger.runtime.getSnapshot();\n\t\treturn Object.keys(snapshot.tasks).flatMap((taskId) => {\n\t\t\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\t\t\tif (!attempt || isManagedWorkerAttempt(attempt)) return [];\n\t\t\tconst record = projectWorkerLaneRecord(snapshot, taskId);\n\t\t\treturn record ? [record] : [];\n\t\t});\n\t}\n\n\tgetManagedRecords(): LaneRecord[] {\n\t\treturn projectManagedWorkerLaneRecords(this.ledger.runtime.getSnapshot());\n\t}\n\n\tgetAllRecords(): LaneRecord[] {\n\t\treturn [...this.getRecords(), ...this.getManagedRecords()];\n\t}\n\n\tgetRecord(laneId: string): LaneRecord | undefined {\n\t\treturn projectWorkerLaneRecord(this.ledger.runtime.getSnapshot(), laneId);\n\t}\n\n\tgetManagedRecord(laneId: string): LaneRecord | undefined {\n\t\treturn this.getManagedRecords().find((record) => record.laneId === laneId);\n\t}\n\n\tgetManagedAttempt(laneId: string): AttemptRuntimeState | undefined {\n\t\treturn selectedManagedWorkerAttempt(this.ledger.runtime.getSnapshot(), laneId);\n\t}\n\n\tgetManagedHandle(laneId: string): StartedDelegationAttempt | undefined {\n\t\tconst attempt = this.getManagedAttempt(laneId);\n\t\treturn attempt?.lease ? this.startedHandle(attempt) : undefined;\n\t}\n\n\tgetActiveAttempt(laneId: string): AttemptRuntimeState | undefined {\n\t\treturn selectedWorkerAttempt(this.ledger.runtime.getSnapshot(), laneId);\n\t}\n\n\tgetRunningCount(profileId?: string): number {\n\t\tconst snapshot = this.ledger.runtime.getSnapshot();\n\t\treturn Object.keys(snapshot.tasks).filter((taskId) => {\n\t\t\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\t\t\treturn (\n\t\t\t\tattempt?.status === \"running\" &&\n\t\t\t\t!isManagedWorkerAttempt(attempt) &&\n\t\t\t\t(!profileId || attempt.dispatch.profileId === profileId)\n\t\t\t);\n\t\t}).length;\n\t}\n\n\tgetPendingTerminalNotifications(): Array<{ notificationId: string; record: LaneRecord }> {\n\t\tthis.ensureTerminalNotifications();\n\t\tconst snapshot = this.ledger.runtime.getSnapshot();\n\t\treturn Object.values(snapshot.notifications).flatMap((notification) => {\n\t\t\tif (notification.status !== \"pending\" || !notification.attemptId) return [];\n\t\t\tconst attempt = snapshot.attempts[notification.attemptId];\n\t\t\tif (!attempt) return [];\n\t\t\tconst record = projectWorkerLaneRecord(snapshot, attempt.taskId);\n\t\t\tif (!record || record.status === \"queued\" || record.status === \"running\") return [];\n\t\t\treturn [{ notificationId: notification.notificationId, record }];\n\t\t});\n\t}\n\n\tgetTerminalNotification(\n\t\tlaneId: string,\n\t): { notificationId: string; status: \"pending\" | \"delivered\"; record: LaneRecord } | undefined {\n\t\tconst record = this.getRecord(laneId) ?? this.getManagedRecord(laneId);\n\t\tif (!record || record.status === \"queued\" || record.status === \"running\") return undefined;\n\t\tthis.enqueueTerminalNotification(record);\n\t\tconst attempt = this.getActiveAttempt(laneId) ?? this.getManagedAttempt(laneId);\n\t\tif (!attempt) return undefined;\n\t\tconst notificationId = `worker-terminal:${attempt.attemptId}`;\n\t\tconst notification = this.ledger.runtime.getSnapshot().notifications[notificationId];\n\t\treturn notification ? { notificationId, status: notification.status, record } : undefined;\n\t}\n\n\tmarkNotificationsDelivered(notificationIds: readonly string[]): void {\n\t\tfor (const notificationId of notificationIds) this.ledger.runtime.markNotificationDelivered(notificationId);\n\t}\n\n\tprivate ensureTerminalNotifications(): void {\n\t\tconst snapshot = this.ledger.runtime.getSnapshot();\n\t\tfor (const taskId of Object.keys(snapshot.tasks)) {\n\t\t\tconst record = projectWorkerLaneRecord(snapshot, taskId);\n\t\t\tif (record && record.status !== \"queued\" && record.status !== \"running\") {\n\t\t\t\tthis.enqueueTerminalNotification(record);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate enqueueTerminalNotification(record: LaneRecord): void {\n\t\tconst attempt = this.getActiveAttempt(record.laneId) ?? this.getManagedAttempt(record.laneId);\n\t\tif (!attempt || ACTIVE_WORKER_ATTEMPT_STATUSES.has(attempt.status)) return;\n\t\tconst snapshot = this.ledger.runtime.getSnapshot();\n\t\tconst task = snapshot.tasks[attempt.taskId];\n\t\tif (!task) return;\n\t\tif (attempt.result?.nextAction === \"independent_verification_required\" && !task.verification) return;\n\t\tthis.ledger.runtime.enqueueNotification({\n\t\t\tnotificationId: `worker-terminal:${attempt.attemptId}`,\n\t\t\tobjectiveId: task.task.objectiveId,\n\t\t\tattemptId: attempt.attemptId,\n\t\t\tmessage: `Worker ${record.laneId} reached ${record.status}.`,\n\t\t});\n\t}\n\n\tprivate requireActiveAttempt(laneId: string): AttemptRuntimeState {\n\t\tconst attempt = this.getActiveAttempt(laneId);\n\t\tif (!attempt || !ACTIVE_WORKER_ATTEMPT_STATUSES.has(attempt.status)) {\n\t\t\tthrow new Error(`Durable worker '${laneId}' has no active attempt.`);\n\t\t}\n\t\treturn attempt;\n\t}\n\n\tprivate startedHandle(attempt: AttemptRuntimeState): StartedDelegationAttempt {\n\t\tconst task = this.ledger.runtime.getSnapshot().tasks[attempt.taskId];\n\t\tif (!task || !attempt.lease) throw new Error(`Attempt '${attempt.attemptId}' has no started handle.`);\n\t\treturn {\n\t\t\tobjectiveId: task.task.objectiveId,\n\t\t\ttaskId: task.task.taskId,\n\t\t\tattemptId: attempt.attemptId,\n\t\t\tleaseId: attempt.lease.leaseId,\n\t\t\tfencingToken: attempt.lease.fencingToken,\n\t\t\texpiresAt: attempt.lease.expiresAt,\n\t\t};\n\t}\n\n\tprivate startPreparedManagedAttempt(\n\t\tattempt: AttemptRuntimeState,\n\t\tleaseTtlMs: number,\n\t\tcompileGrant: (target: { objectiveId: string; taskId: string; attemptId: string }) => ExecutionGrant,\n\t): StartedDelegationAttempt {\n\t\tconst task = this.ledger.runtime.getSnapshot().tasks[attempt.taskId];\n\t\tif (!task) throw new Error(`Managed attempt '${attempt.attemptId}' has no durable task.`);\n\t\tconst grant = compileGrant({\n\t\t\tobjectiveId: task.task.objectiveId,\n\t\t\ttaskId: task.task.taskId,\n\t\t\tattemptId: attempt.attemptId,\n\t\t});\n\t\tthis.bindGrant(attempt.attemptId, grant);\n\t\treturn this.ledger.start(\n\t\t\tattempt.attemptId,\n\t\t\tleaseTtlMs,\n\t\t\t`managed:${attempt.dispatch.logicalLaneId ?? attempt.taskId}`,\n\t\t);\n\t}\n}\n"]}
|