@caupulican/pi-adaptative 0.81.40 → 0.81.42
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 +41 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +1 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +5 -1
- package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +3 -3
- package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +8 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +26 -3
- package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +3 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +4 -1
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +2 -1
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +2 -0
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +22 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-paths.d.ts +38 -0
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +77 -0
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +311 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -0
- package/dist/core/agent-session-contracts.js +26 -0
- package/dist/core/agent-session-contracts.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +26 -405
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +90 -316
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +2 -0
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js +4 -9
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +3 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +19 -5
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/path-scope.d.ts +14 -0
- package/dist/core/autonomy/path-scope.d.ts.map +1 -1
- package/dist/core/autonomy/path-scope.js +37 -6
- package/dist/core/autonomy/path-scope.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +30 -2
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +33 -1
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts +16 -0
- package/dist/core/bedrock-sso-login.d.ts.map +1 -0
- package/dist/core/bedrock-sso-login.js +98 -0
- package/dist/core/bedrock-sso-login.js.map +1 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +1 -1
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +3 -8
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +3 -3
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -1
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +7 -33
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +5 -3
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +4 -5
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts +11 -1
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.js +84 -41
- package/dist/core/delegation/managed-lane-controller.js.map +1 -1
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/session-worker-claim.js +4 -3
- package/dist/core/delegation/session-worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-action-journal.d.ts +73 -0
- package/dist/core/delegation/worker-action-journal.d.ts.map +1 -0
- package/dist/core/delegation/worker-action-journal.js +297 -0
- package/dist/core/delegation/worker-action-journal.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +36 -1
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +171 -46
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +75 -0
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-agent-control-coordinator.js +218 -0
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-agent-control.d.ts +66 -0
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -0
- package/dist/core/delegation/worker-agent-control.js +163 -0
- package/dist/core/delegation/worker-agent-control.js.map +1 -0
- package/dist/core/delegation/worker-attempt-executor.d.ts +80 -0
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -0
- package/dist/core/delegation/worker-attempt-executor.js +343 -0
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -0
- package/dist/core/delegation/worker-claim.d.ts +30 -0
- package/dist/core/delegation/worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/worker-claim.js +205 -53
- package/dist/core/delegation/worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-conversation-store.d.ts +116 -0
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -0
- package/dist/core/delegation/worker-conversation-store.js +442 -0
- package/dist/core/delegation/worker-conversation-store.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +21 -5
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +386 -251
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +14 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +4 -2
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.js +16 -6
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts +2 -1
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +5 -7
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts +44 -1
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +120 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-process-owner.d.ts +18 -0
- package/dist/core/delegation/worker-process-owner.d.ts.map +1 -0
- package/dist/core/delegation/worker-process-owner.js +54 -0
- package/dist/core/delegation/worker-process-owner.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +5 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +8 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.d.ts +54 -0
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-recovery-coordinator.js +181 -0
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-resource-catalog.d.ts +32 -0
- package/dist/core/delegation/worker-resource-catalog.d.ts.map +1 -0
- package/dist/core/delegation/worker-resource-catalog.js +116 -0
- package/dist/core/delegation/worker-resource-catalog.js.map +1 -0
- package/dist/core/delegation/worker-resource-materializer.d.ts +47 -0
- package/dist/core/delegation/worker-resource-materializer.d.ts.map +1 -0
- package/dist/core/delegation/worker-resource-materializer.js +137 -0
- package/dist/core/delegation/worker-resource-materializer.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +3 -1
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +189 -54
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.d.ts +23 -0
- package/dist/core/delegation/worker-terminal-finalizer.d.ts.map +1 -0
- package/dist/core/delegation/worker-terminal-finalizer.js +12 -0
- package/dist/core/delegation/worker-terminal-finalizer.js.map +1 -0
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +38 -0
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-write-reservation-coordinator.js +107 -0
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-write-reservation.d.ts +90 -0
- package/dist/core/delegation/worker-write-reservation.d.ts.map +1 -0
- package/dist/core/delegation/worker-write-reservation.js +348 -0
- package/dist/core/delegation/worker-write-reservation.js.map +1 -0
- package/dist/core/extension-import-authority.d.ts +6 -0
- package/dist/core/extension-import-authority.d.ts.map +1 -0
- package/dist/core/extension-import-authority.js +10 -0
- package/dist/core/extension-import-authority.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +2 -3
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +14 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +2 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +2 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/types.d.ts +8 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +1 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +13 -13
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +14 -9
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +47 -75
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +11 -0
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -0
- package/dist/core/goals/compact-goal-context.js +59 -0
- package/dist/core/goals/compact-goal-context.js.map +1 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
- package/dist/core/goals/goal-acceptance.js +2 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts +2 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +5 -8
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts +2 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +42 -11
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +4 -29
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +4 -32
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +8 -18
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +9 -179
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +35 -12
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
- package/dist/core/goals/goal-lifecycle.js +98 -13
- package/dist/core/goals/goal-lifecycle.js.map +1 -1
- package/dist/core/goals/goal-record.d.ts +17 -0
- package/dist/core/goals/goal-record.d.ts.map +1 -0
- package/dist/core/goals/goal-record.js +31 -0
- package/dist/core/goals/goal-record.js.map +1 -0
- package/dist/core/goals/goal-session-controller.d.ts +42 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-session-controller.js +128 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -0
- package/dist/core/goals/goal-state.d.ts +45 -25
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +85 -15
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +1 -4
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +49 -34
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +18 -8
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +134 -11
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input-controller.d.ts +47 -0
- package/dist/core/human-input-controller.d.ts.map +1 -0
- package/dist/core/human-input-controller.js +181 -0
- package/dist/core/human-input-controller.js.map +1 -0
- package/dist/core/local-runtime-controller.d.ts +1 -1
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +0 -19
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +0 -19
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -5
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +16 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +32 -16
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -1
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +1 -1
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/models/model-endpoint.d.ts +3 -0
- package/dist/core/models/model-endpoint.d.ts.map +1 -0
- package/dist/core/models/model-endpoint.js +11 -0
- package/dist/core/models/model-endpoint.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +2 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -1
- package/dist/core/orchestration/agent-resume.js +7 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -1
- package/dist/core/orchestration/attempt-usage.d.ts +28 -0
- package/dist/core/orchestration/attempt-usage.d.ts.map +1 -0
- package/dist/core/orchestration/attempt-usage.js +168 -0
- package/dist/core/orchestration/attempt-usage.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +19 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +128 -28
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +35 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +17 -0
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts +17 -2
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +81 -3
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts +1 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +78 -38
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +81 -41
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/profile-store.d.ts.map +1 -1
- package/dist/core/orchestration/profile-store.js +18 -4
- package/dist/core/orchestration/profile-store.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts +2 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js +26 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +13 -1
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +127 -16
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
- package/dist/core/orchestration/work-state-projection.js +1 -1
- package/dist/core/orchestration/work-state-projection.js.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts +3 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js +75 -23
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.d.ts +9 -3
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.js +167 -14
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +20 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts +8 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +23 -5
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -29
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +2 -2
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +92 -54
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/request-auth.d.ts +7 -0
- package/dist/core/request-auth.d.ts.map +1 -0
- package/dist/core/request-auth.js +8 -0
- package/dist/core/request-auth.js.map +1 -0
- package/dist/core/research/evidence-bundle.d.ts +20 -0
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +173 -69
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +16 -6
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts.map +1 -1
- package/dist/core/risk-classifier.js +8 -0
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +22 -3
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +147 -80
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts +9 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.js +241 -0
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +27 -0
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -0
- package/dist/core/secrets/secret-dotenv.js +183 -0
- package/dist/core/secrets/secret-dotenv.js.map +1 -0
- package/dist/core/secrets/secret-vault-format.d.ts +112 -0
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault-format.js +397 -0
- package/dist/core/secrets/secret-vault-format.js.map +1 -0
- package/dist/core/secrets/secret-vault.d.ts +72 -0
- package/dist/core/secrets/secret-vault.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault.js +671 -0
- package/dist/core/secrets/secret-vault.js.map +1 -0
- package/dist/core/session-analytics.d.ts +4 -23
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +39 -69
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-artifact-bundle.d.ts +35 -0
- package/dist/core/session-artifact-bundle.d.ts.map +1 -0
- package/dist/core/session-artifact-bundle.js +61 -0
- package/dist/core/session-artifact-bundle.js.map +1 -0
- package/dist/core/session-role.d.ts +5 -0
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +14 -1
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-tree-navigator.d.ts +4 -6
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +4 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js +1 -0
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +8 -2
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +2 -4
- package/dist/core/tool-protocol-controller.d.ts.map +1 -1
- package/dist/core/tool-protocol-controller.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts +21 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tools/bash.d.ts +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +59 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +6 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +106 -25
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +9 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +329 -69
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -8
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +2 -63
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts +5 -3
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +97 -19
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +1 -4
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +0 -44
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +36 -3
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +3 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +1 -1
- package/dist/core/tools/run-process.d.ts.map +1 -1
- package/dist/core/tools/run-process.js +69 -9
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts +14 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -0
- package/dist/core/tools/search-command-guard.js +333 -0
- package/dist/core/tools/search-command-guard.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts +38 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -0
- package/dist/core/tools/secret-store.js +412 -0
- package/dist/core/tools/secret-store.js.map +1 -0
- package/dist/core/tools/shell-command-parser.d.ts +16 -0
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -0
- package/dist/core/tools/shell-command-parser.js +113 -0
- package/dist/core/tools/shell-command-parser.js.map +1 -0
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +12 -5
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +4 -7
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +6 -2
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +4 -4
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-file.d.ts +15 -0
- package/dist/core/util/bounded-file.d.ts.map +1 -0
- package/dist/core/util/bounded-file.js +120 -0
- package/dist/core/util/bounded-file.js.map +1 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -1
- package/dist/core/util/bounded-jsonl.js +119 -9
- package/dist/core/util/bounded-jsonl.js.map +1 -1
- package/dist/core/util/bounded-value.d.ts +3 -0
- package/dist/core/util/bounded-value.d.ts.map +1 -0
- package/dist/core/util/bounded-value.js +12 -0
- package/dist/core/util/bounded-value.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +2 -0
- package/dist/core/util/value-guards.d.ts.map +1 -1
- package/dist/core/util/value-guards.js +5 -0
- package/dist/core/util/value-guards.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +25 -11
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +4 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +60 -1
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +55 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -0
- package/dist/modes/interactive/components/activity-lane.js +304 -0
- package/dist/modes/interactive/components/activity-lane.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +19 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/expandable-text.d.ts +12 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-text.js +17 -0
- package/dist/modes/interactive/components/expandable-text.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +15 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +30 -21
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +23 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +27 -44
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +4 -4
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +19 -11
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +53 -20
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +3 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts +16 -0
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/usage-action-selector.js +46 -0
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +1 -0
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +15 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +27 -19
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts +6 -2
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js +10 -5
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +74 -0
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-event-controller.js +328 -0
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +20 -25
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +196 -608
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts +20 -0
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -0
- package/dist/modes/interactive/loaded-resources-view.js +147 -0
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -0
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js +8 -2
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts +1 -5
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +0 -5
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +10 -6
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +123 -70
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts +34 -0
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -0
- package/dist/modes/interactive/usage-commands.js +225 -0
- package/dist/modes/interactive/usage-commands.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +5 -3
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +25 -31
- package/docs/UI_QUALITY_ORCHESTRATION.md +22 -24
- package/docs/providers.md +9 -1
- package/docs/tool-repair.md +3 -0
- package/docs/ui-reference/README.md +6 -6
- package/docs/ui-reference/orchestration-after.txt +14 -7
- package/docs/ui-reference/orchestration-before.txt +12 -6
- package/docs/ui-reference/orchestration-reference.txt +15 -5
- package/docs/usage.md +9 -1
- package/docs/windows.md +4 -2
- 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 +13 -13
- package/package.json +4 -4
|
@@ -2,12 +2,14 @@ import { type Static, Type } from "typebox";
|
|
|
2
2
|
import type { WorkerClaim } from "../autonomy/contracts.ts";
|
|
3
3
|
import type { LaneRecord } from "../autonomy/lane-tracker.ts";
|
|
4
4
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
5
|
+
import { type GoalStateRevision } from "../goals/goal-lifecycle.ts";
|
|
5
6
|
import type { GoalState } from "../goals/goal-state.ts";
|
|
6
7
|
import { type GoalActionName, type OpenTaskStepRef } from "../goals/goal-tool-core.ts";
|
|
7
8
|
declare const goalSchema: Type.TObject<{
|
|
8
|
-
action: Type.TUnion<[Type.TLiteral<"start">, Type.TLiteral<"add_requirement">, Type.TLiteral<"satisfy_requirement">, Type.TLiteral<"block_requirement">, Type.TLiteral<"reopen_requirement">, Type.TLiteral<"dispatch_worker">, Type.TLiteral<"add_evidence">, Type.TLiteral<"progress">, Type.TLiteral<"no_progress">, Type.TLiteral<"complete">, Type.TLiteral<"block_goal"
|
|
9
|
+
action: Type.TUnion<[Type.TLiteral<"get">, Type.TLiteral<"start">, Type.TLiteral<"add_requirement">, Type.TLiteral<"satisfy_requirement">, Type.TLiteral<"block_requirement">, Type.TLiteral<"reopen_requirement">, Type.TLiteral<"dispatch_worker">, Type.TLiteral<"add_evidence">, Type.TLiteral<"progress">, Type.TLiteral<"no_progress">, Type.TLiteral<"complete">, Type.TLiteral<"block_goal">]>;
|
|
9
10
|
goalId: Type.TOptional<Type.TString>;
|
|
10
11
|
userGoal: Type.TOptional<Type.TString>;
|
|
12
|
+
tokenBudget: Type.TOptional<Type.TInteger>;
|
|
11
13
|
requirementId: Type.TOptional<Type.TString>;
|
|
12
14
|
text: Type.TOptional<Type.TString>;
|
|
13
15
|
instructions: Type.TOptional<Type.TString>;
|
|
@@ -21,7 +23,7 @@ declare const goalSchema: Type.TObject<{
|
|
|
21
23
|
}>;
|
|
22
24
|
export type GoalToolInput = Static<typeof goalSchema>;
|
|
23
25
|
export interface GoalToolDetails {
|
|
24
|
-
action: GoalActionName;
|
|
26
|
+
action: GoalActionName | "get";
|
|
25
27
|
applied: boolean;
|
|
26
28
|
error?: string;
|
|
27
29
|
state?: GoalState;
|
|
@@ -40,7 +42,7 @@ export interface GoalToolDependencies {
|
|
|
40
42
|
/** Read the latest persisted goal state for the active session. */
|
|
41
43
|
getGoalState: () => GoalState | undefined;
|
|
42
44
|
/** Persist a new goal state snapshot to the active session. */
|
|
43
|
-
saveGoalState: (state: GoalState) => void;
|
|
45
|
+
saveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;
|
|
44
46
|
/** Clock injection for deterministic tests. */
|
|
45
47
|
now?: () => string;
|
|
46
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,eAAe,EAEpB,MAAM,4BA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B,KAAK,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,mGAAmG;IACnG,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;OAGG;IACH,oCAAoC,CAAC,EAAE,MAAM,OAAO,CAAC;IACrD;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,SAAS,eAAe,EAAE,CAAC;CACpD;AAkGD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CA6InF","sourcesContent":["import { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport type { GoalEvidenceKind, GoalState } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t\tType.Literal(\"resume_goal\"),\n\t\t\t\tType.Literal(\"cancel\"),\n\t\t\t],\n\t\t\t{ description: \"Ledger action to record.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Requirement id for add_requirement/satisfy_requirement/block_requirement/reopen_requirement/dispatch_worker.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(Type.String({ description: \"Evidence id. Required for add_evidence.\" })),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Evidence ids supporting a satisfy_requirement action. Each must already be recorded.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional evidence locator (path/URL for kind 'file', a toolCallId for kind 'tool', a laneId for kind 'worker').\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Worker runtime for dispatch_worker. Defaults to 'in_process'. 'tmux' dispatches a persistent tmux worker via the tmux_agent_manager extension -- only takes effect when that dependency is wired AND an owner-granted standing dispatch grant covers it; otherwise the dispatch is honestly skipped with a dispatchSkipReason (never a silent fallback or a fake launch).\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn { action: \"start\", goalId: input.goalId ?? \"\", userGoal: input.userGoal ?? \"\" };\n\t\tcase \"add_requirement\":\n\t\t\treturn { action: \"add_requirement\", requirementId: input.requirementId ?? \"\", text: input.text ?? \"\" };\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId: input.evidenceId ?? \"\",\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"resume_goal\":\n\t\t\treturn { action: \"resume_goal\" };\n\t\tcase \"cancel\":\n\t\t\treturn { action: \"cancel\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"goal\",\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Record and update the durable goal ledger for the current task. Maintains a structured goal with requirements, evidence, and progress so long tasks can be resumed and continued. Start a goal, add requirements, attach evidence, mark requirements satisfied or blocked, reopen resolved blockers, resume blocked goals, and mark progress. This is the producer that drives /goal-continue; without recorded goal state, continuation has nothing to act on.\",\n\t\tpromptSnippet: \"Record goal, requirements, evidence, and progress in the durable goal ledger.\",\n\t\tpromptGuidelines: [\n\t\t\t\"At the start of a multi-step task, call goal with action 'start' to record the user goal, then add the concrete requirements with 'add_requirement'.\",\n\t\t\t\"As you make progress, record evidence with 'add_evidence' and mark requirements satisfied with 'satisfy_requirement', citing the evidence ids.\",\n\t\t\t\"For 'add_evidence', kind 'tool' expects a real toolCallId in 'uri' and kind 'file' expects a real path; both are checked and recorded as verified or not. Kind 'worker' expects a laneId in 'uri' and verifies true only for a reviewed, completed worker result. Kinds 'user'/'finding'/'test' carry no checkable ref.\",\n\t\t\t\"Use 'dispatch_worker' to bind a requirement to a worker lane while it is being worked; this records the binding only -- it never satisfies the requirement. Record 'worker'-kind evidence citing that laneId once the worker completes, then call 'satisfy_requirement'.\",\n\t\t\t\"Use 'progress' when you advance without satisfying a specific requirement, and 'no_progress' when a turn yields nothing, so stall detection works.\",\n\t\t\t\"When the user resolves a blocker, use 'resume_goal' and 'reopen_requirement' as needed; do not strand the old ledger or start a duplicate goal.\",\n\t\t\t\"Mark the goal 'complete' only when every requirement is satisfied and each requirement cites verified or user-confirmed evidence. Use 'block_goal' or 'block_requirement' with a reason when you are stuck and need the user. A blocked goal can still be resumed or cancelled.\",\n\t\t],\n\t\tparameters: goalSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t}> {\n\t\t\tconst mapped = toGoalAction(input);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst useTmux = input.dispatchTarget === \"tmux\" && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tconst dispatched = useTmux\n\t\t\t\t\t? await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t})\n\t\t\t\t\t: deps.startWorkerDelegation?.({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = useTmux\n\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (tmux dispatch is not available from this tool yet).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAA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uB,CAAC,EAAE,MAAM,SAAS,WAAW,EAAE,CAAC;IACvD;;;;;;;;;OASG;IACH,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC9B,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACrB,KAAK;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC3D;;;;;;;;;;;;;;;;;OAiBG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC3B,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACrB,KAAK,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,mGAAmG;IACnG,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;OAGG;IACH,oCAAoC,CAAC,EAAE,MAAM,OAAO,CAAC;IACrD;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,SAAS,eAAe,EAAE,CAAC;CACpD;AA4JD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CAgKnF","sourcesContent":["import { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type GoalStateRevision, getGoalStateRevision } from \"../goals/goal-lifecycle.ts\";\nimport type { GoalEvidenceKind, GoalState } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n} from \"./orchestration-panel.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"get\"),\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t],\n\t\t\t{ description: \"Goal record action.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\ttokenBudget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Optional positive token budget for action 'start'.\" }),\n\t\t),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Requirement id for add_requirement/satisfy_requirement/block_requirement/reopen_requirement/dispatch_worker.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(Type.String({ description: \"Evidence id. Required for add_evidence.\" })),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Evidence ids supporting a satisfy_requirement action. Each must already be recorded.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional evidence locator (path/URL for kind 'file', a toolCallId for kind 'tool', a laneId for kind 'worker').\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription: \"Legacy worker target. Prefer the delegate tool for new work.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName | \"get\";\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn {\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: input.goalId ?? \"\",\n\t\t\t\tuserGoal: input.userGoal ?? \"\",\n\t\t\t\ttokenBudget: input.tokenBudget,\n\t\t\t};\n\t\tcase \"add_requirement\":\n\t\t\treturn { action: \"add_requirement\", requirementId: input.requirementId ?? \"\", text: input.text ?? \"\" };\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId: input.evidenceId ?? \"\",\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"get\":\n\t\t\treturn { error: \"get is handled as a read-only action.\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nfunction goalPanelModel(details: GoalToolDetails | undefined): OrchestrationPanelModel {\n\tconst state = details?.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"goal\",\n\t\t\taction: details?.action,\n\t\t\tstatus: details?.error ? \"error\" : \"idle\",\n\t\t\temptyText: details?.error ?? \"No goal state was returned.\",\n\t\t};\n\t}\n\tconst satisfied = state.requirements.filter((requirement) => requirement.status === \"satisfied\").length;\n\treturn {\n\t\tlabel: \"goal\",\n\t\taction: details.action,\n\t\tstatus:\n\t\t\tstate.status === \"completed\"\n\t\t\t\t? \"success\"\n\t\t\t\t: state.status === \"blocked\" ||\n\t\t\t\t\t\tstate.status === \"paused\" ||\n\t\t\t\t\t\tstate.status === \"usage_limited\" ||\n\t\t\t\t\t\tstate.status === \"budget_limited\"\n\t\t\t\t\t? \"warning\"\n\t\t\t\t\t: state.status === \"cancelled\"\n\t\t\t\t\t\t? \"idle\"\n\t\t\t\t\t\t: \"running\",\n\t\tsummary: [\n\t\t\t`${satisfied}/${state.requirements.length} requirements`,\n\t\t\t`${state.evidence.length} evidence`,\n\t\t\t...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),\n\t\t],\n\t\trows: state.requirements.map((requirement) => ({\n\t\t\tstatus:\n\t\t\t\trequirement.status === \"satisfied\"\n\t\t\t\t\t? (\"completed\" as const)\n\t\t\t\t\t: requirement.status === \"open\"\n\t\t\t\t\t\t? (\"pending\" as const)\n\t\t\t\t\t\t: (\"blocked\" as const),\n\t\t\tlabel: requirement.text,\n\t\t\tmeta: [\n\t\t\t\trequirement.id,\n\t\t\t\trequirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,\n\t\t\t\trequirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,\n\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,\n\t\t})),\n\t\tnotices: [\n\t\t\t...(details.dispatchSkipReason\n\t\t\t\t? [{ status: \"warning\" as const, text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]\n\t\t\t\t: []),\n\t\t\t...(state.blockedReason ? [{ status: \"warning\" as const, text: state.blockedReason }] : []),\n\t\t],\n\t\temptyText: \"No requirements recorded.\",\n\t};\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"goal\",\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Read or update the compact durable goal record for explicitly requested long-running work. Planning belongs to task_steps, workers to delegate, and evidence to current tools/artifacts. Pause, resume, edit, clear, and budget stops are owner/system controlled.\",\n\t\tpromptSnippet: \"Read or update the compact durable goal record.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Call action 'start' only when the user or system explicitly requests a persistent goal. Do not infer a goal from an ordinary multi-step task. Set tokenBudget only when the user explicitly requested a token budget.\",\n\t\t\t\"Use 'get' when the current objective or status is uncertain. Use task_steps for decomposition and delegate for workers; detailed ledger actions exist only for goals that already use the legacy ledger.\",\n\t\t\t\"Mark 'complete' only after current authoritative evidence proves the full objective and no required work remains. Mark 'block_goal' only after the same genuine impasse persists for three goal turns.\",\n\t\t],\n\t\tparameters: goalSchema,\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 GoalToolDetails | undefined;\n\t\t\tif (!expanded && details?.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, goalPanelModel(details), true);\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t}> {\n\t\t\tif (input.action === \"get\") {\n\t\t\t\tconst state = deps.getGoalState();\n\t\t\t\tif (!state) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No goal exists for this session.\" }],\n\t\t\t\t\t\tdetails: { action: \"get\", applied: false },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: summarizeGoalState(state) }],\n\t\t\t\t\tdetails: { action: \"get\", applied: false, state },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst mapped = toGoalAction(input);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst useTmux = input.dispatchTarget === \"tmux\" && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tconst dispatched = useTmux\n\t\t\t\t\t? await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t})\n\t\t\t\t\t: deps.startWorkerDelegation?.({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = useTmux\n\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (tmux dispatch is not available from this tool yet).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
package/dist/core/tools/goal.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { stat as fsStat } from "node:fs/promises";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import { getGoalStateRevision } from "../goals/goal-lifecycle.js";
|
|
3
4
|
import { applyGoalAction, summarizeGoalState, } from "../goals/goal-tool-core.js";
|
|
5
|
+
import { emptyOrchestrationCall, OrchestrationPanelComponent, } from "./orchestration-panel.js";
|
|
4
6
|
import { resolveToCwd } from "./path-utils.js";
|
|
5
7
|
const goalSchema = Type.Object({
|
|
6
8
|
action: Type.Union([
|
|
9
|
+
Type.Literal("get"),
|
|
7
10
|
Type.Literal("start"),
|
|
8
11
|
Type.Literal("add_requirement"),
|
|
9
12
|
Type.Literal("satisfy_requirement"),
|
|
@@ -15,11 +18,10 @@ const goalSchema = Type.Object({
|
|
|
15
18
|
Type.Literal("no_progress"),
|
|
16
19
|
Type.Literal("complete"),
|
|
17
20
|
Type.Literal("block_goal"),
|
|
18
|
-
|
|
19
|
-
Type.Literal("cancel"),
|
|
20
|
-
], { description: "Ledger action to record." }),
|
|
21
|
+
], { description: "Goal record action." }),
|
|
21
22
|
goalId: Type.Optional(Type.String({ description: "Stable goal id. Required for action 'start'." })),
|
|
22
23
|
userGoal: Type.Optional(Type.String({ description: "The goal statement. Required for action 'start'." })),
|
|
24
|
+
tokenBudget: Type.Optional(Type.Integer({ minimum: 1, description: "Optional positive token budget for action 'start'." })),
|
|
23
25
|
requirementId: Type.Optional(Type.String({
|
|
24
26
|
description: "Requirement id for add_requirement/satisfy_requirement/block_requirement/reopen_requirement/dispatch_worker.",
|
|
25
27
|
})),
|
|
@@ -43,7 +45,7 @@ const goalSchema = Type.Object({
|
|
|
43
45
|
})),
|
|
44
46
|
reason: Type.Optional(Type.String({ description: "Reason for block_requirement or block_goal." })),
|
|
45
47
|
dispatchTarget: Type.Optional(Type.Union([Type.Literal("in_process"), Type.Literal("tmux")], {
|
|
46
|
-
description: "
|
|
48
|
+
description: "Legacy worker target. Prefer the delegate tool for new work.",
|
|
47
49
|
})),
|
|
48
50
|
}, { additionalProperties: false });
|
|
49
51
|
/**
|
|
@@ -90,7 +92,12 @@ async function resolveEvidenceVerified(kind, uri, deps) {
|
|
|
90
92
|
function toGoalAction(input) {
|
|
91
93
|
switch (input.action) {
|
|
92
94
|
case "start":
|
|
93
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
action: "start",
|
|
97
|
+
goalId: input.goalId ?? "",
|
|
98
|
+
userGoal: input.userGoal ?? "",
|
|
99
|
+
tokenBudget: input.tokenBudget,
|
|
100
|
+
};
|
|
94
101
|
case "add_requirement":
|
|
95
102
|
return { action: "add_requirement", requirementId: input.requirementId ?? "", text: input.text ?? "" };
|
|
96
103
|
case "satisfy_requirement":
|
|
@@ -134,32 +141,103 @@ function toGoalAction(input) {
|
|
|
134
141
|
return { action: "complete" };
|
|
135
142
|
case "block_goal":
|
|
136
143
|
return { action: "block_goal", reason: input.reason ?? "" };
|
|
137
|
-
case "
|
|
138
|
-
return {
|
|
139
|
-
case "cancel":
|
|
140
|
-
return { action: "cancel" };
|
|
144
|
+
case "get":
|
|
145
|
+
return { error: "get is handled as a read-only action." };
|
|
141
146
|
default:
|
|
142
147
|
return { error: "Unknown goal action." };
|
|
143
148
|
}
|
|
144
149
|
}
|
|
150
|
+
function goalPanelModel(details) {
|
|
151
|
+
const state = details?.state;
|
|
152
|
+
if (!state) {
|
|
153
|
+
return {
|
|
154
|
+
label: "goal",
|
|
155
|
+
action: details?.action,
|
|
156
|
+
status: details?.error ? "error" : "idle",
|
|
157
|
+
emptyText: details?.error ?? "No goal state was returned.",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const satisfied = state.requirements.filter((requirement) => requirement.status === "satisfied").length;
|
|
161
|
+
return {
|
|
162
|
+
label: "goal",
|
|
163
|
+
action: details.action,
|
|
164
|
+
status: state.status === "completed"
|
|
165
|
+
? "success"
|
|
166
|
+
: state.status === "blocked" ||
|
|
167
|
+
state.status === "paused" ||
|
|
168
|
+
state.status === "usage_limited" ||
|
|
169
|
+
state.status === "budget_limited"
|
|
170
|
+
? "warning"
|
|
171
|
+
: state.status === "cancelled"
|
|
172
|
+
? "idle"
|
|
173
|
+
: "running",
|
|
174
|
+
summary: [
|
|
175
|
+
`${satisfied}/${state.requirements.length} requirements`,
|
|
176
|
+
`${state.evidence.length} evidence`,
|
|
177
|
+
...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),
|
|
178
|
+
],
|
|
179
|
+
rows: state.requirements.map((requirement) => ({
|
|
180
|
+
status: requirement.status === "satisfied"
|
|
181
|
+
? "completed"
|
|
182
|
+
: requirement.status === "open"
|
|
183
|
+
? "pending"
|
|
184
|
+
: "blocked",
|
|
185
|
+
label: requirement.text,
|
|
186
|
+
meta: [
|
|
187
|
+
requirement.id,
|
|
188
|
+
requirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,
|
|
189
|
+
requirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,
|
|
190
|
+
].filter((value) => value !== undefined),
|
|
191
|
+
details: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,
|
|
192
|
+
})),
|
|
193
|
+
notices: [
|
|
194
|
+
...(details.dispatchSkipReason
|
|
195
|
+
? [{ status: "warning", text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]
|
|
196
|
+
: []),
|
|
197
|
+
...(state.blockedReason ? [{ status: "warning", text: state.blockedReason }] : []),
|
|
198
|
+
],
|
|
199
|
+
emptyText: "No requirements recorded.",
|
|
200
|
+
};
|
|
201
|
+
}
|
|
145
202
|
export function createGoalToolDefinition(deps) {
|
|
146
203
|
const now = deps.now ?? (() => new Date().toISOString());
|
|
147
204
|
return {
|
|
148
205
|
name: "goal",
|
|
149
206
|
label: "goal",
|
|
150
|
-
description: "
|
|
151
|
-
promptSnippet: "
|
|
207
|
+
description: "Read or update the compact durable goal record for explicitly requested long-running work. Planning belongs to task_steps, workers to delegate, and evidence to current tools/artifacts. Pause, resume, edit, clear, and budget stops are owner/system controlled.",
|
|
208
|
+
promptSnippet: "Read or update the compact durable goal record.",
|
|
152
209
|
promptGuidelines: [
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"Use 'dispatch_worker' to bind a requirement to a worker lane while it is being worked; this records the binding only -- it never satisfies the requirement. Record 'worker'-kind evidence citing that laneId once the worker completes, then call 'satisfy_requirement'.",
|
|
157
|
-
"Use 'progress' when you advance without satisfying a specific requirement, and 'no_progress' when a turn yields nothing, so stall detection works.",
|
|
158
|
-
"When the user resolves a blocker, use 'resume_goal' and 'reopen_requirement' as needed; do not strand the old ledger or start a duplicate goal.",
|
|
159
|
-
"Mark the goal 'complete' only when every requirement is satisfied and each requirement cites verified or user-confirmed evidence. Use 'block_goal' or 'block_requirement' with a reason when you are stuck and need the user. A blocked goal can still be resumed or cancelled.",
|
|
210
|
+
"Call action 'start' only when the user or system explicitly requests a persistent goal. Do not infer a goal from an ordinary multi-step task. Set tokenBudget only when the user explicitly requested a token budget.",
|
|
211
|
+
"Use 'get' when the current objective or status is uncertain. Use task_steps for decomposition and delegate for workers; detailed ledger actions exist only for goals that already use the legacy ledger.",
|
|
212
|
+
"Mark 'complete' only after current authoritative evidence proves the full objective and no required work remains. Mark 'block_goal' only after the same genuine impasse persists for three goal turns.",
|
|
160
213
|
],
|
|
161
214
|
parameters: goalSchema,
|
|
215
|
+
renderShell: "self",
|
|
216
|
+
renderCall() {
|
|
217
|
+
return emptyOrchestrationCall();
|
|
218
|
+
},
|
|
219
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
220
|
+
if (isPartial)
|
|
221
|
+
return emptyOrchestrationCall();
|
|
222
|
+
const details = result.details;
|
|
223
|
+
if (!expanded && details?.applied)
|
|
224
|
+
return emptyOrchestrationCall();
|
|
225
|
+
return new OrchestrationPanelComponent(theme, goalPanelModel(details), true);
|
|
226
|
+
},
|
|
162
227
|
async execute(_toolCallId, input) {
|
|
228
|
+
if (input.action === "get") {
|
|
229
|
+
const state = deps.getGoalState();
|
|
230
|
+
if (!state) {
|
|
231
|
+
return {
|
|
232
|
+
content: [{ type: "text", text: "No goal exists for this session." }],
|
|
233
|
+
details: { action: "get", applied: false },
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
content: [{ type: "text", text: summarizeGoalState(state) }],
|
|
238
|
+
details: { action: "get", applied: false, state },
|
|
239
|
+
};
|
|
240
|
+
}
|
|
163
241
|
const mapped = toGoalAction(input);
|
|
164
242
|
if ("error" in mapped) {
|
|
165
243
|
return {
|
|
@@ -256,7 +334,7 @@ export function createGoalToolDefinition(deps) {
|
|
|
256
334
|
details: { action: input.action, applied: false, error: result.error, state: current },
|
|
257
335
|
};
|
|
258
336
|
}
|
|
259
|
-
deps.saveGoalState(result.state);
|
|
337
|
+
deps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);
|
|
260
338
|
nextState = result.state;
|
|
261
339
|
}
|
|
262
340
|
const summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EACN,eAAe,EAIf,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAC7B;IACC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB;QACC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QACnC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;KACtB,EACD,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAC3C;I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AAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;qBACtF,CAAC;gBACH,CAAC;gBACD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACjC,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;YAC1B,CAAC;YAED,MAAM,OAAO,GAAG,kBAAkB,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;YACpG,MAAM,IAAI,GAAG,YAAY;gBACxB,CAAC,CAAC,QAAQ,KAAK,CAAC,MAAM,eAAe,OAAO,KAAK,YAAY,EAAE;gBAC/D,CAAC,CAAC,QAAQ,KAAK,CAAC,MAAM,eAAe,OAAO,EAAE,CAAC;YAChD,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;gBAC1C,OAAO,EAAE;oBACR,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,SAAS;oBAChB,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,iBAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACpG,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,iBAAiB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACxF;aACD,CAAC;QAAA,CACF;KACD,CAAC;AAAA,CACF","sourcesContent":["import { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport type { GoalEvidenceKind, GoalState } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t\tType.Literal(\"resume_goal\"),\n\t\t\t\tType.Literal(\"cancel\"),\n\t\t\t],\n\t\t\t{ description: \"Ledger action to record.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Requirement id for add_requirement/satisfy_requirement/block_requirement/reopen_requirement/dispatch_worker.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(Type.String({ description: \"Evidence id. Required for add_evidence.\" })),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Evidence ids supporting a satisfy_requirement action. Each must already be recorded.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional evidence locator (path/URL for kind 'file', a toolCallId for kind 'tool', a laneId for kind 'worker').\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Worker runtime for dispatch_worker. Defaults to 'in_process'. 'tmux' dispatches a persistent tmux worker via the tmux_agent_manager extension -- only takes effect when that dependency is wired AND an owner-granted standing dispatch grant covers it; otherwise the dispatch is honestly skipped with a dispatchSkipReason (never a silent fallback or a fake launch).\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn { action: \"start\", goalId: input.goalId ?? \"\", userGoal: input.userGoal ?? \"\" };\n\t\tcase \"add_requirement\":\n\t\t\treturn { action: \"add_requirement\", requirementId: input.requirementId ?? \"\", text: input.text ?? \"\" };\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId: input.evidenceId ?? \"\",\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"resume_goal\":\n\t\t\treturn { action: \"resume_goal\" };\n\t\tcase \"cancel\":\n\t\t\treturn { action: \"cancel\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"goal\",\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Record and update the durable goal ledger for the current task. Maintains a structured goal with requirements, evidence, and progress so long tasks can be resumed and continued. Start a goal, add requirements, attach evidence, mark requirements satisfied or blocked, reopen resolved blockers, resume blocked goals, and mark progress. This is the producer that drives /goal-continue; without recorded goal state, continuation has nothing to act on.\",\n\t\tpromptSnippet: \"Record goal, requirements, evidence, and progress in the durable goal ledger.\",\n\t\tpromptGuidelines: [\n\t\t\t\"At the start of a multi-step task, call goal with action 'start' to record the user goal, then add the concrete requirements with 'add_requirement'.\",\n\t\t\t\"As you make progress, record evidence with 'add_evidence' and mark requirements satisfied with 'satisfy_requirement', citing the evidence ids.\",\n\t\t\t\"For 'add_evidence', kind 'tool' expects a real toolCallId in 'uri' and kind 'file' expects a real path; both are checked and recorded as verified or not. Kind 'worker' expects a laneId in 'uri' and verifies true only for a reviewed, completed worker result. Kinds 'user'/'finding'/'test' carry no checkable ref.\",\n\t\t\t\"Use 'dispatch_worker' to bind a requirement to a worker lane while it is being worked; this records the binding only -- it never satisfies the requirement. Record 'worker'-kind evidence citing that laneId once the worker completes, then call 'satisfy_requirement'.\",\n\t\t\t\"Use 'progress' when you advance without satisfying a specific requirement, and 'no_progress' when a turn yields nothing, so stall detection works.\",\n\t\t\t\"When the user resolves a blocker, use 'resume_goal' and 'reopen_requirement' as needed; do not strand the old ledger or start a duplicate goal.\",\n\t\t\t\"Mark the goal 'complete' only when every requirement is satisfied and each requirement cites verified or user-confirmed evidence. Use 'block_goal' or 'block_requirement' with a reason when you are stuck and need the user. A blocked goal can still be resumed or cancelled.\",\n\t\t],\n\t\tparameters: goalSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t}> {\n\t\t\tconst mapped = toGoalAction(input);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst useTmux = input.dispatchTarget === \"tmux\" && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tconst dispatched = useTmux\n\t\t\t\t\t? await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t})\n\t\t\t\t\t: deps.startWorkerDelegation?.({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = useTmux\n\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (tmux dispatch is not available from this tool yet).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAA0B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,OAAO,EACN,eAAe,EAIf,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,sBAAsB,EACtB,2BAA2B,GAE3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAC7B;IACC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB;QACC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC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CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACxF;aACD,CAAC;QAAA,CACF;KACD,CAAC;AAAA,CACF","sourcesContent":["import { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type GoalStateRevision, getGoalStateRevision } from \"../goals/goal-lifecycle.ts\";\nimport type { GoalEvidenceKind, GoalState } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n} from \"./orchestration-panel.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"get\"),\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t],\n\t\t\t{ description: \"Goal record action.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\ttokenBudget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Optional positive token budget for action 'start'.\" }),\n\t\t),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Requirement id for add_requirement/satisfy_requirement/block_requirement/reopen_requirement/dispatch_worker.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(Type.String({ description: \"Evidence id. Required for add_evidence.\" })),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Evidence ids supporting a satisfy_requirement action. Each must already be recorded.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional evidence locator (path/URL for kind 'file', a toolCallId for kind 'tool', a laneId for kind 'worker').\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription: \"Legacy worker target. Prefer the delegate tool for new work.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName | \"get\";\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn {\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: input.goalId ?? \"\",\n\t\t\t\tuserGoal: input.userGoal ?? \"\",\n\t\t\t\ttokenBudget: input.tokenBudget,\n\t\t\t};\n\t\tcase \"add_requirement\":\n\t\t\treturn { action: \"add_requirement\", requirementId: input.requirementId ?? \"\", text: input.text ?? \"\" };\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId: input.evidenceId ?? \"\",\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"get\":\n\t\t\treturn { error: \"get is handled as a read-only action.\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nfunction goalPanelModel(details: GoalToolDetails | undefined): OrchestrationPanelModel {\n\tconst state = details?.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"goal\",\n\t\t\taction: details?.action,\n\t\t\tstatus: details?.error ? \"error\" : \"idle\",\n\t\t\temptyText: details?.error ?? \"No goal state was returned.\",\n\t\t};\n\t}\n\tconst satisfied = state.requirements.filter((requirement) => requirement.status === \"satisfied\").length;\n\treturn {\n\t\tlabel: \"goal\",\n\t\taction: details.action,\n\t\tstatus:\n\t\t\tstate.status === \"completed\"\n\t\t\t\t? \"success\"\n\t\t\t\t: state.status === \"blocked\" ||\n\t\t\t\t\t\tstate.status === \"paused\" ||\n\t\t\t\t\t\tstate.status === \"usage_limited\" ||\n\t\t\t\t\t\tstate.status === \"budget_limited\"\n\t\t\t\t\t? \"warning\"\n\t\t\t\t\t: state.status === \"cancelled\"\n\t\t\t\t\t\t? \"idle\"\n\t\t\t\t\t\t: \"running\",\n\t\tsummary: [\n\t\t\t`${satisfied}/${state.requirements.length} requirements`,\n\t\t\t`${state.evidence.length} evidence`,\n\t\t\t...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),\n\t\t],\n\t\trows: state.requirements.map((requirement) => ({\n\t\t\tstatus:\n\t\t\t\trequirement.status === \"satisfied\"\n\t\t\t\t\t? (\"completed\" as const)\n\t\t\t\t\t: requirement.status === \"open\"\n\t\t\t\t\t\t? (\"pending\" as const)\n\t\t\t\t\t\t: (\"blocked\" as const),\n\t\t\tlabel: requirement.text,\n\t\t\tmeta: [\n\t\t\t\trequirement.id,\n\t\t\t\trequirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,\n\t\t\t\trequirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,\n\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,\n\t\t})),\n\t\tnotices: [\n\t\t\t...(details.dispatchSkipReason\n\t\t\t\t? [{ status: \"warning\" as const, text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]\n\t\t\t\t: []),\n\t\t\t...(state.blockedReason ? [{ status: \"warning\" as const, text: state.blockedReason }] : []),\n\t\t],\n\t\temptyText: \"No requirements recorded.\",\n\t};\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"goal\",\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Read or update the compact durable goal record for explicitly requested long-running work. Planning belongs to task_steps, workers to delegate, and evidence to current tools/artifacts. Pause, resume, edit, clear, and budget stops are owner/system controlled.\",\n\t\tpromptSnippet: \"Read or update the compact durable goal record.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Call action 'start' only when the user or system explicitly requests a persistent goal. Do not infer a goal from an ordinary multi-step task. Set tokenBudget only when the user explicitly requested a token budget.\",\n\t\t\t\"Use 'get' when the current objective or status is uncertain. Use task_steps for decomposition and delegate for workers; detailed ledger actions exist only for goals that already use the legacy ledger.\",\n\t\t\t\"Mark 'complete' only after current authoritative evidence proves the full objective and no required work remains. Mark 'block_goal' only after the same genuine impasse persists for three goal turns.\",\n\t\t],\n\t\tparameters: goalSchema,\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 GoalToolDetails | undefined;\n\t\t\tif (!expanded && details?.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, goalPanelModel(details), true);\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t}> {\n\t\t\tif (input.action === \"get\") {\n\t\t\t\tconst state = deps.getGoalState();\n\t\t\t\tif (!state) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No goal exists for this session.\" }],\n\t\t\t\t\t\tdetails: { action: \"get\", applied: false },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: summarizeGoalState(state) }],\n\t\t\t\t\tdetails: { action: \"get\", applied: false, state },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst mapped = toGoalAction(input);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst useTmux = input.dispatchTarget === \"tmux\" && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tconst dispatched = useTmux\n\t\t\t\t\t? await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t})\n\t\t\t\t\t: deps.startWorkerDelegation?.({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = useTmux\n\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (tmux dispatch is not available from this tool yet).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
@@ -10,6 +10,7 @@ export { createGrepTool, createGrepToolDefinition, type GrepOperations, type Gre
|
|
|
10
10
|
export { createLsTool, createLsToolDefinition, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, } from "./ls.ts";
|
|
11
11
|
export { createPythonTool, createPythonToolDefinition, DEFAULT_PYTHON_TIMEOUT_SECONDS, MAX_PYTHON_OUTPUT_BYTES, MAX_PYTHON_TIMEOUT_SECONDS, type PythonExecutionRequest, type PythonExecutionResult, type PythonOperations, type PythonToolDetails, type PythonToolInput, type PythonToolOptions, resolvePythonToolPath, } from "./python.ts";
|
|
12
12
|
export { createReadTool, createReadToolDefinition, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, } from "./read.ts";
|
|
13
|
+
export { createSecretStoreToolDefinition, type SecretStoreStatus, type SecretStoreToolDetails, type SecretStoreToolInput, type SecretStoreToolOptions, } from "./secret-store.ts";
|
|
13
14
|
export { createSkillAuditTool, createSkillAuditToolDefinition, jaccard, type SkillAuditInput, type SkillAuditReport, type SkillAuditToolDetails, type SkillAuditToolOptions, tokenize, } from "./skill-audit.ts";
|
|
14
15
|
export { createSkillifyTool, createSkillifyToolDefinition, type SkillifyInput, type SkillifyReport, type SkillifyToolDetails, type SkillifyToolOptions, } from "./skillify.ts";
|
|
15
16
|
export { createWriteTool, createWriteToolDefinition, type WriteOperations, type WriteToolInput, type WriteToolOptions, } from "./write.ts";
|