@caupulican/pi-adaptative 0.81.37 → 0.81.39
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 +91 -0
- package/README.md +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +18 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +131 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +196 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +308 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +22 -2
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +585 -24
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +749 -27
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/__init__.py +43 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +270 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +252 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +399 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +575 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +52 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +49 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +734 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +238 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +132 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +116 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +287 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +137 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +100 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +579 -0
- package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +19 -9
- package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +22 -5
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +5 -5
- package/dist/bundled-resources/skills/tool-call-repair/references/text-protocol-grammar.md +28 -7
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +15 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-paths.d.ts +49 -0
- package/dist/core/agent-paths.d.ts.map +1 -0
- package/dist/core/agent-paths.js +107 -0
- package/dist/core/agent-paths.js.map +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +3 -3
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +234 -17
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +484 -62
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +9 -0
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +10 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +5 -1
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +122 -6
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +447 -90
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +7 -1
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +13 -3
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +43 -7
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-audit.d.ts +33 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +31 -5
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +13 -7
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +16 -1
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +26 -4
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +137 -14
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost-guard.d.ts +19 -3
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +18 -3
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/delegation/session-worker-result.d.ts +34 -4
- package/dist/core/delegation/session-worker-result.d.ts.map +1 -1
- package/dist/core/delegation/session-worker-result.js +64 -4
- package/dist/core/delegation/session-worker-result.js.map +1 -1
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +1 -1
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-result.d.ts +42 -1
- package/dist/core/delegation/worker-result.d.ts.map +1 -1
- package/dist/core/delegation/worker-result.js +68 -0
- package/dist/core/delegation/worker-result.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +23 -7
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +51 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +17 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +79 -11
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts +48 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +77 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +39 -0
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +42 -0
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +4 -0
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +51 -10
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.d.ts +101 -2
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +87 -4
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +89 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +71 -5
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +56 -2
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +111 -5
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +11 -2
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +32 -17
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/keybindings.d.ts +10 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +10 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/observation-store.d.ts +12 -3
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +30 -15
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts +5 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +21 -19
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +65 -3
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +186 -26
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +6 -6
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/model-capability.d.ts +34 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +42 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts +15 -0
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js +23 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +34 -7
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +95 -16
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/models/adaptation-store.d.ts +7 -0
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +47 -11
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js +17 -0
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +3 -0
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +11 -2
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +180 -0
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -0
- package/dist/core/models/llamacpp-runtime.js +475 -0
- package/dist/core/models/llamacpp-runtime.js.map +1 -0
- package/dist/core/models/local-registration.d.ts +40 -0
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +94 -5
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +9 -7
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-ref.d.ts +7 -0
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js +26 -0
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +257 -0
- package/dist/core/models/needle-runtime.d.ts.map +1 -0
- package/dist/core/models/needle-runtime.js +519 -0
- package/dist/core/models/needle-runtime.js.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts +89 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js +121 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -10
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-matrix/codes.d.ts +72 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -0
- package/dist/core/process-matrix/codes.js +15 -0
- package/dist/core/process-matrix/codes.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +63 -0
- package/dist/core/process-matrix/runtime.d.ts.map +1 -0
- package/dist/core/process-matrix/runtime.js +310 -0
- package/dist/core/process-matrix/runtime.js.map +1 -0
- package/dist/core/process-matrix/store.d.ts +22 -0
- package/dist/core/process-matrix/store.d.ts.map +1 -0
- package/dist/core/process-matrix/store.js +80 -0
- package/dist/core/process-matrix/store.js.map +1 -0
- package/dist/core/process-matrix/supervisor.d.ts +72 -0
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -0
- package/dist/core/process-matrix/supervisor.js +130 -0
- package/dist/core/process-matrix/supervisor.js.map +1 -0
- package/dist/core/profile-registry.d.ts +7 -0
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +20 -0
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js +3 -3
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +29 -5
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +215 -126
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +36 -0
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +44 -0
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +8 -7
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +58 -5
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +209 -25
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +6 -0
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +66 -52
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-role.d.ts +31 -0
- package/dist/core/session-role.d.ts.map +1 -0
- package/dist/core/session-role.js +52 -0
- package/dist/core/session-role.js.map +1 -0
- package/dist/core/settings-manager.d.ts +42 -3
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +94 -60
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +12 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +6 -0
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts +14 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +11 -2
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +27 -11
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts +45 -0
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -0
- package/dist/core/tasks/task-contract-monitor.js +56 -0
- package/dist/core/tasks/task-contract-monitor.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +8 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +28 -1
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +5 -0
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-recovery-log-records.d.ts +7 -0
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +14 -6
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts +54 -0
- package/dist/core/tool-selection/promotion.d.ts.map +1 -0
- package/dist/core/tool-selection/promotion.js +81 -0
- package/dist/core/tool-selection/promotion.js.map +1 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts +37 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +87 -3
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.d.ts +45 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +96 -0
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/tools/bash.d.ts +18 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +97 -18
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +14 -0
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +82 -7
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +25 -8
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +52 -44
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/goal.d.ts +94 -3
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +165 -15
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +5 -4
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts +7 -0
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +2 -2
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts +6 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +69 -13
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts +89 -0
- package/dist/core/tools/shell-session.d.ts.map +1 -0
- package/dist/core/tools/shell-session.js +432 -0
- package/dist/core/tools/shell-session.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +4 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +63 -8
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +86 -0
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -0
- package/dist/core/tools/tmux-dispatch.js +91 -0
- package/dist/core/tools/tmux-dispatch.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +42 -0
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-engine.js +153 -0
- package/dist/core/tools/windows-shell-engine.js.map +1 -0
- package/dist/core/tools/windows-shell-state.d.ts +40 -0
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-state.js +59 -0
- package/dist/core/tools/windows-shell-state.js.map +1 -0
- package/dist/core/tools/worktree-sync.d.ts +24 -0
- package/dist/core/tools/worktree-sync.d.ts.map +1 -0
- package/dist/core/tools/worktree-sync.js +338 -0
- package/dist/core/tools/worktree-sync.js.map +1 -0
- package/dist/core/trust-manager.d.ts +4 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +20 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +55 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -0
- package/dist/core/util/atomic-file.js +255 -0
- package/dist/core/util/atomic-file.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts +33 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -0
- package/dist/core/util/minimatch-cache.js +0 -0
- package/dist/core/util/minimatch-cache.js.map +1 -0
- package/dist/core/worktree-sync/codes.d.ts +227 -0
- package/dist/core/worktree-sync/codes.d.ts.map +1 -0
- package/dist/core/worktree-sync/codes.js +14 -0
- package/dist/core/worktree-sync/codes.js.map +1 -0
- package/dist/core/worktree-sync/git-engine.d.ts +156 -0
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -0
- package/dist/core/worktree-sync/git-engine.js +1191 -0
- package/dist/core/worktree-sync/git-engine.js.map +1 -0
- package/dist/core/worktree-sync/lane-gate.d.ts +75 -0
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -0
- package/dist/core/worktree-sync/lane-gate.js +360 -0
- package/dist/core/worktree-sync/lane-gate.js.map +1 -0
- package/dist/core/worktree-sync/runtime.d.ts +47 -0
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -0
- package/dist/core/worktree-sync/runtime.js +96 -0
- package/dist/core/worktree-sync/runtime.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +69 -0
- package/dist/core/worktree-sync/store.d.ts.map +1 -0
- package/dist/core/worktree-sync/store.js +247 -0
- package/dist/core/worktree-sync/store.js.map +1 -0
- package/dist/core/worktree-sync/watcher.d.ts +29 -0
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -0
- package/dist/core/worktree-sync/watcher.js +93 -0
- package/dist/core/worktree-sync/watcher.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +94 -0
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +9 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +38 -0
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +16 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +50 -8
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +23 -1
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +4 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts +43 -0
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +290 -3
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +24 -4
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +11 -0
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +20 -2
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts +4 -0
- package/dist/utils/highlight-js-languages.d.ts.map +1 -0
- package/dist/utils/highlight-js-languages.js +573 -0
- package/dist/utils/highlight-js-languages.js.map +1 -0
- package/dist/utils/shell.d.ts +7 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +39 -9
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +53 -5
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +112 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/development.md +2 -0
- package/docs/packages.md +1 -1
- package/docs/process-matrix.md +120 -0
- package/docs/settings.md +5 -2
- package/docs/tmux-agent-manager.md +85 -2
- package/docs/windows.md +52 -3
- package/docs/work-directory.md +29 -0
- package/docs/worktree-sync.md +250 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +10 -4
- package/docs/integration-sweep-builder-blueprint-2026-07-09.md +0 -365
- package/docs/integration-sweep-resume-2026-07-09.md +0 -407
|
@@ -1 +1 @@
|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AO,CAAC,oBAAoB,CAAC,CA0D/B;AAED;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CACnD,OAAO,EAAE,qCAAqC,GAC5C,OAAO,CAAC,wBAAwB,CAAC,CA8CnC","sourcesContent":["import { join } from \"node:path\";\nimport type { ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport { getAgentDir } from \"../config.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { AuthStorage } from \"./auth-storage.ts\";\nimport type { SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { DefaultResourceLoader, type DefaultResourceLoaderOptions, type ResourceLoader } from \"./resource-loader.ts\";\nimport { parseResourceProfileInput } from \"./resource-profile-blocks.ts\";\nimport { type CreateAgentSessionOptions, type CreateAgentSessionResult, createAgentSession } from \"./sdk.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\n\n/**\n * Non-fatal issues collected while creating services or sessions.\n *\n * Runtime creation returns diagnostics to the caller instead of printing or\n * exiting. The app layer decides whether warnings should be shown and whether\n * errors should abort startup.\n */\nexport interface AgentSessionRuntimeDiagnostic {\n\ttype: \"info\" | \"warning\" | \"error\";\n\tmessage: string;\n}\n\n/**\n * Inputs for creating cwd-bound runtime services.\n *\n * These services are recreated whenever the effective session cwd changes.\n * CLI-provided resource paths should be resolved to absolute paths before they\n * reach this function, so later cwd switches do not reinterpret them.\n */\nexport interface CreateAgentSessionServicesOptions {\n\tcwd: string;\n\tagentDir?: string;\n\tauthStorage?: AuthStorage;\n\tsettingsManager?: SettingsManager;\n\tmodelRegistry?: ModelRegistry;\n\textensionFlagValues?: Map<string, boolean | string>;\n\tresourceLoaderOptions?: Omit<DefaultResourceLoaderOptions, \"cwd\" | \"agentDir\" | \"settingsManager\">;\n}\n\n/**\n * Inputs for creating an AgentSession from already-created services.\n *\n * Use this after services exist and any cwd-bound model/tool/session options\n * have been resolved against those services.\n */\nexport interface CreateAgentSessionFromServicesOptions {\n\tservices: AgentSessionServices;\n\tsessionManager: SessionManager;\n\tsessionStartEvent?: SessionStartEvent;\n\tmodel?: Model<any>;\n\tthinkingLevel?: ThinkingLevel;\n\t/** Preserve whether the foreground model came from an explicit launch flag. */\n\tisExplicitModel?: boolean;\n\t/** Preserve whether the thinking level came from an explicit launch flag. */\n\tisExplicitThinking?: boolean;\n\tscopedModels?: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;\n\ttools?: string[];\n\texcludeTools?: CreateAgentSessionOptions[\"excludeTools\"];\n\tnoTools?: CreateAgentSessionOptions[\"noTools\"];\n\ttoolProfileFilter?: CreateAgentSessionOptions[\"toolProfileFilter\"];\n\tresourceProfileDefinitions?: CreateAgentSessionOptions[\"resourceProfileDefinitions\"];\n\tresourceProfileJson?: CreateAgentSessionOptions[\"resourceProfileJson\"];\n\tresourceProfiles?: CreateAgentSessionOptions[\"resourceProfiles\"];\n\tcustomTools?: ToolDefinition[];\n}\n\n/**\n * Coherent cwd-bound runtime services for one effective session cwd.\n *\n * This is infrastructure only. The AgentSession itself is created separately so\n * session options can be resolved against these services first.\n */\nexport interface AgentSessionServices {\n\tcwd: string;\n\tagentDir: string;\n\tauthStorage: AuthStorage;\n\tsettingsManager: SettingsManager;\n\tmodelRegistry: ModelRegistry;\n\tresourceLoader: ResourceLoader;\n\tdiagnostics: AgentSessionRuntimeDiagnostic[];\n}\n\nfunction applyExtensionFlagValues(\n\tresourceLoader: ResourceLoader,\n\textensionFlagValues: Map<string, boolean | string> | undefined,\n): AgentSessionRuntimeDiagnostic[] {\n\tif (!extensionFlagValues) {\n\t\treturn [];\n\t}\n\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tconst extensionsResult = resourceLoader.getExtensions();\n\tconst registeredFlags = new Map<string, { type: \"boolean\" | \"string\" }>();\n\tfor (const extension of extensionsResult.extensions) {\n\t\tfor (const [name, flag] of extension.flags) {\n\t\t\tregisteredFlags.set(name, { type: flag.type });\n\t\t}\n\t}\n\n\tconst unknownFlags: string[] = [];\n\tfor (const [name, value] of extensionFlagValues) {\n\t\tconst flag = registeredFlags.get(name);\n\t\tif (!flag) {\n\t\t\tunknownFlags.push(name);\n\t\t\tcontinue;\n\t\t}\n\t\tif (flag.type === \"boolean\") {\n\t\t\textensionsResult.runtime.flagValues.set(name, true);\n\t\t\tcontinue;\n\t\t}\n\t\tif (typeof value === \"string\") {\n\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\tcontinue;\n\t\t}\n\t\tdiagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `Extension flag \"--${name}\" requires a value`,\n\t\t});\n\t}\n\n\tif (unknownFlags.length > 0) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `Unknown option${unknownFlags.length === 1 ? \"\" : \"s\"}: ${unknownFlags.map((name) => `--${name}`).join(\", \")}`,\n\t\t});\n\t}\n\n\treturn diagnostics;\n}\n\n/**\n * Create cwd-bound runtime services.\n *\n * Returns services plus diagnostics. It does not create an AgentSession.\n */\nexport async function createAgentSessionServices(\n\toptions: CreateAgentSessionServicesOptions,\n): Promise<AgentSessionServices> {\n\tconst cwd = resolvePath(options.cwd);\n\tconst agentDir = options.agentDir ? resolvePath(options.agentDir) : getAgentDir();\n\tconst authStorage = options.authStorage ?? AuthStorage.create(join(agentDir, \"auth.json\"));\n\tconst settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);\n\tconst modelRegistry = options.modelRegistry ?? ModelRegistry.create(authStorage, join(agentDir, \"models.json\"));\n\tconst resourceLoader = new DefaultResourceLoader({\n\t\t...(options.resourceLoaderOptions ?? {}),\n\t\tcwd,\n\t\tagentDir,\n\t\tsettingsManager,\n\t});\n\tawait resourceLoader.reload();\n\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tconst extensionsResult = resourceLoader.getExtensions();\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tconst runtimeExtensionPaths = new Set(\n\t\t(activeProfileNames.length === 0\n\t\t\t? extensionsResult.extensions.filter((extension) => extension.sourceInfo.source === \"inline\")\n\t\t\t: extensionsResult.extensions.filter((extension) =>\n\t\t\t\t\tsettingsManager.isResourceAllowedByProfile(\"extensions\", extension.path, extension.sourceInfo.baseDir),\n\t\t\t\t)\n\t\t).map((extension) => extension.path),\n\t);\n\tfor (const { name, config, extensionPath } of extensionsResult.runtime.pendingProviderRegistrations) {\n\t\t// Initial model resolution needs providers before AgentSession binds its runner, but it must\n\t\t// observe the same UAC-filtered extension generation as RuntimeBuilder. Registrations from\n\t\t// withheld extensions remain inert and are discarded with the pending queue below.\n\t\tif (!runtimeExtensionPaths.has(extensionPath)) continue;\n\t\ttry {\n\t\t\tmodelRegistry.registerProvider(name, config);\n\t\t\tlet ownedProviders = extensionsResult.runtime.providersByExtension.get(extensionPath);\n\t\t\tif (!ownedProviders) {\n\t\t\t\townedProviders = new Set();\n\t\t\t\textensionsResult.runtime.providersByExtension.set(extensionPath, ownedProviders);\n\t\t\t}\n\t\t\townedProviders.add(name);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"error\",\n\t\t\t\tmessage: `Extension \"${extensionPath}\" error: ${message}`,\n\t\t\t});\n\t\t}\n\t}\n\textensionsResult.runtime.pendingProviderRegistrations = [];\n\tdiagnostics.push(...applyExtensionFlagValues(resourceLoader, options.extensionFlagValues));\n\n\treturn {\n\t\tcwd,\n\t\tagentDir,\n\t\tauthStorage,\n\t\tsettingsManager,\n\t\tmodelRegistry,\n\t\tresourceLoader,\n\t\tdiagnostics,\n\t};\n}\n\n/**\n * Create an AgentSession from previously created services.\n *\n * This keeps session creation separate from service creation so callers can\n * resolve model, thinking, tools, and other session inputs against the target\n * cwd before constructing the session.\n */\nexport async function createAgentSessionFromServices(\n\toptions: CreateAgentSessionFromServicesOptions,\n): Promise<CreateAgentSessionResult> {\n\tconst needsProfileReload =\n\t\toptions.resourceProfileDefinitions !== undefined ||\n\t\toptions.resourceProfileJson !== undefined ||\n\t\toptions.resourceProfiles !== undefined;\n\tif (options.resourceProfileDefinitions) {\n\t\toptions.services.settingsManager.addInlineResourceProfileDefinitions(options.resourceProfileDefinitions);\n\t}\n\tif (options.resourceProfileJson) {\n\t\tconst inputs = Array.isArray(options.resourceProfileJson)\n\t\t\t? options.resourceProfileJson\n\t\t\t: [options.resourceProfileJson];\n\t\tfor (const input of inputs) {\n\t\t\toptions.services.settingsManager.addInlineResourceProfileDefinitions(\n\t\t\t\tparseResourceProfileInput(input).profiles,\n\t\t\t);\n\t\t}\n\t}\n\tif (options.resourceProfiles !== undefined) {\n\t\toptions.services.settingsManager.setRuntimeResourceProfiles(options.resourceProfiles);\n\t}\n\tif (needsProfileReload) {\n\t\tawait options.services.resourceLoader.reload();\n\t}\n\n\treturn createAgentSession({\n\t\tcwd: options.services.cwd,\n\t\tagentDir: options.services.agentDir,\n\t\tauthStorage: options.services.authStorage,\n\t\tsettingsManager: options.services.settingsManager,\n\t\tmodelRegistry: options.services.modelRegistry,\n\t\tresourceLoader: options.services.resourceLoader,\n\t\tsessionManager: options.sessionManager,\n\t\tmodel: options.model,\n\t\tthinkingLevel: options.thinkingLevel,\n\t\tisExplicitModel: options.isExplicitModel,\n\t\tisExplicitThinking: options.isExplicitThinking,\n\t\tscopedModels: options.scopedModels,\n\t\ttools: options.tools,\n\t\texcludeTools: options.excludeTools,\n\t\tnoTools: options.noTools,\n\t\ttoolProfileFilter:\n\t\t\toptions.toolProfileFilter ?? options.services.settingsManager.getResourceProfileFilter(\"tools\"),\n\t\tcustomTools: options.customTools,\n\t\tsessionStartEvent: options.sessionStartEvent,\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-services.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-services.ts"],"names":[],"mappings":"AAAA,OAAO,KA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C,OAAO,CAAC,wBAAwB,CAAC,CA8CnC","sourcesContent":["import type { ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport { getAgentDir } from \"../config.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { configFile } from \"./agent-paths.ts\";\nimport { AuthStorage } from \"./auth-storage.ts\";\nimport type { SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { DefaultResourceLoader, type DefaultResourceLoaderOptions, type ResourceLoader } from \"./resource-loader.ts\";\nimport { parseResourceProfileInput } from \"./resource-profile-blocks.ts\";\nimport { type CreateAgentSessionOptions, type CreateAgentSessionResult, createAgentSession } from \"./sdk.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\n\n/**\n * Non-fatal issues collected while creating services or sessions.\n *\n * Runtime creation returns diagnostics to the caller instead of printing or\n * exiting. The app layer decides whether warnings should be shown and whether\n * errors should abort startup.\n */\nexport interface AgentSessionRuntimeDiagnostic {\n\ttype: \"info\" | \"warning\" | \"error\";\n\tmessage: string;\n}\n\n/**\n * Inputs for creating cwd-bound runtime services.\n *\n * These services are recreated whenever the effective session cwd changes.\n * CLI-provided resource paths should be resolved to absolute paths before they\n * reach this function, so later cwd switches do not reinterpret them.\n */\nexport interface CreateAgentSessionServicesOptions {\n\tcwd: string;\n\tagentDir?: string;\n\tauthStorage?: AuthStorage;\n\tsettingsManager?: SettingsManager;\n\tmodelRegistry?: ModelRegistry;\n\textensionFlagValues?: Map<string, boolean | string>;\n\tresourceLoaderOptions?: Omit<DefaultResourceLoaderOptions, \"cwd\" | \"agentDir\" | \"settingsManager\">;\n}\n\n/**\n * Inputs for creating an AgentSession from already-created services.\n *\n * Use this after services exist and any cwd-bound model/tool/session options\n * have been resolved against those services.\n */\nexport interface CreateAgentSessionFromServicesOptions {\n\tservices: AgentSessionServices;\n\tsessionManager: SessionManager;\n\tsessionStartEvent?: SessionStartEvent;\n\tmodel?: Model<any>;\n\tthinkingLevel?: ThinkingLevel;\n\t/** Preserve whether the foreground model came from an explicit launch flag. */\n\tisExplicitModel?: boolean;\n\t/** Preserve whether the thinking level came from an explicit launch flag. */\n\tisExplicitThinking?: boolean;\n\tscopedModels?: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;\n\ttools?: string[];\n\texcludeTools?: CreateAgentSessionOptions[\"excludeTools\"];\n\tnoTools?: CreateAgentSessionOptions[\"noTools\"];\n\ttoolProfileFilter?: CreateAgentSessionOptions[\"toolProfileFilter\"];\n\tresourceProfileDefinitions?: CreateAgentSessionOptions[\"resourceProfileDefinitions\"];\n\tresourceProfileJson?: CreateAgentSessionOptions[\"resourceProfileJson\"];\n\tresourceProfiles?: CreateAgentSessionOptions[\"resourceProfiles\"];\n\tcustomTools?: ToolDefinition[];\n}\n\n/**\n * Coherent cwd-bound runtime services for one effective session cwd.\n *\n * This is infrastructure only. The AgentSession itself is created separately so\n * session options can be resolved against these services first.\n */\nexport interface AgentSessionServices {\n\tcwd: string;\n\tagentDir: string;\n\tauthStorage: AuthStorage;\n\tsettingsManager: SettingsManager;\n\tmodelRegistry: ModelRegistry;\n\tresourceLoader: ResourceLoader;\n\tdiagnostics: AgentSessionRuntimeDiagnostic[];\n}\n\nfunction applyExtensionFlagValues(\n\tresourceLoader: ResourceLoader,\n\textensionFlagValues: Map<string, boolean | string> | undefined,\n): AgentSessionRuntimeDiagnostic[] {\n\tif (!extensionFlagValues) {\n\t\treturn [];\n\t}\n\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tconst extensionsResult = resourceLoader.getExtensions();\n\tconst registeredFlags = new Map<string, { type: \"boolean\" | \"string\" }>();\n\tfor (const extension of extensionsResult.extensions) {\n\t\tfor (const [name, flag] of extension.flags) {\n\t\t\tregisteredFlags.set(name, { type: flag.type });\n\t\t}\n\t}\n\n\tconst unknownFlags: string[] = [];\n\tfor (const [name, value] of extensionFlagValues) {\n\t\tconst flag = registeredFlags.get(name);\n\t\tif (!flag) {\n\t\t\tunknownFlags.push(name);\n\t\t\tcontinue;\n\t\t}\n\t\tif (flag.type === \"boolean\") {\n\t\t\textensionsResult.runtime.flagValues.set(name, true);\n\t\t\tcontinue;\n\t\t}\n\t\tif (typeof value === \"string\") {\n\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\tcontinue;\n\t\t}\n\t\tdiagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `Extension flag \"--${name}\" requires a value`,\n\t\t});\n\t}\n\n\tif (unknownFlags.length > 0) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `Unknown option${unknownFlags.length === 1 ? \"\" : \"s\"}: ${unknownFlags.map((name) => `--${name}`).join(\", \")}`,\n\t\t});\n\t}\n\n\treturn diagnostics;\n}\n\n/**\n * Create cwd-bound runtime services.\n *\n * Returns services plus diagnostics. It does not create an AgentSession.\n */\nexport async function createAgentSessionServices(\n\toptions: CreateAgentSessionServicesOptions,\n): Promise<AgentSessionServices> {\n\tconst cwd = resolvePath(options.cwd);\n\tconst agentDir = options.agentDir ? resolvePath(options.agentDir) : getAgentDir();\n\tconst authStorage = options.authStorage ?? AuthStorage.create(configFile(agentDir, \"auth.json\"));\n\tconst settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);\n\tconst modelRegistry =\n\t\toptions.modelRegistry ?? ModelRegistry.create(authStorage, configFile(agentDir, \"models.json\"));\n\tconst resourceLoader = new DefaultResourceLoader({\n\t\t...(options.resourceLoaderOptions ?? {}),\n\t\tcwd,\n\t\tagentDir,\n\t\tsettingsManager,\n\t});\n\tawait resourceLoader.reload();\n\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tconst extensionsResult = resourceLoader.getExtensions();\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tconst runtimeExtensionPaths = new Set(\n\t\t(activeProfileNames.length === 0\n\t\t\t? extensionsResult.extensions.filter((extension) => extension.sourceInfo.source === \"inline\")\n\t\t\t: extensionsResult.extensions.filter((extension) =>\n\t\t\t\t\tsettingsManager.isResourceAllowedByProfile(\"extensions\", extension.path, extension.sourceInfo.baseDir),\n\t\t\t\t)\n\t\t).map((extension) => extension.path),\n\t);\n\tfor (const { name, config, extensionPath } of extensionsResult.runtime.pendingProviderRegistrations) {\n\t\t// Initial model resolution needs providers before AgentSession binds its runner, but it must\n\t\t// observe the same UAC-filtered extension generation as RuntimeBuilder. Registrations from\n\t\t// withheld extensions remain inert and are discarded with the pending queue below.\n\t\tif (!runtimeExtensionPaths.has(extensionPath)) continue;\n\t\ttry {\n\t\t\tmodelRegistry.registerProvider(name, config);\n\t\t\tlet ownedProviders = extensionsResult.runtime.providersByExtension.get(extensionPath);\n\t\t\tif (!ownedProviders) {\n\t\t\t\townedProviders = new Set();\n\t\t\t\textensionsResult.runtime.providersByExtension.set(extensionPath, ownedProviders);\n\t\t\t}\n\t\t\townedProviders.add(name);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"error\",\n\t\t\t\tmessage: `Extension \"${extensionPath}\" error: ${message}`,\n\t\t\t});\n\t\t}\n\t}\n\textensionsResult.runtime.pendingProviderRegistrations = [];\n\tdiagnostics.push(...applyExtensionFlagValues(resourceLoader, options.extensionFlagValues));\n\n\treturn {\n\t\tcwd,\n\t\tagentDir,\n\t\tauthStorage,\n\t\tsettingsManager,\n\t\tmodelRegistry,\n\t\tresourceLoader,\n\t\tdiagnostics,\n\t};\n}\n\n/**\n * Create an AgentSession from previously created services.\n *\n * This keeps session creation separate from service creation so callers can\n * resolve model, thinking, tools, and other session inputs against the target\n * cwd before constructing the session.\n */\nexport async function createAgentSessionFromServices(\n\toptions: CreateAgentSessionFromServicesOptions,\n): Promise<CreateAgentSessionResult> {\n\tconst needsProfileReload =\n\t\toptions.resourceProfileDefinitions !== undefined ||\n\t\toptions.resourceProfileJson !== undefined ||\n\t\toptions.resourceProfiles !== undefined;\n\tif (options.resourceProfileDefinitions) {\n\t\toptions.services.settingsManager.addInlineResourceProfileDefinitions(options.resourceProfileDefinitions);\n\t}\n\tif (options.resourceProfileJson) {\n\t\tconst inputs = Array.isArray(options.resourceProfileJson)\n\t\t\t? options.resourceProfileJson\n\t\t\t: [options.resourceProfileJson];\n\t\tfor (const input of inputs) {\n\t\t\toptions.services.settingsManager.addInlineResourceProfileDefinitions(\n\t\t\t\tparseResourceProfileInput(input).profiles,\n\t\t\t);\n\t\t}\n\t}\n\tif (options.resourceProfiles !== undefined) {\n\t\toptions.services.settingsManager.setRuntimeResourceProfiles(options.resourceProfiles);\n\t}\n\tif (needsProfileReload) {\n\t\tawait options.services.resourceLoader.reload();\n\t}\n\n\treturn createAgentSession({\n\t\tcwd: options.services.cwd,\n\t\tagentDir: options.services.agentDir,\n\t\tauthStorage: options.services.authStorage,\n\t\tsettingsManager: options.services.settingsManager,\n\t\tmodelRegistry: options.services.modelRegistry,\n\t\tresourceLoader: options.services.resourceLoader,\n\t\tsessionManager: options.sessionManager,\n\t\tmodel: options.model,\n\t\tthinkingLevel: options.thinkingLevel,\n\t\tisExplicitModel: options.isExplicitModel,\n\t\tisExplicitThinking: options.isExplicitThinking,\n\t\tscopedModels: options.scopedModels,\n\t\ttools: options.tools,\n\t\texcludeTools: options.excludeTools,\n\t\tnoTools: options.noTools,\n\t\ttoolProfileFilter:\n\t\t\toptions.toolProfileFilter ?? options.services.settingsManager.getResourceProfileFilter(\"tools\"),\n\t\tcustomTools: options.customTools,\n\t\tsessionStartEvent: options.sessionStartEvent,\n\t});\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import { getAgentDir } from "../config.js";
|
|
3
2
|
import { resolvePath } from "../utils/paths.js";
|
|
3
|
+
import { configFile } from "./agent-paths.js";
|
|
4
4
|
import { AuthStorage } from "./auth-storage.js";
|
|
5
5
|
import { ModelRegistry } from "./model-registry.js";
|
|
6
6
|
import { DefaultResourceLoader } from "./resource-loader.js";
|
|
@@ -55,9 +55,9 @@ function applyExtensionFlagValues(resourceLoader, extensionFlagValues) {
|
|
|
55
55
|
export async function createAgentSessionServices(options) {
|
|
56
56
|
const cwd = resolvePath(options.cwd);
|
|
57
57
|
const agentDir = options.agentDir ? resolvePath(options.agentDir) : getAgentDir();
|
|
58
|
-
const authStorage = options.authStorage ?? AuthStorage.create(
|
|
58
|
+
const authStorage = options.authStorage ?? AuthStorage.create(configFile(agentDir, "auth.json"));
|
|
59
59
|
const settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);
|
|
60
|
-
const modelRegistry = options.modelRegistry ?? ModelRegistry.create(authStorage,
|
|
60
|
+
const modelRegistry = options.modelRegistry ?? ModelRegistry.create(authStorage, configFile(agentDir, "models.json"));
|
|
61
61
|
const resourceLoader = new DefaultResourceLoader({
|
|
62
62
|
...(options.resourceLoaderOptions ?? {}),
|
|
63
63
|
cwd,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-services.js","sourceRoot":"","sources":["../../src/core/agent-session-services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAA0D,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAiE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC7G,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA0ExD,SAA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AW,EAAE,OAAO,CAAC,WAAW;QAChC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;KAC5C,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { join } from \"node:path\";\nimport type { ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport { getAgentDir } from \"../config.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { AuthStorage } from \"./auth-storage.ts\";\nimport type { SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { DefaultResourceLoader, type DefaultResourceLoaderOptions, type ResourceLoader } from \"./resource-loader.ts\";\nimport { parseResourceProfileInput } from \"./resource-profile-blocks.ts\";\nimport { type CreateAgentSessionOptions, type CreateAgentSessionResult, createAgentSession } from \"./sdk.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\n\n/**\n * Non-fatal issues collected while creating services or sessions.\n *\n * Runtime creation returns diagnostics to the caller instead of printing or\n * exiting. The app layer decides whether warnings should be shown and whether\n * errors should abort startup.\n */\nexport interface AgentSessionRuntimeDiagnostic {\n\ttype: \"info\" | \"warning\" | \"error\";\n\tmessage: string;\n}\n\n/**\n * Inputs for creating cwd-bound runtime services.\n *\n * These services are recreated whenever the effective session cwd changes.\n * CLI-provided resource paths should be resolved to absolute paths before they\n * reach this function, so later cwd switches do not reinterpret them.\n */\nexport interface CreateAgentSessionServicesOptions {\n\tcwd: string;\n\tagentDir?: string;\n\tauthStorage?: AuthStorage;\n\tsettingsManager?: SettingsManager;\n\tmodelRegistry?: ModelRegistry;\n\textensionFlagValues?: Map<string, boolean | string>;\n\tresourceLoaderOptions?: Omit<DefaultResourceLoaderOptions, \"cwd\" | \"agentDir\" | \"settingsManager\">;\n}\n\n/**\n * Inputs for creating an AgentSession from already-created services.\n *\n * Use this after services exist and any cwd-bound model/tool/session options\n * have been resolved against those services.\n */\nexport interface CreateAgentSessionFromServicesOptions {\n\tservices: AgentSessionServices;\n\tsessionManager: SessionManager;\n\tsessionStartEvent?: SessionStartEvent;\n\tmodel?: Model<any>;\n\tthinkingLevel?: ThinkingLevel;\n\t/** Preserve whether the foreground model came from an explicit launch flag. */\n\tisExplicitModel?: boolean;\n\t/** Preserve whether the thinking level came from an explicit launch flag. */\n\tisExplicitThinking?: boolean;\n\tscopedModels?: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;\n\ttools?: string[];\n\texcludeTools?: CreateAgentSessionOptions[\"excludeTools\"];\n\tnoTools?: CreateAgentSessionOptions[\"noTools\"];\n\ttoolProfileFilter?: CreateAgentSessionOptions[\"toolProfileFilter\"];\n\tresourceProfileDefinitions?: CreateAgentSessionOptions[\"resourceProfileDefinitions\"];\n\tresourceProfileJson?: CreateAgentSessionOptions[\"resourceProfileJson\"];\n\tresourceProfiles?: CreateAgentSessionOptions[\"resourceProfiles\"];\n\tcustomTools?: ToolDefinition[];\n}\n\n/**\n * Coherent cwd-bound runtime services for one effective session cwd.\n *\n * This is infrastructure only. The AgentSession itself is created separately so\n * session options can be resolved against these services first.\n */\nexport interface AgentSessionServices {\n\tcwd: string;\n\tagentDir: string;\n\tauthStorage: AuthStorage;\n\tsettingsManager: SettingsManager;\n\tmodelRegistry: ModelRegistry;\n\tresourceLoader: ResourceLoader;\n\tdiagnostics: AgentSessionRuntimeDiagnostic[];\n}\n\nfunction applyExtensionFlagValues(\n\tresourceLoader: ResourceLoader,\n\textensionFlagValues: Map<string, boolean | string> | undefined,\n): AgentSessionRuntimeDiagnostic[] {\n\tif (!extensionFlagValues) {\n\t\treturn [];\n\t}\n\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tconst extensionsResult = resourceLoader.getExtensions();\n\tconst registeredFlags = new Map<string, { type: \"boolean\" | \"string\" }>();\n\tfor (const extension of extensionsResult.extensions) {\n\t\tfor (const [name, flag] of extension.flags) {\n\t\t\tregisteredFlags.set(name, { type: flag.type });\n\t\t}\n\t}\n\n\tconst unknownFlags: string[] = [];\n\tfor (const [name, value] of extensionFlagValues) {\n\t\tconst flag = registeredFlags.get(name);\n\t\tif (!flag) {\n\t\t\tunknownFlags.push(name);\n\t\t\tcontinue;\n\t\t}\n\t\tif (flag.type === \"boolean\") {\n\t\t\textensionsResult.runtime.flagValues.set(name, true);\n\t\t\tcontinue;\n\t\t}\n\t\tif (typeof value === \"string\") {\n\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\tcontinue;\n\t\t}\n\t\tdiagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `Extension flag \"--${name}\" requires a value`,\n\t\t});\n\t}\n\n\tif (unknownFlags.length > 0) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `Unknown option${unknownFlags.length === 1 ? \"\" : \"s\"}: ${unknownFlags.map((name) => `--${name}`).join(\", \")}`,\n\t\t});\n\t}\n\n\treturn diagnostics;\n}\n\n/**\n * Create cwd-bound runtime services.\n *\n * Returns services plus diagnostics. It does not create an AgentSession.\n */\nexport async function createAgentSessionServices(\n\toptions: CreateAgentSessionServicesOptions,\n): Promise<AgentSessionServices> {\n\tconst cwd = resolvePath(options.cwd);\n\tconst agentDir = options.agentDir ? resolvePath(options.agentDir) : getAgentDir();\n\tconst authStorage = options.authStorage ?? AuthStorage.create(join(agentDir, \"auth.json\"));\n\tconst settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);\n\tconst modelRegistry = options.modelRegistry ?? ModelRegistry.create(authStorage, join(agentDir, \"models.json\"));\n\tconst resourceLoader = new DefaultResourceLoader({\n\t\t...(options.resourceLoaderOptions ?? {}),\n\t\tcwd,\n\t\tagentDir,\n\t\tsettingsManager,\n\t});\n\tawait resourceLoader.reload();\n\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tconst extensionsResult = resourceLoader.getExtensions();\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tconst runtimeExtensionPaths = new Set(\n\t\t(activeProfileNames.length === 0\n\t\t\t? extensionsResult.extensions.filter((extension) => extension.sourceInfo.source === \"inline\")\n\t\t\t: extensionsResult.extensions.filter((extension) =>\n\t\t\t\t\tsettingsManager.isResourceAllowedByProfile(\"extensions\", extension.path, extension.sourceInfo.baseDir),\n\t\t\t\t)\n\t\t).map((extension) => extension.path),\n\t);\n\tfor (const { name, config, extensionPath } of extensionsResult.runtime.pendingProviderRegistrations) {\n\t\t// Initial model resolution needs providers before AgentSession binds its runner, but it must\n\t\t// observe the same UAC-filtered extension generation as RuntimeBuilder. Registrations from\n\t\t// withheld extensions remain inert and are discarded with the pending queue below.\n\t\tif (!runtimeExtensionPaths.has(extensionPath)) continue;\n\t\ttry {\n\t\t\tmodelRegistry.registerProvider(name, config);\n\t\t\tlet ownedProviders = extensionsResult.runtime.providersByExtension.get(extensionPath);\n\t\t\tif (!ownedProviders) {\n\t\t\t\townedProviders = new Set();\n\t\t\t\textensionsResult.runtime.providersByExtension.set(extensionPath, ownedProviders);\n\t\t\t}\n\t\t\townedProviders.add(name);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"error\",\n\t\t\t\tmessage: `Extension \"${extensionPath}\" error: ${message}`,\n\t\t\t});\n\t\t}\n\t}\n\textensionsResult.runtime.pendingProviderRegistrations = [];\n\tdiagnostics.push(...applyExtensionFlagValues(resourceLoader, options.extensionFlagValues));\n\n\treturn {\n\t\tcwd,\n\t\tagentDir,\n\t\tauthStorage,\n\t\tsettingsManager,\n\t\tmodelRegistry,\n\t\tresourceLoader,\n\t\tdiagnostics,\n\t};\n}\n\n/**\n * Create an AgentSession from previously created services.\n *\n * This keeps session creation separate from service creation so callers can\n * resolve model, thinking, tools, and other session inputs against the target\n * cwd before constructing the session.\n */\nexport async function createAgentSessionFromServices(\n\toptions: CreateAgentSessionFromServicesOptions,\n): Promise<CreateAgentSessionResult> {\n\tconst needsProfileReload =\n\t\toptions.resourceProfileDefinitions !== undefined ||\n\t\toptions.resourceProfileJson !== undefined ||\n\t\toptions.resourceProfiles !== undefined;\n\tif (options.resourceProfileDefinitions) {\n\t\toptions.services.settingsManager.addInlineResourceProfileDefinitions(options.resourceProfileDefinitions);\n\t}\n\tif (options.resourceProfileJson) {\n\t\tconst inputs = Array.isArray(options.resourceProfileJson)\n\t\t\t? options.resourceProfileJson\n\t\t\t: [options.resourceProfileJson];\n\t\tfor (const input of inputs) {\n\t\t\toptions.services.settingsManager.addInlineResourceProfileDefinitions(\n\t\t\t\tparseResourceProfileInput(input).profiles,\n\t\t\t);\n\t\t}\n\t}\n\tif (options.resourceProfiles !== undefined) {\n\t\toptions.services.settingsManager.setRuntimeResourceProfiles(options.resourceProfiles);\n\t}\n\tif (needsProfileReload) {\n\t\tawait options.services.resourceLoader.reload();\n\t}\n\n\treturn createAgentSession({\n\t\tcwd: options.services.cwd,\n\t\tagentDir: options.services.agentDir,\n\t\tauthStorage: options.services.authStorage,\n\t\tsettingsManager: options.services.settingsManager,\n\t\tmodelRegistry: options.services.modelRegistry,\n\t\tresourceLoader: options.services.resourceLoader,\n\t\tsessionManager: options.sessionManager,\n\t\tmodel: options.model,\n\t\tthinkingLevel: options.thinkingLevel,\n\t\tisExplicitModel: options.isExplicitModel,\n\t\tisExplicitThinking: options.isExplicitThinking,\n\t\tscopedModels: options.scopedModels,\n\t\ttools: options.tools,\n\t\texcludeTools: options.excludeTools,\n\t\tnoTools: options.noTools,\n\t\ttoolProfileFilter:\n\t\t\toptions.toolProfileFilter ?? options.services.settingsManager.getResourceProfileFilter(\"tools\"),\n\t\tcustomTools: options.customTools,\n\t\tsessionStartEvent: options.sessionStartEvent,\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-services.js","sourceRoot":"","sources":["../../src/core/agent-session-services.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAA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c;QACtC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,iBAAiB,EAChB,OAAO,CAAC,iBAAiB,IAAI,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,wBAAwB,CAAC,OAAO,CAAC;QAChG,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;KAC5C,CAAC,CAAC;AAAA,CACH","sourcesContent":["import type { ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport { getAgentDir } from \"../config.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { configFile } from \"./agent-paths.ts\";\nimport { AuthStorage } from \"./auth-storage.ts\";\nimport type { SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { DefaultResourceLoader, type DefaultResourceLoaderOptions, type ResourceLoader } from \"./resource-loader.ts\";\nimport { parseResourceProfileInput } from \"./resource-profile-blocks.ts\";\nimport { type CreateAgentSessionOptions, type CreateAgentSessionResult, createAgentSession } from \"./sdk.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\n\n/**\n * Non-fatal issues collected while creating services or sessions.\n *\n * Runtime creation returns diagnostics to the caller instead of printing or\n * exiting. The app layer decides whether warnings should be shown and whether\n * errors should abort startup.\n */\nexport interface AgentSessionRuntimeDiagnostic {\n\ttype: \"info\" | \"warning\" | \"error\";\n\tmessage: string;\n}\n\n/**\n * Inputs for creating cwd-bound runtime services.\n *\n * These services are recreated whenever the effective session cwd changes.\n * CLI-provided resource paths should be resolved to absolute paths before they\n * reach this function, so later cwd switches do not reinterpret them.\n */\nexport interface CreateAgentSessionServicesOptions {\n\tcwd: string;\n\tagentDir?: string;\n\tauthStorage?: AuthStorage;\n\tsettingsManager?: SettingsManager;\n\tmodelRegistry?: ModelRegistry;\n\textensionFlagValues?: Map<string, boolean | string>;\n\tresourceLoaderOptions?: Omit<DefaultResourceLoaderOptions, \"cwd\" | \"agentDir\" | \"settingsManager\">;\n}\n\n/**\n * Inputs for creating an AgentSession from already-created services.\n *\n * Use this after services exist and any cwd-bound model/tool/session options\n * have been resolved against those services.\n */\nexport interface CreateAgentSessionFromServicesOptions {\n\tservices: AgentSessionServices;\n\tsessionManager: SessionManager;\n\tsessionStartEvent?: SessionStartEvent;\n\tmodel?: Model<any>;\n\tthinkingLevel?: ThinkingLevel;\n\t/** Preserve whether the foreground model came from an explicit launch flag. */\n\tisExplicitModel?: boolean;\n\t/** Preserve whether the thinking level came from an explicit launch flag. */\n\tisExplicitThinking?: boolean;\n\tscopedModels?: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;\n\ttools?: string[];\n\texcludeTools?: CreateAgentSessionOptions[\"excludeTools\"];\n\tnoTools?: CreateAgentSessionOptions[\"noTools\"];\n\ttoolProfileFilter?: CreateAgentSessionOptions[\"toolProfileFilter\"];\n\tresourceProfileDefinitions?: CreateAgentSessionOptions[\"resourceProfileDefinitions\"];\n\tresourceProfileJson?: CreateAgentSessionOptions[\"resourceProfileJson\"];\n\tresourceProfiles?: CreateAgentSessionOptions[\"resourceProfiles\"];\n\tcustomTools?: ToolDefinition[];\n}\n\n/**\n * Coherent cwd-bound runtime services for one effective session cwd.\n *\n * This is infrastructure only. The AgentSession itself is created separately so\n * session options can be resolved against these services first.\n */\nexport interface AgentSessionServices {\n\tcwd: string;\n\tagentDir: string;\n\tauthStorage: AuthStorage;\n\tsettingsManager: SettingsManager;\n\tmodelRegistry: ModelRegistry;\n\tresourceLoader: ResourceLoader;\n\tdiagnostics: AgentSessionRuntimeDiagnostic[];\n}\n\nfunction applyExtensionFlagValues(\n\tresourceLoader: ResourceLoader,\n\textensionFlagValues: Map<string, boolean | string> | undefined,\n): AgentSessionRuntimeDiagnostic[] {\n\tif (!extensionFlagValues) {\n\t\treturn [];\n\t}\n\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tconst extensionsResult = resourceLoader.getExtensions();\n\tconst registeredFlags = new Map<string, { type: \"boolean\" | \"string\" }>();\n\tfor (const extension of extensionsResult.extensions) {\n\t\tfor (const [name, flag] of extension.flags) {\n\t\t\tregisteredFlags.set(name, { type: flag.type });\n\t\t}\n\t}\n\n\tconst unknownFlags: string[] = [];\n\tfor (const [name, value] of extensionFlagValues) {\n\t\tconst flag = registeredFlags.get(name);\n\t\tif (!flag) {\n\t\t\tunknownFlags.push(name);\n\t\t\tcontinue;\n\t\t}\n\t\tif (flag.type === \"boolean\") {\n\t\t\textensionsResult.runtime.flagValues.set(name, true);\n\t\t\tcontinue;\n\t\t}\n\t\tif (typeof value === \"string\") {\n\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\tcontinue;\n\t\t}\n\t\tdiagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `Extension flag \"--${name}\" requires a value`,\n\t\t});\n\t}\n\n\tif (unknownFlags.length > 0) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"error\",\n\t\t\tmessage: `Unknown option${unknownFlags.length === 1 ? \"\" : \"s\"}: ${unknownFlags.map((name) => `--${name}`).join(\", \")}`,\n\t\t});\n\t}\n\n\treturn diagnostics;\n}\n\n/**\n * Create cwd-bound runtime services.\n *\n * Returns services plus diagnostics. It does not create an AgentSession.\n */\nexport async function createAgentSessionServices(\n\toptions: CreateAgentSessionServicesOptions,\n): Promise<AgentSessionServices> {\n\tconst cwd = resolvePath(options.cwd);\n\tconst agentDir = options.agentDir ? resolvePath(options.agentDir) : getAgentDir();\n\tconst authStorage = options.authStorage ?? AuthStorage.create(configFile(agentDir, \"auth.json\"));\n\tconst settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);\n\tconst modelRegistry =\n\t\toptions.modelRegistry ?? ModelRegistry.create(authStorage, configFile(agentDir, \"models.json\"));\n\tconst resourceLoader = new DefaultResourceLoader({\n\t\t...(options.resourceLoaderOptions ?? {}),\n\t\tcwd,\n\t\tagentDir,\n\t\tsettingsManager,\n\t});\n\tawait resourceLoader.reload();\n\n\tconst diagnostics: AgentSessionRuntimeDiagnostic[] = [];\n\tconst extensionsResult = resourceLoader.getExtensions();\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tconst runtimeExtensionPaths = new Set(\n\t\t(activeProfileNames.length === 0\n\t\t\t? extensionsResult.extensions.filter((extension) => extension.sourceInfo.source === \"inline\")\n\t\t\t: extensionsResult.extensions.filter((extension) =>\n\t\t\t\t\tsettingsManager.isResourceAllowedByProfile(\"extensions\", extension.path, extension.sourceInfo.baseDir),\n\t\t\t\t)\n\t\t).map((extension) => extension.path),\n\t);\n\tfor (const { name, config, extensionPath } of extensionsResult.runtime.pendingProviderRegistrations) {\n\t\t// Initial model resolution needs providers before AgentSession binds its runner, but it must\n\t\t// observe the same UAC-filtered extension generation as RuntimeBuilder. Registrations from\n\t\t// withheld extensions remain inert and are discarded with the pending queue below.\n\t\tif (!runtimeExtensionPaths.has(extensionPath)) continue;\n\t\ttry {\n\t\t\tmodelRegistry.registerProvider(name, config);\n\t\t\tlet ownedProviders = extensionsResult.runtime.providersByExtension.get(extensionPath);\n\t\t\tif (!ownedProviders) {\n\t\t\t\townedProviders = new Set();\n\t\t\t\textensionsResult.runtime.providersByExtension.set(extensionPath, ownedProviders);\n\t\t\t}\n\t\t\townedProviders.add(name);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"error\",\n\t\t\t\tmessage: `Extension \"${extensionPath}\" error: ${message}`,\n\t\t\t});\n\t\t}\n\t}\n\textensionsResult.runtime.pendingProviderRegistrations = [];\n\tdiagnostics.push(...applyExtensionFlagValues(resourceLoader, options.extensionFlagValues));\n\n\treturn {\n\t\tcwd,\n\t\tagentDir,\n\t\tauthStorage,\n\t\tsettingsManager,\n\t\tmodelRegistry,\n\t\tresourceLoader,\n\t\tdiagnostics,\n\t};\n}\n\n/**\n * Create an AgentSession from previously created services.\n *\n * This keeps session creation separate from service creation so callers can\n * resolve model, thinking, tools, and other session inputs against the target\n * cwd before constructing the session.\n */\nexport async function createAgentSessionFromServices(\n\toptions: CreateAgentSessionFromServicesOptions,\n): Promise<CreateAgentSessionResult> {\n\tconst needsProfileReload =\n\t\toptions.resourceProfileDefinitions !== undefined ||\n\t\toptions.resourceProfileJson !== undefined ||\n\t\toptions.resourceProfiles !== undefined;\n\tif (options.resourceProfileDefinitions) {\n\t\toptions.services.settingsManager.addInlineResourceProfileDefinitions(options.resourceProfileDefinitions);\n\t}\n\tif (options.resourceProfileJson) {\n\t\tconst inputs = Array.isArray(options.resourceProfileJson)\n\t\t\t? options.resourceProfileJson\n\t\t\t: [options.resourceProfileJson];\n\t\tfor (const input of inputs) {\n\t\t\toptions.services.settingsManager.addInlineResourceProfileDefinitions(\n\t\t\t\tparseResourceProfileInput(input).profiles,\n\t\t\t);\n\t\t}\n\t}\n\tif (options.resourceProfiles !== undefined) {\n\t\toptions.services.settingsManager.setRuntimeResourceProfiles(options.resourceProfiles);\n\t}\n\tif (needsProfileReload) {\n\t\tawait options.services.resourceLoader.reload();\n\t}\n\n\treturn createAgentSession({\n\t\tcwd: options.services.cwd,\n\t\tagentDir: options.services.agentDir,\n\t\tauthStorage: options.services.authStorage,\n\t\tsettingsManager: options.services.settingsManager,\n\t\tmodelRegistry: options.services.modelRegistry,\n\t\tresourceLoader: options.services.resourceLoader,\n\t\tsessionManager: options.sessionManager,\n\t\tmodel: options.model,\n\t\tthinkingLevel: options.thinkingLevel,\n\t\tisExplicitModel: options.isExplicitModel,\n\t\tisExplicitThinking: options.isExplicitThinking,\n\t\tscopedModels: options.scopedModels,\n\t\ttools: options.tools,\n\t\texcludeTools: options.excludeTools,\n\t\tnoTools: options.noTools,\n\t\ttoolProfileFilter:\n\t\t\toptions.toolProfileFilter ?? options.services.settingsManager.getResourceProfileFilter(\"tools\"),\n\t\tcustomTools: options.customTools,\n\t\tsessionStartEvent: options.sessionStartEvent,\n\t});\n}\n"]}
|
|
@@ -23,15 +23,16 @@ import type { ContextUsage, ExtensionCommandContextActions, ExtensionContext, Ex
|
|
|
23
23
|
import { type ChannelProvider, GatewayRegistry, type JobSchedulerProvider } from "./gateways/channel-provider.ts";
|
|
24
24
|
import type { GoalContinuationPrompt, GoalContinuationPromptLimits } from "./goals/goal-continuation-prompt.ts";
|
|
25
25
|
import { type GoalRuntimeSnapshot, type GoalRuntimeSnapshotSettings } from "./goals/goal-runtime-snapshot.ts";
|
|
26
|
-
import type
|
|
26
|
+
import { type GoalState } from "./goals/goal-state.ts";
|
|
27
27
|
import type { LearningAuditRecord } from "./learning/learning-audit.ts";
|
|
28
28
|
import type { DemandSignals, ReflectionResult } from "./learning/reflection-engine.ts";
|
|
29
29
|
import { type CurationProposals } from "./learning/skill-curator.ts";
|
|
30
30
|
import type { MemoryProvider } from "./memory/memory-provider.ts";
|
|
31
|
-
import { type ModelCapabilityProfile } from "./model-capability.ts";
|
|
31
|
+
import { type LaneWorkerRefusal, type ModelCapabilityProfile } from "./model-capability.ts";
|
|
32
32
|
import type { ModelRegistry } from "./model-registry.ts";
|
|
33
33
|
import { type NativeToolProbeGrade } from "./models/adaptation-store.ts";
|
|
34
34
|
import type { StoredFitnessReport } from "./models/fitness-store.ts";
|
|
35
|
+
import type { PrismLlamaCppRuntime } from "./models/llamacpp-runtime.ts";
|
|
35
36
|
import type { LocalRuntimeDeps, OllamaRuntime, TransformersRuntime } from "./models/local-runtime.ts";
|
|
36
37
|
import { type PromptTemplate } from "./prompt-templates.ts";
|
|
37
38
|
import type { ModelFitnessReport } from "./research/model-fitness.ts";
|
|
@@ -261,6 +262,35 @@ export interface SessionStats {
|
|
|
261
262
|
}
|
|
262
263
|
/** customType for spawned-usage roll-up entries (Cost Aggregation, Model A). */
|
|
263
264
|
export declare const SPAWNED_USAGE_CUSTOM_TYPE = "spawned_usage";
|
|
265
|
+
/**
|
|
266
|
+
* customType for a persisted runaway-loop-backstop entry: the agent loop stopped a turn stuck
|
|
267
|
+
* repeating one identical tool-call signature. This is the session-log/telemetry sink for
|
|
268
|
+
* {@link Agent.onRunawayStop} — see `_installAgentToolHooks`.
|
|
269
|
+
*/
|
|
270
|
+
export declare const RUNAWAY_STOP_CUSTOM_TYPE = "runaway_stop";
|
|
271
|
+
/** Payload persisted for a {@link RUNAWAY_STOP_CUSTOM_TYPE} entry. */
|
|
272
|
+
export interface RunawayStopRecord {
|
|
273
|
+
signature: string;
|
|
274
|
+
repeats: number;
|
|
275
|
+
model?: string;
|
|
276
|
+
provider?: string;
|
|
277
|
+
at: string;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* customType for a persisted tool-validation-escalation entry: the agent loop bounced the same
|
|
281
|
+
* tool-call validation failure enough times to escalate. This is the session-log/telemetry sink for
|
|
282
|
+
* {@link Agent.onToolValidationEscalation} — see `_installAgentToolHooks`.
|
|
283
|
+
*/
|
|
284
|
+
export declare const TOOL_VALIDATION_ESCALATION_CUSTOM_TYPE = "tool_validation_escalation";
|
|
285
|
+
/** Payload persisted for a {@link TOOL_VALIDATION_ESCALATION_CUSTOM_TYPE} entry. */
|
|
286
|
+
export interface ToolValidationEscalationRecord {
|
|
287
|
+
tool: string;
|
|
288
|
+
signature: string;
|
|
289
|
+
repeats: number;
|
|
290
|
+
model: string;
|
|
291
|
+
provider: string;
|
|
292
|
+
at: string;
|
|
293
|
+
}
|
|
264
294
|
/**
|
|
265
295
|
* A single spawned/subagent usage report, persisted as a `CustomEntry`
|
|
266
296
|
* (`customType: "spawned_usage"`). Persistence-only — does NOT enter LLM context.
|
|
@@ -319,12 +349,38 @@ export interface IsolatedCompletionOptions {
|
|
|
319
349
|
/** Abort signal. */
|
|
320
350
|
signal?: AbortSignal;
|
|
321
351
|
/**
|
|
322
|
-
* Prompt-cache retention for this isolated call.
|
|
323
|
-
*
|
|
324
|
-
*
|
|
352
|
+
* Prompt-cache retention for this isolated call. REQUIRED — the provider-level default is
|
|
353
|
+
* `"short"`, the opposite of this primitive's old implicit default, so a caller that forgot to
|
|
354
|
+
* set it would silently pay full input price forever. Pass `"none"` explicitly to preserve full
|
|
355
|
+
* isolation (no caching); callers whose `systemPrompt` is STATIC across calls (e.g. reflection,
|
|
356
|
+
* #33) should pass `"short"`/`"long"` so the provider reuses the cached prefix and bills only the
|
|
357
|
+
* variable tail.
|
|
325
358
|
*/
|
|
326
|
-
cacheRetention
|
|
359
|
+
cacheRetention: CacheRetention;
|
|
360
|
+
/**
|
|
361
|
+
* Lane/caller kind (e.g. `"reflection"`, `"research"`, `"worker"`, `"fitness"`) used to derive this
|
|
362
|
+
* call's synthetic cache-affinity key (see {@link computeLaneAffinityKey}). Omitted callers fall
|
|
363
|
+
* back to {@link DEFAULT_ISOLATED_LANE_KIND} — still a stable, namespaced key, just not
|
|
364
|
+
* lane-differentiated. Never the real session id.
|
|
365
|
+
*/
|
|
366
|
+
laneKind?: string;
|
|
327
367
|
}
|
|
368
|
+
/** Fallback {@link IsolatedCompletionOptions.laneKind} for callers that do not tag their lane. */
|
|
369
|
+
export declare const DEFAULT_ISOLATED_LANE_KIND = "isolated";
|
|
370
|
+
/**
|
|
371
|
+
* Derive a STABLE synthetic cache-affinity key for an isolated completion lane. Isolated calls
|
|
372
|
+
* deliberately never carry the real session id (see reflection-controller.ts's isolation invariants —
|
|
373
|
+
* an isolated call must not entangle with the main session), which today also means every isolated
|
|
374
|
+
* call looks like a brand-new, uncorrelated session to providers with session-affinity headers /
|
|
375
|
+
* `prompt_cache_key` (anthropic.ts's `x-session-affinity`, openai-responses.ts /
|
|
376
|
+
* openai-completions.ts's `prompt_cache_key`), defeating their cache routing.
|
|
377
|
+
*
|
|
378
|
+
* This key is deterministic per `(laneKind, model, systemPrompt)` — the SAME lane calling the SAME
|
|
379
|
+
* model with the SAME (static) system prompt always gets the SAME key, so repeat calls route to the
|
|
380
|
+
* same cache-warm backend — while remaining fully synthetic: it is a salted hash, namespaced with a
|
|
381
|
+
* `lane:` prefix, and never derived from or equal to the real session id.
|
|
382
|
+
*/
|
|
383
|
+
export declare function computeLaneAffinityKey(laneKind: string, model: Model<any> | undefined, systemPrompt: string): string;
|
|
328
384
|
/** Result of an isolated completion: the text, the usage spent, and the stop reason. */
|
|
329
385
|
export interface IsolatedCompletionResult {
|
|
330
386
|
text: string;
|
|
@@ -356,7 +412,7 @@ export interface GoalContinuationOnceResult {
|
|
|
356
412
|
snapshot: GoalRuntimeSnapshot;
|
|
357
413
|
prompt?: GoalContinuationPrompt;
|
|
358
414
|
}
|
|
359
|
-
export type GoalContinuationLoopStopReason = "continuation_not_allowed" | "max_turns_reached" | "wall_clock_budget_reached" | "goal_state_not_advanced";
|
|
415
|
+
export type GoalContinuationLoopStopReason = "continuation_not_allowed" | "max_turns_reached" | "wall_clock_budget_reached" | "goal_state_not_advanced" | "goal_budget_exhausted" | "already_continuing" | "session_disposed" | "goal_tool_unavailable" | "worker_in_flight";
|
|
360
416
|
export interface GoalContinuationLoopOptions extends GoalContinuationOnceOptions {
|
|
361
417
|
maxTurns: number;
|
|
362
418
|
/** 0 or undefined disables wall-clock budget. */
|
|
@@ -405,6 +461,8 @@ export declare class AgentSession {
|
|
|
405
461
|
private _resourceLoader;
|
|
406
462
|
private _customTools;
|
|
407
463
|
private _cwd;
|
|
464
|
+
/** Per-agent persistent shell session identity: stable across runtime reloads, disposed with the session. */
|
|
465
|
+
private readonly _shellSessionKey;
|
|
408
466
|
private _agentDir;
|
|
409
467
|
private _collectWorkspaceSources;
|
|
410
468
|
private readonly _localRuntimeController;
|
|
@@ -414,11 +472,22 @@ export declare class AgentSession {
|
|
|
414
472
|
private readonly _repairModeSessionCounts;
|
|
415
473
|
private readonly _textProtocolParseFailures;
|
|
416
474
|
private _textProtocolParseObservedThisTurn;
|
|
475
|
+
/** Total text-protocol parse-failure events observed this session, backing the
|
|
476
|
+
* {@link TEXT_TOOL_PROTOCOL_STEER_INTERVAL} throttle on {@link _maybeInjectTextProtocolCorrectiveSteer}. */
|
|
477
|
+
private _textProtocolCorrectiveSteerCount;
|
|
478
|
+
/** Monotonic counter backing tool-probe/text-protocol-calibration spawned-usage reportIds
|
|
479
|
+
* (see {@link _nextProbeUsageReportId}); guarantees each probe/calibration completion in the
|
|
480
|
+
* session lands in the cost ledger exactly once, even across repeated /toolprobe invocations. */
|
|
481
|
+
private _toolProbeUsageReportSeq;
|
|
482
|
+
/** Anti-loop: modelKeys the evidence-gated auto-probe has already fired for THIS session (see
|
|
483
|
+
* {@link _maybeAutoProbeOnValidationEscalation}), so a burst of validation-escalation events for
|
|
484
|
+
* the same still-failing model never re-fires the probe more than once per session. */
|
|
485
|
+
private readonly _autoProbedModels;
|
|
417
486
|
private _textProtocolValidationOutcomeThisTurn;
|
|
418
487
|
/** Assembles the session's base system prompt from live session state (see
|
|
419
488
|
* system-prompt-builder.ts); owns the paired _baseSystemPromptOptions. */
|
|
420
489
|
private readonly _systemPromptBuilder;
|
|
421
|
-
/**
|
|
490
|
+
/** Autonomy telemetry sink + status/diagnostic snapshots (see autonomy-telemetry.ts); owns
|
|
422
491
|
* the latest gate outcome and the bounded gate-outcome history. */
|
|
423
492
|
private readonly _autonomyTelemetry;
|
|
424
493
|
/** Goal auto-continue + research lane + scout-worker delegation + model-fitness probe (see
|
|
@@ -447,6 +516,13 @@ export declare class AgentSession {
|
|
|
447
516
|
private readonly _analytics;
|
|
448
517
|
private readonly _treeNavigator;
|
|
449
518
|
private _lastCostGuardDecision?;
|
|
519
|
+
/**
|
|
520
|
+
* `getSpawnedUsage().cost` snapshotted at the start of the CURRENT foreground prompt cycle (see
|
|
521
|
+
* `_promptUnserialized`), so the cost guard can attribute only background/spawned spend since THIS
|
|
522
|
+
* turn began, not the session's entire lifetime spend. Reset on every new user prompt; every
|
|
523
|
+
* round-trip within the same turn (tool-call iterations) shares this one baseline.
|
|
524
|
+
*/
|
|
525
|
+
private _costGuardTurnBaselineUsd;
|
|
450
526
|
/** Per-turn model-router subsystem (see model-router-controller.ts); owns the transient route/intent,
|
|
451
527
|
* the cheap-turn session buffer, the escalation/retry flags, and the sticky last-decision/skip-reason
|
|
452
528
|
* used by the status report. Its parallel routed drive path delegates every turn back to
|
|
@@ -520,6 +596,15 @@ export declare class AgentSession {
|
|
|
520
596
|
* model, full system prompt, converted messages, and tool schemas are known. The guard is a
|
|
521
597
|
* projection threshold rather than a hard output cap: warning mode never reduces capability, while
|
|
522
598
|
* opt-in downgrade changes only this request's reasoning effort. Best-effort: never throws.
|
|
599
|
+
*
|
|
600
|
+
* The ceiling is turn-cumulative: the next foreground call's projection is folded together with
|
|
601
|
+
* background/research/worker/reflection spend recorded SINCE THIS TURN BEGAN — {@link getSpawnedUsage}'s
|
|
602
|
+
* already-recorded rollup (the same read-side-deduped total the footer's SUBAGENTS line uses) minus the
|
|
603
|
+
* baseline snapshotted at the top of `_promptUnserialized` ({@link _costGuardTurnBaselineUsd}) — so a
|
|
604
|
+
* turn that is cheap in the foreground but has spent heavily via background lanes THIS turn still trips
|
|
605
|
+
* the warning, while a prior turn's background spend does not keep every later turn's guard stuck
|
|
606
|
+
* "over". A background lane that finishes mid-turn is attributed to whichever turn it completes in.
|
|
607
|
+
* Per-lane dollar caps (research/worker `maxUsd`) are separate and untouched by this guard.
|
|
523
608
|
*/
|
|
524
609
|
private _resolveCostGuardRequestReasoning;
|
|
525
610
|
/** Latest cost-guard decision (for the host footer/UI to surface a warning). Undefined if disabled. */
|
|
@@ -551,6 +636,14 @@ export declare class AgentSession {
|
|
|
551
636
|
private _getModelAdaptationRulesForPrompt;
|
|
552
637
|
private _textProtocolFlag;
|
|
553
638
|
private _streamForToolProbe;
|
|
639
|
+
/** Builds a reportId that uniquely identifies one probe/calibration completion within the
|
|
640
|
+
* session: the model, a caller-supplied `kind` (e.g. "read-task", "echo", or
|
|
641
|
+
* "text-protocol:<variant>"), and a monotonic sequence number. The sequence number (not
|
|
642
|
+
* wall-clock time or randomness) is what guarantees no collision even when the same model+kind
|
|
643
|
+
* is probed again later in the session (e.g. a repeated /toolprobe run), so genuine repeat spend
|
|
644
|
+
* is never silently deduped away. */
|
|
645
|
+
private _nextProbeUsageReportId;
|
|
646
|
+
private _resolveProbeStreamCountingUsage;
|
|
554
647
|
private _textProtocolCalibrationContext;
|
|
555
648
|
private _messageHasToolCallWithStringArgument;
|
|
556
649
|
private _nativeToolProbeSystemPrompt;
|
|
@@ -561,12 +654,35 @@ export declare class AgentSession {
|
|
|
561
654
|
private _calibrateTextToolProtocolForModel;
|
|
562
655
|
private _ensureTextToolProtocolForActiveModel;
|
|
563
656
|
private _modelRef;
|
|
657
|
+
/** The persisted `/toolprobe` verdict on record for this model, if any (undefined = unprobed). */
|
|
658
|
+
private _toolProbeVerdict;
|
|
564
659
|
private _formatToolProbeReport;
|
|
565
660
|
private _storeToolProbe;
|
|
566
661
|
private _probeToolCallingForModel;
|
|
567
662
|
private _resolveToolProbeModels;
|
|
568
663
|
probeToolCalling(target?: string): Promise<ToolProbeReport>;
|
|
664
|
+
/**
|
|
665
|
+
* The text-protocol circuit breaker. Every parse failure (from either the
|
|
666
|
+
* live per-completion {@link Agent.onTextToolProtocolParse} callback or the post-hoc detection in
|
|
667
|
+
* {@link _recordTextToolProtocolParseOutcomeFromLastAssistant}) gets a throttled one-line
|
|
668
|
+
* corrective steer for the next turn. On the 3rd consecutive SAME-SIGNATURE failure — graded
|
|
669
|
+
* evidence a model genuinely cannot speak this dialect, not a single bad turn — the breaker also
|
|
670
|
+
* demotes the persisted tool-probe verdict to "none" so {@link _textProtocolFlag} reads false next
|
|
671
|
+
* turn and native is attempted instead of thrashing on a protocol this model has proven it can't
|
|
672
|
+
* follow.
|
|
673
|
+
*/
|
|
569
674
|
private _handleTextToolProtocolParse;
|
|
675
|
+
/**
|
|
676
|
+
* A phone model whose envelope fails to parse gets no corrective guidance today —
|
|
677
|
+
* the runaway-loop backstop only trips on repeated PARSED tool-call signatures (agent-loop.ts), so
|
|
678
|
+
* an every-turn unparseable-prose model never trips it. Inject a one-line reminder of the envelope
|
|
679
|
+
* shape as a nextTurn message, reusing {@link formatVariantEnvelope} so the reminder can never
|
|
680
|
+
* drift from the grammar the primer actually teaches. Throttled to the first failure this session
|
|
681
|
+
* and then every {@link TEXT_TOOL_PROTOCOL_STEER_INTERVAL}th after — the breaker above is what
|
|
682
|
+
* actually demotes a genuinely-failing model at the 3rd same-signature failure; this is guidance,
|
|
683
|
+
* not a second counter.
|
|
684
|
+
*/
|
|
685
|
+
private _maybeInjectTextProtocolCorrectiveSteer;
|
|
570
686
|
private _handleTextToolProtocolValidationOutcome;
|
|
571
687
|
private _recordTextToolProtocolParseOutcomeFromLastAssistant;
|
|
572
688
|
private _looksLikeTextToolProtocolAttempt;
|
|
@@ -670,6 +786,55 @@ export declare class AgentSession {
|
|
|
670
786
|
*/
|
|
671
787
|
private _estimateCurrentContextTokens;
|
|
672
788
|
private _installAgentToolHooks;
|
|
789
|
+
/**
|
|
790
|
+
* The runaway-loop backstop ({@link Agent.maxStallTurns}) stopped a turn stuck repeating one
|
|
791
|
+
* identical tool-call signature. Previously silent — this is the first host handler. Records a
|
|
792
|
+
* session-log/telemetry entry (see {@link RUNAWAY_STOP_CUSTOM_TYPE}) and surfaces a user-visible
|
|
793
|
+
* warning through the same event the context-window/compaction backstops use.
|
|
794
|
+
*/
|
|
795
|
+
private _handleRunawayStop;
|
|
796
|
+
/** Anti-loop: true when this model's persisted tool-probe verdict was written within the
|
|
797
|
+
* auto-probe freshness window ({@link AUTO_TOOL_PROBE_FRESHNESS_MS}) — covers a very recent
|
|
798
|
+
* explicit `/toolprobe` run or a fresh circuit-breaker demote from an EARLIER session, complementing
|
|
799
|
+
* the in-session {@link _autoProbedModels} latch. */
|
|
800
|
+
private _hasFreshToolProbeVerdict;
|
|
801
|
+
/**
|
|
802
|
+
* Evidence-gated native→phone auto-probe for a LOCAL/MANAGED model (never cloud — see
|
|
803
|
+
* {@link isLocalOrManagedRouterModel}) that just crossed the tool-argument-validation escalation
|
|
804
|
+
* threshold — repeated identical validation failures with no successful native call in between,
|
|
805
|
+
* which is exactly the graded evidence {@link Agent.onToolValidationEscalation} already requires
|
|
806
|
+
* before firing. Runs the SAME probe `/toolprobe` uses ({@link _probeToolCallingForModel}: native
|
|
807
|
+
* trials first, so a model that can actually tool-call natively still resolves to verdict
|
|
808
|
+
* "native" and is never phoned) entirely OFF the hot path — fired here but never awaited by the
|
|
809
|
+
* caller, so a slow or failing probe can never block or throw the user's in-flight turn.
|
|
810
|
+
* Anti-loop: skipped when this session already auto-probed this model, or a fresh persisted
|
|
811
|
+
* verdict already exists ({@link _hasFreshToolProbeVerdict}) — otherwise a model that keeps
|
|
812
|
+
* failing validation every turn would re-fire the (multi-completion) probe every single turn.
|
|
813
|
+
*/
|
|
814
|
+
private _maybeAutoProbeOnValidationEscalation;
|
|
815
|
+
/**
|
|
816
|
+
* A repeated identical tool-argument-validation failure crossed the escalation threshold
|
|
817
|
+
* ({@link Agent.toolValidationEscalationThreshold}) — the graded evidence the capability-gate
|
|
818
|
+
* spine acts on. Always records a session-log/telemetry entry (see {@link
|
|
819
|
+
* TOOL_VALIDATION_ESCALATION_CUSTOM_TYPE}), then branches on the failing model's class:
|
|
820
|
+
* - LOCAL/MANAGED ({@link isLocalOrManagedRouterModel}, never cloud): the failure is evidence the
|
|
821
|
+
* model may lack native tool-calling, so it fires the evidence-gated native→phone auto-probe
|
|
822
|
+
* off the hot path ({@link _maybeAutoProbeOnValidationEscalation}). Escalating a local model's
|
|
823
|
+
* ROUTER TIER on a tool-call failure would not fix a capability problem, so this branch never
|
|
824
|
+
* touches the model router.
|
|
825
|
+
* - CLOUD (known tool-capable): the failure is evidence the routed tier is too weak for this
|
|
826
|
+
* request, so it escalates via {@link ModelRouterController.requestValidationFailureEscalation}
|
|
827
|
+
* — de-conflated from the beforeToolCall mutation gate ({@link
|
|
828
|
+
* ModelRouterController.maybeEscalateToolCall}/`shouldEscalateModelRouterTool`): repeated
|
|
829
|
+
* validation failure is grounds to escalate REGARDLESS of the failing tool's mutation status,
|
|
830
|
+
* so a read-only tool's repeated failure now escalates too (previously a no-op, since the old
|
|
831
|
+
* code reused the mutation gate verbatim for this unrelated signal). Cloud models are never
|
|
832
|
+
* probe-gated or phoned by this handler.
|
|
833
|
+
* If the registry can no longer resolve `event.model`/`event.provider` (e.g. the model was
|
|
834
|
+
* unregistered mid-session), falls back to the cloud/tier-escalation path — the previously
|
|
835
|
+
* existing behavior — rather than silently dropping the signal.
|
|
836
|
+
*/
|
|
837
|
+
private _handleToolValidationEscalation;
|
|
673
838
|
/** Emit an event to all listeners */
|
|
674
839
|
private _emit;
|
|
675
840
|
private _notifyWorkerTerminalHandoff;
|
|
@@ -743,14 +908,14 @@ export declare class AgentSession {
|
|
|
743
908
|
* Returns the names of tools currently set on the agent.
|
|
744
909
|
*/
|
|
745
910
|
getActiveToolNames(): string[];
|
|
746
|
-
/**
|
|
911
|
+
/** Build a foreground {@link CapabilityEnvelope} from the live session state (active tools, cwd, cost ceiling). */
|
|
747
912
|
private _buildForegroundEnvelopeFromState;
|
|
748
913
|
/**
|
|
749
|
-
*
|
|
914
|
+
* (Re)build the foreground envelope for the current turn. Visibility only -- the foreground
|
|
750
915
|
* envelope is NOT enforced this round. Best-effort: never throws into the turn.
|
|
751
916
|
*/
|
|
752
917
|
private _refreshForegroundEnvelope;
|
|
753
|
-
/**
|
|
918
|
+
/** The auto-constructed foreground envelope for the current/most-recent turn (visibility only). */
|
|
754
919
|
getForegroundEnvelope(): CapabilityEnvelope | undefined;
|
|
755
920
|
/**
|
|
756
921
|
* Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.
|
|
@@ -807,7 +972,7 @@ export declare class AgentSession {
|
|
|
807
972
|
private _refreshBaseSystemPrompt;
|
|
808
973
|
/**
|
|
809
974
|
* Build a system prompt for a specific tool surface WITHOUT touching the session's base prompt
|
|
810
|
-
* state (
|
|
975
|
+
* state (used by the router's model swap; see {@link SystemPromptBuilder.buildSystemPromptForToolNames}).
|
|
811
976
|
*/
|
|
812
977
|
private _buildSystemPromptForToolNames;
|
|
813
978
|
private _runAgentPrompt;
|
|
@@ -819,11 +984,25 @@ export declare class AgentSession {
|
|
|
819
984
|
*/
|
|
820
985
|
getLocalRuntime(baseUrl?: string): OllamaRuntime;
|
|
821
986
|
getTransformersRuntime(modelId: string, baseUrl?: string): TransformersRuntime;
|
|
987
|
+
/** Shared {@link PrismLlamaCppRuntime} for pi's own managed prism install — see
|
|
988
|
+
* {@link LocalRuntimeController.getPrismLlamaCppRuntime}. Delegates so `/models` and the
|
|
989
|
+
* readiness gate share the SAME cached instance, same contract as getLocalRuntime above. */
|
|
990
|
+
getPrismLlamaCppRuntime(): PrismLlamaCppRuntime;
|
|
822
991
|
/** models.json registers a local model's baseUrl as `<server>/v1` (OpenAI-compat); the runtime's
|
|
823
992
|
* own health/boot endpoints are on the Ollama-native server root. Delegates to
|
|
824
993
|
* {@link LocalRuntimeController}; kept here for `_warnIfManualModelChoiceIsRisky`'s own use. */
|
|
825
994
|
private _deriveOllamaServerUrl;
|
|
826
995
|
private _ensureRouteModelReady;
|
|
996
|
+
/**
|
|
997
|
+
* Every local model the CURRENT (post-reload) configuration could still route a turn to —
|
|
998
|
+
* the foreground model plus any router tier (cheap/medium/expensive) that still resolves to a
|
|
999
|
+
* real, authed, non-exhausted model. Fed to {@link LocalRuntimeController.reconcile} via the
|
|
1000
|
+
* `reconcileLocalRuntimes` hook above, ONLY after a reload generation has fully committed, so a
|
|
1001
|
+
* local model dropped from the live configuration has its pi-spawned runtime stopped instead of
|
|
1002
|
+
* leaking a child process, while one still referenced here is left untouched. Read-only — never
|
|
1003
|
+
* used for routing itself.
|
|
1004
|
+
*/
|
|
1005
|
+
private _collectEligibleLocalModelsForReconcile;
|
|
827
1006
|
getModelRouterStatus(formatLabel?: (label: string) => string): string;
|
|
828
1007
|
private _handlePostAgentRun;
|
|
829
1008
|
/**
|
|
@@ -995,11 +1174,11 @@ export declare class AgentSession {
|
|
|
995
1174
|
/** Register a memory provider contributed by an extension; applied on the next memory (re)init. */
|
|
996
1175
|
registerMemoryProvider(provider: MemoryProvider): void;
|
|
997
1176
|
registerContextMemoryProvider(provider: ContextMemoryProvider): void;
|
|
998
|
-
/**
|
|
1177
|
+
/** The gateway/scheduler registry. A deployment runner registers providers and drives start/stop. */
|
|
999
1178
|
get gateways(): GatewayRegistry;
|
|
1000
|
-
/**
|
|
1179
|
+
/** Register a deployment-supplied transport channel (gateway). */
|
|
1001
1180
|
registerChannelProvider(provider: ChannelProvider): void;
|
|
1002
|
-
/**
|
|
1181
|
+
/** Register a deployment-supplied job scheduler (cron). */
|
|
1003
1182
|
registerJobScheduler(provider: JobSchedulerProvider): void;
|
|
1004
1183
|
private _refreshToolRegistry;
|
|
1005
1184
|
reload(): Promise<void>;
|
|
@@ -1096,6 +1275,21 @@ export declare class AgentSession {
|
|
|
1096
1275
|
* Retrieve the latest valid goal state snapshot from the session log.
|
|
1097
1276
|
*/
|
|
1098
1277
|
getGoalStateSnapshot(): GoalState | undefined;
|
|
1278
|
+
/**
|
|
1279
|
+
* Persist one submitted continuation pass's turn/wall-clock/spend contribution onto the active
|
|
1280
|
+
* goal's durable cumulative budget (see `GoalState.continuationTurnsUsed` et al.). This is the
|
|
1281
|
+
* "persistence dep" `GoalLoopController` calls once per pass actually submitted — it, not the
|
|
1282
|
+
* loop controller, is where USD gets attributed: it reads the session's OWN cumulative model
|
|
1283
|
+
* spend (`getCostSummary().ownCost` — deliberately excludes worker/subagent spend, which is
|
|
1284
|
+
* tracked and budgeted separately) and threads that single absolute reading into a
|
|
1285
|
+
* `record_continuation_budget` event; the pure reducer in `goal-state.ts` derives the delta.
|
|
1286
|
+
* A no-op when no goal state exists (defensive — in practice this is only ever called right
|
|
1287
|
+
* after a pass the loop already confirmed was submitted against an active goal).
|
|
1288
|
+
*/
|
|
1289
|
+
recordGoalContinuationPass(pass: {
|
|
1290
|
+
turns: number;
|
|
1291
|
+
wallClockMs: number;
|
|
1292
|
+
}): void;
|
|
1099
1293
|
/** Save native task-step state to the active session log. */
|
|
1100
1294
|
saveTaskStepsStateSnapshot(state: TaskStepsState): string;
|
|
1101
1295
|
/** Retrieve the latest valid native task-step state from the active session log. */
|
|
@@ -1115,18 +1309,34 @@ export declare class AgentSession {
|
|
|
1115
1309
|
getLaneRecords(): LaneRecord[];
|
|
1116
1310
|
private _emitAutonomyTelemetry;
|
|
1117
1311
|
private _recordGateOutcome;
|
|
1118
|
-
/**
|
|
1312
|
+
/** Copies of the bounded gate-outcome history, oldest first, latest last. */
|
|
1119
1313
|
getGateOutcomeHistory(): GateOutcomeHistoryEntry[];
|
|
1120
1314
|
saveWorkerResultSnapshot(result: WorkerResult, request?: WorkerRequest): string;
|
|
1121
1315
|
getWorkerResultSnapshots(): WorkerResult[];
|
|
1122
1316
|
saveLearningDecisionSnapshot(decision: LearningDecision): string;
|
|
1123
1317
|
getLearningDecisionSnapshots(): LearningDecision[];
|
|
1318
|
+
/**
|
|
1319
|
+
* The single injection point that makes the goal-continuation snapshot lane-aware:
|
|
1320
|
+
* `laneRecords` feeds BOTH `evaluateGoalContinuation`'s "waiting" branch (a worker dispatched
|
|
1321
|
+
* against an open requirement) and the per-goal worker-spend overlay — read fresh here so BOTH the
|
|
1322
|
+
* goal loop (`GoalLoopController`) and the idle scheduler (`BackgroundLaneController`) see the
|
|
1323
|
+
* same live lane state, since both reach this same method.
|
|
1324
|
+
*/
|
|
1124
1325
|
getGoalRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot;
|
|
1125
1326
|
/**
|
|
1126
1327
|
* Capability profile derived from the CURRENT session model's own metadata (context window),
|
|
1127
1328
|
* honoring the modelCapability.mode setting ("off" disables, a class name forces).
|
|
1128
1329
|
*/
|
|
1129
1330
|
getModelCapabilityProfile(): ModelCapabilityProfile;
|
|
1331
|
+
/**
|
|
1332
|
+
* Whether the CURRENT session model may drive a worktree-sync lane worker (see
|
|
1333
|
+
* `evaluateLaneWorkerRefusal` in model-capability.ts): full capability class, a DECLARED
|
|
1334
|
+
* (registry) context window, an ADVERTISED native tool-call path (`Model.textToolCallProtocol`
|
|
1335
|
+
* unset/false -- `true` means phone-only), and no graded `/toolprobe` demotion to
|
|
1336
|
+
* "text-protocol"/"none" on record. An unprobed model (no verdict on record yet) is eligible on
|
|
1337
|
+
* its advertised support alone. `undefined` means eligible.
|
|
1338
|
+
*/
|
|
1339
|
+
getLaneWorkerRefusal(): LaneWorkerRefusal | undefined;
|
|
1130
1340
|
/**
|
|
1131
1341
|
* Run one bounded, read-only research pass and persist its results. Delegates to
|
|
1132
1342
|
* {@link BackgroundLaneController}; see there for the full gating/budget/dedupe contract.
|
|
@@ -1163,6 +1373,13 @@ export declare class AgentSession {
|
|
|
1163
1373
|
/** Fitness reports persisted for THIS host (measured evidence for architect/profile decisions). */
|
|
1164
1374
|
getStoredFitnessReports(): StoredFitnessReport[];
|
|
1165
1375
|
continueGoalOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult>;
|
|
1376
|
+
/**
|
|
1377
|
+
* Public entry point for BOTH idle autosteer and manual (`/goal start`, `/goal-continue`)
|
|
1378
|
+
* continuation. Delegates to {@link BackgroundLaneController.continueGoalLoopExclusive}, the
|
|
1379
|
+
* single-flight guard that prevents two goal loops from racing to submit prompts through the
|
|
1380
|
+
* same session (which throws "Agent is already processing" from the second submission). Do not
|
|
1381
|
+
* call `this._goalContinuation.continueGoalLoop` directly from here — that bypasses the guard.
|
|
1382
|
+
*/
|
|
1166
1383
|
continueGoalLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult>;
|
|
1167
1384
|
/**
|
|
1168
1385
|
* Run a one-shot LLM completion fully ISOLATED from the main session — the load-bearing primitive
|
|
@@ -1170,7 +1387,7 @@ export declare class AgentSession {
|
|
|
1170
1387
|
*/
|
|
1171
1388
|
runIsolatedCompletion(opts: IsolatedCompletionOptions): Promise<IsolatedCompletionResult>;
|
|
1172
1389
|
/**
|
|
1173
|
-
* Native end-of-loop reflection pass
|
|
1390
|
+
* Native end-of-loop reflection pass. Delegates to {@link ReflectionController}; returns null
|
|
1174
1391
|
* when the demand gate skips or in a child session.
|
|
1175
1392
|
*/
|
|
1176
1393
|
runReflectionPass(input: {
|