@caupulican/pi-adaptative 0.81.39 → 0.81.41
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 +77 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +3 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +4 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +9 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +290 -107
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +357 -122
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +2 -2
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +31 -1
- 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 +25 -2
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +79 -4
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +293 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -0
- package/dist/core/agent-session-contracts.js +26 -0
- package/dist/core/agent-session-contracts.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +400 -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 +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +74 -518
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +370 -1432
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/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 +20 -12
- 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 +48 -9
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +14 -0
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +38 -0
- 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 +56 -236
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +141 -1273
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts +16 -0
- package/dist/core/bedrock-sso-login.d.ts.map +1 -0
- package/dist/core/bedrock-sso-login.js +98 -0
- package/dist/core/bedrock-sso-login.js.map +1 -0
- package/dist/core/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 +13 -17
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +3 -3
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/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-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 +10 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -1
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +16 -37
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +5 -3
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +4 -5
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +2 -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-result.d.ts → worker-claim.d.ts} +13 -13
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/{worker-result.js → worker-claim.js} +61 -51
- 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/extension-import-authority.d.ts +6 -0
- package/dist/core/extension-import-authority.d.ts.map +1 -0
- package/dist/core/extension-import-authority.js +10 -0
- package/dist/core/extension-import-authority.js.map +1 -0
- package/dist/core/extensions/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 +52 -18
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +20 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +2 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +2 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/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 +78 -21
- 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 +53 -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 +14 -9
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +47 -75
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +11 -0
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -0
- package/dist/core/goals/compact-goal-context.js +59 -0
- package/dist/core/goals/compact-goal-context.js.map +1 -0
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +27 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +28 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +90 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +2 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +52 -11
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +4 -29
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +4 -32
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +8 -18
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +9 -179
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +43 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +102 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-record.d.ts +17 -0
- package/dist/core/goals/goal-record.d.ts.map +1 -0
- package/dist/core/goals/goal-record.js +31 -0
- package/dist/core/goals/goal-record.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +11 -9
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +10 -8
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +42 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-session-controller.js +128 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -0
- package/dist/core/goals/goal-state.d.ts +46 -25
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +91 -24
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +9 -10
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +60 -75
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +20 -12
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +133 -33
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input-controller.d.ts +47 -0
- package/dist/core/human-input-controller.d.ts.map +1 -0
- package/dist/core/human-input-controller.js +181 -0
- package/dist/core/human-input-controller.js.map +1 -0
- package/dist/core/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 +17 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +24 -6
- 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/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/local-runtime-controller.d.ts +1 -1
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/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 +0 -19
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +1 -19
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -5
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +17 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +38 -25
- 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-controller.d.ts +1 -1
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +2 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +5 -5
- 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 +4 -6
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +95 -83
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +2 -12
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +84 -57
- 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/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 +200 -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 +20 -3
- 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 +14 -3
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/codes.js.map +1 -1
- 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 +37 -22
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +399 -76
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts +5 -2
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js +123 -14
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts +10 -7
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js +45 -14
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts +8 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +23 -5
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +6 -8
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -29
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +5 -5
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +5 -2
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +6 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts +7 -0
- package/dist/core/request-auth.d.ts.map +1 -0
- package/dist/core/request-auth.js +8 -0
- package/dist/core/request-auth.js.map +1 -0
- package/dist/core/research/evidence-bundle.d.ts.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 +23 -8
- 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 +233 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +41 -23
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +365 -253
- package/dist/core/runtime-builder.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 +68 -25
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts +9 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.js +241 -0
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +27 -0
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -0
- package/dist/core/secrets/secret-dotenv.js +183 -0
- package/dist/core/secrets/secret-dotenv.js.map +1 -0
- package/dist/core/secrets/secret-vault-format.d.ts +112 -0
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault-format.js +397 -0
- package/dist/core/secrets/secret-vault-format.js.map +1 -0
- package/dist/core/secrets/secret-vault.d.ts +72 -0
- package/dist/core/secrets/secret-vault.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault.js +671 -0
- package/dist/core/secrets/secret-vault.js.map +1 -0
- package/dist/core/session-analytics.d.ts +4 -23
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +67 -70
- 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 +11 -4
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +24 -5
- package/dist/core/session-role.js.map +1 -1
- 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/session-tree-navigator.d.ts +4 -6
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +4 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +81 -29
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +2 -4
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +10 -28
- package/dist/core/tasks/session-task-state.js.map +1 -1
- 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 +4 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +28 -11
- 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 +86 -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 +8 -2
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +89 -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 +2 -3
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +9 -35
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts +21 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +3 -7
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +97 -138
- package/dist/core/tool-selection/tool-performance-store.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 +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +59 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +31 -3
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +148 -29
- 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 +106 -23
- 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/git-filter.d.ts +1 -8
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +2 -63
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts +10 -8
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +106 -28
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +2 -2
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +40 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +124 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +36 -3
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +3 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +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/search-command-guard.d.ts +14 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -0
- package/dist/core/tools/search-command-guard.js +333 -0
- package/dist/core/tools/search-command-guard.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts +38 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -0
- package/dist/core/tools/secret-store.js +412 -0
- package/dist/core/tools/secret-store.js.map +1 -0
- package/dist/core/tools/shell-command-parser.d.ts +16 -0
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -0
- package/dist/core/tools/shell-command-parser.js +113 -0
- package/dist/core/tools/shell-command-parser.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +2 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +99 -0
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +3 -5
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +4 -4
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +4 -6
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +6 -2
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +4 -4
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-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/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/store.d.ts +3 -3
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js +10 -5
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +149 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +4 -6
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +186 -28
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +4 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +60 -1
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/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/activity-lane.d.ts +55 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -0
- package/dist/modes/interactive/components/activity-lane.js +304 -0
- package/dist/modes/interactive/components/activity-lane.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +19 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/expandable-text.d.ts +12 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-text.js +17 -0
- package/dist/modes/interactive/components/expandable-text.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +15 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +30 -21
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +23 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +6 -6
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +19 -11
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +53 -20
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +3 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts +16 -0
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/usage-action-selector.js +46 -0
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -0
- package/dist/modes/interactive/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 +77 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +15 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +27 -19
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts +6 -2
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js +10 -5
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +74 -0
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-event-controller.js +328 -0
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +22 -24
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +245 -595
- 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/loaded-resources-view.d.ts +20 -0
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -0
- package/dist/modes/interactive/loaded-resources-view.js +147 -0
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -0
- package/dist/modes/interactive/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/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js +8 -2
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts +1 -5
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +0 -5
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +27 -8
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +150 -64
- 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/interactive/usage-commands.d.ts +34 -0
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -0
- package/dist/modes/interactive/usage-commands.js +225 -0
- package/dist/modes/interactive/usage-commands.js.map +1 -0
- package/dist/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/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.map +1 -1
- package/dist/utils/shell.js +5 -3
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/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 +38 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +28 -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 +59 -26
- package/docs/providers.md +9 -1
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +125 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +10 -3
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +14 -0
- package/docs/ui-reference/orchestration-before.txt +13 -0
- package/docs/ui-reference/orchestration-reference.txt +16 -0
- package/docs/usage.md +22 -2
- package/docs/work-directory.md +19 -8
- 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 +13 -13
- package/package.json +4 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -46
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -113
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-builder.js","sourceRoot":"","sources":["../../src/core/runtime-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAc7C,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAKN,eAAe,EAKf,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBA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QAC7C,MAAM,IAAI,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAAA,CACpC,CAAC,CAAC;AAAA,CACH;AAED,SAAS,cAAc,CAAC,GAAW,EAAE,IAAY,EAAU;IAC1D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAAA,CACjD;AAED,SAAS,cAAc,CAAC,IAAY,EAAsB;IACzD,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AAAA,CACD","sourcesContent":["/**\n * Runtime build & reload: the session's tool-registry assembly and the self-modification-safe\n * extension reload path. Owns building the base tool definitions, wrapping them into the live tool\n * registry (`_refreshToolRegistry`), constructing the {@link ExtensionRunner} for a rebuilt runtime\n * (`_buildRuntime`), and the repo's self-modification safety crown jewel: the preflight-guarded\n * `reload()` with its snapshot / doctor / commit-or-rollback sequence, plus the single-extension\n * live load/unload/reconcile operations that rebuild the runtime in place.\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). Owns ONLY the tool-registry\n * state — the base tool definitions, the wrapped tool registry, the definition registry, and the\n * per-tool prompt snippet/guideline maps. Everything else the build & reload touch — the live\n * {@link ExtensionRunner}, the agent's tool/system-prompt state, the base system prompt, the\n * resource loader, the session/settings managers, the model registry, the profile tool filter and\n * its warning sinks, the requested-active-tool-names request, the memory subsystem, and the many\n * host callbacks the rebuilt tools/runtime are wired to — is reached through narrow deps accessors\n * that read and write the SAME storage the host owns today.\n *\n * Snapshot-ownership boundary (deliberate, load-bearing for reload safety): the reload snapshot\n * spans state owned by OTHER collaborators — the extension runner and its ref, `agent.state.tools`\n * / `agent.state.systemPrompt`, and `_baseSystemPrompt`. Those are captured and restored through\n * {@link RuntimeBuilderDeps} get/set accessors so save/restore mutate exactly the host/agent fields\n * they mutated before extraction; only the five tool-registry maps are captured by direct field\n * reference here (this builder owns them). The `_extensionRunnerRef.current` update folds into\n * {@link RuntimeBuilderDeps.setExtensionRunner} (the same field-then-ref pattern the host used at\n * every assignment site), so no observer runs between the two writes.\n *\n * Host-binding boundary (deliberate): `_bindExtensionCore` — which exposes the SESSION's own public\n * surface (sendMessage, setModel, compact, abort, reload, …) to the extension runner — stays\n * host-side and is invoked from {@link buildRuntime} via {@link RuntimeBuilderDeps.bindExtensionCore};\n * it is host identity, not build logic, and moving it would only re-export ~30 host methods through\n * deps to hand them straight back. The host keeps one-line delegations for the public reload /\n * load / unload / reconcile API and for `getAllTools` / `getToolDefinition`, and a private\n * `_refreshToolRegistry` delegation for its internal callers.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { isAbsolute, join } from \"node:path\";\nimport type { Agent, AgentContext, AgentMessage, AgentTool, ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { Api, Model, Usage } from \"@caupulican/pi-ai\";\nimport type {\n\tIsolatedCompletionOptions,\n\tIsolatedCompletionResult,\n\tWorkerDelegationRunOutcome,\n} from \"./agent-session.ts\";\nimport type { WorkerResult } from \"./autonomy/contracts.ts\";\nimport type { LaneRecord } from \"./autonomy/lane-tracker.ts\";\nimport type { ArtifactStore } from \"./context/context-artifacts.ts\";\nimport type { MemoryPromptInclusionReport, MemoryRetrievalDiagnostics } from \"./context/memory-diagnostics.ts\";\nimport type { ContextGcReport } from \"./context-gc.ts\";\nimport { DEFAULT_ACTIVE_TOOL_NAMES, mapToolNamesForPlatform } from \"./default-tool-surface.ts\";\nimport { acknowledgeWorkerResultReview } from \"./delegation/session-worker-result.ts\";\nimport { createCoreDiagnosticsToolDefinitions } from \"./extensions/builtin.ts\";\nimport {\n\ttype ContextUsage,\n\ttype Extension,\n\ttype ExtensionCommandContextActions,\n\ttype ExtensionErrorListener,\n\tExtensionRunner,\n\ttype ExtensionUIContext,\n\ttype ShutdownHandler,\n\ttype ToolDefinition,\n\ttype ToolInfo,\n\twrapRegisteredTools,\n} from \"./extensions/index.ts\";\nimport { disposeExtensionEventSubscriptions } from \"./extensions/loader.ts\";\nimport { emitSessionShutdownEvent } from \"./extensions/runner.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport type { OpenTaskStepRef } from \"./goals/goal-tool-core.ts\";\nimport type { MemoryManager } from \"./memory/memory-manager.ts\";\nimport type { MemoryControllerReloadSnapshot } from \"./memory-controller.ts\";\nimport type { LaneWorkerRefusal } from \"./model-capability.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport { resolveCliModel } from \"./model-resolver.ts\";\nimport { evaluateSurfaceFitness } from \"./model-router/fitness-gate.ts\";\nimport { FitnessStore } from \"./models/fitness-store.ts\";\nimport type { ProfileFilterReloadSnapshot } from \"./profile-filter-controller.ts\";\nimport { describeInFlightWorkUnit, getInFlightWorkUnits } from \"./reload-blockers.ts\";\nimport type { ModelFitnessReport } from \"./research/model-fitness.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport { ScoutController } from \"./scout-controller.ts\";\nimport { getSessionRole, isWorkerSession, WORKER_FORBIDDEN_TOOLS } from \"./session-role.ts\";\nimport {\n\tmatchesResourceProfilePattern,\n\ttype ResourceProfileFilterSettings,\n\ttype SettingsManager,\n} from \"./settings-manager.ts\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.ts\";\nimport type { TaskStepsState } from \"./tasks/task-state.ts\";\nimport {\n\tbuildReflexUserPrompt,\n\tparseReflexPlan,\n\tREFLEX_INTERPRETER_SYSTEM_PROMPT,\n} from \"./toolkit/reflex-interpreter.ts\";\nimport { executeToolkitScript } from \"./toolkit/script-runner.ts\";\nimport { createContextScoutToolDefinition } from \"./tools/context-scout.ts\";\nimport { createDelegateToolDefinition } from \"./tools/delegate.ts\";\nimport { createDelegateStatusToolDefinition } from \"./tools/delegate-status.ts\";\nimport { createFindTool } from \"./tools/find.ts\";\nimport { createGoalToolDefinition } from \"./tools/goal.ts\";\nimport { createGrepTool } from \"./tools/grep.ts\";\nimport { createAllToolDefinitions } from \"./tools/index.ts\";\nimport { createModelFitnessToolDefinition } from \"./tools/model-fitness.ts\";\nimport { resolveToCwd } from \"./tools/path-utils.ts\";\nimport { createReadTool } from \"./tools/read.ts\";\nimport { createRunToolkitScriptToolDefinition } from \"./tools/run-toolkit-script.ts\";\nimport { createTaskStepsToolDefinition } from \"./tools/task-steps.ts\";\nimport { dispatchTmuxWorker } from \"./tools/tmux-dispatch.ts\";\nimport { createToolDefinitionFromAgentTool } from \"./tools/tool-definition-wrapper.ts\";\nimport { createWorktreeSyncToolDefinition } from \"./tools/worktree-sync.ts\";\nimport { createLane } from \"./worktree-sync/git-engine.ts\";\nimport { WorktreeLaneGate } from \"./worktree-sync/lane-gate.ts\";\nimport { buildWorktreeSyncEngineDeps, getBoundWorktreeLaneKey } from \"./worktree-sync/runtime.ts\";\n\ninterface ToolDefinitionEntry {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\n/**\n * Deterministic `addSpawnedUsage` reportId: `kind` + session id + a content hash of `identity`\n * (never `Date.now`/random). Same identity on a retry of the same logical work unit yields the same\n * id, so the ledger's `seenSubagentReportIds` dedupe catches a duplicate report instead of\n * double-counting spend.\n */\nfunction deriveSpawnedUsageReportId(kind: string, sessionId: string, identity: string): string {\n\tconst digest = createHash(\"sha256\").update(identity).digest(\"hex\").slice(0, 16);\n\treturn `${kind}:${sessionId}:${digest}`;\n}\n\n/**\n * Is `toolCallId` a real, answered tool call on `sessionManager`'s active branch? A\n * toolCallId is \"real\" iff a toolResult message on that branch responded to it -- the same\n * toolResult/toolCallId match `context-pipeline.ts`'s `_buildSessionEntryIdLookup` uses, and\n * branch-scoped (via `getBranch()`) so a sibling branch's tool calls never count. Exported (pure,\n * no `this`) so the goal tool's `hasToolCallId` wiring below is directly testable against a real\n * `SessionManager` without constructing the whole `RuntimeBuilder`.\n */\nexport function hasAnsweredToolCallOnBranch(sessionManager: SessionManager, toolCallId: string): boolean {\n\treturn sessionManager\n\t\t.getBranch()\n\t\t.some(\n\t\t\t(entry) =>\n\t\t\t\tentry.type === \"message\" && entry.message.role === \"toolResult\" && entry.message.toolCallId === toolCallId,\n\t\t);\n}\n\n/**\n * Project a task-steps snapshot down to the OPEN (non-terminal) steps the goal tool's\n * cross-visibility nudge needs. Mirrors `goal-runtime-snapshot.ts`'s `openTaskSteps` filter\n * (status not \"completed\"/\"cancelled\", `activeForm || content`) so the two read the same\n * \"open\" definition, narrowed to `OpenTaskStepRef`'s id+content shape. Exported (pure, no\n * `this`) so the goal tool's `getOpenTaskSteps` wiring below is directly testable.\n */\nexport function deriveOpenTaskStepRefs(taskStepsState: TaskStepsState | undefined): OpenTaskStepRef[] {\n\treturn (taskStepsState?.steps ?? [])\n\t\t.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\")\n\t\t.map((step) => ({ id: step.id, content: step.activeForm || step.content }));\n}\n\ninterface ReloadRuntimeSnapshot {\n\textensionRunner: ExtensionRunner;\n\tsettings: ReturnType<SettingsManager[\"createReloadSnapshot\"]>;\n\tmodelRegistry: ReturnType<ModelRegistry[\"createReloadSnapshot\"]>;\n\tmodel: Model<Api>;\n\tthinkingLevel: ThinkingLevel;\n\tsessionLeafId: string | null;\n\ttoolProfileFilter: Required<ResourceProfileFilterSettings> | undefined;\n\trequestedActiveToolNames: string[] | undefined;\n\tmemory: MemoryControllerReloadSnapshot;\n\tprofileFilter: ProfileFilterReloadSnapshot;\n\tunboundToolGrantWarnings: string[];\n\tbaseToolDefinitions: Map<string, ToolDefinition>;\n\ttoolRegistry: Map<string, AgentTool>;\n\ttoolDefinitions: Map<string, ToolDefinitionEntry>;\n\ttoolPromptSnippets: Map<string, string>;\n\ttoolPromptGuidelines: Map<string, string[]>;\n\tagentTools: AgentTool[];\n\tagentSystemPrompt: string;\n\tbaseSystemPrompt: string;\n}\n\nexport interface RuntimeBuilderDeps {\n\t/** Live agent — the snapshot/doctor read and restore its `state.tools` / `state.systemPrompt`. */\n\tgetAgent(): Agent;\n\t/** Workspace root, passed to the tool-definition factory and the extension runner. */\n\tgetCwd(): string;\n\t/** Per-agent persistent shell session key; stable across reloads so the shell survives them. */\n\tgetShellSessionKey(): string;\n\t/** Agent state root, including the host-keyed fitness store. */\n\tgetAgentDir(): string;\n\t/** Session log, passed to the extension runner. */\n\tgetSessionManager(): SessionManager;\n\t/** Tool/shell/toolkit/resource settings + reload target (settingsManager.reload()). */\n\tgetSettingsManager(): SettingsManager;\n\t/** Model registry, passed to the extension runner and profile model re-resolution. */\n\tgetModelRegistry(): ModelRegistry;\n\t/** Session-scoped provider/model quota exhaustion guard. */\n\tisModelExhausted(model: Model<Api>): boolean;\n\t/** Extension/skill/prompt/theme discovery + the reload/commit/rollback generation swap. */\n\tgetResourceLoader(): ResourceLoader;\n\n\t/** Live extension runner (host-owned; pervasive). */\n\tgetExtensionRunner(): ExtensionRunner;\n\t/** Store the extension runner AND update the Agent's mutable `_extensionRunnerRef.current` (both together). */\n\tsetExtensionRunner(runner: ExtensionRunner): void;\n\t/** Base (extension-free) system prompt; captured/restored by the reload snapshot. */\n\tgetBaseSystemPrompt(): string;\n\tsetBaseSystemPrompt(prompt: string): void;\n\n\t/** SDK-provided plain tools, synthesized into the registry alongside built-ins. */\n\tgetCustomTools(): ToolDefinition[];\n\t/** Optional plain-tool override; when set, the built-in factory + core diagnostics are skipped. */\n\tgetBaseToolsOverride(): Record<string, AgentTool> | undefined;\n\t/** Pre-filter tool REQUEST (never the capability/profile-filtered active set) preserved across a rebuild. */\n\tgetRequestedActiveToolNames(): string[] | undefined;\n\tsetRequestedActiveToolNames(names: string[] | undefined): void;\n\n\t/** Resource-profile tool allow/block filter + the raw allow/exclude sets applied during registry build. */\n\tgetToolProfileFilter(): Required<ResourceProfileFilterSettings> | undefined;\n\tsetToolProfileFilter(filter: Required<ResourceProfileFilterSettings> | undefined): void;\n\tgetAllowedToolNames(): Set<string> | undefined;\n\tgetExcludedToolNames(): Set<string> | undefined;\n\t/** Re-derive the profile tool filter from freshly reloaded settings (reload only). */\n\tderiveToolProfileFilter(): Required<ResourceProfileFilterSettings>;\n\t/** True when a tool/command name survives the active profile's allow/block + user allow/exclude. */\n\tisToolOrCommandAllowedByProfile(name: string): boolean;\n\t/** Filter the loaded extensions through the active resource profile (records inert/denied warnings host-side). */\n\tfilterExtensionsForRuntime(extensions: Extension[]): Extension[];\n\t/** Sink for the unbound-profile-tool-grant warnings surfaced in /context. */\n\tsetUnboundToolGrantWarnings(warnings: string[]): void;\n\tgetUnboundToolGrantWarnings(): string[];\n\tcreateProfileFilterReloadSnapshot(): ProfileFilterReloadSnapshot;\n\trestoreProfileFilterReloadSnapshot(snapshot: ProfileFilterReloadSnapshot): void;\n\n\t/** Currently-active tool names (reads agent.state.tools; the pre-filter fallback for a rebuild). */\n\tgetActiveToolNames(): string[];\n\t/** Apply the recomputed active set (capability filter + companion auto-activation live here). */\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t/** Normalize a tool's prompt snippet / guidelines through the system-prompt builder. */\n\tnormalizePromptSnippet(text: string | undefined): string | undefined;\n\tnormalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\n\t/** Wire the session's own public surface into a freshly-built runner (host identity; stays host-side). */\n\tbindExtensionCore(runner: ExtensionRunner): void;\n\t/** Re-apply UI context / mode / command-context / error subscription to a runner. */\n\tapplyExtensionBindings(runner: ExtensionRunner): void;\n\t/** Re-run resource discovery for the active extensions (reload only). */\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\t/** Re-apply the active profile's model/thinking from reloaded settings (reload only). */\n\treapplyActiveProfileModelSettings(): Promise<void>;\n\t/** Notify extensions-changed listeners after a single-extension live op. */\n\tnotifyExtensionsChanged(): void;\n\n\t/** Session-scoped tool-output artifact store for artifact-producing tools and artifact_retrieve (gated on the profile). */\n\tgetToolArtifactStore(): ArtifactStore;\n\n\t/** Live memory manager — its provider tools join the registry. */\n\tgetMemoryManager(): MemoryManager;\n\t/** Memory retrieval + prompt-inclusion diagnostics for the core diagnostics tool. */\n\tgetMemoryAuditDiagnostics(): { retrieval: MemoryRetrievalDiagnostics; promptInclusion: MemoryPromptInclusionReport };\n\t/** Drop extension-contributed pending memory providers before a reload re-registers them. */\n\tclearPendingMemoryProviders(): void;\n\tcreateMemoryReloadSnapshot(): MemoryControllerReloadSnapshot;\n\trestoreMemoryReloadSnapshot(snapshot: MemoryControllerReloadSnapshot): void;\n\t/** (Re)derive the memory subsystem from reloaded settings/providers. */\n\tinitializeMemory(): Promise<void>;\n\n\t/** Goal-tool state accessors. */\n\tgetGoalStateSnapshot(): GoalState | undefined;\n\tsaveGoalStateSnapshot(state: GoalState): string;\n\t/** Native task-step state accessors. */\n\tgetTaskStepsStateSnapshot(): TaskStepsState | undefined;\n\tsaveTaskStepsStateSnapshot(state: TaskStepsState): string;\n\t/** Context-gc report for the core diagnostics tool. */\n\tgetContextGcReport(messages: AgentMessage[]): ContextGcReport;\n\t/** Non-blocking worker-delegation starter for the delegate tool. */\n\tstartWorkerDelegation(request: {\n\t\tinstructions: string;\n\t\tsystemPrompt?: string;\n\t\tmemoryRead?: boolean;\n\t}): { started: false; skipReason: string } | { started: true; record: LaneRecord };\n\tgetWorkerLaneRecords(): LaneRecord[];\n\tgetWorkerResultSnapshots(): WorkerResult[];\n\t/** Resolve a managed (e.g. tmux) lane dispatch's internal LaneTracker id from the extension's own\n\t * caller-chosen laneId (`BackgroundLaneController.resolveManagedLaneId`) -- the goal->tmux dispatch\n\t * adapter's correlation read (see `tools/tmux-dispatch.ts`). */\n\tresolveManagedLaneId(callerLaneId: string): string | undefined;\n\t/** Worker-delegation runner for SDK/test through-completion calls. */\n\trunWorkerDelegationOnce(request: {\n\t\tinstructions: string;\n\t\tsystemPrompt?: string;\n\t\tmemoryRead?: boolean;\n\t}): Promise<WorkerDelegationRunOutcome>;\n\t/** Model-fitness probe for the model_fitness tool. `toolCallId` is the idempotency token\n\t * for spawned-usage reportId — present only for the LLM tool-call path (see model-fitness.ts). */\n\trunModelFitness(args: {\n\t\tmodel: string;\n\t\ttrials?: number;\n\t\ttoolCallId?: string;\n\t}): Promise<{ started: true; model: string; report: ModelFitnessReport } | { started: false; skipReason: string }>;\n\t/** Fitness-gated reflex-brain model resolver (run_toolkit_script interpretation). */\n\tresolveCurationModelIfFit(): Model<Api> | undefined;\n\t/** One-shot, tool-less LLM call — the reflex-brain interpreter rides this. */\n\trunIsolatedCompletion(opts: IsolatedCompletionOptions): Promise<IsolatedCompletionResult>;\n\t/** Roll reflex-brain spend into spawned-usage accounting. `reportId` is REQUIRED: every\n\t * caller derives a stable id from the work unit's identity so a retry cannot double-count. */\n\taddSpawnedUsage(\n\t\tusage: Usage,\n\t\topts: { label?: string; sourceSessionId?: string; reportId: string },\n\t): string | undefined;\n\t/** Whether the CURRENT session model may drive a worktree-sync lane worker (`AgentSession.\n\t * getLaneWorkerRefusal`) -- consulted BEFORE a goal→tmux dispatch so an ineligible model's\n\t * dispatch is refused before any lane/pane side effect (`tools/tmux-dispatch.ts`'s\n\t * `evaluateWorkerLaneRefusal`). `undefined` means eligible. */\n\tgetLaneWorkerRefusal(): LaneWorkerRefusal | undefined;\n\n\t/** Post-rebuild doctor helpers (validate the rebuilt runtime can render a context). */\n\tcreateAgentContextSnapshot(): AgentContext;\n\tgetContextUsage(): ContextUsage | undefined;\n\n\t/** Reload/live-op preflight refusal guards (identical refusal behavior; host-checked). */\n\tisStreaming(): boolean;\n\tisCompacting(): boolean;\n\n\t/** Extension bindings present — gate for re-emitting session_start on reload. */\n\tgetExtensionUIContext(): ExtensionUIContext | undefined;\n\tgetExtensionCommandContextActions(): ExtensionCommandContextActions | undefined;\n\tgetExtensionShutdownHandler(): ShutdownHandler | undefined;\n\tgetExtensionErrorListener(): ExtensionErrorListener | undefined;\n\n\t/**\n\t * Stop any pi-spawned local (Ollama/Transformers/prism llama.cpp) runtime the host's\n\t * LocalRuntimeController is holding open that no longer applies under the just-reloaded\n\t * configuration — e.g. `LocalRuntimeController.reconcile(eligibleModels)`, with `eligibleModels`\n\t * derived from whatever the host still routes to post-reload (foreground model + any configured\n\t * router tier). Called ONLY after `_reloadOnce()` commits successfully — never on a rolled-back\n\t * reload, since a rollback restores the PREVIOUS configuration and nothing became ineligible.\n\t * Optional: a host that hasn't wired a LocalRuntimeController through here yet sees no behavior\n\t * change — a local runtime this builder doesn't know about is simply left alone, never guessed at.\n\t */\n\treconcileLocalRuntimes?(): void;\n}\n\n/**\n * Owns the tool-registry build and the self-modification-safe extension reload extracted from\n * {@link AgentSession}. See the module header for the snapshot-ownership and host-binding boundaries.\n */\nexport class RuntimeBuilder {\n\t// Tool registry for extension getTools/setTools\n\tprivate _toolRegistry: Map<string, AgentTool> = new Map();\n\tprivate _toolDefinitions: Map<string, ToolDefinitionEntry> = new Map();\n\tprivate _toolPromptSnippets: Map<string, string> = new Map();\n\tprivate _toolPromptGuidelines: Map<string, string[]> = new Map();\n\tprivate _baseToolDefinitions: Map<string, ToolDefinition> = new Map();\n\tprivate _reloadPromise: Promise<void> | undefined;\n\tprivate _reloadRequested = false;\n\n\tprivate readonly deps: RuntimeBuilderDeps;\n\n\tconstructor(deps: RuntimeBuilderDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\tprivate async _runContextScout(\n\t\tquery: string,\n\t\tmaxTurns: number | undefined,\n\t\tartifactStore: ArtifactStore | undefined,\n\t) {\n\t\tconst cwd = this.deps.getCwd();\n\t\tconst controller = new ScoutController({\n\t\t\tresolveScoutModel: async () =>\n\t\t\t\tresolveScoutModel(\n\t\t\t\t\tthis.deps.getModelRegistry(),\n\t\t\t\t\tthis.deps.getSettingsManager().getScoutSettings().model,\n\t\t\t\t\tthis.deps.getAgentDir(),\n\t\t\t\t\t(model) => this.deps.isModelExhausted(model),\n\t\t\t\t),\n\t\t\tgetCwd: () => cwd,\n\t\t\tbuildReadOnlyTools: (toolCwd) => [\n\t\t\t\tcreateReadTool(toolCwd),\n\t\t\t\tcreateGrepTool(toolCwd, { artifactStore }),\n\t\t\t\tcreateFindTool(toolCwd, { artifactStore }),\n\t\t\t],\n\t\t\tstreamFn: this.deps.getAgent().streamFn,\n\t\t\tfileExists: (path) => existsSync(resolveCwdPath(cwd, path)),\n\t\t\tcountLines: (path) => countFileLines(resolveCwdPath(cwd, path)),\n\t\t\t// Lets the scout register itself in the reload-gate quiesce registry (see\n\t\t\t// reload-blockers.ts) for its own agentDir — the same key `_assertReloadQuiescent` reads.\n\t\t\tgetAgentDir: () => this.deps.getAgentDir(),\n\t\t});\n\t\treturn controller.run(query, maxTurns);\n\t}\n\n\t/** Whether a tool name is present in the live wrapped registry. */\n\thasTool(name: string): boolean {\n\t\treturn this._toolRegistry.has(name);\n\t}\n\n\t/** The live wrapped tool for a name, if registered (activation lookup). */\n\tgetRegisteredTool(name: string): AgentTool | undefined {\n\t\treturn this._toolRegistry.get(name);\n\t}\n\n\t/** A registered tool's normalized prompt snippet, if any. */\n\tgetToolPromptSnippet(name: string): string | undefined {\n\t\treturn this._toolPromptSnippets.get(name);\n\t}\n\n\t/** A registered tool's normalized prompt guidelines, if any. */\n\tgetToolPromptGuidelines(name: string): string[] | undefined {\n\t\treturn this._toolPromptGuidelines.get(name);\n\t}\n\n\t/**\n\t * Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.\n\t */\n\tgetAllTools(): ToolInfo[] {\n\t\treturn Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({\n\t\t\tname: definition.name,\n\t\t\tdescription: definition.description,\n\t\t\tparameters: definition.parameters,\n\t\t\tpromptGuidelines: definition.promptGuidelines,\n\t\t\tsourceInfo,\n\t\t}));\n\t}\n\n\tgetToolDefinition(name: string): ToolDefinition | undefined {\n\t\treturn this._toolDefinitions.get(name)?.definition;\n\t}\n\n\trefreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void {\n\t\tconst role = getSessionRole();\n\t\tconst previousRegistryNames = new Set(this._toolRegistry.keys());\n\t\t// Re-derive from the pre-filter REQUEST, never from agent.state.tools: the active set is\n\t\t// capability/profile-filtered, so feeding it back through setActiveToolsByName would\n\t\t// permanently shrink what a later switch to a larger model (or permissive profile) restores.\n\t\tconst previousActiveToolNames = mapToolNamesForPlatform(\n\t\t\tthis.deps.getRequestedActiveToolNames() ?? this.deps.getActiveToolNames(),\n\t\t);\n\t\tconst configuredAllowedToolNames = this.deps.getAllowedToolNames();\n\t\tconst allowedToolNames = configuredAllowedToolNames\n\t\t\t? new Set(mapToolNamesForPlatform([...configuredAllowedToolNames]))\n\t\t\t: undefined;\n\t\tconst configuredExcludedToolNames = this.deps.getExcludedToolNames();\n\t\tconst excludedToolNames = configuredExcludedToolNames\n\t\t\t? new Set(mapToolNamesForPlatform([...configuredExcludedToolNames]))\n\t\t\t: undefined;\n\t\tconst configuredToolProfileFilter = this.deps.getToolProfileFilter();\n\t\tconst toolProfileFilter = configuredToolProfileFilter\n\t\t\t? {\n\t\t\t\t\tallow: mapToolNamesForPlatform(configuredToolProfileFilter.allow),\n\t\t\t\t\tblock: mapToolNamesForPlatform(configuredToolProfileFilter.block),\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tconst isAllowedTool = (name: string): boolean => {\n\t\t\t// Strict worker UAC ceiling: wins over allow-list/exclude/profile -- a worker session\n\t\t\t// (lane-bound or dispatched) can never activate this tool no matter how permissively the\n\t\t\t// active profile or an explicit request names it. See session-role.ts.\n\t\t\tif (role === \"worker\" && WORKER_FORBIDDEN_TOOLS.has(name)) return false;\n\t\t\tif (allowedToolNames && !allowedToolNames.has(name)) return false;\n\t\t\tif (excludedToolNames?.has(name)) return false;\n\t\t\tif (!toolProfileFilter) return true;\n\t\t\tif (toolProfileFilter.allow.length > 0 && !matchesResourceProfilePattern(name, toolProfileFilter.allow)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (matchesResourceProfilePattern(name, toolProfileFilter.block)) return false;\n\t\t\treturn true;\n\t\t};\n\n\t\tconst registeredTools = this.deps.getExtensionRunner().getAllRegisteredTools();\n\t\tconst allCustomTools = [\n\t\t\t...registeredTools,\n\t\t\t...this.deps.getCustomTools().map((definition) => ({\n\t\t\t\tdefinition,\n\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: \"sdk\" }),\n\t\t\t})),\n\t\t\t// Memory subsystem provider tools (e.g. file-store's `memory` tool).\n\t\t\t...this.deps\n\t\t\t\t.getMemoryManager()\n\t\t\t\t.getToolDefinitions()\n\t\t\t\t.map((definition) => ({\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<memory:${definition.name}>`, { source: \"sdk\" }),\n\t\t\t\t})),\n\t\t].filter((tool) => isAllowedTool(tool.definition.name));\n\t\tconst definitionRegistry = new Map<string, ToolDefinitionEntry>(\n\t\t\tArray.from(this._baseToolDefinitions.entries())\n\t\t\t\t.filter(([name]) => isAllowedTool(name))\n\t\t\t\t.map(([name, definition]) => [\n\t\t\t\t\tname,\n\t\t\t\t\t{\n\t\t\t\t\t\tdefinition,\n\t\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${name}>`, { source: \"builtin\" }),\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t);\n\t\tfor (const tool of allCustomTools) {\n\t\t\tdefinitionRegistry.set(tool.definition.name, {\n\t\t\t\tdefinition: tool.definition,\n\t\t\t\tsourceInfo: tool.sourceInfo,\n\t\t\t});\n\t\t}\n\t\tthis._toolDefinitions = definitionRegistry;\n\t\tthis._toolPromptSnippets = new Map(\n\t\t\tArray.from(definitionRegistry.values())\n\t\t\t\t.map(({ definition }) => {\n\t\t\t\t\tconst snippet = this.deps.normalizePromptSnippet(definition.promptSnippet);\n\t\t\t\t\treturn snippet ? ([definition.name, snippet] as const) : undefined;\n\t\t\t\t})\n\t\t\t\t.filter((entry): entry is readonly [string, string] => entry !== undefined),\n\t\t);\n\t\tthis._toolPromptGuidelines = new Map(\n\t\t\tArray.from(definitionRegistry.values())\n\t\t\t\t.map(({ definition }) => {\n\t\t\t\t\tconst guidelines = this.deps.normalizePromptGuidelines(definition.promptGuidelines);\n\t\t\t\t\treturn guidelines.length > 0 ? ([definition.name, guidelines] as const) : undefined;\n\t\t\t\t})\n\t\t\t\t.filter((entry): entry is readonly [string, string[]] => entry !== undefined),\n\t\t);\n\t\tconst runner = this.deps.getExtensionRunner();\n\t\tconst wrappedExtensionTools = wrapRegisteredTools(allCustomTools, runner);\n\t\tconst wrappedBuiltInTools = wrapRegisteredTools(\n\t\t\tArray.from(this._baseToolDefinitions.values())\n\t\t\t\t.filter((definition) => isAllowedTool(definition.name))\n\t\t\t\t.map((definition) => ({\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${definition.name}>`, { source: \"builtin\" }),\n\t\t\t\t})),\n\t\t\trunner,\n\t\t);\n\n\t\tconst toolRegistry = new Map(wrappedBuiltInTools.map((tool) => [tool.name, tool]));\n\t\tfor (const tool of wrappedExtensionTools as AgentTool[]) {\n\t\t\ttoolRegistry.set(tool.name, tool);\n\t\t}\n\t\tthis._toolRegistry = toolRegistry;\n\n\t\tconst requestedBase = options?.activeToolNames\n\t\t\t? mapToolNamesForPlatform(options.activeToolNames)\n\t\t\t: [...previousActiveToolNames];\n\t\tconst nextActiveToolNames = requestedBase.filter((name) => isAllowedTool(name));\n\n\t\tconst persistentAutoActivated: string[] = [];\n\t\tif (allowedToolNames) {\n\t\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\t\tif (allowedToolNames.has(toolName)) {\n\t\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t\t\tpersistentAutoActivated.push(toolName);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (options?.includeAllExtensionTools) {\n\t\t\tfor (const tool of wrappedExtensionTools) {\n\t\t\t\tnextActiveToolNames.push(tool.name);\n\t\t\t\tpersistentAutoActivated.push(tool.name);\n\t\t\t}\n\t\t} else if (!options?.activeToolNames) {\n\t\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\t\tif (!previousRegistryNames.has(toolName)) {\n\t\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t\t\tpersistentAutoActivated.push(toolName);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Strict UAC: the active profile is the COMPLETE grant, so a tool the profile names\n\t\t// explicitly is itself a request for that tool — it must ACTIVATE from the registry even\n\t\t// if the session never requested it. Without this, activation is only ever the requested\n\t\t// defaults ∩ allow-list, and a profile granting non-default tools (a search-only profile's\n\t\t// grep/find) yields an empty or truncated tool set on load and /reload. A blanket \"*\"\n\t\t// stays grant-only: activation then still derives from the request/defaults above.\n\t\tconst explicitAllowPatterns = toolProfileFilter?.allow.filter((pattern) => pattern !== \"*\") ?? [];\n\t\tif (explicitAllowPatterns.length > 0) {\n\t\t\tconst boundPatterns = new Set<string>();\n\t\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\t\tif (!isAllowedTool(toolName)) continue;\n\t\t\t\tfor (const pattern of explicitAllowPatterns) {\n\t\t\t\t\tif (matchesResourceProfilePattern(toolName, [pattern])) boundPatterns.add(pattern);\n\t\t\t\t}\n\t\t\t\tif (matchesResourceProfilePattern(toolName, explicitAllowPatterns)) {\n\t\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// An explicit grant that binds to NO registered tool is a silent no-op — typo'd\n\t\t\t// name, or the owning extension is not granted/loaded. Surface it.\n\t\t\tthis.deps.setUnboundToolGrantWarnings(\n\t\t\t\texplicitAllowPatterns\n\t\t\t\t\t.filter((pattern) => !boundPatterns.has(pattern))\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(pattern) =>\n\t\t\t\t\t\t\t`profile tool grant \"${pattern}\" binds to no registered tool (typo, or the owning extension is not granted/loaded)`,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\tthis.deps.setUnboundToolGrantWarnings([]);\n\t\t}\n\n\t\t// artifact_retrieve companion auto-activation is enforced inside\n\t\t// setActiveToolsByName() itself (not duplicated here), so every activation path --\n\t\t// including the public, extension-exposed setActiveTools() -- gets the same\n\t\t// guarantee, not just this settings/profile refresh flow.\n\t\tthis.deps.setActiveToolsByName([...new Set(nextActiveToolNames)]);\n\t\t// setActiveToolsByName just stored the profile-filtered ACTIVE set as the request; restore\n\t\t// the true pre-filter request (plus non-profile auto-activations) so an internal refresh can\n\t\t// never permanently narrow it. Explicit profile grants are generation-local activations: if\n\t\t// profile A names grep and profile B later grants \"*\", A must not pin grep into B's request.\n\t\tthis.deps.setRequestedActiveToolNames([...new Set([...requestedBase, ...persistentAutoActivated])]);\n\t}\n\n\tprivate _createReloadRuntimeSnapshot(): ReloadRuntimeSnapshot {\n\t\tconst agent = this.deps.getAgent();\n\t\tconst toolProfileFilter = this.deps.getToolProfileFilter();\n\t\tconst requestedActiveToolNames = this.deps.getRequestedActiveToolNames();\n\t\treturn {\n\t\t\textensionRunner: this.deps.getExtensionRunner(),\n\t\t\tsettings: this.deps.getSettingsManager().createReloadSnapshot(),\n\t\t\tmodelRegistry: this.deps.getModelRegistry().createReloadSnapshot(),\n\t\t\tmodel: agent.state.model,\n\t\t\tthinkingLevel: agent.state.thinkingLevel,\n\t\t\tsessionLeafId: this.deps.getSessionManager().getLeafId(),\n\t\t\ttoolProfileFilter: toolProfileFilter\n\t\t\t\t? { allow: [...toolProfileFilter.allow], block: [...toolProfileFilter.block] }\n\t\t\t\t: undefined,\n\t\t\trequestedActiveToolNames: requestedActiveToolNames ? [...requestedActiveToolNames] : undefined,\n\t\t\tmemory: this.deps.createMemoryReloadSnapshot(),\n\t\t\tprofileFilter: this.deps.createProfileFilterReloadSnapshot(),\n\t\t\tunboundToolGrantWarnings: [...this.deps.getUnboundToolGrantWarnings()],\n\t\t\tbaseToolDefinitions: this._baseToolDefinitions,\n\t\t\ttoolRegistry: this._toolRegistry,\n\t\t\ttoolDefinitions: this._toolDefinitions,\n\t\t\ttoolPromptSnippets: this._toolPromptSnippets,\n\t\t\ttoolPromptGuidelines: this._toolPromptGuidelines,\n\t\t\tagentTools: agent.state.tools,\n\t\t\tagentSystemPrompt: agent.state.systemPrompt,\n\t\t\tbaseSystemPrompt: this.deps.getBaseSystemPrompt(),\n\t\t};\n\t}\n\n\tprivate _restoreReloadRuntimeSnapshot(snapshot: ReloadRuntimeSnapshot): void {\n\t\tthis.deps.getSettingsManager().restoreReloadSnapshot(snapshot.settings);\n\t\tthis.deps.getModelRegistry().restoreReloadSnapshot(snapshot.modelRegistry);\n\t\tthis.deps.setToolProfileFilter(\n\t\t\tsnapshot.toolProfileFilter\n\t\t\t\t? { allow: [...snapshot.toolProfileFilter.allow], block: [...snapshot.toolProfileFilter.block] }\n\t\t\t\t: undefined,\n\t\t);\n\t\tthis.deps.setRequestedActiveToolNames(\n\t\t\tsnapshot.requestedActiveToolNames ? [...snapshot.requestedActiveToolNames] : undefined,\n\t\t);\n\t\tthis.deps.restoreMemoryReloadSnapshot(snapshot.memory);\n\t\tthis.deps.restoreProfileFilterReloadSnapshot(snapshot.profileFilter);\n\t\tthis.deps.setUnboundToolGrantWarnings([...snapshot.unboundToolGrantWarnings]);\n\t\t// setExtensionRunner restores both _extensionRunner and _extensionRunnerRef.current together\n\t\t// (the same field-then-ref pair the host wrote at every assignment site); nothing reads the\n\t\t// ref between the two writes, so folding them is unobservable.\n\t\tthis.deps.setExtensionRunner(snapshot.extensionRunner);\n\t\tthis._baseToolDefinitions = snapshot.baseToolDefinitions;\n\t\tthis._toolRegistry = snapshot.toolRegistry;\n\t\tthis._toolDefinitions = snapshot.toolDefinitions;\n\t\tthis._toolPromptSnippets = snapshot.toolPromptSnippets;\n\t\tthis._toolPromptGuidelines = snapshot.toolPromptGuidelines;\n\t\tconst agent = this.deps.getAgent();\n\t\tagent.state.model = snapshot.model;\n\t\tagent.state.thinkingLevel = snapshot.thinkingLevel;\n\t\tagent.state.tools = snapshot.agentTools;\n\t\tagent.state.systemPrompt = snapshot.agentSystemPrompt;\n\t\tthis.deps.setBaseSystemPrompt(snapshot.baseSystemPrompt);\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tif (snapshot.sessionLeafId === null) {\n\t\t\tsessionManager.resetLeaf();\n\t\t} else {\n\t\t\tsessionManager.branch(snapshot.sessionLeafId);\n\t\t}\n\t\tthis.deps.applyExtensionBindings(snapshot.extensionRunner);\n\t}\n\n\tprivate _doctorReloadRuntime(): void {\n\t\tconst extensionErrors = this.deps.getResourceLoader().getExtensions().errors;\n\t\tif (extensionErrors.length > 0) {\n\t\t\tconst summary = extensionErrors\n\t\t\t\t.slice(0, 6)\n\t\t\t\t.map((error) => `${error.path}: ${error.error}`)\n\t\t\t\t.join(\"; \");\n\t\t\tthrow new Error(`Extension reload failed doctor: ${summary}`);\n\t\t}\n\n\t\tconst missingActiveTools = this.deps.getActiveToolNames().filter((name) => !this._toolRegistry.has(name));\n\t\tif (missingActiveTools.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Extension reload failed doctor: active tool(s) missing after reload: ${missingActiveTools.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tfor (const tool of this.deps.getAgent().state.tools) {\n\t\t\tif (!this._toolDefinitions.has(tool.name)) {\n\t\t\t\tthrow new Error(`Extension reload failed doctor: tool ${tool.name} missing from definition registry`);\n\t\t\t}\n\t\t}\n\n\t\tthis.deps.createAgentContextSnapshot();\n\t\tthis.deps.getContextUsage();\n\t}\n\n\tbuildRuntime(options: {\n\t\tactiveToolNames?: string[];\n\t\tflagValues?: Map<string, boolean | string>;\n\t\tincludeAllExtensionTools?: boolean;\n\t\tonError?: ExtensionErrorListener;\n\t}): (() => void) | undefined {\n\t\tconst settingsManager = this.deps.getSettingsManager();\n\t\tconst autoResizeImages = settingsManager.getImageAutoResize();\n\t\tconst shellCommandPrefix = settingsManager.getShellCommandPrefix();\n\t\tconst shellPath = settingsManager.getShellPath();\n\t\tconst baseToolsOverride = this.deps.getBaseToolsOverride();\n\t\t// Artifact-producing tools must not emit a \"Full output: artifact tool-output:<id>\" handle\n\t\t// that nothing can resolve. If artifact_retrieve is explicitly excluded/blocked/outside\n\t\t// an active allowlist, don't hand grep/find/run_toolkit_script an artifact store at all:\n\t\t// they fall back to their bounded preview/truncation behavior, with no payload/meta files\n\t\t// ever written and no retrieval promise made.\n\t\tconst toolArtifactStore = this.deps.isToolOrCommandAllowedByProfile(\"artifact_retrieve\")\n\t\t\t? this.deps.getToolArtifactStore()\n\t\t\t: undefined;\n\t\tconst baseToolDefinitions = baseToolsOverride\n\t\t\t? Object.fromEntries(\n\t\t\t\t\tObject.entries(baseToolsOverride).map(([name, tool]) => [name, createToolDefinitionFromAgentTool(tool)]),\n\t\t\t\t)\n\t\t\t: createAllToolDefinitions(this.deps.getCwd(), {\n\t\t\t\t\tread: { autoResizeImages },\n\t\t\t\t\tbash: { commandPrefix: shellCommandPrefix, shellPath, sessionKey: this.deps.getShellSessionKey() },\n\t\t\t\t\tgrep: { artifactStore: toolArtifactStore },\n\t\t\t\t\tfind: { artifactStore: toolArtifactStore },\n\t\t\t\t\tartifact_retrieve: { artifactStore: toolArtifactStore },\n\t\t\t\t});\n\n\t\tthis._baseToolDefinitions = new Map(\n\t\t\tObject.entries(baseToolDefinitions).map(([name, tool]) => [name, tool as ToolDefinition]),\n\t\t);\n\t\tif (!baseToolsOverride) {\n\t\t\tfor (const definition of createCoreDiagnosticsToolDefinitions(\n\t\t\t\t() => this.deps.getActiveToolNames(),\n\t\t\t\t() => this.getAllTools(),\n\t\t\t\t(messages) => this.deps.getContextGcReport(messages),\n\t\t\t\t() => this.deps.getMemoryAuditDiagnostics(),\n\t\t\t)) {\n\t\t\t\tthis._baseToolDefinitions.set(definition.name, definition);\n\t\t\t}\n\t\t\t// Hoisted above the goal-tool registration (rather than declared only inside the\n\t\t\t// worktreeSync-enabled block further below) so the SAME settings/deps factory backs both\n\t\t\t// the goal->tmux lane-first dispatch dep (`createLaneWorktree`, immediately below) and the\n\t\t\t// `worktree_sync` tool registration later in this method -- one source of truth, no drift.\n\t\t\tconst worktreeSyncSettings = settingsManager.getWorktreeSyncSettings();\n\t\t\tconst worktreeSyncEngineDeps = () =>\n\t\t\t\tbuildWorktreeSyncEngineDeps({\n\t\t\t\t\tcwd: this.deps.getCwd(),\n\t\t\t\t\tagentDir: this.deps.getAgentDir(),\n\t\t\t\t\tsettingsManager: this.deps.getSettingsManager(),\n\t\t\t\t\tsessionId: this.deps.getSessionManager().getSessionId(),\n\t\t\t\t});\n\t\t\tconst goalToolDefinition = createGoalToolDefinition({\n\t\t\t\tgetGoalState: () => this.deps.getGoalStateSnapshot(),\n\t\t\t\tsaveGoalState: (state) => {\n\t\t\t\t\tthis.deps.saveGoalStateSnapshot(state);\n\t\t\t\t},\n\t\t\t\t// kind:\"tool\" evidence refs verify against real session records.\n\t\t\t\thasToolCallId: (toolCallId) => hasAnsweredToolCallOnBranch(this.deps.getSessionManager(), toolCallId),\n\t\t\t\t// kind:\"worker\" evidence refs verify against the SAME live lane/result accessors the\n\t\t\t\t// delegate_status tool already uses below -- live wiring (these were declared optional\n\t\t\t\t// and read-defensive on the goal-tool deps type).\n\t\t\t\tgetLaneRecords: () => this.deps.getWorkerLaneRecords(),\n\t\t\t\tgetWorkerResultSnapshots: () => this.deps.getWorkerResultSnapshots(),\n\t\t\t\t// dispatch_worker's tool-layer side effect for the default (in_process) route: starts a\n\t\t\t\t// real in-process worker lane through the SAME starter the delegate tool uses (below),\n\t\t\t\t// adapted from its `{started:true;record}|{started:false;skipReason}` shape onto this\n\t\t\t\t// tool's narrower `{laneId}|{skipReason}` shape.\n\t\t\t\tstartWorkerDelegation: (args) => {\n\t\t\t\t\tconst outcome = this.deps.startWorkerDelegation({ instructions: args.instructions });\n\t\t\t\t\treturn outcome.started ? { laneId: outcome.record.laneId } : { skipReason: outcome.skipReason };\n\t\t\t\t},\n\t\t\t\t// dispatch_worker's tool-layer side effect for `dispatchTarget:\"tmux\"`: core structurally\n\t\t\t\t// invokes the SAME tmux_agent_manager fire_task call the model itself would make (no\n\t\t\t\t// extension change, no faked launch/laneId) -- see tmux-dispatch.ts's doc comment.\n\t\t\t\tdispatchTmuxWorker: (args) =>\n\t\t\t\t\tdispatchTmuxWorker(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgetToolDefinition: (name) => this.getToolDefinition(name),\n\t\t\t\t\t\t\tcreateExtensionContext: () => this.deps.getExtensionRunner().createContext(),\n\t\t\t\t\t\t\tresolveManagedLaneId: (id) => this.deps.resolveManagedLaneId(id),\n\t\t\t\t\t\t\tgetGoalId: () => this.deps.getGoalStateSnapshot()?.goalId,\n\t\t\t\t\t\t\tevaluateWorkerLaneRefusal: () => this.deps.getLaneWorkerRefusal(),\n\t\t\t\t\t\t\t// Lane-first dispatch, wired ONLY when worktree-sync is enabled -- absent otherwise,\n\t\t\t\t\t\t\t// so a disabled/default session gets the existing byte-identical fire_task params.\n\t\t\t\t\t\t\tcreateLaneWorktree: worktreeSyncSettings.enabled\n\t\t\t\t\t\t\t\t? async (laneArgs) => {\n\t\t\t\t\t\t\t\t\t\tconst created = await createLane(worktreeSyncEngineDeps(), {\n\t\t\t\t\t\t\t\t\t\t\t...(laneArgs.goalId !== undefined ? { goalId: laneArgs.goalId } : {}),\n\t\t\t\t\t\t\t\t\t\t\trequirementId: laneArgs.requirementId,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t// Never fake a lane: any non-\"ok\" engine code (max lanes, invalid key, git\n\t\t\t\t\t\t\t\t\t\t// error, ...) is refused, mapped by the caller onto the stable\n\t\t\t\t\t\t\t\t\t\t// \"worktree_create_failed\" skip reason before any fire_task call runs.\n\t\t\t\t\t\t\t\t\t\tif (created.code !== \"ok\") return { skipReason: created.code };\n\t\t\t\t\t\t\t\t\t\treturn { laneKey: created.lane.laneKey, worktreePath: created.lane.worktreePath };\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs,\n\t\t\t\t\t),\n\t\t\t\tcwd: () => this.deps.getCwd(),\n\t\t\t\t// Reuses the already branch-scoped getTaskStepsStateSnapshot dep -- no new\n\t\t\t\t// SessionManager access needed for the cross-visibility nudge.\n\t\t\t\tgetOpenTaskSteps: () => deriveOpenTaskStepRefs(this.deps.getTaskStepsStateSnapshot()),\n\t\t\t});\n\t\t\tthis._baseToolDefinitions.set(goalToolDefinition.name, goalToolDefinition);\n\t\t\tconst taskStepsToolDefinition = createTaskStepsToolDefinition({\n\t\t\t\tgetTaskStepsState: () => this.deps.getTaskStepsStateSnapshot(),\n\t\t\t\tsaveTaskStepsState: (state) => {\n\t\t\t\t\tthis.deps.saveTaskStepsStateSnapshot(state);\n\t\t\t\t},\n\t\t\t});\n\t\t\tthis._baseToolDefinitions.set(taskStepsToolDefinition.name, taskStepsToolDefinition);\n\t\t\tconst delegateToolDefinition = createDelegateToolDefinition({\n\t\t\t\tstartWorkerDelegation: (args) => this.deps.startWorkerDelegation(args),\n\t\t\t\trunWorkerDelegation: (args) => this.deps.runWorkerDelegationOnce(args),\n\t\t\t});\n\t\t\tconst delegateStatusToolDefinition = createDelegateStatusToolDefinition({\n\t\t\t\tgetLaneRecords: () => this.deps.getWorkerLaneRecords(),\n\t\t\t\tgetWorkerResultSnapshots: () => this.deps.getWorkerResultSnapshots(),\n\t\t\t\t// Durable ack persists straight through the session log; routed here (rather than\n\t\t\t\t// a new agent-session dep) because getSessionManager() is already a stable, generic\n\t\t\t\t// passthrough dep, so no other package needs to change for this to work.\n\t\t\t\tacknowledgeWorkerReview: (requestId) =>\n\t\t\t\t\tacknowledgeWorkerResultReview(this.deps.getSessionManager(), requestId),\n\t\t\t});\n\t\t\tthis._baseToolDefinitions.set(delegateToolDefinition.name, delegateToolDefinition);\n\t\t\tthis._baseToolDefinitions.set(delegateStatusToolDefinition.name, delegateStatusToolDefinition);\n\t\t\t// Registered but not default-active: probes spend tokens on the probed model, so\n\t\t\t// activation is an explicit choice (settings/profile/setActiveTools or /autonomy fitness).\n\t\t\tconst modelFitnessToolDefinition = createModelFitnessToolDefinition({\n\t\t\t\trunProbe: (args) => this.deps.runModelFitness(args),\n\t\t\t});\n\t\t\tthis._baseToolDefinitions.set(modelFitnessToolDefinition.name, modelFitnessToolDefinition);\n\t\t\tif (settingsManager.getScoutSettings().enabled) {\n\t\t\t\tconst contextScoutToolDefinition = createContextScoutToolDefinition({\n\t\t\t\t\trunScout: (input) => this._runContextScout(input.query, input.maxTurns, toolArtifactStore),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(contextScoutToolDefinition.name, contextScoutToolDefinition);\n\t\t\t}\n\t\t\tconst runToolkitScriptToolDefinition = createRunToolkitScriptToolDefinition({\n\t\t\t\tgetScripts: () => this.deps.getSettingsManager().getToolkitScripts(),\n\t\t\t\texecute: (script, scriptArgs) => executeToolkitScript({ script, scriptArgs, cwd: this.deps.getCwd() }),\n\t\t\t\tartifactStore: toolArtifactStore,\n\t\t\t\t// Reflex brain (fitness-gated local model): resolves ambiguous requests into a\n\t\t\t\t// registry pick. Best-effort — absent/unfit brain keeps the shortlist behavior.\n\t\t\t\tinterpret: async (request, scripts) => {\n\t\t\t\t\tconst model = this.deps.resolveCurationModelIfFit();\n\t\t\t\t\tif (!model) return undefined;\n\t\t\t\t\tconst completion = await this.deps.runIsolatedCompletion({\n\t\t\t\t\t\tsystemPrompt: REFLEX_INTERPRETER_SYSTEM_PROMPT,\n\t\t\t\t\t\tmessages: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: buildReflexUserPrompt(request, scripts) }],\n\t\t\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\tthinkingLevel: \"off\",\n\t\t\t\t\t\tmaxTokens: 256,\n\t\t\t\t\t\tcacheRetention: \"short\",\n\t\t\t\t\t\t// Stable per-lane synthetic affinity key so repeat ambiguous-request\n\t\t\t\t\t\t// interpretations hit the same cache-warm backend.\n\t\t\t\t\t\tlaneKind: \"toolkit-brain\",\n\t\t\t\t\t});\n\t\t\t\t\tif (completion.usage.cost.total > 0 || completion.usage.totalTokens > 0) {\n\t\t\t\t\t\t// `reportId` keyed on the ambiguous request text driving THIS interpretation —\n\t\t\t\t\t\t// stable across a retry of the same tool call, distinct across genuinely\n\t\t\t\t\t\t// different requests.\n\t\t\t\t\t\tconst reportId = deriveSpawnedUsageReportId(\n\t\t\t\t\t\t\t\"toolkit-brain\",\n\t\t\t\t\t\t\tthis.deps.getSessionManager().getSessionId(),\n\t\t\t\t\t\t\trequest,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.deps.addSpawnedUsage(completion.usage, { label: \"toolkit-brain\", reportId });\n\t\t\t\t\t}\n\t\t\t\t\treturn parseReflexPlan(completion.text);\n\t\t\t\t},\n\t\t\t});\n\t\t\tthis._baseToolDefinitions.set(runToolkitScriptToolDefinition.name, runToolkitScriptToolDefinition);\n\n\t\t\t// Worktree-sync (opt-in): the closed-action lane workflow tool, plus -- for a session\n\t\t\t// launched lane-bound (PI_WORKTREE_LANE) -- the G8/G10 lane gate wrapped UNDER the\n\t\t\t// file-mutation tools (edit/write, plus cooperative bash only for interactive lanes), so a sync_required lane fails closed with the\n\t\t\t// exact recovery step rather than relying on prompt compliance. `worktreeSyncSettings` /\n\t\t\t// `worktreeSyncEngineDeps` are hoisted above (declared before the goal-tool registration)\n\t\t\t// so the goal->tmux lane-first dispatch dep and this tool share one settings/deps source.\n\t\t\tif (worktreeSyncSettings.enabled) {\n\t\t\t\tconst worktreeSyncToolDefinition = createWorktreeSyncToolDefinition({\n\t\t\t\t\tengineDeps: worktreeSyncEngineDeps,\n\t\t\t\t\tsettings: () => this.deps.getSettingsManager().getWorktreeSyncSettings(),\n\t\t\t\t\tboundLaneKey: () => getBoundWorktreeLaneKey(),\n\t\t\t\t\tisWorker: () => isWorkerSession(),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(worktreeSyncToolDefinition.name, worktreeSyncToolDefinition);\n\n\t\t\t\tconst boundLaneKey = getBoundWorktreeLaneKey();\n\t\t\t\tif (boundLaneKey) {\n\t\t\t\t\tconst laneGate = new WorktreeLaneGate({\n\t\t\t\t\t\tlaneKey: boundLaneKey,\n\t\t\t\t\t\tengineDeps: worktreeSyncEngineDeps,\n\t\t\t\t\t\tpolicy: () => this.deps.getSettingsManager().getWorktreeSyncSettings().syncPolicy,\n\t\t\t\t\t\thardShell: isWorkerSession(),\n\t\t\t\t\t\ttrustedGateCommand: () => this.deps.getSettingsManager().getWorktreeSyncSettings().gateCommand,\n\t\t\t\t\t});\n\t\t\t\t\tfor (const gatedToolName of [\"edit\", \"write\", \"bash\"]) {\n\t\t\t\t\t\tconst original = this._baseToolDefinitions.get(gatedToolName);\n\t\t\t\t\t\tif (!original) continue;\n\t\t\t\t\t\tthis._baseToolDefinitions.set(gatedToolName, {\n\t\t\t\t\t\t\t...original,\n\t\t\t\t\t\t\texecute: async (toolCallId, params, signal, onUpdate, ctx) => {\n\t\t\t\t\t\t\t\tconst bashCommand =\n\t\t\t\t\t\t\t\t\tgatedToolName === \"bash\" ? (params as { command?: string } | undefined)?.command : undefined;\n\t\t\t\t\t\t\t\tconst rawPath =\n\t\t\t\t\t\t\t\t\tgatedToolName === \"edit\" || gatedToolName === \"write\"\n\t\t\t\t\t\t\t\t\t\t? (params as { path?: string } | undefined)?.path\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\tconst targetPath =\n\t\t\t\t\t\t\t\t\trawPath !== undefined ? resolveToCwd(rawPath, this.deps.getCwd()) : undefined;\n\t\t\t\t\t\t\t\tconst check = await laneGate.checkMutation(gatedToolName, bashCommand, targetPath);\n\t\t\t\t\t\t\t\tif (!check.allowed) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: check.message }],\n\t\t\t\t\t\t\t\t\t\tdetails: { code: check.code } as never,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn original.execute(toolCallId, params, signal, onUpdate, ctx);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst extensionsResult = this.deps.getResourceLoader().getExtensions();\n\t\tif (options.flagValues) {\n\t\t\tfor (const [name, value] of options.flagValues) {\n\t\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\t}\n\t\t}\n\t\tconst extensions = this.deps.filterExtensionsForRuntime(extensionsResult.extensions);\n\t\tconst runtimeExtensionPaths = new Set(extensions.map((extension) => extension.path));\n\t\textensionsResult.runtime.pendingProviderRegistrations =\n\t\t\textensionsResult.runtime.pendingProviderRegistrations.filter((registration) =>\n\t\t\t\truntimeExtensionPaths.has(registration.extensionPath),\n\t\t\t);\n\n\t\tconst runner = new ExtensionRunner(\n\t\t\textensions,\n\t\t\textensionsResult.runtime,\n\t\t\tthis.deps.getCwd(),\n\t\t\tthis.deps.getSessionManager(),\n\t\t\tthis.deps.getModelRegistry(),\n\t\t);\n\t\tconst offBuildErrors = options.onError ? runner.onError(options.onError) : undefined;\n\t\tthis.deps.setExtensionRunner(runner);\n\t\ttry {\n\t\t\tthis.deps.bindExtensionCore(runner);\n\t\t} catch (error) {\n\t\t\toffBuildErrors?.();\n\t\t\tthrow error;\n\t\t}\n\t\tthis.deps.applyExtensionBindings(runner);\n\n\t\tconst boundLaneKey = getBoundWorktreeLaneKey();\n\t\tconst hardLaneWorker = boundLaneKey !== undefined && isWorkerSession();\n\t\tconst explicitlyRequestedTools =\n\t\t\toptions.activeToolNames ?? (baseToolsOverride ? Object.keys(baseToolsOverride) : undefined);\n\t\tif (hardLaneWorker && explicitlyRequestedTools?.includes(\"bash\")) {\n\t\t\tthrow new Error(\"hard lane workers cannot request unrestricted bash; use typed worktree_sync actions\");\n\t\t}\n\t\tconst defaultActiveToolNames = mapToolNamesForPlatform(\n\t\t\tbaseToolsOverride\n\t\t\t\t? Object.keys(baseToolsOverride)\n\t\t\t\t: [...DEFAULT_ACTIVE_TOOL_NAMES, ...(settingsManager.getScoutSettings().enabled ? [\"context_scout\"] : [])],\n\t\t);\n\t\tconst baseActiveToolNames = mapToolNamesForPlatform(options.activeToolNames ?? defaultActiveToolNames).filter(\n\t\t\t(name) => !hardLaneWorker || name !== \"bash\",\n\t\t);\n\t\tif (\n\t\t\thardLaneWorker &&\n\t\t\tsettingsManager.getWorktreeSyncSettings().enabled &&\n\t\t\t!baseActiveToolNames.includes(\"worktree_sync\")\n\t\t) {\n\t\t\tbaseActiveToolNames.push(\"worktree_sync\");\n\t\t}\n\t\tthis.refreshToolRegistry({\n\t\t\tactiveToolNames: baseActiveToolNames,\n\t\t\tincludeAllExtensionTools: options.includeAllExtensionTools,\n\t\t});\n\t\treturn offBuildErrors;\n\t}\n\n\treload(): Promise<void> {\n\t\tif (this._reloadPromise) {\n\t\t\t// State can change while a generation is being validated. Coalesce any number of\n\t\t\t// overlapping requests into one follow-up generation instead of silently treating a\n\t\t\t// later profile/settings mutation as part of the already-snapshotted generation.\n\t\t\tthis._reloadRequested = true;\n\t\t\treturn this._reloadPromise;\n\t\t}\n\t\tconst reloadPromise = this._drainReloadRequests();\n\t\tthis._reloadPromise = reloadPromise;\n\t\treturn reloadPromise;\n\t}\n\n\tprivate async _drainReloadRequests(): Promise<void> {\n\t\tlet finalError: unknown;\n\t\ttry {\n\t\t\tdo {\n\t\t\t\tthis._reloadRequested = false;\n\t\t\t\ttry {\n\t\t\t\t\tawait this._reloadOnce();\n\t\t\t\t\tfinalError = undefined;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfinalError = error;\n\t\t\t\t}\n\t\t\t} while (this._reloadRequested);\n\t\t\tif (finalError !== undefined) throw finalError;\n\t\t} finally {\n\t\t\tthis._reloadPromise = undefined;\n\t\t\tthis._reloadRequested = false;\n\t\t}\n\t}\n\n\t/**\n\t * Unified reload-gate quiescence check: refuses the caller's action (message-prefixed by\n\t * `action`) while the agent is streaming, is compacting, or ANY background work unit is still\n\t * registered in the in-process quiesce registry — background lanes (research/worker/\n\t * model-fitness), a context-scout run, or an isolated completion (see reload-blockers.ts). Every\n\t * live-op entry point below calls this so they refuse identically; this is a synchronous refusal\n\t * (not a wait/poll) — callers retry via the same coalescing `reload()` already provides.\n\t */\n\tprivate _assertReloadQuiescent(action: string): void {\n\t\tif (this.deps.isStreaming()) {\n\t\t\tthrow new Error(`Cannot ${action} while the agent is streaming or a tool call is active`);\n\t\t}\n\t\tif (this.deps.isCompacting()) {\n\t\t\tthrow new Error(`Cannot ${action} while context compaction or branch summarization is active`);\n\t\t}\n\t\tconst units = getInFlightWorkUnits(this.deps.getAgentDir());\n\t\tif (units.length > 0) {\n\t\t\tconst summary = units.map(describeInFlightWorkUnit).join(\", \");\n\t\t\tthrow new Error(`Cannot ${action} while background work is in flight: ${summary}`);\n\t\t}\n\t}\n\n\tprivate async _reloadOnce(): Promise<void> {\n\t\tthis._assertReloadQuiescent(\"reload\");\n\t\tconst previousRunner = this.deps.getExtensionRunner();\n\t\tconst snapshot = this._createReloadRuntimeSnapshot();\n\t\t// Preserve the pre-filter tool REQUEST across the rebuild, not the capability/profile-filtered\n\t\t// active set — otherwise a reload under a small model permanently shrinks the restorable set.\n\t\tconst activeToolNames = this.deps.getRequestedActiveToolNames() ?? this.deps.getActiveToolNames();\n\t\tconst previousFlagValues = previousRunner.getFlagValues();\n\t\tconst previousExtensionProviderNames = previousRunner.getRegisteredProviderNames();\n\t\tconst reloadErrors: string[] = [];\n\t\tlet newRunner: ExtensionRunner | undefined;\n\t\tlet offReloadErrors: (() => void) | undefined;\n\t\ttry {\n\t\t\tawait this.deps.getSettingsManager().reload();\n\t\t\t// Re-derive the resource-profile tool filter from the freshly reloaded settings.\n\t\t\t// Unlike skills/prompts/themes (which re-filter through the resource loader on every\n\t\t\t// reload), the tool filter is held on the session, so without this a live edit to the\n\t\t\t// active profile's tools allow/block — or switching the active profile — would not\n\t\t\t// apply on /reload and allowed tools would stay missing.\n\t\t\tthis.deps.setToolProfileFilter(this.deps.deriveToolProfileFilter());\n\t\t\t// Resource discovery must consume this exact settings generation. A second settings read here\n\t\t\t// could combine profile state from one generation with resources from the next.\n\t\t\tawait this.deps.getResourceLoader().reload({\n\t\t\t\tfailOnExtensionErrors: true,\n\t\t\t\tdeferExtensionDispose: true,\n\t\t\t\tskipSettingsReload: true,\n\t\t\t});\n\t\t\t// Replace the previous extension-owned provider generation before binding the new one. The\n\t\t\t// bulk refresh also preserves API/OAuth streams for surviving non-extension providers.\n\t\t\tthis.deps.getModelRegistry().unregisterProviders(previousExtensionProviderNames);\n\t\t\toffReloadErrors = this.buildRuntime({\n\t\t\t\tactiveToolNames,\n\t\t\t\tflagValues: previousFlagValues,\n\t\t\t\tincludeAllExtensionTools: true,\n\t\t\t\tonError: (error) => {\n\t\t\t\t\treloadErrors.push(`${error.extensionPath} ${error.event}: ${error.error}`);\n\t\t\t\t},\n\t\t\t});\n\t\t\tnewRunner = this.deps.getExtensionRunner();\n\t\t\t// Extensions are now bound and their queued providers/models are registered, so a profile may\n\t\t\t// safely select a model contributed by an extension granted in that same profile generation.\n\t\t\tawait this.deps.reapplyActiveProfileModelSettings();\n\t\t\t// Model capability and system-prompt/tool exposure must reflect the newly selected model.\n\t\t\tthis.refreshToolRegistry({ activeToolNames, includeAllExtensionTools: true });\n\t\t\ttry {\n\t\t\t\tthis._doctorReloadRuntime();\n\t\t\t\t// Reload starts memory providers fresh; loaded extensions re-register below.\n\t\t\t\tthis.deps.clearPendingMemoryProviders();\n\t\t\t\tconst hasBindings =\n\t\t\t\t\tthis.deps.getExtensionUIContext() ||\n\t\t\t\t\tthis.deps.getExtensionCommandContextActions() ||\n\t\t\t\t\tthis.deps.getExtensionShutdownHandler() ||\n\t\t\t\t\tthis.deps.getExtensionErrorListener();\n\t\t\t\tif (hasBindings) {\n\t\t\t\t\tawait newRunner.emit({ type: \"session_start\", reason: \"reload\" });\n\t\t\t\t\tawait this.deps.extendResourcesFromExtensions(\"reload\");\n\t\t\t\t\tthis._doctorReloadRuntime();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\toffReloadErrors?.();\n\t\t\t\toffReloadErrors = undefined;\n\t\t\t}\n\t\t\tif (reloadErrors.length > 0) {\n\t\t\t\tthrow new Error(`Extension reload failed doctor: ${reloadErrors.slice(0, 6).join(\"; \")}`);\n\t\t\t}\n\t\t\tawait emitSessionShutdownEvent(previousRunner, { type: \"session_shutdown\", reason: \"reload\" });\n\t\t\tpreviousRunner.invalidate();\n\t\t\tawait this.deps.getResourceLoader().commitReload?.();\n\t\t\t// Re-derive the memory subsystem from the reloaded settings/providers.\n\t\t\tawait this.deps.initializeMemory();\n\t\t\t// This generation has fully committed (no rollback below this point), so any local\n\t\t\t// runtime the host no longer routes to under the new configuration can be stopped now.\n\t\t\tthis.deps.reconcileLocalRuntimes?.();\n\t\t} catch (error) {\n\t\t\toffReloadErrors?.();\n\t\t\tif (newRunner && newRunner !== previousRunner) {\n\t\t\t\tnewRunner.invalidate(\n\t\t\t\t\t\"This extension ctx was discarded because reload failed and Pi restored the previous valid runtime.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait this.deps.getResourceLoader().rollbackReload?.();\n\t\t\tthis._restoreReloadRuntimeSnapshot(snapshot);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Unload a single extension without full reload.\n\t * Runs the extension's session_shutdown lifecycle, unregisters its providers,\n\t * disposes its event subscriptions, and rebuilds the runtime.\n\t * Falls back to full reload on error.\n\t */\n\tasync unloadExtensionLive(extensionPath: string): Promise<void> {\n\t\tthis._assertReloadQuiescent(\"unload extension\");\n\n\t\tconst ext = this.deps.getResourceLoader().getLoadedExtension(extensionPath);\n\t\tif (!ext) {\n\t\t\treturn; // Nothing to unload\n\t\t}\n\n\t\tconst previousRunner = this.deps.getExtensionRunner();\n\t\ttry {\n\t\t\t// Run session_shutdown lifecycle for this extension only\n\t\t\tawait this.deps.getExtensionRunner().emitToExtension(ext, { type: \"session_shutdown\", reason: \"unload\" });\n\n\t\t\t// Unregister its providers (keyed by the extension's own path, as registered)\n\t\t\tconst runtime = this.deps.getResourceLoader().getExtensions().runtime;\n\t\t\tconst ownedMemoryProviders = runtime.memoryProvidersByExtension.get(ext.path) ?? new Set();\n\t\t\tconst ownedContextMemoryProviders = runtime.contextMemoryProvidersByExtension.get(ext.path) ?? new Set();\n\t\t\tfor (const name of runtime.getProvidersForExtension(ext.path)) {\n\t\t\t\truntime.unregisterProvider(name, ext.path);\n\t\t\t}\n\n\t\t\t// Dispose its event subscriptions and run disposers\n\t\t\tawait disposeExtensionEventSubscriptions([ext]);\n\n\t\t\t// Remove from loaded extensions\n\t\t\tthis.deps.getResourceLoader().removeLoadedExtension(extensionPath);\n\n\t\t\t// Rebuild runtime with new extension set\n\t\t\tconst activeToolNames = this.deps.getRequestedActiveToolNames() ?? this.deps.getActiveToolNames();\n\t\t\tconst previousFlagValues = previousRunner.getFlagValues();\n\t\t\tthis.buildRuntime({\n\t\t\t\tactiveToolNames,\n\t\t\t\tflagValues: previousFlagValues,\n\t\t\t\tincludeAllExtensionTools: true,\n\t\t\t});\n\t\t\tpreviousRunner.invalidate();\n\t\t\tconst memorySnapshot = this.deps.createMemoryReloadSnapshot();\n\t\t\tthis.deps.restoreMemoryReloadSnapshot({\n\t\t\t\t...memorySnapshot,\n\t\t\t\tpendingMemoryProviders: memorySnapshot.pendingMemoryProviders.filter(\n\t\t\t\t\t(provider) => !ownedMemoryProviders.has(provider),\n\t\t\t\t),\n\t\t\t\tpendingContextMemoryProviders: memorySnapshot.pendingContextMemoryProviders.filter(\n\t\t\t\t\t(provider) => !ownedContextMemoryProviders.has(provider),\n\t\t\t\t),\n\t\t\t});\n\t\t\truntime.memoryProvidersByExtension.delete(ext.path);\n\t\t\truntime.contextMemoryProvidersByExtension.delete(ext.path);\n\t\t\tawait this.deps.initializeMemory();\n\n\t\t\t// Notify extensions-changed listeners\n\t\t\tthis.deps.notifyExtensionsChanged();\n\t\t} catch (error) {\n\t\t\t// Fall back to full reload on error\n\t\t\ttry {\n\t\t\t\tawait this.reload();\n\t\t\t} catch {\n\t\t\t\t// Suppress nested error; original error will be thrown below\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Load a single extension without full reload.\n\t * Loads the extension with fresh import, rebuilds the runtime,\n\t * and runs the extension's session_start lifecycle.\n\t * Falls back to full reload on error.\n\t */\n\tasync loadExtensionLive(extensionPath: string): Promise<void> {\n\t\tthis._assertReloadQuiescent(\"load extension\");\n\n\t\tconst previousRunner = this.deps.getExtensionRunner();\n\t\ttry {\n\t\t\t// Load the extension with fresh import\n\t\t\tconst { extension, error } = await this.deps.getResourceLoader().loadSingleExtension(extensionPath);\n\t\t\tif (error || !extension) {\n\t\t\t\tthrow new Error(error || `Failed to load extension: ${extensionPath}`);\n\t\t\t}\n\n\t\t\t// Rebuild runtime to aggregate tools/commands/handlers/providers\n\t\t\tconst activeToolNames = this.deps.getRequestedActiveToolNames() ?? this.deps.getActiveToolNames();\n\t\t\tconst previousFlagValues = previousRunner.getFlagValues();\n\t\t\tthis.buildRuntime({\n\t\t\t\tactiveToolNames,\n\t\t\t\tflagValues: previousFlagValues,\n\t\t\t\tincludeAllExtensionTools: true,\n\t\t\t});\n\n\t\t\t// Run session_start lifecycle for the new extension only\n\t\t\tawait this.deps.getExtensionRunner().emitToExtension(extension, { type: \"session_start\", reason: \"load\" });\n\t\t\t// Activate newly registered legacy/context providers immediately. Reinitialization also\n\t\t\t// refreshes provider tools and preserves all providers owned by existing extensions.\n\t\t\tawait this.deps.initializeMemory();\n\n\t\t\t// Notify extensions-changed listeners\n\t\t\tthis.deps.notifyExtensionsChanged();\n\t\t} catch (error) {\n\t\t\t// Fall back to full reload on error\n\t\t\ttry {\n\t\t\t\tawait this.reload();\n\t\t\t} catch {\n\t\t\t\t// Suppress nested error; original error will be thrown below\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Reconcile loaded extensions with the active profile.\n\t * Loads extensions that should be enabled but aren't, and unloads extensions that shouldn't be.\n\t * Falls back to full reload if any individual load/unload fails.\n\t */\n\tasync reconcileLoadedExtensions(): Promise<void> {\n\t\tthis._assertReloadQuiescent(\"reconcile extensions\");\n\n\t\ttry {\n\t\t\t// Get all discoverable extension paths\n\t\t\tconst allDiscoverablePaths = await this.deps.getResourceLoader().getDiscoverableExtensionPaths();\n\n\t\t\t// Get the target enabled set based on profile filters\n\t\t\tconst targetEnabledSet = new Set<string>();\n\t\t\tfor (const path of allDiscoverablePaths) {\n\t\t\t\tif (this.deps.getSettingsManager().isResourceAllowedByProfile(\"extensions\", path)) {\n\t\t\t\t\ttargetEnabledSet.add(path);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Get currently loaded set\n\t\t\tconst loadedExtensions = this.deps.getResourceLoader().getExtensions().extensions;\n\t\t\tconst loadedSet = new Set<string>();\n\t\t\tfor (const ext of loadedExtensions) {\n\t\t\t\tloadedSet.add(ext.path);\n\t\t\t}\n\n\t\t\t// Collect unloads and loads\n\t\t\tconst toUnload: string[] = [];\n\t\t\tconst toLoad: string[] = [];\n\n\t\t\tfor (const path of loadedSet) {\n\t\t\t\tif (!targetEnabledSet.has(path)) {\n\t\t\t\t\ttoUnload.push(path);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const path of targetEnabledSet) {\n\t\t\t\tif (!loadedSet.has(path)) {\n\t\t\t\t\ttoLoad.push(path);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply unloads first, then loads, to minimize churn\n\t\t\t// Collect errors but continue through all operations\n\t\t\tconst errors: Error[] = [];\n\n\t\t\tfor (const path of toUnload) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.unloadExtensionLive(path);\n\t\t\t\t} catch (error) {\n\t\t\t\t\terrors.push(error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const path of toLoad) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.loadExtensionLive(path);\n\t\t\t\t} catch (error) {\n\t\t\t\t\terrors.push(error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If any errors occurred, throw the first one (already fell back to full reload in load/unload)\n\t\t\tif (errors.length > 0) {\n\t\t\t\tthrow errors[0];\n\t\t\t}\n\n\t\t\t// Single notification at the end\n\t\t\tthis.deps.notifyExtensionsChanged();\n\t\t} catch (error) {\n\t\t\t// Fall back to full reload on error\n\t\t\ttry {\n\t\t\t\tawait this.reload();\n\t\t\t} catch {\n\t\t\t\t// Suppress nested error; original error will be thrown below\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\nexport async function resolveScoutModel(\n\tmodelRegistry: ModelRegistry,\n\tmodelSetting: string,\n\tagentDir: string,\n\tisModelExhausted: (model: Model<Api>) => boolean = () => false,\n) {\n\tconst model =\n\t\tmodelSetting === \"auto\"\n\t\t\t? findFastContextModel(modelRegistry)\n\t\t\t: resolveCliModel({ cliModel: modelSetting, modelRegistry }).model;\n\tif (!model) {\n\t\treturn { failure: `no scout model matched ${modelSetting}` };\n\t}\n\tif (isModelExhausted(model)) {\n\t\treturn { failure: `${model.provider}/${model.id} exhausted: quota` };\n\t}\n\tif (modelSetting === \"auto\") {\n\t\tconst modelRef = `${model.provider}/${model.id}`;\n\t\tconst fitness = FitnessStore.forAgentDir(agentDir)\n\t\t\t.getForHost()\n\t\t\t.find((entry) => entry.model === modelRef);\n\t\tconst verdict = evaluateSurfaceFitness(\"scout_auto\", fitness?.report);\n\t\tif (!verdict.fit) {\n\t\t\treturn verdict.reason === \"unprobed\"\n\t\t\t\t? { failure: `${modelRef} unprobed — run /fitness before auto-selection` }\n\t\t\t\t: { failure: `${modelRef} unfit (${verdict.lane} ${verdict.succeeded}/${verdict.total})` };\n\t\t}\n\t}\n\tconst auth = await modelRegistry.getApiKeyAndHeaders(model);\n\tif (!auth.ok) {\n\t\treturn { failure: auth.error ?? `no usable auth for scout model ${model.provider}/${model.id}` };\n\t}\n\treturn { model, apiKey: auth.apiKey, headers: auth.headers };\n}\n\nfunction findFastContextModel(modelRegistry: ModelRegistry) {\n\treturn modelRegistry.getAll().find((model) => {\n\t\tconst text = `${model.provider}/${model.id} ${model.name}`.toLowerCase();\n\t\treturn text.includes(\"fastcontext\");\n\t});\n}\n\nfunction resolveCwdPath(cwd: string, path: string): string {\n\treturn isAbsolute(path) ? path : join(cwd, path);\n}\n\nfunction countFileLines(path: string): number | undefined {\n\ttry {\n\t\treturn readFileSync(path, \"utf8\").split(/\\r?\\n/).length;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime-builder.js","sourceRoot":"","sources":["../../src/core/runtime-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAc7C,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAGpF,OAAO,EAAE,oCAA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AK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAAA,CACpC,CAAC,CAAC;AAAA,CACH;AAED,SAAS,cAAc,CAAC,GAAW,EAAE,IAAY,EAAU;IAC1D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAAA,CACjD;AAED,SAAS,cAAc,CAAC,IAAY,EAAsB;IACzD,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AAAA,CACD","sourcesContent":["/**\n * Runtime build & reload: the session's tool-registry assembly and the self-modification-safe\n * extension reload path. Owns building the base tool definitions, wrapping them into the live tool\n * registry (`_refreshToolRegistry`), constructing the {@link ExtensionRunner} for a rebuilt runtime\n * (`_buildRuntime`), and the repo's self-modification safety crown jewel: the preflight-guarded\n * `reload()` with its snapshot / doctor / commit-or-rollback sequence, plus the single-extension\n * live load/unload/reconcile operations that rebuild the runtime in place.\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). Owns ONLY the tool-registry\n * state — the base tool definitions, the wrapped tool registry, the definition registry, and the\n * per-tool prompt snippet/guideline maps. Everything else the build & reload touch — the live\n * {@link ExtensionRunner}, the agent's tool/system-prompt state, the base system prompt, the\n * resource loader, the session/settings managers, the model registry, the profile tool filter and\n * its warning sinks, the requested-active-tool-names request, the memory subsystem, and the many\n * host callbacks the rebuilt tools/runtime are wired to — is reached through narrow deps accessors\n * that read and write the SAME storage the host owns today.\n *\n * Snapshot-ownership boundary (deliberate, load-bearing for reload safety): the reload snapshot\n * spans state owned by OTHER collaborators — the extension runner and its ref, `agent.state.tools`\n * / `agent.state.systemPrompt`, and `_baseSystemPrompt`. Those are captured and restored through\n * {@link RuntimeBuilderDeps} get/set accessors so save/restore mutate exactly the host/agent fields\n * they mutated before extraction; only the five tool-registry maps are captured by direct field\n * reference here (this builder owns them). The `_extensionRunnerRef.current` update folds into\n * {@link RuntimeBuilderDeps.setExtensionRunner} (the same field-then-ref pattern the host used at\n * every assignment site), so no observer runs between the two writes.\n *\n * Host-binding boundary (deliberate): `_bindExtensionCore` — which exposes the SESSION's own public\n * surface (sendMessage, setModel, compact, abort, reload, …) to the extension runner — stays\n * host-side and is invoked from {@link buildRuntime} via {@link RuntimeBuilderDeps.bindExtensionCore};\n * it is host identity, not build logic, and moving it would only re-export ~30 host methods through\n * deps to hand them straight back. The host keeps one-line delegations for the public reload /\n * load / unload / reconcile API and for `getAllTools` / `getToolDefinition`, and a private\n * `_refreshToolRegistry` delegation for its internal callers.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { isAbsolute, join } from \"node:path\";\nimport type { Agent, AgentContext, AgentMessage, AgentTool, ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { Api, Model, Usage } from \"@caupulican/pi-ai\";\nimport type {\n\tIsolatedCompletionOptions,\n\tIsolatedCompletionResult,\n\tWorkerDelegationRunOutcome,\n} from \"./agent-session-contracts.ts\";\nimport type { WorkerClaim } from \"./autonomy/contracts.ts\";\nimport type { LaneRecord } from \"./autonomy/lane-tracker.ts\";\nimport type { ArtifactStore } from \"./context/context-artifacts.ts\";\nimport type { MemoryPromptInclusionReport, MemoryRetrievalDiagnostics } from \"./context/memory-diagnostics.ts\";\nimport type { ContextGcReport } from \"./context-gc.ts\";\nimport { DEFAULT_ACTIVE_TOOL_NAMES, mapToolNamesForPlatform } from \"./default-tool-surface.ts\";\nimport { acknowledgeWorkerClaimReview } from \"./delegation/session-worker-claim.ts\";\nimport type { WorkerDelegationRequest } from \"./delegation/worker-delegation-request.ts\";\nimport type { ExtensionImportAuthority } from \"./extension-import-authority.ts\";\nimport { createCoreDiagnosticsToolDefinitions } from \"./extensions/builtin.ts\";\nimport {\n\ttype ContextUsage,\n\ttype Extension,\n\ttype ExtensionCommandContextActions,\n\ttype ExtensionErrorListener,\n\tExtensionRunner,\n\ttype ExtensionUIContext,\n\ttype ShutdownHandler,\n\ttype ToolDefinition,\n\ttype ToolInfo,\n\twrapRegisteredTools,\n} from \"./extensions/index.ts\";\nimport { disposeExtensionEventSubscriptions } from \"./extensions/loader.ts\";\nimport { emitSessionShutdownEvent } from \"./extensions/runner.ts\";\nimport type { GoalStateRevision } from \"./goals/goal-lifecycle.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport type { OpenTaskStepRef } from \"./goals/goal-tool-core.ts\";\nimport type { MemoryManager } from \"./memory/memory-manager.ts\";\nimport type { MemoryControllerReloadSnapshot } from \"./memory-controller.ts\";\nimport type { LaneWorkerRefusal } from \"./model-capability.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport { resolveCliModel } from \"./model-resolver.ts\";\nimport { evaluateSurfaceFitness } from \"./model-router/fitness-gate.ts\";\nimport { FitnessStore } from \"./models/fitness-store.ts\";\nimport type { OrchestrationProfile } from \"./orchestration/contracts.ts\";\nimport type { ProfileFilterReloadSnapshot } from \"./profile-filter-controller.ts\";\nimport { describeInFlightWorkUnit, getInFlightWorkUnits } from \"./reload-blockers.ts\";\nimport type { ModelFitnessReport } from \"./research/model-fitness.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport { ScoutController } from \"./scout-controller.ts\";\nimport { wrapToolWithCredentialExposureGuard } from \"./secrets/credential-exposure-guard.ts\";\nimport { SecretVault } from \"./secrets/secret-vault.ts\";\nimport type { SessionImageStore } from \"./session-image-store.ts\";\nimport { getSessionRole, isWorkerSession, WORKER_FORBIDDEN_TOOLS } from \"./session-role.ts\";\nimport {\n\tmatchesResourceProfilePattern,\n\ttype ResourceProfileFilterSettings,\n\ttype SettingsManager,\n} from \"./settings-manager.ts\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.ts\";\nimport { projectOpenTaskSteps } from \"./tasks/task-projection.ts\";\nimport type { TaskStepsState } from \"./tasks/task-state.ts\";\nimport {\n\tbuildReflexUserPrompt,\n\tparseReflexPlan,\n\tREFLEX_INTERPRETER_SYSTEM_PROMPT,\n} from \"./toolkit/reflex-interpreter.ts\";\nimport { executeToolkitScript } from \"./toolkit/script-runner.ts\";\nimport { createAskQuestionToolDefinition } from \"./tools/ask-question.ts\";\nimport { createContextScoutToolDefinition } from \"./tools/context-scout.ts\";\nimport { createDelegateToolDefinition } from \"./tools/delegate.ts\";\nimport { createDelegateStatusToolDefinition } from \"./tools/delegate-status.ts\";\nimport { createFindTool } from \"./tools/find.ts\";\nimport { createGoalToolDefinition } from \"./tools/goal.ts\";\nimport { createGrepTool } from \"./tools/grep.ts\";\nimport { allToolNames, createToolDefinition, type ToolsOptions } from \"./tools/index.ts\";\nimport { createModelFitnessToolDefinition } from \"./tools/model-fitness.ts\";\nimport { resolveToCwd } from \"./tools/path-utils.ts\";\nimport { createReadTool } from \"./tools/read.ts\";\nimport { createRunProcessToolDefinition } from \"./tools/run-process.ts\";\nimport { createRunToolkitScriptToolDefinition } from \"./tools/run-toolkit-script.ts\";\nimport { createSecretStoreToolDefinition } from \"./tools/secret-store.ts\";\nimport { disposePersistentShellSession } from \"./tools/shell-session.ts\";\nimport { createTaskStepsToolDefinition } from \"./tools/task-steps.ts\";\nimport { dispatchTmuxWorker } from \"./tools/tmux-dispatch.ts\";\nimport { createToolDefinitionFromAgentTool } from \"./tools/tool-definition-wrapper.ts\";\nimport { disposeWindowsShellState } from \"./tools/windows-shell-state.ts\";\nimport { createWorktreeSyncToolDefinition } from \"./tools/worktree-sync.ts\";\nimport { createLane } from \"./worktree-sync/git-engine.ts\";\nimport { WorktreeLaneGate } from \"./worktree-sync/lane-gate.ts\";\nimport { buildWorktreeSyncEngineDeps, getBoundWorktreeLaneKey } from \"./worktree-sync/runtime.ts\";\n\ninterface ToolDefinitionEntry {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\n/**\n * Deterministic `addSpawnedUsage` reportId: `kind` + session id + a content hash of `identity`\n * (never `Date.now`/random). Same identity on a retry of the same logical work unit yields the same\n * id, so the ledger's `seenSubagentReportIds` dedupe catches a duplicate report instead of\n * double-counting spend.\n */\nfunction deriveSpawnedUsageReportId(kind: string, sessionId: string, identity: string): string {\n\tconst digest = createHash(\"sha256\").update(identity).digest(\"hex\").slice(0, 16);\n\treturn `${kind}:${sessionId}:${digest}`;\n}\n\n/**\n * Is `toolCallId` a real, answered tool call on `sessionManager`'s active branch? A\n * toolCallId is \"real\" iff a toolResult message on that branch responded to it -- the same\n * toolResult/toolCallId match `context-pipeline.ts`'s `_buildSessionEntryIdLookup` uses, and\n * branch-scoped (via `getBranch()`) so a sibling branch's tool calls never count. Exported (pure,\n * no `this`) so the goal tool's `hasToolCallId` wiring below is directly testable against a real\n * `SessionManager` without constructing the whole `RuntimeBuilder`.\n */\nexport function hasAnsweredToolCallOnBranch(sessionManager: SessionManager, toolCallId: string): boolean {\n\treturn sessionManager\n\t\t.getBranch()\n\t\t.some(\n\t\t\t(entry) =>\n\t\t\t\tentry.type === \"message\" && entry.message.role === \"toolResult\" && entry.message.toolCallId === toolCallId,\n\t\t);\n}\n\n/**\n * Goal-tool adapter over the canonical open-task projection. Exported (pure, no `this`) so the\n * production `getOpenTaskSteps` wiring below remains directly testable without another filter.\n */\nexport function deriveOpenTaskStepRefs(taskStepsState: TaskStepsState | undefined): OpenTaskStepRef[] {\n\treturn projectOpenTaskSteps(taskStepsState).map((step) => ({\n\t\tid: step.id,\n\t\tcontent: step.content,\n\t\t...(step.requirementIds?.length ? { requirementIds: step.requirementIds } : {}),\n\t}));\n}\n\ninterface ReloadRuntimeSnapshot {\n\textensionRunner: ExtensionRunner;\n\tsettings: ReturnType<SettingsManager[\"createReloadSnapshot\"]>;\n\tmodelRegistry: ReturnType<ModelRegistry[\"createReloadSnapshot\"]>;\n\tmodel: Model<Api>;\n\tthinkingLevel: ThinkingLevel;\n\tsessionLeafId: string | null;\n\ttoolProfileFilter: Required<ResourceProfileFilterSettings> | undefined;\n\trequestedActiveToolNames: string[] | undefined;\n\tmemory: MemoryControllerReloadSnapshot;\n\tprofileFilter: ProfileFilterReloadSnapshot;\n\tunboundToolGrantWarnings: string[];\n\tbaseToolDefinitions: Map<string, ToolDefinition>;\n\ttoolRegistry: Map<string, AgentTool>;\n\ttoolDefinitions: Map<string, ToolDefinitionEntry>;\n\ttoolPromptSnippets: Map<string, string>;\n\ttoolPromptGuidelines: Map<string, string[]>;\n\tagentTools: AgentTool[];\n\tagentSystemPrompt: string;\n\tbaseSystemPrompt: string;\n}\n\nexport interface RuntimeBuilderDeps {\n\t/** Live agent — the snapshot/doctor read and restore its `state.tools` / `state.systemPrompt`. */\n\tgetAgent(): Agent;\n\t/** Workspace root, passed to the tool-definition factory and the extension runner. */\n\tgetCwd(): string;\n\t/** Per-agent persistent shell session key; stable across reloads so the shell survives them. */\n\tgetShellSessionKey(): string;\n\t/** Agent state root, including the host-keyed fitness store. */\n\tgetAgentDir(): string;\n\t/** Session log, passed to the extension runner. */\n\tgetSessionManager(): SessionManager;\n\t/** Tool/shell/toolkit/resource settings + reload target (settingsManager.reload()). */\n\tgetSettingsManager(): SettingsManager;\n\t/** Model registry, passed to the extension runner and profile model re-resolution. */\n\tgetModelRegistry(): ModelRegistry;\n\t/** Session-scoped provider/model quota exhaustion guard. */\n\tisModelExhausted(model: Model<Api>): boolean;\n\t/** Extension/skill/prompt/theme discovery + the reload/commit/rollback generation swap. */\n\tgetResourceLoader(): ResourceLoader;\n\n\t/** Live extension runner (host-owned; pervasive). */\n\tgetExtensionRunner(): ExtensionRunner;\n\t/** Store the extension runner AND update the Agent's mutable `_extensionRunnerRef.current` (both together). */\n\tsetExtensionRunner(runner: ExtensionRunner): void;\n\t/** Base (extension-free) system prompt; captured/restored by the reload snapshot. */\n\tgetBaseSystemPrompt(): string;\n\tsetBaseSystemPrompt(prompt: string): void;\n\n\t/** SDK-provided plain tools, synthesized into the registry alongside built-ins. */\n\tgetCustomTools(): ToolDefinition[];\n\t/** Optional plain-tool override; when set, the built-in factory + core diagnostics are skipped. */\n\tgetBaseToolsOverride(): Record<string, AgentTool> | undefined;\n\t/** Pre-filter tool REQUEST (never the capability/profile-filtered active set) preserved across a rebuild. */\n\tgetRequestedActiveToolNames(): string[] | undefined;\n\tsetRequestedActiveToolNames(names: string[] | undefined): void;\n\n\t/** Resource-profile tool allow/block filter + the raw allow/exclude sets applied during registry build. */\n\tgetToolProfileFilter(): Required<ResourceProfileFilterSettings> | undefined;\n\tsetToolProfileFilter(filter: Required<ResourceProfileFilterSettings> | undefined): void;\n\tgetAllowedToolNames(): Set<string> | undefined;\n\t/** Immutable active orchestration profile; absent sessions never construct run_process. */\n\tgetOrchestrationProfile?(): OrchestrationProfile | undefined;\n\tgetExcludedToolNames(): Set<string> | undefined;\n\t/** Re-derive the profile tool filter from freshly reloaded settings (reload only). */\n\tderiveToolProfileFilter(): Required<ResourceProfileFilterSettings>;\n\t/** True when a tool/command name survives the active profile's allow/block + user allow/exclude. */\n\tisToolOrCommandAllowedByProfile(name: string): boolean;\n\t/** Import-boundary decision for an exact owner load or an automatic profile-driven load. */\n\tisExtensionPathAllowed(path: string, authority: ExtensionImportAuthority, baseDir?: string): boolean;\n\t/** Filter the loaded extensions through the active resource profile (records inert/denied warnings host-side). */\n\tfilterExtensionsForRuntime(extensions: Extension[], explicitLiveExtensionPaths?: ReadonlySet<string>): Extension[];\n\t/** Sink for the unbound-profile-tool-grant warnings surfaced in /context. */\n\tsetUnboundToolGrantWarnings(warnings: string[]): void;\n\tgetUnboundToolGrantWarnings(): string[];\n\tcreateProfileFilterReloadSnapshot(): ProfileFilterReloadSnapshot;\n\trestoreProfileFilterReloadSnapshot(snapshot: ProfileFilterReloadSnapshot): void;\n\n\t/** Currently-active tool names (reads agent.state.tools; the pre-filter fallback for a rebuild). */\n\tgetActiveToolNames(): string[];\n\t/** Apply the recomputed active set (capability filter + companion auto-activation live here). */\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t/** Normalize a tool's prompt snippet / guidelines through the system-prompt builder. */\n\tnormalizePromptSnippet(text: string | undefined): string | undefined;\n\tnormalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\n\t/** Wire the session's own public surface into a freshly-built runner (host identity; stays host-side). */\n\tbindExtensionCore(runner: ExtensionRunner): void;\n\t/** Re-apply UI context / mode / command-context / error subscription to a runner. */\n\tapplyExtensionBindings(runner: ExtensionRunner): void;\n\t/** Re-run resource discovery for the active extensions (reload only). */\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\t/** Re-apply the active profile's model/thinking from reloaded settings (reload only). */\n\treapplyActiveProfileModelSettings(): Promise<void>;\n\t/** Notify extensions-changed listeners after a single-extension live op. */\n\tnotifyExtensionsChanged(): void;\n\n\t/** Session-scoped tool-output artifact store for artifact-producing tools and artifact_retrieve (gated on the profile). */\n\tgetToolArtifactStore(): ArtifactStore;\n\t/** Lazily resolve durable image storage only for a persisted/configured session. */\n\tgetSessionImageStore(): Pick<SessionImageStore, \"retainContent\"> | undefined;\n\n\t/** Live memory manager — its provider tools join the registry. */\n\tgetMemoryManager(): MemoryManager;\n\t/** Memory retrieval + prompt-inclusion diagnostics for the core diagnostics tool. */\n\tgetMemoryAuditDiagnostics(): { retrieval: MemoryRetrievalDiagnostics; promptInclusion: MemoryPromptInclusionReport };\n\t/** Drop extension-contributed pending memory providers before a reload re-registers them. */\n\tclearPendingMemoryProviders(): void;\n\tcreateMemoryReloadSnapshot(): MemoryControllerReloadSnapshot;\n\trestoreMemoryReloadSnapshot(snapshot: MemoryControllerReloadSnapshot): void;\n\t/** (Re)derive the memory subsystem from reloaded settings/providers. */\n\tinitializeMemory(): Promise<void>;\n\n\t/** Goal-tool state accessors. */\n\tgetGoalStateSnapshot(): GoalState | undefined;\n\tsaveGoalStateSnapshot(state: GoalState, expected?: GoalStateRevision): string;\n\t/** Native task-step state accessors. */\n\tgetTaskStepsStateSnapshot(): TaskStepsState | undefined;\n\tsaveTaskStepsStateSnapshot(state: TaskStepsState): string;\n\t/** Context-gc report for the core diagnostics tool. */\n\tgetContextGcReport(messages: AgentMessage[]): ContextGcReport;\n\t/** Non-blocking worker-delegation starter for the delegate tool. */\n\tstartWorkerDelegation(\n\t\trequest: WorkerDelegationRequest,\n\t): { started: false; skipReason: string } | { started: true; record: LaneRecord };\n\tgetOrchestrationProfileCatalog(): Array<{ profileId: string; role: string; description: string }>;\n\tgetWorkerLaneRecords(): LaneRecord[];\n\tgetWorkerClaimSnapshots(): WorkerClaim[];\n\t/** Confirm a managed dispatch's caller-stable canonical lane id was registered durably before the\n\t * goal binds it (`BackgroundLaneController.resolveManagedLaneId`). */\n\tresolveManagedLaneId(callerLaneId: string): string | undefined;\n\t/** Worker-delegation runner for SDK/test through-completion calls. */\n\trunWorkerDelegationOnce(request: WorkerDelegationRequest): Promise<WorkerDelegationRunOutcome>;\n\t/** Model-fitness probe for the model_fitness tool. `toolCallId` is the idempotency token\n\t * for spawned-usage reportId — present only for the LLM tool-call path (see model-fitness.ts). */\n\trunModelFitness(args: {\n\t\tmodel: string;\n\t\ttrials?: number;\n\t\ttoolCallId?: string;\n\t}): Promise<{ started: true; model: string; report: ModelFitnessReport } | { started: false; skipReason: string }>;\n\t/** Fitness-gated reflex-brain model resolver (run_toolkit_script interpretation). */\n\tresolveCurationModelIfFit(): Model<Api> | undefined;\n\t/** One-shot, tool-less LLM call — the reflex-brain interpreter rides this. */\n\trunIsolatedCompletion(opts: IsolatedCompletionOptions): Promise<IsolatedCompletionResult>;\n\t/** Roll reflex-brain spend into spawned-usage accounting. `reportId` is REQUIRED: every\n\t * caller derives a stable id from the work unit's identity so a retry cannot double-count. */\n\taddSpawnedUsage(\n\t\tusage: Usage,\n\t\topts: { label?: string; sourceSessionId?: string; reportId: string },\n\t): string | undefined;\n\t/** Whether the CURRENT session model may drive a worktree-sync lane worker (`AgentSession.\n\t * getLaneWorkerRefusal`) -- consulted BEFORE a goal→tmux dispatch so an ineligible model's\n\t * dispatch is refused before any lane/pane side effect (`tools/tmux-dispatch.ts`'s\n\t * `evaluateWorkerLaneRefusal`). `undefined` means eligible. */\n\tgetLaneWorkerRefusal(): LaneWorkerRefusal | undefined;\n\n\t/** Post-rebuild doctor helpers (validate the rebuilt runtime can render a context). */\n\tcreateAgentContextSnapshot(): AgentContext;\n\tgetContextUsage(): ContextUsage | undefined;\n\n\t/** Reload/live-op preflight refusal guards (identical refusal behavior; host-checked). */\n\tisStreaming(): boolean;\n\tisCompacting(): boolean;\n\n\t/** Extension bindings present — gate for re-emitting session_start on reload. */\n\tgetExtensionUIContext(): ExtensionUIContext | undefined;\n\tgetExtensionCommandContextActions(): ExtensionCommandContextActions | undefined;\n\tgetExtensionShutdownHandler(): ShutdownHandler | undefined;\n\tgetExtensionErrorListener(): ExtensionErrorListener | undefined;\n\n\t/**\n\t * Stop any pi-spawned local (Ollama/Transformers/prism llama.cpp) runtime the host's\n\t * LocalRuntimeController is holding open that no longer applies under the just-reloaded\n\t * configuration — e.g. `LocalRuntimeController.reconcile(eligibleModels)`, with `eligibleModels`\n\t * derived from whatever the host still routes to post-reload (foreground model + any configured\n\t * router tier). Called ONLY after `_reloadOnce()` commits successfully — never on a rolled-back\n\t * reload, since a rollback restores the PREVIOUS configuration and nothing became ineligible.\n\t * Optional: a host that hasn't wired a LocalRuntimeController through here yet sees no behavior\n\t * change — a local runtime this builder doesn't know about is simply left alone, never guessed at.\n\t */\n\treconcileLocalRuntimes?(): void;\n}\n\ninterface RuntimeToolAccessPolicy {\n\tallowedToolNames: ReadonlySet<string> | undefined;\n\ttoolProfileFilter: Required<ResourceProfileFilterSettings> | undefined;\n\tallows(name: string): boolean;\n}\n\n/**\n * Owns the tool-registry build and the self-modification-safe extension reload extracted from\n * {@link AgentSession}. See the module header for the snapshot-ownership and host-binding boundaries.\n */\nexport class RuntimeBuilder {\n\t// Tool registry for extension getTools/setTools\n\tprivate _toolRegistry: Map<string, AgentTool> = new Map();\n\tprivate _toolDefinitions: Map<string, ToolDefinitionEntry> = new Map();\n\tprivate _toolPromptSnippets: Map<string, string> = new Map();\n\tprivate _toolPromptGuidelines: Map<string, string[]> = new Map();\n\tprivate _baseToolDefinitions: Map<string, ToolDefinition> = new Map();\n\t/** Exact extensions the owner approved through the live-load API. Discovery never populates this set. */\n\tprivate readonly _explicitLiveExtensionPaths = new Set<string>();\n\tprivate _reloadPromise: Promise<void> | undefined;\n\tprivate _reloadRequested = false;\n\tprivate readonly _secretVault: SecretVault;\n\n\tprivate readonly deps: RuntimeBuilderDeps;\n\n\tconstructor(deps: RuntimeBuilderDeps) {\n\t\tthis.deps = deps;\n\t\tthis._secretVault = new SecretVault({\n\t\t\tagentDir: deps.getAgentDir(),\n\t\t\tonEnvironmentChanged: () => {\n\t\t\t\tconst sessionKey = deps.getShellSessionKey();\n\t\t\t\tdisposePersistentShellSession(sessionKey);\n\t\t\t\tdisposeWindowsShellState(sessionKey);\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Resolve the construction and activation policy once for a runtime generation. This is the\n\t * UAC choke point: callers must consult it before invoking a tool factory, not merely before\n\t * placing an already-created definition in the live registry.\n\t */\n\tprivate _createToolAccessPolicy(): RuntimeToolAccessPolicy {\n\t\tconst role = getSessionRole();\n\t\tconst configuredAllowedToolNames = this.deps.getAllowedToolNames();\n\t\tconst allowedToolNames = configuredAllowedToolNames\n\t\t\t? new Set(mapToolNamesForPlatform([...configuredAllowedToolNames]))\n\t\t\t: undefined;\n\t\tconst configuredExcludedToolNames = this.deps.getExcludedToolNames();\n\t\tconst excludedToolNames = configuredExcludedToolNames\n\t\t\t? new Set(mapToolNamesForPlatform([...configuredExcludedToolNames]))\n\t\t\t: undefined;\n\t\tconst configuredToolProfileFilter = this.deps.getToolProfileFilter();\n\t\tconst toolProfileFilter = configuredToolProfileFilter\n\t\t\t? {\n\t\t\t\t\tallow: mapToolNamesForPlatform(configuredToolProfileFilter.allow),\n\t\t\t\t\tblock: mapToolNamesForPlatform(configuredToolProfileFilter.block),\n\t\t\t\t}\n\t\t\t: undefined;\n\t\treturn {\n\t\t\tallowedToolNames,\n\t\t\ttoolProfileFilter,\n\t\t\tallows: (name) => {\n\t\t\t\t// Strict worker UAC ceiling wins over every explicit grant.\n\t\t\t\tif (role === \"worker\" && WORKER_FORBIDDEN_TOOLS.has(name)) return false;\n\t\t\t\tif (allowedToolNames && !allowedToolNames.has(name)) return false;\n\t\t\t\tif (excludedToolNames?.has(name)) return false;\n\t\t\t\tif (!toolProfileFilter) return true;\n\t\t\t\tif (toolProfileFilter.allow.length > 0 && !matchesResourceProfilePattern(name, toolProfileFilter.allow)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (matchesResourceProfilePattern(name, toolProfileFilter.block)) return false;\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate async _runContextScout(\n\t\tquery: string,\n\t\tmaxTurns: number | undefined,\n\t\tartifactStore: ArtifactStore | undefined,\n\t) {\n\t\tconst cwd = this.deps.getCwd();\n\t\tconst controller = new ScoutController({\n\t\t\tresolveScoutModel: async () =>\n\t\t\t\tresolveScoutModel(\n\t\t\t\t\tthis.deps.getModelRegistry(),\n\t\t\t\t\tthis.deps.getSettingsManager().getScoutSettings().model,\n\t\t\t\t\tthis.deps.getAgentDir(),\n\t\t\t\t\t(model) => this.deps.isModelExhausted(model),\n\t\t\t\t),\n\t\t\tgetCwd: () => cwd,\n\t\t\tbuildReadOnlyTools: (toolCwd) => [\n\t\t\t\twrapToolWithCredentialExposureGuard(createReadTool(toolCwd), toolCwd, this._secretVault),\n\t\t\t\twrapToolWithCredentialExposureGuard(createGrepTool(toolCwd, { artifactStore }), toolCwd, this._secretVault),\n\t\t\t\twrapToolWithCredentialExposureGuard(createFindTool(toolCwd, { artifactStore }), toolCwd, this._secretVault),\n\t\t\t],\n\t\t\tstreamFn: this.deps.getAgent().streamFn,\n\t\t\tfileExists: (path) => existsSync(resolveCwdPath(cwd, path)),\n\t\t\tcountLines: (path) => countFileLines(resolveCwdPath(cwd, path)),\n\t\t\t// Lets the scout register itself in the reload-gate quiesce registry (see\n\t\t\t// reload-blockers.ts) for its own agentDir — the same key `_assertReloadQuiescent` reads.\n\t\t\tgetAgentDir: () => this.deps.getAgentDir(),\n\t\t});\n\t\treturn controller.run(query, maxTurns);\n\t}\n\n\t/** Whether a tool name is present in the live wrapped registry. */\n\thasTool(name: string): boolean {\n\t\treturn this._toolRegistry.has(name);\n\t}\n\n\t/** The live wrapped tool for a name, if registered (activation lookup). */\n\tgetRegisteredTool(name: string): AgentTool | undefined {\n\t\treturn this._toolRegistry.get(name);\n\t}\n\n\t/** A registered tool's normalized prompt snippet, if any. */\n\tgetToolPromptSnippet(name: string): string | undefined {\n\t\treturn this._toolPromptSnippets.get(name);\n\t}\n\n\t/** A registered tool's normalized prompt guidelines, if any. */\n\tgetToolPromptGuidelines(name: string): string[] | undefined {\n\t\treturn this._toolPromptGuidelines.get(name);\n\t}\n\n\t/**\n\t * Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.\n\t */\n\tgetAllTools(): ToolInfo[] {\n\t\treturn Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({\n\t\t\tname: definition.name,\n\t\t\tdescription: definition.description,\n\t\t\tparameters: definition.parameters,\n\t\t\tpromptGuidelines: definition.promptGuidelines,\n\t\t\tsourceInfo,\n\t\t}));\n\t}\n\n\tgetToolDefinition(name: string): ToolDefinition | undefined {\n\t\treturn this._toolDefinitions.get(name)?.definition;\n\t}\n\n\trefreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void {\n\t\tconst previousRegistryNames = new Set(this._toolRegistry.keys());\n\t\t// Re-derive from the pre-filter REQUEST, never from agent.state.tools: the active set is\n\t\t// capability/profile-filtered, so feeding it back through setActiveToolsByName would\n\t\t// permanently shrink what a later switch to a larger model (or permissive profile) restores.\n\t\tconst previousActiveToolNames = mapToolNamesForPlatform(\n\t\t\tthis.deps.getRequestedActiveToolNames() ?? this.deps.getActiveToolNames(),\n\t\t);\n\t\tconst toolAccess = this._createToolAccessPolicy();\n\t\tconst { allowedToolNames, toolProfileFilter } = toolAccess;\n\t\tconst isAllowedTool = toolAccess.allows;\n\n\t\tconst registeredTools = this.deps.getExtensionRunner().getAllRegisteredTools();\n\t\tconst allCustomTools = [\n\t\t\t...registeredTools,\n\t\t\t...this.deps.getCustomTools().map((definition) => ({\n\t\t\t\tdefinition,\n\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: \"sdk\" }),\n\t\t\t})),\n\t\t\t// Memory subsystem provider tools (e.g. file-store's `memory` tool).\n\t\t\t...this.deps\n\t\t\t\t.getMemoryManager()\n\t\t\t\t.getToolDefinitions()\n\t\t\t\t.map((definition) => ({\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<memory:${definition.name}>`, { source: \"sdk\" }),\n\t\t\t\t})),\n\t\t].filter((tool) => isAllowedTool(tool.definition.name));\n\t\tconst definitionRegistry = new Map<string, ToolDefinitionEntry>(\n\t\t\tArray.from(this._baseToolDefinitions.entries())\n\t\t\t\t.filter(([name]) => isAllowedTool(name))\n\t\t\t\t.map(([name, definition]) => [\n\t\t\t\t\tname,\n\t\t\t\t\t{\n\t\t\t\t\t\tdefinition,\n\t\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${name}>`, { source: \"builtin\" }),\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t);\n\t\tfor (const tool of allCustomTools) {\n\t\t\tdefinitionRegistry.set(tool.definition.name, {\n\t\t\t\tdefinition: tool.definition,\n\t\t\t\tsourceInfo: tool.sourceInfo,\n\t\t\t});\n\t\t}\n\t\tthis._toolDefinitions = definitionRegistry;\n\t\tthis._toolPromptSnippets = new Map(\n\t\t\tArray.from(definitionRegistry.values())\n\t\t\t\t.map(({ definition }) => {\n\t\t\t\t\tconst snippet = this.deps.normalizePromptSnippet(definition.promptSnippet);\n\t\t\t\t\treturn snippet ? ([definition.name, snippet] as const) : undefined;\n\t\t\t\t})\n\t\t\t\t.filter((entry): entry is readonly [string, string] => entry !== undefined),\n\t\t);\n\t\tthis._toolPromptGuidelines = new Map(\n\t\t\tArray.from(definitionRegistry.values())\n\t\t\t\t.map(({ definition }) => {\n\t\t\t\t\tconst guidelines = this.deps.normalizePromptGuidelines(definition.promptGuidelines);\n\t\t\t\t\treturn guidelines.length > 0 ? ([definition.name, guidelines] as const) : undefined;\n\t\t\t\t})\n\t\t\t\t.filter((entry): entry is readonly [string, string[]] => entry !== undefined),\n\t\t);\n\t\tconst runner = this.deps.getExtensionRunner();\n\t\tconst wrappedExtensionTools = wrapRegisteredTools(allCustomTools, runner);\n\t\tconst wrappedBuiltInTools = wrapRegisteredTools(\n\t\t\tArray.from(this._baseToolDefinitions.values())\n\t\t\t\t.filter((definition) => isAllowedTool(definition.name))\n\t\t\t\t.map((definition) => ({\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${definition.name}>`, { source: \"builtin\" }),\n\t\t\t\t})),\n\t\t\trunner,\n\t\t);\n\n\t\tconst toolRegistry = new Map(\n\t\t\twrappedBuiltInTools.map((tool) => {\n\t\t\t\tconst guarded = wrapToolWithCredentialExposureGuard(tool, this.deps.getCwd(), this._secretVault);\n\t\t\t\treturn [guarded.name, guarded] as const;\n\t\t\t}),\n\t\t);\n\t\tfor (const tool of wrappedExtensionTools as AgentTool[]) {\n\t\t\tconst guarded = wrapToolWithCredentialExposureGuard(tool, this.deps.getCwd(), this._secretVault);\n\t\t\ttoolRegistry.set(guarded.name, guarded);\n\t\t}\n\t\tthis._toolRegistry = toolRegistry;\n\n\t\tconst requestedBase = options?.activeToolNames\n\t\t\t? mapToolNamesForPlatform(options.activeToolNames)\n\t\t\t: [...previousActiveToolNames];\n\t\tconst nextActiveToolNames = requestedBase.filter((name) => isAllowedTool(name));\n\n\t\tconst persistentAutoActivated: string[] = [];\n\t\tif (allowedToolNames) {\n\t\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\t\tif (allowedToolNames.has(toolName)) {\n\t\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t\t\tpersistentAutoActivated.push(toolName);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (options?.includeAllExtensionTools) {\n\t\t\tfor (const tool of wrappedExtensionTools) {\n\t\t\t\tnextActiveToolNames.push(tool.name);\n\t\t\t\tpersistentAutoActivated.push(tool.name);\n\t\t\t}\n\t\t} else if (!options?.activeToolNames) {\n\t\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\t\tif (!previousRegistryNames.has(toolName)) {\n\t\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t\t\tpersistentAutoActivated.push(toolName);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Strict UAC: the active profile is the COMPLETE grant, so a tool the profile names\n\t\t// explicitly is itself a request for that tool — it must ACTIVATE from the registry even\n\t\t// if the session never requested it. Without this, activation is only ever the requested\n\t\t// defaults ∩ allow-list, and a profile granting non-default tools (a search-only profile's\n\t\t// grep/find) yields an empty or truncated tool set on load and /reload. A blanket \"*\"\n\t\t// stays grant-only: activation then still derives from the request/defaults above.\n\t\tconst explicitAllowPatterns = toolProfileFilter?.allow.filter((pattern) => pattern !== \"*\") ?? [];\n\t\tif (explicitAllowPatterns.length > 0) {\n\t\t\tconst boundPatterns = new Set<string>();\n\t\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\t\tif (!isAllowedTool(toolName)) continue;\n\t\t\t\tfor (const pattern of explicitAllowPatterns) {\n\t\t\t\t\tif (matchesResourceProfilePattern(toolName, [pattern])) boundPatterns.add(pattern);\n\t\t\t\t}\n\t\t\t\tif (matchesResourceProfilePattern(toolName, explicitAllowPatterns)) {\n\t\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// An explicit grant that binds to NO registered tool is a silent no-op — typo'd\n\t\t\t// name, or the owning extension is not granted/loaded. Surface it.\n\t\t\tthis.deps.setUnboundToolGrantWarnings(\n\t\t\t\texplicitAllowPatterns\n\t\t\t\t\t.filter((pattern) => !boundPatterns.has(pattern))\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(pattern) =>\n\t\t\t\t\t\t\t`profile tool grant \"${pattern}\" binds to no registered tool (typo, or the owning extension is not granted/loaded)`,\n\t\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\tthis.deps.setUnboundToolGrantWarnings([]);\n\t\t}\n\n\t\t// artifact_retrieve companion auto-activation is enforced inside\n\t\t// setActiveToolsByName() itself (not duplicated here), so every activation path --\n\t\t// including the public, extension-exposed setActiveTools() -- gets the same\n\t\t// guarantee, not just this settings/profile refresh flow.\n\t\tthis.deps.setActiveToolsByName([...new Set(nextActiveToolNames)]);\n\t\t// setActiveToolsByName just stored the profile-filtered ACTIVE set as the request; restore\n\t\t// the true pre-filter request (plus non-profile auto-activations) so an internal refresh can\n\t\t// never permanently narrow it. Explicit profile grants are generation-local activations: if\n\t\t// profile A names grep and profile B later grants \"*\", A must not pin grep into B's request.\n\t\tthis.deps.setRequestedActiveToolNames([...new Set([...requestedBase, ...persistentAutoActivated])]);\n\t}\n\n\tprivate _createReloadRuntimeSnapshot(): ReloadRuntimeSnapshot {\n\t\tconst agent = this.deps.getAgent();\n\t\tconst toolProfileFilter = this.deps.getToolProfileFilter();\n\t\tconst requestedActiveToolNames = this.deps.getRequestedActiveToolNames();\n\t\treturn {\n\t\t\textensionRunner: this.deps.getExtensionRunner(),\n\t\t\tsettings: this.deps.getSettingsManager().createReloadSnapshot(),\n\t\t\tmodelRegistry: this.deps.getModelRegistry().createReloadSnapshot(),\n\t\t\tmodel: agent.state.model,\n\t\t\tthinkingLevel: agent.state.thinkingLevel,\n\t\t\tsessionLeafId: this.deps.getSessionManager().getLeafId(),\n\t\t\ttoolProfileFilter: toolProfileFilter\n\t\t\t\t? { allow: [...toolProfileFilter.allow], block: [...toolProfileFilter.block] }\n\t\t\t\t: undefined,\n\t\t\trequestedActiveToolNames: requestedActiveToolNames ? [...requestedActiveToolNames] : undefined,\n\t\t\tmemory: this.deps.createMemoryReloadSnapshot(),\n\t\t\tprofileFilter: this.deps.createProfileFilterReloadSnapshot(),\n\t\t\tunboundToolGrantWarnings: [...this.deps.getUnboundToolGrantWarnings()],\n\t\t\tbaseToolDefinitions: this._baseToolDefinitions,\n\t\t\ttoolRegistry: this._toolRegistry,\n\t\t\ttoolDefinitions: this._toolDefinitions,\n\t\t\ttoolPromptSnippets: this._toolPromptSnippets,\n\t\t\ttoolPromptGuidelines: this._toolPromptGuidelines,\n\t\t\tagentTools: agent.state.tools,\n\t\t\tagentSystemPrompt: agent.state.systemPrompt,\n\t\t\tbaseSystemPrompt: this.deps.getBaseSystemPrompt(),\n\t\t};\n\t}\n\n\tprivate _restoreReloadRuntimeSnapshot(snapshot: ReloadRuntimeSnapshot): void {\n\t\tthis.deps.getSettingsManager().restoreReloadSnapshot(snapshot.settings);\n\t\tthis.deps.getModelRegistry().restoreReloadSnapshot(snapshot.modelRegistry);\n\t\tthis.deps.setToolProfileFilter(\n\t\t\tsnapshot.toolProfileFilter\n\t\t\t\t? { allow: [...snapshot.toolProfileFilter.allow], block: [...snapshot.toolProfileFilter.block] }\n\t\t\t\t: undefined,\n\t\t);\n\t\tthis.deps.setRequestedActiveToolNames(\n\t\t\tsnapshot.requestedActiveToolNames ? [...snapshot.requestedActiveToolNames] : undefined,\n\t\t);\n\t\tthis.deps.restoreMemoryReloadSnapshot(snapshot.memory);\n\t\tthis.deps.restoreProfileFilterReloadSnapshot(snapshot.profileFilter);\n\t\tthis.deps.setUnboundToolGrantWarnings([...snapshot.unboundToolGrantWarnings]);\n\t\t// setExtensionRunner restores both _extensionRunner and _extensionRunnerRef.current together\n\t\t// (the same field-then-ref pair the host wrote at every assignment site); nothing reads the\n\t\t// ref between the two writes, so folding them is unobservable.\n\t\tthis.deps.setExtensionRunner(snapshot.extensionRunner);\n\t\tthis._baseToolDefinitions = snapshot.baseToolDefinitions;\n\t\tthis._toolRegistry = snapshot.toolRegistry;\n\t\tthis._toolDefinitions = snapshot.toolDefinitions;\n\t\tthis._toolPromptSnippets = snapshot.toolPromptSnippets;\n\t\tthis._toolPromptGuidelines = snapshot.toolPromptGuidelines;\n\t\tconst agent = this.deps.getAgent();\n\t\tagent.state.model = snapshot.model;\n\t\tagent.state.thinkingLevel = snapshot.thinkingLevel;\n\t\tagent.state.tools = snapshot.agentTools;\n\t\tagent.state.systemPrompt = snapshot.agentSystemPrompt;\n\t\tthis.deps.setBaseSystemPrompt(snapshot.baseSystemPrompt);\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tif (snapshot.sessionLeafId === null) {\n\t\t\tsessionManager.resetLeaf();\n\t\t} else {\n\t\t\tsessionManager.branch(snapshot.sessionLeafId);\n\t\t}\n\t\tthis.deps.applyExtensionBindings(snapshot.extensionRunner);\n\t}\n\n\tprivate _doctorReloadRuntime(): void {\n\t\tconst extensionErrors = this.deps.getResourceLoader().getExtensions().errors;\n\t\tif (extensionErrors.length > 0) {\n\t\t\tconst summary = extensionErrors\n\t\t\t\t.slice(0, 6)\n\t\t\t\t.map((error) => `${error.path}: ${error.error}`)\n\t\t\t\t.join(\"; \");\n\t\t\tthrow new Error(`Extension reload failed doctor: ${summary}`);\n\t\t}\n\n\t\tconst missingActiveTools = this.deps.getActiveToolNames().filter((name) => !this._toolRegistry.has(name));\n\t\tif (missingActiveTools.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Extension reload failed doctor: active tool(s) missing after reload: ${missingActiveTools.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tfor (const tool of this.deps.getAgent().state.tools) {\n\t\t\tif (!this._toolDefinitions.has(tool.name)) {\n\t\t\t\tthrow new Error(`Extension reload failed doctor: tool ${tool.name} missing from definition registry`);\n\t\t\t}\n\t\t}\n\n\t\tthis.deps.createAgentContextSnapshot();\n\t\tthis.deps.getContextUsage();\n\t}\n\n\tbuildRuntime(options: {\n\t\tactiveToolNames?: string[];\n\t\tflagValues?: Map<string, boolean | string>;\n\t\tincludeAllExtensionTools?: boolean;\n\t\tonError?: ExtensionErrorListener;\n\t}): (() => void) | undefined {\n\t\tconst settingsManager = this.deps.getSettingsManager();\n\t\tconst autoResizeImages = settingsManager.getImageAutoResize();\n\t\tconst shellCommandPrefix = settingsManager.getShellCommandPrefix();\n\t\tconst shellPath = settingsManager.getShellPath();\n\t\tconst baseToolsOverride = this.deps.getBaseToolsOverride();\n\t\tconst toolAccess = this._createToolAccessPolicy();\n\t\t// Artifact-producing tools must not emit a \"Full output: artifact tool-output:<id>\" handle\n\t\t// that nothing can resolve. If artifact_retrieve is explicitly excluded/blocked/outside\n\t\t// an active allowlist, don't hand grep/find/run_toolkit_script an artifact store at all:\n\t\t// they fall back to their bounded preview/truncation behavior, with no payload/meta files\n\t\t// ever written and no retrieval promise made.\n\t\tconst toolArtifactStore =\n\t\t\t!baseToolsOverride && toolAccess.allows(\"artifact_retrieve\") ? this.deps.getToolArtifactStore() : undefined;\n\t\tconst toolOptions: ToolsOptions = {\n\t\t\tread: { autoResizeImages },\n\t\t\tbash: {\n\t\t\t\tcommandPrefix: shellCommandPrefix,\n\t\t\t\tshellPath,\n\t\t\t\tsessionKey: this.deps.getShellSessionKey(),\n\t\t\t\tplatform: process.platform,\n\t\t\t\tspawnHook: (context) => ({\n\t\t\t\t\t...context,\n\t\t\t\t\tenv: { ...context.env, ...this._secretVault.getEnvironmentForCwd(context.cwd) },\n\t\t\t\t}),\n\t\t\t},\n\t\t\tpython: { environment: (cwd) => this._secretVault.getEnvironmentForCwd(cwd) },\n\t\t\tgrep: { artifactStore: toolArtifactStore },\n\t\t\tfind: { artifactStore: toolArtifactStore },\n\t\t\tartifact_retrieve: { artifactStore: toolArtifactStore },\n\t\t};\n\t\tthis._baseToolDefinitions = baseToolsOverride\n\t\t\t? new Map(\n\t\t\t\t\tObject.entries(baseToolsOverride)\n\t\t\t\t\t\t.filter(([name]) => toolAccess.allows(name))\n\t\t\t\t\t\t.map(([name, tool]) => [name, createToolDefinitionFromAgentTool(tool)]),\n\t\t\t\t)\n\t\t\t: new Map(\n\t\t\t\t\t[...allToolNames]\n\t\t\t\t\t\t.filter((name) => toolAccess.allows(name))\n\t\t\t\t\t\t.map((name) => [name, createToolDefinition(name, this.deps.getCwd(), toolOptions)]),\n\t\t\t\t);\n\t\tif (!baseToolsOverride) {\n\t\t\tif (toolAccess.allows(\"run_process\")) {\n\t\t\t\tconst orchestrationProfile = this.deps.getOrchestrationProfile?.();\n\t\t\t\tif (orchestrationProfile?.executionPolicy) {\n\t\t\t\t\tthis._baseToolDefinitions.set(\n\t\t\t\t\t\t\"run_process\",\n\t\t\t\t\t\tcreateRunProcessToolDefinition(this.deps.getCwd(), {\n\t\t\t\t\t\t\tpolicy: orchestrationProfile.executionPolicy,\n\t\t\t\t\t\t\tmaxWallClockMs: orchestrationProfile.budget.maxWallClockMs ?? 0,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (toolAccess.allows(\"context_audit\")) {\n\t\t\t\tfor (const definition of createCoreDiagnosticsToolDefinitions(\n\t\t\t\t\t() => this.deps.getActiveToolNames(),\n\t\t\t\t\t() => this.getAllTools(),\n\t\t\t\t\t(messages) => this.deps.getContextGcReport(messages),\n\t\t\t\t\t() => this.deps.getMemoryAuditDiagnostics(),\n\t\t\t\t)) {\n\t\t\t\t\tthis._baseToolDefinitions.set(definition.name, definition);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Hoisted above the goal-tool registration (rather than declared only inside the\n\t\t\t// worktreeSync-enabled block further below) so the SAME settings/deps factory backs both\n\t\t\t// the goal->tmux lane-first dispatch dep (`createLaneWorktree`, immediately below) and the\n\t\t\t// `worktree_sync` tool registration later in this method -- one source of truth, no drift.\n\t\t\tconst worktreeSyncSettings =\n\t\t\t\ttoolAccess.allows(\"goal\") || toolAccess.allows(\"worktree_sync\")\n\t\t\t\t\t? settingsManager.getWorktreeSyncSettings()\n\t\t\t\t\t: undefined;\n\t\t\tconst worktreeSyncEngineDeps = () =>\n\t\t\t\tbuildWorktreeSyncEngineDeps({\n\t\t\t\t\tcwd: this.deps.getCwd(),\n\t\t\t\t\tagentDir: this.deps.getAgentDir(),\n\t\t\t\t\tsettingsManager: this.deps.getSettingsManager(),\n\t\t\t\t\tsessionId: this.deps.getSessionManager().getSessionId(),\n\t\t\t\t});\n\t\t\tif (toolAccess.allows(\"goal\")) {\n\t\t\t\tconst goalToolDefinition = createGoalToolDefinition({\n\t\t\t\t\tgetGoalState: () => this.deps.getGoalStateSnapshot(),\n\t\t\t\t\tsaveGoalState: (state, expected) => {\n\t\t\t\t\t\tthis.deps.saveGoalStateSnapshot(state, expected);\n\t\t\t\t\t},\n\t\t\t\t\t// kind:\"tool\" evidence refs verify against real session records.\n\t\t\t\t\thasToolCallId: (toolCallId) => hasAnsweredToolCallOnBranch(this.deps.getSessionManager(), toolCallId),\n\t\t\t\t\t// kind:\"worker\" evidence refs verify against the SAME live lane/claim accessors the\n\t\t\t\t\t// delegate_status tool already uses below -- live wiring (these were declared optional\n\t\t\t\t\t// and read-defensive on the goal-tool deps type).\n\t\t\t\t\tgetLaneRecords: () => this.deps.getWorkerLaneRecords(),\n\t\t\t\t\tgetWorkerClaimSnapshots: () => this.deps.getWorkerClaimSnapshots(),\n\t\t\t\t\t// dispatch_worker's tool-layer side effect for the default (in_process) route: starts a\n\t\t\t\t\t// real in-process worker lane through the SAME starter the delegate tool uses (below),\n\t\t\t\t\t// adapted from its `{started:true;record}|{started:false;skipReason}` shape onto this\n\t\t\t\t\t// tool's narrower `{laneId}|{skipReason}` shape.\n\t\t\t\t\tstartWorkerDelegation: (args) => {\n\t\t\t\t\t\tconst outcome = this.deps.startWorkerDelegation({ instructions: args.instructions });\n\t\t\t\t\t\treturn outcome.started ? { laneId: outcome.record.laneId } : { skipReason: outcome.skipReason };\n\t\t\t\t\t},\n\t\t\t\t\t// dispatch_worker's tool-layer side effect for `dispatchTarget:\"tmux\"`: core structurally\n\t\t\t\t\t// invokes the SAME tmux_agent_manager fire_task call the model itself would make (no\n\t\t\t\t\t// extension change, no faked launch/laneId) -- see tmux-dispatch.ts's doc comment.\n\t\t\t\t\tdispatchTmuxWorker: (args) =>\n\t\t\t\t\t\tdispatchTmuxWorker(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tgetToolDefinition: (name) => this.getToolDefinition(name),\n\t\t\t\t\t\t\t\tcreateExtensionContext: () => this.deps.getExtensionRunner().createContext(),\n\t\t\t\t\t\t\t\tresolveManagedLaneId: (id) => this.deps.resolveManagedLaneId(id),\n\t\t\t\t\t\t\t\tgetGoalId: () => this.deps.getGoalStateSnapshot()?.goalId,\n\t\t\t\t\t\t\t\tevaluateWorkerLaneRefusal: () => this.deps.getLaneWorkerRefusal(),\n\t\t\t\t\t\t\t\t// Lane-first dispatch, wired ONLY when worktree-sync is enabled -- absent otherwise,\n\t\t\t\t\t\t\t\t// so a disabled/default session gets the existing byte-identical fire_task params.\n\t\t\t\t\t\t\t\tcreateLaneWorktree: worktreeSyncSettings?.enabled\n\t\t\t\t\t\t\t\t\t? async (laneArgs) => {\n\t\t\t\t\t\t\t\t\t\t\tconst created = await createLane(worktreeSyncEngineDeps(), {\n\t\t\t\t\t\t\t\t\t\t\t\t...(laneArgs.goalId !== undefined ? { goalId: laneArgs.goalId } : {}),\n\t\t\t\t\t\t\t\t\t\t\t\trequirementId: laneArgs.requirementId,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t// Never fake a lane: any non-\"ok\" engine code (max lanes, invalid key, git\n\t\t\t\t\t\t\t\t\t\t\t// error, ...) is refused, mapped by the caller onto the stable\n\t\t\t\t\t\t\t\t\t\t\t// \"worktree_create_failed\" skip reason before any fire_task call runs.\n\t\t\t\t\t\t\t\t\t\t\tif (created.code !== \"ok\") return { skipReason: created.code };\n\t\t\t\t\t\t\t\t\t\t\treturn { laneKey: created.lane.laneKey, worktreePath: created.lane.worktreePath };\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\targs,\n\t\t\t\t\t\t),\n\t\t\t\t\tcwd: () => this.deps.getCwd(),\n\t\t\t\t\t// Reuses the already branch-scoped getTaskStepsStateSnapshot dep -- no new\n\t\t\t\t\t// SessionManager access needed for the cross-visibility nudge.\n\t\t\t\t\tgetOpenTaskSteps: () => deriveOpenTaskStepRefs(this.deps.getTaskStepsStateSnapshot()),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(goalToolDefinition.name, goalToolDefinition);\n\t\t\t}\n\t\t\tif (toolAccess.allows(\"task_steps\")) {\n\t\t\t\tconst taskStepsToolDefinition = createTaskStepsToolDefinition({\n\t\t\t\t\tgetTaskStepsState: () => this.deps.getTaskStepsStateSnapshot(),\n\t\t\t\t\tsaveTaskStepsState: (state) => {\n\t\t\t\t\t\tthis.deps.saveTaskStepsStateSnapshot(state);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(taskStepsToolDefinition.name, taskStepsToolDefinition);\n\t\t\t}\n\t\t\tif (toolAccess.allows(\"ask_question\")) {\n\t\t\t\tconst askQuestionToolDefinition = createAskQuestionToolDefinition({\n\t\t\t\t\tsessionManager: this.deps.getSessionManager(),\n\t\t\t\t\tartifactStore: toolArtifactStore,\n\t\t\t\t\tgetImageStore: () => this.deps.getSessionImageStore(),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(askQuestionToolDefinition.name, askQuestionToolDefinition);\n\t\t\t}\n\t\t\tif (toolAccess.allows(\"secret_store\")) {\n\t\t\t\tconst secretStoreToolDefinition = createSecretStoreToolDefinition({ vault: this._secretVault });\n\t\t\t\tthis._baseToolDefinitions.set(secretStoreToolDefinition.name, secretStoreToolDefinition);\n\t\t\t}\n\t\t\tif (toolAccess.allows(\"delegate\")) {\n\t\t\t\tconst delegateToolDefinition = createDelegateToolDefinition({\n\t\t\t\t\tstartWorkerDelegation: (args) => this.deps.startWorkerDelegation(args),\n\t\t\t\t\trunWorkerDelegation: (args) => this.deps.runWorkerDelegationOnce(args),\n\t\t\t\t\torchestrationProfiles: this.deps.getOrchestrationProfileCatalog(),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(delegateToolDefinition.name, delegateToolDefinition);\n\t\t\t}\n\t\t\tif (toolAccess.allows(\"delegate_status\")) {\n\t\t\t\tconst delegateStatusToolDefinition = createDelegateStatusToolDefinition({\n\t\t\t\t\tgetLaneRecords: () => this.deps.getWorkerLaneRecords(),\n\t\t\t\t\tgetWorkerClaimSnapshots: () => this.deps.getWorkerClaimSnapshots(),\n\t\t\t\t\t// Durable ack persists straight through the session log; routed here (rather than\n\t\t\t\t\t// a new agent-session dep) because getSessionManager() is already a stable, generic\n\t\t\t\t\t// passthrough dep, so no other package needs to change for this to work.\n\t\t\t\t\tacknowledgeWorkerReview: (requestId) =>\n\t\t\t\t\t\tacknowledgeWorkerClaimReview(this.deps.getSessionManager(), requestId),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(delegateStatusToolDefinition.name, delegateStatusToolDefinition);\n\t\t\t}\n\t\t\t// Registered but not default-active: probes spend tokens on the probed model, so\n\t\t\t// activation is an explicit choice (settings/profile/setActiveTools or /autonomy fitness).\n\t\t\tif (toolAccess.allows(\"model_fitness\")) {\n\t\t\t\tconst modelFitnessToolDefinition = createModelFitnessToolDefinition({\n\t\t\t\t\trunProbe: (args) => this.deps.runModelFitness(args),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(modelFitnessToolDefinition.name, modelFitnessToolDefinition);\n\t\t\t}\n\t\t\tif (toolAccess.allows(\"context_scout\") && settingsManager.getScoutSettings().enabled) {\n\t\t\t\tconst contextScoutToolDefinition = createContextScoutToolDefinition({\n\t\t\t\t\trunScout: (input) => this._runContextScout(input.query, input.maxTurns, toolArtifactStore),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(contextScoutToolDefinition.name, contextScoutToolDefinition);\n\t\t\t}\n\t\t\tif (toolAccess.allows(\"run_toolkit_script\")) {\n\t\t\t\tconst runToolkitScriptToolDefinition = createRunToolkitScriptToolDefinition({\n\t\t\t\t\tgetScripts: () => this.deps.getSettingsManager().getToolkitScripts(),\n\t\t\t\t\texecute: (script, scriptArgs) => executeToolkitScript({ script, scriptArgs, cwd: this.deps.getCwd() }),\n\t\t\t\t\tartifactStore: toolArtifactStore,\n\t\t\t\t\t// Reflex brain (fitness-gated local model): resolves ambiguous requests into a\n\t\t\t\t\t// registry pick. Best-effort — absent/unfit brain keeps the shortlist behavior.\n\t\t\t\t\tinterpret: async (request, scripts) => {\n\t\t\t\t\t\tconst model = this.deps.resolveCurationModelIfFit();\n\t\t\t\t\t\tif (!model) return undefined;\n\t\t\t\t\t\tconst completion = await this.deps.runIsolatedCompletion({\n\t\t\t\t\t\t\tsystemPrompt: REFLEX_INTERPRETER_SYSTEM_PROMPT,\n\t\t\t\t\t\t\tmessages: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: buildReflexUserPrompt(request, scripts) }],\n\t\t\t\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tthinkingLevel: \"off\",\n\t\t\t\t\t\t\tmaxTokens: 256,\n\t\t\t\t\t\t\tcacheRetention: \"short\",\n\t\t\t\t\t\t\t// Stable per-lane synthetic affinity key so repeat ambiguous-request\n\t\t\t\t\t\t\t// interpretations hit the same cache-warm backend.\n\t\t\t\t\t\t\tlaneKind: \"toolkit-brain\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (completion.usage.cost.total > 0 || completion.usage.totalTokens > 0) {\n\t\t\t\t\t\t\t// `reportId` keyed on the ambiguous request text driving THIS interpretation —\n\t\t\t\t\t\t\t// stable across a retry of the same tool call, distinct across genuinely\n\t\t\t\t\t\t\t// different requests.\n\t\t\t\t\t\t\tconst reportId = deriveSpawnedUsageReportId(\n\t\t\t\t\t\t\t\t\"toolkit-brain\",\n\t\t\t\t\t\t\t\tthis.deps.getSessionManager().getSessionId(),\n\t\t\t\t\t\t\t\trequest,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.deps.addSpawnedUsage(completion.usage, { label: \"toolkit-brain\", reportId });\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn parseReflexPlan(completion.text);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(runToolkitScriptToolDefinition.name, runToolkitScriptToolDefinition);\n\t\t\t}\n\n\t\t\t// Worktree-sync (opt-in): the closed-action lane workflow tool, plus -- for a session\n\t\t\t// launched lane-bound (PI_WORKTREE_LANE) -- the G8/G10 lane gate wrapped UNDER the\n\t\t\t// file-mutation tools (edit/write, plus cooperative bash only for interactive lanes), so a sync_required lane fails closed with the\n\t\t\t// exact recovery step rather than relying on prompt compliance. `worktreeSyncSettings` /\n\t\t\t// `worktreeSyncEngineDeps` are hoisted above (declared before the goal-tool registration)\n\t\t\t// so the goal->tmux lane-first dispatch dep and this tool share one settings/deps source.\n\t\t\tif (toolAccess.allows(\"worktree_sync\") && worktreeSyncSettings?.enabled) {\n\t\t\t\tconst worktreeSyncToolDefinition = createWorktreeSyncToolDefinition({\n\t\t\t\t\tengineDeps: worktreeSyncEngineDeps,\n\t\t\t\t\tsettings: () => this.deps.getSettingsManager().getWorktreeSyncSettings(),\n\t\t\t\t\tboundLaneKey: () => getBoundWorktreeLaneKey(),\n\t\t\t\t\tisWorker: () => isWorkerSession(),\n\t\t\t\t});\n\t\t\t\tthis._baseToolDefinitions.set(worktreeSyncToolDefinition.name, worktreeSyncToolDefinition);\n\n\t\t\t\tconst boundLaneKey = getBoundWorktreeLaneKey();\n\t\t\t\tif (boundLaneKey) {\n\t\t\t\t\tconst laneGate = new WorktreeLaneGate({\n\t\t\t\t\t\tlaneKey: boundLaneKey,\n\t\t\t\t\t\tengineDeps: worktreeSyncEngineDeps,\n\t\t\t\t\t\tpolicy: () => this.deps.getSettingsManager().getWorktreeSyncSettings().syncPolicy,\n\t\t\t\t\t\thardShell: isWorkerSession(),\n\t\t\t\t\t\ttrustedGateCommand: () => this.deps.getSettingsManager().getWorktreeSyncSettings().gateCommand,\n\t\t\t\t\t});\n\t\t\t\t\tfor (const gatedToolName of [\"edit\", \"write\", \"bash\"]) {\n\t\t\t\t\t\tconst original = this._baseToolDefinitions.get(gatedToolName);\n\t\t\t\t\t\tif (!original) continue;\n\t\t\t\t\t\tthis._baseToolDefinitions.set(gatedToolName, {\n\t\t\t\t\t\t\t...original,\n\t\t\t\t\t\t\texecute: async (toolCallId, params, signal, onUpdate, ctx) => {\n\t\t\t\t\t\t\t\tconst bashCommand =\n\t\t\t\t\t\t\t\t\tgatedToolName === \"bash\" ? (params as { command?: string } | undefined)?.command : undefined;\n\t\t\t\t\t\t\t\tconst rawPath =\n\t\t\t\t\t\t\t\t\tgatedToolName === \"edit\" || gatedToolName === \"write\"\n\t\t\t\t\t\t\t\t\t\t? (params as { path?: string } | undefined)?.path\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\tconst targetPath =\n\t\t\t\t\t\t\t\t\trawPath !== undefined ? resolveToCwd(rawPath, this.deps.getCwd()) : undefined;\n\t\t\t\t\t\t\t\tconst check = await laneGate.checkMutation(gatedToolName, bashCommand, targetPath);\n\t\t\t\t\t\t\t\tif (!check.allowed) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: check.message }],\n\t\t\t\t\t\t\t\t\t\tdetails: { code: check.code } as never,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn original.execute(toolCallId, params, signal, onUpdate, ctx);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst extensionsResult = this.deps.getResourceLoader().getExtensions();\n\t\tif (options.flagValues) {\n\t\t\tfor (const [name, value] of options.flagValues) {\n\t\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\t}\n\t\t}\n\t\tconst extensions = this.deps.filterExtensionsForRuntime(\n\t\t\textensionsResult.extensions,\n\t\t\tthis._explicitLiveExtensionPaths,\n\t\t);\n\t\tconst runtimeExtensionPaths = new Set(extensions.map((extension) => extension.path));\n\t\textensionsResult.runtime.pendingProviderRegistrations =\n\t\t\textensionsResult.runtime.pendingProviderRegistrations.filter((registration) =>\n\t\t\t\truntimeExtensionPaths.has(registration.extensionPath),\n\t\t\t);\n\n\t\tconst runner = new ExtensionRunner(\n\t\t\textensions,\n\t\t\textensionsResult.runtime,\n\t\t\tthis.deps.getCwd(),\n\t\t\tthis.deps.getSessionManager(),\n\t\t\tthis.deps.getModelRegistry(),\n\t\t);\n\t\tconst offBuildErrors = options.onError ? runner.onError(options.onError) : undefined;\n\t\tthis.deps.setExtensionRunner(runner);\n\t\ttry {\n\t\t\tthis.deps.bindExtensionCore(runner);\n\t\t} catch (error) {\n\t\t\toffBuildErrors?.();\n\t\t\tthrow error;\n\t\t}\n\t\tthis.deps.applyExtensionBindings(runner);\n\n\t\tconst boundLaneKey = getBoundWorktreeLaneKey();\n\t\tconst hardLaneWorker = boundLaneKey !== undefined && isWorkerSession();\n\t\tconst explicitlyRequestedTools =\n\t\t\toptions.activeToolNames ?? (baseToolsOverride ? Object.keys(baseToolsOverride) : undefined);\n\t\tif (hardLaneWorker && explicitlyRequestedTools?.includes(\"bash\")) {\n\t\t\tthrow new Error(\"hard lane workers cannot request unrestricted bash; use typed worktree_sync actions\");\n\t\t}\n\t\tconst defaultActiveToolNames = mapToolNamesForPlatform(\n\t\t\tbaseToolsOverride\n\t\t\t\t? Object.keys(baseToolsOverride)\n\t\t\t\t: [...DEFAULT_ACTIVE_TOOL_NAMES, ...(settingsManager.getScoutSettings().enabled ? [\"context_scout\"] : [])],\n\t\t);\n\t\tconst baseActiveToolNames = mapToolNamesForPlatform(options.activeToolNames ?? defaultActiveToolNames).filter(\n\t\t\t(name) => !hardLaneWorker || name !== \"bash\",\n\t\t);\n\t\tif (\n\t\t\thardLaneWorker &&\n\t\t\tsettingsManager.getWorktreeSyncSettings().enabled &&\n\t\t\t!baseActiveToolNames.includes(\"worktree_sync\")\n\t\t) {\n\t\t\tbaseActiveToolNames.push(\"worktree_sync\");\n\t\t}\n\t\tthis.refreshToolRegistry({\n\t\t\tactiveToolNames: baseActiveToolNames,\n\t\t\tincludeAllExtensionTools: options.includeAllExtensionTools,\n\t\t});\n\t\treturn offBuildErrors;\n\t}\n\n\treload(): Promise<void> {\n\t\tif (this._reloadPromise) {\n\t\t\t// State can change while a generation is being validated. Coalesce any number of\n\t\t\t// overlapping requests into one follow-up generation instead of silently treating a\n\t\t\t// later profile/settings mutation as part of the already-snapshotted generation.\n\t\t\tthis._reloadRequested = true;\n\t\t\treturn this._reloadPromise;\n\t\t}\n\t\tconst reloadPromise = this._drainReloadRequests();\n\t\tthis._reloadPromise = reloadPromise;\n\t\treturn reloadPromise;\n\t}\n\n\tprivate async _drainReloadRequests(): Promise<void> {\n\t\tlet finalError: unknown;\n\t\ttry {\n\t\t\tdo {\n\t\t\t\tthis._reloadRequested = false;\n\t\t\t\ttry {\n\t\t\t\t\tawait this._reloadOnce();\n\t\t\t\t\tfinalError = undefined;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfinalError = error;\n\t\t\t\t}\n\t\t\t} while (this._reloadRequested);\n\t\t\tif (finalError !== undefined) throw finalError;\n\t\t} finally {\n\t\t\tthis._reloadPromise = undefined;\n\t\t\tthis._reloadRequested = false;\n\t\t}\n\t}\n\n\t/**\n\t * Unified reload-gate quiescence check: refuses the caller's action (message-prefixed by\n\t * `action`) while the agent is streaming, is compacting, or ANY background work unit is still\n\t * registered in the in-process quiesce registry — background lanes (research/worker/\n\t * model-fitness), a context-scout run, or an isolated completion (see reload-blockers.ts). Every\n\t * live-op entry point below calls this so they refuse identically; this is a synchronous refusal\n\t * (not a wait/poll) — callers retry via the same coalescing `reload()` already provides.\n\t */\n\tprivate _assertReloadQuiescent(action: string): void {\n\t\tif (this.deps.isStreaming()) {\n\t\t\tthrow new Error(`Cannot ${action} while the agent is streaming or a tool call is active`);\n\t\t}\n\t\tif (this.deps.isCompacting()) {\n\t\t\tthrow new Error(`Cannot ${action} while context compaction or branch summarization is active`);\n\t\t}\n\t\tconst units = getInFlightWorkUnits(this.deps.getAgentDir());\n\t\tif (units.length > 0) {\n\t\t\tconst summary = units.map(describeInFlightWorkUnit).join(\", \");\n\t\t\tthrow new Error(`Cannot ${action} while background work is in flight: ${summary}`);\n\t\t}\n\t}\n\n\tprivate async _reloadOnce(): Promise<void> {\n\t\tthis._assertReloadQuiescent(\"reload\");\n\t\tconst previousRunner = this.deps.getExtensionRunner();\n\t\tconst snapshot = this._createReloadRuntimeSnapshot();\n\t\t// Preserve the pre-filter tool REQUEST across the rebuild, not the capability/profile-filtered\n\t\t// active set — otherwise a reload under a small model permanently shrinks the restorable set.\n\t\tconst activeToolNames = this.deps.getRequestedActiveToolNames() ?? this.deps.getActiveToolNames();\n\t\tconst previousFlagValues = previousRunner.getFlagValues();\n\t\tconst previousExtensionProviderNames = previousRunner.getRegisteredProviderNames();\n\t\tconst reloadErrors: string[] = [];\n\t\tlet newRunner: ExtensionRunner | undefined;\n\t\tlet offReloadErrors: (() => void) | undefined;\n\t\ttry {\n\t\t\tawait this.deps.getSettingsManager().reload();\n\t\t\t// Re-derive the resource-profile tool filter from the freshly reloaded settings.\n\t\t\t// Unlike skills/prompts/themes (which re-filter through the resource loader on every\n\t\t\t// reload), the tool filter is held on the session, so without this a live edit to the\n\t\t\t// active profile's tools allow/block — or switching the active profile — would not\n\t\t\t// apply on /reload and allowed tools would stay missing.\n\t\t\tthis.deps.setToolProfileFilter(this.deps.deriveToolProfileFilter());\n\t\t\t// Resource discovery must consume this exact settings generation. A second settings read here\n\t\t\t// could combine profile state from one generation with resources from the next.\n\t\t\tawait this.deps.getResourceLoader().reload({\n\t\t\t\tfailOnExtensionErrors: true,\n\t\t\t\tdeferExtensionDispose: true,\n\t\t\t\tskipSettingsReload: true,\n\t\t\t});\n\t\t\t// A live-load call is an exact session-owned grant. Resource discovery deliberately cannot\n\t\t\t// recreate it without a profile, so restore only those approved paths into the new runtime\n\t\t\t// generation before binding it.\n\t\t\tfor (const extensionPath of this._explicitLiveExtensionPaths) {\n\t\t\t\tif (\n\t\t\t\t\tthis.deps.isExtensionPathAllowed(extensionPath, \"explicit\") &&\n\t\t\t\t\t!this.deps.getResourceLoader().getLoadedExtension(extensionPath)\n\t\t\t\t) {\n\t\t\t\t\tawait this._importExtension(extensionPath);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Replace the previous extension-owned provider generation before binding the new one. The\n\t\t\t// bulk refresh also preserves API/OAuth streams for surviving non-extension providers.\n\t\t\tthis.deps.getModelRegistry().unregisterProviders(previousExtensionProviderNames);\n\t\t\toffReloadErrors = this.buildRuntime({\n\t\t\t\tactiveToolNames,\n\t\t\t\tflagValues: previousFlagValues,\n\t\t\t\tincludeAllExtensionTools: true,\n\t\t\t\tonError: (error) => {\n\t\t\t\t\treloadErrors.push(`${error.extensionPath} ${error.event}: ${error.error}`);\n\t\t\t\t},\n\t\t\t});\n\t\t\tnewRunner = this.deps.getExtensionRunner();\n\t\t\t// Extensions are now bound and their queued providers/models are registered, so a profile may\n\t\t\t// safely select a model contributed by an extension granted in that same profile generation.\n\t\t\tawait this.deps.reapplyActiveProfileModelSettings();\n\t\t\t// Model capability and system-prompt/tool exposure must reflect the newly selected model.\n\t\t\tthis.refreshToolRegistry({ activeToolNames, includeAllExtensionTools: true });\n\t\t\ttry {\n\t\t\t\tthis._doctorReloadRuntime();\n\t\t\t\t// Reload starts memory providers fresh; loaded extensions re-register below.\n\t\t\t\tthis.deps.clearPendingMemoryProviders();\n\t\t\t\tconst hasBindings =\n\t\t\t\t\tthis.deps.getExtensionUIContext() ||\n\t\t\t\t\tthis.deps.getExtensionCommandContextActions() ||\n\t\t\t\t\tthis.deps.getExtensionShutdownHandler() ||\n\t\t\t\t\tthis.deps.getExtensionErrorListener();\n\t\t\t\tif (hasBindings) {\n\t\t\t\t\tawait newRunner.emit({ type: \"session_start\", reason: \"reload\" });\n\t\t\t\t\tawait this.deps.extendResourcesFromExtensions(\"reload\");\n\t\t\t\t\tthis._doctorReloadRuntime();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\toffReloadErrors?.();\n\t\t\t\toffReloadErrors = undefined;\n\t\t\t}\n\t\t\tif (reloadErrors.length > 0) {\n\t\t\t\tthrow new Error(`Extension reload failed doctor: ${reloadErrors.slice(0, 6).join(\"; \")}`);\n\t\t\t}\n\t\t\tawait emitSessionShutdownEvent(previousRunner, { type: \"session_shutdown\", reason: \"reload\" });\n\t\t\tpreviousRunner.invalidate();\n\t\t\tawait this.deps.getResourceLoader().commitReload?.();\n\t\t\t// Re-derive the memory subsystem from the reloaded settings/providers.\n\t\t\tawait this.deps.initializeMemory();\n\t\t\t// This generation has fully committed (no rollback below this point), so any local\n\t\t\t// runtime the host no longer routes to under the new configuration can be stopped now.\n\t\t\tthis.deps.reconcileLocalRuntimes?.();\n\t\t} catch (error) {\n\t\t\toffReloadErrors?.();\n\t\t\tif (newRunner && newRunner !== previousRunner) {\n\t\t\t\tnewRunner.invalidate(\n\t\t\t\t\t\"This extension ctx was discarded because reload failed and Pi restored the previous valid runtime.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait this.deps.getResourceLoader().rollbackReload?.();\n\t\t\tthis._restoreReloadRuntimeSnapshot(snapshot);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Unload a single extension without full reload.\n\t * Runs the extension's session_shutdown lifecycle, unregisters its providers,\n\t * disposes its event subscriptions, and rebuilds the runtime.\n\t * Falls back to full reload on error.\n\t */\n\tasync unloadExtensionLive(extensionPath: string): Promise<void> {\n\t\tthis._assertReloadQuiescent(\"unload extension\");\n\t\ttry {\n\t\t\tawait this._unloadExtensionLive(extensionPath, true, true);\n\t\t} catch (error) {\n\t\t\tawait this._recoverLiveExtensionFailure();\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate async _unloadExtensionLive(\n\t\textensionPath: string,\n\t\trevokeExplicitGrant: boolean,\n\t\tnotify: boolean,\n\t): Promise<void> {\n\t\tconst ext = this.deps.getResourceLoader().getLoadedExtension(extensionPath);\n\t\tconst explicitGrantPath = ext?.path ?? extensionPath;\n\t\tconst hadExplicitGrant = this._explicitLiveExtensionPaths.has(explicitGrantPath);\n\t\tif (revokeExplicitGrant) {\n\t\t\tthis._explicitLiveExtensionPaths.delete(explicitGrantPath);\n\t\t}\n\t\tif (!ext) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst previousRunner = this.deps.getExtensionRunner();\n\t\ttry {\n\t\t\t// Run session_shutdown lifecycle for this extension only\n\t\t\tawait this.deps.getExtensionRunner().emitToExtension(ext, { type: \"session_shutdown\", reason: \"unload\" });\n\n\t\t\t// Unregister its providers (keyed by the extension's own path, as registered)\n\t\t\tconst runtime = this.deps.getResourceLoader().getExtensions().runtime;\n\t\t\tconst ownedMemoryProviders = runtime.memoryProvidersByExtension.get(ext.path) ?? new Set();\n\t\t\tconst ownedContextMemoryProviders = runtime.contextMemoryProvidersByExtension.get(ext.path) ?? new Set();\n\t\t\tfor (const name of runtime.getProvidersForExtension(ext.path)) {\n\t\t\t\truntime.unregisterProvider(name, ext.path);\n\t\t\t}\n\n\t\t\t// Dispose its event subscriptions and run disposers\n\t\t\tawait disposeExtensionEventSubscriptions([ext]);\n\n\t\t\t// Remove from loaded extensions\n\t\t\tthis.deps.getResourceLoader().removeLoadedExtension(extensionPath);\n\n\t\t\t// Rebuild runtime with new extension set\n\t\t\tconst activeToolNames = this.deps.getRequestedActiveToolNames() ?? this.deps.getActiveToolNames();\n\t\t\tconst previousFlagValues = previousRunner.getFlagValues();\n\t\t\tthis.buildRuntime({\n\t\t\t\tactiveToolNames,\n\t\t\t\tflagValues: previousFlagValues,\n\t\t\t\tincludeAllExtensionTools: true,\n\t\t\t});\n\t\t\tpreviousRunner.retire();\n\t\t\tconst memorySnapshot = this.deps.createMemoryReloadSnapshot();\n\t\t\tthis.deps.restoreMemoryReloadSnapshot({\n\t\t\t\t...memorySnapshot,\n\t\t\t\tpendingMemoryProviders: memorySnapshot.pendingMemoryProviders.filter(\n\t\t\t\t\t(provider) => !ownedMemoryProviders.has(provider),\n\t\t\t\t),\n\t\t\t\tpendingContextMemoryProviders: memorySnapshot.pendingContextMemoryProviders.filter(\n\t\t\t\t\t(provider) => !ownedContextMemoryProviders.has(provider),\n\t\t\t\t),\n\t\t\t});\n\t\t\truntime.memoryProvidersByExtension.delete(ext.path);\n\t\t\truntime.contextMemoryProvidersByExtension.delete(ext.path);\n\t\t\tawait this.deps.initializeMemory();\n\n\t\t\tif (notify) {\n\t\t\t\tthis.deps.notifyExtensionsChanged();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (revokeExplicitGrant && hadExplicitGrant) {\n\t\t\t\tthis._explicitLiveExtensionPaths.add(explicitGrantPath);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Load a single extension without full reload.\n\t * Loads the extension with fresh import, rebuilds the runtime,\n\t * and runs the extension's session_start lifecycle.\n\t * Falls back to full reload on error.\n\t */\n\tasync loadExtensionLive(extensionPath: string): Promise<void> {\n\t\tthis._assertReloadQuiescent(\"load extension\");\n\t\tthis._assertExtensionLoadAllowed(extensionPath, \"explicit\");\n\t\ttry {\n\t\t\tawait this._loadExtensionLive(extensionPath, \"explicit\", true);\n\t\t} catch (error) {\n\t\t\tawait this._recoverLiveExtensionFailure();\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate async _loadExtensionLive(\n\t\textensionPath: string,\n\t\tauthority: ExtensionImportAuthority,\n\t\tnotify: boolean,\n\t): Promise<void> {\n\t\tconst previousRunner = this.deps.getExtensionRunner();\n\t\tlet explicitGrantPath: string | undefined;\n\t\tlet hadExplicitGrant = false;\n\t\ttry {\n\t\t\t// Load the extension with fresh import\n\t\t\tconst extension = await this._importExtension(extensionPath);\n\t\t\tif (authority === \"explicit\") {\n\t\t\t\texplicitGrantPath = extension.path;\n\t\t\t\thadExplicitGrant = this._explicitLiveExtensionPaths.has(explicitGrantPath);\n\t\t\t\tthis._explicitLiveExtensionPaths.add(explicitGrantPath);\n\t\t\t}\n\n\t\t\t// Rebuild runtime to aggregate tools/commands/handlers/providers\n\t\t\tconst activeToolNames = this.deps.getRequestedActiveToolNames() ?? this.deps.getActiveToolNames();\n\t\t\tconst previousFlagValues = previousRunner.getFlagValues();\n\t\t\tthis.buildRuntime({\n\t\t\t\tactiveToolNames,\n\t\t\t\tflagValues: previousFlagValues,\n\t\t\t\tincludeAllExtensionTools: true,\n\t\t\t});\n\n\t\t\t// Run session_start lifecycle for the new extension only\n\t\t\tawait this.deps.getExtensionRunner().emitToExtension(extension, { type: \"session_start\", reason: \"load\" });\n\t\t\t// Activate newly registered legacy/context providers immediately. Reinitialization also\n\t\t\t// refreshes provider tools and preserves all providers owned by existing extensions.\n\t\t\tawait this.deps.initializeMemory();\n\t\t\tpreviousRunner.retire();\n\n\t\t\tif (notify) {\n\t\t\t\tthis.deps.notifyExtensionsChanged();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (explicitGrantPath && !hadExplicitGrant) {\n\t\t\t\tthis._explicitLiveExtensionPaths.delete(explicitGrantPath);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate async _importExtension(extensionPath: string): Promise<Extension> {\n\t\tconst { extension, error } = await this.deps.getResourceLoader().loadSingleExtension(extensionPath);\n\t\tif (error || !extension) {\n\t\t\tthrow new Error(error || `Failed to load extension: ${extensionPath}`);\n\t\t}\n\t\treturn extension;\n\t}\n\n\tprivate _assertExtensionLoadAllowed(extensionPath: string, authority: ExtensionImportAuthority): void {\n\t\tif (!this.deps.isExtensionPathAllowed(extensionPath, authority)) {\n\t\t\tthrow new Error(`Cannot load extension outside the active resource profile: ${extensionPath}`);\n\t\t}\n\t}\n\n\tprivate async _recoverLiveExtensionFailure(): Promise<void> {\n\t\ttry {\n\t\t\tawait this.reload();\n\t\t} catch {\n\t\t\t// Preserve the original live-operation error; recovery is best effort.\n\t\t}\n\t}\n\n\t/**\n\t * Reconcile loaded extensions with the active profile.\n\t * Loads extensions that should be enabled but aren't, and unloads extensions that shouldn't be.\n\t * Falls back to full reload if any individual load/unload fails.\n\t */\n\tasync reconcileLoadedExtensions(): Promise<void> {\n\t\tthis._assertReloadQuiescent(\"reconcile extensions\");\n\n\t\ttry {\n\t\t\t// Get all discoverable extension paths\n\t\t\tconst allDiscoverablePaths = await this.deps.getResourceLoader().getDiscoverableExtensionPaths();\n\n\t\t\tconst loadedExtensions = this.deps.getResourceLoader().getExtensions().extensions;\n\t\t\tconst targetAuthorities = new Map<string, \"loaded\" | ExtensionImportAuthority>();\n\t\t\tfor (const extension of this.deps.filterExtensionsForRuntime(\n\t\t\t\tloadedExtensions,\n\t\t\t\tthis._explicitLiveExtensionPaths,\n\t\t\t)) {\n\t\t\t\ttargetAuthorities.set(extension.path, \"loaded\");\n\t\t\t}\n\t\t\tfor (const path of this._explicitLiveExtensionPaths) {\n\t\t\t\tif (this.deps.isExtensionPathAllowed(path, \"explicit\")) {\n\t\t\t\t\ttargetAuthorities.set(path, \"explicit\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const path of allDiscoverablePaths) {\n\t\t\t\tif (this.deps.isExtensionPathAllowed(path, \"profile\") && !targetAuthorities.has(path)) {\n\t\t\t\t\ttargetAuthorities.set(path, \"profile\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply unloads first, then loads. A failed mutation stops the generation immediately; the\n\t\t\t// outer recovery reload restores one coherent runtime instead of compounding partial changes.\n\t\t\tfor (const extension of [...loadedExtensions]) {\n\t\t\t\tif (targetAuthorities.has(extension.path) || targetAuthorities.has(extension.resolvedPath)) continue;\n\t\t\t\tthis._assertReloadQuiescent(\"reconcile extensions\");\n\t\t\t\tawait this._unloadExtensionLive(extension.path, false, false);\n\t\t\t}\n\n\t\t\tfor (const [path, authority] of targetAuthorities) {\n\t\t\t\tif (authority === \"loaded\" || this.deps.getResourceLoader().getLoadedExtension(path)) continue;\n\t\t\t\tthis._assertReloadQuiescent(\"reconcile extensions\");\n\t\t\t\tthis._assertExtensionLoadAllowed(path, authority);\n\t\t\t\tawait this._loadExtensionLive(path, authority, false);\n\t\t\t}\n\n\t\t\t// Single notification at the end\n\t\t\tthis.deps.notifyExtensionsChanged();\n\t\t} catch (error) {\n\t\t\tawait this._recoverLiveExtensionFailure();\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\nexport async function resolveScoutModel(\n\tmodelRegistry: ModelRegistry,\n\tmodelSetting: string,\n\tagentDir: string,\n\tisModelExhausted: (model: Model<Api>) => boolean = () => false,\n) {\n\tconst model =\n\t\tmodelSetting === \"auto\"\n\t\t\t? findFastContextModel(modelRegistry)\n\t\t\t: resolveCliModel({ cliModel: modelSetting, modelRegistry }).model;\n\tif (!model) {\n\t\treturn { failure: `no scout model matched ${modelSetting}` };\n\t}\n\tif (isModelExhausted(model)) {\n\t\treturn { failure: `${model.provider}/${model.id} exhausted: quota` };\n\t}\n\tif (modelSetting === \"auto\") {\n\t\tconst modelRef = `${model.provider}/${model.id}`;\n\t\tconst fitness = FitnessStore.forAgentDir(agentDir)\n\t\t\t.getForHost()\n\t\t\t.find((entry) => entry.model === modelRef);\n\t\tconst verdict = evaluateSurfaceFitness(\"scout_auto\", fitness?.report);\n\t\tif (!verdict.fit) {\n\t\t\treturn verdict.reason === \"unprobed\"\n\t\t\t\t? { failure: `${modelRef} unprobed — run /fitness before auto-selection` }\n\t\t\t\t: { failure: `${modelRef} unfit (${verdict.lane} ${verdict.succeeded}/${verdict.total})` };\n\t\t}\n\t}\n\tconst auth = await modelRegistry.getApiKeyAndHeaders(model);\n\tif (!auth.ok) {\n\t\treturn { failure: auth.error ?? `no usable auth for scout model ${model.provider}/${model.id}` };\n\t}\n\treturn { model, apiKey: auth.apiKey, headers: auth.headers };\n}\n\nfunction findFastContextModel(modelRegistry: ModelRegistry) {\n\treturn modelRegistry.getAll().find((model) => {\n\t\tconst text = `${model.provider}/${model.id} ${model.name}`.toLowerCase();\n\t\treturn text.includes(\"fastcontext\");\n\t});\n}\n\nfunction resolveCwdPath(cwd: string, path: string): string {\n\treturn isAbsolute(path) ? path : join(cwd, path);\n}\n\nfunction countFileLines(path: string): number | undefined {\n\ttry {\n\t\treturn readFileSync(path, \"utf8\").split(/\\r?\\n/).length;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
package/dist/core/sdk.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type ThinkingLevel } from "@caupulican/pi-agent-core";
|
|
2
2
|
import { SessionManager } from "@caupulican/pi-agent-core/node";
|
|
3
|
-
import { type Model } from "@caupulican/pi-ai";
|
|
3
|
+
import { type Api, type Model } from "@caupulican/pi-ai";
|
|
4
4
|
import { AgentSession } from "./agent-session.ts";
|
|
5
5
|
import { AuthStorage } from "./auth-storage.ts";
|
|
6
6
|
import type { LoadExtensionsResult, SessionStartEvent, ToolDefinition } from "./extensions/index.ts";
|
|
7
7
|
import { ModelRegistry } from "./model-registry.ts";
|
|
8
|
+
import type { OrchestrationProfile } from "./orchestration/contracts.ts";
|
|
8
9
|
import type { ResourceLoader } from "./resource-loader.ts";
|
|
9
10
|
import type { ProfileDefinitionInput, ResourceProfileFilterSettings, ResourceProfileSettings } from "./settings-manager.ts";
|
|
10
11
|
import { SettingsManager } from "./settings-manager.ts";
|
|
@@ -19,7 +20,7 @@ export interface CreateAgentSessionOptions {
|
|
|
19
20
|
/** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */
|
|
20
21
|
modelRegistry?: ModelRegistry;
|
|
21
22
|
/** Model to use. Default: from settings, else first available */
|
|
22
|
-
model?: Model<
|
|
23
|
+
model?: Model<Api>;
|
|
23
24
|
/** Thinking level. Default: from settings, then the model's declared default, else 'medium'. */
|
|
24
25
|
thinkingLevel?: ThinkingLevel;
|
|
25
26
|
/**
|
|
@@ -34,7 +35,7 @@ export interface CreateAgentSessionOptions {
|
|
|
34
35
|
isChildSession?: boolean;
|
|
35
36
|
/** Models available for cycling (Ctrl+P in interactive mode) */
|
|
36
37
|
scopedModels?: Array<{
|
|
37
|
-
model: Model<
|
|
38
|
+
model: Model<Api>;
|
|
38
39
|
thinkingLevel?: ThinkingLevel;
|
|
39
40
|
}>;
|
|
40
41
|
/**
|
|
@@ -64,6 +65,8 @@ export interface CreateAgentSessionOptions {
|
|
|
64
65
|
resourceProfileJson?: string | string[];
|
|
65
66
|
/** Optional runtime profile selection. Never persisted to disk. */
|
|
66
67
|
resourceProfiles?: string[];
|
|
68
|
+
/** Immutable owner-authored orchestration policy for this session. */
|
|
69
|
+
orchestrationProfile?: OrchestrationProfile;
|
|
67
70
|
/** Custom tools to register (in addition to built-in tools). */
|
|
68
71
|
customTools?: ToolDefinition[];
|
|
69
72
|
/** Resource loader. When omitted, DefaultResourceLoader is used. */
|