@caupulican/pi-adaptative 0.94.1 → 0.95.0
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 +39 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +32 -13
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +7 -4
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +173 -293
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +247 -392
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts +52 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js +118 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.ts +169 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/templates/builder-validator.json +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/templates/provider-prompt-smoke.json +1 -1
- package/dist/bundled-resources/skills/pi-harness-learning/SKILL.md +13 -7
- package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +11 -11
- package/dist/core/agent-session.d.ts +11 -41
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +93 -160
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts +6 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js +26 -25
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
- package/dist/core/autonomy/lane-private-paths.js +2 -1
- package/dist/core/autonomy/lane-private-paths.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +8 -8
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +45 -30
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/worker-session-private-scope.d.ts +12 -0
- package/dist/core/autonomy/worker-session-private-scope.d.ts.map +1 -0
- package/dist/core/autonomy/worker-session-private-scope.js +42 -0
- package/dist/core/autonomy/worker-session-private-scope.js.map +1 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.d.ts +65 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.d.ts.map +1 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.js +145 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.js.map +1 -0
- package/dist/core/background-lane-controller.d.ts +1 -1
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +1 -1
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +8 -2
- package/dist/core/background-tool-task-controller.d.ts.map +1 -1
- package/dist/core/background-tool-task-controller.js +10 -2
- package/dist/core/background-tool-task-controller.js.map +1 -1
- package/dist/core/cost-guard-controller.d.ts +37 -0
- package/dist/core/cost-guard-controller.d.ts.map +1 -0
- package/dist/core/cost-guard-controller.js +71 -0
- package/dist/core/cost-guard-controller.js.map +1 -0
- package/dist/core/cost-guard.d.ts +9 -4
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +7 -3
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +0 -1
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +16 -3
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +114 -55
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts +1 -2
- package/dist/core/delegation/worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +19 -6
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +125 -40
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +3 -3
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js +13 -19
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts +3 -2
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +54 -39
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.d.ts +3 -3
- package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.js +7 -7
- package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
- package/dist/core/delegation/worker-machine-scope.d.ts +12 -0
- package/dist/core/delegation/worker-machine-scope.d.ts.map +1 -0
- package/dist/core/delegation/worker-machine-scope.js +38 -0
- package/dist/core/delegation/worker-machine-scope.js.map +1 -0
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +6 -1
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +5 -7
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +1 -4
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +3 -2
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +50 -25
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/durable-custom-message-turn-controller.d.ts +6 -0
- package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
- package/dist/core/durable-custom-message-turn-controller.js +38 -15
- package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
- package/dist/core/extension-binding-controller.d.ts +5 -1
- package/dist/core/extension-binding-controller.d.ts.map +1 -1
- package/dist/core/extension-binding-controller.js +15 -0
- package/dist/core/extension-binding-controller.js.map +1 -1
- package/dist/core/extensions/factory-runtime.d.ts.map +1 -1
- package/dist/core/extensions/factory-runtime.js +5 -0
- package/dist/core/extensions/factory-runtime.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +8 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.d.ts +14 -0
- package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.js +188 -72
- package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +2 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +8 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +5 -4
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +23 -19
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/learning/auto-learn-settings.d.ts +84 -0
- package/dist/core/learning/auto-learn-settings.d.ts.map +1 -0
- package/dist/core/learning/auto-learn-settings.js +66 -0
- package/dist/core/learning/auto-learn-settings.js.map +1 -0
- package/dist/core/learning/reflection-engine.d.ts +4 -0
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +48 -10
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/local-prefix-warm-controller.d.ts +24 -0
- package/dist/core/local-prefix-warm-controller.d.ts.map +1 -0
- package/dist/core/local-prefix-warm-controller.js +79 -0
- package/dist/core/local-prefix-warm-controller.js.map +1 -0
- package/dist/core/memory/providers/file-store.d.ts +2 -0
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +71 -15
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/worker-memory-tools.d.ts +5 -0
- package/dist/core/memory/worker-memory-tools.d.ts.map +1 -0
- package/dist/core/memory/worker-memory-tools.js +5 -0
- package/dist/core/memory/worker-memory-tools.js.map +1 -0
- package/dist/core/model-capability.d.ts +7 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +12 -0
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -10
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +3 -2
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +3 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +16 -12
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +2 -2
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js +6 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +14 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/task-profile-writer.d.ts +7 -4
- package/dist/core/orchestration/task-profile-writer.d.ts.map +1 -1
- package/dist/core/orchestration/task-profile-writer.js +71 -59
- package/dist/core/orchestration/task-profile-writer.js.map +1 -1
- package/dist/core/orchestration/thinking-level-schema.d.ts +7 -0
- package/dist/core/orchestration/thinking-level-schema.d.ts.map +1 -0
- package/dist/core/orchestration/thinking-level-schema.js +19 -0
- package/dist/core/orchestration/thinking-level-schema.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js +12 -5
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/provider-prompt-contracts.d.ts +1 -4
- package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
- package/dist/core/provider-prompt-contracts.js +4 -10
- package/dist/core/provider-prompt-contracts.js.map +1 -1
- package/dist/core/provider-request-context-controller.d.ts +2 -0
- package/dist/core/provider-request-context-controller.d.ts.map +1 -1
- package/dist/core/provider-request-context-controller.js +10 -3
- package/dist/core/provider-request-context-controller.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +56 -27
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +206 -117
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +1 -0
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +25 -14
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +55 -10
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/session-role.d.ts +6 -8
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +8 -18
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/settings-manager.d.ts +13 -16
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +53 -50
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skill-vault.d.ts +15 -0
- package/dist/core/skill-vault.d.ts.map +1 -1
- package/dist/core/skill-vault.js +79 -45
- package/dist/core/skill-vault.js.map +1 -1
- package/dist/core/skills.d.ts +3 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -6
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +2 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +52 -12
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +3 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js +13 -2
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/toolkit/script-runner.d.ts +2 -1
- package/dist/core/toolkit/script-runner.d.ts.map +1 -1
- package/dist/core/toolkit/script-runner.js +10 -2
- package/dist/core/toolkit/script-runner.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +1 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +1 -1
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +4 -15
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +111 -73
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/goal.d.ts +3 -4
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +24 -7
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/profile-writer.d.ts +2 -8
- package/dist/core/tools/profile-writer.d.ts.map +1 -1
- package/dist/core/tools/profile-writer.js +6 -18
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
- package/dist/core/tools/run-toolkit-script.js +2 -2
- package/dist/core/tools/run-toolkit-script.js.map +1 -1
- package/dist/core/tools/skill-audit.d.ts +28 -1
- package/dist/core/tools/skill-audit.d.ts.map +1 -1
- package/dist/core/tools/skill-audit.js +56 -12
- package/dist/core/tools/skill-audit.js.map +1 -1
- package/dist/core/tools/skill.d.ts +12 -1
- package/dist/core/tools/skill.d.ts.map +1 -1
- package/dist/core/tools/skill.js +52 -0
- package/dist/core/tools/skill.js.map +1 -1
- package/dist/core/tools/skillify.d.ts.map +1 -1
- package/dist/core/tools/skillify.js +16 -7
- package/dist/core/tools/skillify.js.map +1 -1
- package/dist/core/tools/task-steps.js +1 -1
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +4 -16
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +5 -20
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/worktree-sync/codes.d.ts +1 -2
- package/dist/core/worktree-sync/codes.d.ts.map +1 -1
- package/dist/core/worktree-sync/codes.js +1 -2
- package/dist/core/worktree-sync/codes.js.map +1 -1
- package/dist/core/worktree-sync/lane-gate.d.ts +4 -8
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
- package/dist/core/worktree-sync/lane-gate.js +5 -51
- package/dist/core/worktree-sync/lane-gate.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +6 -7
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +30 -207
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/autonomy-commands.js +2 -2
- package/dist/modes/interactive/autonomy-commands.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +17 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.js +2 -2
- package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +150 -73
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +8 -4
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.js +10 -0
- package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
- package/docs/extensions.md +8 -0
- package/docs/harness-architecture.md +28 -32
- package/docs/index.md +1 -1
- package/docs/process-matrix.md +8 -6
- package/docs/resources.md +1 -1
- package/docs/settings.md +61 -51
- package/docs/tmux-agent-manager.md +47 -40
- package/docs/usage.md +1 -1
- package/docs/worker-profiles.md +8 -6
- package/docs/worktree-sync.md +26 -20
- 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/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 +4 -4
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +0 -133
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +0 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +0 -199
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +0 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +0 -312
|
@@ -221,7 +221,7 @@ export function createTaskStepsToolDefinition(deps) {
|
|
|
221
221
|
"Batch transitions; work the first open step; record evidence/blockers; skip unchanged narration.",
|
|
222
222
|
"intake keeps every item; link goal requirementIds.",
|
|
223
223
|
"advance completes current, then starts next pending.",
|
|
224
|
-
"Attach completed tool_task IDs as evidence; goal completion rejects open
|
|
224
|
+
"Attach completed tool_task IDs as evidence; goal completion rejects every open step.",
|
|
225
225
|
"Before final, resolve or defer open work. goal owns outcomes; delegate owns workers.",
|
|
226
226
|
],
|
|
227
227
|
parameters: taskStepsSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-steps.js","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,oCAAoC,EACpC,cAAc,EACd,6BAA6B,EAC7B,uBAAuB,EACvB,YAAY,EAGZ,cAAc,EAGd,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,sBAAsB,EACtB,2BAA2B,EAE3B,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACzB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAA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AK,CAAC,aAAa;gCACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;6BACxB,CAAC,GAAG,OAAO,EAAE;yBACd;qBACD;oBACD,OAAO,EAAE;wBACR,MAAM,EAAE,KAAK,CAAC,MAAM;wBACpB,OAAO,EAAE,IAAI;wBACb,KAAK;wBACL,GAAG,WAAW;wBACd,aAAa,EAAE,KAAK,CAAC,aAAa;wBAClC,iBAAiB,EAAE,eAAe;wBAClC,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;qBACvC;iBAChC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { advanceTaskSteps } from \"../pipelines/increment.ts\";\nimport { MAX_PIPELINE_STAGE_ID_LENGTH } from \"../pipelines/types.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tfindOpenDuplicateStep,\n\tformatTaskSteps,\n\thasUnverifiedCompletedStep,\n\tMAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,\n\tMAX_TASK_STEPS,\n\tnormalizeTaskStepPipelineLink,\n\tresolveTaskStepSelector,\n\tsetTaskSteps,\n\ttype TaskStep,\n\ttype TaskStepInput,\n\tTaskStepsError,\n\ttype TaskStepsState,\n\ttype TaskStepUpdate,\n\tupdateTaskStep,\n} from \"../tasks/task-state.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttaskStepPanelRow,\n} from \"./orchestration-panel.ts\";\n\nconst statusSchema = Type.Union([\n\tType.Literal(\"pending\"),\n\tType.Literal(\"in_progress\"),\n\tType.Literal(\"completed\"),\n\tType.Literal(\"blocked\"),\n\tType.Literal(\"cancelled\"),\n]);\n\nconst prioritySchema = Type.Union([Type.Literal(\"low\"), Type.Literal(\"normal\"), Type.Literal(\"high\")]);\n\nfunction optionalTaskStepFields(requirementIdsDescription: string) {\n\treturn {\n\t\tstatus: Type.Optional(statusSchema),\n\t\tpriority: Type.Optional(prioritySchema),\n\t\towner: Type.Optional(Type.String({ maxLength: 200 })),\n\t\trequirementIds: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: 200 }), {\n\t\t\t\tmaxItems: 32,\n\t\t\t\tdescription: requirementIdsDescription,\n\t\t\t}),\n\t\t),\n\t\tpipelineRunId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,\n\t\t\t\tdescription: \"Active pipeline run id this step advances. Supply together with pipelineStageId.\",\n\t\t\t}),\n\t\t),\n\t\tpipelineStageId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_PIPELINE_STAGE_ID_LENGTH,\n\t\t\t\tdescription: \"Stage id in pipelineRunId this step advances. Supply both ids together.\",\n\t\t\t}),\n\t\t),\n\t\tclearPipelineLink: Type.Optional(\n\t\t\tType.Boolean({\n\t\t\t\tdescription: \"Remove both pipeline ids. Cannot be combined with pipelineRunId/pipelineStageId.\",\n\t\t\t}),\n\t\t),\n\t\tnote: Type.Optional(Type.String({ maxLength: 4_000 })),\n\t\tevidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),\n\t};\n}\n\nconst stepInputSchema = Type.Object(\n\t{\n\t\tcontent: Type.String({ minLength: 1, maxLength: 2_000, description: \"Imperative task step text.\" }),\n\t\tactiveForm: Type.Optional(\n\t\t\tType.String({ minLength: 1, maxLength: 2_000, description: \"Short present-progress label for active UI.\" }),\n\t\t),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances.\"),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst taskStepsSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"add\"),\n\t\t\t\tType.Literal(\"update\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"clear\"),\n\t\t\t\tType.Literal(\"compact\"),\n\t\t\t\tType.Literal(\"intake\"),\n\t\t\t\tType.Literal(\"advance\"),\n\t\t\t],\n\t\t\t{ description: \"Checklist action. Use list to read without mutation.\" },\n\t\t),\n\t\tsteps: Type.Optional(\n\t\t\tType.Array(stepInputSchema, {\n\t\t\t\tmaxItems: MAX_TASK_STEPS,\n\t\t\t\tdescription: \"Complete replacement list for set/intake. Intake preserves every supplied item in order.\",\n\t\t\t}),\n\t\t),\n\t\tid: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"For update: current/active, exact step id, unique id prefix, or unique content selector.\",\n\t\t\t}),\n\t\t),\n\t\tcontent: Type.Optional(Type.String({ minLength: 1, maxLength: 2_000 })),\n\t\tactiveForm: Type.Optional(Type.String({ maxLength: 2_000 })),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances; [] clears existing links.\"),\n\t\tclearCompleted: Type.Optional(\n\t\t\tType.Boolean({ description: \"For list: compact completed and cancelled steps before rendering.\" }),\n\t\t),\n\t\tshowCompleted: Type.Optional(Type.Boolean({ description: \"Include completed and cancelled steps in output.\" })),\n\t\tmaxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TaskStepsToolInput = Static<typeof taskStepsSchema>;\nexport type TaskStepsAction = TaskStepsToolInput[\"action\"];\n\nexport interface TaskStepsToolDetails {\n\taction: TaskStepsAction;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: TaskStepsState;\n\tstepCount?: number;\n\topenStepCount?: number;\n\tverificationNudgeNeeded?: boolean;\n\tshowCompleted?: boolean;\n\t/** Set when `add` was a no-op because an open step already carries this content. */\n\tduplicateOfStepId?: string;\n\t/** Step ids silently demoted to pending because another step became active in this call. */\n\tdemotedStepIds?: readonly string[];\n}\n\nexport interface TaskStepsToolDependencies {\n\tgetTaskStepsState: () => TaskStepsState | undefined;\n\tsaveTaskStepsState: (state: TaskStepsState) => void;\n\tgetActivePipelineScope?: () => { runId: string; stageIds: readonly string[] } | undefined;\n\tnow?: () => string;\n}\n\nfunction toTaskStepUpdate(input: TaskStepsToolInput): TaskStepUpdate {\n\treturn {\n\t\tcontent: input.content,\n\t\tactiveForm: input.activeForm,\n\t\tstatus: input.status,\n\t\tpriority: input.priority,\n\t\towner: input.owner,\n\t\trequirementIds: input.requirementIds,\n\t\tpipelineRunId: input.pipelineRunId,\n\t\tpipelineStageId: input.pipelineStageId,\n\t\tclearPipelineLink: input.clearPipelineLink,\n\t\tnote: input.note,\n\t\tevidence: input.evidence,\n\t};\n}\n\nfunction toTaskStepInput(input: TaskStepsToolInput): TaskStepInput {\n\treturn { ...toTaskStepUpdate(input), content: input.content ?? \"\" };\n}\n\nfunction validatePipelineLink(\n\tdeps: TaskStepsToolDependencies,\n\tpipelineRunId: string | undefined,\n\tpipelineStageId: string | undefined,\n\tclearPipelineLink = false,\n): void {\n\tconst { pipelineRunId: runId, pipelineStageId: stageId } = normalizeTaskStepPipelineLink(\n\t\tpipelineRunId,\n\t\tpipelineStageId,\n\t\tclearPipelineLink,\n\t);\n\tif (!runId || !stageId) return;\n\tconst active = deps.getActivePipelineScope?.();\n\tif (!active) throw new TaskStepsError(\"Task step pipeline linkage requires an active pipeline run.\");\n\tif (runId !== active.runId) {\n\t\tthrow new TaskStepsError(`Task step pipelineRunId must match active run '${active.runId}'.`);\n\t}\n\tif (!active.stageIds.includes(stageId)) {\n\t\tthrow new TaskStepsError(`Task step pipelineStageId '${stageId}' is not in active run '${active.runId}'.`);\n\t}\n}\n\nfunction validatePipelineInputs(deps: TaskStepsToolDependencies, inputs: readonly TaskStepInput[]): void {\n\tfor (const input of inputs) {\n\t\tvalidatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);\n\t}\n}\n\nfunction counts(\n\tstate: TaskStepsState,\n): Pick<TaskStepsToolDetails, \"stepCount\" | \"openStepCount\" | \"verificationNudgeNeeded\"> {\n\tconst openStepCount = state.steps.filter(\n\t\t(step) => step.status !== \"completed\" && step.status !== \"cancelled\",\n\t).length;\n\treturn {\n\t\tstepCount: state.steps.length,\n\t\topenStepCount,\n\t\tverificationNudgeNeeded: hasUnverifiedCompletedStep(state),\n\t};\n}\n\n/** Ids (from `resultSteps`, index-aligned with `inputs`) whose status was set explicitly by the caller. */\nfunction explicitStatusStepIds(inputs: readonly TaskStepInput[], resultSteps: readonly TaskStep[]): Set<string> {\n\tconst ids = new Set<string>();\n\tinputs.forEach((stepInput, index) => {\n\t\tif (stepInput.status !== undefined) {\n\t\t\tconst id = resultSteps[index]?.id;\n\t\t\tif (id) ids.add(id);\n\t\t}\n\t});\n\treturn ids;\n}\n\n/**\n * Steps that were in_progress before this call and are pending after, excluding any step whose\n * new status was set explicitly by the caller (an explicit change is not a \"silent\" demotion).\n */\nfunction computeDemotedStepIds(\n\tbefore: TaskStepsState,\n\tafter: TaskStepsState,\n\texcludeIds: ReadonlySet<string>,\n): string[] {\n\tconst beforeActiveIds = new Set(before.steps.filter((step) => step.status === \"in_progress\").map((step) => step.id));\n\treturn after.steps\n\t\t.filter((step) => beforeActiveIds.has(step.id) && step.status === \"pending\" && !excludeIds.has(step.id))\n\t\t.map((step) => step.id);\n}\n\nfunction errorResult(action: TaskStepsAction, error: string, state?: TaskStepsState) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: `task_steps ${action} failed: ${error}` }],\n\t\tdetails: { action, applied: false, error, state, ...(state ? counts(state) : {}) } satisfies TaskStepsToolDetails,\n\t\tisError: true as const,\n\t};\n}\n\nfunction taskStepsPanelModel(details: TaskStepsToolDetails, expanded: boolean): OrchestrationPanelModel {\n\tconst state = details.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"task steps\",\n\t\t\taction: details.action,\n\t\t\tstatus: details.error ? \"error\" : \"idle\",\n\t\t\temptyText: details.error ?? \"No checklist state.\",\n\t\t};\n\t}\n\tconst active = state.steps.filter((step) => step.status === \"in_progress\");\n\tconst blocked = state.steps.filter((step) => step.status === \"blocked\");\n\tconst pending = state.steps.filter((step) => step.status === \"pending\");\n\tconst completed = state.steps.filter((step) => step.status === \"completed\");\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\");\n\tconst open = [...active, ...blocked, ...pending];\n\tconst terminal = details.showCompleted ? [...completed, ...cancelled] : [];\n\tconst candidates = [...open, ...terminal];\n\tconst limit = expanded ? 24 : 8;\n\tconst rows = candidates.slice(0, limit).map(taskStepPanelRow);\n\tconst archivedDone = state.archive.completed + state.archive.cancelled;\n\tconst done = completed.length + state.archive.completed;\n\tconst summary = [\n\t\tactive.length ? `${active.length} working` : undefined,\n\t\t`${open.length} open`,\n\t\t`${done} done`,\n\t\tblocked.length ? `${blocked.length} blocked` : undefined,\n\t\tarchivedDone ? `${archivedDone} archived` : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst notices = [];\n\tif (!details.showCompleted && completed.length + cancelled.length > 0) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${completed.length + cancelled.length} finished step${completed.length + cancelled.length === 1 ? \"\" : \"s\"} hidden`,\n\t\t});\n\t}\n\tif (details.duplicateOfStepId) {\n\t\tnotices.push({ status: \"info\" as const, text: \"Duplicate open step ignored.\" });\n\t}\n\tif (details.demotedStepIds?.length) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${details.demotedStepIds.length} previous working step${details.demotedStepIds.length === 1 ? \"\" : \"s\"} returned to pending.`,\n\t\t});\n\t}\n\tif (details.verificationNudgeNeeded) {\n\t\tnotices.push({ status: \"warning\" as const, text: \"Completed work still needs attached evidence.\" });\n\t}\n\tconst status = details.error\n\t\t? \"error\"\n\t\t: blocked.length > 0\n\t\t\t? \"warning\"\n\t\t\t: active.length > 0\n\t\t\t\t? \"running\"\n\t\t\t\t: open.length === 0 && state.steps.length > 0\n\t\t\t\t\t? \"success\"\n\t\t\t\t\t: \"idle\";\n\treturn {\n\t\tlabel: \"task steps\",\n\t\taction: details.action,\n\t\tstatus,\n\t\tsummary,\n\t\trows,\n\t\tnotices,\n\t\temptyText: state.steps.length === 0 ? \"No tracked steps.\" : \"All open steps are done.\",\n\t\thiddenRowCount: Math.max(0, candidates.length - rows.length),\n\t};\n}\n\nexport function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"task_steps\",\n\t\tlabel: \"Task Steps\",\n\t\tdescription:\n\t\t\t\"Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.\",\n\t\tpromptSnippet: \"Track multi-step session work.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use for multi-step work; keep one in_progress step.\",\n\t\t\t\"Batch transitions; work the first open step; record evidence/blockers; skip unchanged narration.\",\n\t\t\t\"intake keeps every item; link goal requirementIds.\",\n\t\t\t\"advance completes current, then starts next pending.\",\n\t\t\t\"Attach completed tool_task IDs as evidence; goal completion rejects open linked steps.\",\n\t\t\t\"Before final, resolve or defer open work. goal owns outcomes; delegate owns workers.\",\n\t\t],\n\t\tparameters: taskStepsSchema,\n\t\texecutionMode: \"sequential\",\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return emptyOrchestrationCall();\n\t\t\tconst details = result.details as TaskStepsToolDetails | undefined;\n\t\t\tif (!details) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"task steps\",\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\temptyText: \"No task-step details were returned.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!expanded && details.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, taskStepsPanelModel(details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input: TaskStepsToolInput) {\n\t\t\tconst timestamp = now();\n\t\t\tconst current = deps.getTaskStepsState();\n\t\t\tconst before = current ?? createTaskStepsState(timestamp);\n\t\t\tlet state = before;\n\t\t\tlet duplicateStepId: string | undefined;\n\t\t\tlet demotedStepIds: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"set\":\n\t\t\t\t\tcase \"intake\": {\n\t\t\t\t\t\tconst steps = input.steps;\n\t\t\t\t\t\tif (!steps) {\n\t\t\t\t\t\t\tconst error =\n\t\t\t\t\t\t\t\tinput.action === \"set\" ? \"set requires steps[].\" : \"intake requires a complete steps[] list.\";\n\t\t\t\t\t\t\treturn errorResult(input.action, error, current);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalidatePipelineInputs(deps, steps);\n\t\t\t\t\t\tstate = setTaskSteps(state, steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(steps, state.steps));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"add\":\n\t\t\t\t\t\tvalidatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);\n\t\t\t\t\t\tstate = addTaskStep(state, toTaskStepInput(input), timestamp);\n\t\t\t\t\t\tif (state === before) {\n\t\t\t\t\t\t\t// The reducer returned the unchanged state: an open step already carries this\n\t\t\t\t\t\t\t// content, so nothing was created. Name the existing step in the response.\n\t\t\t\t\t\t\tduplicateStepId = findOpenDuplicateStep(before.steps, input.content ?? \"\")?.id;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\tif (!input.id?.trim())\n\t\t\t\t\t\t\treturn errorResult(input.action, \"update requires id or a unique selector.\", current);\n\t\t\t\t\t\tconst selected = resolveTaskStepSelector(before.steps, input.id);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tinput.pipelineRunId !== undefined ||\n\t\t\t\t\t\t\tinput.pipelineStageId !== undefined ||\n\t\t\t\t\t\t\tinput.clearPipelineLink === true\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst clearingPipelineLink = input.clearPipelineLink === true;\n\t\t\t\t\t\t\tvalidatePipelineLink(\n\t\t\t\t\t\t\t\tdeps,\n\t\t\t\t\t\t\t\tclearingPipelineLink ? input.pipelineRunId : (input.pipelineRunId ?? selected.pipelineRunId),\n\t\t\t\t\t\t\t\tclearingPipelineLink\n\t\t\t\t\t\t\t\t\t? input.pipelineStageId\n\t\t\t\t\t\t\t\t\t: (input.pipelineStageId ?? selected.pipelineStageId),\n\t\t\t\t\t\t\t\tclearingPipelineLink,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate = updateTaskStep(state, input.id, toTaskStepUpdate(input), timestamp);\n\t\t\t\t\t\t// Exclude the explicitly targeted step: its own status change was requested by\n\t\t\t\t\t\t// the caller, so it is never a \"silent\" demotion even if it moved to pending.\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"clear\":\n\t\t\t\t\t\tstate = clearTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"compact\":\n\t\t\t\t\t\tstate = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"advance\": {\n\t\t\t\t\t\tconst advanced = advanceTaskSteps(before, timestamp);\n\t\t\t\t\t\tstate = advanced.state;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\tif (input.clearCompleted) state = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst isNoopDuplicateAdd = input.action === \"add\" && state === before;\n\t\t\t\tconst mutated = (input.action !== \"list\" || input.clearCompleted === true) && !isNoopDuplicateAdd;\n\t\t\t\tif (mutated) deps.saveTaskStepsState(state);\n\n\t\t\t\tconst stateCounts = counts(state);\n\t\t\t\tconst noticeLines: string[] = [];\n\t\t\t\tif (duplicateStepId) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t`Duplicate open step ignored; existing ${duplicateStepId} already tracks this content.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (demotedStepIds.length > 0) {\n\t\t\t\t\tnoticeLines.push(`Demoted to pending because another step became active: ${demotedStepIds.join(\", \")}.`);\n\t\t\t\t}\n\t\t\t\tif (stateCounts.verificationNudgeNeeded) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t\"Reminder: a completed step has no evidence attached; attach evidence via update before treating it as verified.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst notices = noticeLines.length > 0 ? `\\n${noticeLines.join(\"\\n\")}` : \"\";\n\n\t\t\t\tconst headerAction =\n\t\t\t\t\tinput.action === \"list\"\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `task_steps ${input.action} ${duplicateStepId ? \"ignored (duplicate)\" : \"recorded\"}.\\n`;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `${headerAction}${formatTaskSteps(state, {\n\t\t\t\t\t\t\t\tincludeTerminal: input.showCompleted,\n\t\t\t\t\t\t\t\tmaxItems: input.maxItems,\n\t\t\t\t\t\t\t})}${notices}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\tapplied: true,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t...stateCounts,\n\t\t\t\t\t\tshowCompleted: input.showCompleted,\n\t\t\t\t\t\tduplicateOfStepId: duplicateStepId,\n\t\t\t\t\t\tdemotedStepIds: demotedStepIds.length > 0 ? demotedStepIds : undefined,\n\t\t\t\t\t} satisfies TaskStepsToolDetails,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn errorResult(input.action, error instanceof Error ? error.message : String(error), current);\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"task-steps.js","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,oCAAoC,EACpC,cAAc,EACd,6BAA6B,EAC7B,uBAAuB,EACvB,YAAY,EAGZ,cAAc,EAGd,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,sBAAsB,EACtB,2BAA2B,EAE3B,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IAC3B,IAAI,CAAC,OAA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,IAAI,EAAE,GAAG,YAAY,GAAG,eAAe,CAAC,KAAK,EAAE;gCAC9C,eAAe,EAAE,KAAK,CAAC,aAAa;gCACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;6BACxB,CAAC,GAAG,OAAO,EAAE;yBACd;qBACD;oBACD,OAAO,EAAE;wBACR,MAAM,EAAE,KAAK,CAAC,MAAM;wBACpB,OAAO,EAAE,IAAI;wBACb,KAAK;wBACL,GAAG,WAAW;wBACd,aAAa,EAAE,KAAK,CAAC,aAAa;wBAClC,iBAAiB,EAAE,eAAe;wBAClC,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;qBACvC;iBAChC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { advanceTaskSteps } from \"../pipelines/increment.ts\";\nimport { MAX_PIPELINE_STAGE_ID_LENGTH } from \"../pipelines/types.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tfindOpenDuplicateStep,\n\tformatTaskSteps,\n\thasUnverifiedCompletedStep,\n\tMAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,\n\tMAX_TASK_STEPS,\n\tnormalizeTaskStepPipelineLink,\n\tresolveTaskStepSelector,\n\tsetTaskSteps,\n\ttype TaskStep,\n\ttype TaskStepInput,\n\tTaskStepsError,\n\ttype TaskStepsState,\n\ttype TaskStepUpdate,\n\tupdateTaskStep,\n} from \"../tasks/task-state.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttaskStepPanelRow,\n} from \"./orchestration-panel.ts\";\n\nconst statusSchema = Type.Union([\n\tType.Literal(\"pending\"),\n\tType.Literal(\"in_progress\"),\n\tType.Literal(\"completed\"),\n\tType.Literal(\"blocked\"),\n\tType.Literal(\"cancelled\"),\n]);\n\nconst prioritySchema = Type.Union([Type.Literal(\"low\"), Type.Literal(\"normal\"), Type.Literal(\"high\")]);\n\nfunction optionalTaskStepFields(requirementIdsDescription: string) {\n\treturn {\n\t\tstatus: Type.Optional(statusSchema),\n\t\tpriority: Type.Optional(prioritySchema),\n\t\towner: Type.Optional(Type.String({ maxLength: 200 })),\n\t\trequirementIds: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: 200 }), {\n\t\t\t\tmaxItems: 32,\n\t\t\t\tdescription: requirementIdsDescription,\n\t\t\t}),\n\t\t),\n\t\tpipelineRunId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,\n\t\t\t\tdescription: \"Active pipeline run id this step advances. Supply together with pipelineStageId.\",\n\t\t\t}),\n\t\t),\n\t\tpipelineStageId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_PIPELINE_STAGE_ID_LENGTH,\n\t\t\t\tdescription: \"Stage id in pipelineRunId this step advances. Supply both ids together.\",\n\t\t\t}),\n\t\t),\n\t\tclearPipelineLink: Type.Optional(\n\t\t\tType.Boolean({\n\t\t\t\tdescription: \"Remove both pipeline ids. Cannot be combined with pipelineRunId/pipelineStageId.\",\n\t\t\t}),\n\t\t),\n\t\tnote: Type.Optional(Type.String({ maxLength: 4_000 })),\n\t\tevidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),\n\t};\n}\n\nconst stepInputSchema = Type.Object(\n\t{\n\t\tcontent: Type.String({ minLength: 1, maxLength: 2_000, description: \"Imperative task step text.\" }),\n\t\tactiveForm: Type.Optional(\n\t\t\tType.String({ minLength: 1, maxLength: 2_000, description: \"Short present-progress label for active UI.\" }),\n\t\t),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances.\"),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst taskStepsSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"add\"),\n\t\t\t\tType.Literal(\"update\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"clear\"),\n\t\t\t\tType.Literal(\"compact\"),\n\t\t\t\tType.Literal(\"intake\"),\n\t\t\t\tType.Literal(\"advance\"),\n\t\t\t],\n\t\t\t{ description: \"Checklist action. Use list to read without mutation.\" },\n\t\t),\n\t\tsteps: Type.Optional(\n\t\t\tType.Array(stepInputSchema, {\n\t\t\t\tmaxItems: MAX_TASK_STEPS,\n\t\t\t\tdescription: \"Complete replacement list for set/intake. Intake preserves every supplied item in order.\",\n\t\t\t}),\n\t\t),\n\t\tid: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"For update: current/active, exact step id, unique id prefix, or unique content selector.\",\n\t\t\t}),\n\t\t),\n\t\tcontent: Type.Optional(Type.String({ minLength: 1, maxLength: 2_000 })),\n\t\tactiveForm: Type.Optional(Type.String({ maxLength: 2_000 })),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances; [] clears existing links.\"),\n\t\tclearCompleted: Type.Optional(\n\t\t\tType.Boolean({ description: \"For list: compact completed and cancelled steps before rendering.\" }),\n\t\t),\n\t\tshowCompleted: Type.Optional(Type.Boolean({ description: \"Include completed and cancelled steps in output.\" })),\n\t\tmaxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TaskStepsToolInput = Static<typeof taskStepsSchema>;\nexport type TaskStepsAction = TaskStepsToolInput[\"action\"];\n\nexport interface TaskStepsToolDetails {\n\taction: TaskStepsAction;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: TaskStepsState;\n\tstepCount?: number;\n\topenStepCount?: number;\n\tverificationNudgeNeeded?: boolean;\n\tshowCompleted?: boolean;\n\t/** Set when `add` was a no-op because an open step already carries this content. */\n\tduplicateOfStepId?: string;\n\t/** Step ids silently demoted to pending because another step became active in this call. */\n\tdemotedStepIds?: readonly string[];\n}\n\nexport interface TaskStepsToolDependencies {\n\tgetTaskStepsState: () => TaskStepsState | undefined;\n\tsaveTaskStepsState: (state: TaskStepsState) => void;\n\tgetActivePipelineScope?: () => { runId: string; stageIds: readonly string[] } | undefined;\n\tnow?: () => string;\n}\n\nfunction toTaskStepUpdate(input: TaskStepsToolInput): TaskStepUpdate {\n\treturn {\n\t\tcontent: input.content,\n\t\tactiveForm: input.activeForm,\n\t\tstatus: input.status,\n\t\tpriority: input.priority,\n\t\towner: input.owner,\n\t\trequirementIds: input.requirementIds,\n\t\tpipelineRunId: input.pipelineRunId,\n\t\tpipelineStageId: input.pipelineStageId,\n\t\tclearPipelineLink: input.clearPipelineLink,\n\t\tnote: input.note,\n\t\tevidence: input.evidence,\n\t};\n}\n\nfunction toTaskStepInput(input: TaskStepsToolInput): TaskStepInput {\n\treturn { ...toTaskStepUpdate(input), content: input.content ?? \"\" };\n}\n\nfunction validatePipelineLink(\n\tdeps: TaskStepsToolDependencies,\n\tpipelineRunId: string | undefined,\n\tpipelineStageId: string | undefined,\n\tclearPipelineLink = false,\n): void {\n\tconst { pipelineRunId: runId, pipelineStageId: stageId } = normalizeTaskStepPipelineLink(\n\t\tpipelineRunId,\n\t\tpipelineStageId,\n\t\tclearPipelineLink,\n\t);\n\tif (!runId || !stageId) return;\n\tconst active = deps.getActivePipelineScope?.();\n\tif (!active) throw new TaskStepsError(\"Task step pipeline linkage requires an active pipeline run.\");\n\tif (runId !== active.runId) {\n\t\tthrow new TaskStepsError(`Task step pipelineRunId must match active run '${active.runId}'.`);\n\t}\n\tif (!active.stageIds.includes(stageId)) {\n\t\tthrow new TaskStepsError(`Task step pipelineStageId '${stageId}' is not in active run '${active.runId}'.`);\n\t}\n}\n\nfunction validatePipelineInputs(deps: TaskStepsToolDependencies, inputs: readonly TaskStepInput[]): void {\n\tfor (const input of inputs) {\n\t\tvalidatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);\n\t}\n}\n\nfunction counts(\n\tstate: TaskStepsState,\n): Pick<TaskStepsToolDetails, \"stepCount\" | \"openStepCount\" | \"verificationNudgeNeeded\"> {\n\tconst openStepCount = state.steps.filter(\n\t\t(step) => step.status !== \"completed\" && step.status !== \"cancelled\",\n\t).length;\n\treturn {\n\t\tstepCount: state.steps.length,\n\t\topenStepCount,\n\t\tverificationNudgeNeeded: hasUnverifiedCompletedStep(state),\n\t};\n}\n\n/** Ids (from `resultSteps`, index-aligned with `inputs`) whose status was set explicitly by the caller. */\nfunction explicitStatusStepIds(inputs: readonly TaskStepInput[], resultSteps: readonly TaskStep[]): Set<string> {\n\tconst ids = new Set<string>();\n\tinputs.forEach((stepInput, index) => {\n\t\tif (stepInput.status !== undefined) {\n\t\t\tconst id = resultSteps[index]?.id;\n\t\t\tif (id) ids.add(id);\n\t\t}\n\t});\n\treturn ids;\n}\n\n/**\n * Steps that were in_progress before this call and are pending after, excluding any step whose\n * new status was set explicitly by the caller (an explicit change is not a \"silent\" demotion).\n */\nfunction computeDemotedStepIds(\n\tbefore: TaskStepsState,\n\tafter: TaskStepsState,\n\texcludeIds: ReadonlySet<string>,\n): string[] {\n\tconst beforeActiveIds = new Set(before.steps.filter((step) => step.status === \"in_progress\").map((step) => step.id));\n\treturn after.steps\n\t\t.filter((step) => beforeActiveIds.has(step.id) && step.status === \"pending\" && !excludeIds.has(step.id))\n\t\t.map((step) => step.id);\n}\n\nfunction errorResult(action: TaskStepsAction, error: string, state?: TaskStepsState) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: `task_steps ${action} failed: ${error}` }],\n\t\tdetails: { action, applied: false, error, state, ...(state ? counts(state) : {}) } satisfies TaskStepsToolDetails,\n\t\tisError: true as const,\n\t};\n}\n\nfunction taskStepsPanelModel(details: TaskStepsToolDetails, expanded: boolean): OrchestrationPanelModel {\n\tconst state = details.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"task steps\",\n\t\t\taction: details.action,\n\t\t\tstatus: details.error ? \"error\" : \"idle\",\n\t\t\temptyText: details.error ?? \"No checklist state.\",\n\t\t};\n\t}\n\tconst active = state.steps.filter((step) => step.status === \"in_progress\");\n\tconst blocked = state.steps.filter((step) => step.status === \"blocked\");\n\tconst pending = state.steps.filter((step) => step.status === \"pending\");\n\tconst completed = state.steps.filter((step) => step.status === \"completed\");\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\");\n\tconst open = [...active, ...blocked, ...pending];\n\tconst terminal = details.showCompleted ? [...completed, ...cancelled] : [];\n\tconst candidates = [...open, ...terminal];\n\tconst limit = expanded ? 24 : 8;\n\tconst rows = candidates.slice(0, limit).map(taskStepPanelRow);\n\tconst archivedDone = state.archive.completed + state.archive.cancelled;\n\tconst done = completed.length + state.archive.completed;\n\tconst summary = [\n\t\tactive.length ? `${active.length} working` : undefined,\n\t\t`${open.length} open`,\n\t\t`${done} done`,\n\t\tblocked.length ? `${blocked.length} blocked` : undefined,\n\t\tarchivedDone ? `${archivedDone} archived` : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst notices = [];\n\tif (!details.showCompleted && completed.length + cancelled.length > 0) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${completed.length + cancelled.length} finished step${completed.length + cancelled.length === 1 ? \"\" : \"s\"} hidden`,\n\t\t});\n\t}\n\tif (details.duplicateOfStepId) {\n\t\tnotices.push({ status: \"info\" as const, text: \"Duplicate open step ignored.\" });\n\t}\n\tif (details.demotedStepIds?.length) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${details.demotedStepIds.length} previous working step${details.demotedStepIds.length === 1 ? \"\" : \"s\"} returned to pending.`,\n\t\t});\n\t}\n\tif (details.verificationNudgeNeeded) {\n\t\tnotices.push({ status: \"warning\" as const, text: \"Completed work still needs attached evidence.\" });\n\t}\n\tconst status = details.error\n\t\t? \"error\"\n\t\t: blocked.length > 0\n\t\t\t? \"warning\"\n\t\t\t: active.length > 0\n\t\t\t\t? \"running\"\n\t\t\t\t: open.length === 0 && state.steps.length > 0\n\t\t\t\t\t? \"success\"\n\t\t\t\t\t: \"idle\";\n\treturn {\n\t\tlabel: \"task steps\",\n\t\taction: details.action,\n\t\tstatus,\n\t\tsummary,\n\t\trows,\n\t\tnotices,\n\t\temptyText: state.steps.length === 0 ? \"No tracked steps.\" : \"All open steps are done.\",\n\t\thiddenRowCount: Math.max(0, candidates.length - rows.length),\n\t};\n}\n\nexport function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"task_steps\",\n\t\tlabel: \"Task Steps\",\n\t\tdescription:\n\t\t\t\"Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.\",\n\t\tpromptSnippet: \"Track multi-step session work.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use for multi-step work; keep one in_progress step.\",\n\t\t\t\"Batch transitions; work the first open step; record evidence/blockers; skip unchanged narration.\",\n\t\t\t\"intake keeps every item; link goal requirementIds.\",\n\t\t\t\"advance completes current, then starts next pending.\",\n\t\t\t\"Attach completed tool_task IDs as evidence; goal completion rejects every open step.\",\n\t\t\t\"Before final, resolve or defer open work. goal owns outcomes; delegate owns workers.\",\n\t\t],\n\t\tparameters: taskStepsSchema,\n\t\texecutionMode: \"sequential\",\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return emptyOrchestrationCall();\n\t\t\tconst details = result.details as TaskStepsToolDetails | undefined;\n\t\t\tif (!details) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"task steps\",\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\temptyText: \"No task-step details were returned.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!expanded && details.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, taskStepsPanelModel(details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input: TaskStepsToolInput) {\n\t\t\tconst timestamp = now();\n\t\t\tconst current = deps.getTaskStepsState();\n\t\t\tconst before = current ?? createTaskStepsState(timestamp);\n\t\t\tlet state = before;\n\t\t\tlet duplicateStepId: string | undefined;\n\t\t\tlet demotedStepIds: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"set\":\n\t\t\t\t\tcase \"intake\": {\n\t\t\t\t\t\tconst steps = input.steps;\n\t\t\t\t\t\tif (!steps) {\n\t\t\t\t\t\t\tconst error =\n\t\t\t\t\t\t\t\tinput.action === \"set\" ? \"set requires steps[].\" : \"intake requires a complete steps[] list.\";\n\t\t\t\t\t\t\treturn errorResult(input.action, error, current);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalidatePipelineInputs(deps, steps);\n\t\t\t\t\t\tstate = setTaskSteps(state, steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(steps, state.steps));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"add\":\n\t\t\t\t\t\tvalidatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);\n\t\t\t\t\t\tstate = addTaskStep(state, toTaskStepInput(input), timestamp);\n\t\t\t\t\t\tif (state === before) {\n\t\t\t\t\t\t\t// The reducer returned the unchanged state: an open step already carries this\n\t\t\t\t\t\t\t// content, so nothing was created. Name the existing step in the response.\n\t\t\t\t\t\t\tduplicateStepId = findOpenDuplicateStep(before.steps, input.content ?? \"\")?.id;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\tif (!input.id?.trim())\n\t\t\t\t\t\t\treturn errorResult(input.action, \"update requires id or a unique selector.\", current);\n\t\t\t\t\t\tconst selected = resolveTaskStepSelector(before.steps, input.id);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tinput.pipelineRunId !== undefined ||\n\t\t\t\t\t\t\tinput.pipelineStageId !== undefined ||\n\t\t\t\t\t\t\tinput.clearPipelineLink === true\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst clearingPipelineLink = input.clearPipelineLink === true;\n\t\t\t\t\t\t\tvalidatePipelineLink(\n\t\t\t\t\t\t\t\tdeps,\n\t\t\t\t\t\t\t\tclearingPipelineLink ? input.pipelineRunId : (input.pipelineRunId ?? selected.pipelineRunId),\n\t\t\t\t\t\t\t\tclearingPipelineLink\n\t\t\t\t\t\t\t\t\t? input.pipelineStageId\n\t\t\t\t\t\t\t\t\t: (input.pipelineStageId ?? selected.pipelineStageId),\n\t\t\t\t\t\t\t\tclearingPipelineLink,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate = updateTaskStep(state, input.id, toTaskStepUpdate(input), timestamp);\n\t\t\t\t\t\t// Exclude the explicitly targeted step: its own status change was requested by\n\t\t\t\t\t\t// the caller, so it is never a \"silent\" demotion even if it moved to pending.\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"clear\":\n\t\t\t\t\t\tstate = clearTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"compact\":\n\t\t\t\t\t\tstate = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"advance\": {\n\t\t\t\t\t\tconst advanced = advanceTaskSteps(before, timestamp);\n\t\t\t\t\t\tstate = advanced.state;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\tif (input.clearCompleted) state = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst isNoopDuplicateAdd = input.action === \"add\" && state === before;\n\t\t\t\tconst mutated = (input.action !== \"list\" || input.clearCompleted === true) && !isNoopDuplicateAdd;\n\t\t\t\tif (mutated) deps.saveTaskStepsState(state);\n\n\t\t\t\tconst stateCounts = counts(state);\n\t\t\t\tconst noticeLines: string[] = [];\n\t\t\t\tif (duplicateStepId) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t`Duplicate open step ignored; existing ${duplicateStepId} already tracks this content.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (demotedStepIds.length > 0) {\n\t\t\t\t\tnoticeLines.push(`Demoted to pending because another step became active: ${demotedStepIds.join(\", \")}.`);\n\t\t\t\t}\n\t\t\t\tif (stateCounts.verificationNudgeNeeded) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t\"Reminder: a completed step has no evidence attached; attach evidence via update before treating it as verified.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst notices = noticeLines.length > 0 ? `\\n${noticeLines.join(\"\\n\")}` : \"\";\n\n\t\t\t\tconst headerAction =\n\t\t\t\t\tinput.action === \"list\"\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `task_steps ${input.action} ${duplicateStepId ? \"ignored (duplicate)\" : \"recorded\"}.\\n`;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `${headerAction}${formatTaskSteps(state, {\n\t\t\t\t\t\t\t\tincludeTerminal: input.showCompleted,\n\t\t\t\t\t\t\t\tmaxItems: input.maxItems,\n\t\t\t\t\t\t\t})}${notices}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\tapplied: true,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t...stateCounts,\n\t\t\t\t\t\tshowCompleted: input.showCompleted,\n\t\t\t\t\t\tduplicateOfStepId: duplicateStepId,\n\t\t\t\t\t\tdemotedStepIds: demotedStepIds.length > 0 ? demotedStepIds : undefined,\n\t\t\t\t\t} satisfies TaskStepsToolDetails,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn errorResult(input.action, error instanceof Error ? error.message : String(error), current);\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
@@ -34,7 +34,7 @@ export interface TmuxDispatchDeps {
|
|
|
34
34
|
* a creation refusal aborts cleanly before any tmux/pane side effect ever runs -- never a
|
|
35
35
|
* half-made lane, never a fabricated worktree. On success the dispatched agent's `cwd` is the new
|
|
36
36
|
* lane worktree and it carries `worktreeLane` (threaded to the tmux extension's launch profile --
|
|
37
|
-
* see `
|
|
37
|
+
* see `launch-profile.ts`'s `buildLaunchProfileFlags`). Absent dep -> existing byte-identical
|
|
38
38
|
* `params.agents` (no `cwd`/`worktreeLane`), exactly as before this field existed.
|
|
39
39
|
*/
|
|
40
40
|
createLaneWorktree?: (args: {
|
|
@@ -56,25 +56,13 @@ export interface TmuxDispatchDeps {
|
|
|
56
56
|
*/
|
|
57
57
|
evaluateWorkerLaneRefusal?: () => LaneWorkerRefusal | undefined;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Classify a `fire_task` launch failure into an honest, stable skip reason. For an UNATTENDED
|
|
61
|
-
* caller (`ctx.hasUI === false`, always true from the goal/idle path) `authorizeLaunch`'s ONLY
|
|
62
|
-
* refusal throw is the no-standing-grant error (`tmux-agent-manager/index.ts`'s `authorizeLaunch`,
|
|
63
|
-
* message containing the stable phrase "no standing grant") -- matched here by substring since the
|
|
64
|
-
* extension throws a plain `Error`, not a tagged error code (documented follow-up hardening, not
|
|
65
|
-
* blocking). Every other thrown error (a bad jobId, a live session-name collision,
|
|
66
|
-
* an environment failure) maps onto the generic `"tmux_dispatch_failed"` -- still surfaced through
|
|
67
|
-
* the existing `dispatchSkipReason` contract, never a crash and never a silently-ignored failure.
|
|
68
|
-
*/
|
|
69
|
-
export declare function classifyDispatchError(error: unknown): string;
|
|
70
59
|
/**
|
|
71
60
|
* Structurally dispatch ONE persistent tmux worker agent for a single goal requirement, by
|
|
72
61
|
* invoking the SAME `tmux_agent_manager` `fire_task` tool call the model itself would make. Core
|
|
73
62
|
* -- not model discretion -- decides WHEN this fires (the goal tool's `dispatchTarget:"tmux"`
|
|
74
|
-
* routing gates the call)
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* `dispatchSkipReason` contract on the goal tool's response.
|
|
63
|
+
* routing gates the call). The extension derives an immutable child profile from the parent's
|
|
64
|
+
* admitted worker surface and reserves it durably before launch; no separate approval handshake is
|
|
65
|
+
* involved. Any launch failure is surfaced through the existing `dispatchSkipReason` contract.
|
|
78
66
|
*/
|
|
79
67
|
export declare function dispatchTmuxWorker(deps: TmuxDispatchDeps, args: {
|
|
80
68
|
requirementId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmux-dispatch.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tmux-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAChC,gG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oB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACnE;;iDAE6C;IAC7C,SAAS,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACpC;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;KACtB,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClF;;;;;;;OAOG;IACH,yBAAyB,CAAC,EAAE,MAAM,iBAAiB,GAAG,SAAS,CAAC;CAChE;AAaD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACnD,OAAO,CAAC;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA+EnD"}
|
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Classify a `fire_task` launch failure into an honest, stable skip reason. For an UNATTENDED
|
|
3
|
-
* caller (`ctx.hasUI === false`, always true from the goal/idle path) `authorizeLaunch`'s ONLY
|
|
4
|
-
* refusal throw is the no-standing-grant error (`tmux-agent-manager/index.ts`'s `authorizeLaunch`,
|
|
5
|
-
* message containing the stable phrase "no standing grant") -- matched here by substring since the
|
|
6
|
-
* extension throws a plain `Error`, not a tagged error code (documented follow-up hardening, not
|
|
7
|
-
* blocking). Every other thrown error (a bad jobId, a live session-name collision,
|
|
8
|
-
* an environment failure) maps onto the generic `"tmux_dispatch_failed"` -- still surfaced through
|
|
9
|
-
* the existing `dispatchSkipReason` contract, never a crash and never a silently-ignored failure.
|
|
10
|
-
*/
|
|
11
|
-
export function classifyDispatchError(error) {
|
|
12
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
13
|
-
return message.includes("no standing grant") ? "no_standing_grant" : "tmux_dispatch_failed";
|
|
14
|
-
}
|
|
15
1
|
/**
|
|
16
2
|
* Structurally dispatch ONE persistent tmux worker agent for a single goal requirement, by
|
|
17
3
|
* invoking the SAME `tmux_agent_manager` `fire_task` tool call the model itself would make. Core
|
|
18
4
|
* -- not model discretion -- decides WHEN this fires (the goal tool's `dispatchTarget:"tmux"`
|
|
19
|
-
* routing gates the call)
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* `dispatchSkipReason` contract on the goal tool's response.
|
|
5
|
+
* routing gates the call). The extension derives an immutable child profile from the parent's
|
|
6
|
+
* admitted worker surface and reserves it durably before launch; no separate approval handshake is
|
|
7
|
+
* involved. Any launch failure is surfaced through the existing `dispatchSkipReason` contract.
|
|
23
8
|
*/
|
|
24
9
|
export async function dispatchTmuxWorker(deps, args) {
|
|
25
10
|
// Capability check FIRST -- before the tool-definition lookup and before createLaneWorktree --
|
|
@@ -86,8 +71,8 @@ export async function dispatchTmuxWorker(deps, args) {
|
|
|
86
71
|
try {
|
|
87
72
|
result = await toolDef.execute(toolCallId, params, ctx.signal, undefined, ctx);
|
|
88
73
|
}
|
|
89
|
-
catch
|
|
90
|
-
return { skipReason:
|
|
74
|
+
catch {
|
|
75
|
+
return { skipReason: "tmux_dispatch_failed" };
|
|
91
76
|
}
|
|
92
77
|
// Correlate: the extension reports its dispatch under its OWN caller-chosen laneId
|
|
93
78
|
// (`tmux:${job.id}:${agent.id}`, reconstructed here from the tool result's `details.job` --
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmux-dispatch.js","sourceRoot":"","sources":["../../../src/core/tools/tmux-dispatch.ts"],"names":[],"mappings":"AAuDA;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IACnD,MAA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EAAE,GAAG,CAAC,CAAC;IAChF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,EAAE,UAAU,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;IACrD,CAAC;IAED,mFAAmF;IACnF,4FAA4F;IAC5F,4FAA4F;IAC5F,yFAAyF;IACzF,sEAAsE;IACtE,MAAM,GAAG,GAAI,MAAM,CAAC,OAA6C,EAAE,GAAG,CAAC;IACvE,MAAM,OAAO,GAAG,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,UAAU,EAAE,0BAA0B,EAAE,CAAC;IAEhF,MAAM,YAAY,GAAG,QAAQ,GAAG,CAAC,EAAE,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IACpD,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACjE,OAAO,gBAAgB,KAAK,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,yBAAyB,EAAE,CAAC;AACjH,CAAC","sourcesContent":["import type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport type { LaneWorkerRefusal } from \"../model-capability.ts\";\n\n/**\n * Dependencies for {@link dispatchTmuxWorker}, injected from the construction site\n * (`RuntimeBuilder`) so the adapter itself stays a small, unit-testable, faux-tool-driven module\n * with no direct dependency on `AgentSession`/`ExtensionRunner`/`BackgroundLaneController`.\n */\nexport interface TmuxDispatchDeps {\n\t/** Runtime platform seam. Native Windows has no supported tmux backend; WSL reports `linux`. */\n\tplatform?: NodeJS.Platform;\n\t/** Look up a registered tool by name -- the SAME seam the model's own tool calls resolve\n\t * through (`AgentSession.getToolDefinition` -> `RuntimeBuilder.getToolDefinition`). `undefined`\n\t * when the tmux extension is not loaded in this session -- an honest, non-fatal skip, not a\n\t * crash and not a silent no-op. */\n\tgetToolDefinition: (name: string) => ToolDefinition | undefined;\n\t/** Build a fresh, non-turn-bound `ExtensionContext` for this call\n\t * (`ExtensionRunner.createContext()`) -- safe to invoke from the goal/idle path, outside any\n\t * live model turn. */\n\tcreateExtensionContext: () => ExtensionContext;\n\t/**\n\t * Confirm that the tmux extension's caller-chosen lane id (reconstructed below from the\n\t * `fire_task` result's `details.job`) was durably registered by the host. The returned id is\n\t * identity-preserving and is the same value `Requirement.boundLaneId` uses.\n\t */\n\tresolveManagedLaneId: (callerLaneId: string) => string | undefined;\n\t/** Active goal id, threaded onto the `fire_task` call so the dispatched lane is goal-tagged\n\t * (`ManagedLaneEvent.goalId`) -- `undefined` when no goal is active (dispatch still proceeds;\n\t * the resulting lane is simply untagged). */\n\tgetGoalId: () => string | undefined;\n\t/**\n\t * Worktree-sync lane-first dispatch (opt-in -- wired ONLY inside `runtime-builder.ts`'s\n\t * `worktreeSync.enabled` block, via the engine's `createLane`): when present, `dispatchTmuxWorker`\n\t * creates a fresh worktree-sync lane for this requirement BEFORE issuing any `fire_task` call, so\n\t * a creation refusal aborts cleanly before any tmux/pane side effect ever runs -- never a\n\t * half-made lane, never a fabricated worktree. On success the dispatched agent's `cwd` is the new\n\t * lane worktree and it carries `worktreeLane` (threaded to the tmux extension's launch profile --\n\t * see `dispatch-grant.ts`'s `buildLaunchProfileFlags`). Absent dep -> existing byte-identical\n\t * `params.agents` (no `cwd`/`worktreeLane`), exactly as before this field existed.\n\t */\n\tcreateLaneWorktree?: (args: {\n\t\tgoalId?: string;\n\t\trequirementId: string;\n\t}) => Promise<{ laneKey: string; worktreePath: string } | { skipReason: string }>;\n\t/**\n\t * Lane-worker capability eligibility (opt-in -- wired only from `runtime-builder.ts`, backed by\n\t * `AgentSession.getLaneWorkerRefusal`): checked FIRST, before `createLaneWorktree`, so an\n\t * ineligible model's dispatch is refused before any lane/pane side effect ever runs. This is the\n\t * parent's best-effort check only -- the dispatched child session refuses authoritatively at its\n\t * own startup (main.ts) regardless of what the parent decides here. Absent dep -> no capability\n\t * check runs, byte-identical to before this field existed.\n\t */\n\tevaluateWorkerLaneRefusal?: () => LaneWorkerRefusal | undefined;\n}\n\n/**\n * Classify a `fire_task` launch failure into an honest, stable skip reason. For an UNATTENDED\n * caller (`ctx.hasUI === false`, always true from the goal/idle path) `authorizeLaunch`'s ONLY\n * refusal throw is the no-standing-grant error (`tmux-agent-manager/index.ts`'s `authorizeLaunch`,\n * message containing the stable phrase \"no standing grant\") -- matched here by substring since the\n * extension throws a plain `Error`, not a tagged error code (documented follow-up hardening, not\n * blocking). Every other thrown error (a bad jobId, a live session-name collision,\n * an environment failure) maps onto the generic `\"tmux_dispatch_failed\"` -- still surfaced through\n * the existing `dispatchSkipReason` contract, never a crash and never a silently-ignored failure.\n */\nexport function classifyDispatchError(error: unknown): string {\n\tconst message = error instanceof Error ? error.message : String(error);\n\treturn message.includes(\"no standing grant\") ? \"no_standing_grant\" : \"tmux_dispatch_failed\";\n}\n\ninterface FireTaskResultDetails {\n\tjob?: {\n\t\tid?: string;\n\t\tagents?: ReadonlyArray<{ id?: string }>;\n\t};\n}\n\ninterface TmuxGuardResultDetails {\n\tguard?: { allowed?: boolean };\n}\n\n/**\n * Structurally dispatch ONE persistent tmux worker agent for a single goal requirement, by\n * invoking the SAME `tmux_agent_manager` `fire_task` tool call the model itself would make. Core\n * -- not model discretion -- decides WHEN this fires (the goal tool's `dispatchTarget:\"tmux\"`\n * routing gates the call); the launch itself always still goes through the extension's own\n * grant-gated `authorizeLaunch`, so an ungranted unattended call is honestly refused here (never a\n * silent launch, never a fabricated laneId) and the refusal is surfaced through the existing\n * `dispatchSkipReason` contract on the goal tool's response.\n */\nexport async function dispatchTmuxWorker(\n\tdeps: TmuxDispatchDeps,\n\targs: { requirementId: string; instructions: string },\n): Promise<{ laneId?: string; skipReason?: string }> {\n\t// Capability check FIRST -- before the tool-definition lookup and before createLaneWorktree --\n\t// so an ineligible model's dispatch is refused with zero lane/pane/tool side effect. The coarse\n\t// \"worker_capability_insufficient\" skip reason is the stable contract code on the goal tool's\n\t// response; the granular reason (class/window/tool-calling) lives only in the refusal object\n\t// itself, surfaced by the caller for logging (see model-capability.ts's formatLaneWorkerRefusal).\n\tif (deps.evaluateWorkerLaneRefusal?.() !== undefined) {\n\t\treturn { skipReason: \"worker_capability_insufficient\" };\n\t}\n\tif ((deps.platform ?? process.platform) === \"win32\") return { skipReason: \"tmux_unavailable\" };\n\n\tconst toolDef = deps.getToolDefinition(\"tmux_agent_manager\");\n\tif (!toolDef) return { skipReason: \"tmux_extension_not_loaded\" };\n\n\tconst goalId = deps.getGoalId();\n\tconst ctx = deps.createExtensionContext();\n\tconst toolCallId = `goal-dispatch:${goalId ?? \"?\"}:${args.requirementId}`;\n\ttry {\n\t\tconst guardResult = await toolDef.execute(`${toolCallId}:guard`, { action: \"guard\" }, ctx.signal, undefined, ctx);\n\t\tconst guard = (guardResult.details as TmuxGuardResultDetails | undefined)?.guard;\n\t\tif (guard?.allowed !== true) return { skipReason: \"tmux_unavailable\" };\n\t} catch {\n\t\t// A guard failure is side-effect free. Treat it as backend unavailability so the goal owner can\n\t\t// safely choose its native worker fallback without fabricating a tmux lane.\n\t\treturn { skipReason: \"tmux_unavailable\" };\n\t}\n\n\t// Availability first, then lane-first: when worktree-sync is wired, create the lane only after\n\t// tmux's pure guard succeeds and BEFORE any fire_task call so a\n\t// creation refusal (max lanes, invalid key, git error, ...) aborts cleanly with no tmux/pane side\n\t// effect ever having run. The specific engine refusal code is deliberately collapsed onto the one\n\t// stable `worktree_create_failed` skip reason -- same narrow `{laneId?, skipReason?}` contract\n\t// every other skip path here already uses; the engine's own detail lives in its audit log, not in\n\t// this narrow return.\n\tlet laneWorktree: { laneKey: string; worktreePath: string } | undefined;\n\tif (deps.createLaneWorktree) {\n\t\tconst created = await deps.createLaneWorktree({ goalId, requirementId: args.requirementId });\n\t\tif (\"skipReason\" in created) return { skipReason: \"worktree_create_failed\" };\n\t\tlaneWorktree = created;\n\t}\n\n\t// Single-agent 1:1 mapping: a bare fire_task with no `agents` defaults to a THREE-agent\n\t// team (pi/agy/codex -- `DEFAULT_AGENT_PROVIDERS`), which would mint three lanes for one\n\t// requirement. A goal-bound dispatch must map to exactly one lane, so `agents` is always\n\t// passed explicitly here.\n\tconst params = {\n\t\taction: \"fire_task\",\n\t\ttask: args.instructions,\n\t\tgoalId,\n\t\tagents: [\n\t\t\tlaneWorktree\n\t\t\t\t? {\n\t\t\t\t\t\tprovider: \"pi\",\n\t\t\t\t\t\tname: \"goal-worker\",\n\t\t\t\t\t\tcwd: laneWorktree.worktreePath,\n\t\t\t\t\t\tworktreeLane: laneWorktree.laneKey,\n\t\t\t\t\t}\n\t\t\t\t: { provider: \"pi\", name: \"goal-worker\" },\n\t\t],\n\t};\n\tlet result: Awaited<ReturnType<ToolDefinition[\"execute\"]>>;\n\ttry {\n\t\tresult = await toolDef.execute(toolCallId, params, ctx.signal, undefined, ctx);\n\t} catch (error) {\n\t\treturn { skipReason: classifyDispatchError(error) };\n\t}\n\n\t// Correlate: the extension reports its dispatch under its OWN caller-chosen laneId\n\t// (`tmux:${job.id}:${agent.id}`, reconstructed here from the tool result's `details.job` --\n\t// the same format `agentLaneId` builds extension-side) which the host's `recordManagedLane`\n\t// bridge preserves as the canonical durable id; `resolveManagedLaneId` confirms that the\n\t// matching dispatch report reached the host before the goal binds it.\n\tconst job = (result.details as FireTaskResultDetails | undefined)?.job;\n\tconst primary = job?.agents?.[0];\n\tif (!job?.id || !primary?.id) return { skipReason: \"tmux_dispatch_incomplete\" };\n\n\tconst callerLaneId = `tmux:${job.id}:${primary.id}`;\n\tconst registeredLaneId = deps.resolveManagedLaneId(callerLaneId);\n\treturn registeredLaneId === callerLaneId ? { laneId: callerLaneId } : { skipReason: \"lane_correlation_failed\" };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tmux-dispatch.js","sourceRoot":"","sources":["../../../src/core/tools/tmux-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AM,CAAC,OAA6C,EAAE,GAAG,CAAC;IACvE,MAAM,OAAO,GAAG,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,UAAU,EAAE,0BAA0B,EAAE,CAAC;IAEhF,MAAM,YAAY,GAAG,QAAQ,GAAG,CAAC,EAAE,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IACpD,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IACjE,OAAO,gBAAgB,KAAK,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,yBAAyB,EAAE,CAAC;AACjH,CAAC","sourcesContent":["import type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport type { LaneWorkerRefusal } from \"../model-capability.ts\";\n\n/**\n * Dependencies for {@link dispatchTmuxWorker}, injected from the construction site\n * (`RuntimeBuilder`) so the adapter itself stays a small, unit-testable, faux-tool-driven module\n * with no direct dependency on `AgentSession`/`ExtensionRunner`/`BackgroundLaneController`.\n */\nexport interface TmuxDispatchDeps {\n\t/** Runtime platform seam. Native Windows has no supported tmux backend; WSL reports `linux`. */\n\tplatform?: NodeJS.Platform;\n\t/** Look up a registered tool by name -- the SAME seam the model's own tool calls resolve\n\t * through (`AgentSession.getToolDefinition` -> `RuntimeBuilder.getToolDefinition`). `undefined`\n\t * when the tmux extension is not loaded in this session -- an honest, non-fatal skip, not a\n\t * crash and not a silent no-op. */\n\tgetToolDefinition: (name: string) => ToolDefinition | undefined;\n\t/** Build a fresh, non-turn-bound `ExtensionContext` for this call\n\t * (`ExtensionRunner.createContext()`) -- safe to invoke from the goal/idle path, outside any\n\t * live model turn. */\n\tcreateExtensionContext: () => ExtensionContext;\n\t/**\n\t * Confirm that the tmux extension's caller-chosen lane id (reconstructed below from the\n\t * `fire_task` result's `details.job`) was durably registered by the host. The returned id is\n\t * identity-preserving and is the same value `Requirement.boundLaneId` uses.\n\t */\n\tresolveManagedLaneId: (callerLaneId: string) => string | undefined;\n\t/** Active goal id, threaded onto the `fire_task` call so the dispatched lane is goal-tagged\n\t * (`ManagedLaneEvent.goalId`) -- `undefined` when no goal is active (dispatch still proceeds;\n\t * the resulting lane is simply untagged). */\n\tgetGoalId: () => string | undefined;\n\t/**\n\t * Worktree-sync lane-first dispatch (opt-in -- wired ONLY inside `runtime-builder.ts`'s\n\t * `worktreeSync.enabled` block, via the engine's `createLane`): when present, `dispatchTmuxWorker`\n\t * creates a fresh worktree-sync lane for this requirement BEFORE issuing any `fire_task` call, so\n\t * a creation refusal aborts cleanly before any tmux/pane side effect ever runs -- never a\n\t * half-made lane, never a fabricated worktree. On success the dispatched agent's `cwd` is the new\n\t * lane worktree and it carries `worktreeLane` (threaded to the tmux extension's launch profile --\n\t * see `launch-profile.ts`'s `buildLaunchProfileFlags`). Absent dep -> existing byte-identical\n\t * `params.agents` (no `cwd`/`worktreeLane`), exactly as before this field existed.\n\t */\n\tcreateLaneWorktree?: (args: {\n\t\tgoalId?: string;\n\t\trequirementId: string;\n\t}) => Promise<{ laneKey: string; worktreePath: string } | { skipReason: string }>;\n\t/**\n\t * Lane-worker capability eligibility (opt-in -- wired only from `runtime-builder.ts`, backed by\n\t * `AgentSession.getLaneWorkerRefusal`): checked FIRST, before `createLaneWorktree`, so an\n\t * ineligible model's dispatch is refused before any lane/pane side effect ever runs. This is the\n\t * parent's best-effort check only -- the dispatched child session refuses authoritatively at its\n\t * own startup (main.ts) regardless of what the parent decides here. Absent dep -> no capability\n\t * check runs, byte-identical to before this field existed.\n\t */\n\tevaluateWorkerLaneRefusal?: () => LaneWorkerRefusal | undefined;\n}\n\ninterface FireTaskResultDetails {\n\tjob?: {\n\t\tid?: string;\n\t\tagents?: ReadonlyArray<{ id?: string }>;\n\t};\n}\n\ninterface TmuxGuardResultDetails {\n\tguard?: { allowed?: boolean };\n}\n\n/**\n * Structurally dispatch ONE persistent tmux worker agent for a single goal requirement, by\n * invoking the SAME `tmux_agent_manager` `fire_task` tool call the model itself would make. Core\n * -- not model discretion -- decides WHEN this fires (the goal tool's `dispatchTarget:\"tmux\"`\n * routing gates the call). The extension derives an immutable child profile from the parent's\n * admitted worker surface and reserves it durably before launch; no separate approval handshake is\n * involved. Any launch failure is surfaced through the existing `dispatchSkipReason` contract.\n */\nexport async function dispatchTmuxWorker(\n\tdeps: TmuxDispatchDeps,\n\targs: { requirementId: string; instructions: string },\n): Promise<{ laneId?: string; skipReason?: string }> {\n\t// Capability check FIRST -- before the tool-definition lookup and before createLaneWorktree --\n\t// so an ineligible model's dispatch is refused with zero lane/pane/tool side effect. The coarse\n\t// \"worker_capability_insufficient\" skip reason is the stable contract code on the goal tool's\n\t// response; the granular reason (class/window/tool-calling) lives only in the refusal object\n\t// itself, surfaced by the caller for logging (see model-capability.ts's formatLaneWorkerRefusal).\n\tif (deps.evaluateWorkerLaneRefusal?.() !== undefined) {\n\t\treturn { skipReason: \"worker_capability_insufficient\" };\n\t}\n\tif ((deps.platform ?? process.platform) === \"win32\") return { skipReason: \"tmux_unavailable\" };\n\n\tconst toolDef = deps.getToolDefinition(\"tmux_agent_manager\");\n\tif (!toolDef) return { skipReason: \"tmux_extension_not_loaded\" };\n\n\tconst goalId = deps.getGoalId();\n\tconst ctx = deps.createExtensionContext();\n\tconst toolCallId = `goal-dispatch:${goalId ?? \"?\"}:${args.requirementId}`;\n\ttry {\n\t\tconst guardResult = await toolDef.execute(`${toolCallId}:guard`, { action: \"guard\" }, ctx.signal, undefined, ctx);\n\t\tconst guard = (guardResult.details as TmuxGuardResultDetails | undefined)?.guard;\n\t\tif (guard?.allowed !== true) return { skipReason: \"tmux_unavailable\" };\n\t} catch {\n\t\t// A guard failure is side-effect free. Treat it as backend unavailability so the goal owner can\n\t\t// safely choose its native worker fallback without fabricating a tmux lane.\n\t\treturn { skipReason: \"tmux_unavailable\" };\n\t}\n\n\t// Availability first, then lane-first: when worktree-sync is wired, create the lane only after\n\t// tmux's pure guard succeeds and BEFORE any fire_task call so a\n\t// creation refusal (max lanes, invalid key, git error, ...) aborts cleanly with no tmux/pane side\n\t// effect ever having run. The specific engine refusal code is deliberately collapsed onto the one\n\t// stable `worktree_create_failed` skip reason -- same narrow `{laneId?, skipReason?}` contract\n\t// every other skip path here already uses; the engine's own detail lives in its audit log, not in\n\t// this narrow return.\n\tlet laneWorktree: { laneKey: string; worktreePath: string } | undefined;\n\tif (deps.createLaneWorktree) {\n\t\tconst created = await deps.createLaneWorktree({ goalId, requirementId: args.requirementId });\n\t\tif (\"skipReason\" in created) return { skipReason: \"worktree_create_failed\" };\n\t\tlaneWorktree = created;\n\t}\n\n\t// Single-agent 1:1 mapping: a bare fire_task with no `agents` defaults to a THREE-agent\n\t// team (pi/agy/codex -- `DEFAULT_AGENT_PROVIDERS`), which would mint three lanes for one\n\t// requirement. A goal-bound dispatch must map to exactly one lane, so `agents` is always\n\t// passed explicitly here.\n\tconst params = {\n\t\taction: \"fire_task\",\n\t\ttask: args.instructions,\n\t\tgoalId,\n\t\tagents: [\n\t\t\tlaneWorktree\n\t\t\t\t? {\n\t\t\t\t\t\tprovider: \"pi\",\n\t\t\t\t\t\tname: \"goal-worker\",\n\t\t\t\t\t\tcwd: laneWorktree.worktreePath,\n\t\t\t\t\t\tworktreeLane: laneWorktree.laneKey,\n\t\t\t\t\t}\n\t\t\t\t: { provider: \"pi\", name: \"goal-worker\" },\n\t\t],\n\t};\n\tlet result: Awaited<ReturnType<ToolDefinition[\"execute\"]>>;\n\ttry {\n\t\tresult = await toolDef.execute(toolCallId, params, ctx.signal, undefined, ctx);\n\t} catch {\n\t\treturn { skipReason: \"tmux_dispatch_failed\" };\n\t}\n\n\t// Correlate: the extension reports its dispatch under its OWN caller-chosen laneId\n\t// (`tmux:${job.id}:${agent.id}`, reconstructed here from the tool result's `details.job` --\n\t// the same format `agentLaneId` builds extension-side) which the host's `recordManagedLane`\n\t// bridge preserves as the canonical durable id; `resolveManagedLaneId` confirms that the\n\t// matching dispatch report reached the host before the goal binds it.\n\tconst job = (result.details as FireTaskResultDetails | undefined)?.job;\n\tconst primary = job?.agents?.[0];\n\tif (!job?.id || !primary?.id) return { skipReason: \"tmux_dispatch_incomplete\" };\n\n\tconst callerLaneId = `tmux:${job.id}:${primary.id}`;\n\tconst registeredLaneId = deps.resolveManagedLaneId(callerLaneId);\n\treturn registeredLaneId === callerLaneId ? { laneId: callerLaneId } : { skipReason: \"lane_correlation_failed\" };\n}\n"]}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Worktree-sync SSOT for tagged result codes and shared record types.
|
|
3
3
|
*
|
|
4
4
|
* Every worktree-sync operation reports its outcome through one of these string-literal codes in
|
|
5
|
-
* a typed result -- callers branch on `code`, NEVER on message/stderr substrings
|
|
6
|
-
* `classifyDispatchError` substring compromise is deliberately not repeated here). Git stderr is
|
|
5
|
+
* a typed result -- callers branch on `code`, NEVER on message/stderr substrings. Git stderr is
|
|
7
6
|
* carried alongside as evidence for humans, not as a branch condition.
|
|
8
7
|
*/
|
|
9
8
|
/** Cap on `WorktreeSyncEpoch.changedPaths`; beyond it the list is truncated and overlap checks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-sync/codes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-sync/codes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;gGACgG;AAChG,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GACzB,IAAI,GACJ,UAAU,GACV,gBAAgB,GAChB,2BAA2B,GAC3B,aAAa,GACb,kBAAkB,GAClB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,EAAE,OAAO,CAAC;IACtB;0EACsE;IACtE,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;qEACqE;AACrE,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IACvC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC9E,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,gBAAgB,GACzB,UAAU,GACV,mBAAmB,CAAC,gBAAgB,GAAG,2BAA2B,GAAG,WAAW,CAAC,CAAC"}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Worktree-sync SSOT for tagged result codes and shared record types.
|
|
3
3
|
*
|
|
4
4
|
* Every worktree-sync operation reports its outcome through one of these string-literal codes in
|
|
5
|
-
* a typed result -- callers branch on `code`, NEVER on message/stderr substrings
|
|
6
|
-
* `classifyDispatchError` substring compromise is deliberately not repeated here). Git stderr is
|
|
5
|
+
* a typed result -- callers branch on `code`, NEVER on message/stderr substrings. Git stderr is
|
|
7
6
|
* carried alongside as evidence for humans, not as a branch condition.
|
|
8
7
|
*/
|
|
9
8
|
/** Cap on `WorktreeSyncEpoch.changedPaths`; beyond it the list is truncated and overlap checks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codes.js","sourceRoot":"","sources":["../../../src/core/worktree-sync/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;gGACgG;AAChG,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["/**\n * Worktree-sync SSOT for tagged result codes and shared record types.\n *\n * Every worktree-sync operation reports its outcome through one of these string-literal codes in\n * a typed result -- callers branch on `code`, NEVER on message/stderr substrings (the\n * `classifyDispatchError` substring compromise is deliberately not repeated here). Git stderr is\n * carried alongside as evidence for humans, not as a branch condition.\n */\n\n/** Cap on `WorktreeSyncEpoch.changedPaths`; beyond it the list is truncated and overlap checks\n * treat the land as conservatively overlapping EVERYTHING (deterministic, never optimistic). */\nexport const EPOCH_CHANGED_PATHS_CAP = 500;\n\n/** Branch namespace for lane branches: `pi/wt/<laneKey>`. */\nexport const LANE_BRANCH_PREFIX = \"pi/wt/\";\n\nexport type WorktreeSyncCode =\n\t| \"ok\"\n\t| \"disabled\"\n\t| \"not_a_git_repo\"\n\t| \"default_branch_unresolved\"\n\t| \"hub_missing\"\n\t| \"invalid_lane_key\"\n\t| \"lane_exists\"\n\t| \"lane_not_found\"\n\t| \"max_lanes_reached\"\n\t| \"lane_dirty\"\n\t| \"hub_dirty\"\n\t| \"stale_lane\"\n\t| \"sync_required\"\n\t| \"sync_clean\"\n\t| \"sync_conflicts\"\n\t| \"rebase_in_progress\"\n\t| \"no_rebase_in_progress\"\n\t| \"conflict_markers_present\"\n\t| \"gate_command_unset\"\n\t| \"gate_failed\"\n\t| \"lane_changed_during_gate\"\n\t| \"ff_failed\"\n\t| \"lock_busy\"\n\t| \"lock_takeover\"\n\t| \"nothing_to_land\"\n\t| \"main_mutation_refused\"\n\t| \"lane_unlanded_work\"\n\t| \"worktree_missing\"\n\t| \"released\"\n\t| \"reconciled\"\n\t| \"git_error\"\n\t| \"role_forbidden\"\n\t| \"path_outside_lane\"\n\t| \"lane_owner_conflict\";\n\n/**\n * A refusal/failure outcome. `message` is deterministic text assembled from facts (safe to show a\n * model verbatim); `gitStderr` is bounded raw evidence; `paths` names offending files where the\n * refusal is about specific files (dirty files, conflict markers); `holder` identifies the\n * integration-lock holder on `lock_busy`.\n */\nexport interface WorktreeSyncRefusal<C extends WorktreeSyncCode = WorktreeSyncCode> {\n\tcode: C;\n\tmessage: string;\n\tgitStderr?: string;\n\tpaths?: string[];\n\tholder?: IntegrationLockOwner;\n}\n\n/** Staleness-propagation policy (D9). `on_land_mandatory` is the default: every land marks every\n * other active lane sync_required. `overlap_mandatory` requires it only on changed-file overlap.\n * `land_time_only` keeps staleness advisory until the land gate (G3 always enforces). */\nexport type WorktreeSyncPolicy = \"on_land_mandatory\" | \"overlap_mandatory\" | \"land_time_only\";\n\n/** One lane registration record (`lanes/<laneKey>.json`). Identity/binding fields ONLY -- git\n * truths (freshness, dirtiness, ahead/behind) are always re-derived live, never stored here. */\nexport interface LaneRegistration {\n\tlaneKey: string;\n\tbranch: string;\n\tworktreePath: string;\n\tstatus: \"active\" | \"released\" | \"orphaned\";\n\tcreatedAt: string;\n\tupdatedAt: string;\n\tgoalId?: string;\n\trequirementId?: string;\n\t/** Host `LaneRecord.laneId` after dispatch correlation (tmux/in-process worker binding). */\n\tboundLaneId?: string;\n\townerPid?: number;\n\townerSessionId?: string;\n}\n\n/** `epoch.json` -- the integration epoch. `epoch` is monotonic messaging/audit sugar; correctness\n * always derives from git shas (`merge-base --is-ancestor`), never from this counter. */\nexport interface WorktreeSyncEpoch {\n\tepoch: number;\n\tmainSha: string;\n\tpreviousMainSha?: string;\n\tlandedLaneKey?: string;\n\tlandedAt?: string;\n\tchangedPaths: string[];\n\tchangedPathsTruncated: boolean;\n}\n\n/** Live, git-derived facts about one lane. Computed fresh per call -- there is no cached copy to\n * go stale, which is the point. */\nexport interface LaneFacts {\n\tlaneKey: string;\n\tbranch: string;\n\tworktreePath: string;\n\tregistrationStatus: LaneRegistration[\"status\"];\n\t/** Lane branch tip sha; undefined when the branch no longer exists. */\n\tbranchSha?: string;\n\t/** True iff current main is an ancestor of the lane tip (`merge-base --is-ancestor`). */\n\tfresh: boolean;\n\t/** True when `status --porcelain` in the lane worktree is non-empty. */\n\tdirty: boolean;\n\trebaseInProgress: boolean;\n\taheadOfMain: number;\n\tbehindMain: number;\n\tworktreePresent: boolean;\n\t/** Undefined when the lane has no recorded owner pid. */\n\townerAlive?: boolean;\n}\n\nexport interface IntegrationLockOwner {\n\tpid: number;\n\thostname: string;\n\t/** Random acquisition identity; PID/session are diagnostic only and never authorize release. */\n\ttoken: string;\n\tsessionId?: string;\n\tlaneKey?: string;\n\tacquiredAt: string;\n}\n\nexport type IntegrationLockAcquisition =\n\t| { acquired: true; takeover: boolean; token: string }\n\t| { acquired: false; holder?: IntegrationLockOwner; holderAlive: boolean };\n\n/** One conflicted file in a sync stopped on conflicts. */\nexport interface ConflictWorklistFile {\n\tpath: string;\n\t/** Both-modified is the common case; add/add and modify/delete surface as their index states. */\n\tkind: \"both_modified\" | \"both_added\" | \"deleted_by_us\" | \"deleted_by_them\" | \"unknown\";\n\t/** True when git rerere already replayed a recorded resolution for this file -- review, not re-resolve. */\n\tresolvedByRerere: boolean;\n}\n\n/** Structured conflict worklist returned when a sync/continue stops on conflicts. */\nexport interface ConflictWorklist {\n\t/** e.g. \"2/5\" -- rebase progress (stopped step / total steps). */\n\tstep: string;\n\tstoppedAtCommit?: { sha: string; subject: string };\n\tfiles: ConflictWorklistFile[];\n}\n\nexport type BindLaneWorkerResult =\n\t| { code: \"bound\"; laneKey: string; laneId: string }\n\t| { code: \"already_bound\"; laneKey: string; laneId: string }\n\t| { code: \"binding_conflict\"; laneKey: string; boundLaneId: string }\n\t| { code: \"lane_not_found\"; message: string }\n\t| { code: \"lane_not_active\"; message: string }\n\t| { code: \"store_error\"; message: string };\n\nexport type CreateLaneResult =\n\t| { code: \"ok\"; lane: LaneRegistration }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"invalid_lane_key\"\n\t\t\t| \"lane_exists\"\n\t\t\t| \"max_lanes_reached\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type ReleaseLaneResult =\n\t| { code: \"released\"; laneKey: string }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"lane_unlanded_work\"\n\t\t\t| \"lane_owner_conflict\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport interface LandingTransaction {\n\tlaneKey: string;\n\tpriorMainSha: string;\n\ttestedTipSha: string;\n\tchangedPaths: string[];\n\tchangedPathsTruncated: boolean;\n\tlockToken: string;\n\tgate: \"passed\" | \"off\";\n\tstage: \"ready_to_merge\" | \"main_moved\" | \"epoch_written\" | \"audit_logged\";\n}\n\nexport interface ReconcileSummary {\n\tcode: \"reconciled\";\n\torphanedLaneKeys: string[];\n\treRegisteredLaneKeys: string[];\n\townerClearedLaneKeys: string[];\n\tstaleLockReleased: boolean;\n}\n\nexport type ReconcileResult =\n\t| ReconcileSummary\n\t| WorktreeSyncRefusal<\"not_a_git_repo\" | \"default_branch_unresolved\" | \"git_error\">;\n\nexport type SyncLaneResult =\n\t| { code: \"sync_clean\"; laneKey: string; alreadyFresh: boolean; autoContinued: number }\n\t| { code: \"sync_conflicts\"; laneKey: string; worklist: ConflictWorklist }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"lane_dirty\"\n\t\t\t| \"rebase_in_progress\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type ContinueSyncResult =\n\t| { code: \"sync_clean\"; laneKey: string; autoContinued: number }\n\t| { code: \"sync_conflicts\"; laneKey: string; worklist: ConflictWorklist }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"no_rebase_in_progress\"\n\t\t\t| \"conflict_markers_present\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type AbortSyncResult =\n\t| { code: \"ok\"; laneKey: string }\n\t| WorktreeSyncRefusal<\n\t\t\t\"not_a_git_repo\" | \"default_branch_unresolved\" | \"lane_not_found\" | \"no_rebase_in_progress\" | \"git_error\"\n\t >;\n\nexport type LandResult =\n\t| { code: \"ok\"; laneKey: string; epoch: number; mainSha: string; gate: \"passed\" | \"off\" }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"rebase_in_progress\"\n\t\t\t| \"lane_dirty\"\n\t\t\t| \"stale_lane\"\n\t\t\t| \"hub_missing\"\n\t\t\t| \"hub_dirty\"\n\t\t\t| \"gate_command_unset\"\n\t\t\t| \"gate_failed\"\n\t\t\t| \"lane_changed_during_gate\"\n\t\t\t| \"ff_failed\"\n\t\t\t| \"lock_busy\"\n\t\t\t| \"nothing_to_land\"\n\t\t\t| \"lane_owner_conflict\"\n\t\t\t| \"git_error\"\n\t >;\n\n/** One lane's full status entry: live git facts plus registry identity plus policy derivation. */\nexport interface LaneStatusEntry extends LaneFacts {\n\tgoalId?: string;\n\trequirementId?: string;\n\tboundLaneId?: string;\n\t/** Not fresh: main moved past this lane's base. Derived, never stored. */\n\tstale: boolean;\n\t/** Stale AND the active policy makes syncing mandatory NOW (G8 gates on this). */\n\tsyncRequired: boolean;\n\t/** Lane-changed files intersecting the last land's changed files (conservatively the whole\n\t * lane-changed list when the epoch's changedPaths were truncated). */\n\toverlapWithLastLand: string[];\n}\n\n/** The deterministic full picture (`status` action): everything an agent would otherwise infer\n * probabilistically from porcelain output, computed mechanically. */\nexport interface SyncStatus {\n\tcode: \"ok\";\n\tmainBranch: string;\n\tmainSha: string;\n\tepoch: number;\n\thub?: { path: string; clean: boolean };\n\tlock: { held: boolean; holder?: IntegrationLockOwner; holderAlive?: boolean };\n\tlanes: LaneStatusEntry[];\n\t/** One deterministic advisory sentence assembled from the codes above; never model-generated. */\n\tadvice?: string;\n}\n\nexport type SyncStatusResult =\n\t| SyncStatus\n\t| WorktreeSyncRefusal<\"not_a_git_repo\" | \"default_branch_unresolved\" | \"git_error\">;\n"]}
|
|
1
|
+
{"version":3,"file":"codes.js","sourceRoot":"","sources":["../../../src/core/worktree-sync/codes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;gGACgG;AAChG,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["/**\n * Worktree-sync SSOT for tagged result codes and shared record types.\n *\n * Every worktree-sync operation reports its outcome through one of these string-literal codes in\n * a typed result -- callers branch on `code`, NEVER on message/stderr substrings. Git stderr is\n * carried alongside as evidence for humans, not as a branch condition.\n */\n\n/** Cap on `WorktreeSyncEpoch.changedPaths`; beyond it the list is truncated and overlap checks\n * treat the land as conservatively overlapping EVERYTHING (deterministic, never optimistic). */\nexport const EPOCH_CHANGED_PATHS_CAP = 500;\n\n/** Branch namespace for lane branches: `pi/wt/<laneKey>`. */\nexport const LANE_BRANCH_PREFIX = \"pi/wt/\";\n\nexport type WorktreeSyncCode =\n\t| \"ok\"\n\t| \"disabled\"\n\t| \"not_a_git_repo\"\n\t| \"default_branch_unresolved\"\n\t| \"hub_missing\"\n\t| \"invalid_lane_key\"\n\t| \"lane_exists\"\n\t| \"lane_not_found\"\n\t| \"max_lanes_reached\"\n\t| \"lane_dirty\"\n\t| \"hub_dirty\"\n\t| \"stale_lane\"\n\t| \"sync_required\"\n\t| \"sync_clean\"\n\t| \"sync_conflicts\"\n\t| \"rebase_in_progress\"\n\t| \"no_rebase_in_progress\"\n\t| \"conflict_markers_present\"\n\t| \"gate_command_unset\"\n\t| \"gate_failed\"\n\t| \"lane_changed_during_gate\"\n\t| \"ff_failed\"\n\t| \"lock_busy\"\n\t| \"lock_takeover\"\n\t| \"nothing_to_land\"\n\t| \"main_mutation_refused\"\n\t| \"lane_unlanded_work\"\n\t| \"worktree_missing\"\n\t| \"released\"\n\t| \"reconciled\"\n\t| \"git_error\"\n\t| \"role_forbidden\"\n\t| \"path_outside_lane\"\n\t| \"lane_owner_conflict\";\n\n/**\n * A refusal/failure outcome. `message` is deterministic text assembled from facts (safe to show a\n * model verbatim); `gitStderr` is bounded raw evidence; `paths` names offending files where the\n * refusal is about specific files (dirty files, conflict markers); `holder` identifies the\n * integration-lock holder on `lock_busy`.\n */\nexport interface WorktreeSyncRefusal<C extends WorktreeSyncCode = WorktreeSyncCode> {\n\tcode: C;\n\tmessage: string;\n\tgitStderr?: string;\n\tpaths?: string[];\n\tholder?: IntegrationLockOwner;\n}\n\n/** Staleness-propagation policy (D9). `on_land_mandatory` is the default: every land marks every\n * other active lane sync_required. `overlap_mandatory` requires it only on changed-file overlap.\n * `land_time_only` keeps staleness advisory until the land gate (G3 always enforces). */\nexport type WorktreeSyncPolicy = \"on_land_mandatory\" | \"overlap_mandatory\" | \"land_time_only\";\n\n/** One lane registration record (`lanes/<laneKey>.json`). Identity/binding fields ONLY -- git\n * truths (freshness, dirtiness, ahead/behind) are always re-derived live, never stored here. */\nexport interface LaneRegistration {\n\tlaneKey: string;\n\tbranch: string;\n\tworktreePath: string;\n\tstatus: \"active\" | \"released\" | \"orphaned\";\n\tcreatedAt: string;\n\tupdatedAt: string;\n\tgoalId?: string;\n\trequirementId?: string;\n\t/** Host `LaneRecord.laneId` after dispatch correlation (tmux/in-process worker binding). */\n\tboundLaneId?: string;\n\townerPid?: number;\n\townerSessionId?: string;\n}\n\n/** `epoch.json` -- the integration epoch. `epoch` is monotonic messaging/audit sugar; correctness\n * always derives from git shas (`merge-base --is-ancestor`), never from this counter. */\nexport interface WorktreeSyncEpoch {\n\tepoch: number;\n\tmainSha: string;\n\tpreviousMainSha?: string;\n\tlandedLaneKey?: string;\n\tlandedAt?: string;\n\tchangedPaths: string[];\n\tchangedPathsTruncated: boolean;\n}\n\n/** Live, git-derived facts about one lane. Computed fresh per call -- there is no cached copy to\n * go stale, which is the point. */\nexport interface LaneFacts {\n\tlaneKey: string;\n\tbranch: string;\n\tworktreePath: string;\n\tregistrationStatus: LaneRegistration[\"status\"];\n\t/** Lane branch tip sha; undefined when the branch no longer exists. */\n\tbranchSha?: string;\n\t/** True iff current main is an ancestor of the lane tip (`merge-base --is-ancestor`). */\n\tfresh: boolean;\n\t/** True when `status --porcelain` in the lane worktree is non-empty. */\n\tdirty: boolean;\n\trebaseInProgress: boolean;\n\taheadOfMain: number;\n\tbehindMain: number;\n\tworktreePresent: boolean;\n\t/** Undefined when the lane has no recorded owner pid. */\n\townerAlive?: boolean;\n}\n\nexport interface IntegrationLockOwner {\n\tpid: number;\n\thostname: string;\n\t/** Random acquisition identity; PID/session are diagnostic only and never authorize release. */\n\ttoken: string;\n\tsessionId?: string;\n\tlaneKey?: string;\n\tacquiredAt: string;\n}\n\nexport type IntegrationLockAcquisition =\n\t| { acquired: true; takeover: boolean; token: string }\n\t| { acquired: false; holder?: IntegrationLockOwner; holderAlive: boolean };\n\n/** One conflicted file in a sync stopped on conflicts. */\nexport interface ConflictWorklistFile {\n\tpath: string;\n\t/** Both-modified is the common case; add/add and modify/delete surface as their index states. */\n\tkind: \"both_modified\" | \"both_added\" | \"deleted_by_us\" | \"deleted_by_them\" | \"unknown\";\n\t/** True when git rerere already replayed a recorded resolution for this file -- review, not re-resolve. */\n\tresolvedByRerere: boolean;\n}\n\n/** Structured conflict worklist returned when a sync/continue stops on conflicts. */\nexport interface ConflictWorklist {\n\t/** e.g. \"2/5\" -- rebase progress (stopped step / total steps). */\n\tstep: string;\n\tstoppedAtCommit?: { sha: string; subject: string };\n\tfiles: ConflictWorklistFile[];\n}\n\nexport type BindLaneWorkerResult =\n\t| { code: \"bound\"; laneKey: string; laneId: string }\n\t| { code: \"already_bound\"; laneKey: string; laneId: string }\n\t| { code: \"binding_conflict\"; laneKey: string; boundLaneId: string }\n\t| { code: \"lane_not_found\"; message: string }\n\t| { code: \"lane_not_active\"; message: string }\n\t| { code: \"store_error\"; message: string };\n\nexport type CreateLaneResult =\n\t| { code: \"ok\"; lane: LaneRegistration }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"invalid_lane_key\"\n\t\t\t| \"lane_exists\"\n\t\t\t| \"max_lanes_reached\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type ReleaseLaneResult =\n\t| { code: \"released\"; laneKey: string }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"lane_unlanded_work\"\n\t\t\t| \"lane_owner_conflict\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport interface LandingTransaction {\n\tlaneKey: string;\n\tpriorMainSha: string;\n\ttestedTipSha: string;\n\tchangedPaths: string[];\n\tchangedPathsTruncated: boolean;\n\tlockToken: string;\n\tgate: \"passed\" | \"off\";\n\tstage: \"ready_to_merge\" | \"main_moved\" | \"epoch_written\" | \"audit_logged\";\n}\n\nexport interface ReconcileSummary {\n\tcode: \"reconciled\";\n\torphanedLaneKeys: string[];\n\treRegisteredLaneKeys: string[];\n\townerClearedLaneKeys: string[];\n\tstaleLockReleased: boolean;\n}\n\nexport type ReconcileResult =\n\t| ReconcileSummary\n\t| WorktreeSyncRefusal<\"not_a_git_repo\" | \"default_branch_unresolved\" | \"git_error\">;\n\nexport type SyncLaneResult =\n\t| { code: \"sync_clean\"; laneKey: string; alreadyFresh: boolean; autoContinued: number }\n\t| { code: \"sync_conflicts\"; laneKey: string; worklist: ConflictWorklist }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"lane_dirty\"\n\t\t\t| \"rebase_in_progress\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type ContinueSyncResult =\n\t| { code: \"sync_clean\"; laneKey: string; autoContinued: number }\n\t| { code: \"sync_conflicts\"; laneKey: string; worklist: ConflictWorklist }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"no_rebase_in_progress\"\n\t\t\t| \"conflict_markers_present\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type AbortSyncResult =\n\t| { code: \"ok\"; laneKey: string }\n\t| WorktreeSyncRefusal<\n\t\t\t\"not_a_git_repo\" | \"default_branch_unresolved\" | \"lane_not_found\" | \"no_rebase_in_progress\" | \"git_error\"\n\t >;\n\nexport type LandResult =\n\t| { code: \"ok\"; laneKey: string; epoch: number; mainSha: string; gate: \"passed\" | \"off\" }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"rebase_in_progress\"\n\t\t\t| \"lane_dirty\"\n\t\t\t| \"stale_lane\"\n\t\t\t| \"hub_missing\"\n\t\t\t| \"hub_dirty\"\n\t\t\t| \"gate_command_unset\"\n\t\t\t| \"gate_failed\"\n\t\t\t| \"lane_changed_during_gate\"\n\t\t\t| \"ff_failed\"\n\t\t\t| \"lock_busy\"\n\t\t\t| \"nothing_to_land\"\n\t\t\t| \"lane_owner_conflict\"\n\t\t\t| \"git_error\"\n\t >;\n\n/** One lane's full status entry: live git facts plus registry identity plus policy derivation. */\nexport interface LaneStatusEntry extends LaneFacts {\n\tgoalId?: string;\n\trequirementId?: string;\n\tboundLaneId?: string;\n\t/** Not fresh: main moved past this lane's base. Derived, never stored. */\n\tstale: boolean;\n\t/** Stale AND the active policy makes syncing mandatory NOW (G8 gates on this). */\n\tsyncRequired: boolean;\n\t/** Lane-changed files intersecting the last land's changed files (conservatively the whole\n\t * lane-changed list when the epoch's changedPaths were truncated). */\n\toverlapWithLastLand: string[];\n}\n\n/** The deterministic full picture (`status` action): everything an agent would otherwise infer\n * probabilistically from porcelain output, computed mechanically. */\nexport interface SyncStatus {\n\tcode: \"ok\";\n\tmainBranch: string;\n\tmainSha: string;\n\tepoch: number;\n\thub?: { path: string; clean: boolean };\n\tlock: { held: boolean; holder?: IntegrationLockOwner; holderAlive?: boolean };\n\tlanes: LaneStatusEntry[];\n\t/** One deterministic advisory sentence assembled from the codes above; never model-generated. */\n\tadvice?: string;\n}\n\nexport type SyncStatusResult =\n\t| SyncStatus\n\t| WorktreeSyncRefusal<\"not_a_git_repo\" | \"default_branch_unresolved\" | \"git_error\">;\n"]}
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* write / bash) with {@link WorktreeLaneGate.checkMutation}; a lane that the active policy marks
|
|
5
5
|
* sync_required fails closed with the exact recovery step until it rebases main.
|
|
6
6
|
*
|
|
7
|
-
* Honesty boundary
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Honesty boundary: edit/write checks are structural for Pi children because the wrapper lives
|
|
8
|
+
* under the tool layer. Bash remains a deliberate host-trust boundary; this gate only rejects
|
|
9
|
+
* integration-sensitive Git forms and never claims to sandbox arbitrary process code. Foreign
|
|
10
|
+
* CLIs stay cooperative-only, with the land CAS (G3) as their backstop.
|
|
10
11
|
*
|
|
11
12
|
* Determinism: the gate re-derives from git only when the epoch file actually changed (mtime
|
|
12
13
|
* fence) or while blocked; verdicts in between are cached. No polling, no timers.
|
|
@@ -44,11 +45,6 @@ export interface WorktreeLaneGateConfig {
|
|
|
44
45
|
laneKey: string;
|
|
45
46
|
engineDeps: () => WorktreeSyncEngineDeps;
|
|
46
47
|
policy: () => WorktreeSyncPolicy;
|
|
47
|
-
/** Worker launches use a hard shell envelope: only lane-safe Git/WIP commands and the owner-configured
|
|
48
|
-
* exact gate command may pass through bash. Interactive lane sessions retain the legacy cooperative
|
|
49
|
-
* command surface while the typed worktree_sync actions are used for hard worker mutations. */
|
|
50
|
-
hardShell?: boolean;
|
|
51
|
-
trustedGateCommand?: () => string | undefined;
|
|
52
48
|
}
|
|
53
49
|
export type LaneMutationCheck = {
|
|
54
50
|
allowed: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-gate.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-sync/lane-gate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lane-gate.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-sync/lane-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAyD,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGrH,MAAM,MAAM,eAAe,GACxB;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,GACtB;IAAE,OAAO,EAAE,iCAAiC,CAAA;CAAE,GAC9C;IAAE,OAAO,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAkBxD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe,CAiF5F;AA8BD,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CASnF;AAED,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGnG;AAED,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,sBAAsB,CAAC;IACzC,MAAM,EAAE,MAAM,kBAAkB,CAAC;CACjC;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAsBtG;;;GAGG;AACH,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,IAAI,CAA0B;IACtC,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,cAAc,CAAS;IAE/B,YAAY,MAAM,EAAE,sBAAsB,EAEzC;YAEa,cAAc;IAQ5B,8EAA8E;IAC9E,OAAO,CAAC,YAAY;IAYd,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0F3G;CACD"}
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* write / bash) with {@link WorktreeLaneGate.checkMutation}; a lane that the active policy marks
|
|
5
5
|
* sync_required fails closed with the exact recovery step until it rebases main.
|
|
6
6
|
*
|
|
7
|
-
* Honesty boundary
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Honesty boundary: edit/write checks are structural for Pi children because the wrapper lives
|
|
8
|
+
* under the tool layer. Bash remains a deliberate host-trust boundary; this gate only rejects
|
|
9
|
+
* integration-sensitive Git forms and never claims to sandbox arbitrary process code. Foreign
|
|
10
|
+
* CLIs stay cooperative-only, with the land CAS (G3) as their backstop.
|
|
10
11
|
*
|
|
11
12
|
* Determinism: the gate re-derives from git only when the epoch file actually changed (mtime
|
|
12
13
|
* fence) or while blocked; verdicts in between are cached. No polling, no timers.
|
|
@@ -184,24 +185,6 @@ async function changedPaths(deps, cwd, base, ref) {
|
|
|
184
185
|
.map((path) => path.trim())
|
|
185
186
|
.filter(Boolean));
|
|
186
187
|
}
|
|
187
|
-
function hardShellCommandAllowed(command, mainBranch, trustedGateCommand) {
|
|
188
|
-
const trimmed = command.trim();
|
|
189
|
-
if (trustedGateCommand && trimmed === trustedGateCommand.trim())
|
|
190
|
-
return true;
|
|
191
|
-
if (!/^git(?:\s|$)/u.test(trimmed))
|
|
192
|
-
return false;
|
|
193
|
-
const verdict = classifyLaneBashCommand(trimmed, mainBranch);
|
|
194
|
-
if (verdict.verdict === "main_mutation_refused")
|
|
195
|
-
return false;
|
|
196
|
-
const tokens = trimmed.split(/\s+/u);
|
|
197
|
-
const subcommand = tokens[1] ?? "";
|
|
198
|
-
if (!SYNC_SAFE_GIT_SUBCOMMANDS.has(subcommand) && subcommand !== "commit")
|
|
199
|
-
return false;
|
|
200
|
-
// Git path operands must not escape the lane checkout. The typed worktree
|
|
201
|
-
// actions are the authoritative route for path-sensitive add/diff operations;
|
|
202
|
-
// this final check prevents the common absolute/parent escape in the shell floor.
|
|
203
|
-
return !tokens.slice(2).some((token) => token.startsWith("/") || token.startsWith("..") || token.includes("/../"));
|
|
204
|
-
}
|
|
205
188
|
/**
|
|
206
189
|
* The G8 gate object RuntimeBuilder holds per lane-bound session. `checkMutation` is called by
|
|
207
190
|
* the wrapped edit/write/bash tools before every mutating execution.
|
|
@@ -237,24 +220,9 @@ export class WorktreeLaneGate {
|
|
|
237
220
|
async checkMutation(toolName, bashCommand, targetPath) {
|
|
238
221
|
const ctx = await this.resolveContext();
|
|
239
222
|
// No repo context (deleted repo, engine failure): fail OPEN for plain tools -- the land
|
|
240
|
-
// CAS still holds -- but the
|
|
223
|
+
// CAS still holds -- but the integration-sensitive Git rules below never depend on repo state.
|
|
241
224
|
const mainBranch = ctx?.mainBranch ?? "main";
|
|
242
|
-
if (this.config.hardShell && !ctx) {
|
|
243
|
-
return {
|
|
244
|
-
allowed: false,
|
|
245
|
-
code: "lane_state_unavailable",
|
|
246
|
-
message: "worktree-sync: lane state is unavailable; hard worker mutations fail closed",
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
225
|
if (toolName === "bash" && bashCommand !== undefined) {
|
|
250
|
-
if (this.config.hardShell &&
|
|
251
|
-
!hardShellCommandAllowed(bashCommand, mainBranch, this.config.trustedGateCommand?.())) {
|
|
252
|
-
return {
|
|
253
|
-
allowed: false,
|
|
254
|
-
code: "main_mutation_refused",
|
|
255
|
-
message: "worktree-sync: unrestricted bash is unavailable in a hard worker lane; use typed worktree_sync actions",
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
226
|
const verdict = classifyLaneBashCommand(bashCommand, mainBranch);
|
|
259
227
|
if (verdict.verdict === "main_mutation_refused") {
|
|
260
228
|
return { allowed: false, code: "main_mutation_refused", message: `worktree-sync: ${verdict.reason}` };
|
|
@@ -284,26 +252,12 @@ export class WorktreeLaneGate {
|
|
|
284
252
|
const deps = this.config.engineDeps();
|
|
285
253
|
const lane = await readLane(ctx.paths, this.config.laneKey);
|
|
286
254
|
if (!lane || lane.status !== "active") {
|
|
287
|
-
if (this.config.hardShell) {
|
|
288
|
-
return {
|
|
289
|
-
allowed: false,
|
|
290
|
-
code: "lane_state_unavailable",
|
|
291
|
-
message: "worktree-sync: hard worker lane registration is missing or inactive; reconcile before mutating",
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
255
|
this._cachedAllowed = true;
|
|
295
256
|
return { allowed: true };
|
|
296
257
|
}
|
|
297
258
|
// Re-derive main tip: the cached ctx pins the sha from session start.
|
|
298
259
|
const fresh = await resolveRepoContext(deps);
|
|
299
260
|
if ("code" in fresh) {
|
|
300
|
-
if (this.config.hardShell) {
|
|
301
|
-
return {
|
|
302
|
-
allowed: false,
|
|
303
|
-
code: "lane_state_unavailable",
|
|
304
|
-
message: "worktree-sync: Git context is unavailable; hard worker mutation refused",
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
261
|
this._cachedAllowed = true;
|
|
308
262
|
return { allowed: true };
|
|
309
263
|
}
|