@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,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Execution-plane coordinator for goal continuation, research, managed lanes, worker delegation,
|
|
3
|
+
* and model fitness.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* session-lifetime abort controllers for in-flight research/worker passes. Everything else it needs
|
|
5
|
+
* Coordination state is owned by focused controllers. This coordinator retains one AgentSession
|
|
6
|
+
* composition seam and a shared lane read model. Everything it needs
|
|
8
7
|
* — the session manager, settings, model registry, live model, capability envelope, the goal
|
|
9
8
|
* continuation LOOP, the isolated-completion primitive, spawned-usage accounting, and the telemetry
|
|
10
9
|
* sink — is reached through narrow deps accessors rather than the whole AgentSession.
|
|
@@ -14,438 +13,223 @@
|
|
|
14
13
|
* delegations; goal auto-continue itself only ever asks the session to `continueGoalLoop`, so this
|
|
15
14
|
* controller never touches `prompt()`, the last-assistant-message, retry, or streaming state.
|
|
16
15
|
*/
|
|
17
|
-
import path from "node:path";
|
|
18
|
-
import { createLaneToolSurface } from "./autonomy/lane-tool-surface.js";
|
|
19
16
|
import { LaneTracker } from "./autonomy/lane-tracker.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export function clampLaneMaxUsd(settingsMaxUsd, foregroundMaxEstimatedUsd) {
|
|
33
|
-
return Math.min(settingsMaxUsd, foregroundMaxEstimatedUsd ?? Number.POSITIVE_INFINITY);
|
|
34
|
-
}
|
|
35
|
-
export function getPrivateLaneDeniedPaths(cwd, agentDir) {
|
|
36
|
-
return [
|
|
37
|
-
"auth.json",
|
|
38
|
-
"MEMORY.md",
|
|
39
|
-
"USER.md",
|
|
40
|
-
"settings.json",
|
|
41
|
-
"models.json",
|
|
42
|
-
"trust.json",
|
|
43
|
-
"sessions",
|
|
44
|
-
"state",
|
|
45
|
-
"work",
|
|
46
|
-
]
|
|
47
|
-
.map((entry) => path.join(agentDir, entry))
|
|
48
|
-
.concat(path.join(cwd, ".pi", "settings.json"));
|
|
49
|
-
}
|
|
50
|
-
export function isLocalExecutionModel(model) {
|
|
51
|
-
if (model.provider === "ollama" || model.provider === "transformers" || model.provider === "llama-cpp") {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const hostname = new URL(model.baseUrl).hostname.toLowerCase();
|
|
56
|
-
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
17
|
+
import { appendLaneRecordSnapshot, getLatestLaneRecordSnapshots } from "./autonomy/session-lane-record.js";
|
|
18
|
+
import { ManagedLaneController } from "./delegation/managed-lane-controller.js";
|
|
19
|
+
import { WorkerDelegationController, } from "./delegation/worker-delegation-controller.js";
|
|
20
|
+
import { WorkerLifecycle } from "./delegation/worker-lifecycle.js";
|
|
21
|
+
import { WorkerNotificationCoordinator } from "./delegation/worker-notification-coordinator.js";
|
|
22
|
+
import { GoalAutoContinueController } from "./goals/goal-auto-continue-controller.js";
|
|
23
|
+
import { LaneModelResolver } from "./research/lane-model-resolver.js";
|
|
24
|
+
import { ModelFitnessController } from "./research/model-fitness-controller.js";
|
|
25
|
+
import { ResearchLaneController } from "./research/research-lane-controller.js";
|
|
26
|
+
import { getActiveSessionBranchEntries } from "./session-snapshot.js";
|
|
27
|
+
export { isLocalExecutionModel } from "./delegation/worker-delegation-controller.js";
|
|
28
|
+
export { clampLaneMaxUsd } from "./research/lane-model-resolver.js";
|
|
62
29
|
export class BackgroundLaneController {
|
|
63
|
-
/** Pending idle timer that starts bounded goal continuation after the session becomes idle. */
|
|
64
|
-
_goalAutoContinueTimer;
|
|
65
|
-
/** Guards bounded idle autosteer so continuation prompts do not recursively trigger themselves. */
|
|
66
|
-
_isGoalAutoContinuing = false;
|
|
67
|
-
/** Pending idle timer that starts an autonomous research pass after the session becomes idle. */
|
|
68
|
-
_researchLaneTimer;
|
|
69
|
-
/** Single-flight guard: at most one research pass runs at a time per session. */
|
|
70
|
-
_isResearchLaneRunning = false;
|
|
71
|
-
/** Why the last idle research-lane evaluation skipped, for /autonomy diagnostics. */
|
|
72
|
-
_lastResearchLaneSkipReason;
|
|
73
30
|
/** Live lane registry — the real source for AutonomyStatusSnapshot.activeLaneCount. */
|
|
74
31
|
_laneTracker = new LaneTracker();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
_workerNotificationTail = Promise.resolve();
|
|
88
|
-
_disposed = false;
|
|
89
|
-
_workersCompletedSinceFlush = 0;
|
|
90
|
-
_workersFailedSinceFlush = 0;
|
|
91
|
-
_workerTerminalSinceFlush = [];
|
|
32
|
+
_laneModels;
|
|
33
|
+
_goalAutoContinue;
|
|
34
|
+
_research;
|
|
35
|
+
_fitness;
|
|
36
|
+
/** Lazily materialized only when managed-lane state is queried or reported. */
|
|
37
|
+
_managedLanes;
|
|
38
|
+
/** Lazily materialized so a UAC surface without `delegate` allocates no worker runtime state. */
|
|
39
|
+
_workers;
|
|
40
|
+
/** One durable lifecycle shared by every worker execution adapter. */
|
|
41
|
+
_workerLifecycle;
|
|
42
|
+
/** Shared terminal outbox for managed and in-process workers; lazy under UAC omission. */
|
|
43
|
+
_workerNotifications;
|
|
92
44
|
deps;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
45
|
+
/** Emit a warning without ever throwing — used from disposal-adjacent persistence where a
|
|
46
|
+
* listener failure (or a bare test double missing `emit`) must never block or crash cleanup. */
|
|
47
|
+
_safeWarn(message) {
|
|
48
|
+
try {
|
|
49
|
+
this.deps.emit({ type: "warning", message });
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Dispose must never throw.
|
|
53
|
+
}
|
|
98
54
|
}
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
running,
|
|
117
|
-
completedSinceFlush,
|
|
118
|
-
failedSinceFlush,
|
|
119
|
-
terminalSinceFlush,
|
|
120
|
-
});
|
|
121
|
-
if (terminalSinceFlush.length === 0)
|
|
122
|
-
return;
|
|
123
|
-
const delivery = this._workerNotificationTail.then(async () => {
|
|
124
|
-
if (this._disposed)
|
|
125
|
-
return;
|
|
126
|
-
let timeout;
|
|
127
|
-
try {
|
|
128
|
-
await Promise.race([
|
|
129
|
-
this.deps.notifyWorkerTerminalHandoff(terminalSinceFlush),
|
|
130
|
-
new Promise((_resolve, reject) => {
|
|
131
|
-
timeout = setTimeout(() => reject(new Error(`worker terminal handoff timed out after ${WORKER_HANDOFF_TIMEOUT_MS}ms`)), WORKER_HANDOFF_TIMEOUT_MS);
|
|
132
|
-
timeout.unref();
|
|
133
|
-
}),
|
|
134
|
-
]);
|
|
135
|
-
}
|
|
136
|
-
finally {
|
|
137
|
-
if (timeout)
|
|
138
|
-
clearTimeout(timeout);
|
|
139
|
-
}
|
|
55
|
+
_recordWorkerTerminal(record, durableNotificationId) {
|
|
56
|
+
this._getWorkerNotificationCoordinator().recordTerminal(record, durableNotificationId);
|
|
57
|
+
}
|
|
58
|
+
constructor(deps) {
|
|
59
|
+
this.deps = deps;
|
|
60
|
+
this._laneModels = new LaneModelResolver(deps);
|
|
61
|
+
this._research = new ResearchLaneController(deps, this._laneTracker, this._laneModels);
|
|
62
|
+
this._fitness = new ModelFitnessController(deps, this._laneModels);
|
|
63
|
+
this._goalAutoContinue = new GoalAutoContinueController({
|
|
64
|
+
isDisposed: deps.isDisposed,
|
|
65
|
+
isGoalToolActive: deps.isGoalToolActive,
|
|
66
|
+
getSettingsManager: deps.getSettingsManager,
|
|
67
|
+
getModelCapabilityProfile: deps.getModelCapabilityProfile,
|
|
68
|
+
getGoalRuntimeSnapshot: deps.getGoalRuntimeSnapshot,
|
|
69
|
+
hasInFlightLaneForGoal: (goalId) => this._hasInFlightLaneForGoal(goalId),
|
|
70
|
+
continueGoalLoop: deps.continueGoalLoop,
|
|
71
|
+
emit: deps.emit,
|
|
140
72
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
73
|
+
}
|
|
74
|
+
_getWorkerController() {
|
|
75
|
+
this._workers ??= new WorkerDelegationController(this.deps, this._getWorkerNotificationCoordinator(), this._getWorkerLifecycle());
|
|
76
|
+
return this._workers;
|
|
77
|
+
}
|
|
78
|
+
_getWorkerLifecycle() {
|
|
79
|
+
if (this._workerLifecycle)
|
|
80
|
+
return this._workerLifecycle;
|
|
81
|
+
const lifecycle = new WorkerLifecycle({
|
|
82
|
+
agentDir: this.deps.getAgentDir(),
|
|
83
|
+
sessionId: this.deps.getSessionId(),
|
|
146
84
|
});
|
|
85
|
+
this._workerLifecycle = lifecycle;
|
|
86
|
+
for (const notification of lifecycle.getPendingTerminalNotifications()) {
|
|
87
|
+
this._getWorkerNotificationCoordinator().recordTerminal(notification.record, notification.notificationId);
|
|
88
|
+
}
|
|
89
|
+
return lifecycle;
|
|
147
90
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
91
|
+
_getWorkerNotificationCoordinator() {
|
|
92
|
+
this._workerNotifications ??= new WorkerNotificationCoordinator({
|
|
93
|
+
getWorkerRecords: () => this._workerLifecycle?.getAllRecords() ?? [],
|
|
94
|
+
emitStatus: (status) => {
|
|
95
|
+
try {
|
|
96
|
+
this.deps.emit({
|
|
97
|
+
type: "delegate_workers",
|
|
98
|
+
...status,
|
|
99
|
+
terminalSinceFlush: [...status.terminalSinceFlush],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// A partial integration must not crash the event-driven terminal outbox.
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
notify: (records) => this.deps.notifyWorkerTerminalHandoff(records),
|
|
107
|
+
warn: (message) => this._safeWarn(message),
|
|
108
|
+
markDurableDelivered: (notificationIds) => this._workerLifecycle?.markNotificationsDelivered(notificationIds),
|
|
159
109
|
});
|
|
160
|
-
this.
|
|
110
|
+
return this._workerNotifications;
|
|
161
111
|
}
|
|
162
|
-
|
|
163
|
-
this.deps
|
|
112
|
+
_getManagedLaneController() {
|
|
113
|
+
this._managedLanes ??= new ManagedLaneController(this.deps, this._getWorkerLifecycle(), (record, notificationId) => this._recordWorkerTerminal(record, notificationId));
|
|
114
|
+
return this._managedLanes;
|
|
164
115
|
}
|
|
165
|
-
|
|
166
|
-
if (this.
|
|
116
|
+
_hydrateManagedLanes() {
|
|
117
|
+
if (this._managedLanes) {
|
|
118
|
+
this._managedLanes.ensureHydrated();
|
|
167
119
|
return;
|
|
168
|
-
|
|
169
|
-
this.
|
|
170
|
-
|
|
171
|
-
|
|
120
|
+
}
|
|
121
|
+
const hasPersistedActiveManagedLane = getLatestLaneRecordSnapshots(getActiveSessionBranchEntries(this.deps.getSessionManager())).some((record) => record.type === "tmux-worker" && (record.status === "queued" || record.status === "running"));
|
|
122
|
+
if (hasPersistedActiveManagedLane)
|
|
123
|
+
this._getManagedLaneController().ensureHydrated();
|
|
172
124
|
}
|
|
173
125
|
/** Live lane records tracked by this process (running and terminal). */
|
|
174
126
|
getLaneRecords() {
|
|
175
|
-
|
|
127
|
+
this._hydrateManagedLanes();
|
|
128
|
+
const workerRecords = this._workers?.getRecords() ??
|
|
129
|
+
(this.deps.isDelegateToolActive?.() ? this._getWorkerController().getRecords() : []);
|
|
130
|
+
return [
|
|
131
|
+
...this._laneTracker.getRecords(),
|
|
132
|
+
...workerRecords,
|
|
133
|
+
...(this._workerLifecycle?.getManagedRecords() ?? []),
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
/** Does not materialize the worker controller when UAC omitted delegation. */
|
|
137
|
+
getTaskRuntimeSnapshot() {
|
|
138
|
+
return this._workerLifecycle?.getTaskRuntimeSnapshot();
|
|
139
|
+
}
|
|
140
|
+
/** Reconcile only when delegation has already been materialized; UAC omission stays zero-load. */
|
|
141
|
+
synchronizeGoalState(goal) {
|
|
142
|
+
this._workers?.synchronizeGoalState(goal);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Resolve a tracked managed-lane dispatch. The caller's stable id is also the canonical durable
|
|
146
|
+
* lane id, so this is an existence check rather than an id translation.
|
|
147
|
+
*/
|
|
148
|
+
resolveManagedLaneId(callerLaneId) {
|
|
149
|
+
return this._getManagedLaneController().resolve(callerLaneId);
|
|
176
150
|
}
|
|
177
151
|
/** Live count of active lanes — the real source for AutonomyStatusSnapshot.activeLaneCount. */
|
|
178
152
|
getActiveLaneCount() {
|
|
179
|
-
return this.
|
|
153
|
+
return this.getLaneRecords().filter((record) => record.status === "queued" || record.status === "running").length;
|
|
154
|
+
}
|
|
155
|
+
/** Belt-and-braces guard: whether ANY queued/running lane is tagged with this goalId. */
|
|
156
|
+
_hasInFlightLaneForGoal(goalId) {
|
|
157
|
+
return this.getLaneRecords().some((record) => record.goalId === goalId && (record.status === "queued" || record.status === "running"));
|
|
158
|
+
}
|
|
159
|
+
/** Delegate the out-of-process dispatch/terminal claim to its single lifecycle owner. */
|
|
160
|
+
recordManagedLane(event) {
|
|
161
|
+
return this._getManagedLaneController().record(event);
|
|
180
162
|
}
|
|
181
163
|
/** Why the last idle research-lane evaluation skipped, for /autonomy diagnostics. */
|
|
182
164
|
getLastResearchLaneSkipReason() {
|
|
183
|
-
return this.
|
|
165
|
+
return this._research.getLastSkipReason();
|
|
184
166
|
}
|
|
185
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Abort in-flight research and delegate worker disposal to its single owning controller.
|
|
169
|
+
*
|
|
170
|
+
* This synchronous body is the LAST provably-safe write window for canceled/in-flight work.
|
|
171
|
+
* `dispose()` (agent-session.ts) has already set the session's own disposed flag but has not yet
|
|
172
|
+
* returned — no successor session (e.g. a `/reload` adoption) can exist yet, so an append here
|
|
173
|
+
* cannot interleave with one; a post-await continuation resuming AFTER this method returns must
|
|
174
|
+
* not append (see the disposed branch in `runWorkerDelegationOnce`). Persist FIRST, then
|
|
175
|
+
* complete-in-memory, so a throw from one lane's persist cannot skip another's; each persist gets
|
|
176
|
+
* its own try/catch — dispose must never throw.
|
|
177
|
+
*/
|
|
186
178
|
abortInFlightLanes() {
|
|
187
|
-
this.
|
|
188
|
-
this.
|
|
189
|
-
this.
|
|
190
|
-
this._queuedWorkers.clear();
|
|
179
|
+
this._goalAutoContinue.clearTimer();
|
|
180
|
+
this._research.abort();
|
|
181
|
+
this._fitness.abort();
|
|
191
182
|
for (const record of this._laneTracker.getRecords()) {
|
|
192
|
-
if (record.status
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
183
|
+
if (record.status !== "queued" && record.status !== "running")
|
|
184
|
+
continue;
|
|
185
|
+
if (record.type === "tmux-worker")
|
|
186
|
+
continue;
|
|
187
|
+
const canceled = this._laneTracker.complete(record.laneId, {
|
|
188
|
+
status: "canceled",
|
|
189
|
+
reasonCode: "session_disposed",
|
|
190
|
+
});
|
|
191
|
+
if (!canceled)
|
|
192
|
+
continue;
|
|
193
|
+
try {
|
|
194
|
+
appendLaneRecordSnapshot(this.deps.getSessionManager(), canceled);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
this._safeWarn(`Failed to persist canceled lane record ${canceled.laneId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
|
-
this.
|
|
200
|
-
this.
|
|
200
|
+
this._managedLanes?.release();
|
|
201
|
+
this._workers?.abort();
|
|
202
|
+
this._workerNotifications?.dispose();
|
|
201
203
|
}
|
|
202
204
|
clearGoalAutoContinueTimer() {
|
|
203
|
-
|
|
204
|
-
clearTimeout(this._goalAutoContinueTimer);
|
|
205
|
-
this._goalAutoContinueTimer = undefined;
|
|
206
|
-
}
|
|
205
|
+
this._goalAutoContinue.clearTimer();
|
|
207
206
|
}
|
|
208
207
|
scheduleGoalAutoContinueFromIdle(options) {
|
|
209
|
-
|
|
210
|
-
return;
|
|
211
|
-
// Small-window models cannot afford multi-thousand-token continuation prompts per idle turn.
|
|
212
|
-
if (!this.deps.getModelCapabilityProfile().backgroundLanesEnabled)
|
|
213
|
-
return;
|
|
214
|
-
const { maxStallTurns, goalAutoContinue, goalAutoContinueDelayMs } = this.deps
|
|
215
|
-
.getSettingsManager()
|
|
216
|
-
.getAutonomySettings();
|
|
217
|
-
if (!goalAutoContinue)
|
|
218
|
-
return;
|
|
219
|
-
const snapshot = this.deps.getGoalRuntimeSnapshot({ maxStallTurns });
|
|
220
|
-
if (snapshot.continuation.action !== "continue")
|
|
221
|
-
return;
|
|
222
|
-
this.clearGoalAutoContinueTimer();
|
|
223
|
-
this._goalAutoContinueTimer = setTimeout(() => {
|
|
224
|
-
this._goalAutoContinueTimer = undefined;
|
|
225
|
-
void this._runScheduledGoalAutoContinue();
|
|
226
|
-
}, goalAutoContinueDelayMs);
|
|
227
|
-
const timer = this._goalAutoContinueTimer;
|
|
228
|
-
if (typeof timer === "object" && timer && "unref" in timer) {
|
|
229
|
-
const { unref } = timer;
|
|
230
|
-
unref?.call(timer);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
async _runScheduledGoalAutoContinue() {
|
|
234
|
-
if (this._isGoalAutoContinuing || this.deps.isDisposed())
|
|
235
|
-
return;
|
|
236
|
-
const { maxStallTurns, goalContinueTurns, goalContinueMaxWallClockMinutes, goalAutoContinue } = this.deps
|
|
237
|
-
.getSettingsManager()
|
|
238
|
-
.getAutonomySettings();
|
|
239
|
-
if (!goalAutoContinue)
|
|
240
|
-
return;
|
|
241
|
-
const snapshot = this.deps.getGoalRuntimeSnapshot({ maxStallTurns });
|
|
242
|
-
if (snapshot.continuation.action !== "continue")
|
|
243
|
-
return;
|
|
244
|
-
// Lean-window models (16-32k) keep autosteer but at a reduced budget; full passes through.
|
|
245
|
-
const scaled = scaleContinuationBudgetsForCapability(this.deps.getModelCapabilityProfile(), {
|
|
246
|
-
maxTurns: goalContinueTurns,
|
|
247
|
-
maxWallClockMinutes: goalContinueMaxWallClockMinutes,
|
|
248
|
-
});
|
|
249
|
-
this._isGoalAutoContinuing = true;
|
|
250
|
-
try {
|
|
251
|
-
await this.deps.continueGoalLoop({
|
|
252
|
-
maxTurns: scaled.maxTurns,
|
|
253
|
-
maxStallTurns,
|
|
254
|
-
maxWallClockMinutes: scaled.maxWallClockMinutes,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
catch (error) {
|
|
258
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
259
|
-
this.deps.emit({ type: "warning", message: `Goal auto-continuation failed: ${message}` });
|
|
260
|
-
}
|
|
261
|
-
finally {
|
|
262
|
-
this._isGoalAutoContinuing = false;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
clearResearchLaneTimer() {
|
|
266
|
-
if (this._researchLaneTimer !== undefined) {
|
|
267
|
-
clearTimeout(this._researchLaneTimer);
|
|
268
|
-
this._researchLaneTimer = undefined;
|
|
269
|
-
}
|
|
208
|
+
this._goalAutoContinue.scheduleFromIdle(options);
|
|
270
209
|
}
|
|
271
210
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
211
|
+
* Single-flight entry point for EVERY goal-continuation loop invocation — idle autosteer
|
|
212
|
+
* ({@link _runScheduledGoalAutoContinue}) AND the manual `/goal start` / `/goal-continue`
|
|
213
|
+
* commands (reached through `AgentSession.continueGoalLoop`). Both paths ultimately submit
|
|
214
|
+
* continuation prompts through the session's single `prompt()` path, so two loops racing throws
|
|
215
|
+
* "Agent is already processing" from whichever submits second. `_isGoalAutoContinuing` is the
|
|
216
|
+
* ONE owner of that mutex; `deps.continueGoalLoop` (the raw {@link GoalLoopController} loop)
|
|
217
|
+
* must never be called directly outside this method, or the guard is bypassed.
|
|
275
218
|
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (!goal || goal.status !== "active") {
|
|
279
|
-
this._lastResearchLaneSkipReason = "no_active_goal";
|
|
280
|
-
return undefined;
|
|
281
|
-
}
|
|
282
|
-
const open = goal.requirements.filter((requirement) => requirement.status === "open");
|
|
283
|
-
if (open.length === 0) {
|
|
284
|
-
this._lastResearchLaneSkipReason = "no_open_requirements";
|
|
285
|
-
return undefined;
|
|
286
|
-
}
|
|
287
|
-
const query = `goal:${goal.goalId} requirements:${open
|
|
288
|
-
.map((requirement) => requirement.id)
|
|
289
|
-
.sort()
|
|
290
|
-
.join(",")}`;
|
|
291
|
-
if (this.deps.getEvidenceBundleSnapshot()?.query === query) {
|
|
292
|
-
this._lastResearchLaneSkipReason = "recent_evidence_sufficient";
|
|
293
|
-
return undefined;
|
|
294
|
-
}
|
|
295
|
-
const context = [
|
|
296
|
-
`Goal: ${goal.userGoal}`,
|
|
297
|
-
"Open requirements:",
|
|
298
|
-
...open.slice(0, 20).map((requirement) => `- ${requirement.text}`),
|
|
299
|
-
].join("\n");
|
|
300
|
-
return { query, context, goalId: goal.goalId };
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Idle trigger for the autonomous research lane (mirrors {@link scheduleGoalAutoContinueFromIdle}).
|
|
304
|
-
* All skips are recorded in `_lastResearchLaneSkipReason` and surfaced via diagnostics — the lane
|
|
305
|
-
* informs, it never prompts or blocks the foreground.
|
|
306
|
-
*/
|
|
307
|
-
scheduleResearchLaneFromIdle() {
|
|
308
|
-
if (this._isResearchLaneRunning || this.deps.isDisposed() || this.deps.isChildSession())
|
|
309
|
-
return;
|
|
310
|
-
const research = this.deps.getSettingsManager().getResearchLaneSettings();
|
|
311
|
-
if (!research.enabled) {
|
|
312
|
-
this._lastResearchLaneSkipReason = "research_lane_disabled";
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const { mode } = this.deps.getSettingsManager().getAutonomySettings();
|
|
316
|
-
if (mode === "off") {
|
|
317
|
-
this._lastResearchLaneSkipReason = "autonomy_mode_off";
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
this._seedLaneHistory();
|
|
321
|
-
if (this._persistedResearchRunCount >= research.maxRunsPerSession) {
|
|
322
|
-
this._lastResearchLaneSkipReason = "max_runs_reached";
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
if (!this._buildResearchLaneDemand())
|
|
326
|
-
return;
|
|
327
|
-
const shipment = this._resolveLaneShipment(research, "no_research_model");
|
|
328
|
-
if (!shipment.ok) {
|
|
329
|
-
this._lastResearchLaneSkipReason = shipment.skipReason;
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
if (!this._laneCapabilityProfile(shipment.model).backgroundLanesEnabled) {
|
|
333
|
-
this._lastResearchLaneSkipReason = "model_research_unsupported";
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
this.clearResearchLaneTimer();
|
|
337
|
-
this._researchLaneTimer = setTimeout(() => {
|
|
338
|
-
this._researchLaneTimer = undefined;
|
|
339
|
-
void this._runScheduledResearchLane();
|
|
340
|
-
}, research.idleDelayMs);
|
|
341
|
-
const timer = this._researchLaneTimer;
|
|
342
|
-
if (typeof timer === "object" && timer && "unref" in timer) {
|
|
343
|
-
const { unref } = timer;
|
|
344
|
-
unref?.call(timer);
|
|
345
|
-
}
|
|
219
|
+
async continueGoalLoopExclusive(options) {
|
|
220
|
+
return this._goalAutoContinue.continueExclusive(options);
|
|
346
221
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return;
|
|
350
|
-
const research = this.deps.getSettingsManager().getResearchLaneSettings();
|
|
351
|
-
const { mode } = this.deps.getSettingsManager().getAutonomySettings();
|
|
352
|
-
if (!research.enabled || mode === "off")
|
|
353
|
-
return;
|
|
354
|
-
try {
|
|
355
|
-
await this.runResearchLaneOnce();
|
|
356
|
-
}
|
|
357
|
-
catch (error) {
|
|
358
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
359
|
-
this.deps.emit({ type: "warning", message: `Research lane failed: ${message}` });
|
|
360
|
-
}
|
|
222
|
+
clearResearchLaneTimer() {
|
|
223
|
+
this._research.clearTimer();
|
|
361
224
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return deriveModelCapabilityProfile({
|
|
365
|
-
contextWindow: model.contextWindow,
|
|
366
|
-
mode: this.deps.getSettingsManager().getModelCapabilitySettings().mode,
|
|
367
|
-
});
|
|
225
|
+
scheduleResearchLaneFromIdle() {
|
|
226
|
+
this._research.scheduleFromIdle();
|
|
368
227
|
}
|
|
369
|
-
/**
|
|
370
|
-
* Resolve the model for a background lane. Lanes are shipped BY this session, so they inherit
|
|
371
|
-
* the session's own model unless a lane-specific model is explicitly configured — a single-model
|
|
372
|
-
* setup (e.g. one local open model) runs its lanes on that same model. An explicitly configured
|
|
373
|
-
* pattern that cannot resolve/authenticate is a visible skip, not a silent fallback.
|
|
374
|
-
*/
|
|
375
228
|
resolveLaneModel(configuredPattern) {
|
|
376
|
-
|
|
377
|
-
const resolved = resolveCliModel({ cliModel: configuredPattern, modelRegistry: this.deps.getModelRegistry() });
|
|
378
|
-
if (resolved.model && this.deps.getModelRegistry().hasConfiguredAuth(resolved.model)) {
|
|
379
|
-
return resolved.model;
|
|
380
|
-
}
|
|
381
|
-
return undefined;
|
|
382
|
-
}
|
|
383
|
-
return this.deps.getModel() ?? undefined;
|
|
229
|
+
return this._laneModels.resolveModel(configuredPattern);
|
|
384
230
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
* profile's model (a shipped profile with a model MUST be obeyed — unresolvable is a visible
|
|
388
|
-
* skip, never a fallback), then generic inheritance of the session model.
|
|
389
|
-
*/
|
|
390
|
-
_resolveLaneShipment(laneSettings, missingModelReason) {
|
|
391
|
-
let laneProfile;
|
|
392
|
-
if (laneSettings.profile) {
|
|
393
|
-
const profileRef = laneSettings.profile.trim();
|
|
394
|
-
const registry = this.deps.getSettingsManager().getProfileRegistry();
|
|
395
|
-
laneProfile =
|
|
396
|
-
profileRef.startsWith("./") || profileRef.startsWith("../")
|
|
397
|
-
? registry.resolveProfileRef(profileRef, this.deps.getCwd())
|
|
398
|
-
: registry.getProfile(profileRef);
|
|
399
|
-
if (!laneProfile) {
|
|
400
|
-
return { ok: false, skipReason: "lane_profile_not_found" };
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
let model;
|
|
404
|
-
if (laneSettings.model) {
|
|
405
|
-
model = this.resolveLaneModel(laneSettings.model);
|
|
406
|
-
if (!model)
|
|
407
|
-
return { ok: false, skipReason: missingModelReason };
|
|
408
|
-
}
|
|
409
|
-
else if (laneProfile?.model) {
|
|
410
|
-
model = this.resolveLaneModel(laneProfile.model);
|
|
411
|
-
if (!model)
|
|
412
|
-
return { ok: false, skipReason: "no_lane_profile_model" };
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
model = this.deps.getModel() ?? undefined;
|
|
416
|
-
if (!model)
|
|
417
|
-
return { ok: false, skipReason: missingModelReason };
|
|
418
|
-
}
|
|
419
|
-
if (this.deps.isModelExhausted(model)) {
|
|
420
|
-
return { ok: false, skipReason: `${model.provider}/${model.id} model exhausted: quota` };
|
|
421
|
-
}
|
|
422
|
-
return { ok: true, model, laneProfile };
|
|
423
|
-
}
|
|
424
|
-
_warnUnboundLaneToolGrants(laneProfile, surface) {
|
|
425
|
-
if (!laneProfile || surface.unboundAllowPatterns.length === 0)
|
|
426
|
-
return;
|
|
427
|
-
const warningKey = `${laneProfile.name}\0${[...surface.unboundAllowPatterns].sort().join("\0")}`;
|
|
428
|
-
if (this._warnedUnboundLaneToolGrants.has(warningKey))
|
|
429
|
-
return;
|
|
430
|
-
this._warnedUnboundLaneToolGrants.add(warningKey);
|
|
431
|
-
this.deps.emit({
|
|
432
|
-
type: "warning",
|
|
433
|
-
message: `Lane profile '${laneProfile.name}' grants unavailable isolated-lane tools: ${surface.unboundAllowPatterns.join(", ")}. Only classified lane tools can execute.`,
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
/** Stripped research envelope — never the foreground/architect envelope. */
|
|
437
|
-
_buildResearchLaneEnvelope(maxUsd, laneProfile, surface) {
|
|
438
|
-
return {
|
|
439
|
-
id: `research-${this.deps.getSessionId()}-${Date.now()}`,
|
|
440
|
-
profileId: laneProfile?.name,
|
|
441
|
-
capabilities: ["research", "read_files", "memory_read"],
|
|
442
|
-
allowedTools: [...surface.allowedTools],
|
|
443
|
-
deniedTools: [...surface.deniedTools],
|
|
444
|
-
allowedPaths: [this.deps.getCwd()],
|
|
445
|
-
deniedPaths: getPrivateLaneDeniedPaths(this.deps.getCwd(), this.deps.getAgentDir()),
|
|
446
|
-
maxEstimatedUsd: clampLaneMaxUsd(maxUsd, this.deps.getCapabilityEnvelope()?.maxEstimatedUsd),
|
|
447
|
-
createdAt: new Date().toISOString(),
|
|
448
|
-
};
|
|
231
|
+
getOrchestrationProfileCatalog() {
|
|
232
|
+
return this._getWorkerController().getProfileCatalog();
|
|
449
233
|
}
|
|
450
234
|
/**
|
|
451
235
|
* Run one bounded, read-only research pass and persist its results: evidence bundle snapshot,
|
|
@@ -454,468 +238,15 @@ export class BackgroundLaneController {
|
|
|
454
238
|
* enabled/mode/dedupe gates the idle scheduler enforces; budget and capability gates always apply.
|
|
455
239
|
*/
|
|
456
240
|
async runResearchLaneOnce(request) {
|
|
457
|
-
|
|
458
|
-
return { started: false, skipReason: "research_lane_already_running" };
|
|
459
|
-
}
|
|
460
|
-
if (this.deps.isDisposed()) {
|
|
461
|
-
return { started: false, skipReason: "session_disposed" };
|
|
462
|
-
}
|
|
463
|
-
const settings = this.deps.getSettingsManager().getResearchLaneSettings();
|
|
464
|
-
const demand = request?.query
|
|
465
|
-
? { query: request.query, context: request.context ?? "", goalId: request.goalId }
|
|
466
|
-
: this._buildResearchLaneDemand();
|
|
467
|
-
if (!demand) {
|
|
468
|
-
return { started: false, skipReason: this._lastResearchLaneSkipReason ?? "no_research_demand" };
|
|
469
|
-
}
|
|
470
|
-
const shipment = this._resolveLaneShipment(settings, "no_research_model");
|
|
471
|
-
if (!shipment.ok) {
|
|
472
|
-
this._lastResearchLaneSkipReason = shipment.skipReason;
|
|
473
|
-
return { started: false, skipReason: shipment.skipReason };
|
|
474
|
-
}
|
|
475
|
-
const { model, laneProfile } = shipment;
|
|
476
|
-
const laneCapability = this._laneCapabilityProfile(model);
|
|
477
|
-
if (!laneCapability.backgroundLanesEnabled) {
|
|
478
|
-
this._lastResearchLaneSkipReason = "model_research_unsupported";
|
|
479
|
-
return { started: false, skipReason: "model_research_unsupported" };
|
|
480
|
-
}
|
|
481
|
-
this._isResearchLaneRunning = true;
|
|
482
|
-
this._seedLaneHistory();
|
|
483
|
-
const startedRecord = this._laneTracker.start({ type: "research", goalId: demand.goalId });
|
|
484
|
-
this._persistedResearchRunCount++;
|
|
485
|
-
try {
|
|
486
|
-
let spentUsage;
|
|
487
|
-
// Best-effort, pointer-first workspace evidence. Derives search terms from the goal/requirement
|
|
488
|
-
// text (not the identity-key query) and is bounded + silent-on-failure: [] == today's behavior.
|
|
489
|
-
const workspaceSources = await this.deps.collectWorkspaceSources({
|
|
490
|
-
query: `${demand.context}\n${demand.query}`,
|
|
491
|
-
cwd: this.deps.getCwd(),
|
|
492
|
-
maxSources: settings.maxSources,
|
|
493
|
-
});
|
|
494
|
-
const maxUsd = clampLaneMaxUsd(settings.maxUsd, this.deps.getCapabilityEnvelope()?.maxEstimatedUsd);
|
|
495
|
-
const toolSurface = createLaneToolSurface({
|
|
496
|
-
cwd: this.deps.getCwd(),
|
|
497
|
-
profile: laneProfile,
|
|
498
|
-
deniedPaths: getPrivateLaneDeniedPaths(this.deps.getCwd(), this.deps.getAgentDir()),
|
|
499
|
-
});
|
|
500
|
-
this._warnUnboundLaneToolGrants(laneProfile, toolSurface);
|
|
501
|
-
const result = await runResearch({
|
|
502
|
-
query: demand.query,
|
|
503
|
-
context: demand.context,
|
|
504
|
-
sources: workspaceSources,
|
|
505
|
-
envelope: this._buildResearchLaneEnvelope(maxUsd, laneProfile, toolSurface),
|
|
506
|
-
maxUsd,
|
|
507
|
-
maxSources: settings.maxSources,
|
|
508
|
-
maxFindings: settings.maxFindings,
|
|
509
|
-
maxWallClockMs: settings.maxWallClockMs,
|
|
510
|
-
signal: this._researchLaneAbort.signal,
|
|
511
|
-
complete: async ({ systemPrompt, userPrompt, signal }) => {
|
|
512
|
-
const completion = await this.deps.runIsolatedCompletion({
|
|
513
|
-
// Level-0 core always survives; profile soul and role prompt are the replaceable
|
|
514
|
-
// layers; a settings-provided prompt replaces everything above the core.
|
|
515
|
-
systemPrompt: composeSubagentSystemPrompt({
|
|
516
|
-
soul: laneProfile?.soul,
|
|
517
|
-
rolePrompt: systemPrompt,
|
|
518
|
-
override: settings.systemPrompt,
|
|
519
|
-
}),
|
|
520
|
-
messages: [{ role: "user", content: [{ type: "text", text: userPrompt }], timestamp: Date.now() }],
|
|
521
|
-
model,
|
|
522
|
-
thinkingLevel: laneProfile?.thinking ?? "off",
|
|
523
|
-
maxTokens: laneCapability.laneMaxOutputTokens,
|
|
524
|
-
tools: toolSurface.tools,
|
|
525
|
-
maxTurns: 6,
|
|
526
|
-
beforeToolCall: toolSurface.beforeToolCall,
|
|
527
|
-
signal,
|
|
528
|
-
// Core/soul/role are all static per configuration — the provider can cache the prefix.
|
|
529
|
-
cacheRetention: "short",
|
|
530
|
-
});
|
|
531
|
-
spentUsage = completion.usage;
|
|
532
|
-
return {
|
|
533
|
-
text: completion.text,
|
|
534
|
-
costUsd: completion.usage.cost.total,
|
|
535
|
-
stopReason: String(completion.stopReason),
|
|
536
|
-
};
|
|
537
|
-
},
|
|
538
|
-
});
|
|
539
|
-
// Bug #21 pattern: if the session was disposed while the completion was in flight, do NOT
|
|
540
|
-
// persist evidence/records/usage against the dead session.
|
|
541
|
-
if (this.deps.isDisposed()) {
|
|
542
|
-
const record = this._laneTracker.complete(startedRecord.laneId, {
|
|
543
|
-
status: "canceled",
|
|
544
|
-
reasonCode: "session_disposed",
|
|
545
|
-
});
|
|
546
|
-
return { started: true, record, result };
|
|
547
|
-
}
|
|
548
|
-
let evidenceEntryId;
|
|
549
|
-
if (result.bundle) {
|
|
550
|
-
evidenceEntryId = this.deps.saveEvidenceBundleSnapshot(result.bundle);
|
|
551
|
-
}
|
|
552
|
-
if (spentUsage && (spentUsage.cost.total > 0 || spentUsage.totalTokens > 0)) {
|
|
553
|
-
this.deps.addSpawnedUsage(spentUsage, {
|
|
554
|
-
label: "research-lane",
|
|
555
|
-
reportId: `research:${this.deps.getSessionId()}:${startedRecord.laneId}`,
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
const record = this._laneTracker.complete(startedRecord.laneId, {
|
|
559
|
-
status: result.status,
|
|
560
|
-
reasonCode: result.reasonCode,
|
|
561
|
-
costUsd: result.costUsd,
|
|
562
|
-
evidenceEntryId,
|
|
563
|
-
});
|
|
564
|
-
if (record) {
|
|
565
|
-
appendLaneRecordSnapshot(this.deps.getSessionManager(), record);
|
|
566
|
-
// G3: a research lane's product is an evidence bundle, so its terminal record maps to
|
|
567
|
-
// the evidence_bundle event. Lane outcome only (status/reasonCode/cost) — no findings text.
|
|
568
|
-
this.deps.emitAutonomyTelemetry({
|
|
569
|
-
type: AUTONOMY_TELEMETRY_EVENT_TYPES.evidenceBundle,
|
|
570
|
-
timestamp: new Date().toISOString(),
|
|
571
|
-
payload: {
|
|
572
|
-
laneId: record.laneId,
|
|
573
|
-
laneType: record.type,
|
|
574
|
-
status: record.status,
|
|
575
|
-
reasonCode: record.reasonCode ?? null,
|
|
576
|
-
costUsd: record.costUsd ?? null,
|
|
577
|
-
hasEvidence: record.evidenceEntryId !== undefined,
|
|
578
|
-
},
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
return { started: true, record, result };
|
|
582
|
-
}
|
|
583
|
-
catch (error) {
|
|
584
|
-
const record = this._laneTracker.complete(startedRecord.laneId, {
|
|
585
|
-
status: "failed",
|
|
586
|
-
reasonCode: "research_lane_error",
|
|
587
|
-
});
|
|
588
|
-
if (record && !this.deps.isDisposed()) {
|
|
589
|
-
appendLaneRecordSnapshot(this.deps.getSessionManager(), record);
|
|
590
|
-
this.deps.emitAutonomyTelemetry({
|
|
591
|
-
type: AUTONOMY_TELEMETRY_EVENT_TYPES.evidenceBundle,
|
|
592
|
-
timestamp: new Date().toISOString(),
|
|
593
|
-
payload: {
|
|
594
|
-
laneId: record.laneId,
|
|
595
|
-
laneType: record.type,
|
|
596
|
-
status: record.status,
|
|
597
|
-
reasonCode: record.reasonCode ?? null,
|
|
598
|
-
costUsd: record.costUsd ?? null,
|
|
599
|
-
hasEvidence: record.evidenceEntryId !== undefined,
|
|
600
|
-
},
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
604
|
-
this.deps.emit({ type: "warning", message: `Research lane failed: ${message}` });
|
|
605
|
-
return { started: true, record };
|
|
606
|
-
}
|
|
607
|
-
finally {
|
|
608
|
-
this._isResearchLaneRunning = false;
|
|
609
|
-
}
|
|
241
|
+
return this._research.runOnce(request);
|
|
610
242
|
}
|
|
611
|
-
/**
|
|
612
|
-
* Run one bounded scout-worker delegation: build a WorkerRequest with a stripped read-only
|
|
613
|
-
* envelope, execute it as an isolated completion on a cheap lane, validate the result via
|
|
614
|
-
* {@link validateWorkerResult} before acceptance, and persist result + lane record + spawned
|
|
615
|
-
* usage (idempotent per-lane reportId). Consumed by the `delegate` tool.
|
|
616
|
-
*/
|
|
243
|
+
/** Start a durable, profile-bound worker delegation. */
|
|
617
244
|
startWorkerDelegation(request) {
|
|
618
|
-
|
|
619
|
-
if (this.deps.isDisposed())
|
|
620
|
-
return { started: false, skipReason: "session_disposed" };
|
|
621
|
-
if (request.instructions.trim().length === 0)
|
|
622
|
-
return { started: false, skipReason: "missing_instructions" };
|
|
623
|
-
if (!this.deps.isDelegateToolActive())
|
|
624
|
-
return { started: false, skipReason: "delegate_tool_inactive" };
|
|
625
|
-
if (!settings.enabled)
|
|
626
|
-
return { started: false, skipReason: "worker_delegation_disabled" };
|
|
627
|
-
const shipment = this._resolveLaneShipment(settings, "no_worker_model");
|
|
628
|
-
if (!shipment.ok)
|
|
629
|
-
return { started: false, skipReason: shipment.skipReason };
|
|
630
|
-
if (!this._laneCapabilityProfile(shipment.model).backgroundLanesEnabled) {
|
|
631
|
-
return { started: false, skipReason: "model_delegation_unsupported" };
|
|
632
|
-
}
|
|
633
|
-
const foreground = this.deps.getModel();
|
|
634
|
-
const contendsWithLocalForeground = foreground !== undefined && isLocalExecutionModel(foreground) && isLocalExecutionModel(shipment.model);
|
|
635
|
-
if (contendsWithLocalForeground) {
|
|
636
|
-
if (this._queuedWorkers.size >= 8 ||
|
|
637
|
-
this._laneTracker.getActiveCount("worker") >= settings.maxConcurrent + 8) {
|
|
638
|
-
return { started: false, skipReason: "worker_delegation_queue_full" };
|
|
639
|
-
}
|
|
640
|
-
const record = this._laneTracker.enqueue({ type: "worker" });
|
|
641
|
-
this._queuedWorkers.set(record.laneId, request);
|
|
642
|
-
this._scheduleWorkerNotification();
|
|
643
|
-
return { started: true, record };
|
|
644
|
-
}
|
|
645
|
-
if (this._laneTracker.getRunningCount("worker") >= settings.maxConcurrent) {
|
|
646
|
-
return { started: false, skipReason: "worker_delegation_already_running" };
|
|
647
|
-
}
|
|
648
|
-
let startedRecord;
|
|
649
|
-
const promise = this.runWorkerDelegationOnce(request, (record) => {
|
|
650
|
-
startedRecord = record;
|
|
651
|
-
});
|
|
652
|
-
if (!startedRecord) {
|
|
653
|
-
// Preparation is synchronous up to the first isolated completion await. A promise that
|
|
654
|
-
// rejected before producing a lane is still observed below, so it cannot become unhandled.
|
|
655
|
-
void promise.catch(() => undefined);
|
|
656
|
-
return { started: false, skipReason: "worker_not_started" };
|
|
657
|
-
}
|
|
658
|
-
this._workerPromises.set(startedRecord.laneId, promise);
|
|
659
|
-
void promise.then(() => this._workerPromises.delete(startedRecord?.laneId ?? ""), () => this._workerPromises.delete(startedRecord?.laneId ?? ""));
|
|
660
|
-
return { started: true, record: startedRecord };
|
|
245
|
+
return this._getWorkerController().start(request);
|
|
661
246
|
}
|
|
247
|
+
/** Run one worker immediately; used by focused integrations and tests. */
|
|
662
248
|
async runWorkerDelegationOnce(request, onStarted, existingRecord) {
|
|
663
|
-
|
|
664
|
-
const runningWorkers = this._laneTracker.getRunningCount("worker");
|
|
665
|
-
if (runningWorkers >= delegationSettings.maxConcurrent) {
|
|
666
|
-
return { started: false, skipReason: "worker_delegation_already_running" };
|
|
667
|
-
}
|
|
668
|
-
if (this.deps.isDisposed()) {
|
|
669
|
-
return { started: false, skipReason: "session_disposed" };
|
|
670
|
-
}
|
|
671
|
-
const instructions = request.instructions.trim();
|
|
672
|
-
if (instructions.length === 0) {
|
|
673
|
-
return { started: false, skipReason: "missing_instructions" };
|
|
674
|
-
}
|
|
675
|
-
const settings = delegationSettings;
|
|
676
|
-
if (!this.deps.isDelegateToolActive()) {
|
|
677
|
-
return { started: false, skipReason: "delegate_tool_inactive" };
|
|
678
|
-
}
|
|
679
|
-
if (!settings.enabled) {
|
|
680
|
-
return { started: false, skipReason: "worker_delegation_disabled" };
|
|
681
|
-
}
|
|
682
|
-
const shipment = this._resolveLaneShipment(settings, "no_worker_model");
|
|
683
|
-
if (!shipment.ok) {
|
|
684
|
-
return { started: false, skipReason: shipment.skipReason };
|
|
685
|
-
}
|
|
686
|
-
const { model, laneProfile } = shipment;
|
|
687
|
-
const laneCapability = this._laneCapabilityProfile(model);
|
|
688
|
-
if (!laneCapability.backgroundLanesEnabled) {
|
|
689
|
-
return { started: false, skipReason: "model_delegation_unsupported" };
|
|
690
|
-
}
|
|
691
|
-
this._seedLaneHistory();
|
|
692
|
-
const startedRecord = existingRecord ?? this._laneTracker.start({ type: "worker" });
|
|
693
|
-
if (existingRecord)
|
|
694
|
-
this._laneTracker.markRunning(existingRecord.laneId);
|
|
695
|
-
onStarted?.(startedRecord);
|
|
696
|
-
const maxUsd = Math.min(settings.maxUsd, this.deps.getCapabilityEnvelope()?.maxEstimatedUsd ?? Number.POSITIVE_INFINITY);
|
|
697
|
-
const writeEnabled = settings.writeEnabled && settings.writePaths.length > 0;
|
|
698
|
-
const toolSurface = createLaneToolSurface({
|
|
699
|
-
cwd: this.deps.getCwd(),
|
|
700
|
-
profile: laneProfile,
|
|
701
|
-
deniedPaths: getPrivateLaneDeniedPaths(this.deps.getCwd(), this.deps.getAgentDir()),
|
|
702
|
-
readMemory: request.memoryRead ? (query) => this.deps.readMemoryForLane(query) : undefined,
|
|
703
|
-
writeEnabled,
|
|
704
|
-
writePaths: settings.writePaths,
|
|
705
|
-
});
|
|
706
|
-
this._warnUnboundLaneToolGrants(laneProfile, toolSurface);
|
|
707
|
-
const allowedActionOps = new Set(toolSurface.allowedTools.filter((name) => name === "write" || name === "edit"));
|
|
708
|
-
const writeGranted = writeEnabled && allowedActionOps.size > 0;
|
|
709
|
-
const memoryReadGranted = request.memoryRead === true && toolSurface.allowedTools.includes("memory");
|
|
710
|
-
const workerRequest = {
|
|
711
|
-
id: startedRecord.laneId,
|
|
712
|
-
instructions,
|
|
713
|
-
route: {
|
|
714
|
-
tier: "cheap",
|
|
715
|
-
risk: writeGranted ? "scoped-write" : "read-only",
|
|
716
|
-
confidence: 1,
|
|
717
|
-
reasonCode: "scout_worker",
|
|
718
|
-
reasons: [writeGranted ? "Path-scoped worker delegation" : "Read-only scout delegation"],
|
|
719
|
-
},
|
|
720
|
-
envelope: {
|
|
721
|
-
id: `worker-${this.deps.getSessionId()}-${startedRecord.laneId}`,
|
|
722
|
-
profileId: laneProfile?.name,
|
|
723
|
-
// write_files requires BOTH the opt-in AND an explicit non-empty path scope —
|
|
724
|
-
// an unscoped write grant is refused here, not discovered at validation time.
|
|
725
|
-
capabilities: [
|
|
726
|
-
"read_files",
|
|
727
|
-
...(memoryReadGranted ? ["memory_read"] : []),
|
|
728
|
-
...(writeGranted ? ["write_files"] : []),
|
|
729
|
-
],
|
|
730
|
-
...(writeGranted ? { allowedPaths: [...settings.writePaths] } : {}),
|
|
731
|
-
deniedPaths: getPrivateLaneDeniedPaths(this.deps.getCwd(), this.deps.getAgentDir()),
|
|
732
|
-
allowedTools: [...toolSurface.allowedTools],
|
|
733
|
-
deniedTools: [...toolSurface.deniedTools],
|
|
734
|
-
maxEstimatedUsd: maxUsd,
|
|
735
|
-
createdAt: new Date().toISOString(),
|
|
736
|
-
},
|
|
737
|
-
maxEstimatedUsd: maxUsd,
|
|
738
|
-
createdAt: new Date().toISOString(),
|
|
739
|
-
};
|
|
740
|
-
// G8: worker delegation START. Routing/scope codes + budget only — never the instructions text.
|
|
741
|
-
this.deps.emitAutonomyTelemetry({
|
|
742
|
-
type: AUTONOMY_TELEMETRY_EVENT_TYPES.workerRequest,
|
|
743
|
-
timestamp: new Date().toISOString(),
|
|
744
|
-
payload: {
|
|
745
|
-
id: workerRequest.id,
|
|
746
|
-
tier: workerRequest.route.tier,
|
|
747
|
-
capabilities: [...workerRequest.envelope.capabilities],
|
|
748
|
-
maxEstimatedUsd: workerRequest.maxEstimatedUsd ?? null,
|
|
749
|
-
},
|
|
750
|
-
});
|
|
751
|
-
const usageReportId = `worker:${this.deps.getSessionId()}:${startedRecord.laneId}`;
|
|
752
|
-
try {
|
|
753
|
-
let spentUsage;
|
|
754
|
-
const toolChangedFiles = new Set();
|
|
755
|
-
const toolIssues = new Set();
|
|
756
|
-
const outcome = await runWorker({
|
|
757
|
-
request: workerRequest,
|
|
758
|
-
maxUsd,
|
|
759
|
-
maxWallClockMs: settings.maxWallClockMs,
|
|
760
|
-
usageReportId,
|
|
761
|
-
getChangedFiles: () => [...toolChangedFiles],
|
|
762
|
-
signal: this._workerDelegationAbort.signal,
|
|
763
|
-
// Parent validation must use the same relative-path baseline the runner reports in.
|
|
764
|
-
cwd: this.deps.getCwd(),
|
|
765
|
-
// Write lane (G2): runner-side action application through the envelope path scope.
|
|
766
|
-
applyActions: workerRequest.envelope.capabilities.includes("write_files")
|
|
767
|
-
? (actions) => {
|
|
768
|
-
const permitted = actions.filter((action) => allowedActionOps.has(action.op));
|
|
769
|
-
const applied = applyWorkerActions({
|
|
770
|
-
actions: permitted,
|
|
771
|
-
envelope: workerRequest.envelope,
|
|
772
|
-
cwd: this.deps.getCwd(),
|
|
773
|
-
});
|
|
774
|
-
return {
|
|
775
|
-
...applied,
|
|
776
|
-
refused: [
|
|
777
|
-
...actions
|
|
778
|
-
.filter((action) => !allowedActionOps.has(action.op))
|
|
779
|
-
.map((action) => ({
|
|
780
|
-
path: action.path,
|
|
781
|
-
reason: `${action.op} is not granted by the lane profile`,
|
|
782
|
-
})),
|
|
783
|
-
...applied.refused,
|
|
784
|
-
],
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
: undefined,
|
|
788
|
-
complete: async ({ systemPrompt, userPrompt, signal }) => {
|
|
789
|
-
const completion = await this.deps.runIsolatedCompletion({
|
|
790
|
-
// Level-0 core always survives. A model-provided prompt (delegate tool) is the most
|
|
791
|
-
// specific override, then the settings-level prompt, then profile soul + role prompt.
|
|
792
|
-
systemPrompt: composeSubagentSystemPrompt({
|
|
793
|
-
soul: laneProfile?.soul,
|
|
794
|
-
rolePrompt: systemPrompt,
|
|
795
|
-
override: request.systemPrompt ?? settings.systemPrompt,
|
|
796
|
-
}),
|
|
797
|
-
messages: [{ role: "user", content: [{ type: "text", text: userPrompt }], timestamp: Date.now() }],
|
|
798
|
-
model,
|
|
799
|
-
thinkingLevel: laneProfile?.thinking ?? "off",
|
|
800
|
-
maxTokens: laneCapability.laneMaxOutputTokens,
|
|
801
|
-
tools: toolSurface.tools,
|
|
802
|
-
maxTurns: 6,
|
|
803
|
-
finalTextPrompt: "The tool-turn budget is exhausted. Do not call more tools. Return the required worker-result JSON envelope now using only evidence already gathered. If the investigation is incomplete, say so in the summary or blockers instead of omitting the envelope.",
|
|
804
|
-
beforeToolCall: async (context, toolSignal) => {
|
|
805
|
-
const decision = await toolSurface.beforeToolCall(context, toolSignal);
|
|
806
|
-
if (decision?.block) {
|
|
807
|
-
toolIssues.add(`${context.toolCall.name} blocked: ${decision.reason ?? "capability denied"}`);
|
|
808
|
-
}
|
|
809
|
-
return decision;
|
|
810
|
-
},
|
|
811
|
-
afterToolCall: async ({ toolCall, args, isError }) => {
|
|
812
|
-
// This hook runs only for a validated, gate-approved tool that actually entered
|
|
813
|
-
// execution. Record a direct mutation target before inspecting `isError`: write/edit
|
|
814
|
-
// may have changed disk and then observed cancellation, timeout, or a late I/O error.
|
|
815
|
-
// Pre-gate/profile/path refusals never reach afterToolCall, so they remain unreported.
|
|
816
|
-
if (toolCall.name === "write" || toolCall.name === "edit") {
|
|
817
|
-
if (args && typeof args === "object" && !Array.isArray(args)) {
|
|
818
|
-
const rawPath = args.path;
|
|
819
|
-
if (typeof rawPath === "string" && rawPath.length > 0) {
|
|
820
|
-
const absolutePath = path.isAbsolute(rawPath)
|
|
821
|
-
? path.resolve(rawPath)
|
|
822
|
-
: path.resolve(this.deps.getCwd(), rawPath);
|
|
823
|
-
let canonicalPath = absolutePath;
|
|
824
|
-
try {
|
|
825
|
-
canonicalPath = safeRealpathSync(absolutePath);
|
|
826
|
-
}
|
|
827
|
-
catch {
|
|
828
|
-
// Execution was attempted; preserve conservative accounting with the lexical path.
|
|
829
|
-
}
|
|
830
|
-
toolChangedFiles.add(path.relative(this.deps.getCwd(), canonicalPath).split(path.sep).join("/"));
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
if (isError) {
|
|
835
|
-
toolIssues.add(`${toolCall.name} failed during isolated execution`);
|
|
836
|
-
return undefined;
|
|
837
|
-
}
|
|
838
|
-
return undefined;
|
|
839
|
-
},
|
|
840
|
-
signal,
|
|
841
|
-
// Core/soul/role are all static per configuration — the provider can cache the prefix.
|
|
842
|
-
cacheRetention: "short",
|
|
843
|
-
});
|
|
844
|
-
spentUsage = completion.usage;
|
|
845
|
-
return {
|
|
846
|
-
text: completion.text,
|
|
847
|
-
costUsd: completion.usage.cost.total,
|
|
848
|
-
stopReason: String(completion.stopReason),
|
|
849
|
-
changedFiles: [...toolChangedFiles],
|
|
850
|
-
blockers: [...toolIssues],
|
|
851
|
-
};
|
|
852
|
-
},
|
|
853
|
-
});
|
|
854
|
-
// Bug #21 pattern: never persist against a disposed session.
|
|
855
|
-
if (this.deps.isDisposed()) {
|
|
856
|
-
const record = this._laneTracker.complete(startedRecord.laneId, {
|
|
857
|
-
status: "canceled",
|
|
858
|
-
reasonCode: "session_disposed",
|
|
859
|
-
});
|
|
860
|
-
if (record)
|
|
861
|
-
this._recordWorkerTerminal(record);
|
|
862
|
-
return { started: true, record, outcome };
|
|
863
|
-
}
|
|
864
|
-
this.deps.saveWorkerResultSnapshot(outcome.result, workerRequest);
|
|
865
|
-
if (spentUsage && (spentUsage.cost.total > 0 || spentUsage.totalTokens > 0)) {
|
|
866
|
-
this.deps.addSpawnedUsage(spentUsage, { label: "worker-delegation", reportId: usageReportId });
|
|
867
|
-
}
|
|
868
|
-
const record = this._laneTracker.complete(startedRecord.laneId, {
|
|
869
|
-
status: outcome.laneStatus,
|
|
870
|
-
reasonCode: outcome.reasonCode,
|
|
871
|
-
costUsd: outcome.costUsd,
|
|
872
|
-
});
|
|
873
|
-
if (record) {
|
|
874
|
-
this._recordWorkerTerminal(record);
|
|
875
|
-
appendLaneRecordSnapshot(this.deps.getSessionManager(), record);
|
|
876
|
-
// G3: worker lane terminal record -> worker_result event. Lane outcome only
|
|
877
|
-
// (status/reasonCode/cost) — never the worker's summary/changed-file text.
|
|
878
|
-
this.deps.emitAutonomyTelemetry({
|
|
879
|
-
type: AUTONOMY_TELEMETRY_EVENT_TYPES.workerResult,
|
|
880
|
-
timestamp: new Date().toISOString(),
|
|
881
|
-
payload: {
|
|
882
|
-
laneId: record.laneId,
|
|
883
|
-
laneType: record.type,
|
|
884
|
-
status: record.status,
|
|
885
|
-
reasonCode: record.reasonCode ?? null,
|
|
886
|
-
costUsd: record.costUsd ?? null,
|
|
887
|
-
},
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
return { started: true, record, outcome };
|
|
891
|
-
}
|
|
892
|
-
catch (error) {
|
|
893
|
-
const record = this._laneTracker.complete(startedRecord.laneId, {
|
|
894
|
-
status: "failed",
|
|
895
|
-
reasonCode: "worker_delegation_error",
|
|
896
|
-
});
|
|
897
|
-
if (record)
|
|
898
|
-
this._recordWorkerTerminal(record);
|
|
899
|
-
if (record && !this.deps.isDisposed()) {
|
|
900
|
-
appendLaneRecordSnapshot(this.deps.getSessionManager(), record);
|
|
901
|
-
this.deps.emitAutonomyTelemetry({
|
|
902
|
-
type: AUTONOMY_TELEMETRY_EVENT_TYPES.workerResult,
|
|
903
|
-
timestamp: new Date().toISOString(),
|
|
904
|
-
payload: {
|
|
905
|
-
laneId: record.laneId,
|
|
906
|
-
laneType: record.type,
|
|
907
|
-
status: record.status,
|
|
908
|
-
reasonCode: record.reasonCode ?? null,
|
|
909
|
-
costUsd: record.costUsd ?? null,
|
|
910
|
-
},
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
914
|
-
this.deps.emit({ type: "warning", message: `Worker delegation failed: ${message}` });
|
|
915
|
-
return { started: true, record };
|
|
916
|
-
}
|
|
917
|
-
finally {
|
|
918
|
-
}
|
|
249
|
+
return this._getWorkerController().runOnce(request, onStarted, existingRecord);
|
|
919
250
|
}
|
|
920
251
|
/**
|
|
921
252
|
* Probe a candidate model against the subagent contracts (research/worker/judge/search/
|
|
@@ -924,123 +255,16 @@ export class BackgroundLaneController {
|
|
|
924
255
|
* spend is reported through spawned-usage accounting.
|
|
925
256
|
*/
|
|
926
257
|
async runModelFitness(args) {
|
|
927
|
-
|
|
928
|
-
return { started: false, skipReason: "session_disposed" };
|
|
929
|
-
const resolved = this.resolveLaneModel(args.model.trim() || undefined);
|
|
930
|
-
if (!resolved)
|
|
931
|
-
return { started: false, skipReason: "model_unresolved_or_unauthenticated" };
|
|
932
|
-
const capability = this._laneCapabilityProfile(resolved);
|
|
933
|
-
const spent = {
|
|
934
|
-
input: 0,
|
|
935
|
-
output: 0,
|
|
936
|
-
cacheRead: 0,
|
|
937
|
-
cacheWrite: 0,
|
|
938
|
-
totalTokens: 0,
|
|
939
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
940
|
-
};
|
|
941
|
-
const report = await runModelFitnessProbe({
|
|
942
|
-
trials: args.trials,
|
|
943
|
-
signal: this._researchLaneAbort.signal,
|
|
944
|
-
capacityProbe: resolved.provider === "ollama" && resolved.contextWindow > 0
|
|
945
|
-
? { registeredContextWindow: resolved.contextWindow }
|
|
946
|
-
: undefined,
|
|
947
|
-
complete: async ({ systemPrompt, userPrompt, signal }) => {
|
|
948
|
-
const callStarted = Date.now();
|
|
949
|
-
const completion = await this.deps.runIsolatedCompletion({
|
|
950
|
-
systemPrompt,
|
|
951
|
-
messages: [{ role: "user", content: [{ type: "text", text: userPrompt }], timestamp: Date.now() }],
|
|
952
|
-
model: resolved,
|
|
953
|
-
thinkingLevel: "off",
|
|
954
|
-
maxTokens: capability.laneMaxOutputTokens,
|
|
955
|
-
signal,
|
|
956
|
-
cacheRetention: "short",
|
|
957
|
-
});
|
|
958
|
-
const callMs = Date.now() - callStarted;
|
|
959
|
-
spent.input += completion.usage.input;
|
|
960
|
-
spent.output += completion.usage.output;
|
|
961
|
-
spent.cacheRead += completion.usage.cacheRead;
|
|
962
|
-
spent.cacheWrite += completion.usage.cacheWrite;
|
|
963
|
-
spent.totalTokens += completion.usage.totalTokens;
|
|
964
|
-
spent.cost.input += completion.usage.cost.input;
|
|
965
|
-
spent.cost.output += completion.usage.cost.output;
|
|
966
|
-
spent.cost.cacheRead += completion.usage.cost.cacheRead;
|
|
967
|
-
spent.cost.cacheWrite += completion.usage.cost.cacheWrite;
|
|
968
|
-
spent.cost.total += completion.usage.cost.total;
|
|
969
|
-
return {
|
|
970
|
-
text: completion.text,
|
|
971
|
-
costUsd: completion.usage.cost.total,
|
|
972
|
-
stopReason: String(completion.stopReason),
|
|
973
|
-
// Wall-clock fallback for tok/s: providers don't expose pure eval time, so the
|
|
974
|
-
// measured call time stands in — slightly conservative (includes network/queue).
|
|
975
|
-
outputTokens: completion.usage.output,
|
|
976
|
-
evalMs: callMs,
|
|
977
|
-
};
|
|
978
|
-
},
|
|
979
|
-
});
|
|
980
|
-
if (!this.deps.isDisposed() && (spent.cost.total > 0 || spent.totalTokens > 0)) {
|
|
981
|
-
this.deps.addSpawnedUsage(spent, { label: "model-fitness" });
|
|
982
|
-
}
|
|
983
|
-
const modelRef = `${resolved.provider}/${resolved.id}`;
|
|
984
|
-
// Fitness is a property of a model ON a host — persist the report host-keyed so role
|
|
985
|
-
// assignments stay per-machine (a model can await better hardware without being forgotten).
|
|
986
|
-
// Best-effort: a disk problem must not fail the probe itself.
|
|
987
|
-
try {
|
|
988
|
-
if (!this.deps.isDisposed()) {
|
|
989
|
-
FitnessStore.forAgentDir(this.deps.getAgentDir()).save(modelRef, report);
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
catch {
|
|
993
|
-
// best-effort persistence
|
|
994
|
-
}
|
|
995
|
-
return { started: true, model: modelRef, report };
|
|
258
|
+
return this._fitness.run(args);
|
|
996
259
|
}
|
|
997
|
-
/** Start queued
|
|
260
|
+
/** Start every capacity-eligible queued worker at the owner session's foreground-idle boundary. */
|
|
998
261
|
drainQueuedWorkerDelegations() {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
this.deps.getSettingsManager().getWorkerDelegationSettings().maxConcurrent)
|
|
1002
|
-
break;
|
|
1003
|
-
const record = this._laneTracker.getRecords().find((candidate) => candidate.laneId === laneId);
|
|
1004
|
-
if (!record) {
|
|
1005
|
-
this._queuedWorkers.delete(laneId);
|
|
1006
|
-
continue;
|
|
1007
|
-
}
|
|
1008
|
-
this._queuedWorkers.delete(laneId);
|
|
1009
|
-
const promise = this.runWorkerDelegationOnce(request, undefined, record);
|
|
1010
|
-
this._workerPromises.set(laneId, promise);
|
|
1011
|
-
void promise.then((outcome) => {
|
|
1012
|
-
if (!outcome.started) {
|
|
1013
|
-
const terminal = this._laneTracker.complete(laneId, {
|
|
1014
|
-
status: "canceled",
|
|
1015
|
-
reasonCode: outcome.skipReason,
|
|
1016
|
-
});
|
|
1017
|
-
if (terminal)
|
|
1018
|
-
this._recordWorkerTerminal(terminal);
|
|
1019
|
-
}
|
|
1020
|
-
this._workerPromises.delete(laneId);
|
|
1021
|
-
if (!this.deps.isDisposed())
|
|
1022
|
-
this.drainQueuedWorkerDelegations();
|
|
1023
|
-
}, () => {
|
|
1024
|
-
const terminal = this._laneTracker.complete(laneId, {
|
|
1025
|
-
status: "failed",
|
|
1026
|
-
reasonCode: "worker_background_error",
|
|
1027
|
-
});
|
|
1028
|
-
if (terminal)
|
|
1029
|
-
this._recordWorkerTerminal(terminal);
|
|
1030
|
-
this._workerPromises.delete(laneId);
|
|
1031
|
-
if (!this.deps.isDisposed())
|
|
1032
|
-
this.drainQueuedWorkerDelegations();
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
262
|
+
if (this.deps.isDelegateToolActive?.())
|
|
263
|
+
this._getWorkerController().drain();
|
|
1035
264
|
}
|
|
1036
265
|
/** Fitness reports persisted for THIS host (measured evidence for architect/profile decisions). */
|
|
1037
266
|
getStoredFitnessReports() {
|
|
1038
|
-
|
|
1039
|
-
return FitnessStore.forAgentDir(this.deps.getAgentDir()).getForHost();
|
|
1040
|
-
}
|
|
1041
|
-
catch {
|
|
1042
|
-
return [];
|
|
1043
|
-
}
|
|
267
|
+
return this._fitness.getStoredReports();
|
|
1044
268
|
}
|
|
1045
269
|
}
|
|
1046
270
|
//# sourceMappingURL=background-lane-controller.js.map
|