@caupulican/pi-adaptative 0.81.38 → 0.81.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +18 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +133 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +198 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +311 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +31 -2
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +823 -79
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +1043 -86
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/__init__.py +43 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +270 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +252 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +399 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +575 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +52 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +49 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +734 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +238 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +132 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +116 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +287 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +137 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +100 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +579 -0
- package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +19 -9
- package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +22 -5
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +7 -7
- package/dist/bundled-resources/skills/tool-call-repair/references/text-protocol-grammar.md +28 -7
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +24 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts +15 -0
- package/dist/core/agent-directory-layout.d.ts.map +1 -0
- package/dist/core/agent-directory-layout.js +72 -0
- package/dist/core/agent-directory-layout.js.map +1 -0
- package/dist/core/agent-paths.d.ts +66 -0
- package/dist/core/agent-paths.d.ts.map +1 -0
- package/dist/core/agent-paths.js +170 -0
- package/dist/core/agent-paths.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +397 -79
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +4 -3
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +255 -103
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +754 -1173
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +3 -2
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +6 -28
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +26 -9
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js +8 -25
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +8 -10
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
- package/dist/core/autonomy/lane-private-paths.js +16 -0
- package/dist/core/autonomy/lane-private-paths.js.map +1 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +46 -8
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +24 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +43 -1
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts +1 -2
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/risk-assessment.js +1 -123
- package/dist/core/autonomy/risk-assessment.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +4 -4
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js +16 -29
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +7 -7
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +9 -9
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +90 -156
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +192 -968
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +7 -1
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/capability-contract.d.ts +4 -0
- package/dist/core/capability-contract.d.ts.map +1 -0
- package/dist/core/capability-contract.js +28 -0
- package/dist/core/capability-contract.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +90 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +452 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/compaction-support.d.ts +24 -13
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +43 -7
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -2
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +34 -2
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-audit.d.ts +33 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +31 -5
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts +8 -2
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +158 -35
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +9 -11
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +6 -8
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts +3 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +26 -6
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +26 -4
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +146 -18
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost-guard.d.ts +19 -3
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +18 -3
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
- package/dist/core/delegation/managed-lane-controller.js +217 -0
- package/dist/core/delegation/managed-lane-controller.js.map +1 -0
- package/dist/core/delegation/session-worker-claim.d.ts +44 -0
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-claim.js +98 -0
- package/dist/core/delegation/session-worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +7 -5
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +20 -4
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts +56 -0
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/worker-claim.js +239 -0
- package/dist/core/delegation/worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.js +861 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
- package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-request.js +2 -0
- package/dist/core/delegation/worker-delegation-request.js.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
- package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-execution-policy.js +160 -0
- package/dist/core/delegation/worker-execution-policy.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
- package/dist/core/delegation/worker-lane-projection.js +100 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
- package/dist/core/delegation/worker-lifecycle.js +339 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.js +90 -0
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.js +113 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +25 -14
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +122 -53
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts +3 -0
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-label.js +11 -0
- package/dist/core/delegation/worker-task-label.js.map +1 -0
- package/dist/core/doctor.d.ts +8 -0
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +32 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +68 -13
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +7 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/storage.d.ts +8 -0
- package/dist/core/extensions/storage.d.ts.map +1 -0
- package/dist/core/extensions/storage.js +28 -0
- package/dist/core/extensions/storage.js.map +1 -0
- package/dist/core/extensions/types.d.ts +101 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +1 -15
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +9 -37
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +52 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
- package/dist/core/foreground-recovery-controller.js +111 -0
- package/dist/core/foreground-recovery-controller.js.map +1 -0
- package/dist/core/gateways/channel-provider.d.ts +3 -0
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +31 -6
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +17 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +79 -11
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +25 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +27 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +93 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +48 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +87 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +39 -0
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +42 -0
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +5 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +56 -15
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +20 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +17 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +105 -4
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +91 -6
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +90 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +78 -15
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +58 -2
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +82 -6
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +13 -6
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +20 -28
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input.d.ts +100 -0
- package/dist/core/human-input.d.ts.map +1 -0
- package/dist/core/human-input.js +362 -0
- package/dist/core/human-input.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -0
- package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
- package/dist/core/install-telemetry.js.map +1 -0
- package/dist/core/keybindings.d.ts +27 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +34 -8
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +2 -4
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +9 -29
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js +1 -6
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/observation-store.d.ts +12 -3
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +30 -15
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +2 -4
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js +9 -29
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts +5 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +21 -19
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +65 -3
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +186 -26
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +6 -6
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +4 -4
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +34 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +43 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +6 -9
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +1 -4
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +1 -156
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts +15 -0
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js +23 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +34 -7
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +95 -16
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +4 -4
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +23 -0
- package/dist/core/model-tool-protocol.d.ts.map +1 -0
- package/dist/core/model-tool-protocol.js +43 -0
- package/dist/core/model-tool-protocol.js.map +1 -0
- package/dist/core/models/adaptation-store.d.ts +10 -5
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +129 -81
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js +17 -0
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +4 -11
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +87 -51
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts +34 -0
- package/dist/core/models/host-state-store.d.ts.map +1 -0
- package/dist/core/models/host-state-store.js +86 -0
- package/dist/core/models/host-state-store.js.map +1 -0
- package/dist/core/models/llamacpp-runtime.d.ts +180 -0
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -0
- package/dist/core/models/llamacpp-runtime.js +475 -0
- package/dist/core/models/llamacpp-runtime.js.map +1 -0
- package/dist/core/models/local-registration.d.ts +40 -0
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +94 -5
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +6 -5
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-ref.d.ts +7 -0
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js +26 -0
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +257 -0
- package/dist/core/models/needle-runtime.d.ts.map +1 -0
- package/dist/core/models/needle-runtime.js +519 -0
- package/dist/core/models/needle-runtime.js.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts +89 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js +121 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +24 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
- package/dist/core/orchestration/agent-resume.js +90 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +61 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
- package/dist/core/orchestration/capability-gateway.js +152 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -0
- package/dist/core/orchestration/contracts.d.ts +343 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -0
- package/dist/core/orchestration/contracts.js +135 -0
- package/dist/core/orchestration/contracts.js.map +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/delegation-ledger.js +197 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -0
- package/dist/core/orchestration/event-store.d.ts +83 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -0
- package/dist/core/orchestration/event-store.js +560 -0
- package/dist/core/orchestration/event-store.js.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.js +37 -0
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
- package/dist/core/orchestration/model-binding.d.ts +15 -0
- package/dist/core/orchestration/model-binding.d.ts.map +1 -0
- package/dist/core/orchestration/model-binding.js +29 -0
- package/dist/core/orchestration/model-binding.js.map +1 -0
- package/dist/core/orchestration/policy-compiler.d.ts +49 -0
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
- package/dist/core/orchestration/policy-compiler.js +191 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -0
- package/dist/core/orchestration/policy-gate.d.ts +18 -0
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
- package/dist/core/orchestration/policy-gate.js +24 -0
- package/dist/core/orchestration/policy-gate.js.map +1 -0
- package/dist/core/orchestration/profile-registry.d.ts +51 -0
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
- package/dist/core/orchestration/profile-registry.js +393 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -0
- package/dist/core/orchestration/profile-store.d.ts +31 -0
- package/dist/core/orchestration/profile-store.d.ts.map +1 -0
- package/dist/core/orchestration/profile-store.js +136 -0
- package/dist/core/orchestration/profile-store.js.map +1 -0
- package/dist/core/orchestration/risk-budget.d.ts +9 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
- package/dist/core/orchestration/risk-budget.js +48 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +168 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime.js +1600 -0
- package/dist/core/orchestration/task-runtime.js.map +1 -0
- package/dist/core/orchestration/work-state-projection.d.ts +32 -0
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
- package/dist/core/orchestration/work-state-projection.js +116 -0
- package/dist/core/orchestration/work-state-projection.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.js +179 -0
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.js +109 -0
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -10
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts +11 -0
- package/dist/core/process-identity.d.ts.map +1 -0
- package/dist/core/process-identity.js +26 -0
- package/dist/core/process-identity.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts +83 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -0
- package/dist/core/process-matrix/codes.js +15 -0
- package/dist/core/process-matrix/codes.js.map +1 -0
- package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
- package/dist/core/process-matrix/resume-launcher.js +62 -0
- package/dist/core/process-matrix/resume-launcher.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +78 -0
- package/dist/core/process-matrix/runtime.d.ts.map +1 -0
- package/dist/core/process-matrix/runtime.js +633 -0
- package/dist/core/process-matrix/runtime.js.map +1 -0
- package/dist/core/process-matrix/store.d.ts +25 -0
- package/dist/core/process-matrix/store.d.ts.map +1 -0
- package/dist/core/process-matrix/store.js +189 -0
- package/dist/core/process-matrix/store.js.map +1 -0
- package/dist/core/process-matrix/supervisor.d.ts +75 -0
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -0
- package/dist/core/process-matrix/supervisor.js +161 -0
- package/dist/core/process-matrix/supervisor.js.map +1 -0
- package/dist/core/profile-registry.d.ts +7 -0
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +25 -7
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js +3 -3
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +33 -9
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +217 -127
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +36 -0
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +50 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +1 -6
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts +33 -0
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
- package/dist/core/research/lane-model-resolver.js +65 -0
- package/dist/core/research/lane-model-resolver.js.map +1 -0
- package/dist/core/research/model-fitness-controller.d.ts +38 -0
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
- package/dist/core/research/model-fitness-controller.js +106 -0
- package/dist/core/research/model-fitness-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -4
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js +7 -7
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +62 -0
- package/dist/core/research/research-lane-controller.d.ts.map +1 -0
- package/dist/core/research/research-lane-controller.js +292 -0
- package/dist/core/research/research-lane-controller.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +2 -4
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js +10 -46
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +15 -9
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts +6 -0
- package/dist/core/risk-classifier.d.ts.map +1 -0
- package/dist/core/risk-classifier.js +225 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +76 -17
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +367 -124
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +6 -0
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +66 -52
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +64 -27
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +28 -1
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-image-store.d.ts +33 -0
- package/dist/core/session-image-store.d.ts.map +1 -0
- package/dist/core/session-image-store.js +283 -0
- package/dist/core/session-image-store.js.map +1 -0
- package/dist/core/session-role.d.ts +33 -0
- package/dist/core/session-role.d.ts.map +1 -0
- package/dist/core/session-role.js +58 -0
- package/dist/core/session-role.js.map +1 -0
- package/dist/core/session-snapshot.d.ts +34 -0
- package/dist/core/session-snapshot.d.ts.map +1 -0
- package/dist/core/session-snapshot.js +68 -0
- package/dist/core/session-snapshot.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +31 -0
- package/dist/core/session-supervision-runtime.d.ts.map +1 -0
- package/dist/core/session-supervision-runtime.js +97 -0
- package/dist/core/session-supervision-runtime.js.map +1 -0
- package/dist/core/settings-manager.d.ts +51 -7
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +168 -82
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +12 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +6 -0
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts +14 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +13 -6
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +20 -22
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts +45 -0
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -0
- package/dist/core/tasks/task-contract-monitor.js +56 -0
- package/dist/core/tasks/task-contract-monitor.js.map +1 -0
- package/dist/core/tasks/task-projection.d.ts +20 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -0
- package/dist/core/tasks/task-projection.js +47 -0
- package/dist/core/tasks/task-projection.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +12 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +56 -12
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -0
- package/dist/core/tool-capability-policy.js +85 -0
- package/dist/core/tool-capability-policy.js.map +1 -0
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +5 -0
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +91 -0
- package/dist/core/tool-protocol-controller.d.ts.map +1 -0
- package/dist/core/tool-protocol-controller.js +512 -0
- package/dist/core/tool-protocol-controller.js.map +1 -0
- package/dist/core/tool-recovery-log-records.d.ts +6 -0
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +13 -31
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts +54 -0
- package/dist/core/tool-selection/promotion.d.ts.map +1 -0
- package/dist/core/tool-selection/promotion.js +81 -0
- package/dist/core/tool-selection/promotion.js.map +1 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts +39 -6
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +153 -110
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.d.ts +45 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +96 -0
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +124 -0
- package/dist/core/tools/ask-question.d.ts.map +1 -0
- package/dist/core/tools/ask-question.js +693 -0
- package/dist/core/tools/ask-question.js.map +1 -0
- package/dist/core/tools/bash.d.ts +18 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +95 -16
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +44 -2
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +214 -19
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +15 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +124 -22
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +1 -0
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/goal.d.ts +94 -3
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +165 -15
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts +7 -0
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +4 -4
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +43 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +168 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/run-process.d.ts +26 -0
- package/dist/core/tools/run-process.d.ts.map +1 -0
- package/dist/core/tools/run-process.js +138 -0
- package/dist/core/tools/run-process.js.map +1 -0
- package/dist/core/tools/shell-contract-router.d.ts +6 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +23 -2
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts +89 -0
- package/dist/core/tools/shell-session.d.ts.map +1 -0
- package/dist/core/tools/shell-session.js +432 -0
- package/dist/core/tools/shell-session.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +6 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +165 -8
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +84 -0
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -0
- package/dist/core/tools/tmux-dispatch.js +91 -0
- package/dist/core/tools/tmux-dispatch.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +42 -0
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-engine.js +151 -0
- package/dist/core/tools/windows-shell-engine.js.map +1 -0
- package/dist/core/tools/windows-shell-state.d.ts +40 -0
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-state.js +59 -0
- package/dist/core/tools/windows-shell-state.js.map +1 -0
- package/dist/core/tools/worktree-sync.d.ts +24 -0
- package/dist/core/tools/worktree-sync.d.ts.map +1 -0
- package/dist/core/tools/worktree-sync.js +338 -0
- package/dist/core/tools/worktree-sync.js.map +1 -0
- package/dist/core/trust-manager.d.ts +4 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +20 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +55 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -0
- package/dist/core/util/atomic-file.js +255 -0
- package/dist/core/util/atomic-file.js.map +1 -0
- package/dist/core/util/bounded-jsonl.d.ts +10 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
- package/dist/core/util/bounded-jsonl.js +75 -0
- package/dist/core/util/bounded-jsonl.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts +33 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -0
- package/dist/core/util/minimatch-cache.js +0 -0
- package/dist/core/util/minimatch-cache.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +5 -0
- package/dist/core/util/value-guards.d.ts.map +1 -0
- package/dist/core/util/value-guards.js +12 -0
- package/dist/core/util/value-guards.js.map +1 -0
- package/dist/core/worktree-sync/codes.d.ts +227 -0
- package/dist/core/worktree-sync/codes.d.ts.map +1 -0
- package/dist/core/worktree-sync/codes.js +14 -0
- package/dist/core/worktree-sync/codes.js.map +1 -0
- package/dist/core/worktree-sync/git-engine.d.ts +156 -0
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -0
- package/dist/core/worktree-sync/git-engine.js +1191 -0
- package/dist/core/worktree-sync/git-engine.js.map +1 -0
- package/dist/core/worktree-sync/lane-gate.d.ts +75 -0
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -0
- package/dist/core/worktree-sync/lane-gate.js +360 -0
- package/dist/core/worktree-sync/lane-gate.js.map +1 -0
- package/dist/core/worktree-sync/runtime.d.ts +47 -0
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -0
- package/dist/core/worktree-sync/runtime.js +96 -0
- package/dist/core/worktree-sync/runtime.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +69 -0
- package/dist/core/worktree-sync/store.d.ts.map +1 -0
- package/dist/core/worktree-sync/store.js +252 -0
- package/dist/core/worktree-sync/store.js.map +1 -0
- package/dist/core/worktree-sync/watcher.d.ts +29 -0
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -0
- package/dist/core/worktree-sync/watcher.js +93 -0
- package/dist/core/worktree-sync/watcher.js.map +1 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +179 -1
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +7 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +197 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +16 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +50 -8
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +7 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +44 -6
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +23 -1
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +2 -2
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js +5 -4
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +76 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +67 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -1
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts +43 -0
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +290 -3
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +7 -7
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +21 -0
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +17 -2
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +74 -21
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js +16 -6
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
- package/dist/modes/interactive/session-replacement-errors.js +15 -0
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +1 -1
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +82 -23
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +138 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -13
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +52 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +11 -0
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +20 -2
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts +4 -0
- package/dist/utils/highlight-js-languages.d.ts.map +1 -0
- package/dist/utils/highlight-js-languages.js +573 -0
- package/dist/utils/highlight-js-languages.js.map +1 -0
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +8 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell.d.ts +7 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +21 -6
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +53 -5
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +112 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/work-directory.d.ts +11 -0
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js +30 -9
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +44 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +30 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +62 -2
- package/docs/harness-architecture.md +156 -0
- package/docs/keybindings.md +11 -1
- package/docs/process-matrix.md +153 -0
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +128 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +92 -2
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +7 -0
- package/docs/ui-reference/orchestration-before.txt +7 -0
- package/docs/ui-reference/orchestration-reference.txt +6 -0
- package/docs/usage.md +14 -2
- package/docs/windows.md +52 -3
- package/docs/work-directory.md +42 -2
- package/docs/worktree-sync.md +250 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/question.ts +34 -245
- package/examples/extensions/questionnaire.ts +41 -407
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +10 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -16
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -53
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts +0 -15
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js +0 -161
- package/dist/core/delegation/worker-result.js.map +0 -1
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js.map +0 -1
- package/docs/integration-sweep-builder-blueprint-2026-07-09.md +0 -365
- package/docs/integration-sweep-resume-2026-07-09.md +0 -407
|
@@ -1,54 +1,151 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
+
import { emptyOrchestrationCall, OrchestrationPanelComponent, } from "./orchestration-panel.js";
|
|
2
3
|
function createDelegateSchema() {
|
|
3
4
|
return Type.Object({
|
|
5
|
+
profileId: Type.Optional(Type.String({
|
|
6
|
+
description: "Owner-authored orchestration profile to use. The profile fixes role, model, thinking, tools, resources, budget, and concurrency. Omit only when the owner configured a default workerDelegation.orchestrationProfile.",
|
|
7
|
+
})),
|
|
4
8
|
instructions: Type.String({
|
|
5
9
|
description: "The self-contained task for a bounded worker with classified workspace tools. It is read-only unless workerDelegation.writeEnabled, non-empty writePaths, and its lane profile all grant write/edit; any write is path-scoped and parent-reviewed. Include all context it needs; it cannot see this conversation.",
|
|
6
10
|
}),
|
|
7
|
-
systemPrompt: Type.Optional(Type.String({
|
|
8
|
-
description: "Optional replacement for the worker's role prompt — useful to hand a small model a minimal, purpose-built prompt. A short non-negotiable core (read-only, no invention, untrusted output, exact format) always remains.",
|
|
9
|
-
})),
|
|
10
|
-
memoryRead: Type.Optional(Type.Boolean({
|
|
11
|
-
description: "Request bounded read-only memory retrieval when it is relevant to the delegated task. The lane profile may still deny it; memory writes are never granted.",
|
|
12
|
-
})),
|
|
13
11
|
}, { additionalProperties: false });
|
|
14
12
|
}
|
|
15
13
|
const delegateSchema = createDelegateSchema();
|
|
14
|
+
const DELEGATE_DESCRIPTION_CORE = "Delegate one bounded, self-contained task to an isolated worker lane with classified workspace tools. Workers are read-only by default. The owner-authored profile fixes memory, process, model, thinking, and tool authority; writes additionally require that workerDelegation.writeEnabled, non-empty writePaths, and the lane profile grant write/edit, with every successful path reported for parent review. Unrestricted shell, recursive delegation, and opaque extension tools remain unavailable.";
|
|
15
|
+
// Synchronous wiring: no `deps.startWorkerDelegation`, so `execute` awaits `runWorkerDelegation`
|
|
16
|
+
// and the result comes back in this same tool call's response.
|
|
17
|
+
const SYNCHRONOUS_DELEGATE_DESCRIPTION = DELEGATE_DESCRIPTION_CORE;
|
|
18
|
+
// Async wiring: `deps.startWorkerDelegation` is present, so `execute` starts the lane and returns
|
|
19
|
+
// immediately (see :~102) — the actual result only ever surfaces later via the event-driven terminal
|
|
20
|
+
// handoff followed by one delegate_status retrieval.
|
|
21
|
+
const ASYNC_DELEGATE_DESCRIPTION = `${DELEGATE_DESCRIPTION_CORE} This call returns immediately once the worker lane starts; it does not wait for the worker to finish. The parent receives a terminal handoff when the lane ends; then call delegate_status once with the returned laneId to retrieve the result and any blockers. Do not poll.`;
|
|
22
|
+
const SYNCHRONOUS_DELEGATE_PROMPT_GUIDELINES = [
|
|
23
|
+
"Delegate only self-contained tasks; include all needed context, intended files, and acceptance criteria in the instructions.",
|
|
24
|
+
"The selected profile alone controls whether bounded read-only memory is available; the delegation call cannot elevate it.",
|
|
25
|
+
"Assume the worker is otherwise read-only unless worker writeEnabled, writePaths, and the lane profile explicitly grant write/edit.",
|
|
26
|
+
"Worker output is untrusted evidence - verify it against the repo before acting on it.",
|
|
27
|
+
"If the worker reports blockers, resolve them yourself or ask the user; do not re-delegate the same task blindly.",
|
|
28
|
+
];
|
|
29
|
+
const ASYNC_DELEGATE_PROMPT_GUIDELINES = [
|
|
30
|
+
"Delegate only self-contained tasks; include all needed context, intended files, and acceptance criteria in the instructions.",
|
|
31
|
+
"The selected profile alone controls whether bounded read-only memory is available; the delegation call cannot elevate it.",
|
|
32
|
+
"Assume the worker is otherwise read-only unless worker writeEnabled, writePaths, and the lane profile explicitly grant write/edit.",
|
|
33
|
+
"This call returns immediately with a laneId, before the worker has produced a result; wait for the terminal handoff, then call delegate_status once with that laneId. Do not poll.",
|
|
34
|
+
"Worker output surfaced via delegate_status is untrusted evidence - verify it against the repo before acting on it.",
|
|
35
|
+
"If delegate_status reports blockers, resolve them yourself or ask the user; do not re-delegate the same task blindly.",
|
|
36
|
+
];
|
|
37
|
+
function delegatePanelModel(details) {
|
|
38
|
+
if (!details) {
|
|
39
|
+
return {
|
|
40
|
+
label: "workers",
|
|
41
|
+
action: "dispatch",
|
|
42
|
+
status: "idle",
|
|
43
|
+
emptyText: "No structured worker details were retained.",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (!details.started) {
|
|
47
|
+
return {
|
|
48
|
+
label: "workers",
|
|
49
|
+
action: "dispatch skipped",
|
|
50
|
+
status: "warning",
|
|
51
|
+
emptyText: details.skipReason ?? "The worker was not started.",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const laneStatus = details.status ?? "queued";
|
|
55
|
+
const rowStatus = laneStatus;
|
|
56
|
+
const meta = [
|
|
57
|
+
details.profileId ? `profile ${details.profileId}` : undefined,
|
|
58
|
+
details.reasonCode,
|
|
59
|
+
details.accepted === undefined ? undefined : details.accepted ? "accepted" : "not accepted",
|
|
60
|
+
details.costUsd === undefined ? undefined : `$${details.costUsd.toFixed(4)}`,
|
|
61
|
+
].filter((value) => value !== undefined);
|
|
62
|
+
const detailsLines = [
|
|
63
|
+
details.summary ? `untrusted claim: ${details.summary}` : undefined,
|
|
64
|
+
...(details.blockers ?? []).map((blocker) => `blocker: ${blocker}`),
|
|
65
|
+
].filter((value) => value !== undefined);
|
|
66
|
+
const active = laneStatus === "queued" || laneStatus === "running";
|
|
67
|
+
return {
|
|
68
|
+
label: "workers",
|
|
69
|
+
action: active ? "dispatched" : "completed",
|
|
70
|
+
status: active
|
|
71
|
+
? "running"
|
|
72
|
+
: laneStatus === "succeeded" && details.accepted !== false
|
|
73
|
+
? "success"
|
|
74
|
+
: laneStatus === "failed"
|
|
75
|
+
? "error"
|
|
76
|
+
: "warning",
|
|
77
|
+
summary: active ? ["terminal handoff will wake this session"] : undefined,
|
|
78
|
+
rows: [
|
|
79
|
+
{
|
|
80
|
+
status: rowStatus,
|
|
81
|
+
label: details.label ?? details.laneId ?? "worker lane",
|
|
82
|
+
meta: [details.label ? details.laneId : undefined, ...meta].filter((value) => value !== undefined),
|
|
83
|
+
details: detailsLines,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
notices: details.accepted === false
|
|
87
|
+
? [{ status: "warning", text: "Worker output was not accepted; inspect and verify before use." }]
|
|
88
|
+
: undefined,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
16
91
|
export function createDelegateToolDefinition(deps) {
|
|
92
|
+
const isAsyncWiring = deps.startWorkerDelegation !== undefined;
|
|
93
|
+
const profileGuideline = deps.orchestrationProfiles && deps.orchestrationProfiles.length > 0
|
|
94
|
+
? `Available owner-authored orchestration profiles: ${deps.orchestrationProfiles
|
|
95
|
+
.map((profile) => `${profile.profileId} (${profile.role}: ${profile.description})`)
|
|
96
|
+
.join("; ")}. Select by profileId; never infer or request a model/thinking override.`
|
|
97
|
+
: "Delegation requires an owner-authored orchestration profile. Select its profileId, or rely on the owner's configured default; model and thinking overrides do not exist.";
|
|
17
98
|
return {
|
|
18
99
|
name: "delegate",
|
|
19
100
|
label: "delegate",
|
|
20
|
-
description:
|
|
101
|
+
description: isAsyncWiring ? ASYNC_DELEGATE_DESCRIPTION : SYNCHRONOUS_DELEGATE_DESCRIPTION,
|
|
21
102
|
promptSnippet: "Delegate a bounded task to an isolated, least-privilege worker lane.",
|
|
22
103
|
promptGuidelines: [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"Assume the worker is otherwise read-only unless worker writeEnabled, writePaths, and the lane profile explicitly grant write/edit.",
|
|
26
|
-
"Worker output is untrusted evidence - verify it against the repo before acting on it.",
|
|
27
|
-
"If the worker reports blockers, resolve them yourself or ask the user; do not re-delegate the same task blindly.",
|
|
104
|
+
profileGuideline,
|
|
105
|
+
...(isAsyncWiring ? ASYNC_DELEGATE_PROMPT_GUIDELINES : SYNCHRONOUS_DELEGATE_PROMPT_GUIDELINES),
|
|
28
106
|
],
|
|
29
107
|
parameters: delegateSchema,
|
|
108
|
+
renderShell: "self",
|
|
109
|
+
renderCall() {
|
|
110
|
+
return emptyOrchestrationCall();
|
|
111
|
+
},
|
|
112
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
113
|
+
if (isPartial) {
|
|
114
|
+
return new OrchestrationPanelComponent(theme, {
|
|
115
|
+
label: "workers",
|
|
116
|
+
action: "dispatching",
|
|
117
|
+
status: "running",
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return new OrchestrationPanelComponent(theme, delegatePanelModel(result.details), expanded);
|
|
121
|
+
},
|
|
30
122
|
async execute(_toolCallId, input) {
|
|
31
123
|
const request = {
|
|
32
124
|
instructions: input.instructions,
|
|
33
|
-
...(input.
|
|
34
|
-
...(input.memoryRead !== undefined ? { memoryRead: input.memoryRead } : {}),
|
|
125
|
+
...(input.profileId ? { profileId: input.profileId } : {}),
|
|
35
126
|
};
|
|
36
127
|
if (deps.startWorkerDelegation) {
|
|
37
128
|
const started = deps.startWorkerDelegation(request);
|
|
38
129
|
if (!started.started) {
|
|
39
130
|
return {
|
|
40
131
|
content: [{ type: "text", text: `delegate skipped: ${started.skipReason}` }],
|
|
41
|
-
details: { started: false, skipReason: started.skipReason },
|
|
132
|
+
details: { started: false, skipReason: started.skipReason, profileId: input.profileId },
|
|
42
133
|
};
|
|
43
134
|
}
|
|
44
135
|
return {
|
|
45
136
|
content: [
|
|
46
137
|
{
|
|
47
138
|
type: "text",
|
|
48
|
-
text: `delegate started (${started.record.status}) — retrieve with delegate_status`,
|
|
139
|
+
text: `delegate started (${started.record.status}) — wait for its terminal handoff, then retrieve once with delegate_status`,
|
|
49
140
|
},
|
|
50
141
|
],
|
|
51
|
-
details: {
|
|
142
|
+
details: {
|
|
143
|
+
started: true,
|
|
144
|
+
profileId: started.record.profileId ?? input.profileId,
|
|
145
|
+
laneId: started.record.laneId,
|
|
146
|
+
label: started.record.label,
|
|
147
|
+
status: started.record.status,
|
|
148
|
+
},
|
|
52
149
|
};
|
|
53
150
|
}
|
|
54
151
|
const run = await deps.runWorkerDelegation(request);
|
|
@@ -56,7 +153,7 @@ export function createDelegateToolDefinition(deps) {
|
|
|
56
153
|
const reason = run.skipReason ?? "unknown";
|
|
57
154
|
return {
|
|
58
155
|
content: [{ type: "text", text: `delegate skipped: ${reason}` }],
|
|
59
|
-
details: { started: false, skipReason: reason },
|
|
156
|
+
details: { started: false, skipReason: reason, profileId: input.profileId },
|
|
60
157
|
};
|
|
61
158
|
}
|
|
62
159
|
const outcome = run.outcome;
|
|
@@ -64,11 +161,11 @@ export function createDelegateToolDefinition(deps) {
|
|
|
64
161
|
`delegate ${run.record?.status ?? "unknown"}${run.record?.reasonCode ? ` (${run.record.reasonCode})` : ""}`,
|
|
65
162
|
];
|
|
66
163
|
if (outcome) {
|
|
67
|
-
lines.push(`accepted: ${outcome.accepted} [${outcome.acceptance.outcome}/${outcome.acceptance.reasonCode}]`, "Worker output (UNTRUSTED - verify before acting on it):", outcome.
|
|
68
|
-
if (outcome.
|
|
69
|
-
lines.push(`Blockers: ${outcome.
|
|
164
|
+
lines.push(`accepted: ${outcome.accepted} [${outcome.acceptance.outcome}/${outcome.acceptance.reasonCode}]`, "Worker output (UNTRUSTED - verify before acting on it):", outcome.claim.summary);
|
|
165
|
+
if (outcome.claim.blockers && outcome.claim.blockers.length > 0) {
|
|
166
|
+
lines.push(`Blockers: ${outcome.claim.blockers.join("; ")}`);
|
|
70
167
|
}
|
|
71
|
-
for (const finding of outcome.
|
|
168
|
+
for (const finding of outcome.claim.evidence?.findings ?? []) {
|
|
72
169
|
lines.push(`- Finding: ${finding.summary}`);
|
|
73
170
|
}
|
|
74
171
|
}
|
|
@@ -76,10 +173,15 @@ export function createDelegateToolDefinition(deps) {
|
|
|
76
173
|
content: [{ type: "text", text: lines.join("\n") }],
|
|
77
174
|
details: {
|
|
78
175
|
started: true,
|
|
176
|
+
profileId: run.record?.profileId ?? input.profileId,
|
|
79
177
|
laneId: run.record?.laneId,
|
|
178
|
+
label: run.record?.label,
|
|
80
179
|
status: run.record?.status,
|
|
180
|
+
reasonCode: run.record?.reasonCode,
|
|
81
181
|
accepted: outcome?.accepted,
|
|
82
182
|
costUsd: outcome?.costUsd,
|
|
183
|
+
summary: outcome?.claim.summary.slice(0, 8_000),
|
|
184
|
+
blockers: outcome?.claim.blockers?.slice(0, 16),
|
|
83
185
|
},
|
|
84
186
|
};
|
|
85
187
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../../src/core/tools/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,SAAS,oBAAoB,GAAG;IAC/B,OAAO,IAAI,CAAC,MAAM,CACjB;QACC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC;YACzB,WAAW,EACV,mTAAmT;SACpT,CAAC;QACF,YAAY,EAAE,IAAI,CAAC,QAAQ,CAC1B,IAAI,CAAC,MAAM,CAAC;YACX,WAAW,EACV,2NAAyN;SAC1N,CAAC,CACF;QACD,UAAU,EAAE,IAAI,CAAC,QAAQ,CACxB,IAAI,CAAC,OAAO,CAAC;YACZ,WAAW,EACV,4JAA4J;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CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACnE,KAAK,CAAC,IAAI,CAAC,aAAa,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/D,CAAC;gBACD,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,IAAI,EAAE,EAAE,CAAC;oBAC/D,KAAK,CAAC,IAAI,CAAC,cAAc,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC7C,CAAC;YACF,CAAC;YACD,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5D,OAAO,EAAE;oBACR,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM;oBAC1B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM;oBAC1B,QAAQ,EAAE,OAAO,EAAE,QAAQ;oBAC3B,OAAO,EAAE,OAAO,EAAE,OAAO;iBACzB;aACD,CAAC;QAAA,CACF;KACD,CAAC;AAAA,CACF","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { WorkerRunOutcome } from \"../delegation/worker-runner.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\n\nfunction createDelegateSchema() {\n\treturn Type.Object(\n\t\t{\n\t\t\tinstructions: Type.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"The self-contained task for a bounded worker with classified workspace tools. It is read-only unless workerDelegation.writeEnabled, non-empty writePaths, and its lane profile all grant write/edit; any write is path-scoped and parent-reviewed. Include all context it needs; it cannot see this conversation.\",\n\t\t\t}),\n\t\t\tsystemPrompt: Type.Optional(\n\t\t\t\tType.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Optional replacement for the worker's role prompt — useful to hand a small model a minimal, purpose-built prompt. A short non-negotiable core (read-only, no invention, untrusted output, exact format) always remains.\",\n\t\t\t\t}),\n\t\t\t),\n\t\t\tmemoryRead: Type.Optional(\n\t\t\t\tType.Boolean({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Request bounded read-only memory retrieval when it is relevant to the delegated task. The lane profile may still deny it; memory writes are never granted.\",\n\t\t\t\t}),\n\t\t\t),\n\t\t},\n\t\t{ additionalProperties: false },\n\t);\n}\n\nconst delegateSchema = createDelegateSchema();\n\nexport type DelegateToolInput = Static<typeof delegateSchema>;\n\nexport interface DelegateRunOutcome {\n\tstarted: boolean;\n\tskipReason?: string;\n\trecord?: LaneRecord;\n\toutcome?: WorkerRunOutcome;\n}\n\nexport interface DelegateToolDetails {\n\tstarted: boolean;\n\tskipReason?: string;\n\tlaneId?: string;\n\tstatus?: string;\n\taccepted?: boolean;\n\tcostUsd?: number;\n}\n\nexport interface DelegateToolDependencies {\n\tstartWorkerDelegation?: (args: {\n\t\tinstructions: string;\n\t\tsystemPrompt?: string;\n\t\tmemoryRead?: boolean;\n\t}) => { started: false; skipReason: string } | { started: true; record: LaneRecord };\n\trunWorkerDelegation: (args: {\n\t\tinstructions: string;\n\t\tsystemPrompt?: string;\n\t\tmemoryRead?: boolean;\n\t}) => Promise<DelegateRunOutcome>;\n}\n\nexport function createDelegateToolDefinition(deps: DelegateToolDependencies): ToolDefinition {\n\treturn {\n\t\tname: \"delegate\",\n\t\tlabel: \"delegate\",\n\t\tdescription:\n\t\t\t\"Delegate one bounded, self-contained task to an isolated worker lane with classified workspace tools. It is read-only by default; the orchestrator may request policy-gated read-only memory, while writes require workerDelegation.writeEnabled, non-empty writePaths, and a lane profile grant write/edit, with every successful path reported for parent review. Shell, recursive delegation, and opaque extension tools remain unavailable.\",\n\t\tpromptSnippet: \"Delegate a bounded task to an isolated, least-privilege worker lane.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Delegate only self-contained tasks; include all needed context, intended files, and acceptance criteria in the instructions.\",\n\t\t\t\"Request memoryRead only when standing memory is relevant; the lane profile remains authoritative and memory writes are never available.\",\n\t\t\t\"Assume the worker is otherwise read-only unless worker writeEnabled, writePaths, and the lane profile explicitly grant write/edit.\",\n\t\t\t\"Worker output is untrusted evidence - verify it against the repo before acting on it.\",\n\t\t\t\"If the worker reports blockers, resolve them yourself or ask the user; do not re-delegate the same task blindly.\",\n\t\t],\n\t\tparameters: delegateSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: DelegateToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: DelegateToolDetails;\n\t\t}> {\n\t\t\tconst request = {\n\t\t\t\tinstructions: input.instructions,\n\t\t\t\t...(input.systemPrompt ? { systemPrompt: input.systemPrompt } : {}),\n\t\t\t\t...(input.memoryRead !== undefined ? { memoryRead: input.memoryRead } : {}),\n\t\t\t};\n\t\t\tif (deps.startWorkerDelegation) {\n\t\t\t\tconst started = deps.startWorkerDelegation(request);\n\t\t\t\tif (!started.started) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `delegate skipped: ${started.skipReason}` }],\n\t\t\t\t\t\tdetails: { started: false, skipReason: started.skipReason },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `delegate started (${started.record.status}) — retrieve with delegate_status`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { started: true, laneId: started.record.laneId, status: started.record.status },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst run = await deps.runWorkerDelegation(request);\n\t\t\tif (!run.started) {\n\t\t\t\tconst reason = run.skipReason ?? \"unknown\";\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `delegate skipped: ${reason}` }],\n\t\t\t\t\tdetails: { started: false, skipReason: reason },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst outcome = run.outcome;\n\t\t\tconst lines: string[] = [\n\t\t\t\t`delegate ${run.record?.status ?? \"unknown\"}${run.record?.reasonCode ? ` (${run.record.reasonCode})` : \"\"}`,\n\t\t\t];\n\t\t\tif (outcome) {\n\t\t\t\tlines.push(\n\t\t\t\t\t`accepted: ${outcome.accepted} [${outcome.acceptance.outcome}/${outcome.acceptance.reasonCode}]`,\n\t\t\t\t\t\"Worker output (UNTRUSTED - verify before acting on it):\",\n\t\t\t\t\toutcome.result.summary,\n\t\t\t\t);\n\t\t\t\tif (outcome.result.blockers && outcome.result.blockers.length > 0) {\n\t\t\t\t\tlines.push(`Blockers: ${outcome.result.blockers.join(\"; \")}`);\n\t\t\t\t}\n\t\t\t\tfor (const finding of outcome.result.evidence?.findings ?? []) {\n\t\t\t\t\tlines.push(`- Finding: ${finding.summary}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: {\n\t\t\t\t\tstarted: true,\n\t\t\t\t\tlaneId: run.record?.laneId,\n\t\t\t\t\tstatus: run.record?.status,\n\t\t\t\t\taccepted: outcome?.accepted,\n\t\t\t\t\tcostUsd: outcome?.costUsd,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../../src/core/tools/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EACN,sBAAsB,EACtB,2BAA2B,GAG3B,MAAM,0BAA0B,CAAC;AAElC,SAAS,oBAAoB,GAAG;IAC/B,OAAO,IAAI,CAAC,MAAM,CACjB;QACC,SAAS,EAAE,IAAI,CAAC,QAAQ,CACvB,IAAI,C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AAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;oBAC/C,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;iBAC/C;aACD,CAAC;QAAA,CACF;KACD,CAAC;AAAA,CACF","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { WorkerDelegationRequest } from \"../delegation/worker-delegation-request.ts\";\nimport type { WorkerRunOutcome } from \"../delegation/worker-runner.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttype OrchestrationRowStatus,\n} from \"./orchestration-panel.ts\";\n\nfunction createDelegateSchema() {\n\treturn Type.Object(\n\t\t{\n\t\t\tprofileId: Type.Optional(\n\t\t\t\tType.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Owner-authored orchestration profile to use. The profile fixes role, model, thinking, tools, resources, budget, and concurrency. Omit only when the owner configured a default workerDelegation.orchestrationProfile.\",\n\t\t\t\t}),\n\t\t\t),\n\t\t\tinstructions: Type.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"The self-contained task for a bounded worker with classified workspace tools. It is read-only unless workerDelegation.writeEnabled, non-empty writePaths, and its lane profile all grant write/edit; any write is path-scoped and parent-reviewed. Include all context it needs; it cannot see this conversation.\",\n\t\t\t}),\n\t\t},\n\t\t{ additionalProperties: false },\n\t);\n}\n\nconst delegateSchema = createDelegateSchema();\n\nexport type DelegateToolInput = Static<typeof delegateSchema>;\n\nexport interface DelegateRunOutcome {\n\tstarted: boolean;\n\tskipReason?: string;\n\trecord?: LaneRecord;\n\toutcome?: WorkerRunOutcome;\n}\n\nexport interface DelegateToolDetails {\n\tstarted: boolean;\n\tskipReason?: string;\n\tprofileId?: string;\n\tlaneId?: string;\n\tlabel?: string;\n\tstatus?: LaneRecord[\"status\"];\n\treasonCode?: string;\n\taccepted?: boolean;\n\tcostUsd?: number;\n\tsummary?: string;\n\tblockers?: readonly string[];\n}\n\nexport interface DelegateToolDependencies {\n\tstartWorkerDelegation?: (\n\t\targs: WorkerDelegationRequest,\n\t) => { started: false; skipReason: string } | { started: true; record: LaneRecord };\n\trunWorkerDelegation: (args: WorkerDelegationRequest) => Promise<DelegateRunOutcome>;\n\torchestrationProfiles?: readonly { profileId: string; role: string; description: string }[];\n}\n\nconst DELEGATE_DESCRIPTION_CORE =\n\t\"Delegate one bounded, self-contained task to an isolated worker lane with classified workspace tools. Workers are read-only by default. The owner-authored profile fixes memory, process, model, thinking, and tool authority; writes additionally require that workerDelegation.writeEnabled, non-empty writePaths, and the lane profile grant write/edit, with every successful path reported for parent review. Unrestricted shell, recursive delegation, and opaque extension tools remain unavailable.\";\n\n// Synchronous wiring: no `deps.startWorkerDelegation`, so `execute` awaits `runWorkerDelegation`\n// and the result comes back in this same tool call's response.\nconst SYNCHRONOUS_DELEGATE_DESCRIPTION = DELEGATE_DESCRIPTION_CORE;\n\n// Async wiring: `deps.startWorkerDelegation` is present, so `execute` starts the lane and returns\n// immediately (see :~102) — the actual result only ever surfaces later via the event-driven terminal\n// handoff followed by one delegate_status retrieval.\nconst ASYNC_DELEGATE_DESCRIPTION = `${DELEGATE_DESCRIPTION_CORE} This call returns immediately once the worker lane starts; it does not wait for the worker to finish. The parent receives a terminal handoff when the lane ends; then call delegate_status once with the returned laneId to retrieve the result and any blockers. Do not poll.`;\n\nconst SYNCHRONOUS_DELEGATE_PROMPT_GUIDELINES = [\n\t\"Delegate only self-contained tasks; include all needed context, intended files, and acceptance criteria in the instructions.\",\n\t\"The selected profile alone controls whether bounded read-only memory is available; the delegation call cannot elevate it.\",\n\t\"Assume the worker is otherwise read-only unless worker writeEnabled, writePaths, and the lane profile explicitly grant write/edit.\",\n\t\"Worker output is untrusted evidence - verify it against the repo before acting on it.\",\n\t\"If the worker reports blockers, resolve them yourself or ask the user; do not re-delegate the same task blindly.\",\n];\n\nconst ASYNC_DELEGATE_PROMPT_GUIDELINES = [\n\t\"Delegate only self-contained tasks; include all needed context, intended files, and acceptance criteria in the instructions.\",\n\t\"The selected profile alone controls whether bounded read-only memory is available; the delegation call cannot elevate it.\",\n\t\"Assume the worker is otherwise read-only unless worker writeEnabled, writePaths, and the lane profile explicitly grant write/edit.\",\n\t\"This call returns immediately with a laneId, before the worker has produced a result; wait for the terminal handoff, then call delegate_status once with that laneId. Do not poll.\",\n\t\"Worker output surfaced via delegate_status is untrusted evidence - verify it against the repo before acting on it.\",\n\t\"If delegate_status reports blockers, resolve them yourself or ask the user; do not re-delegate the same task blindly.\",\n];\n\nfunction delegatePanelModel(details: DelegateToolDetails | undefined): OrchestrationPanelModel {\n\tif (!details) {\n\t\treturn {\n\t\t\tlabel: \"workers\",\n\t\t\taction: \"dispatch\",\n\t\t\tstatus: \"idle\",\n\t\t\temptyText: \"No structured worker details were retained.\",\n\t\t};\n\t}\n\tif (!details.started) {\n\t\treturn {\n\t\t\tlabel: \"workers\",\n\t\t\taction: \"dispatch skipped\",\n\t\t\tstatus: \"warning\",\n\t\t\temptyText: details.skipReason ?? \"The worker was not started.\",\n\t\t};\n\t}\n\tconst laneStatus = details.status ?? \"queued\";\n\tconst rowStatus: OrchestrationRowStatus = laneStatus;\n\tconst meta = [\n\t\tdetails.profileId ? `profile ${details.profileId}` : undefined,\n\t\tdetails.reasonCode,\n\t\tdetails.accepted === undefined ? undefined : details.accepted ? \"accepted\" : \"not accepted\",\n\t\tdetails.costUsd === undefined ? undefined : `$${details.costUsd.toFixed(4)}`,\n\t].filter((value): value is string => value !== undefined);\n\tconst detailsLines = [\n\t\tdetails.summary ? `untrusted claim: ${details.summary}` : undefined,\n\t\t...(details.blockers ?? []).map((blocker) => `blocker: ${blocker}`),\n\t].filter((value): value is string => value !== undefined);\n\tconst active = laneStatus === \"queued\" || laneStatus === \"running\";\n\treturn {\n\t\tlabel: \"workers\",\n\t\taction: active ? \"dispatched\" : \"completed\",\n\t\tstatus: active\n\t\t\t? \"running\"\n\t\t\t: laneStatus === \"succeeded\" && details.accepted !== false\n\t\t\t\t? \"success\"\n\t\t\t\t: laneStatus === \"failed\"\n\t\t\t\t\t? \"error\"\n\t\t\t\t\t: \"warning\",\n\t\tsummary: active ? [\"terminal handoff will wake this session\"] : undefined,\n\t\trows: [\n\t\t\t{\n\t\t\t\tstatus: rowStatus,\n\t\t\t\tlabel: details.label ?? details.laneId ?? \"worker lane\",\n\t\t\t\tmeta: [details.label ? details.laneId : undefined, ...meta].filter(\n\t\t\t\t\t(value): value is string => value !== undefined,\n\t\t\t\t),\n\t\t\t\tdetails: detailsLines,\n\t\t\t},\n\t\t],\n\t\tnotices:\n\t\t\tdetails.accepted === false\n\t\t\t\t? [{ status: \"warning\", text: \"Worker output was not accepted; inspect and verify before use.\" }]\n\t\t\t\t: undefined,\n\t};\n}\n\nexport function createDelegateToolDefinition(deps: DelegateToolDependencies): ToolDefinition {\n\tconst isAsyncWiring = deps.startWorkerDelegation !== undefined;\n\tconst profileGuideline =\n\t\tdeps.orchestrationProfiles && deps.orchestrationProfiles.length > 0\n\t\t\t? `Available owner-authored orchestration profiles: ${deps.orchestrationProfiles\n\t\t\t\t\t.map((profile) => `${profile.profileId} (${profile.role}: ${profile.description})`)\n\t\t\t\t\t.join(\"; \")}. Select by profileId; never infer or request a model/thinking override.`\n\t\t\t: \"Delegation requires an owner-authored orchestration profile. Select its profileId, or rely on the owner's configured default; model and thinking overrides do not exist.\";\n\treturn {\n\t\tname: \"delegate\",\n\t\tlabel: \"delegate\",\n\t\tdescription: isAsyncWiring ? ASYNC_DELEGATE_DESCRIPTION : SYNCHRONOUS_DELEGATE_DESCRIPTION,\n\t\tpromptSnippet: \"Delegate a bounded task to an isolated, least-privilege worker lane.\",\n\t\tpromptGuidelines: [\n\t\t\tprofileGuideline,\n\t\t\t...(isAsyncWiring ? ASYNC_DELEGATE_PROMPT_GUIDELINES : SYNCHRONOUS_DELEGATE_PROMPT_GUIDELINES),\n\t\t],\n\t\tparameters: delegateSchema,\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) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"workers\",\n\t\t\t\t\taction: \"dispatching\",\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn new OrchestrationPanelComponent(\n\t\t\t\ttheme,\n\t\t\t\tdelegatePanelModel(result.details as DelegateToolDetails | undefined),\n\t\t\t\texpanded,\n\t\t\t);\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: DelegateToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: DelegateToolDetails;\n\t\t}> {\n\t\t\tconst request = {\n\t\t\t\tinstructions: input.instructions,\n\t\t\t\t...(input.profileId ? { profileId: input.profileId } : {}),\n\t\t\t};\n\t\t\tif (deps.startWorkerDelegation) {\n\t\t\t\tconst started = deps.startWorkerDelegation(request);\n\t\t\t\tif (!started.started) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `delegate skipped: ${started.skipReason}` }],\n\t\t\t\t\t\tdetails: { started: false, skipReason: started.skipReason, profileId: input.profileId },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `delegate started (${started.record.status}) — wait for its terminal handoff, then retrieve once with delegate_status`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tstarted: true,\n\t\t\t\t\t\tprofileId: started.record.profileId ?? input.profileId,\n\t\t\t\t\t\tlaneId: started.record.laneId,\n\t\t\t\t\t\tlabel: started.record.label,\n\t\t\t\t\t\tstatus: started.record.status,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst run = await deps.runWorkerDelegation(request);\n\t\t\tif (!run.started) {\n\t\t\t\tconst reason = run.skipReason ?? \"unknown\";\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `delegate skipped: ${reason}` }],\n\t\t\t\t\tdetails: { started: false, skipReason: reason, profileId: input.profileId },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst outcome = run.outcome;\n\t\t\tconst lines: string[] = [\n\t\t\t\t`delegate ${run.record?.status ?? \"unknown\"}${run.record?.reasonCode ? ` (${run.record.reasonCode})` : \"\"}`,\n\t\t\t];\n\t\t\tif (outcome) {\n\t\t\t\tlines.push(\n\t\t\t\t\t`accepted: ${outcome.accepted} [${outcome.acceptance.outcome}/${outcome.acceptance.reasonCode}]`,\n\t\t\t\t\t\"Worker output (UNTRUSTED - verify before acting on it):\",\n\t\t\t\t\toutcome.claim.summary,\n\t\t\t\t);\n\t\t\t\tif (outcome.claim.blockers && outcome.claim.blockers.length > 0) {\n\t\t\t\t\tlines.push(`Blockers: ${outcome.claim.blockers.join(\"; \")}`);\n\t\t\t\t}\n\t\t\t\tfor (const finding of outcome.claim.evidence?.findings ?? []) {\n\t\t\t\t\tlines.push(`- Finding: ${finding.summary}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: {\n\t\t\t\t\tstarted: true,\n\t\t\t\t\tprofileId: run.record?.profileId ?? input.profileId,\n\t\t\t\t\tlaneId: run.record?.laneId,\n\t\t\t\t\tlabel: run.record?.label,\n\t\t\t\t\tstatus: run.record?.status,\n\t\t\t\t\treasonCode: run.record?.reasonCode,\n\t\t\t\t\taccepted: outcome?.accepted,\n\t\t\t\t\tcostUsd: outcome?.costUsd,\n\t\t\t\t\tsummary: outcome?.claim.summary.slice(0, 8_000),\n\t\t\t\t\tblockers: outcome?.claim.blockers?.slice(0, 16),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensionify.d.ts","sourceRoot":"","sources":["../../../src/core/tools/extensionify.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,QAAA,MAAM,kBAAkB;;;;EAItB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAElE,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE;QACX,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACF;AAED,MAAM,WAAW,uBAAuB;IACvC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,gCAAgC,CAC/C,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,uBAAuB,GAC/B,cAAc,CAAC,OAAO,kBAAkB,EAAE,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"extensionify.d.ts","sourceRoot":"","sources":["../../../src/core/tools/extensionify.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,QAAA,MAAM,kBAAkB;;;;EAItB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAElE,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE;QACX,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACF;AAED,MAAM,WAAW,uBAAuB;IACvC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,gCAAgC,CAC/C,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,uBAAuB,GAC/B,cAAc,CAAC,OAAO,kBAAkB,EAAE,kBAAkB,CAAC,CA6J/D;AAED,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,uBAAuB,GAC/B,SAAS,CAAC,OAAO,kBAAkB,CAAC,CAEtC","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { getAgentDir } from \"../../config.ts\";\nimport { acquireWorkRun, type WorkRunLease } from \"../../utils/work-directory.ts\";\nimport { createEventBus } from \"../event-bus.ts\";\nimport { createExtensionRuntime, loadExtension } from \"../extensions/loader.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst extensionifySchema = Type.Object({\n\tname: Type.String({ description: \"Extension name (lowercase, a-z 0-9 hyphens only)\" }),\n\tcode: Type.String({ description: \"Extension factory code (TypeScript/JavaScript)\" }),\n\tpackageJson: Type.Optional(Type.String({ description: \"Optional package.json content as JSON string\" })),\n});\n\nexport type ExtensionifyInput = Static<typeof extensionifySchema>;\n\nexport interface ExtensionifyReport {\n\tok: boolean;\n\tsmokeTestPassed: boolean;\n\tdiagnostics: string[];\n\tregistered: {\n\t\ttools: string[];\n\t\tcommands: string[];\n\t};\n\tproposedPath: string;\n\tdraft: {\n\t\tname: string;\n\t\tcode: string;\n\t\tpackageJson?: string;\n\t};\n}\n\nexport interface ExtensionifyToolDetails {\n\treport?: ExtensionifyReport;\n}\n\nexport interface ExtensionifyToolOptions {\n\tagentDir?: string;\n}\n\nexport function createExtensionifyToolDefinition(\n\t_cwd: string,\n\toptions?: ExtensionifyToolOptions,\n): ToolDefinition<typeof extensionifySchema, ExtensionifyReport> {\n\treturn {\n\t\tname: \"extensionify\",\n\t\tlabel: \"extensionify\",\n\t\tdescription:\n\t\t\t\"Smoke-test a draft extension in an isolated throwaway runtime. Pure analysis tool: creates temporary scaffold, loads it, inspects registrations, then completely deletes temp dir. Does NOT write to the real extensions dir or modify the live runtime. Returns proposal with registration details.\",\n\t\tpromptSnippet: \"Smoke-test a draft extension\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use extensionify to validate draft extensions before creating them.\",\n\t\t\t\"Fix any factory errors or registration issues; review tools and commands registered.\",\n\t\t\t\"The tool runs in complete isolation; the live session is never touched.\",\n\t\t\t\"Persistent write and activation happen later via a separate step.\",\n\t\t],\n\t\tparameters: extensionifySchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ name, code, packageJson }: ExtensionifyInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: ExtensionifyReport;\n\t\t}> {\n\t\t\tconst diagnostics: string[] = [];\n\t\t\tlet smokeTestPassed = false;\n\t\t\tconst registeredTools: string[] = [];\n\t\t\tconst registeredCommands: string[] = [];\n\t\t\tconst agentDir = options?.agentDir ?? getAgentDir();\n\t\t\tconst proposedPath = join(agentDir, \"extensions\", name);\n\n\t\t\tlet tempDir: string | null = null;\n\t\t\tlet workRun: WorkRunLease | undefined;\n\t\t\ttry {\n\t\t\t\tworkRun = acquireWorkRun({ agentDir, category: \"extensions\", tenant: \"smoke-test\" });\n\t\t\t\ttempDir = workRun.path;\n\n\t\t\t\t// Write index.ts with the factory code\n\t\t\t\tconst indexPath = join(tempDir, \"index.ts\");\n\t\t\t\twriteFileSync(indexPath, code, \"utf-8\");\n\n\t\t\t\t// Write package.json if provided\n\t\t\t\tif (packageJson) {\n\t\t\t\t\tconst packageJsonPath = join(tempDir, \"package.json\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Validate it's valid JSON\n\t\t\t\t\t\tJSON.parse(packageJson);\n\t\t\t\t\t\twriteFileSync(packageJsonPath, packageJson, \"utf-8\");\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tdiagnostics.push(`Invalid package.json: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Create isolated runtime and event bus\n\t\t\t\tconst eventBus = createEventBus();\n\t\t\t\tconst runtime = createExtensionRuntime();\n\n\t\t\t\t// Load the extension in isolation\n\t\t\t\tconst { extension, error: loadError } = await loadExtension(indexPath, tempDir, eventBus, runtime, {\n\t\t\t\t\tfresh: true,\n\t\t\t\t\tagentDir,\n\t\t\t\t});\n\n\t\t\t\tif (loadError) {\n\t\t\t\t\tdiagnostics.push(`Factory error: ${loadError}`);\n\t\t\t\t\tsmokeTestPassed = false;\n\t\t\t\t} else if (extension) {\n\t\t\t\t\tsmokeTestPassed = true;\n\n\t\t\t\t\t// Inspect registered tools\n\t\t\t\t\tfor (const [toolName] of extension.tools) {\n\t\t\t\t\t\tregisteredTools.push(toolName);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Inspect registered commands\n\t\t\t\t\tfor (const [cmdName] of extension.commands) {\n\t\t\t\t\t\tregisteredCommands.push(cmdName);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (registeredTools.length === 0 && registeredCommands.length === 0) {\n\t\t\t\t\t\tdiagnostics.push(\"Extension loaded but registered no tools or commands\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tdiagnostics.push(`Test error: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t\tsmokeTestPassed = false;\n\t\t\t} finally {\n\t\t\t\t// Always clean up the temporary directory.\n\t\t\t\tworkRun?.release();\n\t\t\t\tif (tempDir) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\trmSync(tempDir, { recursive: true, force: true });\n\t\t\t\t\t} catch (cleanupErr) {\n\t\t\t\t\t\tdiagnostics.push(\n\t\t\t\t\t\t\t`Cleanup warning: ${cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ok = smokeTestPassed && diagnostics.length === 0;\n\n\t\t\tconst report: ExtensionifyReport = {\n\t\t\t\tok,\n\t\t\t\tsmokeTestPassed,\n\t\t\t\tdiagnostics,\n\t\t\t\tregistered: {\n\t\t\t\t\ttools: registeredTools,\n\t\t\t\t\tcommands: registeredCommands,\n\t\t\t\t},\n\t\t\t\tproposedPath,\n\t\t\t\tdraft: { name, code, packageJson },\n\t\t\t};\n\n\t\t\t// Format the report as readable text\n\t\t\tconst lines: string[] = [];\n\t\t\tlines.push(`Extensionify smoke-test: ${smokeTestPassed ? \"✓ passed\" : \"✗ failed\"}`);\n\n\t\t\tif (diagnostics.length > 0) {\n\t\t\t\tlines.push(\"\\nDiagnostics:\");\n\t\t\t\tfor (const diag of diagnostics) {\n\t\t\t\t\tlines.push(`- ${diag}`);\n\t\t\t\t}\n\t\t\t} else if (smokeTestPassed) {\n\t\t\t\tlines.push(\"\\n✓ No errors during factory execution.\");\n\t\t\t}\n\n\t\t\tif (registeredTools.length > 0) {\n\t\t\t\tlines.push(`\\nRegistered tools (${registeredTools.length}):`);\n\t\t\t\tfor (const toolName of registeredTools) {\n\t\t\t\t\tlines.push(`- ${toolName}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (registeredCommands.length > 0) {\n\t\t\t\tlines.push(`\\nRegistered commands (${registeredCommands.length}):`);\n\t\t\t\tfor (const cmdName of registeredCommands) {\n\t\t\t\t\tlines.push(`- ${cmdName}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (registeredTools.length === 0 && registeredCommands.length === 0 && smokeTestPassed) {\n\t\t\t\tlines.push(\"\\n⚠ Extension loaded but registered nothing.\");\n\t\t\t}\n\n\t\t\tif (ok) {\n\t\t\t\tlines.push(\"\\n✓ Extension ready for creation.\");\n\t\t\t}\n\n\t\t\tlines.push(`\\nProposed install path: ${proposedPath}`);\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: report,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport function createExtensionifyTool(\n\tcwd: string,\n\toptions?: ExtensionifyToolOptions,\n): AgentTool<typeof extensionifySchema> {\n\treturn wrapToolDefinition(createExtensionifyToolDefinition(cwd, options));\n}\n"]}
|
|
@@ -57,6 +57,7 @@ export function createExtensionifyToolDefinition(_cwd, options) {
|
|
|
57
57
|
// Load the extension in isolation
|
|
58
58
|
const { extension, error: loadError } = await loadExtension(indexPath, tempDir, eventBus, runtime, {
|
|
59
59
|
fresh: true,
|
|
60
|
+
agentDir,
|
|
60
61
|
});
|
|
61
62
|
if (loadError) {
|
|
62
63
|
diagnostics.push(`Factory error: ${loadError}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensionify.js","sourceRoot":"","sources":["../../../src/core/tools/extensionify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAqB,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IACtF,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;IACpF,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC,CAAC;CACxG,CAAC,CAAC;AA4BH,MAAM,UAAU,gCAAgC,CAC/C,IAAY,EACZ,OAAiC,EAC+B;IAChE,OAAO;QACN,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,cAAc;QACrB,WAAW,EACV,sSAA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ACF;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,sBAAsB,CACrC,GAAW,EACX,OAAiC,EACM;IACvC,OAAO,kBAAkB,CAAC,gCAAgC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAC1E","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { getAgentDir } from \"../../config.ts\";\nimport { acquireWorkRun, type WorkRunLease } from \"../../utils/work-directory.ts\";\nimport { createEventBus } from \"../event-bus.ts\";\nimport { createExtensionRuntime, loadExtension } from \"../extensions/loader.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst extensionifySchema = Type.Object({\n\tname: Type.String({ description: \"Extension name (lowercase, a-z 0-9 hyphens only)\" }),\n\tcode: Type.String({ description: \"Extension factory code (TypeScript/JavaScript)\" }),\n\tpackageJson: Type.Optional(Type.String({ description: \"Optional package.json content as JSON string\" })),\n});\n\nexport type ExtensionifyInput = Static<typeof extensionifySchema>;\n\nexport interface ExtensionifyReport {\n\tok: boolean;\n\tsmokeTestPassed: boolean;\n\tdiagnostics: string[];\n\tregistered: {\n\t\ttools: string[];\n\t\tcommands: string[];\n\t};\n\tproposedPath: string;\n\tdraft: {\n\t\tname: string;\n\t\tcode: string;\n\t\tpackageJson?: string;\n\t};\n}\n\nexport interface ExtensionifyToolDetails {\n\treport?: ExtensionifyReport;\n}\n\nexport interface ExtensionifyToolOptions {\n\tagentDir?: string;\n}\n\nexport function createExtensionifyToolDefinition(\n\t_cwd: string,\n\toptions?: ExtensionifyToolOptions,\n): ToolDefinition<typeof extensionifySchema, ExtensionifyReport> {\n\treturn {\n\t\tname: \"extensionify\",\n\t\tlabel: \"extensionify\",\n\t\tdescription:\n\t\t\t\"Smoke-test a draft extension in an isolated throwaway runtime. Pure analysis tool: creates temporary scaffold, loads it, inspects registrations, then completely deletes temp dir. Does NOT write to the real extensions dir or modify the live runtime. Returns proposal with registration details.\",\n\t\tpromptSnippet: \"Smoke-test a draft extension\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use extensionify to validate draft extensions before creating them.\",\n\t\t\t\"Fix any factory errors or registration issues; review tools and commands registered.\",\n\t\t\t\"The tool runs in complete isolation; the live session is never touched.\",\n\t\t\t\"Persistent write and activation happen later via a separate step.\",\n\t\t],\n\t\tparameters: extensionifySchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ name, code, packageJson }: ExtensionifyInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: ExtensionifyReport;\n\t\t}> {\n\t\t\tconst diagnostics: string[] = [];\n\t\t\tlet smokeTestPassed = false;\n\t\t\tconst registeredTools: string[] = [];\n\t\t\tconst registeredCommands: string[] = [];\n\t\t\tconst agentDir = options?.agentDir ?? getAgentDir();\n\t\t\tconst proposedPath = join(agentDir, \"extensions\", name);\n\n\t\t\tlet tempDir: string | null = null;\n\t\t\tlet workRun: WorkRunLease | undefined;\n\t\t\ttry {\n\t\t\t\tworkRun = acquireWorkRun({ agentDir, category: \"extensions\", tenant: \"smoke-test\" });\n\t\t\t\ttempDir = workRun.path;\n\n\t\t\t\t// Write index.ts with the factory code\n\t\t\t\tconst indexPath = join(tempDir, \"index.ts\");\n\t\t\t\twriteFileSync(indexPath, code, \"utf-8\");\n\n\t\t\t\t// Write package.json if provided\n\t\t\t\tif (packageJson) {\n\t\t\t\t\tconst packageJsonPath = join(tempDir, \"package.json\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Validate it's valid JSON\n\t\t\t\t\t\tJSON.parse(packageJson);\n\t\t\t\t\t\twriteFileSync(packageJsonPath, packageJson, \"utf-8\");\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tdiagnostics.push(`Invalid package.json: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Create isolated runtime and event bus\n\t\t\t\tconst eventBus = createEventBus();\n\t\t\t\tconst runtime = createExtensionRuntime();\n\n\t\t\t\t// Load the extension in isolation\n\t\t\t\tconst { extension, error: loadError } = await loadExtension(indexPath, tempDir, eventBus, runtime, {\n\t\t\t\t\tfresh: true,\n\t\t\t\t});\n\n\t\t\t\tif (loadError) {\n\t\t\t\t\tdiagnostics.push(`Factory error: ${loadError}`);\n\t\t\t\t\tsmokeTestPassed = false;\n\t\t\t\t} else if (extension) {\n\t\t\t\t\tsmokeTestPassed = true;\n\n\t\t\t\t\t// Inspect registered tools\n\t\t\t\t\tfor (const [toolName] of extension.tools) {\n\t\t\t\t\t\tregisteredTools.push(toolName);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Inspect registered commands\n\t\t\t\t\tfor (const [cmdName] of extension.commands) {\n\t\t\t\t\t\tregisteredCommands.push(cmdName);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (registeredTools.length === 0 && registeredCommands.length === 0) {\n\t\t\t\t\t\tdiagnostics.push(\"Extension loaded but registered no tools or commands\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tdiagnostics.push(`Test error: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t\tsmokeTestPassed = false;\n\t\t\t} finally {\n\t\t\t\t// Always clean up the temporary directory.\n\t\t\t\tworkRun?.release();\n\t\t\t\tif (tempDir) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\trmSync(tempDir, { recursive: true, force: true });\n\t\t\t\t\t} catch (cleanupErr) {\n\t\t\t\t\t\tdiagnostics.push(\n\t\t\t\t\t\t\t`Cleanup warning: ${cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ok = smokeTestPassed && diagnostics.length === 0;\n\n\t\t\tconst report: ExtensionifyReport = {\n\t\t\t\tok,\n\t\t\t\tsmokeTestPassed,\n\t\t\t\tdiagnostics,\n\t\t\t\tregistered: {\n\t\t\t\t\ttools: registeredTools,\n\t\t\t\t\tcommands: registeredCommands,\n\t\t\t\t},\n\t\t\t\tproposedPath,\n\t\t\t\tdraft: { name, code, packageJson },\n\t\t\t};\n\n\t\t\t// Format the report as readable text\n\t\t\tconst lines: string[] = [];\n\t\t\tlines.push(`Extensionify smoke-test: ${smokeTestPassed ? \"✓ passed\" : \"✗ failed\"}`);\n\n\t\t\tif (diagnostics.length > 0) {\n\t\t\t\tlines.push(\"\\nDiagnostics:\");\n\t\t\t\tfor (const diag of diagnostics) {\n\t\t\t\t\tlines.push(`- ${diag}`);\n\t\t\t\t}\n\t\t\t} else if (smokeTestPassed) {\n\t\t\t\tlines.push(\"\\n✓ No errors during factory execution.\");\n\t\t\t}\n\n\t\t\tif (registeredTools.length > 0) {\n\t\t\t\tlines.push(`\\nRegistered tools (${registeredTools.length}):`);\n\t\t\t\tfor (const toolName of registeredTools) {\n\t\t\t\t\tlines.push(`- ${toolName}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (registeredCommands.length > 0) {\n\t\t\t\tlines.push(`\\nRegistered commands (${registeredCommands.length}):`);\n\t\t\t\tfor (const cmdName of registeredCommands) {\n\t\t\t\t\tlines.push(`- ${cmdName}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (registeredTools.length === 0 && registeredCommands.length === 0 && smokeTestPassed) {\n\t\t\t\tlines.push(\"\\n⚠ Extension loaded but registered nothing.\");\n\t\t\t}\n\n\t\t\tif (ok) {\n\t\t\t\tlines.push(\"\\n✓ Extension ready for creation.\");\n\t\t\t}\n\n\t\t\tlines.push(`\\nProposed install path: ${proposedPath}`);\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: report,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport function createExtensionifyTool(\n\tcwd: string,\n\toptions?: ExtensionifyToolOptions,\n): AgentTool<typeof extensionifySchema> {\n\treturn wrapToolDefinition(createExtensionifyToolDefinition(cwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"extensionify.js","sourceRoot":"","sources":["../../../src/core/tools/extensionify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAqB,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IACtF,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;IACpF,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC,CAAC;CACxG,CAAC,CAAC;AA4BH,MAAM,UAAU,gCAAgC,CAC/C,IAAY,EACZ,OAAiC,EAC+B;IAChE,OAAO;QACN,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,cAAc;QACrB,WAAW,EACV,sSAAsS;QACvS,aAAa,EAAE,8BAA8B;QAC7C,gBAAgB,EAAE;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AU,sBAAsB,CACrC,GAAW,EACX,OAAiC,EACM;IACvC,OAAO,kBAAkB,CAAC,gCAAgC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAC1E","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { getAgentDir } from \"../../config.ts\";\nimport { acquireWorkRun, type WorkRunLease } from \"../../utils/work-directory.ts\";\nimport { createEventBus } from \"../event-bus.ts\";\nimport { createExtensionRuntime, loadExtension } from \"../extensions/loader.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst extensionifySchema = Type.Object({\n\tname: Type.String({ description: \"Extension name (lowercase, a-z 0-9 hyphens only)\" }),\n\tcode: Type.String({ description: \"Extension factory code (TypeScript/JavaScript)\" }),\n\tpackageJson: Type.Optional(Type.String({ description: \"Optional package.json content as JSON string\" })),\n});\n\nexport type ExtensionifyInput = Static<typeof extensionifySchema>;\n\nexport interface ExtensionifyReport {\n\tok: boolean;\n\tsmokeTestPassed: boolean;\n\tdiagnostics: string[];\n\tregistered: {\n\t\ttools: string[];\n\t\tcommands: string[];\n\t};\n\tproposedPath: string;\n\tdraft: {\n\t\tname: string;\n\t\tcode: string;\n\t\tpackageJson?: string;\n\t};\n}\n\nexport interface ExtensionifyToolDetails {\n\treport?: ExtensionifyReport;\n}\n\nexport interface ExtensionifyToolOptions {\n\tagentDir?: string;\n}\n\nexport function createExtensionifyToolDefinition(\n\t_cwd: string,\n\toptions?: ExtensionifyToolOptions,\n): ToolDefinition<typeof extensionifySchema, ExtensionifyReport> {\n\treturn {\n\t\tname: \"extensionify\",\n\t\tlabel: \"extensionify\",\n\t\tdescription:\n\t\t\t\"Smoke-test a draft extension in an isolated throwaway runtime. Pure analysis tool: creates temporary scaffold, loads it, inspects registrations, then completely deletes temp dir. Does NOT write to the real extensions dir or modify the live runtime. Returns proposal with registration details.\",\n\t\tpromptSnippet: \"Smoke-test a draft extension\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use extensionify to validate draft extensions before creating them.\",\n\t\t\t\"Fix any factory errors or registration issues; review tools and commands registered.\",\n\t\t\t\"The tool runs in complete isolation; the live session is never touched.\",\n\t\t\t\"Persistent write and activation happen later via a separate step.\",\n\t\t],\n\t\tparameters: extensionifySchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ name, code, packageJson }: ExtensionifyInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: ExtensionifyReport;\n\t\t}> {\n\t\t\tconst diagnostics: string[] = [];\n\t\t\tlet smokeTestPassed = false;\n\t\t\tconst registeredTools: string[] = [];\n\t\t\tconst registeredCommands: string[] = [];\n\t\t\tconst agentDir = options?.agentDir ?? getAgentDir();\n\t\t\tconst proposedPath = join(agentDir, \"extensions\", name);\n\n\t\t\tlet tempDir: string | null = null;\n\t\t\tlet workRun: WorkRunLease | undefined;\n\t\t\ttry {\n\t\t\t\tworkRun = acquireWorkRun({ agentDir, category: \"extensions\", tenant: \"smoke-test\" });\n\t\t\t\ttempDir = workRun.path;\n\n\t\t\t\t// Write index.ts with the factory code\n\t\t\t\tconst indexPath = join(tempDir, \"index.ts\");\n\t\t\t\twriteFileSync(indexPath, code, \"utf-8\");\n\n\t\t\t\t// Write package.json if provided\n\t\t\t\tif (packageJson) {\n\t\t\t\t\tconst packageJsonPath = join(tempDir, \"package.json\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Validate it's valid JSON\n\t\t\t\t\t\tJSON.parse(packageJson);\n\t\t\t\t\t\twriteFileSync(packageJsonPath, packageJson, \"utf-8\");\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tdiagnostics.push(`Invalid package.json: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Create isolated runtime and event bus\n\t\t\t\tconst eventBus = createEventBus();\n\t\t\t\tconst runtime = createExtensionRuntime();\n\n\t\t\t\t// Load the extension in isolation\n\t\t\t\tconst { extension, error: loadError } = await loadExtension(indexPath, tempDir, eventBus, runtime, {\n\t\t\t\t\tfresh: true,\n\t\t\t\t\tagentDir,\n\t\t\t\t});\n\n\t\t\t\tif (loadError) {\n\t\t\t\t\tdiagnostics.push(`Factory error: ${loadError}`);\n\t\t\t\t\tsmokeTestPassed = false;\n\t\t\t\t} else if (extension) {\n\t\t\t\t\tsmokeTestPassed = true;\n\n\t\t\t\t\t// Inspect registered tools\n\t\t\t\t\tfor (const [toolName] of extension.tools) {\n\t\t\t\t\t\tregisteredTools.push(toolName);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Inspect registered commands\n\t\t\t\t\tfor (const [cmdName] of extension.commands) {\n\t\t\t\t\t\tregisteredCommands.push(cmdName);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (registeredTools.length === 0 && registeredCommands.length === 0) {\n\t\t\t\t\t\tdiagnostics.push(\"Extension loaded but registered no tools or commands\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tdiagnostics.push(`Test error: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t\tsmokeTestPassed = false;\n\t\t\t} finally {\n\t\t\t\t// Always clean up the temporary directory.\n\t\t\t\tworkRun?.release();\n\t\t\t\tif (tempDir) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\trmSync(tempDir, { recursive: true, force: true });\n\t\t\t\t\t} catch (cleanupErr) {\n\t\t\t\t\t\tdiagnostics.push(\n\t\t\t\t\t\t\t`Cleanup warning: ${cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ok = smokeTestPassed && diagnostics.length === 0;\n\n\t\t\tconst report: ExtensionifyReport = {\n\t\t\t\tok,\n\t\t\t\tsmokeTestPassed,\n\t\t\t\tdiagnostics,\n\t\t\t\tregistered: {\n\t\t\t\t\ttools: registeredTools,\n\t\t\t\t\tcommands: registeredCommands,\n\t\t\t\t},\n\t\t\t\tproposedPath,\n\t\t\t\tdraft: { name, code, packageJson },\n\t\t\t};\n\n\t\t\t// Format the report as readable text\n\t\t\tconst lines: string[] = [];\n\t\t\tlines.push(`Extensionify smoke-test: ${smokeTestPassed ? \"✓ passed\" : \"✗ failed\"}`);\n\n\t\t\tif (diagnostics.length > 0) {\n\t\t\t\tlines.push(\"\\nDiagnostics:\");\n\t\t\t\tfor (const diag of diagnostics) {\n\t\t\t\t\tlines.push(`- ${diag}`);\n\t\t\t\t}\n\t\t\t} else if (smokeTestPassed) {\n\t\t\t\tlines.push(\"\\n✓ No errors during factory execution.\");\n\t\t\t}\n\n\t\t\tif (registeredTools.length > 0) {\n\t\t\t\tlines.push(`\\nRegistered tools (${registeredTools.length}):`);\n\t\t\t\tfor (const toolName of registeredTools) {\n\t\t\t\t\tlines.push(`- ${toolName}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (registeredCommands.length > 0) {\n\t\t\t\tlines.push(`\\nRegistered commands (${registeredCommands.length}):`);\n\t\t\t\tfor (const cmdName of registeredCommands) {\n\t\t\t\t\tlines.push(`- ${cmdName}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (registeredTools.length === 0 && registeredCommands.length === 0 && smokeTestPassed) {\n\t\t\t\tlines.push(\"\\n⚠ Extension loaded but registered nothing.\");\n\t\t\t}\n\n\t\t\tif (ok) {\n\t\t\t\tlines.push(\"\\n✓ Extension ready for creation.\");\n\t\t\t}\n\n\t\t\tlines.push(`\\nProposed install path: ${proposedPath}`);\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: lines.join(\"\\n\") }],\n\t\t\t\tdetails: report,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport function createExtensionifyTool(\n\tcwd: string,\n\toptions?: ExtensionifyToolOptions,\n): AgentTool<typeof extensionifySchema> {\n\treturn wrapToolDefinition(createExtensionifyToolDefinition(cwd, options));\n}\n"]}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { type Static, Type } from "typebox";
|
|
2
|
+
import type { WorkerClaim } from "../autonomy/contracts.ts";
|
|
3
|
+
import type { LaneRecord } from "../autonomy/lane-tracker.ts";
|
|
2
4
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
3
5
|
import type { GoalState } from "../goals/goal-state.ts";
|
|
4
|
-
import { type GoalActionName } from "../goals/goal-tool-core.ts";
|
|
6
|
+
import { type GoalActionName, type OpenTaskStepRef } from "../goals/goal-tool-core.ts";
|
|
5
7
|
declare const goalSchema: Type.TObject<{
|
|
6
|
-
action: Type.TUnion<[Type.TLiteral<"start">, Type.TLiteral<"add_requirement">, Type.TLiteral<"satisfy_requirement">, Type.TLiteral<"block_requirement">, Type.TLiteral<"reopen_requirement">, Type.TLiteral<"add_evidence">, Type.TLiteral<"progress">, Type.TLiteral<"no_progress">, Type.TLiteral<"complete">, Type.TLiteral<"block_goal">, Type.TLiteral<"resume_goal">, Type.TLiteral<"cancel">]>;
|
|
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">, Type.TLiteral<"resume_goal">, Type.TLiteral<"cancel">]>;
|
|
7
9
|
goalId: Type.TOptional<Type.TString>;
|
|
8
10
|
userGoal: Type.TOptional<Type.TString>;
|
|
9
11
|
requirementId: Type.TOptional<Type.TString>;
|
|
10
12
|
text: Type.TOptional<Type.TString>;
|
|
13
|
+
instructions: Type.TOptional<Type.TString>;
|
|
11
14
|
evidenceId: Type.TOptional<Type.TString>;
|
|
12
15
|
evidenceIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
13
|
-
kind: Type.TOptional<Type.TUnion<[Type.TLiteral<"file">, Type.TLiteral<"test">, Type.TLiteral<"tool">, Type.TLiteral<"user">, Type.TLiteral<"finding">]>>;
|
|
16
|
+
kind: Type.TOptional<Type.TUnion<[Type.TLiteral<"file">, Type.TLiteral<"test">, Type.TLiteral<"tool">, Type.TLiteral<"user">, Type.TLiteral<"finding">, Type.TLiteral<"worker">]>>;
|
|
14
17
|
summary: Type.TOptional<Type.TString>;
|
|
15
18
|
uri: Type.TOptional<Type.TString>;
|
|
16
19
|
reason: Type.TOptional<Type.TString>;
|
|
20
|
+
dispatchTarget: Type.TOptional<Type.TUnion<[Type.TLiteral<"in_process">, Type.TLiteral<"tmux">]>>;
|
|
17
21
|
}>;
|
|
18
22
|
export type GoalToolInput = Static<typeof goalSchema>;
|
|
19
23
|
export interface GoalToolDetails {
|
|
@@ -21,6 +25,16 @@ export interface GoalToolDetails {
|
|
|
21
25
|
applied: boolean;
|
|
22
26
|
error?: string;
|
|
23
27
|
state?: GoalState;
|
|
28
|
+
/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's
|
|
29
|
+
* new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when
|
|
30
|
+
* `dispatchTarget:"tmux"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */
|
|
31
|
+
dispatchedLaneId?: string;
|
|
32
|
+
/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker
|
|
33
|
+
* delegation disabled, already at capacity, or an honest tmux skip reason -- see
|
|
34
|
+
* {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a
|
|
35
|
+
* re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).
|
|
36
|
+
* The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */
|
|
37
|
+
dispatchSkipReason?: string;
|
|
24
38
|
}
|
|
25
39
|
export interface GoalToolDependencies {
|
|
26
40
|
/** Read the latest persisted goal state for the active session. */
|
|
@@ -29,6 +43,83 @@ export interface GoalToolDependencies {
|
|
|
29
43
|
saveGoalState: (state: GoalState) => void;
|
|
30
44
|
/** Clock injection for deterministic tests. */
|
|
31
45
|
now?: () => string;
|
|
46
|
+
/**
|
|
47
|
+
* Check whether `toolCallId` exists in this session's records, for validating kind:"tool"
|
|
48
|
+
* evidence refs at add_evidence time. When not wired, a "tool" ref cannot be proven and is
|
|
49
|
+
* recorded as `verified: false` rather than assumed true.
|
|
50
|
+
*/
|
|
51
|
+
hasToolCallId?: (toolCallId: string) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Read the session's live worker lane records, for validating kind:"worker" evidence refs
|
|
54
|
+
* (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like
|
|
55
|
+
* `hasToolCallId` -- a "worker" ref cannot be proven and is recorded as `verified: false` rather
|
|
56
|
+
* than assumed true. Live wiring is added separately.
|
|
57
|
+
*/
|
|
58
|
+
getLaneRecords?: () => readonly LaneRecord[];
|
|
59
|
+
/**
|
|
60
|
+
* Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same
|
|
61
|
+
* id as the dispatching lane's laneId), for validating kind:"worker" evidence refs. See
|
|
62
|
+
* {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`
|
|
63
|
+
* verifies `false` -- an unreviewed worker completion must never ungate goal completion through
|
|
64
|
+
* the existing verified/complete gate.
|
|
65
|
+
*/
|
|
66
|
+
getWorkerClaimSnapshots?: () => readonly WorkerClaim[];
|
|
67
|
+
/**
|
|
68
|
+
* Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'
|
|
69
|
+
* (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process
|
|
70
|
+
* worker lane for the given requirement and returns the resulting laneId to bind onto it. When
|
|
71
|
+
* the dependency is present but the underlying delegation starter declines (disabled, already at
|
|
72
|
+
* capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that
|
|
73
|
+
* the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`
|
|
74
|
+
* dep, or the dep returning `undefined`), which records the binding attempt structurally with no
|
|
75
|
+
* laneId (a no-op).
|
|
76
|
+
*/
|
|
77
|
+
startWorkerDelegation?: (args: {
|
|
78
|
+
requirementId: string;
|
|
79
|
+
instructions: string;
|
|
80
|
+
}) => {
|
|
81
|
+
laneId?: string;
|
|
82
|
+
skipReason?: string;
|
|
83
|
+
} | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === "tmux"`:
|
|
86
|
+
* dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`
|
|
87
|
+
* action (core structurally invokes the same tool call the model would make; no extension change,
|
|
88
|
+
* no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when
|
|
89
|
+
* BOTH `input.dispatchTarget === "tmux"` AND this dependency is present; otherwise the EXISTING
|
|
90
|
+
* {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.
|
|
91
|
+
* The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,
|
|
92
|
+
* `no_standing_grant` (the owner has not authorized unattended tmux dispatch),
|
|
93
|
+
* `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,
|
|
94
|
+
* `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was
|
|
95
|
+
* refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),
|
|
96
|
+
* `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,
|
|
97
|
+
* does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see
|
|
98
|
+
* `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check
|
|
99
|
+
* only, refused before any lane/pane side effect -- the dispatched child still refuses
|
|
100
|
+
* authoritatively at its own startup regardless).
|
|
101
|
+
*/
|
|
102
|
+
dispatchTmuxWorker?: (args: {
|
|
103
|
+
requirementId: string;
|
|
104
|
+
instructions: string;
|
|
105
|
+
}) => Promise<{
|
|
106
|
+
laneId?: string;
|
|
107
|
+
skipReason?: string;
|
|
108
|
+
}>;
|
|
109
|
+
/** Working directory for resolving kind:"file" evidence ref paths. Defaults to `process.cwd()`. */
|
|
110
|
+
cwd?: () => string;
|
|
111
|
+
/**
|
|
112
|
+
* Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)
|
|
113
|
+
* when omitted -- the conservative default; set to a function returning `false` to opt out.
|
|
114
|
+
*/
|
|
115
|
+
requireVerifiedEvidenceForCompletion?: () => boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task
|
|
118
|
+
* cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets
|
|
119
|
+
* no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads
|
|
120
|
+
* task state itself; this is the only place that supplies it.
|
|
121
|
+
*/
|
|
122
|
+
getOpenTaskSteps?: () => readonly OpenTaskStepRef[];
|
|
32
123
|
}
|
|
33
124
|
export declare function createGoalToolDefinition(deps: GoalToolDependencies): ToolDefinition;
|
|
34
125
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAoC,KAAK,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAEvH,QAAA,MAAM,UAAU;;;;;;;;;;;;EAkDf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACpC,mEAAmE;IACnE,YAAY,EAAE,MAAM,SAAS,GAAG,SAAS,CAAC;IAC1C,+DAA+D;IAC/D,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1C,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACnB;AAoDD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CAiDnF","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport type { GoalEvidenceKind, GoalState } from \"../goals/goal-state.ts\";\nimport { applyGoalAction, type GoalAction, type GoalActionName, summarizeGoalState } from \"../goals/goal-tool-core.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(\"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: \"Requirement id for add_requirement/satisfy_requirement/block_requirement/reopen_requirement.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\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],\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(Type.String({ description: \"Optional evidence locator (path/URL).\" })),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\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}\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}\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 \"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\"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; 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\tconst current = deps.getGoalState();\n\t\t\tconst result = applyGoalAction(current, mapped, now());\n\t\t\tif (!result.ok) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tdeps.saveGoalState(result.state);\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{ type: \"text\" as const, text: `goal ${input.action} recorded.\\n${summarizeGoalState(result.state)}` },\n\t\t\t\t],\n\t\t\t\tdetails: { action: input.action, applied: true, state: result.state },\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,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,4BAA4B,CAAC;AAGpC,QAAA,MAAM,UAAU;;;;;;;;;;;;;;EAiEf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;iHAE6G;IAC7G,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;uGAImG;IACnG,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACpC,mEAAmE;IACnE,YAAY,EAAE,MAAM,SAAS,GAAG,SAAS,CAAC;IAC1C,+DAA+D;IAC/D,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1C,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAChD;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,SAAS,UAAU,EAAE,CAAC;IAC7C;;;;;;OAMG;IACH,uBAAuB,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;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"]}
|