@caupulican/pi-adaptative 0.81.38 → 0.81.40
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 +131 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +18 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +133 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +198 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +311 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +31 -2
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +823 -79
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +1043 -86
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/__init__.py +43 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +270 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +252 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +399 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +575 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +52 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +49 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +734 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +238 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +132 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +116 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +287 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +137 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +100 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +579 -0
- package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +19 -9
- package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +22 -5
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +7 -7
- package/dist/bundled-resources/skills/tool-call-repair/references/text-protocol-grammar.md +28 -7
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +24 -0
- 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 +66 -0
- package/dist/core/agent-paths.d.ts.map +1 -0
- package/dist/core/agent-paths.js +170 -0
- package/dist/core/agent-paths.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 +397 -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 +4 -3
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +255 -103
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +754 -1173
- package/dist/core/agent-session.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 +26 -9
- 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 +46 -8
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +24 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +43 -1
- 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 +90 -156
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +192 -968
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +7 -1
- package/dist/core/bash-execution-controller.js.map +1 -1
- 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 +24 -13
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +43 -7
- 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-audit.d.ts +33 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +31 -5
- package/dist/core/context/context-audit.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 +26 -6
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +26 -4
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +146 -18
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost-guard.d.ts +19 -3
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +18 -3
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -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-claim.d.ts +56 -0
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/worker-claim.js +239 -0
- 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/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 +68 -13
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +7 -0
- package/dist/core/extensions/runner.js.map +1 -1
- 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 +101 -1
- 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 +52 -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 +17 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +79 -11
- package/dist/core/goal-loop-controller.js.map +1 -1
- 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 +25 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +27 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +93 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +48 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +87 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +39 -0
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +42 -0
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +5 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +56 -15
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +20 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +17 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +105 -4
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +91 -6
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +90 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +78 -15
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +58 -2
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +82 -6
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +13 -6
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +20 -28
- package/dist/core/goals/session-goal-state.js.map +1 -1
- 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 +27 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +34 -8
- 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/observation-store.d.ts +12 -3
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +30 -15
- package/dist/core/learning/observation-store.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/learning/skill-curator.d.ts +5 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +21 -19
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +65 -3
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +186 -26
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +6 -6
- package/dist/core/memory/providers/file-store.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 +34 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +43 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +6 -9
- 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/tool-escalation.d.ts +15 -0
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js +23 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +34 -7
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +95 -16
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +4 -4
- 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 +10 -5
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +129 -81
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js +17 -0
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +4 -11
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +87 -51
- 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/models/llamacpp-runtime.d.ts +180 -0
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -0
- package/dist/core/models/llamacpp-runtime.js +475 -0
- package/dist/core/models/llamacpp-runtime.js.map +1 -0
- package/dist/core/models/local-registration.d.ts +40 -0
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +94 -5
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +6 -5
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-ref.d.ts +7 -0
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js +26 -0
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +257 -0
- package/dist/core/models/needle-runtime.d.ts.map +1 -0
- package/dist/core/models/needle-runtime.js +519 -0
- package/dist/core/models/needle-runtime.js.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts +89 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js +121 -0
- package/dist/core/models/prism-llamacpp-lifecycle.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 +197 -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 +11 -10
- 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 +83 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -0
- package/dist/core/process-matrix/codes.js +15 -0
- package/dist/core/process-matrix/codes.js.map +1 -0
- 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 +78 -0
- package/dist/core/process-matrix/runtime.d.ts.map +1 -0
- package/dist/core/process-matrix/runtime.js +633 -0
- package/dist/core/process-matrix/runtime.js.map +1 -0
- package/dist/core/process-matrix/store.d.ts +25 -0
- package/dist/core/process-matrix/store.d.ts.map +1 -0
- package/dist/core/process-matrix/store.js +189 -0
- package/dist/core/process-matrix/store.js.map +1 -0
- package/dist/core/process-matrix/supervisor.d.ts +75 -0
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -0
- package/dist/core/process-matrix/supervisor.js +161 -0
- package/dist/core/process-matrix/supervisor.js.map +1 -0
- package/dist/core/profile-registry.d.ts +7 -0
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +25 -7
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js +3 -3
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +33 -9
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +217 -127
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +36 -0
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +50 -8
- package/dist/core/reload-blockers.js.map +1 -1
- 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 +15 -9
- 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 +225 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +76 -17
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +367 -124
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +6 -0
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +66 -52
- package/dist/core/scout-controller.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 +64 -27
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +28 -1
- 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 +33 -0
- package/dist/core/session-role.d.ts.map +1 -0
- package/dist/core/session-role.js +58 -0
- package/dist/core/session-role.js.map +1 -0
- 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/settings-manager.d.ts +51 -7
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +168 -82
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +12 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +6 -0
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts +14 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +13 -6
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +20 -22
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts +45 -0
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -0
- package/dist/core/tasks/task-contract-monitor.js +56 -0
- package/dist/core/tasks/task-contract-monitor.js.map +1 -0
- 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 +12 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +56 -12
- 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 +85 -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 +5 -0
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +91 -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 +6 -0
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +13 -31
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts +54 -0
- package/dist/core/tool-selection/promotion.d.ts.map +1 -0
- package/dist/core/tool-selection/promotion.js +81 -0
- package/dist/core/tool-selection/promotion.js.map +1 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts +39 -6
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +153 -110
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.d.ts +45 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +96 -0
- package/dist/core/tool-selection/tool-selection-controller.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 +18 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +95 -16
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +44 -2
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +214 -19
- 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 +124 -22
- 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/goal.d.ts +94 -3
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +165 -15
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts +7 -0
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +4 -4
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +43 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +168 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- 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/shell-contract-router.d.ts +6 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +23 -2
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts +89 -0
- package/dist/core/tools/shell-session.d.ts.map +1 -0
- package/dist/core/tools/shell-session.js +432 -0
- package/dist/core/tools/shell-session.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +6 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +165 -8
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +84 -0
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -0
- package/dist/core/tools/tmux-dispatch.js +91 -0
- package/dist/core/tools/tmux-dispatch.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +42 -0
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-engine.js +151 -0
- package/dist/core/tools/windows-shell-engine.js.map +1 -0
- package/dist/core/tools/windows-shell-state.d.ts +40 -0
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-state.js +59 -0
- package/dist/core/tools/windows-shell-state.js.map +1 -0
- package/dist/core/tools/worktree-sync.d.ts +24 -0
- package/dist/core/tools/worktree-sync.d.ts.map +1 -0
- package/dist/core/tools/worktree-sync.js +338 -0
- package/dist/core/tools/worktree-sync.js.map +1 -0
- package/dist/core/trust-manager.d.ts +4 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +20 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +55 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -0
- package/dist/core/util/atomic-file.js +255 -0
- package/dist/core/util/atomic-file.js.map +1 -0
- 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/minimatch-cache.d.ts +33 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -0
- package/dist/core/util/minimatch-cache.js +0 -0
- package/dist/core/util/minimatch-cache.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/codes.d.ts +227 -0
- package/dist/core/worktree-sync/codes.d.ts.map +1 -0
- package/dist/core/worktree-sync/codes.js +14 -0
- package/dist/core/worktree-sync/codes.js.map +1 -0
- package/dist/core/worktree-sync/git-engine.d.ts +156 -0
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -0
- package/dist/core/worktree-sync/git-engine.js +1191 -0
- package/dist/core/worktree-sync/git-engine.js.map +1 -0
- package/dist/core/worktree-sync/lane-gate.d.ts +75 -0
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -0
- package/dist/core/worktree-sync/lane-gate.js +360 -0
- package/dist/core/worktree-sync/lane-gate.js.map +1 -0
- package/dist/core/worktree-sync/runtime.d.ts +47 -0
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -0
- package/dist/core/worktree-sync/runtime.js +96 -0
- package/dist/core/worktree-sync/runtime.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +69 -0
- package/dist/core/worktree-sync/store.d.ts.map +1 -0
- package/dist/core/worktree-sync/store.js +252 -0
- package/dist/core/worktree-sync/store.js.map +1 -0
- package/dist/core/worktree-sync/watcher.d.ts +29 -0
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -0
- package/dist/core/worktree-sync/watcher.js +93 -0
- package/dist/core/worktree-sync/watcher.js.map +1 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +179 -1
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +7 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +197 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +16 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +50 -8
- package/dist/modes/interactive/auto-learn-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/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +23 -1
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +2 -2
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- 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 +76 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +67 -1
- 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/local-model-commands.d.ts +43 -0
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +290 -3
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- 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/session-flow-commands.d.ts +17 -2
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +74 -21
- 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/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/fs-watch.d.ts +11 -0
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +20 -2
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts +4 -0
- package/dist/utils/highlight-js-languages.d.ts.map +1 -0
- package/dist/utils/highlight-js-languages.js +573 -0
- package/dist/utils/highlight-js-languages.js.map +1 -0
- 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 +7 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +21 -6
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +53 -5
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +112 -1
- package/dist/utils/tools-manager.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 +44 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +30 -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 +153 -0
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +128 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +92 -2
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +7 -0
- package/docs/ui-reference/orchestration-before.txt +7 -0
- package/docs/ui-reference/orchestration-reference.txt +6 -0
- package/docs/usage.md +14 -2
- package/docs/windows.md +52 -3
- package/docs/work-directory.md +42 -2
- package/docs/worktree-sync.md +250 -0
- 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 +12 -12
- package/package.json +10 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -16
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -53
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts +0 -15
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js +0 -161
- 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
- package/docs/integration-sweep-builder-blueprint-2026-07-09.md +0 -365
- package/docs/integration-sweep-resume-2026-07-09.md +0 -407
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { HARNESS_CAPABILITIES } from "../capability-contract.js";
|
|
2
|
+
import { isPlainRecord } from "../util/value-guards.js";
|
|
3
|
+
export { HARNESS_CAPABILITIES } from "../capability-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* Versioned control-plane contracts. These records are the durable truth exchanged between the
|
|
6
|
+
* deterministic kernel/runtime and replaceable execution-plane workers. They deliberately do not
|
|
7
|
+
* contain callbacks, provider objects, tool implementations, or transcript messages.
|
|
8
|
+
*/
|
|
9
|
+
export const ORCHESTRATION_SCHEMA_VERSION = 1;
|
|
10
|
+
export const WORKER_ROLES = [
|
|
11
|
+
"orchestrator",
|
|
12
|
+
"planner",
|
|
13
|
+
"explorer",
|
|
14
|
+
"implementer",
|
|
15
|
+
"operator",
|
|
16
|
+
"verifier",
|
|
17
|
+
"database",
|
|
18
|
+
];
|
|
19
|
+
export const ORCHESTRATION_THINKING_LEVELS = [
|
|
20
|
+
"off",
|
|
21
|
+
"minimal",
|
|
22
|
+
"low",
|
|
23
|
+
"medium",
|
|
24
|
+
"high",
|
|
25
|
+
"xhigh",
|
|
26
|
+
"max",
|
|
27
|
+
"ultra",
|
|
28
|
+
];
|
|
29
|
+
export const OBJECTIVE_STATUSES = ["active", "paused", "completed", "cancelled"];
|
|
30
|
+
export const TASK_STATUSES = ["pending", "ready", "running", "blocked", "completed", "failed", "cancelled"];
|
|
31
|
+
export const ATTEMPT_STATUSES = [
|
|
32
|
+
"queued",
|
|
33
|
+
"leased",
|
|
34
|
+
"running",
|
|
35
|
+
"suspended",
|
|
36
|
+
"completed",
|
|
37
|
+
"partial",
|
|
38
|
+
"blocked",
|
|
39
|
+
"failed",
|
|
40
|
+
"cancelled",
|
|
41
|
+
"expired",
|
|
42
|
+
];
|
|
43
|
+
export const WORKER_RESULT_STATUSES = ["completed", "partial", "blocked", "failed", "cancelled"];
|
|
44
|
+
export const RESOURCE_POINTER_KINDS = [
|
|
45
|
+
"repository",
|
|
46
|
+
"worktree",
|
|
47
|
+
"artifact",
|
|
48
|
+
"evidence",
|
|
49
|
+
"memory-query",
|
|
50
|
+
"skill",
|
|
51
|
+
"prompt",
|
|
52
|
+
"service",
|
|
53
|
+
];
|
|
54
|
+
export function isResourcePointerKind(value) {
|
|
55
|
+
return RESOURCE_POINTER_KINDS.some((kind) => kind === value);
|
|
56
|
+
}
|
|
57
|
+
export const APPROVAL_OUTCOMES = ["approved", "rejected"];
|
|
58
|
+
export const ORCHESTRATION_EVENT_TYPES = [
|
|
59
|
+
"objective.created",
|
|
60
|
+
"objective.updated",
|
|
61
|
+
"objective.evidence_recorded",
|
|
62
|
+
"objective.paused",
|
|
63
|
+
"objective.resumed",
|
|
64
|
+
"objective.completed",
|
|
65
|
+
"objective.cancelled",
|
|
66
|
+
"task.created",
|
|
67
|
+
"task.ready",
|
|
68
|
+
"task.failed",
|
|
69
|
+
"task.verification_finished",
|
|
70
|
+
"agent.registered",
|
|
71
|
+
"agent.suspended",
|
|
72
|
+
"agent.resume_requested",
|
|
73
|
+
"agent.resumed",
|
|
74
|
+
"attempt.queued",
|
|
75
|
+
"attempt.grant_bound",
|
|
76
|
+
"attempt.leased",
|
|
77
|
+
"attempt.started",
|
|
78
|
+
"attempt.checkpointed",
|
|
79
|
+
"attempt.suspended",
|
|
80
|
+
"attempt.resumed",
|
|
81
|
+
"attempt.cancelled",
|
|
82
|
+
"attempt.finished",
|
|
83
|
+
"attempt.lease_expired",
|
|
84
|
+
"approval.requested",
|
|
85
|
+
"approval.resolved",
|
|
86
|
+
"notification.enqueued",
|
|
87
|
+
"notification.delivered",
|
|
88
|
+
];
|
|
89
|
+
function isNonEmptyString(value) {
|
|
90
|
+
return typeof value === "string" && value.length > 0;
|
|
91
|
+
}
|
|
92
|
+
function isJsonValue(value, depth = 0) {
|
|
93
|
+
if (depth > 30)
|
|
94
|
+
return false;
|
|
95
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
96
|
+
return true;
|
|
97
|
+
if (typeof value === "number")
|
|
98
|
+
return Number.isFinite(value);
|
|
99
|
+
if (Array.isArray(value))
|
|
100
|
+
return value.every((entry) => isJsonValue(entry, depth + 1));
|
|
101
|
+
if (!isPlainRecord(value))
|
|
102
|
+
return false;
|
|
103
|
+
return Object.values(value).every((entry) => isJsonValue(entry, depth + 1));
|
|
104
|
+
}
|
|
105
|
+
function includesString(values, value) {
|
|
106
|
+
return typeof value === "string" && values.includes(value);
|
|
107
|
+
}
|
|
108
|
+
export function isHarnessCapability(value) {
|
|
109
|
+
return includesString(HARNESS_CAPABILITIES, value);
|
|
110
|
+
}
|
|
111
|
+
/** Clone a runtime value into the persisted JSON domain, rejecting unsupported or over-deep data. */
|
|
112
|
+
export function toJsonObject(value) {
|
|
113
|
+
if (!isPlainRecord(value) || !isJsonValue(value)) {
|
|
114
|
+
throw new TypeError("Value is not a valid orchestration JSON object.");
|
|
115
|
+
}
|
|
116
|
+
return structuredClone(value);
|
|
117
|
+
}
|
|
118
|
+
export function isOrchestrationEvent(value) {
|
|
119
|
+
if (!isPlainRecord(value))
|
|
120
|
+
return false;
|
|
121
|
+
return (value.schemaVersion === ORCHESTRATION_SCHEMA_VERSION &&
|
|
122
|
+
Number.isSafeInteger(value.ordinal) &&
|
|
123
|
+
Number(value.ordinal) > 0 &&
|
|
124
|
+
isNonEmptyString(value.eventId) &&
|
|
125
|
+
includesString(ORCHESTRATION_EVENT_TYPES, value.type) &&
|
|
126
|
+
isNonEmptyString(value.aggregateId) &&
|
|
127
|
+
includesString(["human", "kernel", "runtime", "policy", "router", "worker"], value.actor) &&
|
|
128
|
+
isNonEmptyString(value.occurredAt) &&
|
|
129
|
+
(value.correlationId === undefined || isNonEmptyString(value.correlationId)) &&
|
|
130
|
+
(value.causationId === undefined || isNonEmptyString(value.causationId)) &&
|
|
131
|
+
(value.idempotencyKey === undefined || isNonEmptyString(value.idempotencyKey)) &&
|
|
132
|
+
isPlainRecord(value.payload) &&
|
|
133
|
+
isJsonValue(value.payload));
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/core/orchestration/contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA0B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,2BAA2B,CAAC;AAEzF;;;;GAIG;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAU,CAAC;AAEvD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,cAAc;IACd,SAAS;IACT,UAAU;IACV,aAAa;IACb,UAAU;IACV,UAAU;IACV,UAAU;CACD,CAAC;AAGX,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC5C,KAAK;IACL,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;IACP,K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CAAC,KAAK,CAAC,OAAO,CAAC,CAC1B,CAAC;AAAA,CACF","sourcesContent":["import type { JsonObject, JsonValue } from \"../autonomy/contracts.ts\";\nimport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\n\nexport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\n\n/**\n * Versioned control-plane contracts. These records are the durable truth exchanged between the\n * deterministic kernel/runtime and replaceable execution-plane workers. They deliberately do not\n * contain callbacks, provider objects, tool implementations, or transcript messages.\n */\n\nexport const ORCHESTRATION_SCHEMA_VERSION = 1 as const;\n\nexport const WORKER_ROLES = [\n\t\"orchestrator\",\n\t\"planner\",\n\t\"explorer\",\n\t\"implementer\",\n\t\"operator\",\n\t\"verifier\",\n\t\"database\",\n] as const;\nexport type WorkerRole = (typeof WORKER_ROLES)[number];\n\nexport const ORCHESTRATION_THINKING_LEVELS = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n\t\"max\",\n\t\"ultra\",\n] as const;\nexport type OrchestrationThinkingLevel = (typeof ORCHESTRATION_THINKING_LEVELS)[number];\n\nexport interface OrchestrationModelBinding {\n\tprovider: string;\n\tmodelId: string;\n\tthinkingLevel: OrchestrationThinkingLevel;\n}\n\nexport interface OrchestrationModelPolicy {\n\tmode: \"fixed\" | \"ordered-fallback\";\n\tcandidates: readonly OrchestrationModelBinding[];\n}\n\n/** Constrained direct-argv launcher policy. This is allowlisting, not OS/container isolation. */\nexport interface OrchestrationExecutionPolicy {\n\tallowedExecutables: readonly string[];\n\tallowedEnvironmentVariables: readonly string[];\n\tmaxOutputBytes: number;\n}\n\nexport const OBJECTIVE_STATUSES = [\"active\", \"paused\", \"completed\", \"cancelled\"] as const;\nexport type ObjectiveStatus = (typeof OBJECTIVE_STATUSES)[number];\n\nexport const TASK_STATUSES = [\"pending\", \"ready\", \"running\", \"blocked\", \"completed\", \"failed\", \"cancelled\"] as const;\nexport type OrchestrationTaskStatus = (typeof TASK_STATUSES)[number];\n\nexport const ATTEMPT_STATUSES = [\n\t\"queued\",\n\t\"leased\",\n\t\"running\",\n\t\"suspended\",\n\t\"completed\",\n\t\"partial\",\n\t\"blocked\",\n\t\"failed\",\n\t\"cancelled\",\n\t\"expired\",\n] as const;\nexport type AttemptStatus = (typeof ATTEMPT_STATUSES)[number];\n\nexport const WORKER_RESULT_STATUSES = [\"completed\", \"partial\", \"blocked\", \"failed\", \"cancelled\"] as const;\nexport type WorkerResultContractStatus = (typeof WORKER_RESULT_STATUSES)[number];\n\nexport type AgentBindingStatus = \"registered\" | \"active\" | \"suspended\" | \"resuming\" | \"retired\";\n\nexport interface AgentResumeContext {\n\tprovider: \"pi\" | \"external\";\n\tsessionId: string;\n\tsessionDir?: string;\n\tsessionFile?: string;\n\tcwd: string;\n\tworktreeLaneKey?: string;\n\torchestrationProfileId?: string;\n\tresourceProfileNames: readonly string[];\n\tmodelRef?: string;\n\tcontextPointers: readonly ResourcePointer[];\n\tlatestCheckpointId?: string;\n}\n\n/** Provider-neutral logical identity shared by durable orchestration and process supervision. */\nexport interface AgentIdentityContract {\n\tagentId: string;\n\tresumeContext: AgentResumeContext;\n}\n\n/** Durable logical identity. A replacement OS process resumes this same binding after interruption. */\nexport interface AgentBindingContract extends AgentIdentityContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\trole: WorkerRole;\n\tstatus: AgentBindingStatus;\n\tactiveAttemptId?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface RiskBudget {\n\tmaxTokens?: number;\n\tmaxWallClockMs?: number;\n\tmaxCostUsd?: number;\n\tmaxAttempts?: number;\n\tmaxToolCalls?: number;\n\trequireApprovalAboveCostUsd?: number;\n}\n\nexport interface AcceptanceCriterion {\n\tid: string;\n\tdescription: string;\n\trequired: boolean;\n\tevaluator?: string;\n}\n\nexport interface ObjectiveContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\tstatus: ObjectiveStatus;\n\tconstraints: readonly string[];\n\tacceptanceCriteria: readonly AcceptanceCriterion[];\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\ttaskId: string;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tstatus: OrchestrationTaskStatus;\n\tdependsOn: readonly string[];\n\trequiredCapabilities: readonly HarnessCapability[];\n\tacceptanceCriterionIds: readonly string[];\n\t/** Implementer task this verifier task must independently reconcile. */\n\tverificationOfTaskId?: string;\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport const RESOURCE_POINTER_KINDS = [\n\t\"repository\",\n\t\"worktree\",\n\t\"artifact\",\n\t\"evidence\",\n\t\"memory-query\",\n\t\"skill\",\n\t\"prompt\",\n\t\"service\",\n] as const;\nexport type ResourcePointerKind = (typeof RESOURCE_POINTER_KINDS)[number];\n\nexport function isResourcePointerKind(value: unknown): value is ResourcePointerKind {\n\treturn RESOURCE_POINTER_KINDS.some((kind) => kind === value);\n}\n\nexport interface ResourcePointer {\n\tid: string;\n\tkind: ResourcePointerKind;\n\turi: string;\n\treadOnly: boolean;\n\tdigest?: string;\n\tmetadata?: JsonObject;\n}\n\n/** Lightweight metadata catalogued without importing the executable tool module. */\nexport interface ToolCapabilityManifest {\n\ttoolName: string;\n\tmoduleSpecifier: string;\n\tcapabilities: readonly HarnessCapability[];\n\troles: readonly WorkerRole[];\n\tenforcements: readonly CapabilityEnforcementKind[];\n\tsourcePath?: string;\n}\n\nexport interface OrchestrationProfile {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofileId: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tmodelPolicy: OrchestrationModelPolicy;\n\tcapabilityCeiling: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\tresourceProfileNames: readonly string[];\n\t/** Worker profiles this orchestrator may dispatch. Empty for non-orchestrator profiles. */\n\tdispatchProfileIds: readonly string[];\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\tbudget: RiskBudget;\n\tmaxConcurrent: number;\n\tleaseTtlMs: number;\n\trequireIndependentVerification: boolean;\n\t/** Owner-pinned verifier profile. Required when independent verification is enabled. */\n\tverificationProfileId?: string;\n\t/** Resolved origin retained for controlled improvements; omitted from authored JSON. */\n\tsourcePath?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** Admission-time worker profile materialization. Profile files are never consulted after this is persisted. */\nexport interface WorkerProfileExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofile: OrchestrationProfile;\n\tmodelBinding: OrchestrationModelBinding;\n\tauthority: WorkerExecutionAuthorityContract;\n\t/** Resolved resource-profile identity text. Other worker resources are represented by profile tools. */\n\tsoul?: string;\n}\n\n/** Effective authority admitted for one materialized worker profile. */\nexport interface WorkerExecutionAuthorityContract {\n\tcapabilities: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n}\n\n/** Immutable execution contract owned by the runtime, including any mandatory verifier. */\nexport interface WorkerExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tworker: WorkerProfileExecutionContract;\n\tverifier?: WorkerProfileExecutionContract;\n}\n\n/** The orchestrator may select only a profile and task; model/thinking fields are intentionally absent. */\nexport interface OrchestrationDispatchRequest {\n\ttaskId: string;\n\tprofileId: string;\n\tinstructions: string;\n\tresourcePointerIds: readonly string[];\n\t/** Execution owner. Omitted on legacy records and normalized to in-process. */\n\texecutionKind?: \"in-process\" | \"managed-process\";\n\t/** Stable external lane identity shared by successive managed-process turns. */\n\tlogicalLaneId?: string;\n\t/** Monotonic dispatch sequence within a managed-process logical lane. */\n\tdispatchSequence?: number;\n\t/** External provider identity retained for routing and diagnostics. */\n\tprovider?: string;\n\t/** Owner approval or standing-grant record that authorized an external launch. */\n\tauthorizationId?: string;\n\t/** Worktree-sync lane claimed by the external dispatcher. */\n\tworktreeLaneKey?: string;\n\t/** Runtime-owned immutable worker materialization. Never accepted from a model tool call. */\n\texecutionContract?: WorkerExecutionContract;\n}\n\nexport type CapabilityEnforcementKind =\n\t| \"path-scope\"\n\t| \"process-launcher\"\n\t| \"service-proxy\"\n\t| \"memory-broker\"\n\t| \"control-plane\";\n\nexport interface CapabilityDecision {\n\tcapability: HarnessCapability;\n\toutcome: \"allow\" | \"deny\";\n\treasonCode: string;\n\tsource: string;\n}\n\nexport interface ExecutionGrant {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tgrantId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tsubjectId: string;\n\trole: WorkerRole;\n\tcapabilities: readonly HarnessCapability[];\n\tallowedTools: readonly string[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n\tpolicyVersion: string;\n\tdecisionTrace: readonly CapabilityDecision[];\n\tissuedAt: string;\n\texpiresAt?: string;\n}\n\nexport interface AttemptLease {\n\tleaseId: string;\n\tattemptId: string;\n\townerId: string;\n\tfencingToken: number;\n\tissuedAt: string;\n\texpiresAt: string;\n}\n\nexport interface AttemptCheckpoint {\n\tcheckpointId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\tsummary: string;\n\tartifactIds: readonly string[];\n\tevidenceIds: readonly string[];\n\tcreatedAt: string;\n}\n\nexport interface ArtifactContract {\n\tartifactId: string;\n\tkind: \"diff\" | \"file\" | \"report\" | \"test-result\" | \"log\" | \"structured-data\";\n\turi: string;\n\tdigest?: string;\n\tsizeBytes?: number;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface EvidenceContract {\n\tevidenceId: string;\n\tcriterionId?: string;\n\tkind: \"observation\" | \"command\" | \"test\" | \"review\" | \"external\";\n\tsummary: string;\n\tartifactIds: readonly string[];\n\ttrusted: boolean;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface WorkerErrorContract {\n\tcode: string;\n\tmessage: string;\n\tretryable: boolean;\n\tdetails?: JsonObject;\n}\n\nexport interface WorkerUsageContract {\n\tinputTokens?: number;\n\toutputTokens?: number;\n\ttotalTokens?: number;\n\tcostUsd?: number;\n\twallClockMs: number;\n\ttoolCalls: number;\n}\n\nexport interface WorkerResultContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tresultId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\tstatus: WorkerResultContractStatus;\n\treasonCode: string;\n\tsummary: string;\n\tartifacts: readonly ArtifactContract[];\n\tevidence: readonly EvidenceContract[];\n\terrors: readonly WorkerErrorContract[];\n\tnextAction?: string;\n\tusage: WorkerUsageContract;\n\tcreatedAt: string;\n}\n\nexport interface ApprovalRequestContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\tobjectiveId: string;\n\ttaskId?: string;\n\tattemptId?: string;\n\treasonCode: string;\n\tsummary: string;\n\trequestedCapabilities: readonly HarnessCapability[];\n\trequestedBudget?: RiskBudget;\n\treversible: boolean;\n\tcreatedAt: string;\n}\n\nexport const APPROVAL_OUTCOMES = [\"approved\", \"rejected\"] as const;\nexport type ApprovalOutcome = (typeof APPROVAL_OUTCOMES)[number];\n\n/** Human decision only. Approval is not an execution grant; policy must compile a new grant afterward. */\nexport interface ApprovalResolutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\toutcome: ApprovalOutcome;\n\treasonCode: string;\n\tresolvedAt: string;\n}\n\nexport const ORCHESTRATION_EVENT_TYPES = [\n\t\"objective.created\",\n\t\"objective.updated\",\n\t\"objective.evidence_recorded\",\n\t\"objective.paused\",\n\t\"objective.resumed\",\n\t\"objective.completed\",\n\t\"objective.cancelled\",\n\t\"task.created\",\n\t\"task.ready\",\n\t\"task.failed\",\n\t\"task.verification_finished\",\n\t\"agent.registered\",\n\t\"agent.suspended\",\n\t\"agent.resume_requested\",\n\t\"agent.resumed\",\n\t\"attempt.queued\",\n\t\"attempt.grant_bound\",\n\t\"attempt.leased\",\n\t\"attempt.started\",\n\t\"attempt.checkpointed\",\n\t\"attempt.suspended\",\n\t\"attempt.resumed\",\n\t\"attempt.cancelled\",\n\t\"attempt.finished\",\n\t\"attempt.lease_expired\",\n\t\"approval.requested\",\n\t\"approval.resolved\",\n\t\"notification.enqueued\",\n\t\"notification.delivered\",\n] as const;\n\nexport type OrchestrationEventType = (typeof ORCHESTRATION_EVENT_TYPES)[number];\nexport type OrchestrationActorKind = \"human\" | \"kernel\" | \"runtime\" | \"policy\" | \"router\" | \"worker\";\n\nexport interface OrchestrationEvent {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tordinal: number;\n\teventId: string;\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\toccurredAt: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nexport interface AppendOrchestrationEventInput {\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n\treturn typeof value === \"string\" && value.length > 0;\n}\n\nfunction isJsonValue(value: unknown, depth = 0): value is JsonValue {\n\tif (depth > 30) return false;\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every((entry) => isJsonValue(entry, depth + 1));\n\tif (!isPlainRecord(value)) return false;\n\treturn Object.values(value).every((entry) => isJsonValue(entry, depth + 1));\n}\n\nfunction includesString<const T extends readonly string[]>(values: T, value: unknown): value is T[number] {\n\treturn typeof value === \"string\" && values.includes(value);\n}\n\nexport function isHarnessCapability(value: unknown): value is HarnessCapability {\n\treturn includesString(HARNESS_CAPABILITIES, value);\n}\n\n/** Clone a runtime value into the persisted JSON domain, rejecting unsupported or over-deep data. */\nexport function toJsonObject(value: unknown): JsonObject {\n\tif (!isPlainRecord(value) || !isJsonValue(value)) {\n\t\tthrow new TypeError(\"Value is not a valid orchestration JSON object.\");\n\t}\n\treturn structuredClone(value);\n}\n\nexport function isOrchestrationEvent(value: unknown): value is OrchestrationEvent {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\tvalue.schemaVersion === ORCHESTRATION_SCHEMA_VERSION &&\n\t\tNumber.isSafeInteger(value.ordinal) &&\n\t\tNumber(value.ordinal) > 0 &&\n\t\tisNonEmptyString(value.eventId) &&\n\t\tincludesString(ORCHESTRATION_EVENT_TYPES, value.type) &&\n\t\tisNonEmptyString(value.aggregateId) &&\n\t\tincludesString([\"human\", \"kernel\", \"runtime\", \"policy\", \"router\", \"worker\"] as const, value.actor) &&\n\t\tisNonEmptyString(value.occurredAt) &&\n\t\t(value.correlationId === undefined || isNonEmptyString(value.correlationId)) &&\n\t\t(value.causationId === undefined || isNonEmptyString(value.causationId)) &&\n\t\t(value.idempotencyKey === undefined || isNonEmptyString(value.idempotencyKey)) &&\n\t\tisPlainRecord(value.payload) &&\n\t\tisJsonValue(value.payload)\n\t);\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { GoalState } from "../goals/goal-state.ts";
|
|
2
|
+
import type { HarnessCapability, RiskBudget, WorkerExecutionContract, WorkerRole } from "./contracts.ts";
|
|
3
|
+
import { type AttemptRuntimeState, DurableTaskRuntime } from "./task-runtime.ts";
|
|
4
|
+
export interface DelegationLedgerOptions {
|
|
5
|
+
agentDir: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
now?: () => number;
|
|
8
|
+
}
|
|
9
|
+
export interface PrepareDelegationInput {
|
|
10
|
+
laneId: string;
|
|
11
|
+
instructions: string;
|
|
12
|
+
executionContract: WorkerExecutionContract;
|
|
13
|
+
requiredCapabilities: readonly HarnessCapability[];
|
|
14
|
+
goal?: GoalState;
|
|
15
|
+
verificationOfTaskId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface PrepareManagedDelegationInput {
|
|
18
|
+
laneId: string;
|
|
19
|
+
dispatchSequence: number;
|
|
20
|
+
instructions: string;
|
|
21
|
+
profileId: string;
|
|
22
|
+
provider: string;
|
|
23
|
+
authorizationId: string;
|
|
24
|
+
role: WorkerRole;
|
|
25
|
+
riskBudget: RiskBudget;
|
|
26
|
+
goal?: GoalState;
|
|
27
|
+
goalId?: string;
|
|
28
|
+
worktreeLaneKey?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface StartedDelegationAttempt {
|
|
31
|
+
objectiveId: string;
|
|
32
|
+
taskId: string;
|
|
33
|
+
attemptId: string;
|
|
34
|
+
leaseId: string;
|
|
35
|
+
fencingToken: number;
|
|
36
|
+
expiresAt: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Durable adapter for in-process delegated completions. It records the dispatch before execution,
|
|
40
|
+
* fences interrupted completions on restart, and returns queued work for event-driven re-dispatch.
|
|
41
|
+
* It deliberately does not pretend an isolated completion has a resumable model transcript.
|
|
42
|
+
*/
|
|
43
|
+
export declare class DelegationOrchestrationLedger {
|
|
44
|
+
readonly runtime: DurableTaskRuntime;
|
|
45
|
+
private readonly sessionId;
|
|
46
|
+
constructor(options: DelegationLedgerOptions);
|
|
47
|
+
prepare(input: PrepareDelegationInput): AttemptRuntimeState;
|
|
48
|
+
prepareManaged(input: PrepareManagedDelegationInput): AttemptRuntimeState;
|
|
49
|
+
private prepareNormalized;
|
|
50
|
+
synchronizeGoalState(goal: GoalState): void;
|
|
51
|
+
start(attemptId: string, leaseTtlMs: number, ownerId?: string): StartedDelegationAttempt;
|
|
52
|
+
cancel(attemptId: string, reasonCode: string): void;
|
|
53
|
+
/** Fence interrupted isolated completions and queue one replacement attempt per task. */
|
|
54
|
+
recoverQueuedDispatches(): AttemptRuntimeState[];
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=delegation-ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation-ledger.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/delegation-ledger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EACX,iBAAiB,EAEjB,UAAU,EACV,uBAAuB,EACvB,UAAU,EACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,mBAAmB,EAAE,kBAAkB,EAA2B,MAAM,mBAAmB,CAAC;AAG1G,MAAM,WAAW,uBAAuB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,oBAAoB,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACnD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,6BAA6B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,wBAAwB;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CAClB;AAMD;;;;GAIG;AACH,qBAAa,6BAA6B;IACzC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC,YAAY,OAAO,EAAE,uBAAuB,EAM3C;IAED,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,mBAAmB,CAa1D;IAED,cAAc,CAAC,KAAK,EAAE,6BAA6B,GAAG,mBAAmB,CAuBxE;IAED,OAAO,CAAC,iBAAiB;IAgFzB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAuB1C;IAED,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,SAAiC,GAAG,wBAAwB,CAgB/G;IAED,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAElD;IAED,yFAAyF;IACzF,uBAAuB,IAAI,mBAAmB,EAAE,CAoB/C;CACD","sourcesContent":["import { deriveWorkerTaskLabel } from \"../delegation/worker-task-label.ts\";\nimport { hasGoalAcceptanceOverride } from \"../goals/goal-acceptance.ts\";\nimport type { GoalState } from \"../goals/goal-state.ts\";\nimport type {\n\tHarnessCapability,\n\tOrchestrationDispatchRequest,\n\tRiskBudget,\n\tWorkerExecutionContract,\n\tWorkerRole,\n} from \"./contracts.ts\";\nimport { OrchestrationEventStore } from \"./event-store.ts\";\nimport { type AttemptRuntimeState, DurableTaskRuntime, DurableTaskRuntimeError } from \"./task-runtime.ts\";\nimport { goalObjectiveId, projectGoalAcceptanceEvidence, projectGoalObjective } from \"./work-state-projection.ts\";\n\nexport interface DelegationLedgerOptions {\n\tagentDir: string;\n\tsessionId: string;\n\tnow?: () => number;\n}\n\nexport interface PrepareDelegationInput {\n\tlaneId: string;\n\tinstructions: string;\n\texecutionContract: WorkerExecutionContract;\n\trequiredCapabilities: readonly HarnessCapability[];\n\tgoal?: GoalState;\n\tverificationOfTaskId?: string;\n}\n\nexport interface PrepareManagedDelegationInput {\n\tlaneId: string;\n\tdispatchSequence: number;\n\tinstructions: string;\n\tprofileId: string;\n\tprovider: string;\n\tauthorizationId: string;\n\trole: WorkerRole;\n\triskBudget: RiskBudget;\n\tgoal?: GoalState;\n\tgoalId?: string;\n\tworktreeLaneKey?: string;\n}\n\nexport interface StartedDelegationAttempt {\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\texpiresAt: string;\n}\n\nfunction activeAttempt(attempt: AttemptRuntimeState): boolean {\n\treturn attempt.status === \"queued\" || attempt.status === \"leased\" || attempt.status === \"running\";\n}\n\n/**\n * Durable adapter for in-process delegated completions. It records the dispatch before execution,\n * fences interrupted completions on restart, and returns queued work for event-driven re-dispatch.\n * It deliberately does not pretend an isolated completion has a resumable model transcript.\n */\nexport class DelegationOrchestrationLedger {\n\treadonly runtime: DurableTaskRuntime;\n\tprivate readonly sessionId: string;\n\n\tconstructor(options: DelegationLedgerOptions) {\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.runtime = new DurableTaskRuntime({\n\t\t\tstore: new OrchestrationEventStore({ agentDir: options.agentDir, sessionId: options.sessionId }),\n\t\t\tnow: options.now,\n\t\t});\n\t}\n\n\tprepare(input: PrepareDelegationInput): AttemptRuntimeState {\n\t\tconst profile = input.executionContract.worker.profile;\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: input.laneId,\n\t\t\tinstructions: input.instructions,\n\t\t\tprofileId: profile.profileId,\n\t\t\trole: profile.role,\n\t\t\trequiredCapabilities: input.requiredCapabilities,\n\t\t\triskBudget: profile.budget,\n\t\t\texecutionContract: input.executionContract,\n\t\t\t...(input.goal ? { goal: input.goal } : {}),\n\t\t\t...(input.verificationOfTaskId ? { verificationOfTaskId: input.verificationOfTaskId } : {}),\n\t\t});\n\t}\n\n\tprepareManaged(input: PrepareManagedDelegationInput): AttemptRuntimeState {\n\t\tif (!Number.isSafeInteger(input.dispatchSequence) || input.dispatchSequence < 1) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Managed dispatch sequence must be a positive integer.\");\n\t\t}\n\t\tconst taskId = `${input.laneId}:turn:${input.dispatchSequence}`;\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: taskId,\n\t\t\tinstructions: input.instructions,\n\t\t\tprofileId: input.profileId,\n\t\t\trole: input.role,\n\t\t\trequiredCapabilities: [],\n\t\t\triskBudget: input.riskBudget,\n\t\t\t...(input.goal ? { goal: input.goal } : {}),\n\t\t\t...(input.goalId ? { goalId: input.goalId } : {}),\n\t\t\tdispatchMetadata: {\n\t\t\t\texecutionKind: \"managed-process\",\n\t\t\t\tlogicalLaneId: input.laneId,\n\t\t\t\tdispatchSequence: input.dispatchSequence,\n\t\t\t\tprovider: input.provider,\n\t\t\t\tauthorizationId: input.authorizationId,\n\t\t\t\t...(input.worktreeLaneKey ? { worktreeLaneKey: input.worktreeLaneKey } : {}),\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate prepareNormalized(input: {\n\t\tlaneId: string;\n\t\tinstructions: string;\n\t\tprofileId: string;\n\t\trole: WorkerRole;\n\t\trequiredCapabilities: readonly HarnessCapability[];\n\t\triskBudget: RiskBudget;\n\t\tgoal?: GoalState;\n\t\tgoalId?: string;\n\t\tverificationOfTaskId?: string;\n\t\texecutionContract?: WorkerExecutionContract;\n\t\tdispatchMetadata?: Pick<\n\t\t\tOrchestrationDispatchRequest,\n\t\t\t\"executionKind\" | \"logicalLaneId\" | \"dispatchSequence\" | \"provider\" | \"authorizationId\" | \"worktreeLaneKey\"\n\t\t>;\n\t}): AttemptRuntimeState {\n\t\tlet snapshot = this.runtime.getSnapshot();\n\t\tconst existingVerificationSubject = input.verificationOfTaskId\n\t\t\t? snapshot.tasks[input.verificationOfTaskId]\n\t\t\t: undefined;\n\t\tif (input.verificationOfTaskId && !existingVerificationSubject) {\n\t\t\tthrow new DurableTaskRuntimeError(`Unknown verification subject '${input.verificationOfTaskId}'.`);\n\t\t}\n\t\tconst projectedGoal = input.goal ? projectGoalObjective(input.goal) : undefined;\n\t\tconst objectiveId =\n\t\t\texistingVerificationSubject?.task.objectiveId ??\n\t\t\tprojectedGoal?.objectiveId ??\n\t\t\t(input.goalId ? goalObjectiveId(input.goalId) : `session:${this.sessionId}`);\n\t\tif (input.goal && objectiveId === projectedGoal?.objectiveId) {\n\t\t\tthis.synchronizeGoalState(input.goal);\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t} else if (!snapshot.objectives[objectiveId]) {\n\t\t\tthis.runtime.createObjective({\n\t\t\t\tobjectiveId,\n\t\t\t\ttitle: input.goalId ? `Goal ${input.goalId}` : `Session ${this.sessionId}`,\n\t\t\t\tdescription: input.goalId ? \"Externally managed goal work\" : \"Session-scoped delegated work\",\n\t\t\t});\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\n\t\tif (!snapshot.tasks[input.laneId]) {\n\t\t\tconst verificationSubject = input.verificationOfTaskId\n\t\t\t\t? snapshot.tasks[input.verificationOfTaskId]\n\t\t\t\t: undefined;\n\t\t\tthis.runtime.createTask({\n\t\t\t\ttaskId: input.laneId,\n\t\t\t\tobjectiveId,\n\t\t\t\ttitle: deriveWorkerTaskLabel(input.instructions, `Delegated ${input.role} work`),\n\t\t\t\tdescription: input.instructions,\n\t\t\t\trole: input.role,\n\t\t\t\trequiredCapabilities: input.requiredCapabilities,\n\t\t\t\triskBudget: input.riskBudget,\n\t\t\t\t...(input.verificationOfTaskId\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tverificationOfTaskId: input.verificationOfTaskId,\n\t\t\t\t\t\t\tacceptanceCriterionIds: verificationSubject?.task.acceptanceCriterionIds ?? [],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\n\t\tconst task = snapshot.tasks[input.laneId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Failed to create task '${input.laneId}'.`);\n\t\tconst existing = [...task.attemptIds]\n\t\t\t.reverse()\n\t\t\t.map((attemptId) => snapshot.attempts[attemptId])\n\t\t\t.find((attempt): attempt is AttemptRuntimeState => attempt !== undefined && activeAttempt(attempt));\n\t\tif (existing) return existing;\n\n\t\treturn this.runtime.queueAttempt(input.laneId, {\n\t\t\ttaskId: input.laneId,\n\t\t\tprofileId: input.profileId,\n\t\t\tinstructions: input.instructions,\n\t\t\tresourcePointerIds: [],\n\t\t\t...(input.executionContract ? { executionContract: input.executionContract } : {}),\n\t\t\t...input.dispatchMetadata,\n\t\t});\n\t}\n\n\tsynchronizeGoalState(goal: GoalState): void {\n\t\tconst objective = projectGoalObjective(goal);\n\t\tthis.runtime.ensureObjective(objective);\n\t\tfor (const evidence of projectGoalAcceptanceEvidence(goal)) {\n\t\t\tthis.runtime.recordObjectiveEvidence(objective.objectiveId, evidence);\n\t\t}\n\t\tconst status = this.runtime.getSnapshot().objectives[goalObjectiveId(goal.goalId)]?.objective.status;\n\t\tswitch (goal.status) {\n\t\t\tcase \"active\":\n\t\t\t\tif (status === \"paused\") this.runtime.resumeObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"blocked\":\n\t\t\t\tif (status === \"active\") this.runtime.pauseObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"cancelled\":\n\t\t\t\tif (status !== \"cancelled\") this.runtime.cancelObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"completed\":\n\t\t\t\tif (status !== \"completed\") {\n\t\t\t\t\tthis.runtime.completeObjectiveFromOwner(objective.objectiveId, hasGoalAcceptanceOverride(goal));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tstart(attemptId: string, leaseTtlMs: number, ownerId = `in-process:${this.sessionId}`): StartedDelegationAttempt {\n\t\tconst snapshot = this.runtime.getSnapshot();\n\t\tconst attempt = snapshot.attempts[attemptId];\n\t\tif (!attempt) throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);\n\t\tconst task = snapshot.tasks[attempt.taskId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Unknown task '${attempt.taskId}'.`);\n\t\tconst lease = this.runtime.leaseAttempt(attemptId, ownerId, leaseTtlMs);\n\t\tthis.runtime.startAttempt(attemptId, lease.leaseId, lease.fencingToken);\n\t\treturn {\n\t\t\tobjectiveId: task.task.objectiveId,\n\t\t\ttaskId: task.task.taskId,\n\t\t\tattemptId,\n\t\t\tleaseId: lease.leaseId,\n\t\t\tfencingToken: lease.fencingToken,\n\t\t\texpiresAt: lease.expiresAt,\n\t\t};\n\t}\n\n\tcancel(attemptId: string, reasonCode: string): void {\n\t\tthis.runtime.cancelAttempt(attemptId, reasonCode);\n\t}\n\n\t/** Fence interrupted isolated completions and queue one replacement attempt per task. */\n\trecoverQueuedDispatches(): AttemptRuntimeState[] {\n\t\tthis.runtime.recoverInterruptedUnboundAttempts((attempt) => attempt.dispatch.executionKind !== \"managed-process\");\n\t\tlet snapshot = this.runtime.getSnapshot();\n\t\tfor (const task of Object.values(snapshot.tasks)) {\n\t\t\tconst attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);\n\t\t\tif (attempts.some((attempt) => attempt && activeAttempt(attempt))) continue;\n\t\t\tconst interrupted = [...attempts].reverse().find((attempt) => attempt?.status === \"expired\");\n\t\t\tif (!interrupted || task.task.status !== \"ready\") continue;\n\t\t\tconst maxAttempts = task.task.riskBudget.maxAttempts;\n\t\t\tif (maxAttempts !== undefined && task.attemptIds.length >= maxAttempts) {\n\t\t\t\tthis.runtime.failTask(task.task.taskId, \"attempt_budget_exhausted\");\n\t\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.runtime.queueAttempt(task.task.taskId, interrupted.dispatch);\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\t\treturn Object.values(snapshot.attempts).filter(\n\t\t\t(attempt) => attempt.status === \"queued\" && attempt.dispatch.executionKind !== \"managed-process\",\n\t\t);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { deriveWorkerTaskLabel } from "../delegation/worker-task-label.js";
|
|
2
|
+
import { hasGoalAcceptanceOverride } from "../goals/goal-acceptance.js";
|
|
3
|
+
import { OrchestrationEventStore } from "./event-store.js";
|
|
4
|
+
import { DurableTaskRuntime, DurableTaskRuntimeError } from "./task-runtime.js";
|
|
5
|
+
import { goalObjectiveId, projectGoalAcceptanceEvidence, projectGoalObjective } from "./work-state-projection.js";
|
|
6
|
+
function activeAttempt(attempt) {
|
|
7
|
+
return attempt.status === "queued" || attempt.status === "leased" || attempt.status === "running";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Durable adapter for in-process delegated completions. It records the dispatch before execution,
|
|
11
|
+
* fences interrupted completions on restart, and returns queued work for event-driven re-dispatch.
|
|
12
|
+
* It deliberately does not pretend an isolated completion has a resumable model transcript.
|
|
13
|
+
*/
|
|
14
|
+
export class DelegationOrchestrationLedger {
|
|
15
|
+
runtime;
|
|
16
|
+
sessionId;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.sessionId = options.sessionId;
|
|
19
|
+
this.runtime = new DurableTaskRuntime({
|
|
20
|
+
store: new OrchestrationEventStore({ agentDir: options.agentDir, sessionId: options.sessionId }),
|
|
21
|
+
now: options.now,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
prepare(input) {
|
|
25
|
+
const profile = input.executionContract.worker.profile;
|
|
26
|
+
return this.prepareNormalized({
|
|
27
|
+
laneId: input.laneId,
|
|
28
|
+
instructions: input.instructions,
|
|
29
|
+
profileId: profile.profileId,
|
|
30
|
+
role: profile.role,
|
|
31
|
+
requiredCapabilities: input.requiredCapabilities,
|
|
32
|
+
riskBudget: profile.budget,
|
|
33
|
+
executionContract: input.executionContract,
|
|
34
|
+
...(input.goal ? { goal: input.goal } : {}),
|
|
35
|
+
...(input.verificationOfTaskId ? { verificationOfTaskId: input.verificationOfTaskId } : {}),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
prepareManaged(input) {
|
|
39
|
+
if (!Number.isSafeInteger(input.dispatchSequence) || input.dispatchSequence < 1) {
|
|
40
|
+
throw new DurableTaskRuntimeError("Managed dispatch sequence must be a positive integer.");
|
|
41
|
+
}
|
|
42
|
+
const taskId = `${input.laneId}:turn:${input.dispatchSequence}`;
|
|
43
|
+
return this.prepareNormalized({
|
|
44
|
+
laneId: taskId,
|
|
45
|
+
instructions: input.instructions,
|
|
46
|
+
profileId: input.profileId,
|
|
47
|
+
role: input.role,
|
|
48
|
+
requiredCapabilities: [],
|
|
49
|
+
riskBudget: input.riskBudget,
|
|
50
|
+
...(input.goal ? { goal: input.goal } : {}),
|
|
51
|
+
...(input.goalId ? { goalId: input.goalId } : {}),
|
|
52
|
+
dispatchMetadata: {
|
|
53
|
+
executionKind: "managed-process",
|
|
54
|
+
logicalLaneId: input.laneId,
|
|
55
|
+
dispatchSequence: input.dispatchSequence,
|
|
56
|
+
provider: input.provider,
|
|
57
|
+
authorizationId: input.authorizationId,
|
|
58
|
+
...(input.worktreeLaneKey ? { worktreeLaneKey: input.worktreeLaneKey } : {}),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
prepareNormalized(input) {
|
|
63
|
+
let snapshot = this.runtime.getSnapshot();
|
|
64
|
+
const existingVerificationSubject = input.verificationOfTaskId
|
|
65
|
+
? snapshot.tasks[input.verificationOfTaskId]
|
|
66
|
+
: undefined;
|
|
67
|
+
if (input.verificationOfTaskId && !existingVerificationSubject) {
|
|
68
|
+
throw new DurableTaskRuntimeError(`Unknown verification subject '${input.verificationOfTaskId}'.`);
|
|
69
|
+
}
|
|
70
|
+
const projectedGoal = input.goal ? projectGoalObjective(input.goal) : undefined;
|
|
71
|
+
const objectiveId = existingVerificationSubject?.task.objectiveId ??
|
|
72
|
+
projectedGoal?.objectiveId ??
|
|
73
|
+
(input.goalId ? goalObjectiveId(input.goalId) : `session:${this.sessionId}`);
|
|
74
|
+
if (input.goal && objectiveId === projectedGoal?.objectiveId) {
|
|
75
|
+
this.synchronizeGoalState(input.goal);
|
|
76
|
+
snapshot = this.runtime.getSnapshot();
|
|
77
|
+
}
|
|
78
|
+
else if (!snapshot.objectives[objectiveId]) {
|
|
79
|
+
this.runtime.createObjective({
|
|
80
|
+
objectiveId,
|
|
81
|
+
title: input.goalId ? `Goal ${input.goalId}` : `Session ${this.sessionId}`,
|
|
82
|
+
description: input.goalId ? "Externally managed goal work" : "Session-scoped delegated work",
|
|
83
|
+
});
|
|
84
|
+
snapshot = this.runtime.getSnapshot();
|
|
85
|
+
}
|
|
86
|
+
if (!snapshot.tasks[input.laneId]) {
|
|
87
|
+
const verificationSubject = input.verificationOfTaskId
|
|
88
|
+
? snapshot.tasks[input.verificationOfTaskId]
|
|
89
|
+
: undefined;
|
|
90
|
+
this.runtime.createTask({
|
|
91
|
+
taskId: input.laneId,
|
|
92
|
+
objectiveId,
|
|
93
|
+
title: deriveWorkerTaskLabel(input.instructions, `Delegated ${input.role} work`),
|
|
94
|
+
description: input.instructions,
|
|
95
|
+
role: input.role,
|
|
96
|
+
requiredCapabilities: input.requiredCapabilities,
|
|
97
|
+
riskBudget: input.riskBudget,
|
|
98
|
+
...(input.verificationOfTaskId
|
|
99
|
+
? {
|
|
100
|
+
verificationOfTaskId: input.verificationOfTaskId,
|
|
101
|
+
acceptanceCriterionIds: verificationSubject?.task.acceptanceCriterionIds ?? [],
|
|
102
|
+
}
|
|
103
|
+
: {}),
|
|
104
|
+
});
|
|
105
|
+
snapshot = this.runtime.getSnapshot();
|
|
106
|
+
}
|
|
107
|
+
const task = snapshot.tasks[input.laneId];
|
|
108
|
+
if (!task)
|
|
109
|
+
throw new DurableTaskRuntimeError(`Failed to create task '${input.laneId}'.`);
|
|
110
|
+
const existing = [...task.attemptIds]
|
|
111
|
+
.reverse()
|
|
112
|
+
.map((attemptId) => snapshot.attempts[attemptId])
|
|
113
|
+
.find((attempt) => attempt !== undefined && activeAttempt(attempt));
|
|
114
|
+
if (existing)
|
|
115
|
+
return existing;
|
|
116
|
+
return this.runtime.queueAttempt(input.laneId, {
|
|
117
|
+
taskId: input.laneId,
|
|
118
|
+
profileId: input.profileId,
|
|
119
|
+
instructions: input.instructions,
|
|
120
|
+
resourcePointerIds: [],
|
|
121
|
+
...(input.executionContract ? { executionContract: input.executionContract } : {}),
|
|
122
|
+
...input.dispatchMetadata,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
synchronizeGoalState(goal) {
|
|
126
|
+
const objective = projectGoalObjective(goal);
|
|
127
|
+
this.runtime.ensureObjective(objective);
|
|
128
|
+
for (const evidence of projectGoalAcceptanceEvidence(goal)) {
|
|
129
|
+
this.runtime.recordObjectiveEvidence(objective.objectiveId, evidence);
|
|
130
|
+
}
|
|
131
|
+
const status = this.runtime.getSnapshot().objectives[goalObjectiveId(goal.goalId)]?.objective.status;
|
|
132
|
+
switch (goal.status) {
|
|
133
|
+
case "active":
|
|
134
|
+
if (status === "paused")
|
|
135
|
+
this.runtime.resumeObjective(objective.objectiveId);
|
|
136
|
+
break;
|
|
137
|
+
case "blocked":
|
|
138
|
+
if (status === "active")
|
|
139
|
+
this.runtime.pauseObjective(objective.objectiveId);
|
|
140
|
+
break;
|
|
141
|
+
case "cancelled":
|
|
142
|
+
if (status !== "cancelled")
|
|
143
|
+
this.runtime.cancelObjective(objective.objectiveId);
|
|
144
|
+
break;
|
|
145
|
+
case "completed":
|
|
146
|
+
if (status !== "completed") {
|
|
147
|
+
this.runtime.completeObjectiveFromOwner(objective.objectiveId, hasGoalAcceptanceOverride(goal));
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
start(attemptId, leaseTtlMs, ownerId = `in-process:${this.sessionId}`) {
|
|
153
|
+
const snapshot = this.runtime.getSnapshot();
|
|
154
|
+
const attempt = snapshot.attempts[attemptId];
|
|
155
|
+
if (!attempt)
|
|
156
|
+
throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);
|
|
157
|
+
const task = snapshot.tasks[attempt.taskId];
|
|
158
|
+
if (!task)
|
|
159
|
+
throw new DurableTaskRuntimeError(`Unknown task '${attempt.taskId}'.`);
|
|
160
|
+
const lease = this.runtime.leaseAttempt(attemptId, ownerId, leaseTtlMs);
|
|
161
|
+
this.runtime.startAttempt(attemptId, lease.leaseId, lease.fencingToken);
|
|
162
|
+
return {
|
|
163
|
+
objectiveId: task.task.objectiveId,
|
|
164
|
+
taskId: task.task.taskId,
|
|
165
|
+
attemptId,
|
|
166
|
+
leaseId: lease.leaseId,
|
|
167
|
+
fencingToken: lease.fencingToken,
|
|
168
|
+
expiresAt: lease.expiresAt,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
cancel(attemptId, reasonCode) {
|
|
172
|
+
this.runtime.cancelAttempt(attemptId, reasonCode);
|
|
173
|
+
}
|
|
174
|
+
/** Fence interrupted isolated completions and queue one replacement attempt per task. */
|
|
175
|
+
recoverQueuedDispatches() {
|
|
176
|
+
this.runtime.recoverInterruptedUnboundAttempts((attempt) => attempt.dispatch.executionKind !== "managed-process");
|
|
177
|
+
let snapshot = this.runtime.getSnapshot();
|
|
178
|
+
for (const task of Object.values(snapshot.tasks)) {
|
|
179
|
+
const attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);
|
|
180
|
+
if (attempts.some((attempt) => attempt && activeAttempt(attempt)))
|
|
181
|
+
continue;
|
|
182
|
+
const interrupted = [...attempts].reverse().find((attempt) => attempt?.status === "expired");
|
|
183
|
+
if (!interrupted || task.task.status !== "ready")
|
|
184
|
+
continue;
|
|
185
|
+
const maxAttempts = task.task.riskBudget.maxAttempts;
|
|
186
|
+
if (maxAttempts !== undefined && task.attemptIds.length >= maxAttempts) {
|
|
187
|
+
this.runtime.failTask(task.task.taskId, "attempt_budget_exhausted");
|
|
188
|
+
snapshot = this.runtime.getSnapshot();
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
this.runtime.queueAttempt(task.task.taskId, interrupted.dispatch);
|
|
192
|
+
snapshot = this.runtime.getSnapshot();
|
|
193
|
+
}
|
|
194
|
+
return Object.values(snapshot.attempts).filter((attempt) => attempt.status === "queued" && attempt.dispatch.executionKind !== "managed-process");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=delegation-ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation-ledger.js","sourceRoot":"","sources":["../../../src/core/orchestration/delegation-ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AASxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAA4B,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAwClH,SAAS,aAAa,CAAC,OAA4B,EAAW;IAC7D,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAA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AE,SAAS;YAC3D,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;YACrD,IAAI,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,WAAW,EAAE,CAAC;gBACxE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;gBACpE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;gBACtC,SAAS;YACV,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC7C,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,KAAK,iBAAiB,CAChG,CAAC;IAAA,CACF;CACD","sourcesContent":["import { deriveWorkerTaskLabel } from \"../delegation/worker-task-label.ts\";\nimport { hasGoalAcceptanceOverride } from \"../goals/goal-acceptance.ts\";\nimport type { GoalState } from \"../goals/goal-state.ts\";\nimport type {\n\tHarnessCapability,\n\tOrchestrationDispatchRequest,\n\tRiskBudget,\n\tWorkerExecutionContract,\n\tWorkerRole,\n} from \"./contracts.ts\";\nimport { OrchestrationEventStore } from \"./event-store.ts\";\nimport { type AttemptRuntimeState, DurableTaskRuntime, DurableTaskRuntimeError } from \"./task-runtime.ts\";\nimport { goalObjectiveId, projectGoalAcceptanceEvidence, projectGoalObjective } from \"./work-state-projection.ts\";\n\nexport interface DelegationLedgerOptions {\n\tagentDir: string;\n\tsessionId: string;\n\tnow?: () => number;\n}\n\nexport interface PrepareDelegationInput {\n\tlaneId: string;\n\tinstructions: string;\n\texecutionContract: WorkerExecutionContract;\n\trequiredCapabilities: readonly HarnessCapability[];\n\tgoal?: GoalState;\n\tverificationOfTaskId?: string;\n}\n\nexport interface PrepareManagedDelegationInput {\n\tlaneId: string;\n\tdispatchSequence: number;\n\tinstructions: string;\n\tprofileId: string;\n\tprovider: string;\n\tauthorizationId: string;\n\trole: WorkerRole;\n\triskBudget: RiskBudget;\n\tgoal?: GoalState;\n\tgoalId?: string;\n\tworktreeLaneKey?: string;\n}\n\nexport interface StartedDelegationAttempt {\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\texpiresAt: string;\n}\n\nfunction activeAttempt(attempt: AttemptRuntimeState): boolean {\n\treturn attempt.status === \"queued\" || attempt.status === \"leased\" || attempt.status === \"running\";\n}\n\n/**\n * Durable adapter for in-process delegated completions. It records the dispatch before execution,\n * fences interrupted completions on restart, and returns queued work for event-driven re-dispatch.\n * It deliberately does not pretend an isolated completion has a resumable model transcript.\n */\nexport class DelegationOrchestrationLedger {\n\treadonly runtime: DurableTaskRuntime;\n\tprivate readonly sessionId: string;\n\n\tconstructor(options: DelegationLedgerOptions) {\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.runtime = new DurableTaskRuntime({\n\t\t\tstore: new OrchestrationEventStore({ agentDir: options.agentDir, sessionId: options.sessionId }),\n\t\t\tnow: options.now,\n\t\t});\n\t}\n\n\tprepare(input: PrepareDelegationInput): AttemptRuntimeState {\n\t\tconst profile = input.executionContract.worker.profile;\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: input.laneId,\n\t\t\tinstructions: input.instructions,\n\t\t\tprofileId: profile.profileId,\n\t\t\trole: profile.role,\n\t\t\trequiredCapabilities: input.requiredCapabilities,\n\t\t\triskBudget: profile.budget,\n\t\t\texecutionContract: input.executionContract,\n\t\t\t...(input.goal ? { goal: input.goal } : {}),\n\t\t\t...(input.verificationOfTaskId ? { verificationOfTaskId: input.verificationOfTaskId } : {}),\n\t\t});\n\t}\n\n\tprepareManaged(input: PrepareManagedDelegationInput): AttemptRuntimeState {\n\t\tif (!Number.isSafeInteger(input.dispatchSequence) || input.dispatchSequence < 1) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Managed dispatch sequence must be a positive integer.\");\n\t\t}\n\t\tconst taskId = `${input.laneId}:turn:${input.dispatchSequence}`;\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: taskId,\n\t\t\tinstructions: input.instructions,\n\t\t\tprofileId: input.profileId,\n\t\t\trole: input.role,\n\t\t\trequiredCapabilities: [],\n\t\t\triskBudget: input.riskBudget,\n\t\t\t...(input.goal ? { goal: input.goal } : {}),\n\t\t\t...(input.goalId ? { goalId: input.goalId } : {}),\n\t\t\tdispatchMetadata: {\n\t\t\t\texecutionKind: \"managed-process\",\n\t\t\t\tlogicalLaneId: input.laneId,\n\t\t\t\tdispatchSequence: input.dispatchSequence,\n\t\t\t\tprovider: input.provider,\n\t\t\t\tauthorizationId: input.authorizationId,\n\t\t\t\t...(input.worktreeLaneKey ? { worktreeLaneKey: input.worktreeLaneKey } : {}),\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate prepareNormalized(input: {\n\t\tlaneId: string;\n\t\tinstructions: string;\n\t\tprofileId: string;\n\t\trole: WorkerRole;\n\t\trequiredCapabilities: readonly HarnessCapability[];\n\t\triskBudget: RiskBudget;\n\t\tgoal?: GoalState;\n\t\tgoalId?: string;\n\t\tverificationOfTaskId?: string;\n\t\texecutionContract?: WorkerExecutionContract;\n\t\tdispatchMetadata?: Pick<\n\t\t\tOrchestrationDispatchRequest,\n\t\t\t\"executionKind\" | \"logicalLaneId\" | \"dispatchSequence\" | \"provider\" | \"authorizationId\" | \"worktreeLaneKey\"\n\t\t>;\n\t}): AttemptRuntimeState {\n\t\tlet snapshot = this.runtime.getSnapshot();\n\t\tconst existingVerificationSubject = input.verificationOfTaskId\n\t\t\t? snapshot.tasks[input.verificationOfTaskId]\n\t\t\t: undefined;\n\t\tif (input.verificationOfTaskId && !existingVerificationSubject) {\n\t\t\tthrow new DurableTaskRuntimeError(`Unknown verification subject '${input.verificationOfTaskId}'.`);\n\t\t}\n\t\tconst projectedGoal = input.goal ? projectGoalObjective(input.goal) : undefined;\n\t\tconst objectiveId =\n\t\t\texistingVerificationSubject?.task.objectiveId ??\n\t\t\tprojectedGoal?.objectiveId ??\n\t\t\t(input.goalId ? goalObjectiveId(input.goalId) : `session:${this.sessionId}`);\n\t\tif (input.goal && objectiveId === projectedGoal?.objectiveId) {\n\t\t\tthis.synchronizeGoalState(input.goal);\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t} else if (!snapshot.objectives[objectiveId]) {\n\t\t\tthis.runtime.createObjective({\n\t\t\t\tobjectiveId,\n\t\t\t\ttitle: input.goalId ? `Goal ${input.goalId}` : `Session ${this.sessionId}`,\n\t\t\t\tdescription: input.goalId ? \"Externally managed goal work\" : \"Session-scoped delegated work\",\n\t\t\t});\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\n\t\tif (!snapshot.tasks[input.laneId]) {\n\t\t\tconst verificationSubject = input.verificationOfTaskId\n\t\t\t\t? snapshot.tasks[input.verificationOfTaskId]\n\t\t\t\t: undefined;\n\t\t\tthis.runtime.createTask({\n\t\t\t\ttaskId: input.laneId,\n\t\t\t\tobjectiveId,\n\t\t\t\ttitle: deriveWorkerTaskLabel(input.instructions, `Delegated ${input.role} work`),\n\t\t\t\tdescription: input.instructions,\n\t\t\t\trole: input.role,\n\t\t\t\trequiredCapabilities: input.requiredCapabilities,\n\t\t\t\triskBudget: input.riskBudget,\n\t\t\t\t...(input.verificationOfTaskId\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tverificationOfTaskId: input.verificationOfTaskId,\n\t\t\t\t\t\t\tacceptanceCriterionIds: verificationSubject?.task.acceptanceCriterionIds ?? [],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\n\t\tconst task = snapshot.tasks[input.laneId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Failed to create task '${input.laneId}'.`);\n\t\tconst existing = [...task.attemptIds]\n\t\t\t.reverse()\n\t\t\t.map((attemptId) => snapshot.attempts[attemptId])\n\t\t\t.find((attempt): attempt is AttemptRuntimeState => attempt !== undefined && activeAttempt(attempt));\n\t\tif (existing) return existing;\n\n\t\treturn this.runtime.queueAttempt(input.laneId, {\n\t\t\ttaskId: input.laneId,\n\t\t\tprofileId: input.profileId,\n\t\t\tinstructions: input.instructions,\n\t\t\tresourcePointerIds: [],\n\t\t\t...(input.executionContract ? { executionContract: input.executionContract } : {}),\n\t\t\t...input.dispatchMetadata,\n\t\t});\n\t}\n\n\tsynchronizeGoalState(goal: GoalState): void {\n\t\tconst objective = projectGoalObjective(goal);\n\t\tthis.runtime.ensureObjective(objective);\n\t\tfor (const evidence of projectGoalAcceptanceEvidence(goal)) {\n\t\t\tthis.runtime.recordObjectiveEvidence(objective.objectiveId, evidence);\n\t\t}\n\t\tconst status = this.runtime.getSnapshot().objectives[goalObjectiveId(goal.goalId)]?.objective.status;\n\t\tswitch (goal.status) {\n\t\t\tcase \"active\":\n\t\t\t\tif (status === \"paused\") this.runtime.resumeObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"blocked\":\n\t\t\t\tif (status === \"active\") this.runtime.pauseObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"cancelled\":\n\t\t\t\tif (status !== \"cancelled\") this.runtime.cancelObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"completed\":\n\t\t\t\tif (status !== \"completed\") {\n\t\t\t\t\tthis.runtime.completeObjectiveFromOwner(objective.objectiveId, hasGoalAcceptanceOverride(goal));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tstart(attemptId: string, leaseTtlMs: number, ownerId = `in-process:${this.sessionId}`): StartedDelegationAttempt {\n\t\tconst snapshot = this.runtime.getSnapshot();\n\t\tconst attempt = snapshot.attempts[attemptId];\n\t\tif (!attempt) throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);\n\t\tconst task = snapshot.tasks[attempt.taskId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Unknown task '${attempt.taskId}'.`);\n\t\tconst lease = this.runtime.leaseAttempt(attemptId, ownerId, leaseTtlMs);\n\t\tthis.runtime.startAttempt(attemptId, lease.leaseId, lease.fencingToken);\n\t\treturn {\n\t\t\tobjectiveId: task.task.objectiveId,\n\t\t\ttaskId: task.task.taskId,\n\t\t\tattemptId,\n\t\t\tleaseId: lease.leaseId,\n\t\t\tfencingToken: lease.fencingToken,\n\t\t\texpiresAt: lease.expiresAt,\n\t\t};\n\t}\n\n\tcancel(attemptId: string, reasonCode: string): void {\n\t\tthis.runtime.cancelAttempt(attemptId, reasonCode);\n\t}\n\n\t/** Fence interrupted isolated completions and queue one replacement attempt per task. */\n\trecoverQueuedDispatches(): AttemptRuntimeState[] {\n\t\tthis.runtime.recoverInterruptedUnboundAttempts((attempt) => attempt.dispatch.executionKind !== \"managed-process\");\n\t\tlet snapshot = this.runtime.getSnapshot();\n\t\tfor (const task of Object.values(snapshot.tasks)) {\n\t\t\tconst attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);\n\t\t\tif (attempts.some((attempt) => attempt && activeAttempt(attempt))) continue;\n\t\t\tconst interrupted = [...attempts].reverse().find((attempt) => attempt?.status === \"expired\");\n\t\t\tif (!interrupted || task.task.status !== \"ready\") continue;\n\t\t\tconst maxAttempts = task.task.riskBudget.maxAttempts;\n\t\t\tif (maxAttempts !== undefined && task.attemptIds.length >= maxAttempts) {\n\t\t\t\tthis.runtime.failTask(task.task.taskId, \"attempt_budget_exhausted\");\n\t\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.runtime.queueAttempt(task.task.taskId, interrupted.dispatch);\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\t\treturn Object.values(snapshot.attempts).filter(\n\t\t\t(attempt) => attempt.status === \"queued\" && attempt.dispatch.executionKind !== \"managed-process\",\n\t\t);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { JsonObject } from "../autonomy/contracts.ts";
|
|
2
|
+
import { type AppendOrchestrationEventInput, type OrchestrationEvent } from "./contracts.ts";
|
|
3
|
+
export interface OrchestrationEventStoreOptions {
|
|
4
|
+
agentDir: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
now?: () => string;
|
|
7
|
+
createEventId?: () => string;
|
|
8
|
+
maxTailEvents?: number;
|
|
9
|
+
maxTailBytes?: number;
|
|
10
|
+
maxIdempotencyEvents?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class OrchestrationEventStoreError extends Error {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class OrchestrationConcurrencyError extends OrchestrationEventStoreError {
|
|
16
|
+
constructor(expected: number, actual: number);
|
|
17
|
+
}
|
|
18
|
+
export declare class OrchestrationSnapshotRequiredError extends OrchestrationEventStoreError {
|
|
19
|
+
readonly throughOrdinal: number;
|
|
20
|
+
constructor(throughOrdinal: number);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Append-only event tail with a replaceable full-state projection snapshot. Atomic rename prevents
|
|
24
|
+
* torn records. Snapshot publication is two-phase (payload, then small baseline pointer), after which
|
|
25
|
+
* covered event/idempotency files are pruned. A crash at any point leaves either the old replay prefix
|
|
26
|
+
* or the new verified snapshot authoritative; ordinals never reset.
|
|
27
|
+
*/
|
|
28
|
+
export declare class OrchestrationEventStore {
|
|
29
|
+
readonly rootDir: string;
|
|
30
|
+
readonly eventsDir: string;
|
|
31
|
+
readonly idempotencyDir: string;
|
|
32
|
+
readonly cursorPath: string;
|
|
33
|
+
readonly snapshotsDir: string;
|
|
34
|
+
readonly baselinePath: string;
|
|
35
|
+
private readonly now;
|
|
36
|
+
private readonly createEventId;
|
|
37
|
+
private readonly maxTailEvents;
|
|
38
|
+
private readonly maxTailBytes;
|
|
39
|
+
private readonly maxIdempotencyEvents;
|
|
40
|
+
private readonly listeners;
|
|
41
|
+
private verifiedSnapshotBaseline;
|
|
42
|
+
constructor(options: OrchestrationEventStoreOptions);
|
|
43
|
+
append(input: AppendOrchestrationEventInput, options?: {
|
|
44
|
+
expectedLastOrdinal?: number;
|
|
45
|
+
}): OrchestrationEvent;
|
|
46
|
+
readAll(): OrchestrationEvent[];
|
|
47
|
+
readAfter(ordinal: number): OrchestrationEvent[];
|
|
48
|
+
readProjectionSnapshot(): {
|
|
49
|
+
throughOrdinal: number;
|
|
50
|
+
projection: JsonObject;
|
|
51
|
+
} | undefined;
|
|
52
|
+
/** Replace a large replay prefix with one verified current-state snapshot and a bounded tail. */
|
|
53
|
+
compactIfNeeded(throughOrdinal: number, projection: () => JsonObject): boolean;
|
|
54
|
+
subscribe(listener: (event: OrchestrationEvent) => void): () => void;
|
|
55
|
+
private readAllUnlocked;
|
|
56
|
+
private eventFileNamesUnlocked;
|
|
57
|
+
private idempotencyFileNamesUnlocked;
|
|
58
|
+
private snapshotFileNamesUnlocked;
|
|
59
|
+
/** Event files are a contiguous append-only tail after the published snapshot. */
|
|
60
|
+
private assertContiguousTailOrdinalsUnlocked;
|
|
61
|
+
/** A valid cursor may lag a newly published snapshot, but it must never lead its committed tail. */
|
|
62
|
+
private assertReadableTailUnlocked;
|
|
63
|
+
private readBaselineUnlocked;
|
|
64
|
+
private readProjectionSnapshotUnlocked;
|
|
65
|
+
/**
|
|
66
|
+
* Appends need a verified snapshot baseline but must not deserialize its projection on every event.
|
|
67
|
+
* The baseline pointer remains small and is reread each time; an immutable snapshot is reparsed only
|
|
68
|
+
* when its pointer or filesystem identity changes.
|
|
69
|
+
*/
|
|
70
|
+
private readVerifiedSnapshotBaselineUnlocked;
|
|
71
|
+
private snapshotFileSignatureUnlocked;
|
|
72
|
+
private unlinkManagedFile;
|
|
73
|
+
private readEventFileUnlocked;
|
|
74
|
+
private idempotencyPath;
|
|
75
|
+
private writeIdempotencyMarkerUnlocked;
|
|
76
|
+
private readIdempotentEventUnlocked;
|
|
77
|
+
/**
|
|
78
|
+
* Reconcile only the crash tail when an event rename committed before its marker/cursor. Normal
|
|
79
|
+
* appends read directory metadata plus one marker, never the accumulated event payload prefix.
|
|
80
|
+
*/
|
|
81
|
+
private synchronizeIndexesUnlocked;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=event-store.d.ts.map
|