@caupulican/pi-adaptative 0.94.1 → 0.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +32 -13
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +7 -4
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +201 -293
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +272 -392
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts +52 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js +118 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.ts +169 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/templates/builder-validator.json +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/templates/provider-prompt-smoke.json +1 -1
- package/dist/bundled-resources/extensions/tps/index.d.ts +3 -0
- package/dist/bundled-resources/extensions/tps/index.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tps/index.js +44 -0
- package/dist/bundled-resources/extensions/tps/index.js.map +1 -0
- package/dist/bundled-resources/extensions/tps/index.ts +48 -0
- package/dist/bundled-resources/skills/pi-harness-learning/SKILL.md +13 -7
- package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +11 -11
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +12 -3
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +11 -41
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +93 -160
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts +6 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js +26 -25
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
- package/dist/core/autonomy/lane-private-paths.js +2 -1
- package/dist/core/autonomy/lane-private-paths.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +8 -8
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +45 -30
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/worker-session-private-scope.d.ts +12 -0
- package/dist/core/autonomy/worker-session-private-scope.d.ts.map +1 -0
- package/dist/core/autonomy/worker-session-private-scope.js +42 -0
- package/dist/core/autonomy/worker-session-private-scope.js.map +1 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.d.ts +65 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.d.ts.map +1 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.js +145 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.js.map +1 -0
- package/dist/core/background-lane-controller.d.ts +1 -1
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +1 -1
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +8 -2
- package/dist/core/background-tool-task-controller.d.ts.map +1 -1
- package/dist/core/background-tool-task-controller.js +10 -2
- package/dist/core/background-tool-task-controller.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +3 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +12 -1
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/cost-guard-controller.d.ts +37 -0
- package/dist/core/cost-guard-controller.d.ts.map +1 -0
- package/dist/core/cost-guard-controller.js +71 -0
- package/dist/core/cost-guard-controller.js.map +1 -0
- package/dist/core/cost-guard.d.ts +9 -4
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +7 -3
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +0 -1
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +16 -3
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +114 -55
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts +1 -2
- package/dist/core/delegation/worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +19 -6
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +125 -40
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +3 -3
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js +13 -19
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts +3 -2
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +54 -39
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.d.ts +3 -3
- package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.js +7 -7
- package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
- package/dist/core/delegation/worker-machine-scope.d.ts +12 -0
- package/dist/core/delegation/worker-machine-scope.d.ts.map +1 -0
- package/dist/core/delegation/worker-machine-scope.js +38 -0
- package/dist/core/delegation/worker-machine-scope.js.map +1 -0
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +6 -1
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +5 -7
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +1 -4
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +3 -2
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +50 -25
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/durable-custom-message-turn-controller.d.ts +6 -0
- package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
- package/dist/core/durable-custom-message-turn-controller.js +38 -15
- package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
- package/dist/core/extension-binding-controller.d.ts +5 -1
- package/dist/core/extension-binding-controller.d.ts.map +1 -1
- package/dist/core/extension-binding-controller.js +15 -0
- package/dist/core/extension-binding-controller.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts +3 -1
- package/dist/core/extension-import-authority.d.ts.map +1 -1
- package/dist/core/extension-import-authority.js +15 -0
- package/dist/core/extension-import-authority.js.map +1 -1
- package/dist/core/extensions/factory-runtime.d.ts.map +1 -1
- package/dist/core/extensions/factory-runtime.js +5 -0
- package/dist/core/extensions/factory-runtime.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +8 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.d.ts +14 -0
- package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.js +188 -72
- package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +2 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +8 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +5 -4
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +23 -19
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/auto-learn-settings.d.ts +84 -0
- package/dist/core/learning/auto-learn-settings.d.ts.map +1 -0
- package/dist/core/learning/auto-learn-settings.js +66 -0
- package/dist/core/learning/auto-learn-settings.js.map +1 -0
- package/dist/core/learning/reflection-engine.d.ts +4 -0
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +48 -10
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/local-prefix-warm-controller.d.ts +24 -0
- package/dist/core/local-prefix-warm-controller.d.ts.map +1 -0
- package/dist/core/local-prefix-warm-controller.js +79 -0
- package/dist/core/local-prefix-warm-controller.js.map +1 -0
- package/dist/core/memory/providers/file-store.d.ts +2 -0
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +71 -15
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/worker-memory-tools.d.ts +5 -0
- package/dist/core/memory/worker-memory-tools.d.ts.map +1 -0
- package/dist/core/memory/worker-memory-tools.js +5 -0
- package/dist/core/memory/worker-memory-tools.js.map +1 -0
- package/dist/core/model-capability.d.ts +7 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +12 -0
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -10
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +3 -2
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +3 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +16 -12
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +2 -2
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js +6 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +14 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/task-profile-writer.d.ts +7 -4
- package/dist/core/orchestration/task-profile-writer.d.ts.map +1 -1
- package/dist/core/orchestration/task-profile-writer.js +71 -59
- package/dist/core/orchestration/task-profile-writer.js.map +1 -1
- package/dist/core/orchestration/thinking-level-schema.d.ts +7 -0
- package/dist/core/orchestration/thinking-level-schema.d.ts.map +1 -0
- package/dist/core/orchestration/thinking-level-schema.js +19 -0
- package/dist/core/orchestration/thinking-level-schema.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js +12 -5
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +5 -2
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/provider-prompt-contracts.d.ts +6 -5
- package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
- package/dist/core/provider-prompt-contracts.js +9 -11
- package/dist/core/provider-prompt-contracts.js.map +1 -1
- package/dist/core/provider-request-context-controller.d.ts +2 -0
- package/dist/core/provider-request-context-controller.d.ts.map +1 -1
- package/dist/core/provider-request-context-controller.js +10 -3
- package/dist/core/provider-request-context-controller.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +56 -27
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +206 -117
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +6 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts.map +1 -1
- package/dist/core/risk-classifier.js +22 -2
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +1 -0
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +25 -14
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +55 -10
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/session-role.d.ts +6 -8
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +8 -18
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/settings-manager.d.ts +20 -16
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +75 -50
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skill-vault.d.ts +15 -0
- package/dist/core/skill-vault.d.ts.map +1 -1
- package/dist/core/skill-vault.js +79 -45
- package/dist/core/skill-vault.js.map +1 -1
- package/dist/core/skills.d.ts +3 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -6
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +3 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +73 -13
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +6 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +3 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js +13 -2
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/toolkit/script-runner.d.ts +2 -1
- package/dist/core/toolkit/script-runner.d.ts.map +1 -1
- package/dist/core/toolkit/script-runner.js +10 -2
- package/dist/core/toolkit/script-runner.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +1 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +1 -1
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +4 -15
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +111 -73
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/goal.d.ts +3 -4
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +30 -23
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +7 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +58 -9
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/profile-writer.d.ts +2 -8
- package/dist/core/tools/profile-writer.d.ts.map +1 -1
- package/dist/core/tools/profile-writer.js +6 -18
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
- package/dist/core/tools/run-toolkit-script.js +2 -2
- package/dist/core/tools/run-toolkit-script.js.map +1 -1
- package/dist/core/tools/skill-audit.d.ts +28 -1
- package/dist/core/tools/skill-audit.d.ts.map +1 -1
- package/dist/core/tools/skill-audit.js +56 -12
- package/dist/core/tools/skill-audit.js.map +1 -1
- package/dist/core/tools/skill.d.ts +12 -1
- package/dist/core/tools/skill.d.ts.map +1 -1
- package/dist/core/tools/skill.js +52 -0
- package/dist/core/tools/skill.js.map +1 -1
- package/dist/core/tools/skillify.d.ts.map +1 -1
- package/dist/core/tools/skillify.js +16 -7
- package/dist/core/tools/skillify.js.map +1 -1
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +2 -1
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +4 -16
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +5 -20
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/worktree-sync/codes.d.ts +1 -2
- package/dist/core/worktree-sync/codes.d.ts.map +1 -1
- package/dist/core/worktree-sync/codes.js +1 -2
- package/dist/core/worktree-sync/codes.js.map +1 -1
- package/dist/core/worktree-sync/lane-gate.d.ts +4 -8
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
- package/dist/core/worktree-sync/lane-gate.js +5 -51
- package/dist/core/worktree-sync/lane-gate.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +6 -7
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +30 -207
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/autonomy-commands.js +2 -2
- package/dist/modes/interactive/autonomy-commands.js.map +1 -1
- package/dist/modes/interactive/components/agents-overlay.d.ts +16 -4
- package/dist/modes/interactive/components/agents-overlay.d.ts.map +1 -1
- package/dist/modes/interactive/components/agents-overlay.js +108 -29
- package/dist/modes/interactive/components/agents-overlay.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +17 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.js +2 -2
- package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +150 -73
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +5 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +8 -4
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.js +10 -0
- package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
- package/docs/extensions.md +10 -0
- package/docs/harness-architecture.md +28 -32
- package/docs/index.md +2 -1
- package/docs/keybindings.md +2 -0
- package/docs/process-matrix.md +8 -6
- package/docs/resources.md +1 -1
- package/docs/settings.md +61 -51
- package/docs/task-steps.md +2 -0
- package/docs/tmux-agent-manager.md +48 -41
- package/docs/usage.md +1 -1
- package/docs/work-lifecycle.md +137 -0
- package/docs/worker-profiles.md +8 -6
- package/docs/worktree-sync.md +26 -20
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +0 -133
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +0 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +0 -199
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +0 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +0 -312
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { basename } from "node:path";
|
|
3
3
|
import { AgentBusyError } from "@caupulican/pi-agent-core/agent";
|
|
4
4
|
import { compactToolResultDetailsForRetention } from "@caupulican/pi-agent-core/message-retention";
|
|
5
5
|
import { createCustomMessage } from "@caupulican/pi-agent-core/messages";
|
|
6
|
-
import { projectToolsForProvider } from "@caupulican/pi-agent-core/provider-tool-projection";
|
|
7
6
|
import { DEFAULT_STREAM_IDLE, withStreamIdleWatchdog, } from "@caupulican/pi-agent-core/reliability";
|
|
8
7
|
import { NATIVE_TOOL_PROTOCOL_RESIDUE_ERROR } from "@caupulican/pi-agent-core/tool-protocol-residue";
|
|
9
|
-
import {
|
|
8
|
+
import { modelsAreEqual } from "@caupulican/pi-ai/models";
|
|
10
9
|
import { cleanupSessionResources } from "@caupulican/pi-ai/session-resources";
|
|
11
10
|
import { streamSimple } from "@caupulican/pi-ai/stream";
|
|
12
11
|
import { getAgentDir } from "../config.js";
|
|
@@ -22,7 +21,7 @@ import { CompactionController } from "./compaction-controller.js";
|
|
|
22
21
|
import { CompactionSupport } from "./compaction-support.js";
|
|
23
22
|
import { buildContextCompositionReport, formatContextCompositionDashboard, } from "./context/context-composition.js";
|
|
24
23
|
import { ContextPipeline } from "./context-pipeline.js";
|
|
25
|
-
import {
|
|
24
|
+
import { CostGuardController } from "./cost-guard-controller.js";
|
|
26
25
|
import { appendWorkerClaimSnapshot, getLatestWorkerClaimSnapshot, getWorkerClaimSnapshots, } from "./delegation/session-worker-claim.js";
|
|
27
26
|
import { DurableCustomMessageTurnController } from "./durable-custom-message-turn-controller.js";
|
|
28
27
|
import { ExtensionBindingController } from "./extension-binding-controller.js";
|
|
@@ -38,6 +37,7 @@ import { constrainStreamIdleToHttpTimeout } from "./http-dispatcher.js";
|
|
|
38
37
|
import { HumanInputController } from "./human-input-controller.js";
|
|
39
38
|
import { appendLearningDecisionSnapshot, getLearningDecisionSnapshots } from "./learning/session-learning-decision.js";
|
|
40
39
|
import { SkillCurator } from "./learning/skill-curator.js";
|
|
40
|
+
import { isWarmableLocalModel, LocalPrefixWarmController } from "./local-prefix-warm-controller.js";
|
|
41
41
|
import { LocalRuntimeController } from "./local-runtime-controller.js";
|
|
42
42
|
import { MemoryController } from "./memory-controller.js";
|
|
43
43
|
import { deriveModelCapabilityProfile, evaluateLaneWorkerRefusal, filterToolNamesForCapability, } from "./model-capability.js";
|
|
@@ -45,8 +45,6 @@ import { isLocalOrManagedRouterModel } from "./model-router/tool-escalation.js";
|
|
|
45
45
|
import { formatModelRouterModel, ModelRouterController } from "./model-router-controller.js";
|
|
46
46
|
import { ModelSelectionController } from "./model-selection-controller.js";
|
|
47
47
|
import { ModelAdaptationStore } from "./models/adaptation-store.js";
|
|
48
|
-
import { HF_TRANSFORMERS_PROVIDER, OLLAMA_PROVIDER } from "./models/local-registration.js";
|
|
49
|
-
import { isLoopbackModelEndpoint } from "./models/model-endpoint.js";
|
|
50
48
|
import { DEFAULT_ADAPTIVE_STREAM_IDLE_CEILING_MS, estimateContextPromptTokens, resolveAdaptiveStreamIdleOptions, withModelPerfProfile, } from "./models/perf-profile.js";
|
|
51
49
|
import { resolveConfiguredOrchestrationModel } from "./orchestration/model-binding.js";
|
|
52
50
|
import { validateOrchestrationProfile } from "./orchestration/profile-registry.js";
|
|
@@ -129,15 +127,7 @@ export class AgentSession {
|
|
|
129
127
|
this._turnIndex = 0;
|
|
130
128
|
/** Per-agent persistent shell session identity: stable across runtime reloads, disposed with the session. */
|
|
131
129
|
this._shellSessionKey = `agent:${randomUUID()}`;
|
|
132
|
-
this._completedPrefixWarms = new Set();
|
|
133
130
|
this._gatewayRegistry = new GatewayRegistry();
|
|
134
|
-
/**
|
|
135
|
-
* `getSpawnedUsage().cost` snapshotted at the start of the CURRENT foreground prompt cycle (see
|
|
136
|
-
* `_promptUnserialized`), so the cost guard can attribute only background/spawned spend since THIS
|
|
137
|
-
* turn began, not the session's entire lifetime spend. Reset on every new user prompt; every
|
|
138
|
-
* round-trip within the same turn (tool-call iterations) shares this one baseline.
|
|
139
|
-
*/
|
|
140
|
-
this._costGuardTurnBaselineUsd = 0;
|
|
141
131
|
this._disposed = false;
|
|
142
132
|
this._reflectionAbort = new AbortController();
|
|
143
133
|
this._extensionMode = "print";
|
|
@@ -239,13 +229,20 @@ export class AgentSession {
|
|
|
239
229
|
}
|
|
240
230
|
}
|
|
241
231
|
if (event.type === "agent_end" && !this._willRetryAfterAgentEnd(event)) {
|
|
242
|
-
const
|
|
243
|
-
const reflectionTurn = this._reflection.scheduleFromTurn(event.messages, contextHeadroomPct);
|
|
232
|
+
const reflectionTurn = this._reflection.analyzeCompletedTurn(event.messages);
|
|
244
233
|
// The shared projection excludes raw tool-result payloads and bounds both roles before any
|
|
245
|
-
//
|
|
234
|
+
// deterministic memory sync. No reflection provider request is scheduled at this boundary.
|
|
246
235
|
this._memory.scheduleTurnSync(reflectionTurn.userText, reflectionTurn.assistantText);
|
|
236
|
+
if (reflectionTurn.trigger !== "none")
|
|
237
|
+
this._reflection.queueCurrentTurnCue(reflectionTurn.trigger);
|
|
247
238
|
this._goals.endQueuedOwnerChatGoalExecution();
|
|
248
239
|
}
|
|
240
|
+
// Error/abort turns bypass the normal steering boundary, and a completion can arrive after the
|
|
241
|
+
// final normal poll. agent_end is the fallback before foreground recovery decides whether queued
|
|
242
|
+
// steering requires one continuation; turn_end is intentionally not a flush.
|
|
243
|
+
if (event.type === "agent_end") {
|
|
244
|
+
this._terminalHandoffs.flushProviderBoundary();
|
|
245
|
+
}
|
|
249
246
|
};
|
|
250
247
|
this.agent = config.agent;
|
|
251
248
|
// Bound every provider stream this session starts against a silently dead connection: a
|
|
@@ -264,7 +261,7 @@ export class AgentSession {
|
|
|
264
261
|
const resolvedReasoning = previousResolveRequestReasoning
|
|
265
262
|
? previousResolveRequestReasoning(reasoning, request)
|
|
266
263
|
: reasoning;
|
|
267
|
-
return this.
|
|
264
|
+
return this._costGuard.resolveRequestReasoning(request.model, request.context, resolvedReasoning, request.maxTokens);
|
|
268
265
|
};
|
|
269
266
|
const profiledStreamFn = withModelPerfProfile(baseStreamFn, {
|
|
270
267
|
modelKey: (model) => formatModelRouterModel(model),
|
|
@@ -287,7 +284,7 @@ export class AgentSession {
|
|
|
287
284
|
base: httpBounded.options,
|
|
288
285
|
profile,
|
|
289
286
|
promptTokens: estimateContextPromptTokens(context),
|
|
290
|
-
localClass:
|
|
287
|
+
localClass: isWarmableLocalModel(model),
|
|
291
288
|
ceilingMs: httpBounded.adaptiveCeilingMs ?? DEFAULT_ADAPTIVE_STREAM_IDLE_CEILING_MS,
|
|
292
289
|
});
|
|
293
290
|
return { ...httpBounded.options, ...adaptive };
|
|
@@ -352,6 +349,15 @@ export class AgentSession {
|
|
|
352
349
|
resolveConfiguredTierModel: (tier) => this._modelRouter.resolveConfiguredTierModel(tier),
|
|
353
350
|
formatModel: (model) => formatModelRouterModel(model),
|
|
354
351
|
});
|
|
352
|
+
this._localPrefixWarm = new LocalPrefixWarmController({
|
|
353
|
+
getStreamFn: () => this.agent.streamFn,
|
|
354
|
+
getTools: () => this.agent.state.tools,
|
|
355
|
+
getSystemPrompt: () => this._baseSystemPrompt,
|
|
356
|
+
getRequestHooks: () => ({ onPayload: this.agent.onPayload, onResponse: this.agent.onResponse }),
|
|
357
|
+
isRawStreamSimple: (streamFn) => this._isRawStreamSimple(streamFn),
|
|
358
|
+
getRequiredRequestAuth: (model) => this._getRequiredRequestAuth(model),
|
|
359
|
+
ensureManagedModelReady: (model) => this._localRuntimeController.ensureIsolatedModelReady(model),
|
|
360
|
+
});
|
|
355
361
|
this._systemPromptBuilder = new SystemPromptBuilder({
|
|
356
362
|
getCwd: () => this._cwd,
|
|
357
363
|
getSettingsManager: () => this.settingsManager,
|
|
@@ -363,6 +369,7 @@ export class AgentSession {
|
|
|
363
369
|
getModelAdaptationRules: () => this._toolProtocol.getAdaptationRulesForPrompt(),
|
|
364
370
|
getActiveExtensions: () => this._extensionRunner.activeExtensions,
|
|
365
371
|
getModelCapabilityProfile: () => this.getModelCapabilityProfile(),
|
|
372
|
+
isChildSession: () => this._isChildSession,
|
|
366
373
|
// The evidence-gated tool-selection hint block — self-gated by kill switch/evidence
|
|
367
374
|
// thresholds inside getActiveHints() itself, so this is a plain always-on pass-through.
|
|
368
375
|
getToolSelectionHints: () => this._toolSelection.getActiveHints(),
|
|
@@ -380,6 +387,12 @@ export class AgentSession {
|
|
|
380
387
|
getLearningAuditRecords: () => this.getLearningAuditRecords(),
|
|
381
388
|
});
|
|
382
389
|
this._modelRegistry = config.modelRegistry;
|
|
390
|
+
this._costGuard = new CostGuardController({
|
|
391
|
+
getSettings: () => this.settingsManager.getCostGuardSettings(),
|
|
392
|
+
getCompactionReserveTokens: () => this.settingsManager.getCompactionReserveTokens(),
|
|
393
|
+
getSpawnedUsageCost: () => this.getSpawnedUsage().cost,
|
|
394
|
+
isUnmeteredSubscription: (model) => model.provider === "openai-codex" && this._modelRegistry.isUsingOAuth(model),
|
|
395
|
+
});
|
|
383
396
|
this._humanInput = new HumanInputController({
|
|
384
397
|
getSessionManager: () => this.sessionManager,
|
|
385
398
|
getUIContext: () => this._extensionUIContext,
|
|
@@ -414,6 +427,8 @@ export class AgentSession {
|
|
|
414
427
|
getModelRegistry: () => this._modelRegistry,
|
|
415
428
|
isModelExhausted: (model) => this._foregroundRecovery.isModelExhausted(`${model.provider}/${model.id}`),
|
|
416
429
|
getModel: () => this.model ?? undefined,
|
|
430
|
+
getForegroundThinkingLevel: () => this.thinkingLevel,
|
|
431
|
+
getForegroundToolNames: () => this.getActiveToolNames(),
|
|
417
432
|
isDelegateToolActive: () => this.getActiveToolNames().includes("delegate"),
|
|
418
433
|
isGoalToolActive: () => hasGoalContinuationControl(this.getActiveToolNames()),
|
|
419
434
|
getCapabilityEnvelope: () => this.capabilityEnvelope,
|
|
@@ -428,6 +443,15 @@ export class AgentSession {
|
|
|
428
443
|
saveEvidenceBundleSnapshot: (bundle) => this.saveEvidenceBundleSnapshot(bundle),
|
|
429
444
|
saveWorkerClaimSnapshot: (claim, request) => this.saveWorkerClaimSnapshot(claim, request),
|
|
430
445
|
readMemoryForLane: (query) => this._memory.readMemoryForLane(query),
|
|
446
|
+
getArtifactStore: () => this._getToolArtifactStore(),
|
|
447
|
+
getSkillReadBroker: () => ({
|
|
448
|
+
search: (query) => this._skillVault.search(query),
|
|
449
|
+
read: (name) => this._skillVault.read(name),
|
|
450
|
+
}),
|
|
451
|
+
getSkillAuditSource: () => ({
|
|
452
|
+
getSkills: () => this._skillVault.getSkillsSnapshot(),
|
|
453
|
+
redactPath: (path) => `skill:${createHash("sha256").update(path).digest("hex").slice(0, 12)}`,
|
|
454
|
+
}),
|
|
431
455
|
addSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),
|
|
432
456
|
runIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),
|
|
433
457
|
// RAW loop, deliberately bypassing the public `continueGoalLoop` — that method now delegates
|
|
@@ -482,6 +506,7 @@ export class AgentSession {
|
|
|
482
506
|
});
|
|
483
507
|
this._backgroundToolTasks = new BackgroundToolTaskController({
|
|
484
508
|
getSessionId: () => this.sessionManager.getSessionId(),
|
|
509
|
+
getGoalId: () => this._goals.getExecutionGoalId(),
|
|
485
510
|
getSessionLineageIds: () => this.sessionManager.getSessionLineageIds(),
|
|
486
511
|
getArtifactStore: () => this._getToolArtifactStore(),
|
|
487
512
|
loadPersistedRecordsNewestFirst: () => loadBackgroundToolTaskRecordsNewestFirst(this.sessionManager),
|
|
@@ -549,6 +574,7 @@ export class AgentSession {
|
|
|
549
574
|
enqueueRelevanceCuration: (messages, report) => this._enqueueRelevanceCuration(messages, report),
|
|
550
575
|
maybeDrainBrainCuration: () => this._maybeDrainBrainCuration(),
|
|
551
576
|
appendMemoryEvidence: (messages, report) => this._maybeAppendMemoryEvidenceBlock(messages, report),
|
|
577
|
+
previewReflectionCue: () => this._reflection.previewCurrentTurnCue(),
|
|
552
578
|
getGoalState: () => this.getGoalStateSnapshot(),
|
|
553
579
|
skillVault: this._skillVault,
|
|
554
580
|
});
|
|
@@ -587,6 +613,7 @@ export class AgentSession {
|
|
|
587
613
|
this._durableCustomMessageTurns = new DurableCustomMessageTurnController({
|
|
588
614
|
foreground: this._foregroundRecovery,
|
|
589
615
|
goals: this._goals,
|
|
616
|
+
enqueueSteeringMessage: (message) => this.agent.steer(message),
|
|
590
617
|
});
|
|
591
618
|
this._terminalHandoffs = new ForegroundTerminalHandoffController({
|
|
592
619
|
foreground: this._foregroundRecovery,
|
|
@@ -595,6 +622,7 @@ export class AgentSession {
|
|
|
595
622
|
getWorkerClaimSnapshot: (laneId) => getLatestWorkerClaimSnapshot(getActiveSessionBranchEntries(this.sessionManager), laneId),
|
|
596
623
|
getWorkerResult: (laneId) => this._backgroundLanes.getWorkerResult(laneId),
|
|
597
624
|
startCustomMessageTurn: (message, lease, goalId) => this._durableCustomMessageTurns.start(message, lease, goalId),
|
|
625
|
+
enqueueCustomMessageTurn: (message) => this._durableCustomMessageTurns.enqueue(message),
|
|
598
626
|
sendCustomMessage: (message, options, lease) => this._sendCustomMessage(message, options, lease),
|
|
599
627
|
warn: (message) => this._emit({ type: "warning", message }),
|
|
600
628
|
});
|
|
@@ -639,6 +667,8 @@ export class AgentSession {
|
|
|
639
667
|
getSettingsManager: () => this.settingsManager,
|
|
640
668
|
getSessionManager: () => this.sessionManager,
|
|
641
669
|
getAgentDir: () => this._agentDir,
|
|
670
|
+
getCwd: () => this._cwd,
|
|
671
|
+
getSkillsForAudit: () => this._resourceLoader.getActiveSkills(),
|
|
642
672
|
isChildSession: () => this._isChildSession,
|
|
643
673
|
isDisposed: () => this._disposed,
|
|
644
674
|
getReflectionSignal: () => this._reflectionAbort.signal,
|
|
@@ -957,79 +987,15 @@ export class AgentSession {
|
|
|
957
987
|
activeToolNames: this._initialActiveToolNames,
|
|
958
988
|
includeAllExtensionTools: true,
|
|
959
989
|
});
|
|
960
|
-
this.
|
|
990
|
+
this._unsubscribeSettingsChanges = this.settingsManager.subscribeChanges(() => {
|
|
991
|
+
this._refreshBaseSystemPrompt();
|
|
992
|
+
});
|
|
993
|
+
this._localPrefixWarm.schedule(this.agent.state.model);
|
|
961
994
|
}
|
|
962
995
|
/** Model registry for API key resolution and model discovery */
|
|
963
996
|
get modelRegistry() {
|
|
964
997
|
return this._modelRegistry;
|
|
965
998
|
}
|
|
966
|
-
_scheduleLocalPrefixWarm(model, _reason) {
|
|
967
|
-
if (!model || !this._isWarmableLocalModel(model))
|
|
968
|
-
return;
|
|
969
|
-
const modelKey = formatModelRouterModel(model);
|
|
970
|
-
if (this._completedPrefixWarms.has(modelKey) || this._prefixWarmer?.modelKey === modelKey)
|
|
971
|
-
return;
|
|
972
|
-
this._cancelPrefixWarm();
|
|
973
|
-
const controller = new AbortController();
|
|
974
|
-
const timer = setTimeout(() => {
|
|
975
|
-
const warmer = this._prefixWarmer;
|
|
976
|
-
if (!warmer || warmer.controller !== controller || controller.signal.aborted)
|
|
977
|
-
return;
|
|
978
|
-
warmer.timer = undefined;
|
|
979
|
-
void this._runLocalPrefixWarm(model, modelKey, controller);
|
|
980
|
-
}, 0);
|
|
981
|
-
timer.unref?.();
|
|
982
|
-
this._prefixWarmer = { modelKey, controller, timer };
|
|
983
|
-
}
|
|
984
|
-
_cancelPrefixWarm() {
|
|
985
|
-
const warmer = this._prefixWarmer;
|
|
986
|
-
if (!warmer)
|
|
987
|
-
return;
|
|
988
|
-
if (warmer.timer)
|
|
989
|
-
clearTimeout(warmer.timer);
|
|
990
|
-
warmer.controller.abort(new Error("prefix warmer preempted"));
|
|
991
|
-
this._prefixWarmer = undefined;
|
|
992
|
-
}
|
|
993
|
-
async _runLocalPrefixWarm(model, modelKey, controller) {
|
|
994
|
-
try {
|
|
995
|
-
const options = {
|
|
996
|
-
maxTokens: 1,
|
|
997
|
-
signal: controller.signal,
|
|
998
|
-
onPayload: this.agent.onPayload,
|
|
999
|
-
onResponse: this.agent.onResponse,
|
|
1000
|
-
};
|
|
1001
|
-
if (this._isRawStreamSimple(this.agent.streamFn)) {
|
|
1002
|
-
const auth = await this._getRequiredRequestAuth(model);
|
|
1003
|
-
options.apiKey = auth.apiKey;
|
|
1004
|
-
options.headers = auth.headers;
|
|
1005
|
-
}
|
|
1006
|
-
if (controller.signal.aborted)
|
|
1007
|
-
return;
|
|
1008
|
-
if (model.provider === OLLAMA_PROVIDER || model.provider === HF_TRANSFORMERS_PROVIDER) {
|
|
1009
|
-
await this._localRuntimeController.ensureIsolatedModelReady(model);
|
|
1010
|
-
}
|
|
1011
|
-
if (controller.signal.aborted)
|
|
1012
|
-
return;
|
|
1013
|
-
const stream = await this.agent.streamFn(model, {
|
|
1014
|
-
systemPrompt: this._baseSystemPrompt,
|
|
1015
|
-
tools: projectToolsForProvider(this.agent.state.tools),
|
|
1016
|
-
messages: [],
|
|
1017
|
-
}, options);
|
|
1018
|
-
await stream.result();
|
|
1019
|
-
if (!controller.signal.aborted)
|
|
1020
|
-
this._completedPrefixWarms.add(modelKey);
|
|
1021
|
-
}
|
|
1022
|
-
catch {
|
|
1023
|
-
// Best-effort cache warm only; a miss must never affect the real turn.
|
|
1024
|
-
}
|
|
1025
|
-
finally {
|
|
1026
|
-
if (this._prefixWarmer?.controller === controller)
|
|
1027
|
-
this._prefixWarmer = undefined;
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
_isWarmableLocalModel(model) {
|
|
1031
|
-
return model.api === "openai-completions" && isLoopbackModelEndpoint(model.baseUrl);
|
|
1032
|
-
}
|
|
1033
999
|
/**
|
|
1034
1000
|
* True when the session's stream fn is the raw `streamSimple` provider entry (directly, or as the
|
|
1035
1001
|
* base wrapped by the idle watchdog at construction). Callers use this to decide whether request
|
|
@@ -1084,58 +1050,16 @@ export class AgentSession {
|
|
|
1084
1050
|
_resolveCompactionThinkingLevel(compactionModel, sessionModel) {
|
|
1085
1051
|
return this._compactionSupport.resolveThinkingLevel(this.thinkingLevel, compactionModel, sessionModel);
|
|
1086
1052
|
}
|
|
1087
|
-
/**
|
|
1088
|
-
* Resolve the foreground request's cost policy after routing/context conversion, when the actual
|
|
1089
|
-
* model, full system prompt, converted messages, and tool schemas are known. The guard is a
|
|
1090
|
-
* projection threshold rather than a hard output cap: warning mode never reduces capability, while
|
|
1091
|
-
* opt-in downgrade changes only this request's reasoning effort. Best-effort: never throws.
|
|
1092
|
-
*
|
|
1093
|
-
* The ceiling is turn-cumulative: the next foreground call's projection is folded together with
|
|
1094
|
-
* background/research/worker/reflection spend recorded SINCE THIS TURN BEGAN — {@link getSpawnedUsage}'s
|
|
1095
|
-
* already-recorded rollup (the same read-side-deduped total the footer's SUBAGENTS line uses) minus the
|
|
1096
|
-
* baseline snapshotted before a new turn enters routing in `_promptUnserialized`
|
|
1097
|
-
* ({@link _costGuardTurnBaselineUsd}) — so a
|
|
1098
|
-
* turn that is cheap in the foreground but has spent heavily via background lanes THIS turn still trips
|
|
1099
|
-
* the warning, while a prior turn's background spend does not keep every later turn's guard stuck
|
|
1100
|
-
* "over". A background lane that finishes mid-turn is attributed to whichever turn it completes in.
|
|
1101
|
-
* Per-lane dollar caps (research/worker `maxUsd`) are separate and untouched by this guard.
|
|
1102
|
-
*/
|
|
1103
|
-
_resolveCostGuardRequestReasoning(model, context, reasoning, requestMaxTokens) {
|
|
1104
|
-
try {
|
|
1105
|
-
const guard = this.settingsManager.getCostGuardSettings();
|
|
1106
|
-
const isChatGptSubscription = model.provider === "openai-codex" && this._modelRegistry.isUsingOAuth(model);
|
|
1107
|
-
if (guard.maxTurnUsd <= 0 || !model.cost || isChatGptSubscription) {
|
|
1108
|
-
this._lastCostGuardDecision = undefined;
|
|
1109
|
-
return reasoning;
|
|
1110
|
-
}
|
|
1111
|
-
const inputTokens = estimateContextPromptTokens(context);
|
|
1112
|
-
// Use an explicit request cap when present; otherwise project against the session response
|
|
1113
|
-
// reserve instead of a frontier model's theoretical 128K output maximum.
|
|
1114
|
-
const maxOutputTokens = Math.min(model.maxTokens ?? 4096, requestMaxTokens ?? this.settingsManager.getCompactionReserveTokens());
|
|
1115
|
-
const estUsd = estimateTurnCostUsd({
|
|
1116
|
-
inputTokens,
|
|
1117
|
-
maxOutputTokens,
|
|
1118
|
-
cost: model.cost,
|
|
1119
|
-
longContextPricing: model.longContextPricing,
|
|
1120
|
-
});
|
|
1121
|
-
// Only spend recorded SINCE this turn's baseline counts -- never negative (a dedup/rollup
|
|
1122
|
-
// correction could otherwise move the total backward transiently).
|
|
1123
|
-
const cumulativeBackgroundUsd = Math.max(0, this.getSpawnedUsage().cost - this._costGuardTurnBaselineUsd);
|
|
1124
|
-
const decision = evaluateCostGuard(estUsd, { maxTurnUsd: guard.maxTurnUsd, action: guard.action }, cumulativeBackgroundUsd);
|
|
1125
|
-
this._lastCostGuardDecision = decision;
|
|
1126
|
-
if (!decision.over || guard.action !== "downgrade" || reasoning === undefined)
|
|
1127
|
-
return reasoning;
|
|
1128
|
-
const next = downgradeReasoning(reasoning, getSupportedThinkingLevels(model), model.thinkingLevelMap);
|
|
1129
|
-
return next;
|
|
1130
|
-
}
|
|
1131
|
-
catch {
|
|
1132
|
-
// cost guard must never disrupt a turn
|
|
1133
|
-
return reasoning;
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
1053
|
/** Latest cost-guard decision (for the host footer/UI to surface a warning). Undefined if disabled. */
|
|
1137
1054
|
getLastCostGuardDecision() {
|
|
1138
|
-
return this.
|
|
1055
|
+
return this._costGuard.getLastDecision();
|
|
1056
|
+
}
|
|
1057
|
+
/** Apply an explicit guard choice and invalidate all prior decision/envelope projections immediately. */
|
|
1058
|
+
setCostGuardSettings(settings, scope = "global") {
|
|
1059
|
+
this.settingsManager.setCostGuardSettings(settings, scope);
|
|
1060
|
+
this._costGuard.invalidateDecision();
|
|
1061
|
+
if (this._currentForegroundEnvelope)
|
|
1062
|
+
this._refreshForegroundEnvelope();
|
|
1139
1063
|
}
|
|
1140
1064
|
get _skillCurator() {
|
|
1141
1065
|
if (!this._skillCuratorInstance) {
|
|
@@ -1179,6 +1103,13 @@ export class AgentSession {
|
|
|
1179
1103
|
}
|
|
1180
1104
|
_installAgentTurnRefresh() {
|
|
1181
1105
|
const previousPrepareNextTurn = this.agent.prepareNextTurn?.bind(this.agent);
|
|
1106
|
+
const previousBeforeSteeringPoll = this.agent.beforeSteeringPoll?.bind(this.agent);
|
|
1107
|
+
this.agent.beforeSteeringPoll = async (signal) => {
|
|
1108
|
+
await previousBeforeSteeringPoll?.(signal);
|
|
1109
|
+
// This is later than async turn preparation and the graceful-stop check, making it the
|
|
1110
|
+
// authoritative last-moment inbox refresh before the queue is drained.
|
|
1111
|
+
this._terminalHandoffs.flushProviderBoundary();
|
|
1112
|
+
};
|
|
1182
1113
|
this.agent.prepareNextTurn = async (signal) => {
|
|
1183
1114
|
const previous = previousPrepareNextTurn ? await previousPrepareNextTurn(signal) : undefined;
|
|
1184
1115
|
const snapshot = this._createAgentContextSnapshot();
|
|
@@ -1741,18 +1672,21 @@ export class AgentSession {
|
|
|
1741
1672
|
safely(() => this._backgroundLanes.clearGoalAutoContinueTimer());
|
|
1742
1673
|
safely(() => this._backgroundLanes.clearResearchLaneTimer());
|
|
1743
1674
|
safely(() => this._foregroundRecovery.shutdown());
|
|
1675
|
+
safely(() => this._durableCustomMessageTurns.shutdown());
|
|
1744
1676
|
safely(() => this.abortRetry());
|
|
1745
1677
|
safely(() => this.abortCompaction());
|
|
1746
1678
|
safely(() => this.abortBranchSummary());
|
|
1747
1679
|
safely(() => this.abortBash());
|
|
1748
1680
|
safely(() => this._skillVault.unload());
|
|
1681
|
+
safely(() => this._unsubscribeSettingsChanges?.());
|
|
1682
|
+
this._unsubscribeSettingsChanges = undefined;
|
|
1749
1683
|
trackRequired(() => disposeShellExecutionSessionAndWait(this._shellSessionKey));
|
|
1750
|
-
safely(() => this.
|
|
1684
|
+
safely(() => this._localPrefixWarm.cancel());
|
|
1751
1685
|
safely(() => this.agent.abort());
|
|
1752
1686
|
track(() => this._gatewayRegistry.stop());
|
|
1753
1687
|
track(() => this._backgroundToolTasks.shutdown());
|
|
1754
1688
|
track(() => this._runtimeBuilder.dispose());
|
|
1755
|
-
safely(() => this._reflection.
|
|
1689
|
+
safely(() => this._reflection.dispose());
|
|
1756
1690
|
safely(() => this._reflectionAbort.abort());
|
|
1757
1691
|
safely(() => this._backgroundLanes.abortInFlightLanes());
|
|
1758
1692
|
safely(() => this._providerRequestRuntime.dispose());
|
|
@@ -1765,12 +1699,7 @@ export class AgentSession {
|
|
|
1765
1699
|
track(() => this._resourceLoader.dispose?.() ?? Promise.resolve());
|
|
1766
1700
|
safely(() => this._disconnectFromAgent());
|
|
1767
1701
|
this._eventListeners = [];
|
|
1768
|
-
|
|
1769
|
-
// hooks before releasing provider locks/handles. This prevents a late write racing shutdown.
|
|
1770
|
-
track(async () => {
|
|
1771
|
-
await this._reflection.waitForActivePass();
|
|
1772
|
-
await this._memory.shutdown();
|
|
1773
|
-
});
|
|
1702
|
+
track(() => this._memory.shutdown());
|
|
1774
1703
|
track(() => this._toolRecoveryLogger.shutdown());
|
|
1775
1704
|
safely(() => cleanupSessionResources(this.sessionId));
|
|
1776
1705
|
// Best-effort final sweep for any grep/find artifact already released (reference
|
|
@@ -1828,7 +1757,7 @@ export class AgentSession {
|
|
|
1828
1757
|
turnIndex: this._turnIndex,
|
|
1829
1758
|
activeToolNames: this.getActiveToolNames(),
|
|
1830
1759
|
cwd: this._cwd,
|
|
1831
|
-
maxTurnUsd: this.
|
|
1760
|
+
maxTurnUsd: this._costGuard.getEnabledMaxTurnUsd(),
|
|
1832
1761
|
});
|
|
1833
1762
|
}
|
|
1834
1763
|
/**
|
|
@@ -2090,7 +2019,7 @@ export class AgentSession {
|
|
|
2090
2019
|
}
|
|
2091
2020
|
async _promptUnserialized(text, options, submission) {
|
|
2092
2021
|
this._toolProtocol.applyRepairLayerSettings();
|
|
2093
|
-
this.
|
|
2022
|
+
this._localPrefixWarm.cancel();
|
|
2094
2023
|
const expandPromptTemplates = options?.expandPromptTemplates ?? true;
|
|
2095
2024
|
const processSlashCommands = options?.processSlashCommands ?? expandPromptTemplates;
|
|
2096
2025
|
const preflightResult = options?.preflightResult;
|
|
@@ -2175,9 +2104,9 @@ export class AgentSession {
|
|
|
2175
2104
|
if (!options?.internalContextType) {
|
|
2176
2105
|
admittedGoalId = this._goals.startOwnerChatGoal(expandedText, this.agent.state.messages) ?? admittedGoalId;
|
|
2177
2106
|
}
|
|
2178
|
-
//
|
|
2179
|
-
//
|
|
2180
|
-
this.
|
|
2107
|
+
// Queued steer/follow-up messages remain in the active turn; only a new submission resets the
|
|
2108
|
+
// cost controller's spawned-usage baseline shared by every round trip in this turn.
|
|
2109
|
+
this._costGuard.beginForegroundTurn();
|
|
2181
2110
|
// Flush any pending bash messages before the new prompt
|
|
2182
2111
|
this._flushPendingBashMessages();
|
|
2183
2112
|
// Build the user message now — before the router judge — and paint it to the UI
|
|
@@ -2274,6 +2203,10 @@ export class AgentSession {
|
|
|
2274
2203
|
// recall must never break a turn
|
|
2275
2204
|
}
|
|
2276
2205
|
}
|
|
2206
|
+
// Queue one durable logical cue. ProviderRequestContextController owns its transient preview
|
|
2207
|
+
// and accepted-plan commit, so it never enters or needs cleanup from agent history.
|
|
2208
|
+
if (!options?.internalContextType)
|
|
2209
|
+
this._reflection.queueCurrentTurnCue("root-turn");
|
|
2277
2210
|
// Add user message (built earlier, before the router judge, so it could be painted
|
|
2278
2211
|
// immediately — see the early message_start emit above).
|
|
2279
2212
|
messages.push(promptMessage);
|
|
@@ -2654,7 +2587,7 @@ export class AgentSession {
|
|
|
2654
2587
|
// =========================================================================
|
|
2655
2588
|
async setModel(model, options = {}) {
|
|
2656
2589
|
await this._modelSelection.setModel(model, options);
|
|
2657
|
-
this.
|
|
2590
|
+
this._localPrefixWarm.schedule(this.agent.state.model);
|
|
2658
2591
|
}
|
|
2659
2592
|
/** Re-resolve startup profile model/thinking after allowed extension providers are bound. */
|
|
2660
2593
|
async reapplyActiveProfileModelSettings() {
|
|
@@ -2663,12 +2596,12 @@ export class AgentSession {
|
|
|
2663
2596
|
const activeToolNames = this._requestedActiveToolNames ?? this.getActiveToolNames();
|
|
2664
2597
|
this._refreshToolRegistry({ activeToolNames, includeAllExtensionTools: true });
|
|
2665
2598
|
if (!modelsAreEqual(previousModel, this.model)) {
|
|
2666
|
-
this.
|
|
2599
|
+
this._localPrefixWarm.schedule(this.model);
|
|
2667
2600
|
}
|
|
2668
2601
|
}
|
|
2669
2602
|
async cycleModel(direction = "forward") {
|
|
2670
2603
|
const result = await this._modelSelection.cycleModel(direction);
|
|
2671
|
-
this.
|
|
2604
|
+
this._localPrefixWarm.schedule(result?.model);
|
|
2672
2605
|
return result;
|
|
2673
2606
|
}
|
|
2674
2607
|
// =========================================================================
|
|
@@ -2839,6 +2772,7 @@ export class AgentSession {
|
|
|
2839
2772
|
}
|
|
2840
2773
|
async reload() {
|
|
2841
2774
|
this._foregroundLifecycle.reload();
|
|
2775
|
+
this._reflection.invalidateCurrentTurnCueStateCache();
|
|
2842
2776
|
this.agent.state.messages = this.sessionManager.buildSessionContext().messages;
|
|
2843
2777
|
return this._runtimeBuilder.reload();
|
|
2844
2778
|
}
|
|
@@ -2928,7 +2862,9 @@ export class AgentSession {
|
|
|
2928
2862
|
// Tree Navigation
|
|
2929
2863
|
// =========================================================================
|
|
2930
2864
|
async navigateTree(targetId, options = {}) {
|
|
2931
|
-
|
|
2865
|
+
const result = await this._treeNavigator.navigateTree(targetId, options);
|
|
2866
|
+
this._reflection.invalidateCurrentTurnCueStateCache();
|
|
2867
|
+
return result;
|
|
2932
2868
|
}
|
|
2933
2869
|
getUserMessagesForForking() {
|
|
2934
2870
|
return this._treeNavigator.getUserMessagesForForking();
|
|
@@ -3124,16 +3060,13 @@ export class AgentSession {
|
|
|
3124
3060
|
async continueGoalLoop(options) {
|
|
3125
3061
|
return this._backgroundLanes.continueGoalLoopExclusive(options);
|
|
3126
3062
|
}
|
|
3127
|
-
/**
|
|
3128
|
-
* Run a one-shot LLM completion fully ISOLATED from the main session — the load-bearing primitive
|
|
3129
|
-
* for native reflection (see reflection-controller.ts for the isolation invariants).
|
|
3130
|
-
*/
|
|
3063
|
+
/** Run one explicit isolated completion for bounded host-owned consumers. */
|
|
3131
3064
|
async runIsolatedCompletion(opts) {
|
|
3132
3065
|
return this._reflection.runIsolatedCompletion(opts);
|
|
3133
3066
|
}
|
|
3134
3067
|
/**
|
|
3135
|
-
*
|
|
3136
|
-
* when the demand gate skips or in a child session.
|
|
3068
|
+
* Explicit compatibility/application reflection pass. Automatic reflection never calls this
|
|
3069
|
+
* method; it returns null when the demand gate skips or in a child session.
|
|
3137
3070
|
*/
|
|
3138
3071
|
async runReflectionPass(input) {
|
|
3139
3072
|
return this._reflection.runReflectionPass(input);
|