@caupulican/pi-adaptative 0.81.42 → 0.84.1
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 +57 -0
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +52 -49
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +62 -57
- package/dist/bundled-resources/prompts/skillify.md +1 -1
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +16 -19
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +12 -26
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +15 -121
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +52 -79
- package/dist/bundled-resources/runtimes/pi-shell-engine/escapes.py +70 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +110 -61
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +106 -23
- package/dist/bundled-resources/runtimes/pi-shell-engine/paths.py +10 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +12 -4
- package/dist/bundled-resources/runtimes/pi-shell-engine/shell_args.py +22 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +9 -2
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +129 -259
- package/dist/bundled-resources/skills/authorized-web-security-audit/SKILL.md +187 -0
- package/dist/bundled-resources/skills/authorized-web-security-audit/references/assessment-contract.md +92 -0
- package/dist/bundled-resources/skills/deduplicate-by-evidence/SKILL.md +134 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/SKILL.md +93 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/references/evidence-model.md +27 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/references/security-scanners.md +24 -0
- package/dist/bundled-resources/skills/harness-self-adaptation/SKILL.md +4 -2
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/SKILL.md +217 -0
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/defensive-exploit-catalogue.md +175 -0
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/tool-boundary-checklist.md +87 -0
- package/dist/bundled-resources/skills/skill-architect/SKILL.md +2 -2
- package/dist/bundled-resources/skills/skill-creator/SKILL.md +188 -0
- package/dist/bundled-resources/skills/skill-creator/references/pi-skill-contract.md +73 -0
- package/dist/bundled-resources/skills/skill-creator/scripts/init-skill.mjs +142 -0
- package/dist/bundled-resources/skills/skill-creator/scripts/validate-skill.mjs +122 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +8 -8
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/piped-stdin.d.ts +4 -0
- package/dist/cli/piped-stdin.d.ts.map +1 -0
- package/dist/cli/piped-stdin.js +13 -0
- package/dist/cli/piped-stdin.js.map +1 -0
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -15
- package/dist/config.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts.map +1 -1
- package/dist/core/agent-directory-layout.js.map +1 -1
- package/dist/core/agent-paths.d.ts +1 -1
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +1 -1
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +5 -9
- package/dist/core/agent-session-contracts.d.ts.map +1 -1
- package/dist/core/agent-session-contracts.js +1 -12
- package/dist/core/agent-session-contracts.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +10 -25
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +24 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +210 -237
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +13 -39
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/evidence-finding-projection.d.ts +11 -0
- package/dist/core/autonomy/evidence-finding-projection.d.ts.map +1 -0
- package/dist/core/autonomy/evidence-finding-projection.js +37 -0
- package/dist/core/autonomy/evidence-finding-projection.js.map +1 -0
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
- package/dist/core/autonomy/lane-private-paths.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +2 -3
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/path-scope.d.ts.map +1 -1
- package/dist/core/autonomy/path-scope.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/status.d.ts.map +1 -1
- package/dist/core/autonomy/status.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +2 -4
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +2 -15
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +88 -0
- package/dist/core/background-tool-task-controller.d.ts.map +1 -0
- package/dist/core/background-tool-task-controller.js +470 -0
- package/dist/core/background-tool-task-controller.js.map +1 -0
- package/dist/core/bash-execution-controller.d.ts +1 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +5 -4
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts.map +1 -1
- package/dist/core/bedrock-sso-login.js.map +1 -1
- package/dist/core/billing-failover-controller.d.ts.map +1 -1
- package/dist/core/billing-failover-controller.js +3 -3
- package/dist/core/billing-failover-controller.js.map +1 -1
- package/dist/core/billing-failover.d.ts.map +1 -1
- package/dist/core/billing-failover.js.map +1 -1
- package/dist/core/capability-contract.d.ts.map +1 -1
- package/dist/core/catalog-manager.d.ts.map +1 -1
- package/dist/core/catalog-manager.js +0 -0
- package/dist/core/catalog-manager.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +2 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +21 -8
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +8 -0
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +0 -2
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
- package/dist/core/context/artifact-retrieval.js.map +1 -1
- package/dist/core/context/brain-curator.d.ts.map +1 -1
- package/dist/core/context/brain-curator.js +14 -33
- package/dist/core/context/brain-curator.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +16 -24
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +3 -17
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context/context-composition.d.ts.map +1 -1
- package/dist/core/context/context-composition.js.map +1 -1
- package/dist/core/context/context-item.d.ts.map +1 -1
- package/dist/core/context/context-item.js.map +1 -1
- package/dist/core/context/context-prompt-enforcement.d.ts.map +1 -1
- package/dist/core/context/context-prompt-enforcement.js +3 -16
- package/dist/core/context/context-prompt-enforcement.js.map +1 -1
- package/dist/core/context/context-prompt-policy.d.ts.map +1 -1
- package/dist/core/context/context-prompt-policy.js.map +1 -1
- package/dist/core/context/context-retention.d.ts.map +1 -1
- package/dist/core/context/context-retention.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/context-store.d.ts.map +1 -1
- package/dist/core/context/context-store.js.map +1 -1
- package/dist/core/context/context-tool-result.d.ts +4 -0
- package/dist/core/context/context-tool-result.d.ts.map +1 -0
- package/dist/core/context/context-tool-result.js +15 -0
- package/dist/core/context/context-tool-result.js.map +1 -0
- package/dist/core/context/current-work-memory.d.ts.map +1 -1
- package/dist/core/context/current-work-memory.js.map +1 -1
- package/dist/core/context/file-store-memory-provider.d.ts.map +1 -1
- package/dist/core/context/file-store-memory-provider.js +7 -28
- package/dist/core/context/file-store-memory-provider.js.map +1 -1
- package/dist/core/context/local-memory-search.d.ts +11 -0
- package/dist/core/context/local-memory-search.d.ts.map +1 -0
- package/dist/core/context/local-memory-search.js +37 -0
- package/dist/core/context/local-memory-search.js.map +1 -0
- package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
- package/dist/core/context/long-term-memory-trigger.js.map +1 -1
- package/dist/core/context/memory-diagnostics.d.ts.map +1 -1
- package/dist/core/context/memory-diagnostics.js.map +1 -1
- package/dist/core/context/memory-index-store.d.ts.map +1 -1
- package/dist/core/context/memory-index-store.js.map +1 -1
- package/dist/core/context/memory-prompt-block.d.ts.map +1 -1
- package/dist/core/context/memory-prompt-block.js.map +1 -1
- package/dist/core/context/memory-prompt-budget.d.ts.map +1 -1
- package/dist/core/context/memory-prompt-budget.js.map +1 -1
- package/dist/core/context/memory-provider-contract.d.ts.map +1 -1
- package/dist/core/context/memory-provider-contract.js.map +1 -1
- package/dist/core/context/memory-retrieval.d.ts.map +1 -1
- package/dist/core/context/memory-retrieval.js.map +1 -1
- package/dist/core/context/memory-tier-composer.d.ts.map +1 -1
- package/dist/core/context/memory-tier-composer.js.map +1 -1
- package/dist/core/context/message-text.d.ts +7 -0
- package/dist/core/context/message-text.d.ts.map +1 -0
- package/dist/core/context/message-text.js +68 -0
- package/dist/core/context/message-text.js.map +1 -0
- package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
- package/dist/core/context/okf-memory-provider.js +4 -30
- package/dist/core/context/okf-memory-provider.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/policy-engine.d.ts.map +1 -1
- package/dist/core/context/policy-engine.js.map +1 -1
- package/dist/core/context/policy-types.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context/storage-authority.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +14 -21
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -3
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +64 -145
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/cost/session-usage.d.ts.map +1 -1
- package/dist/core/cost/session-usage.js.map +1 -1
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.js +2 -6
- package/dist/core/delegation/managed-lane-controller.js.map +1 -1
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/session-worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-action-journal.d.ts.map +1 -1
- package/dist/core/delegation/worker-action-journal.js +0 -4
- package/dist/core/delegation/worker-action-journal.js.map +1 -1
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +1 -0
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +13 -15
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +1 -4
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +0 -2
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +5 -14
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.js +5 -6
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +0 -3
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +4 -5
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-process-owner.d.ts.map +1 -1
- package/dist/core/delegation/worker-process-owner.js.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +1 -2
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +3 -4
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-resource-catalog.d.ts.map +1 -1
- package/dist/core/delegation/worker-resource-catalog.js.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.d.ts.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.js +1 -4
- package/dist/core/delegation/worker-resource-materializer.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +2 -4
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +6 -18
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -1
- package/dist/core/delegation/worker-task-label.js.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.d.ts.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +1 -4
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation.js +0 -2
- package/dist/core/delegation/worker-write-reservation.js.map +1 -1
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/doctor.d.ts +5 -5
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +16 -20
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +26 -7
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +21 -74
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +4 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/session-tree-foundations.d.mts +67 -0
- package/dist/core/export-html/session-tree-foundations.mjs +313 -0
- package/dist/core/export-html/template.css +14 -41
- package/dist/core/export-html/template.html +3 -1
- package/dist/core/export-html/template.js +26 -435
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts.map +1 -1
- package/dist/core/extension-import-authority.js.map +1 -1
- package/dist/core/extension-metadata.d.ts.map +1 -1
- package/dist/core/extension-metadata.js.map +1 -1
- package/dist/core/extensions/builtin.d.ts +17 -0
- package/dist/core/extensions/builtin.d.ts.map +1 -1
- package/dist/core/extensions/builtin.js +18 -54
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/extensions/entry-resolution.d.ts +3 -0
- package/dist/core/extensions/entry-resolution.d.ts.map +1 -0
- package/dist/core/extensions/entry-resolution.js +17 -0
- package/dist/core/extensions/entry-resolution.js.map +1 -0
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +76 -21
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +41 -112
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts.map +1 -1
- package/dist/core/extensions/storage.d.ts.map +1 -1
- package/dist/core/extensions/storage.js.map +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +2 -5
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +27 -33
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +0 -4
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +7 -5
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +0 -1
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
- package/dist/core/goals/compact-goal-context.js +2 -4
- package/dist/core/goals/compact-goal-context.js.map +1 -1
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
- package/dist/core/goals/goal-acceptance.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +1 -3
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
- package/dist/core/goals/goal-lifecycle.js.map +1 -1
- package/dist/core/goals/goal-record.d.ts.map +1 -1
- package/dist/core/goals/goal-record.js.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +15 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +27 -3
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +35 -51
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/natural-language-goal.d.ts +9 -0
- package/dist/core/goals/natural-language-goal.d.ts.map +1 -0
- package/dist/core/goals/natural-language-goal.js +23 -0
- package/dist/core/goals/natural-language-goal.js.map +1 -0
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/human-input-controller.d.ts.map +1 -1
- package/dist/core/human-input-controller.js +2 -3
- package/dist/core/human-input-controller.js.map +1 -1
- package/dist/core/human-input.d.ts.map +1 -1
- package/dist/core/human-input.js.map +1 -1
- package/dist/core/improvement-loop.d.ts.map +1 -1
- package/dist/core/improvement-loop.js +11 -11
- package/dist/core/improvement-loop.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -1
- package/dist/core/install-telemetry.js.map +1 -1
- package/dist/core/isolated-text-completion.d.ts +17 -0
- package/dist/core/isolated-text-completion.d.ts.map +1 -0
- package/dist/core/isolated-text-completion.js +15 -0
- package/dist/core/isolated-text-completion.js.map +1 -0
- package/dist/core/keybindings.d.ts +47 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +12 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +0 -2
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/reflection-engine.d.ts +1 -1
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +3 -0
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/learning/reflection-turn-analysis.d.ts +20 -0
- package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -0
- package/dist/core/learning/reflection-turn-analysis.js +136 -0
- package/dist/core/learning/reflection-turn-analysis.js.map +1 -0
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +0 -3
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +39 -0
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +41 -62
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/effectiveness-tracker.d.ts.map +1 -1
- package/dist/core/memory/effectiveness-tracker.js +4 -2
- package/dist/core/memory/effectiveness-tracker.js.map +1 -1
- package/dist/core/memory/memory-manager.d.ts.map +1 -1
- package/dist/core/memory/memory-manager.js +7 -7
- package/dist/core/memory/memory-manager.js.map +1 -1
- package/dist/core/memory/memory-provider.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +7 -0
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +48 -13
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts +47 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.js +50 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker.d.ts +2 -0
- package/dist/core/memory/providers/transcript-recall-worker.d.ts.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker.js +143 -0
- package/dist/core/memory/providers/transcript-recall-worker.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall.d.ts +24 -13
- package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
- package/dist/core/memory/providers/transcript-recall.js +143 -141
- package/dist/core/memory/providers/transcript-recall.js.map +1 -1
- package/dist/core/memory/providers/user-memory-archive.d.ts +39 -0
- package/dist/core/memory/providers/user-memory-archive.d.ts.map +1 -0
- package/dist/core/memory/providers/user-memory-archive.js +258 -0
- package/dist/core/memory/providers/user-memory-archive.js.map +1 -0
- package/dist/core/memory/transcript-index.d.ts.map +1 -1
- package/dist/core/memory/transcript-index.js +1 -1
- package/dist/core/memory/transcript-index.js.map +1 -1
- package/dist/core/memory-controller.d.ts +9 -0
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +57 -16
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-output-json.d.ts +10 -0
- package/dist/core/model-output-json.d.ts.map +1 -0
- package/dist/core/model-output-json.js +43 -0
- package/dist/core/model-output-json.js.map +1 -0
- package/dist/core/model-registry.d.ts +8 -8
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +29 -52
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/config-diagnostics.d.ts.map +1 -1
- package/dist/core/model-router/config-diagnostics.js.map +1 -1
- package/dist/core/model-router/executor-route.d.ts.map +1 -1
- package/dist/core/model-router/executor-route.js.map +1 -1
- package/dist/core/model-router/fitness-gate.d.ts.map +1 -1
- package/dist/core/model-router/fitness-gate.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.js +18 -36
- package/dist/core/model-router/route-judge.js.map +1 -1
- package/dist/core/model-router/session-buffer.d.ts.map +1 -1
- package/dist/core/model-router/session-buffer.js.map +1 -1
- package/dist/core/model-router/status.d.ts.map +1 -1
- package/dist/core/model-router/status.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -0
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +25 -56
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +10 -0
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js +0 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts.map +1 -1
- package/dist/core/model-tool-protocol.js.map +1 -1
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +0 -1
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/context-sizing.d.ts.map +1 -1
- package/dist/core/models/context-sizing.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +0 -1
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts.map +1 -1
- package/dist/core/models/host-state-store.js +1 -6
- package/dist/core/models/host-state-store.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +4 -19
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
- package/dist/core/models/llamacpp-runtime.js +32 -136
- package/dist/core/models/llamacpp-runtime.js.map +1 -1
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +82 -115
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts +12 -18
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +60 -204
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-endpoint.d.ts.map +1 -1
- package/dist/core/models/model-endpoint.js.map +1 -1
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +7 -3
- package/dist/core/models/needle-runtime.d.ts.map +1 -1
- package/dist/core/models/needle-runtime.js +16 -92
- package/dist/core/models/needle-runtime.js.map +1 -1
- package/dist/core/models/perf-profile.d.ts +1 -1
- package/dist/core/models/perf-profile.d.ts.map +1 -1
- package/dist/core/models/perf-profile.js +6 -13
- package/dist/core/models/perf-profile.js.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
- package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
- package/dist/core/models/runtime-arbiter.js +3 -15
- package/dist/core/models/runtime-arbiter.js.map +1 -1
- package/dist/core/models/runtime-process.d.ts +100 -0
- package/dist/core/models/runtime-process.d.ts.map +1 -0
- package/dist/core/models/runtime-process.js +183 -0
- package/dist/core/models/runtime-process.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -1
- package/dist/core/orchestration/agent-resume.js.map +1 -1
- package/dist/core/orchestration/attempt-usage.d.ts.map +1 -1
- package/dist/core/orchestration/attempt-usage.js.map +1 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +0 -14
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +0 -2
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +1 -14
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/model-binding.d.ts.map +1 -1
- package/dist/core/orchestration/model-binding.js.map +1 -1
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
- package/dist/core/orchestration/policy-compiler.js +0 -3
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -1
- package/dist/core/orchestration/policy-gate.js +0 -2
- package/dist/core/orchestration/policy-gate.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +1 -1
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/profile-store.d.ts.map +1 -1
- package/dist/core/orchestration/profile-store.js +0 -3
- package/dist/core/orchestration/profile-store.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +1 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +27 -42
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
- package/dist/core/orchestration/work-state-projection.js.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts +3 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +88 -353
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts.map +1 -1
- package/dist/core/process-identity.js.map +1 -1
- package/dist/core/process-liveness.d.ts +3 -0
- package/dist/core/process-liveness.d.ts.map +1 -0
- package/dist/core/process-liveness.js +17 -0
- package/dist/core/process-liveness.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -1
- package/dist/core/process-matrix/resume-launcher.js.map +1 -1
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +7 -8
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +1 -2
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/profile-resource-selection.d.ts.map +1 -1
- package/dist/core/profile-resource-selection.js +18 -59
- package/dist/core/profile-resource-selection.js.map +1 -1
- package/dist/core/prompt-markup.d.ts +3 -0
- package/dist/core/prompt-markup.d.ts.map +1 -0
- package/dist/core/prompt-markup.js +7 -0
- package/dist/core/prompt-markup.js.map +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +13 -39
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +22 -1
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +143 -25
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +2 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +4 -14
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts.map +1 -1
- package/dist/core/request-auth.js.map +1 -1
- package/dist/core/research/automata-provider.d.ts.map +1 -1
- package/dist/core/research/automata-provider.js.map +1 -1
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -1
- package/dist/core/research/lane-model-resolver.js +0 -1
- package/dist/core/research/lane-model-resolver.js.map +1 -1
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -1
- package/dist/core/research/model-fitness-controller.js +17 -33
- package/dist/core/research/model-fitness-controller.js.map +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -25
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts.map +1 -1
- package/dist/core/research/research-lane-controller.js +5 -10
- package/dist/core/research/research-lane-controller.js.map +1 -1
- package/dist/core/research/research-runner.d.ts +2 -4
- package/dist/core/research/research-runner.d.ts.map +1 -1
- package/dist/core/research/research-runner.js +17 -48
- package/dist/core/research/research-runner.js.map +1 -1
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/research/workspace-collector.d.ts.map +1 -1
- package/dist/core/research/workspace-collector.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-ignore.d.ts +6 -0
- package/dist/core/resource-ignore.d.ts.map +1 -0
- package/dist/core/resource-ignore.js +44 -0
- package/dist/core/resource-ignore.js.map +1 -0
- package/dist/core/resource-loader.d.ts +0 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +52 -187
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/resource-profile-blocks.d.ts +3 -1
- package/dist/core/resource-profile-blocks.d.ts.map +1 -1
- package/dist/core/resource-profile-blocks.js +8 -5
- package/dist/core/resource-profile-blocks.js.map +1 -1
- package/dist/core/resource-profile-equality.d.ts.map +1 -1
- package/dist/core/resource-profile-equality.js.map +1 -1
- package/dist/core/resource-traversal.d.ts +43 -0
- package/dist/core/resource-traversal.d.ts.map +1 -0
- package/dist/core/resource-traversal.js +84 -0
- package/dist/core/resource-traversal.js.map +1 -0
- package/dist/core/risk-classifier.d.ts.map +1 -1
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +4 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +25 -50
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +0 -1
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +101 -43
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -1
- package/dist/core/secrets/secret-dotenv.js +0 -1
- package/dist/core/secrets/secret-dotenv.js.map +1 -1
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -1
- package/dist/core/secrets/secret-vault-format.js +0 -1
- package/dist/core/secrets/secret-vault-format.js.map +1 -1
- package/dist/core/secrets/secret-vault.d.ts.map +1 -1
- package/dist/core/secrets/secret-vault.js +2 -10
- package/dist/core/secrets/secret-vault.js.map +1 -1
- package/dist/core/security/secret-text.d.ts.map +1 -1
- package/dist/core/security/secret-text.js.map +1 -1
- package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
- package/dist/core/security/untrusted-boundary.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +18 -50
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-artifact-bundle.d.ts.map +1 -1
- package/dist/core/session-artifact-bundle.js.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +0 -1
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-entry-index.d.ts +8 -0
- package/dist/core/session-entry-index.d.ts.map +1 -0
- package/dist/core/session-entry-index.js +16 -0
- package/dist/core/session-entry-index.js.map +1 -0
- package/dist/core/session-image-store.d.ts.map +1 -1
- package/dist/core/session-image-store.js +0 -3
- package/dist/core/session-image-store.js.map +1 -1
- package/dist/core/session-jsonl-writer.d.ts +3 -0
- package/dist/core/session-jsonl-writer.d.ts.map +1 -0
- package/dist/core/session-jsonl-writer.js +38 -0
- package/dist/core/session-jsonl-writer.js.map +1 -0
- package/dist/core/session-manager-factory.d.ts.map +1 -1
- package/dist/core/session-manager-factory.js.map +1 -1
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts.map +1 -1
- package/dist/core/session-snapshot.js.map +1 -1
- package/dist/core/session-supervision-runtime.d.ts.map +1 -1
- package/dist/core/session-supervision-runtime.js +1 -4
- package/dist/core/session-supervision-runtime.js.map +1 -1
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +0 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +64 -162
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skill-block.d.mts +8 -0
- package/dist/core/skill-block.mjs +52 -0
- package/dist/core/skill-discovery.d.ts +5 -0
- package/dist/core/skill-discovery.d.ts.map +1 -0
- package/dist/core/skill-discovery.js +34 -0
- package/dist/core/skill-discovery.js.map +1 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +23 -159
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/spawned-usage.d.ts +21 -0
- package/dist/core/spawned-usage.d.ts.map +1 -0
- package/dist/core/spawned-usage.js +29 -0
- package/dist/core/spawned-usage.js.map +1 -0
- package/dist/core/system-prompt-builder.d.ts +4 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +15 -8
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +53 -35
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-command.d.ts.map +1 -1
- package/dist/core/tasks/task-command.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -1
- package/dist/core/tasks/task-contract-monitor.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts.map +1 -1
- package/dist/core/tasks/task-projection.js.map +1 -1
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/text-preview.d.ts +4 -0
- package/dist/core/text-preview.d.ts.map +1 -0
- package/dist/core/text-preview.js +33 -0
- package/dist/core/text-preview.js.map +1 -0
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +86 -87
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +4 -1
- package/dist/core/tool-protocol-controller.d.ts.map +1 -1
- package/dist/core/tool-protocol-controller.js +19 -23
- package/dist/core/tool-protocol-controller.js.map +1 -1
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-log-worker.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-worker.js.map +1 -1
- package/dist/core/tool-recovery-logger.d.ts.map +1 -1
- package/dist/core/tool-recovery-logger.js +12 -24
- package/dist/core/tool-recovery-logger.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js +16 -22
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-repair-health.d.ts.map +1 -1
- package/dist/core/tool-repair-health.js.map +1 -1
- package/dist/core/tool-repair-settings.d.ts.map +1 -1
- package/dist/core/tool-repair-settings.js.map +1 -1
- package/dist/core/tool-selection/expected-utility.d.ts.map +1 -1
- package/dist/core/tool-selection/expected-utility.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts.map +1 -1
- package/dist/core/tool-selection/promotion.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +2 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +49 -7
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-phase-timing.d.ts +19 -0
- package/dist/core/tool-selection/tool-phase-timing.d.ts.map +1 -0
- package/dist/core/tool-selection/tool-phase-timing.js +63 -0
- package/dist/core/tool-selection/tool-phase-timing.js.map +1 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts +2 -5
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +50 -30
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.d.ts +16 -0
- package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.js +21 -0
- package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
- package/dist/core/toolkit/script-registry.d.ts.map +1 -1
- package/dist/core/toolkit/script-registry.js.map +1 -1
- package/dist/core/toolkit/script-runner.d.ts.map +1 -1
- package/dist/core/toolkit/script-runner.js.map +1 -1
- package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
- package/dist/core/tools/artifact-retrieve.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +2 -3
- package/dist/core/tools/ask-question.d.ts.map +1 -1
- package/dist/core/tools/ask-question.js +14 -40
- package/dist/core/tools/ask-question.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +83 -30
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/context-scout.d.ts.map +1 -1
- package/dist/core/tools/context-scout.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +9 -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 +6 -6
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/fff-search-backend.d.ts +19 -0
- package/dist/core/tools/fff-search-backend.d.ts.map +1 -1
- package/dist/core/tools/fff-search-backend.js +28 -2
- package/dist/core/tools/fff-search-backend.js.map +1 -1
- package/dist/core/tools/file-encoding-policy.d.ts.map +1 -1
- package/dist/core/tools/file-encoding-policy.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +44 -108
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +7 -7
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +42 -102
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +20 -36
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +5 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +5 -5
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +2 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +24 -36
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/persistent-process-coordinator.d.ts +31 -0
- package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -0
- package/dist/core/tools/persistent-process-coordinator.js +123 -0
- package/dist/core/tools/persistent-process-coordinator.js.map +1 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +14 -13
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +29 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +31 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/run-process.d.ts.map +1 -1
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
- package/dist/core/tools/run-toolkit-script.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts +10 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -1
- package/dist/core/tools/search-command-guard.js +118 -31
- package/dist/core/tools/search-command-guard.js.map +1 -1
- package/dist/core/tools/search-router.d.ts.map +1 -1
- package/dist/core/tools/search-router.js.map +1 -1
- package/dist/core/tools/search-tool-runtime.d.ts +19 -0
- package/dist/core/tools/search-tool-runtime.d.ts.map +1 -0
- package/dist/core/tools/search-tool-runtime.js +12 -0
- package/dist/core/tools/search-tool-runtime.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
- package/dist/core/tools/shell-command-parser.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +4 -1
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-execution-session.d.ts +4 -0
- package/dist/core/tools/shell-execution-session.d.ts.map +1 -0
- package/dist/core/tools/shell-execution-session.js +11 -0
- package/dist/core/tools/shell-execution-session.js.map +1 -0
- package/dist/core/tools/shell-output-projection.d.ts +49 -0
- package/dist/core/tools/shell-output-projection.d.ts.map +1 -0
- package/dist/core/tools/shell-output-projection.js +381 -0
- package/dist/core/tools/shell-output-projection.js.map +1 -0
- package/dist/core/tools/shell-session.d.ts +2 -13
- package/dist/core/tools/shell-session.d.ts.map +1 -1
- package/dist/core/tools/shell-session.js +36 -136
- package/dist/core/tools/shell-session.js.map +1 -1
- package/dist/core/tools/skill-audit.d.ts.map +1 -1
- package/dist/core/tools/skill-audit.js.map +1 -1
- package/dist/core/tools/skillify.d.ts.map +1 -1
- package/dist/core/tools/skillify.js.map +1 -1
- package/dist/core/tools/task-steps.d.ts +8 -8
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +17 -18
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-task.d.ts +23 -0
- package/dist/core/tools/tool-task.d.ts.map +1 -0
- package/dist/core/tools/tool-task.js +93 -0
- package/dist/core/tools/tool-task.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +17 -11
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +339 -117
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-state.js.map +1 -1
- package/dist/core/tools/worktree-sync.d.ts.map +1 -1
- package/dist/core/tools/worktree-sync.js +8 -12
- package/dist/core/tools/worktree-sync.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +0 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +7 -40
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +19 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +50 -15
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-file.d.ts.map +1 -1
- package/dist/core/util/bounded-file.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -1
- package/dist/core/util/bounded-jsonl.js +2 -9
- package/dist/core/util/bounded-jsonl.js.map +1 -1
- package/dist/core/util/bounded-value.d.ts.map +1 -1
- package/dist/core/util/bounded-value.js.map +1 -1
- package/dist/core/util/json-size.d.ts +3 -0
- package/dist/core/util/json-size.d.ts.map +1 -0
- package/dist/core/util/json-size.js +95 -0
- package/dist/core/util/json-size.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -1
- package/dist/core/util/minimatch-cache.js.map +1 -1
- package/dist/core/util/value-guards.d.ts.map +1 -1
- package/dist/core/util/value-guards.js.map +1 -1
- package/dist/core/worktree-sync/codes.d.ts.map +1 -1
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -1
- package/dist/core/worktree-sync/git-engine.js +20 -36
- package/dist/core/worktree-sync/git-engine.js.map +1 -1
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
- package/dist/core/worktree-sync/lane-gate.js +1 -4
- package/dist/core/worktree-sync/lane-gate.js.map +1 -1
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -1
- package/dist/core/worktree-sync/runtime.js.map +1 -1
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -1
- package/dist/core/worktree-sync/watcher.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +10 -32
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +6 -19
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +3 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +96 -132
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +1 -31
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +86 -307
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -1
- package/dist/modes/interactive/autocomplete-provider.js.map +1 -1
- package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -1
- package/dist/modes/interactive/autonomy-commands.js +2 -8
- package/dist/modes/interactive/autonomy-commands.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +5 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +17 -0
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/compaction-queue.d.ts.map +1 -1
- package/dist/modes/interactive/compaction-queue.js +13 -18
- package/dist/modes/interactive/compaction-queue.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +6 -10
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts +1 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +10 -21
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +1 -6
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +4 -9
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +0 -3
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +3 -8
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +13 -35
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +3 -8
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +14 -36
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +20 -43
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +0 -5
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +4 -8
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -6
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +6 -8
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +0 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/expandable-markdown-message.d.ts +21 -0
- package/dist/modes/interactive/components/expandable-markdown-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-markdown-message.js +48 -0
- package/dist/modes/interactive/components/expandable-markdown-message.js.map +1 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/expandable-text.js +0 -2
- package/dist/modes/interactive/components/expandable-text.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +2 -8
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +5 -20
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.js +0 -1
- package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -5
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +4 -10
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +21 -44
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/model-suggestion-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-suggestion-selector.js +0 -1
- package/dist/modes/interactive/components/model-suggestion-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +16 -32
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts +3 -4
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +34 -93
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/components/profile-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-selector.js +0 -1
- package/dist/modes/interactive/components/profile-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +3 -4
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +34 -79
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/selector-list.d.ts +63 -0
- package/dist/modes/interactive/components/selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/selector-list.js +186 -0
- package/dist/modes/interactive/components/selector-list.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +34 -59
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +40 -138
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts +2 -4
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +9 -28
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +3 -8
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +12 -40
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts +2 -5
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +11 -37
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +2 -4
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +9 -31
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -28
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +2 -3
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-panel-registry.js +5 -3
- package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -1
- package/dist/modes/interactive/components/tool-title.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-title.js +0 -4
- package/dist/modes/interactive/components/tool-title.js.map +1 -1
- package/dist/modes/interactive/components/transcript-pager.d.ts +26 -0
- package/dist/modes/interactive/components/transcript-pager.d.ts.map +1 -0
- package/dist/modes/interactive/components/transcript-pager.js +81 -0
- package/dist/modes/interactive/components/transcript-pager.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -12
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +42 -402
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +4 -16
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.js +2 -10
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +3 -6
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +0 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -1
- package/dist/modes/interactive/editor-overlay-host.js +0 -3
- package/dist/modes/interactive/editor-overlay-host.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +2 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +51 -72
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -15
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +23 -16
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +126 -207
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-selection-prompts.d.ts +20 -0
- package/dist/modes/interactive/interactive-selection-prompts.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-selection-prompts.js +43 -0
- package/dist/modes/interactive/interactive-selection-prompts.js.map +1 -0
- package/dist/modes/interactive/key-handlers.d.ts +2 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +4 -2
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +4 -9
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/model-fitness-presentation.d.ts +21 -0
- package/dist/modes/interactive/model-fitness-presentation.d.ts.map +1 -0
- package/dist/modes/interactive/model-fitness-presentation.js +13 -0
- package/dist/modes/interactive/model-fitness-presentation.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts +2 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +79 -171
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts +2 -0
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +12 -6
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +6 -23
- package/dist/modes/interactive/resource-shell-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 +21 -25
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
- package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/signal-lifecycle.js.map +1 -1
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +12 -8
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +10 -76
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -1
- package/dist/modes/interactive/usage-commands.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +5 -22
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +1 -1
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -8
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +5 -20
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/termination-signals.d.ts +4 -0
- package/dist/modes/termination-signals.d.ts.map +1 -0
- package/dist/modes/termination-signals.js +21 -0
- package/dist/modes/termination-signals.js.map +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi-colors.d.ts +5 -0
- package/dist/utils/ansi-colors.d.ts.map +1 -0
- package/dist/utils/ansi-colors.js +38 -0
- package/dist/utils/ansi-colors.js.map +1 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/deprecation.d.ts.map +1 -1
- package/dist/utils/deprecation.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/external-editor-command.d.ts.map +1 -1
- package/dist/utils/external-editor-command.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +20 -28
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts.map +1 -1
- package/dist/utils/html.d.ts.map +1 -1
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.d.ts.map +1 -1
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/process-memory.d.ts.map +1 -1
- package/dist/utils/process-memory.js.map +1 -1
- package/dist/utils/safe-write-stream.d.ts.map +1 -1
- package/dist/utils/safe-write-stream.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js +2 -15
- package/dist/utils/sleep.js.map +1 -1
- package/dist/utils/stdin-events.d.ts +8 -0
- package/dist/utils/stdin-events.d.ts.map +1 -0
- package/dist/utils/stdin-events.js +19 -0
- package/dist/utils/stdin-events.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +20 -13
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +6 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +59 -2
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/windows-self-update.d.ts.map +1 -1
- package/dist/utils/windows-self-update.js.map +1 -1
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/compaction.md +11 -3
- package/docs/development.md +1 -1
- package/docs/sessions.md +6 -0
- package/docs/settings.md +1 -1
- package/docs/windows.md +28 -3
- package/docs/work-directory.md +10 -2
- 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 +27 -27
- package/package.json +11 -11
- package/dist/utils/streaming-lines.d.ts +0 -20
- package/dist/utils/streaming-lines.d.ts.map +0 -1
- package/dist/utils/streaming-lines.js +0 -79
- package/dist/utils/streaming-lines.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scout-controller.d.ts","sourceRoot":"","sources":["../../src/core/scout-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,eAAO,MAAM,mBAAmB,65BAewC,CAAC;AAEzE,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,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,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC9C,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC,CAuB7D","sourcesContent":["import { Agent, type AgentTool, type StreamFn } from \"@caupulican/pi-agent-core\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport { registerInFlightWork } from \"./reload-blockers.ts\";\n\nexport const SCOUT_SYSTEM_PROMPT = `You are a repository scout. You explore a codebase with read-only tools and return compact evidence. You do NOT solve tasks, write code, or modify anything.\n\nTOOLS: read (file contents), grep (search file contents), find (locate files by glob/name).\n- Issue INDEPENDENT tool calls in parallel in the same turn whenever possible.\n- Prefer grep/find to narrow, then read only the decisive regions.\n\nOUTPUT CONTRACT: when you have enough evidence (or hit your turn budget), reply with:\n<final_answer>\n<one-to-three-sentence summary of what you found>\npath/to/file.ts:START-END\npath/to/other.ts:START-END\n</final_answer>\n- Every path MUST be one you actually observed via a tool result this run.\n- Line ranges point at the decisive code, not whole files.\n- If you found nothing relevant, say so inside <final_answer> with zero citations.\nTurn budget: {MAX_TURNS} turns. Be fast; be precise; cite, don't paste.`;\n\nexport interface ScoutCitation {\n\tpath: string;\n\tstart: number;\n\tend: number;\n\tvalid: boolean;\n}\n\nexport interface ScoutRunResult {\n\tsummary: string;\n\tcitations: ScoutCitation[];\n\tdroppedCitations: number;\n\tunreliable: boolean;\n\ttruncated: boolean;\n\tturnsUsed: number;\n\tfailure?: string;\n}\n\nexport interface ScoutControllerDeps {\n\tresolveScoutModel(): Promise<\n\t\t{ model: Model<any>; apiKey?: string; headers?: Record<string, string> } | { failure: string }\n\t>;\n\tgetCwd(): string;\n\tbuildReadOnlyTools(cwd: string): AgentTool<any>[];\n\tstreamFn?: StreamFn;\n\tfileExists(path: string): boolean;\n\tcountLines(path: string): number | undefined;\n\tonEvent?(event: { type: \"scout_turn\" | \"scout_end\"; detail: string }): void;\n\tsignal?: AbortSignal;\n\t/** Registers this scout's own Agent run in the reload-gate quiesce registry while it drives\n\t * turns, so `/reload`/profile-switch/live extension load-unload-reconcile wait it out. Optional —\n\t * a caller that hasn't wired an agent dir through (e.g. an existing test construction) sees no\n\t * behavior change; the scout simply stays invisible to the reload gate, matching its behavior\n\t * before this registration was added. */\n\tgetAgentDir?(): string;\n}\n\nconst MAX_TURNS_DEFAULT = 8;\nconst MAX_TURNS_HARD_CAP = 12;\nconst MAX_OUTPUT_TOKENS = 30_000;\nconst READ_ONLY_TOOL_NAMES = new Set([\"read\", \"grep\", \"find\"]);\n\nexport class ScoutController {\n\tprivate readonly deps: ScoutControllerDeps;\n\n\tconstructor(deps: ScoutControllerDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\tasync run(query: string, maxTurns = MAX_TURNS_DEFAULT): Promise<ScoutRunResult> {\n\t\tconst turnLimit = clampTurns(maxTurns);\n\t\tconst unavailable = emptyResult();\n\t\tif (this.deps.signal?.aborted) {\n\t\t\treturn { ...unavailable, failure: \"aborted\" };\n\t\t}\n\n\t\tlet modelResolution: Awaited<ReturnType<ScoutControllerDeps[\"resolveScoutModel\"]>>;\n\t\ttry {\n\t\t\tmodelResolution = await this.deps.resolveScoutModel();\n\t\t} catch (error) {\n\t\t\treturn { ...unavailable, failure: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t\tif (\"failure\" in modelResolution) {\n\t\t\treturn { ...unavailable, failure: modelResolution.failure };\n\t\t}\n\n\t\t// Registered while this scout's own Agent drives turns, so the reload gate waits it out.\n\t\t// registerInFlightWork is a pure sync map op (cannot throw), so wrapping everything from here\n\t\t// through the end in try/finally guarantees deregistration on every exit path. Optional dep —\n\t\t// a caller that hasn't wired an agent dir through stays invisible to the gate, matching the\n\t\t// behavior before this registration was added.\n\t\tconst deregisterInFlight = this.deps.getAgentDir\n\t\t\t? registerInFlightWork(this.deps.getAgentDir(), \"scout\", query.slice(0, 80))\n\t\t\t: undefined;\n\t\ttry {\n\t\t\tlet turnsUsed = 0;\n\t\t\tlet truncated = false;\n\t\t\tlet lastAssistantText = \"\";\n\t\t\tlet outputTokens = 0;\n\t\t\tconst agent = new Agent({\n\t\t\t\tinitialState: {\n\t\t\t\t\tmodel: modelResolution.model,\n\t\t\t\t\tsystemPrompt: SCOUT_SYSTEM_PROMPT.replace(\"{MAX_TURNS}\", String(turnLimit)),\n\t\t\t\t\ttools: this.deps\n\t\t\t\t\t\t.buildReadOnlyTools(this.deps.getCwd())\n\t\t\t\t\t\t.filter((tool) => READ_ONLY_TOOL_NAMES.has(tool.name)),\n\t\t\t\t},\n\t\t\t\tstreamFn: this.deps.streamFn,\n\t\t\t\tgetApiKey: () => modelResolution.apiKey,\n\t\t\t\tmaxStallTurns: turnLimit,\n\t\t\t});\n\n\t\t\tconst unsubscribe = agent.subscribe((event) => {\n\t\t\t\tif (event.type !== \"message_end\" || event.message.role !== \"assistant\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tturnsUsed += 1;\n\t\t\t\tlastAssistantText = assistantText(event.message);\n\t\t\t\toutputTokens += getScoutOutputTokenCount(event.message);\n\t\t\t\tthis.deps.onEvent?.({ type: \"scout_turn\", detail: `turn ${turnsUsed}` });\n\t\t\t\tif (hasFinalAnswer(lastAssistantText)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (turnsUsed >= turnLimit || outputTokens >= MAX_OUTPUT_TOKENS) {\n\t\t\t\t\ttruncated = true;\n\t\t\t\t\tagent.abort();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst abortScout = (): void => {\n\t\t\t\ttruncated = true;\n\t\t\t\tagent.abort();\n\t\t\t};\n\t\t\tthis.deps.signal?.addEventListener(\"abort\", abortScout, { once: true });\n\t\t\tlet runFailure: string | undefined;\n\t\t\ttry {\n\t\t\t\tawait agent.prompt(query);\n\t\t\t} catch (error) {\n\t\t\t\tif (!truncated && !this.deps.signal?.aborted) {\n\t\t\t\t\trunFailure = error instanceof Error ? error.message : String(error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tunsubscribe();\n\t\t\t\tthis.deps.signal?.removeEventListener(\"abort\", abortScout);\n\t\t\t}\n\n\t\t\tconst result = parseScoutAnswer(\n\t\t\t\tlastAssistantText,\n\t\t\t\t(path) => this.deps.fileExists(path),\n\t\t\t\t(path) => this.deps.countLines(path),\n\t\t\t);\n\t\t\tconst finalResult = {\n\t\t\t\t...result,\n\t\t\t\ttruncated: truncated || !hasFinalAnswer(lastAssistantText),\n\t\t\t\tturnsUsed,\n\t\t\t\tfailure: this.deps.signal?.aborted ? \"aborted\" : runFailure,\n\t\t\t};\n\t\t\tthis.deps.onEvent?.({ type: \"scout_end\", detail: finalResult.failure ?? \"ok\" });\n\t\t\treturn finalResult;\n\t\t} finally {\n\t\t\tderegisterInFlight?.();\n\t\t}\n\t}\n}\n\nexport function getScoutOutputTokenCount(message: { usage?: { output?: number } }): number {\n\treturn message.usage?.output ?? 0;\n}\n\nexport function parseScoutAnswer(\n\ttext: string,\n\tfileExists: (path: string) => boolean,\n\tcountLines: (path: string) => number | undefined,\n): Omit<ScoutRunResult, \"truncated\" | \"turnsUsed\" | \"failure\"> {\n\tconst finalAnswer = /<final_answer>([\\s\\S]*?)<\\/final_answer>/i.exec(text)?.[1] ?? text;\n\tconst summaryLines: string[] = [];\n\tconst citations: ScoutCitation[] = [];\n\n\tfor (const rawLine of finalAnswer.split(/\\r?\\n/)) {\n\t\tconst line = rawLine.trim();\n\t\tif (!line) continue;\n\t\tconst citation = parseCitationLine(line, fileExists, countLines);\n\t\tif (citation) {\n\t\t\tcitations.push(citation);\n\t\t\tcontinue;\n\t\t}\n\t\tsummaryLines.push(line);\n\t}\n\n\tconst droppedCitations = citations.filter((citation) => !citation.valid).length;\n\treturn {\n\t\tsummary: summaryLines.join(\"\\n\"),\n\t\tcitations,\n\t\tdroppedCitations,\n\t\tunreliable: citations.length > 0 && droppedCitations / citations.length > 0.5,\n\t};\n}\n\nfunction parseCitationLine(\n\tline: string,\n\tfileExists: (path: string) => boolean,\n\tcountLines: (path: string) => number | undefined,\n): ScoutCitation | undefined {\n\tconst match = /^(.+?):(\\d+)(?:-(\\d+))?$/.exec(line);\n\tif (!match) return undefined;\n\tconst path = match[1].trim();\n\tconst start = Number.parseInt(match[2], 10);\n\tconst end = Number.parseInt(match[3] ?? match[2], 10);\n\tconst lineCount = countLines(path);\n\tconst valid =\n\t\tfileExists(path) &&\n\t\tNumber.isFinite(start) &&\n\t\tNumber.isFinite(end) &&\n\t\tstart >= 1 &&\n\t\tend >= start &&\n\t\t(lineCount === undefined || end <= lineCount);\n\treturn { path, start, end, valid };\n}\n\nfunction clampTurns(maxTurns: number): number {\n\tif (!Number.isFinite(maxTurns)) return MAX_TURNS_DEFAULT;\n\treturn Math.min(MAX_TURNS_HARD_CAP, Math.max(1, Math.trunc(maxTurns)));\n}\n\nfunction emptyResult(): ScoutRunResult {\n\treturn { summary: \"\", citations: [], droppedCitations: 0, unreliable: false, truncated: false, turnsUsed: 0 };\n}\n\nfunction hasFinalAnswer(text: string): boolean {\n\treturn /<final_answer>[\\s\\S]*?<\\/final_answer>/i.test(text);\n}\n\nfunction assistantText(message: { content: unknown }): string {\n\tif (!Array.isArray(message.content)) return \"\";\n\treturn message.content\n\t\t.filter((content): content is { type: \"text\"; text: string } =>\n\t\t\tBoolean(\n\t\t\t\tcontent &&\n\t\t\t\t\ttypeof content === \"object\" &&\n\t\t\t\t\t(content as { type?: unknown }).type === \"text\" &&\n\t\t\t\t\ttypeof (content as { text?: unknown }).text === \"string\",\n\t\t\t),\n\t\t)\n\t\t.map((content) => content.text)\n\t\t.join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scout-controller.d.ts","sourceRoot":"","sources":["../../src/core/scout-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,eAAO,MAAM,mBAAmB,65B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KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAAA,CACvE;AAED,SAAS,WAAW,GAAmB;IACtC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;AAAA,CAC9G;AAED,SAAS,cAAc,CAAC,IAAY,EAAW;IAC9C,OAAO,yCAAyC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CAC5D;AAED,SAAS,aAAa,CAAC,OAA6B,EAAU;IAC7D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IAC/C,OAAO,OAAO,CAAC,OAAO;SACpB,MAAM,CAAC,CAAC,OAAO,EAA6C,EAAE,CAC9D,OAAO,CACN,OAAO;QACN,OAAO,OAAO,KAAK,QAAQ;QAC1B,OAA8B,CAAC,IAAI,KAAK,MAAM;QAC/C,OAAQ,OAA8B,CAAC,IAAI,KAAK,QAAQ,CACzD,CACD;SACA,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;SAC9B,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACb","sourcesContent":["import { Agent, type AgentTool, type StreamFn } from \"@caupulican/pi-agent-core\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport { registerInFlightWork } from \"./reload-blockers.ts\";\n\nexport const SCOUT_SYSTEM_PROMPT = `You are a repository scout. You explore a codebase with read-only tools and return compact evidence. You do NOT solve tasks, write code, or modify anything.\n\nTOOLS: read (file contents), grep (search file contents), find (locate files by glob/name).\n- Issue INDEPENDENT tool calls in parallel in the same turn whenever possible.\n- Prefer grep/find to narrow, then read only the decisive regions.\n\nOUTPUT CONTRACT: when you have enough evidence (or hit your turn budget), reply with:\n<final_answer>\n<one-to-three-sentence summary of what you found>\npath/to/file.ts:START-END\npath/to/other.ts:START-END\n</final_answer>\n- Every path MUST be one you actually observed via a tool result this run.\n- Line ranges point at the decisive code, not whole files.\n- If you found nothing relevant, say so inside <final_answer> with zero citations.\nTurn budget: {MAX_TURNS} turns. Be fast; be precise; cite, don't paste.`;\n\nexport interface ScoutCitation {\n\tpath: string;\n\tstart: number;\n\tend: number;\n\tvalid: boolean;\n}\n\nexport interface ScoutRunResult {\n\tsummary: string;\n\tcitations: ScoutCitation[];\n\tdroppedCitations: number;\n\tunreliable: boolean;\n\ttruncated: boolean;\n\tturnsUsed: number;\n\tfailure?: string;\n}\n\nexport interface ScoutControllerDeps {\n\tresolveScoutModel(): Promise<\n\t\t{ model: Model<any>; apiKey?: string; headers?: Record<string, string> } | { failure: string }\n\t>;\n\tgetCwd(): string;\n\tbuildReadOnlyTools(cwd: string): AgentTool<any>[];\n\tstreamFn?: StreamFn;\n\tfileExists(path: string): boolean;\n\tcountLines(path: string): number | undefined;\n\tonEvent?(event: { type: \"scout_turn\" | \"scout_end\"; detail: string }): void;\n\tsignal?: AbortSignal;\n\t/** Registers this scout's own Agent run in the reload-gate quiesce registry while it drives\n\t * turns, so `/reload`/profile-switch/live extension load-unload-reconcile wait it out. Optional —\n\t * a caller that hasn't wired an agent dir through (e.g. an existing test construction) sees no\n\t * behavior change; the scout simply stays invisible to the reload gate, matching its behavior\n\t * before this registration was added. */\n\tgetAgentDir?(): string;\n}\n\nconst MAX_TURNS_DEFAULT = 8;\nconst MAX_TURNS_HARD_CAP = 12;\nconst MAX_OUTPUT_TOKENS = 30_000;\nconst READ_ONLY_TOOL_NAMES = new Set([\"read\", \"grep\", \"find\"]);\n\nexport class ScoutController {\n\tprivate readonly deps: ScoutControllerDeps;\n\n\tconstructor(deps: ScoutControllerDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\tasync run(query: string, maxTurns = MAX_TURNS_DEFAULT): Promise<ScoutRunResult> {\n\t\tconst turnLimit = clampTurns(maxTurns);\n\t\tconst unavailable = emptyResult();\n\t\tif (this.deps.signal?.aborted) {\n\t\t\treturn { ...unavailable, failure: \"aborted\" };\n\t\t}\n\n\t\tlet modelResolution: Awaited<ReturnType<ScoutControllerDeps[\"resolveScoutModel\"]>>;\n\t\ttry {\n\t\t\tmodelResolution = await this.deps.resolveScoutModel();\n\t\t} catch (error) {\n\t\t\treturn { ...unavailable, failure: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t\tif (\"failure\" in modelResolution) {\n\t\t\treturn { ...unavailable, failure: modelResolution.failure };\n\t\t}\n\n\t\t// Registered while this scout's own Agent drives turns, so the reload gate waits it out.\n\t\t// registerInFlightWork is a pure sync map op (cannot throw), so wrapping everything from here\n\t\t// through the end in try/finally guarantees deregistration on every exit path. Optional dep —\n\t\t// a caller that hasn't wired an agent dir through stays invisible to the gate, matching the\n\t\t// behavior before this registration was added.\n\t\tconst deregisterInFlight = this.deps.getAgentDir\n\t\t\t? registerInFlightWork(this.deps.getAgentDir(), \"scout\", query.slice(0, 80))\n\t\t\t: undefined;\n\t\ttry {\n\t\t\tlet turnsUsed = 0;\n\t\t\tlet truncated = false;\n\t\t\tlet lastAssistantText = \"\";\n\t\t\tlet outputTokens = 0;\n\t\t\tconst agent = new Agent({\n\t\t\t\tinitialState: {\n\t\t\t\t\tmodel: modelResolution.model,\n\t\t\t\t\tsystemPrompt: SCOUT_SYSTEM_PROMPT.replace(\"{MAX_TURNS}\", String(turnLimit)),\n\t\t\t\t\ttools: this.deps\n\t\t\t\t\t\t.buildReadOnlyTools(this.deps.getCwd())\n\t\t\t\t\t\t.filter((tool) => READ_ONLY_TOOL_NAMES.has(tool.name)),\n\t\t\t\t},\n\t\t\t\tstreamFn: this.deps.streamFn,\n\t\t\t\tgetApiKey: () => modelResolution.apiKey,\n\t\t\t\tmaxStallTurns: turnLimit,\n\t\t\t});\n\n\t\t\tconst unsubscribe = agent.subscribe((event) => {\n\t\t\t\tif (event.type !== \"message_end\" || event.message.role !== \"assistant\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tturnsUsed += 1;\n\t\t\t\tlastAssistantText = assistantText(event.message);\n\t\t\t\toutputTokens += getScoutOutputTokenCount(event.message);\n\t\t\t\tthis.deps.onEvent?.({ type: \"scout_turn\", detail: `turn ${turnsUsed}` });\n\t\t\t\tif (hasFinalAnswer(lastAssistantText)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (turnsUsed >= turnLimit || outputTokens >= MAX_OUTPUT_TOKENS) {\n\t\t\t\t\ttruncated = true;\n\t\t\t\t\tagent.abort();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst abortScout = (): void => {\n\t\t\t\ttruncated = true;\n\t\t\t\tagent.abort();\n\t\t\t};\n\t\t\tthis.deps.signal?.addEventListener(\"abort\", abortScout, { once: true });\n\t\t\tlet runFailure: string | undefined;\n\t\t\ttry {\n\t\t\t\tawait agent.prompt(query);\n\t\t\t} catch (error) {\n\t\t\t\tif (!truncated && !this.deps.signal?.aborted) {\n\t\t\t\t\trunFailure = error instanceof Error ? error.message : String(error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tunsubscribe();\n\t\t\t\tthis.deps.signal?.removeEventListener(\"abort\", abortScout);\n\t\t\t}\n\n\t\t\tconst result = parseScoutAnswer(\n\t\t\t\tlastAssistantText,\n\t\t\t\t(path) => this.deps.fileExists(path),\n\t\t\t\t(path) => this.deps.countLines(path),\n\t\t\t);\n\t\t\tconst finalResult = {\n\t\t\t\t...result,\n\t\t\t\ttruncated: truncated || !hasFinalAnswer(lastAssistantText),\n\t\t\t\tturnsUsed,\n\t\t\t\tfailure: this.deps.signal?.aborted ? \"aborted\" : runFailure,\n\t\t\t};\n\t\t\tthis.deps.onEvent?.({ type: \"scout_end\", detail: finalResult.failure ?? \"ok\" });\n\t\t\treturn finalResult;\n\t\t} finally {\n\t\t\tderegisterInFlight?.();\n\t\t}\n\t}\n}\n\nexport function getScoutOutputTokenCount(message: { usage?: { output?: number } }): number {\n\treturn message.usage?.output ?? 0;\n}\n\nexport function parseScoutAnswer(\n\ttext: string,\n\tfileExists: (path: string) => boolean,\n\tcountLines: (path: string) => number | undefined,\n): Omit<ScoutRunResult, \"truncated\" | \"turnsUsed\" | \"failure\"> {\n\tconst finalAnswer = /<final_answer>([\\s\\S]*?)<\\/final_answer>/i.exec(text)?.[1] ?? text;\n\tconst summaryLines: string[] = [];\n\tconst citations: ScoutCitation[] = [];\n\n\tfor (const rawLine of finalAnswer.split(/\\r?\\n/)) {\n\t\tconst line = rawLine.trim();\n\t\tif (!line) continue;\n\t\tconst citation = parseCitationLine(line, fileExists, countLines);\n\t\tif (citation) {\n\t\t\tcitations.push(citation);\n\t\t\tcontinue;\n\t\t}\n\t\tsummaryLines.push(line);\n\t}\n\n\tconst droppedCitations = citations.filter((citation) => !citation.valid).length;\n\treturn {\n\t\tsummary: summaryLines.join(\"\\n\"),\n\t\tcitations,\n\t\tdroppedCitations,\n\t\tunreliable: citations.length > 0 && droppedCitations / citations.length > 0.5,\n\t};\n}\n\nfunction parseCitationLine(\n\tline: string,\n\tfileExists: (path: string) => boolean,\n\tcountLines: (path: string) => number | undefined,\n): ScoutCitation | undefined {\n\tconst match = /^(.+?):(\\d+)(?:-(\\d+))?$/.exec(line);\n\tif (!match) return undefined;\n\tconst path = match[1].trim();\n\tconst start = Number.parseInt(match[2], 10);\n\tconst end = Number.parseInt(match[3] ?? match[2], 10);\n\tconst lineCount = countLines(path);\n\tconst valid =\n\t\tfileExists(path) &&\n\t\tNumber.isFinite(start) &&\n\t\tNumber.isFinite(end) &&\n\t\tstart >= 1 &&\n\t\tend >= start &&\n\t\t(lineCount === undefined || end <= lineCount);\n\treturn { path, start, end, valid };\n}\n\nfunction clampTurns(maxTurns: number): number {\n\tif (!Number.isFinite(maxTurns)) return MAX_TURNS_DEFAULT;\n\treturn Math.min(MAX_TURNS_HARD_CAP, Math.max(1, Math.trunc(maxTurns)));\n}\n\nfunction emptyResult(): ScoutRunResult {\n\treturn { summary: \"\", citations: [], droppedCitations: 0, unreliable: false, truncated: false, turnsUsed: 0 };\n}\n\nfunction hasFinalAnswer(text: string): boolean {\n\treturn /<final_answer>[\\s\\S]*?<\\/final_answer>/i.test(text);\n}\n\nfunction assistantText(message: { content: unknown }): string {\n\tif (!Array.isArray(message.content)) return \"\";\n\treturn message.content\n\t\t.filter((content): content is { type: \"text\"; text: string } =>\n\t\t\tBoolean(\n\t\t\t\tcontent &&\n\t\t\t\t\ttypeof content === \"object\" &&\n\t\t\t\t\t(content as { type?: unknown }).type === \"text\" &&\n\t\t\t\t\ttypeof (content as { text?: unknown }).text === \"string\",\n\t\t\t),\n\t\t)\n\t\t.map((content) => content.text)\n\t\t.join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scout-controller.js","sourceRoot":"","sources":["../../src/core/scout-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAiC,MAAM,2BAA2B,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;wEAeqC,CAAC;AAsCzE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/D,MAAM,OAAO,eAAe;IAG3B,YAAY,IAAyB;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,QAAQ,GAAG,iBAAiB;QACpD,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QACvC,MAAM,WAAW,GAAG,WAAW,EAAE,CAAC;QAClC,IAAI,IAAI,CA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AAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;AAC/G,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IACnC,OAAO,yCAAyC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,aAAa,CAAC,OAA6B;IACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IAC/C,OAAO,OAAO,CAAC,OAAO;SACpB,MAAM,CAAC,CAAC,OAAO,EAA6C,EAAE,CAC9D,OAAO,CACN,OAAO;QACN,OAAO,OAAO,KAAK,QAAQ;QAC1B,OAA8B,CAAC,IAAI,KAAK,MAAM;QAC/C,OAAQ,OAA8B,CAAC,IAAI,KAAK,QAAQ,CACzD,CACD;SACA,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;SAC9B,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { Agent, type AgentTool, type StreamFn } from \"@caupulican/pi-agent-core\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport { registerInFlightWork } from \"./reload-blockers.ts\";\n\nexport const SCOUT_SYSTEM_PROMPT = `You are a repository scout. You explore a codebase with read-only tools and return compact evidence. You do NOT solve tasks, write code, or modify anything.\n\nTOOLS: read (file contents), grep (search file contents), find (locate files by glob/name).\n- Issue INDEPENDENT tool calls in parallel in the same turn whenever possible.\n- Prefer grep/find to narrow, then read only the decisive regions.\n\nOUTPUT CONTRACT: when you have enough evidence (or hit your turn budget), reply with:\n<final_answer>\n<one-to-three-sentence summary of what you found>\npath/to/file.ts:START-END\npath/to/other.ts:START-END\n</final_answer>\n- Every path MUST be one you actually observed via a tool result this run.\n- Line ranges point at the decisive code, not whole files.\n- If you found nothing relevant, say so inside <final_answer> with zero citations.\nTurn budget: {MAX_TURNS} turns. Be fast; be precise; cite, don't paste.`;\n\nexport interface ScoutCitation {\n\tpath: string;\n\tstart: number;\n\tend: number;\n\tvalid: boolean;\n}\n\nexport interface ScoutRunResult {\n\tsummary: string;\n\tcitations: ScoutCitation[];\n\tdroppedCitations: number;\n\tunreliable: boolean;\n\ttruncated: boolean;\n\tturnsUsed: number;\n\tfailure?: string;\n}\n\nexport interface ScoutControllerDeps {\n\tresolveScoutModel(): Promise<\n\t\t{ model: Model<any>; apiKey?: string; headers?: Record<string, string> } | { failure: string }\n\t>;\n\tgetCwd(): string;\n\tbuildReadOnlyTools(cwd: string): AgentTool<any>[];\n\tstreamFn?: StreamFn;\n\tfileExists(path: string): boolean;\n\tcountLines(path: string): number | undefined;\n\tonEvent?(event: { type: \"scout_turn\" | \"scout_end\"; detail: string }): void;\n\tsignal?: AbortSignal;\n\t/** Registers this scout's own Agent run in the reload-gate quiesce registry while it drives\n\t * turns, so `/reload`/profile-switch/live extension load-unload-reconcile wait it out. Optional —\n\t * a caller that hasn't wired an agent dir through (e.g. an existing test construction) sees no\n\t * behavior change; the scout simply stays invisible to the reload gate, matching its behavior\n\t * before this registration was added. */\n\tgetAgentDir?(): string;\n}\n\nconst MAX_TURNS_DEFAULT = 8;\nconst MAX_TURNS_HARD_CAP = 12;\nconst MAX_OUTPUT_TOKENS = 30_000;\nconst READ_ONLY_TOOL_NAMES = new Set([\"read\", \"grep\", \"find\"]);\n\nexport class ScoutController {\n\tprivate readonly deps: ScoutControllerDeps;\n\n\tconstructor(deps: ScoutControllerDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\tasync run(query: string, maxTurns = MAX_TURNS_DEFAULT): Promise<ScoutRunResult> {\n\t\tconst turnLimit = clampTurns(maxTurns);\n\t\tconst unavailable = emptyResult();\n\t\tif (this.deps.signal?.aborted) {\n\t\t\treturn { ...unavailable, failure: \"aborted\" };\n\t\t}\n\n\t\tlet modelResolution: Awaited<ReturnType<ScoutControllerDeps[\"resolveScoutModel\"]>>;\n\t\ttry {\n\t\t\tmodelResolution = await this.deps.resolveScoutModel();\n\t\t} catch (error) {\n\t\t\treturn { ...unavailable, failure: error instanceof Error ? error.message : String(error) };\n\t\t}\n\t\tif (\"failure\" in modelResolution) {\n\t\t\treturn { ...unavailable, failure: modelResolution.failure };\n\t\t}\n\n\t\t// Registered while this scout's own Agent drives turns, so the reload gate waits it out.\n\t\t// registerInFlightWork is a pure sync map op (cannot throw), so wrapping everything from here\n\t\t// through the end in try/finally guarantees deregistration on every exit path. Optional dep —\n\t\t// a caller that hasn't wired an agent dir through stays invisible to the gate, matching the\n\t\t// behavior before this registration was added.\n\t\tconst deregisterInFlight = this.deps.getAgentDir\n\t\t\t? registerInFlightWork(this.deps.getAgentDir(), \"scout\", query.slice(0, 80))\n\t\t\t: undefined;\n\t\ttry {\n\t\t\tlet turnsUsed = 0;\n\t\t\tlet truncated = false;\n\t\t\tlet lastAssistantText = \"\";\n\t\t\tlet outputTokens = 0;\n\t\t\tconst agent = new Agent({\n\t\t\t\tinitialState: {\n\t\t\t\t\tmodel: modelResolution.model,\n\t\t\t\t\tsystemPrompt: SCOUT_SYSTEM_PROMPT.replace(\"{MAX_TURNS}\", String(turnLimit)),\n\t\t\t\t\ttools: this.deps\n\t\t\t\t\t\t.buildReadOnlyTools(this.deps.getCwd())\n\t\t\t\t\t\t.filter((tool) => READ_ONLY_TOOL_NAMES.has(tool.name)),\n\t\t\t\t},\n\t\t\t\tstreamFn: this.deps.streamFn,\n\t\t\t\tgetApiKey: () => modelResolution.apiKey,\n\t\t\t\tmaxStallTurns: turnLimit,\n\t\t\t});\n\n\t\t\tconst unsubscribe = agent.subscribe((event) => {\n\t\t\t\tif (event.type !== \"message_end\" || event.message.role !== \"assistant\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tturnsUsed += 1;\n\t\t\t\tlastAssistantText = assistantText(event.message);\n\t\t\t\toutputTokens += getScoutOutputTokenCount(event.message);\n\t\t\t\tthis.deps.onEvent?.({ type: \"scout_turn\", detail: `turn ${turnsUsed}` });\n\t\t\t\tif (hasFinalAnswer(lastAssistantText)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (turnsUsed >= turnLimit || outputTokens >= MAX_OUTPUT_TOKENS) {\n\t\t\t\t\ttruncated = true;\n\t\t\t\t\tagent.abort();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst abortScout = (): void => {\n\t\t\t\ttruncated = true;\n\t\t\t\tagent.abort();\n\t\t\t};\n\t\t\tthis.deps.signal?.addEventListener(\"abort\", abortScout, { once: true });\n\t\t\tlet runFailure: string | undefined;\n\t\t\ttry {\n\t\t\t\tawait agent.prompt(query);\n\t\t\t} catch (error) {\n\t\t\t\tif (!truncated && !this.deps.signal?.aborted) {\n\t\t\t\t\trunFailure = error instanceof Error ? error.message : String(error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tunsubscribe();\n\t\t\t\tthis.deps.signal?.removeEventListener(\"abort\", abortScout);\n\t\t\t}\n\n\t\t\tconst result = parseScoutAnswer(\n\t\t\t\tlastAssistantText,\n\t\t\t\t(path) => this.deps.fileExists(path),\n\t\t\t\t(path) => this.deps.countLines(path),\n\t\t\t);\n\t\t\tconst finalResult = {\n\t\t\t\t...result,\n\t\t\t\ttruncated: truncated || !hasFinalAnswer(lastAssistantText),\n\t\t\t\tturnsUsed,\n\t\t\t\tfailure: this.deps.signal?.aborted ? \"aborted\" : runFailure,\n\t\t\t};\n\t\t\tthis.deps.onEvent?.({ type: \"scout_end\", detail: finalResult.failure ?? \"ok\" });\n\t\t\treturn finalResult;\n\t\t} finally {\n\t\t\tderegisterInFlight?.();\n\t\t}\n\t}\n}\n\nexport function getScoutOutputTokenCount(message: { usage?: { output?: number } }): number {\n\treturn message.usage?.output ?? 0;\n}\n\nexport function parseScoutAnswer(\n\ttext: string,\n\tfileExists: (path: string) => boolean,\n\tcountLines: (path: string) => number | undefined,\n): Omit<ScoutRunResult, \"truncated\" | \"turnsUsed\" | \"failure\"> {\n\tconst finalAnswer = /<final_answer>([\\s\\S]*?)<\\/final_answer>/i.exec(text)?.[1] ?? text;\n\tconst summaryLines: string[] = [];\n\tconst citations: ScoutCitation[] = [];\n\n\tfor (const rawLine of finalAnswer.split(/\\r?\\n/)) {\n\t\tconst line = rawLine.trim();\n\t\tif (!line) continue;\n\t\tconst citation = parseCitationLine(line, fileExists, countLines);\n\t\tif (citation) {\n\t\t\tcitations.push(citation);\n\t\t\tcontinue;\n\t\t}\n\t\tsummaryLines.push(line);\n\t}\n\n\tconst droppedCitations = citations.filter((citation) => !citation.valid).length;\n\treturn {\n\t\tsummary: summaryLines.join(\"\\n\"),\n\t\tcitations,\n\t\tdroppedCitations,\n\t\tunreliable: citations.length > 0 && droppedCitations / citations.length > 0.5,\n\t};\n}\n\nfunction parseCitationLine(\n\tline: string,\n\tfileExists: (path: string) => boolean,\n\tcountLines: (path: string) => number | undefined,\n): ScoutCitation | undefined {\n\tconst match = /^(.+?):(\\d+)(?:-(\\d+))?$/.exec(line);\n\tif (!match) return undefined;\n\tconst path = match[1].trim();\n\tconst start = Number.parseInt(match[2], 10);\n\tconst end = Number.parseInt(match[3] ?? match[2], 10);\n\tconst lineCount = countLines(path);\n\tconst valid =\n\t\tfileExists(path) &&\n\t\tNumber.isFinite(start) &&\n\t\tNumber.isFinite(end) &&\n\t\tstart >= 1 &&\n\t\tend >= start &&\n\t\t(lineCount === undefined || end <= lineCount);\n\treturn { path, start, end, valid };\n}\n\nfunction clampTurns(maxTurns: number): number {\n\tif (!Number.isFinite(maxTurns)) return MAX_TURNS_DEFAULT;\n\treturn Math.min(MAX_TURNS_HARD_CAP, Math.max(1, Math.trunc(maxTurns)));\n}\n\nfunction emptyResult(): ScoutRunResult {\n\treturn { summary: \"\", citations: [], droppedCitations: 0, unreliable: false, truncated: false, turnsUsed: 0 };\n}\n\nfunction hasFinalAnswer(text: string): boolean {\n\treturn /<final_answer>[\\s\\S]*?<\\/final_answer>/i.test(text);\n}\n\nfunction assistantText(message: { content: unknown }): string {\n\tif (!Array.isArray(message.content)) return \"\";\n\treturn message.content\n\t\t.filter((content): content is { type: \"text\"; text: string } =>\n\t\t\tBoolean(\n\t\t\t\tcontent &&\n\t\t\t\t\ttypeof content === \"object\" &&\n\t\t\t\t\t(content as { type?: unknown }).type === \"text\" &&\n\t\t\t\t\ttypeof (content as { text?: unknown }).text === \"string\",\n\t\t\t),\n\t\t)\n\t\t.map((content) => content.text)\n\t\t.join(\"\\n\");\n}\n"]}
|
package/dist/core/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAwB,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAE,KAAK,GAAG,EAAgB,KAAK,KAAK,EAA2C,MAAM,mBAAmB,CAAC;AAIhH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAmB,oBAAoB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,KAAK,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf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C,gEAAgE;IAChE,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;IAE/B,oEAAoE;IACpE,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,0GAA0G;IAC1G,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,uEAAuE;IACvE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACtC;AAED,qCAAqC;AACrC,MAAM,WAAW,wBAAwB;IACxC,0BAA0B;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,mEAAmE;IACnE,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,wEAAwE;IACxE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAID,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EACX,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACd,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EACN,qBAAqB,EAErB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,GACZ,CAAC;AA8CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA4VnH","sourcesContent":["import { Agent, type AgentMessage, convertToLlm, type ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport { getDefaultSessionDir, SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport { type Api, type Message, type Model, resolveModelThinkingLevel, streamSimple } from \"@caupulican/pi-ai\";\nimport { getAgentDir } from \"../config.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { configFile } from \"./agent-paths.ts\";\nimport { AgentSession } from \"./agent-session.ts\";\nimport { formatNoModelsAvailableMessage } from \"./auth-guidance.ts\";\nimport { AuthStorage } from \"./auth-storage.ts\";\nimport { recoverBedrockSsoAuthentication } from \"./bedrock-sso-login.ts\";\nimport { DEFAULT_ACTIVE_TOOL_NAMES } from \"./default-tool-surface.ts\";\nimport type { ExtensionRunner, LoadExtensionsResult, SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\nimport { isInstallTelemetryEnabled } from \"./install-telemetry.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { findInitialModel, resolveProfileModelSettings } from \"./model-resolver.ts\";\nimport type { OrchestrationProfile } from \"./orchestration/contracts.ts\";\nimport { resolveConfiguredOrchestrationModel } from \"./orchestration/model-binding.ts\";\nimport { validateOrchestrationProfile } from \"./orchestration/profile-registry.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport { DefaultResourceLoader } from \"./resource-loader.ts\";\nimport { parseResourceProfileInput } from \"./resource-profile-blocks.ts\";\nimport { isWorkerSession } from \"./session-role.ts\";\nimport type {\n\tProfileDefinitionInput,\n\tResourceProfileFilterSettings,\n\tResourceProfileSettings,\n} from \"./settings-manager.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\nimport { time } from \"./timings.ts\";\nimport {\n\tcreateBashTool,\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\twithFileMutationQueue,\n} from \"./tools/index.ts\";\n\nexport interface CreateAgentSessionOptions {\n\t/** Working directory for project-local discovery. Default: process.cwd() */\n\tcwd?: string;\n\t/** Global config directory. Default: ~/.pi/agent */\n\tagentDir?: string;\n\n\t/** Auth storage for credentials. Default: AuthStorage.create(agentDir/auth.json) */\n\tauthStorage?: AuthStorage;\n\t/** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */\n\tmodelRegistry?: ModelRegistry;\n\n\t/** Model to use. Default: from settings, else first available */\n\tmodel?: Model<Api>;\n\t/** Thinking level. Default: from settings, then the model's declared default, else 'medium'. */\n\tthinkingLevel?: ThinkingLevel;\n\t/**\n\t * Whether `model` came from an explicit CLI/SDK flag (vs. profile/settings resolution).\n\t * When false (default), the active profile's model is re-applied on reload so live profile\n\t * edits take effect; when true, the explicit launch-time model is preserved across reloads.\n\t */\n\tisExplicitModel?: boolean;\n\t/** Whether `thinkingLevel` came from an explicit flag (see isExplicitModel). */\n\tisExplicitThinking?: boolean;\n\t/** True when this session is a spawned subagent/child — gates durable memory writes. */\n\tisChildSession?: boolean;\n\t/** Models available for cycling (Ctrl+P in interactive mode) */\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n\t/**\n\t * Optional default tool suppression mode when no explicit allowlist is provided.\n\t *\n\t * - \"all\": start with no tools enabled\n\t * - \"builtin\": disable the default built-in tools (read, bash, edit, write, context_audit,\n\t * goal, delegate, and run_toolkit_script)\n\t * but keep extension/custom tools enabled\n\t */\n\tnoTools?: \"all\" | \"builtin\";\n\t/**\n\t * Optional allowlist of tool names.\n\t *\n\t * When omitted, pi enables the shared default built-in tool surface and leaves extension/custom\n\t * tools enabled unless `noTools` changes that default.\n\t * When provided, only the listed tool names are enabled.\n\t */\n\ttools?: string[];\n\t/** Optional denylist of tool names to disable. Applies after `tools` when both are provided. */\n\texcludeTools?: string[];\n\t/** Optional resource-profile allow/block filters for tool names. */\n\ttoolProfileFilter?: ResourceProfileFilterSettings;\n\t/** Optional one-shot resource filters or complete situation profiles. Never persisted to disk. */\n\tresourceProfileDefinitions?: Record<string, ResourceProfileSettings | ProfileDefinitionInput>;\n\t/** Optional one-shot profile definitions as JSON or <resource-profile> tag text. Never persisted to disk. */\n\tresourceProfileJson?: string | string[];\n\t/** Optional runtime profile selection. Never persisted to disk. */\n\tresourceProfiles?: string[];\n\t/** Immutable owner-authored orchestration policy for this session. */\n\torchestrationProfile?: OrchestrationProfile;\n\t/** Custom tools to register (in addition to built-in tools). */\n\tcustomTools?: ToolDefinition[];\n\n\t/** Resource loader. When omitted, DefaultResourceLoader is used. */\n\tresourceLoader?: ResourceLoader;\n\n\t/** Session manager. Default: SessionManager.create(cwd, agentDir, getDefaultSessionDir(cwd, agentDir)) */\n\tsessionManager?: SessionManager;\n\n\t/** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n\tsettingsManager?: SettingsManager;\n\t/** Session start event metadata for extension runtime startup. */\n\tsessionStartEvent?: SessionStartEvent;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n\t/** The created session */\n\tsession: AgentSession;\n\t/** Extensions result (for UI context setup in interactive mode) */\n\textensionsResult: LoadExtensionsResult;\n\t/** Warning if session was restored with a different model than saved */\n\tmodelFallbackMessage?: string;\n}\n\n// Re-exports\n\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n} from \"./extensions/index.ts\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type { Tool } from \"./tools/index.ts\";\n\nexport {\n\twithFileMutationQueue,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateBashTool,\n\tcreateEditTool,\n\tcreateWriteTool,\n\tcreateGrepTool,\n\tcreateFindTool,\n\tcreateLsTool,\n};\n\n// Helper Functions\n\nfunction getDefaultAgentDir(): string {\n\treturn getAgentDir();\n}\n\nfunction getAttributionHeaders(\n\tmodel: Model<Api>,\n\tsettingsManager: SettingsManager,\n\tsessionId?: string,\n): Record<string, string> | undefined {\n\tif (\n\t\tsessionId &&\n\t\t(model.provider === \"opencode\" || model.provider === \"opencode-go\" || model.baseUrl.includes(\"opencode.ai\"))\n\t) {\n\t\treturn { \"x-opencode-session\": sessionId, \"x-opencode-client\": \"pi\" };\n\t}\n\n\tif (!isInstallTelemetryEnabled(settingsManager)) {\n\t\treturn undefined;\n\t}\n\n\tif (model.provider === \"openrouter\" || model.baseUrl.includes(\"openrouter.ai\")) {\n\t\treturn {\n\t\t\t\"HTTP-Referer\": \"https://pi.dev\",\n\t\t\t\"X-OpenRouter-Title\": \"pi\",\n\t\t\t\"X-OpenRouter-Categories\": \"cli-agent\",\n\t\t};\n\t}\n\n\tif (\n\t\tmodel.provider === \"cloudflare-workers-ai\" ||\n\t\tmodel.provider === \"cloudflare-ai-gateway\" ||\n\t\tmodel.baseUrl.includes(\"api.cloudflare.com\") ||\n\t\tmodel.baseUrl.includes(\"gateway.ai.cloudflare.com\")\n\t) {\n\t\treturn {\n\t\t\t\"User-Agent\": \"pi-coding-agent\",\n\t\t};\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Create an AgentSession with the specified options.\n *\n * @example\n * ```typescript\n * // Minimal - uses defaults\n * const { session } = await createAgentSession();\n *\n * // With explicit model\n * import { getModel } from '@caupulican/pi-ai';\n * const { session } = await createAgentSession({\n * model: getModel('anthropic', 'claude-opus-4-5'),\n * thinkingLevel: 'high',\n * });\n *\n * // Continue previous session\n * const { session, modelFallbackMessage } = await createAgentSession({\n * continueSession: true,\n * });\n *\n * // Full control\n * const loader = new DefaultResourceLoader({\n * cwd: process.cwd(),\n * agentDir: getAgentDir(),\n * settingsManager: SettingsManager.create(),\n * });\n * await loader.reload();\n * const { session } = await createAgentSession({\n * model: myModel,\n * tools: [\"read\", \"bash\"],\n * resourceLoader: loader,\n * sessionManager: SessionManager.inMemory(),\n * });\n * ```\n */\nexport async function createAgentSession(options: CreateAgentSessionOptions = {}): Promise<CreateAgentSessionResult> {\n\tconst cwd = resolvePath(options.cwd ?? options.sessionManager?.getCwd() ?? process.cwd());\n\tconst agentDir = options.agentDir ? resolvePath(options.agentDir) : getDefaultAgentDir();\n\tlet resourceLoader = options.resourceLoader;\n\n\t// Use provided or create AuthStorage and ModelRegistry\n\tconst authPath = options.agentDir ? configFile(agentDir, \"auth.json\") : undefined;\n\tconst modelsPath = options.agentDir ? configFile(agentDir, \"models.json\") : undefined;\n\tconst authStorage = options.authStorage ?? AuthStorage.create(authPath);\n\tconst modelRegistry = options.modelRegistry ?? ModelRegistry.create(authStorage, modelsPath);\n\n\tconst settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);\n\tconst isChildSession = options.isChildSession ?? process.env.PI_CHILD_SESSION === \"1\";\n\tconst forceBackgroundRequests = isChildSession || isWorkerSession();\n\tconst orchestrationProfile = options.orchestrationProfile;\n\tif (orchestrationProfile) {\n\t\tvalidateOrchestrationProfile(orchestrationProfile);\n\t\tconst conflictingOptions = [\n\t\t\t...(options.model ? [\"model\"] : []),\n\t\t\t...(options.thinkingLevel !== undefined ? [\"thinkingLevel\"] : []),\n\t\t\t...(options.scopedModels !== undefined ? [\"scopedModels\"] : []),\n\t\t\t...(options.tools !== undefined ? [\"tools\"] : []),\n\t\t\t...(options.noTools !== undefined ? [\"noTools\"] : []),\n\t\t\t...(options.excludeTools !== undefined ? [\"excludeTools\"] : []),\n\t\t\t...(options.toolProfileFilter !== undefined ? [\"toolProfileFilter\"] : []),\n\t\t\t...(options.resourceProfiles !== undefined ? [\"resourceProfiles\"] : []),\n\t\t];\n\t\tif (conflictingOptions.length > 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Orchestration profile '${orchestrationProfile.profileId}' owns model, thinking, tools, and resources; remove conflicting SDK options: ${conflictingOptions.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tsettingsManager.setRuntimeResourceProfiles([...orchestrationProfile.resourceProfileNames]);\n\t}\n\tconst needsProfileReload =\n\t\toptions.resourceProfileDefinitions !== undefined ||\n\t\toptions.resourceProfileJson !== undefined ||\n\t\toptions.resourceProfiles !== undefined ||\n\t\torchestrationProfile !== undefined;\n\tif (options.resourceProfileDefinitions) {\n\t\tsettingsManager.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\tsettingsManager.addInlineResourceProfileDefinitions(parseResourceProfileInput(input).profiles);\n\t\t}\n\t}\n\tif (!orchestrationProfile && options.resourceProfiles !== undefined) {\n\t\tsettingsManager.setRuntimeResourceProfiles(options.resourceProfiles);\n\t}\n\tconst sessionManager =\n\t\toptions.sessionManager ?? SessionManager.create(cwd, agentDir, getDefaultSessionDir(cwd, agentDir));\n\n\tif (!resourceLoader) {\n\t\tresourceLoader = new DefaultResourceLoader({ cwd, agentDir, settingsManager });\n\t\tawait resourceLoader.reload();\n\t\ttime(\"resourceLoader.reload\");\n\t} else if (needsProfileReload) {\n\t\tawait resourceLoader.reload();\n\t\ttime(\"resourceLoader.reload\");\n\t}\n\n\t// Check if session has existing data to restore\n\tconst existingSession = sessionManager.buildSessionContext();\n\tconst hasExistingSession = existingSession.messages.length > 0;\n\tconst hasThinkingEntry = sessionManager.getBranch().some((entry) => entry.type === \"thinking_level_change\");\n\n\tconst orchestrationModel = orchestrationProfile\n\t\t? resolveConfiguredOrchestrationModel(orchestrationProfile, modelRegistry)\n\t\t: undefined;\n\tif (orchestrationProfile && !orchestrationModel) {\n\t\tthrow new TypeError(\n\t\t\t`Orchestration profile '${orchestrationProfile.profileId}' has no configured, authenticated model that supports its exact thinking level.`,\n\t\t);\n\t}\n\tlet model = orchestrationModel?.model ?? options.model;\n\tlet modelFallbackMessage: string | undefined;\n\n\tlet thinkingLevel = orchestrationModel?.binding.thinkingLevel ?? options.thinkingLevel;\n\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tif (!orchestrationProfile && activeProfileNames.length > 0) {\n\t\tconst profileSettings = resolveProfileModelSettings({\n\t\t\tactiveProfileNames,\n\t\t\tregistry: settingsManager.getProfileRegistry(),\n\t\t\tmodelRegistry,\n\t\t\tcwd,\n\t\t});\n\t\tif (profileSettings.error) {\n\t\t\tmodelFallbackMessage = `Profile model resolution error: ${profileSettings.error}`;\n\t\t}\n\t\tif (!model && profileSettings.model) {\n\t\t\tmodel = profileSettings.model;\n\t\t}\n\t\tif (thinkingLevel === undefined && profileSettings.thinkingLevel) {\n\t\t\tthinkingLevel = profileSettings.thinkingLevel;\n\t\t}\n\t}\n\n\t// If session has data, try to restore model from it\n\tif (!model && hasExistingSession && existingSession.model) {\n\t\tconst restoredModel = modelRegistry.find(existingSession.model.provider, existingSession.model.modelId);\n\t\tif (restoredModel && modelRegistry.hasConfiguredAuth(restoredModel)) {\n\t\t\tmodel = restoredModel;\n\t\t}\n\t\tif (!model) {\n\t\t\tmodelFallbackMessage = `Could not restore model ${existingSession.model.provider}/${existingSession.model.modelId}`;\n\t\t}\n\t}\n\n\t// If still no model, use findInitialModel (checks settings default, then provider defaults)\n\tif (!model) {\n\t\tconst result = await findInitialModel({\n\t\t\tscopedModels: [],\n\t\t\tisContinuing: hasExistingSession,\n\t\t\tdefaultProvider: settingsManager.getDefaultProvider(),\n\t\t\tdefaultModelId: settingsManager.getDefaultModel(),\n\t\t\tdefaultThinkingLevel: settingsManager.getDefaultThinkingLevel(),\n\t\t\tmodelRegistry,\n\t\t});\n\t\tmodel = result.model;\n\t\tif (thinkingLevel === undefined && !(hasExistingSession && hasThinkingEntry)) {\n\t\t\tthinkingLevel = result.thinkingLevel;\n\t\t}\n\t\tif (!model) {\n\t\t\tmodelFallbackMessage = formatNoModelsAvailableMessage();\n\t\t} else if (modelFallbackMessage) {\n\t\t\tmodelFallbackMessage += `. Using ${model.provider}/${model.id}`;\n\t\t}\n\t}\n\n\t// If session has data, restore thinking level from it\n\tif (thinkingLevel === undefined && hasExistingSession) {\n\t\tthinkingLevel = hasThinkingEntry\n\t\t\t? (existingSession.thinkingLevel as ThinkingLevel)\n\t\t\t: settingsManager.getDefaultThinkingLevel();\n\t}\n\n\t// Resolve preference, model metadata, harness fallback, and capability clamping through the\n\t// same contract used by CLI startup and isolated lanes.\n\tif (!model) {\n\t\tthinkingLevel = \"off\";\n\t} else {\n\t\tthinkingLevel = resolveModelThinkingLevel(\n\t\t\tmodel,\n\t\t\tthinkingLevel ?? settingsManager.getDefaultThinkingLevel(),\n\t\t) as ThinkingLevel;\n\t}\n\n\tconst defaultActiveToolNames = [\n\t\t...DEFAULT_ACTIVE_TOOL_NAMES,\n\t\t...(settingsManager.getScoutSettings().enabled ? [\"context_scout\"] : []),\n\t];\n\tconst toolProfileFilter = orchestrationProfile\n\t\t? settingsManager.getResourceProfileFilter(\"tools\")\n\t\t: (options.toolProfileFilter ?? settingsManager.getResourceProfileFilter(\"tools\"));\n\tconst allowedToolNames = orchestrationProfile\n\t\t? [...orchestrationProfile.toolNames]\n\t\t: (options.tools ?? (options.noTools === \"all\" ? [] : undefined));\n\tconst excludedToolNames = orchestrationProfile ? undefined : options.excludeTools;\n\tconst excludedToolNameSet = excludedToolNames ? new Set(excludedToolNames) : undefined;\n\tconst initialActiveToolNames: string[] = (\n\t\torchestrationProfile\n\t\t\t? [...orchestrationProfile.toolNames]\n\t\t\t: options.tools\n\t\t\t\t? [...options.tools]\n\t\t\t\t: options.noTools\n\t\t\t\t\t? []\n\t\t\t\t\t: defaultActiveToolNames\n\t).filter((name) => !excludedToolNameSet?.has(name));\n\n\tlet agent: Agent;\n\n\t// Create convertToLlm wrapper that filters images if blockImages is enabled (defense-in-depth)\n\tconst convertToLlmWithBlockImages = (messages: AgentMessage[]): Message[] => {\n\t\tconst converted = convertToLlm(messages);\n\t\t// Check setting dynamically so mid-session changes take effect\n\t\tif (!settingsManager.getBlockImages()) {\n\t\t\treturn converted;\n\t\t}\n\t\t// Filter out ImageContent from all messages, replacing with text placeholder\n\t\treturn converted.map((msg) => {\n\t\t\tif (msg.role === \"user\" || msg.role === \"toolResult\") {\n\t\t\t\tconst content = msg.content;\n\t\t\t\tif (Array.isArray(content)) {\n\t\t\t\t\tconst hasImages = content.some((c) => c.type === \"image\");\n\t\t\t\t\tif (hasImages) {\n\t\t\t\t\t\tconst filteredContent = content\n\t\t\t\t\t\t\t.map((c) =>\n\t\t\t\t\t\t\t\tc.type === \"image\" ? { type: \"text\" as const, text: \"Image reading is disabled.\" } : c,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(c, i, arr) =>\n\t\t\t\t\t\t\t\t\t// Dedupe consecutive \"Image reading is disabled.\" texts\n\t\t\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\t\t\tc.type === \"text\" &&\n\t\t\t\t\t\t\t\t\t\tc.text === \"Image reading is disabled.\" &&\n\t\t\t\t\t\t\t\t\t\ti > 0 &&\n\t\t\t\t\t\t\t\t\t\tarr[i - 1].type === \"text\" &&\n\t\t\t\t\t\t\t\t\t\t(arr[i - 1] as { type: \"text\"; text: string }).text === \"Image reading is disabled.\"\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\treturn { ...msg, content: filteredContent };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn msg;\n\t\t});\n\t};\n\n\tconst extensionRunnerRef: { current?: ExtensionRunner } = {};\n\n\tagent = new Agent({\n\t\tinitialState: {\n\t\t\tsystemPrompt: \"\",\n\t\t\tmodel,\n\t\t\tthinkingLevel,\n\t\t\ttools: [],\n\t\t},\n\t\tconvertToLlm: convertToLlmWithBlockImages,\n\t\tstreamFn: async (model, context, options) => {\n\t\t\tconst auth = await modelRegistry.getApiKeyAndHeaders(model);\n\t\t\tif (!auth.ok) {\n\t\t\t\tthrow new Error(auth.error);\n\t\t\t}\n\t\t\tconst providerRetrySettings = settingsManager.getProviderRetrySettings();\n\t\t\tconst httpIdleTimeoutMs = settingsManager.getHttpIdleTimeoutMs();\n\t\t\t// SDKs treat timeout=0 as 0ms (immediate timeout), not \"no timeout\".\n\t\t\t// Use max int32 to effectively disable the timeout.\n\t\t\tconst effectiveTimeoutMs = httpIdleTimeoutMs === 0 ? 2147483647 : httpIdleTimeoutMs;\n\t\t\tconst timeoutMs = options?.timeoutMs ?? providerRetrySettings.timeoutMs ?? effectiveTimeoutMs;\n\t\t\tconst websocketConnectTimeoutMs =\n\t\t\t\toptions?.websocketConnectTimeoutMs ?? settingsManager.getWebSocketConnectTimeoutMs();\n\t\t\tconst attributionHeaders = getAttributionHeaders(model, settingsManager, options?.sessionId);\n\t\t\treturn streamSimple(model, context, {\n\t\t\t\t...options,\n\t\t\t\tinteractionMode: forceBackgroundRequests ? \"background\" : (options?.interactionMode ?? \"user\"),\n\t\t\t\tonInteractiveAuthRecovery: options?.onInteractiveAuthRecovery ?? recoverBedrockSsoAuthentication,\n\t\t\t\tapiKey: auth.apiKey,\n\t\t\t\tonAuthRejection:\n\t\t\t\t\tauth.apiKey && model.provider === \"openai-codex\"\n\t\t\t\t\t\t? async () => modelRegistry.recoverRejectedOAuthApiKey(model.provider, auth.apiKey as string)\n\t\t\t\t\t\t: options?.onAuthRejection,\n\t\t\t\ttimeoutMs,\n\t\t\t\twebsocketConnectTimeoutMs,\n\t\t\t\tmaxRetries: options?.maxRetries ?? providerRetrySettings.maxRetries,\n\t\t\t\tmaxRetryDelayMs: options?.maxRetryDelayMs ?? providerRetrySettings.maxRetryDelayMs,\n\t\t\t\theaders:\n\t\t\t\t\tattributionHeaders || auth.headers || options?.headers\n\t\t\t\t\t\t? { ...attributionHeaders, ...auth.headers, ...options?.headers }\n\t\t\t\t\t\t: undefined,\n\t\t\t});\n\t\t},\n\t\tonPayload: async (payload, _model) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner?.hasHandlers(\"before_provider_request\")) {\n\t\t\t\treturn payload;\n\t\t\t}\n\t\t\treturn runner.emitBeforeProviderRequest(payload);\n\t\t},\n\t\tonResponse: async (response, _model) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner?.hasHandlers(\"after_provider_response\")) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait runner.emit({\n\t\t\t\ttype: \"after_provider_response\",\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t});\n\t\t},\n\t\tsessionId: sessionManager.getSessionId(),\n\t\ttransformContext: async (messages) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner) return messages;\n\t\t\treturn runner.emitContext(messages);\n\t\t},\n\t\tsteeringMode: settingsManager.getSteeringMode(),\n\t\tfollowUpMode: settingsManager.getFollowUpMode(),\n\t\ttransport: settingsManager.getTransport(),\n\t\tthinkingBudgets: settingsManager.getThinkingBudgets(),\n\t\tmaxRetryDelayMs: settingsManager.getProviderRetrySettings().maxRetryDelayMs,\n\t\tmaxStallTurns: settingsManager.getAutonomySettings().maxStallTurns,\n\t});\n\n\t// Restore messages if session has existing data\n\tif (hasExistingSession) {\n\t\tagent.state.messages = existingSession.messages;\n\t\tif (!hasThinkingEntry) {\n\t\t\tsessionManager.appendThinkingLevelChange(thinkingLevel);\n\t\t}\n\t} else {\n\t\t// Save initial model and thinking level for new sessions so they can be restored on resume\n\t\tif (model) {\n\t\t\tsessionManager.appendModelChange(model.provider, model.id);\n\t\t}\n\t\tsessionManager.appendThinkingLevelChange(thinkingLevel);\n\t}\n\n\tconst session = new AgentSession({\n\t\tagent,\n\t\tsessionManager,\n\t\tsettingsManager,\n\t\tcwd,\n\t\tagentDir,\n\t\tscopedModels: orchestrationModel\n\t\t\t? [{ model: orchestrationModel.model, thinkingLevel: orchestrationModel.binding.thinkingLevel }]\n\t\t\t: options.scopedModels,\n\t\tresourceLoader,\n\t\tcustomTools: options.customTools,\n\t\tmodelRegistry,\n\t\tinitialActiveToolNames,\n\t\tallowedToolNames,\n\t\texcludedToolNames,\n\t\textensionRunnerRef,\n\t\ttoolProfileFilter,\n\t\tisExplicitModel: orchestrationProfile ? true : (options.isExplicitModel ?? options.model != null),\n\t\tisExplicitThinking: orchestrationProfile\n\t\t\t? true\n\t\t\t: (options.isExplicitThinking ?? options.thinkingLevel !== undefined),\n\t\tisChildSession,\n\t\torchestrationProfile,\n\t\tsessionStartEvent: options.sessionStartEvent,\n\t});\n\ttry {\n\t\t// The initial runtime has now bound providers from profile-granted extensions. Re-resolve the\n\t\t// profile model against that authoritative registry generation, then resync model capability.\n\t\tawait session.reapplyActiveProfileModelSettings();\n\t\tif (modelFallbackMessage?.startsWith(\"Profile model resolution error:\")) {\n\t\t\tmodelFallbackMessage = undefined;\n\t\t}\n\t} catch (error) {\n\t\t// Preserve the established non-fatal fallback for a genuinely unresolved profile model.\n\t\tif (!modelFallbackMessage?.startsWith(\"Profile model resolution error:\")) {\n\t\t\tawait session.disposeAndWait();\n\t\t\tthrow error;\n\t\t}\n\t}\n\tconst extensionsResult = resourceLoader.getExtensions();\n\n\treturn {\n\t\tsession,\n\t\textensionsResult,\n\t\tmodelFallbackMessage,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAwB,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAE,KAAK,GAAG,EAAgB,KAAK,KAAK,EAA2C,MAAM,mBAAmB,CAAC;AAIhH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAmB,oBAAoB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MA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;KACpB,CAAC;AAAA,CACF","sourcesContent":["import { Agent, type AgentMessage, convertToLlm, type ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport { getDefaultSessionDir, SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport { type Api, type Message, type Model, resolveModelThinkingLevel, streamSimple } from \"@caupulican/pi-ai\";\nimport { getAgentDir } from \"../config.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { configFile } from \"./agent-paths.ts\";\nimport { AgentSession } from \"./agent-session.ts\";\nimport { formatNoModelsAvailableMessage } from \"./auth-guidance.ts\";\nimport { AuthStorage } from \"./auth-storage.ts\";\nimport { recoverBedrockSsoAuthentication } from \"./bedrock-sso-login.ts\";\nimport { DEFAULT_ACTIVE_TOOL_NAMES } from \"./default-tool-surface.ts\";\nimport type { ExtensionRunner, LoadExtensionsResult, SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\nimport { isInstallTelemetryEnabled } from \"./install-telemetry.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { findInitialModel, resolveProfileModelSettings } from \"./model-resolver.ts\";\nimport type { OrchestrationProfile } from \"./orchestration/contracts.ts\";\nimport { resolveConfiguredOrchestrationModel } from \"./orchestration/model-binding.ts\";\nimport { validateOrchestrationProfile } from \"./orchestration/profile-registry.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport { DefaultResourceLoader } from \"./resource-loader.ts\";\nimport { parseResourceProfileInput } from \"./resource-profile-blocks.ts\";\nimport { isWorkerSession } from \"./session-role.ts\";\nimport type {\n\tProfileDefinitionInput,\n\tResourceProfileFilterSettings,\n\tResourceProfileSettings,\n} from \"./settings-manager.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\nimport { time } from \"./timings.ts\";\nimport {\n\tcreateBashTool,\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\twithFileMutationQueue,\n} from \"./tools/index.ts\";\n\nexport interface CreateAgentSessionOptions {\n\t/** Working directory for project-local discovery. Default: process.cwd() */\n\tcwd?: string;\n\t/** Global config directory. Default: ~/.pi/agent */\n\tagentDir?: string;\n\n\t/** Auth storage for credentials. Default: AuthStorage.create(agentDir/auth.json) */\n\tauthStorage?: AuthStorage;\n\t/** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */\n\tmodelRegistry?: ModelRegistry;\n\n\t/** Model to use. Default: from settings, else first available */\n\tmodel?: Model<Api>;\n\t/** Thinking level. Default: from settings, then the model's declared default, else 'medium'. */\n\tthinkingLevel?: ThinkingLevel;\n\t/**\n\t * Whether `model` came from an explicit CLI/SDK flag (vs. profile/settings resolution).\n\t * When false (default), the active profile's model is re-applied on reload so live profile\n\t * edits take effect; when true, the explicit launch-time model is preserved across reloads.\n\t */\n\tisExplicitModel?: boolean;\n\t/** Whether `thinkingLevel` came from an explicit flag (see isExplicitModel). */\n\tisExplicitThinking?: boolean;\n\t/** True when this session is a spawned subagent/child — gates durable memory writes. */\n\tisChildSession?: boolean;\n\t/** Models available for cycling (Ctrl+P in interactive mode) */\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n\t/**\n\t * Optional default tool suppression mode when no explicit allowlist is provided.\n\t *\n\t * - \"all\": start with no tools enabled\n\t * - \"builtin\": disable the default built-in tools (read, bash, edit, write, context_audit,\n\t * goal, delegate, and run_toolkit_script)\n\t * but keep extension/custom tools enabled\n\t */\n\tnoTools?: \"all\" | \"builtin\";\n\t/**\n\t * Optional allowlist of tool names.\n\t *\n\t * When omitted, pi enables the shared default built-in tool surface and leaves extension/custom\n\t * tools enabled unless `noTools` changes that default.\n\t * When provided, only the listed tool names are enabled.\n\t */\n\ttools?: string[];\n\t/** Optional denylist of tool names to disable. Applies after `tools` when both are provided. */\n\texcludeTools?: string[];\n\t/** Optional resource-profile allow/block filters for tool names. */\n\ttoolProfileFilter?: ResourceProfileFilterSettings;\n\t/** Optional one-shot resource filters or complete situation profiles. Never persisted to disk. */\n\tresourceProfileDefinitions?: Record<string, ResourceProfileSettings | ProfileDefinitionInput>;\n\t/** Optional one-shot profile definitions as JSON or <resource-profile> tag text. Never persisted to disk. */\n\tresourceProfileJson?: string | string[];\n\t/** Optional runtime profile selection. Never persisted to disk. */\n\tresourceProfiles?: string[];\n\t/** Immutable owner-authored orchestration policy for this session. */\n\torchestrationProfile?: OrchestrationProfile;\n\t/** Custom tools to register (in addition to built-in tools). */\n\tcustomTools?: ToolDefinition[];\n\n\t/** Resource loader. When omitted, DefaultResourceLoader is used. */\n\tresourceLoader?: ResourceLoader;\n\n\t/** Session manager. Default: SessionManager.create(cwd, agentDir, getDefaultSessionDir(cwd, agentDir)) */\n\tsessionManager?: SessionManager;\n\n\t/** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n\tsettingsManager?: SettingsManager;\n\t/** Session start event metadata for extension runtime startup. */\n\tsessionStartEvent?: SessionStartEvent;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n\t/** The created session */\n\tsession: AgentSession;\n\t/** Extensions result (for UI context setup in interactive mode) */\n\textensionsResult: LoadExtensionsResult;\n\t/** Warning if session was restored with a different model than saved */\n\tmodelFallbackMessage?: string;\n}\n\n// Re-exports\n\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n} from \"./extensions/index.ts\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type { Tool } from \"./tools/index.ts\";\n\nexport {\n\twithFileMutationQueue,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateBashTool,\n\tcreateEditTool,\n\tcreateWriteTool,\n\tcreateGrepTool,\n\tcreateFindTool,\n\tcreateLsTool,\n};\n\n// Helper Functions\n\nfunction getDefaultAgentDir(): string {\n\treturn getAgentDir();\n}\n\nfunction getAttributionHeaders(\n\tmodel: Model<Api>,\n\tsettingsManager: SettingsManager,\n\tsessionId?: string,\n): Record<string, string> | undefined {\n\tif (\n\t\tsessionId &&\n\t\t(model.provider === \"opencode\" || model.provider === \"opencode-go\" || model.baseUrl.includes(\"opencode.ai\"))\n\t) {\n\t\treturn { \"x-opencode-session\": sessionId, \"x-opencode-client\": \"pi\" };\n\t}\n\n\tif (!isInstallTelemetryEnabled(settingsManager)) {\n\t\treturn undefined;\n\t}\n\n\tif (model.provider === \"openrouter\" || model.baseUrl.includes(\"openrouter.ai\")) {\n\t\treturn {\n\t\t\t\"HTTP-Referer\": \"https://pi.dev\",\n\t\t\t\"X-OpenRouter-Title\": \"pi\",\n\t\t\t\"X-OpenRouter-Categories\": \"cli-agent\",\n\t\t};\n\t}\n\n\tif (\n\t\tmodel.provider === \"cloudflare-workers-ai\" ||\n\t\tmodel.provider === \"cloudflare-ai-gateway\" ||\n\t\tmodel.baseUrl.includes(\"api.cloudflare.com\") ||\n\t\tmodel.baseUrl.includes(\"gateway.ai.cloudflare.com\")\n\t) {\n\t\treturn {\n\t\t\t\"User-Agent\": \"pi-coding-agent\",\n\t\t};\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Create an AgentSession with the specified options.\n *\n * @example\n * ```typescript\n * // Minimal - uses defaults\n * const { session } = await createAgentSession();\n *\n * // With explicit model\n * import { getModel } from '@caupulican/pi-ai';\n * const { session } = await createAgentSession({\n * model: getModel('anthropic', 'claude-opus-4-5'),\n * thinkingLevel: 'high',\n * });\n *\n * // Continue previous session\n * const { session, modelFallbackMessage } = await createAgentSession({\n * continueSession: true,\n * });\n *\n * // Full control\n * const loader = new DefaultResourceLoader({\n * cwd: process.cwd(),\n * agentDir: getAgentDir(),\n * settingsManager: SettingsManager.create(),\n * });\n * await loader.reload();\n * const { session } = await createAgentSession({\n * model: myModel,\n * tools: [\"read\", \"bash\"],\n * resourceLoader: loader,\n * sessionManager: SessionManager.inMemory(),\n * });\n * ```\n */\nexport async function createAgentSession(options: CreateAgentSessionOptions = {}): Promise<CreateAgentSessionResult> {\n\tconst cwd = resolvePath(options.cwd ?? options.sessionManager?.getCwd() ?? process.cwd());\n\tconst agentDir = options.agentDir ? resolvePath(options.agentDir) : getDefaultAgentDir();\n\tlet resourceLoader = options.resourceLoader;\n\n\t// Use provided or create AuthStorage and ModelRegistry\n\tconst authPath = options.agentDir ? configFile(agentDir, \"auth.json\") : undefined;\n\tconst modelsPath = options.agentDir ? configFile(agentDir, \"models.json\") : undefined;\n\tconst authStorage = options.authStorage ?? AuthStorage.create(authPath);\n\tconst modelRegistry = options.modelRegistry ?? ModelRegistry.create(authStorage, modelsPath);\n\n\tconst settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);\n\tconst isChildSession = options.isChildSession ?? process.env.PI_CHILD_SESSION === \"1\";\n\tconst forceBackgroundRequests = isChildSession || isWorkerSession();\n\tconst orchestrationProfile = options.orchestrationProfile;\n\tif (orchestrationProfile) {\n\t\tvalidateOrchestrationProfile(orchestrationProfile);\n\t\tconst conflictingOptions = [\n\t\t\t...(options.model ? [\"model\"] : []),\n\t\t\t...(options.thinkingLevel !== undefined ? [\"thinkingLevel\"] : []),\n\t\t\t...(options.scopedModels !== undefined ? [\"scopedModels\"] : []),\n\t\t\t...(options.tools !== undefined ? [\"tools\"] : []),\n\t\t\t...(options.noTools !== undefined ? [\"noTools\"] : []),\n\t\t\t...(options.excludeTools !== undefined ? [\"excludeTools\"] : []),\n\t\t\t...(options.toolProfileFilter !== undefined ? [\"toolProfileFilter\"] : []),\n\t\t\t...(options.resourceProfiles !== undefined ? [\"resourceProfiles\"] : []),\n\t\t];\n\t\tif (conflictingOptions.length > 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Orchestration profile '${orchestrationProfile.profileId}' owns model, thinking, tools, and resources; remove conflicting SDK options: ${conflictingOptions.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tsettingsManager.setRuntimeResourceProfiles([...orchestrationProfile.resourceProfileNames]);\n\t}\n\tconst needsProfileReload =\n\t\toptions.resourceProfileDefinitions !== undefined ||\n\t\toptions.resourceProfileJson !== undefined ||\n\t\toptions.resourceProfiles !== undefined ||\n\t\torchestrationProfile !== undefined;\n\tif (options.resourceProfileDefinitions) {\n\t\tsettingsManager.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\tsettingsManager.addInlineResourceProfileDefinitions(parseResourceProfileInput(input).profiles);\n\t\t}\n\t}\n\tif (!orchestrationProfile && options.resourceProfiles !== undefined) {\n\t\tsettingsManager.setRuntimeResourceProfiles(options.resourceProfiles);\n\t}\n\tconst sessionManager =\n\t\toptions.sessionManager ?? SessionManager.create(cwd, agentDir, getDefaultSessionDir(cwd, agentDir));\n\n\tif (!resourceLoader) {\n\t\tresourceLoader = new DefaultResourceLoader({ cwd, agentDir, settingsManager });\n\t\tawait resourceLoader.reload();\n\t\ttime(\"resourceLoader.reload\");\n\t} else if (needsProfileReload) {\n\t\tawait resourceLoader.reload();\n\t\ttime(\"resourceLoader.reload\");\n\t}\n\n\t// Check if session has existing data to restore\n\tconst existingSession = sessionManager.buildSessionContext();\n\tconst hasExistingSession = existingSession.messages.length > 0;\n\tconst hasThinkingEntry = sessionManager.getBranch().some((entry) => entry.type === \"thinking_level_change\");\n\n\tconst orchestrationModel = orchestrationProfile\n\t\t? resolveConfiguredOrchestrationModel(orchestrationProfile, modelRegistry)\n\t\t: undefined;\n\tif (orchestrationProfile && !orchestrationModel) {\n\t\tthrow new TypeError(\n\t\t\t`Orchestration profile '${orchestrationProfile.profileId}' has no configured, authenticated model that supports its exact thinking level.`,\n\t\t);\n\t}\n\tlet model = orchestrationModel?.model ?? options.model;\n\tlet modelFallbackMessage: string | undefined;\n\n\tlet thinkingLevel = orchestrationModel?.binding.thinkingLevel ?? options.thinkingLevel;\n\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tif (!orchestrationProfile && activeProfileNames.length > 0) {\n\t\tconst profileSettings = resolveProfileModelSettings({\n\t\t\tactiveProfileNames,\n\t\t\tregistry: settingsManager.getProfileRegistry(),\n\t\t\tmodelRegistry,\n\t\t\tcwd,\n\t\t});\n\t\tif (profileSettings.error) {\n\t\t\tmodelFallbackMessage = `Profile model resolution error: ${profileSettings.error}`;\n\t\t}\n\t\tif (!model && profileSettings.model) {\n\t\t\tmodel = profileSettings.model;\n\t\t}\n\t\tif (thinkingLevel === undefined && profileSettings.thinkingLevel) {\n\t\t\tthinkingLevel = profileSettings.thinkingLevel;\n\t\t}\n\t}\n\n\t// If session has data, try to restore model from it\n\tif (!model && hasExistingSession && existingSession.model) {\n\t\tconst restoredModel = modelRegistry.find(existingSession.model.provider, existingSession.model.modelId);\n\t\tif (restoredModel && modelRegistry.hasConfiguredAuth(restoredModel)) {\n\t\t\tmodel = restoredModel;\n\t\t}\n\t\tif (!model) {\n\t\t\tmodelFallbackMessage = `Could not restore model ${existingSession.model.provider}/${existingSession.model.modelId}`;\n\t\t}\n\t}\n\n\t// If still no model, use findInitialModel (checks settings default, then provider defaults)\n\tif (!model) {\n\t\tconst result = await findInitialModel({\n\t\t\tscopedModels: [],\n\t\t\tisContinuing: hasExistingSession,\n\t\t\tdefaultProvider: settingsManager.getDefaultProvider(),\n\t\t\tdefaultModelId: settingsManager.getDefaultModel(),\n\t\t\tdefaultThinkingLevel: settingsManager.getDefaultThinkingLevel(),\n\t\t\tmodelRegistry,\n\t\t});\n\t\tmodel = result.model;\n\t\tif (thinkingLevel === undefined && !(hasExistingSession && hasThinkingEntry)) {\n\t\t\tthinkingLevel = result.thinkingLevel;\n\t\t}\n\t\tif (!model) {\n\t\t\tmodelFallbackMessage = formatNoModelsAvailableMessage();\n\t\t} else if (modelFallbackMessage) {\n\t\t\tmodelFallbackMessage += `. Using ${model.provider}/${model.id}`;\n\t\t}\n\t}\n\n\t// If session has data, restore thinking level from it\n\tif (thinkingLevel === undefined && hasExistingSession) {\n\t\tthinkingLevel = hasThinkingEntry\n\t\t\t? (existingSession.thinkingLevel as ThinkingLevel)\n\t\t\t: settingsManager.getDefaultThinkingLevel();\n\t}\n\n\t// Resolve preference, model metadata, harness fallback, and capability clamping through the\n\t// same contract used by CLI startup and isolated lanes.\n\tif (!model) {\n\t\tthinkingLevel = \"off\";\n\t} else {\n\t\tthinkingLevel = resolveModelThinkingLevel(\n\t\t\tmodel,\n\t\t\tthinkingLevel ?? settingsManager.getDefaultThinkingLevel(),\n\t\t) as ThinkingLevel;\n\t}\n\n\tconst defaultActiveToolNames = [\n\t\t...DEFAULT_ACTIVE_TOOL_NAMES,\n\t\t...(settingsManager.getScoutSettings().enabled ? [\"context_scout\"] : []),\n\t];\n\tconst toolProfileFilter = orchestrationProfile\n\t\t? settingsManager.getResourceProfileFilter(\"tools\")\n\t\t: (options.toolProfileFilter ?? settingsManager.getResourceProfileFilter(\"tools\"));\n\tconst allowedToolNames = orchestrationProfile\n\t\t? [...orchestrationProfile.toolNames]\n\t\t: (options.tools ?? (options.noTools === \"all\" ? [] : undefined));\n\tconst excludedToolNames = orchestrationProfile ? undefined : options.excludeTools;\n\tconst excludedToolNameSet = excludedToolNames ? new Set(excludedToolNames) : undefined;\n\tconst initialActiveToolNames: string[] = (\n\t\torchestrationProfile\n\t\t\t? [...orchestrationProfile.toolNames]\n\t\t\t: options.tools\n\t\t\t\t? [...options.tools]\n\t\t\t\t: options.noTools\n\t\t\t\t\t? []\n\t\t\t\t\t: defaultActiveToolNames\n\t).filter((name) => !excludedToolNameSet?.has(name));\n\n\tlet agent: Agent;\n\n\t// Create convertToLlm wrapper that filters images if blockImages is enabled (defense-in-depth)\n\tconst convertToLlmWithBlockImages = (messages: AgentMessage[]): Message[] => {\n\t\tconst converted = convertToLlm(messages);\n\t\t// Check setting dynamically so mid-session changes take effect\n\t\tif (!settingsManager.getBlockImages()) {\n\t\t\treturn converted;\n\t\t}\n\t\t// Filter out ImageContent from all messages, replacing with text placeholder\n\t\treturn converted.map((msg) => {\n\t\t\tif (msg.role === \"user\" || msg.role === \"toolResult\") {\n\t\t\t\tconst content = msg.content;\n\t\t\t\tif (Array.isArray(content)) {\n\t\t\t\t\tconst hasImages = content.some((c) => c.type === \"image\");\n\t\t\t\t\tif (hasImages) {\n\t\t\t\t\t\tconst filteredContent = content\n\t\t\t\t\t\t\t.map((c) =>\n\t\t\t\t\t\t\t\tc.type === \"image\" ? { type: \"text\" as const, text: \"Image reading is disabled.\" } : c,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(c, i, arr) =>\n\t\t\t\t\t\t\t\t\t// Dedupe consecutive \"Image reading is disabled.\" texts\n\t\t\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\t\t\tc.type === \"text\" &&\n\t\t\t\t\t\t\t\t\t\tc.text === \"Image reading is disabled.\" &&\n\t\t\t\t\t\t\t\t\t\ti > 0 &&\n\t\t\t\t\t\t\t\t\t\tarr[i - 1].type === \"text\" &&\n\t\t\t\t\t\t\t\t\t\t(arr[i - 1] as { type: \"text\"; text: string }).text === \"Image reading is disabled.\"\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\treturn { ...msg, content: filteredContent };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn msg;\n\t\t});\n\t};\n\n\tconst extensionRunnerRef: { current?: ExtensionRunner } = {};\n\n\tagent = new Agent({\n\t\tinitialState: {\n\t\t\tsystemPrompt: \"\",\n\t\t\tmodel,\n\t\t\tthinkingLevel,\n\t\t\ttools: [],\n\t\t},\n\t\tconvertToLlm: convertToLlmWithBlockImages,\n\t\tstreamFn: async (model, context, options) => {\n\t\t\tconst auth = await modelRegistry.getApiKeyAndHeaders(model);\n\t\t\tif (!auth.ok) {\n\t\t\t\tthrow new Error(auth.error);\n\t\t\t}\n\t\t\tconst providerRetrySettings = settingsManager.getProviderRetrySettings();\n\t\t\tconst httpIdleTimeoutMs = settingsManager.getHttpIdleTimeoutMs();\n\t\t\t// SDKs treat timeout=0 as 0ms (immediate timeout), not \"no timeout\".\n\t\t\t// Use max int32 to effectively disable the timeout.\n\t\t\tconst effectiveTimeoutMs = httpIdleTimeoutMs === 0 ? 2147483647 : httpIdleTimeoutMs;\n\t\t\tconst timeoutMs = options?.timeoutMs ?? providerRetrySettings.timeoutMs ?? effectiveTimeoutMs;\n\t\t\tconst websocketConnectTimeoutMs =\n\t\t\t\toptions?.websocketConnectTimeoutMs ?? settingsManager.getWebSocketConnectTimeoutMs();\n\t\t\tconst attributionHeaders = getAttributionHeaders(model, settingsManager, options?.sessionId);\n\t\t\treturn streamSimple(model, context, {\n\t\t\t\t...options,\n\t\t\t\tinteractionMode: forceBackgroundRequests ? \"background\" : (options?.interactionMode ?? \"user\"),\n\t\t\t\tonInteractiveAuthRecovery: options?.onInteractiveAuthRecovery ?? recoverBedrockSsoAuthentication,\n\t\t\t\tapiKey: auth.apiKey,\n\t\t\t\tonAuthRejection:\n\t\t\t\t\tauth.apiKey && model.provider === \"openai-codex\"\n\t\t\t\t\t\t? async () => modelRegistry.recoverRejectedOAuthApiKey(model.provider, auth.apiKey as string)\n\t\t\t\t\t\t: options?.onAuthRejection,\n\t\t\t\ttimeoutMs,\n\t\t\t\twebsocketConnectTimeoutMs,\n\t\t\t\tmaxRetries: options?.maxRetries ?? providerRetrySettings.maxRetries,\n\t\t\t\tmaxRetryDelayMs: options?.maxRetryDelayMs ?? providerRetrySettings.maxRetryDelayMs,\n\t\t\t\theaders:\n\t\t\t\t\tattributionHeaders || auth.headers || options?.headers\n\t\t\t\t\t\t? { ...attributionHeaders, ...auth.headers, ...options?.headers }\n\t\t\t\t\t\t: undefined,\n\t\t\t});\n\t\t},\n\t\tonPayload: async (payload, _model) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner?.hasHandlers(\"before_provider_request\")) {\n\t\t\t\treturn payload;\n\t\t\t}\n\t\t\treturn runner.emitBeforeProviderRequest(payload);\n\t\t},\n\t\tonResponse: async (response, _model) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner?.hasHandlers(\"after_provider_response\")) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait runner.emit({\n\t\t\t\ttype: \"after_provider_response\",\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t});\n\t\t},\n\t\tsessionId: sessionManager.getSessionId(),\n\t\ttransformContext: async (messages) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner) return messages;\n\t\t\treturn runner.emitContext(messages);\n\t\t},\n\t\tsteeringMode: settingsManager.getSteeringMode(),\n\t\tfollowUpMode: settingsManager.getFollowUpMode(),\n\t\ttransport: settingsManager.getTransport(),\n\t\tthinkingBudgets: settingsManager.getThinkingBudgets(),\n\t\tmaxRetryDelayMs: settingsManager.getProviderRetrySettings().maxRetryDelayMs,\n\t\tmaxStallTurns: settingsManager.getAutonomySettings().maxStallTurns,\n\t});\n\n\t// Restore messages if session has existing data\n\tif (hasExistingSession) {\n\t\tagent.state.messages = existingSession.messages;\n\t\tif (!hasThinkingEntry) {\n\t\t\tsessionManager.appendThinkingLevelChange(thinkingLevel);\n\t\t}\n\t} else {\n\t\t// Save initial model and thinking level for new sessions so they can be restored on resume\n\t\tif (model) {\n\t\t\tsessionManager.appendModelChange(model.provider, model.id);\n\t\t}\n\t\tsessionManager.appendThinkingLevelChange(thinkingLevel);\n\t}\n\n\tconst session = new AgentSession({\n\t\tagent,\n\t\tsessionManager,\n\t\tsettingsManager,\n\t\tcwd,\n\t\tagentDir,\n\t\tscopedModels: orchestrationModel\n\t\t\t? [{ model: orchestrationModel.model, thinkingLevel: orchestrationModel.binding.thinkingLevel }]\n\t\t\t: options.scopedModels,\n\t\tresourceLoader,\n\t\tcustomTools: options.customTools,\n\t\tmodelRegistry,\n\t\tinitialActiveToolNames,\n\t\tallowedToolNames,\n\t\texcludedToolNames,\n\t\textensionRunnerRef,\n\t\ttoolProfileFilter,\n\t\tisExplicitModel: orchestrationProfile ? true : (options.isExplicitModel ?? options.model != null),\n\t\tisExplicitThinking: orchestrationProfile\n\t\t\t? true\n\t\t\t: (options.isExplicitThinking ?? options.thinkingLevel !== undefined),\n\t\tisChildSession,\n\t\torchestrationProfile,\n\t\tsessionStartEvent: options.sessionStartEvent,\n\t});\n\ttry {\n\t\t// The initial runtime has now bound providers from profile-granted extensions. Re-resolve the\n\t\t// profile model against that authoritative registry generation, then resync model capability.\n\t\tawait session.reapplyActiveProfileModelSettings();\n\t\tif (modelFallbackMessage?.startsWith(\"Profile model resolution error:\")) {\n\t\t\tmodelFallbackMessage = undefined;\n\t\t}\n\t} catch (error) {\n\t\t// Preserve the established non-fatal fallback for a genuinely unresolved profile model.\n\t\tif (!modelFallbackMessage?.startsWith(\"Profile model resolution error:\")) {\n\t\t\tawait session.disposeAndWait();\n\t\t\tthrow error;\n\t\t}\n\t}\n\tconst extensionsResult = resourceLoader.getExtensions();\n\n\treturn {\n\t\tsession,\n\t\textensionsResult,\n\t\tmodelFallbackMessage,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,YAAY,EAAsB,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAsC,yBAAyB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAChH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,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tE,cAAc;QACd,oBAAoB;QACpB,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;KAC5C,CAAC,CAAC;IACH,IAAI,CAAC;QACJ,8FAA8F;QAC9F,8FAA8F;QAC9F,MAAM,OAAO,CAAC,iCAAiC,EAAE,CAAC;QAClD,IAAI,oBAAoB,EAAE,UAAU,CAAC,iCAAiC,CAAC,EAAE,CAAC;YACzE,oBAAoB,GAAG,SAAS,CAAC;QAClC,CAAC;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,wFAAwF;QACxF,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,iCAAiC,CAAC,EAAE,CAAC;YAC1E,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;YAC/B,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IACD,MAAM,gBAAgB,GAAG,cAAc,CAAC,aAAa,EAAE,CAAC;IAExD,OAAO;QACN,OAAO;QACP,gBAAgB;QAChB,oBAAoB;KACpB,CAAC;AACH,CAAC","sourcesContent":["import { Agent, type AgentMessage, convertToLlm, type ThinkingLevel } from \"@caupulican/pi-agent-core\";\nimport { getDefaultSessionDir, SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport { type Api, type Message, type Model, resolveModelThinkingLevel, streamSimple } from \"@caupulican/pi-ai\";\nimport { getAgentDir } from \"../config.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { configFile } from \"./agent-paths.ts\";\nimport { AgentSession } from \"./agent-session.ts\";\nimport { formatNoModelsAvailableMessage } from \"./auth-guidance.ts\";\nimport { AuthStorage } from \"./auth-storage.ts\";\nimport { recoverBedrockSsoAuthentication } from \"./bedrock-sso-login.ts\";\nimport { DEFAULT_ACTIVE_TOOL_NAMES } from \"./default-tool-surface.ts\";\nimport type { ExtensionRunner, LoadExtensionsResult, SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\nimport { isInstallTelemetryEnabled } from \"./install-telemetry.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { findInitialModel, resolveProfileModelSettings } from \"./model-resolver.ts\";\nimport type { OrchestrationProfile } from \"./orchestration/contracts.ts\";\nimport { resolveConfiguredOrchestrationModel } from \"./orchestration/model-binding.ts\";\nimport { validateOrchestrationProfile } from \"./orchestration/profile-registry.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport { DefaultResourceLoader } from \"./resource-loader.ts\";\nimport { parseResourceProfileInput } from \"./resource-profile-blocks.ts\";\nimport { isWorkerSession } from \"./session-role.ts\";\nimport type {\n\tProfileDefinitionInput,\n\tResourceProfileFilterSettings,\n\tResourceProfileSettings,\n} from \"./settings-manager.ts\";\nimport { SettingsManager } from \"./settings-manager.ts\";\nimport { time } from \"./timings.ts\";\nimport {\n\tcreateBashTool,\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\twithFileMutationQueue,\n} from \"./tools/index.ts\";\n\nexport interface CreateAgentSessionOptions {\n\t/** Working directory for project-local discovery. Default: process.cwd() */\n\tcwd?: string;\n\t/** Global config directory. Default: ~/.pi/agent */\n\tagentDir?: string;\n\n\t/** Auth storage for credentials. Default: AuthStorage.create(agentDir/auth.json) */\n\tauthStorage?: AuthStorage;\n\t/** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */\n\tmodelRegistry?: ModelRegistry;\n\n\t/** Model to use. Default: from settings, else first available */\n\tmodel?: Model<Api>;\n\t/** Thinking level. Default: from settings, then the model's declared default, else 'medium'. */\n\tthinkingLevel?: ThinkingLevel;\n\t/**\n\t * Whether `model` came from an explicit CLI/SDK flag (vs. profile/settings resolution).\n\t * When false (default), the active profile's model is re-applied on reload so live profile\n\t * edits take effect; when true, the explicit launch-time model is preserved across reloads.\n\t */\n\tisExplicitModel?: boolean;\n\t/** Whether `thinkingLevel` came from an explicit flag (see isExplicitModel). */\n\tisExplicitThinking?: boolean;\n\t/** True when this session is a spawned subagent/child — gates durable memory writes. */\n\tisChildSession?: boolean;\n\t/** Models available for cycling (Ctrl+P in interactive mode) */\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n\t/**\n\t * Optional default tool suppression mode when no explicit allowlist is provided.\n\t *\n\t * - \"all\": start with no tools enabled\n\t * - \"builtin\": disable the default built-in tools (read, bash, edit, write, context_audit,\n\t * goal, delegate, and run_toolkit_script)\n\t * but keep extension/custom tools enabled\n\t */\n\tnoTools?: \"all\" | \"builtin\";\n\t/**\n\t * Optional allowlist of tool names.\n\t *\n\t * When omitted, pi enables the shared default built-in tool surface and leaves extension/custom\n\t * tools enabled unless `noTools` changes that default.\n\t * When provided, only the listed tool names are enabled.\n\t */\n\ttools?: string[];\n\t/** Optional denylist of tool names to disable. Applies after `tools` when both are provided. */\n\texcludeTools?: string[];\n\t/** Optional resource-profile allow/block filters for tool names. */\n\ttoolProfileFilter?: ResourceProfileFilterSettings;\n\t/** Optional one-shot resource filters or complete situation profiles. Never persisted to disk. */\n\tresourceProfileDefinitions?: Record<string, ResourceProfileSettings | ProfileDefinitionInput>;\n\t/** Optional one-shot profile definitions as JSON or <resource-profile> tag text. Never persisted to disk. */\n\tresourceProfileJson?: string | string[];\n\t/** Optional runtime profile selection. Never persisted to disk. */\n\tresourceProfiles?: string[];\n\t/** Immutable owner-authored orchestration policy for this session. */\n\torchestrationProfile?: OrchestrationProfile;\n\t/** Custom tools to register (in addition to built-in tools). */\n\tcustomTools?: ToolDefinition[];\n\n\t/** Resource loader. When omitted, DefaultResourceLoader is used. */\n\tresourceLoader?: ResourceLoader;\n\n\t/** Session manager. Default: SessionManager.create(cwd, agentDir, getDefaultSessionDir(cwd, agentDir)) */\n\tsessionManager?: SessionManager;\n\n\t/** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n\tsettingsManager?: SettingsManager;\n\t/** Session start event metadata for extension runtime startup. */\n\tsessionStartEvent?: SessionStartEvent;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n\t/** The created session */\n\tsession: AgentSession;\n\t/** Extensions result (for UI context setup in interactive mode) */\n\textensionsResult: LoadExtensionsResult;\n\t/** Warning if session was restored with a different model than saved */\n\tmodelFallbackMessage?: string;\n}\n\n// Re-exports\n\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n} from \"./extensions/index.ts\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type { Tool } from \"./tools/index.ts\";\n\nexport {\n\twithFileMutationQueue,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateBashTool,\n\tcreateEditTool,\n\tcreateWriteTool,\n\tcreateGrepTool,\n\tcreateFindTool,\n\tcreateLsTool,\n};\n\n// Helper Functions\n\nfunction getDefaultAgentDir(): string {\n\treturn getAgentDir();\n}\n\nfunction getAttributionHeaders(\n\tmodel: Model<Api>,\n\tsettingsManager: SettingsManager,\n\tsessionId?: string,\n): Record<string, string> | undefined {\n\tif (\n\t\tsessionId &&\n\t\t(model.provider === \"opencode\" || model.provider === \"opencode-go\" || model.baseUrl.includes(\"opencode.ai\"))\n\t) {\n\t\treturn { \"x-opencode-session\": sessionId, \"x-opencode-client\": \"pi\" };\n\t}\n\n\tif (!isInstallTelemetryEnabled(settingsManager)) {\n\t\treturn undefined;\n\t}\n\n\tif (model.provider === \"openrouter\" || model.baseUrl.includes(\"openrouter.ai\")) {\n\t\treturn {\n\t\t\t\"HTTP-Referer\": \"https://pi.dev\",\n\t\t\t\"X-OpenRouter-Title\": \"pi\",\n\t\t\t\"X-OpenRouter-Categories\": \"cli-agent\",\n\t\t};\n\t}\n\n\tif (\n\t\tmodel.provider === \"cloudflare-workers-ai\" ||\n\t\tmodel.provider === \"cloudflare-ai-gateway\" ||\n\t\tmodel.baseUrl.includes(\"api.cloudflare.com\") ||\n\t\tmodel.baseUrl.includes(\"gateway.ai.cloudflare.com\")\n\t) {\n\t\treturn {\n\t\t\t\"User-Agent\": \"pi-coding-agent\",\n\t\t};\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Create an AgentSession with the specified options.\n *\n * @example\n * ```typescript\n * // Minimal - uses defaults\n * const { session } = await createAgentSession();\n *\n * // With explicit model\n * import { getModel } from '@caupulican/pi-ai';\n * const { session } = await createAgentSession({\n * model: getModel('anthropic', 'claude-opus-4-5'),\n * thinkingLevel: 'high',\n * });\n *\n * // Continue previous session\n * const { session, modelFallbackMessage } = await createAgentSession({\n * continueSession: true,\n * });\n *\n * // Full control\n * const loader = new DefaultResourceLoader({\n * cwd: process.cwd(),\n * agentDir: getAgentDir(),\n * settingsManager: SettingsManager.create(),\n * });\n * await loader.reload();\n * const { session } = await createAgentSession({\n * model: myModel,\n * tools: [\"read\", \"bash\"],\n * resourceLoader: loader,\n * sessionManager: SessionManager.inMemory(),\n * });\n * ```\n */\nexport async function createAgentSession(options: CreateAgentSessionOptions = {}): Promise<CreateAgentSessionResult> {\n\tconst cwd = resolvePath(options.cwd ?? options.sessionManager?.getCwd() ?? process.cwd());\n\tconst agentDir = options.agentDir ? resolvePath(options.agentDir) : getDefaultAgentDir();\n\tlet resourceLoader = options.resourceLoader;\n\n\t// Use provided or create AuthStorage and ModelRegistry\n\tconst authPath = options.agentDir ? configFile(agentDir, \"auth.json\") : undefined;\n\tconst modelsPath = options.agentDir ? configFile(agentDir, \"models.json\") : undefined;\n\tconst authStorage = options.authStorage ?? AuthStorage.create(authPath);\n\tconst modelRegistry = options.modelRegistry ?? ModelRegistry.create(authStorage, modelsPath);\n\n\tconst settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);\n\tconst isChildSession = options.isChildSession ?? process.env.PI_CHILD_SESSION === \"1\";\n\tconst forceBackgroundRequests = isChildSession || isWorkerSession();\n\tconst orchestrationProfile = options.orchestrationProfile;\n\tif (orchestrationProfile) {\n\t\tvalidateOrchestrationProfile(orchestrationProfile);\n\t\tconst conflictingOptions = [\n\t\t\t...(options.model ? [\"model\"] : []),\n\t\t\t...(options.thinkingLevel !== undefined ? [\"thinkingLevel\"] : []),\n\t\t\t...(options.scopedModels !== undefined ? [\"scopedModels\"] : []),\n\t\t\t...(options.tools !== undefined ? [\"tools\"] : []),\n\t\t\t...(options.noTools !== undefined ? [\"noTools\"] : []),\n\t\t\t...(options.excludeTools !== undefined ? [\"excludeTools\"] : []),\n\t\t\t...(options.toolProfileFilter !== undefined ? [\"toolProfileFilter\"] : []),\n\t\t\t...(options.resourceProfiles !== undefined ? [\"resourceProfiles\"] : []),\n\t\t];\n\t\tif (conflictingOptions.length > 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Orchestration profile '${orchestrationProfile.profileId}' owns model, thinking, tools, and resources; remove conflicting SDK options: ${conflictingOptions.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tsettingsManager.setRuntimeResourceProfiles([...orchestrationProfile.resourceProfileNames]);\n\t}\n\tconst needsProfileReload =\n\t\toptions.resourceProfileDefinitions !== undefined ||\n\t\toptions.resourceProfileJson !== undefined ||\n\t\toptions.resourceProfiles !== undefined ||\n\t\torchestrationProfile !== undefined;\n\tif (options.resourceProfileDefinitions) {\n\t\tsettingsManager.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\tsettingsManager.addInlineResourceProfileDefinitions(parseResourceProfileInput(input).profiles);\n\t\t}\n\t}\n\tif (!orchestrationProfile && options.resourceProfiles !== undefined) {\n\t\tsettingsManager.setRuntimeResourceProfiles(options.resourceProfiles);\n\t}\n\tconst sessionManager =\n\t\toptions.sessionManager ?? SessionManager.create(cwd, agentDir, getDefaultSessionDir(cwd, agentDir));\n\n\tif (!resourceLoader) {\n\t\tresourceLoader = new DefaultResourceLoader({ cwd, agentDir, settingsManager });\n\t\tawait resourceLoader.reload();\n\t\ttime(\"resourceLoader.reload\");\n\t} else if (needsProfileReload) {\n\t\tawait resourceLoader.reload();\n\t\ttime(\"resourceLoader.reload\");\n\t}\n\n\t// Check if session has existing data to restore\n\tconst existingSession = sessionManager.buildSessionContext();\n\tconst hasExistingSession = existingSession.messages.length > 0;\n\tconst hasThinkingEntry = sessionManager.getBranch().some((entry) => entry.type === \"thinking_level_change\");\n\n\tconst orchestrationModel = orchestrationProfile\n\t\t? resolveConfiguredOrchestrationModel(orchestrationProfile, modelRegistry)\n\t\t: undefined;\n\tif (orchestrationProfile && !orchestrationModel) {\n\t\tthrow new TypeError(\n\t\t\t`Orchestration profile '${orchestrationProfile.profileId}' has no configured, authenticated model that supports its exact thinking level.`,\n\t\t);\n\t}\n\tlet model = orchestrationModel?.model ?? options.model;\n\tlet modelFallbackMessage: string | undefined;\n\n\tlet thinkingLevel = orchestrationModel?.binding.thinkingLevel ?? options.thinkingLevel;\n\n\tconst activeProfileNames = settingsManager.getActiveResourceProfileNames();\n\tif (!orchestrationProfile && activeProfileNames.length > 0) {\n\t\tconst profileSettings = resolveProfileModelSettings({\n\t\t\tactiveProfileNames,\n\t\t\tregistry: settingsManager.getProfileRegistry(),\n\t\t\tmodelRegistry,\n\t\t\tcwd,\n\t\t});\n\t\tif (profileSettings.error) {\n\t\t\tmodelFallbackMessage = `Profile model resolution error: ${profileSettings.error}`;\n\t\t}\n\t\tif (!model && profileSettings.model) {\n\t\t\tmodel = profileSettings.model;\n\t\t}\n\t\tif (thinkingLevel === undefined && profileSettings.thinkingLevel) {\n\t\t\tthinkingLevel = profileSettings.thinkingLevel;\n\t\t}\n\t}\n\n\t// If session has data, try to restore model from it\n\tif (!model && hasExistingSession && existingSession.model) {\n\t\tconst restoredModel = modelRegistry.find(existingSession.model.provider, existingSession.model.modelId);\n\t\tif (restoredModel && modelRegistry.hasConfiguredAuth(restoredModel)) {\n\t\t\tmodel = restoredModel;\n\t\t}\n\t\tif (!model) {\n\t\t\tmodelFallbackMessage = `Could not restore model ${existingSession.model.provider}/${existingSession.model.modelId}`;\n\t\t}\n\t}\n\n\t// If still no model, use findInitialModel (checks settings default, then provider defaults)\n\tif (!model) {\n\t\tconst result = await findInitialModel({\n\t\t\tscopedModels: [],\n\t\t\tisContinuing: hasExistingSession,\n\t\t\tdefaultProvider: settingsManager.getDefaultProvider(),\n\t\t\tdefaultModelId: settingsManager.getDefaultModel(),\n\t\t\tdefaultThinkingLevel: settingsManager.getDefaultThinkingLevel(),\n\t\t\tmodelRegistry,\n\t\t});\n\t\tmodel = result.model;\n\t\tif (thinkingLevel === undefined && !(hasExistingSession && hasThinkingEntry)) {\n\t\t\tthinkingLevel = result.thinkingLevel;\n\t\t}\n\t\tif (!model) {\n\t\t\tmodelFallbackMessage = formatNoModelsAvailableMessage();\n\t\t} else if (modelFallbackMessage) {\n\t\t\tmodelFallbackMessage += `. Using ${model.provider}/${model.id}`;\n\t\t}\n\t}\n\n\t// If session has data, restore thinking level from it\n\tif (thinkingLevel === undefined && hasExistingSession) {\n\t\tthinkingLevel = hasThinkingEntry\n\t\t\t? (existingSession.thinkingLevel as ThinkingLevel)\n\t\t\t: settingsManager.getDefaultThinkingLevel();\n\t}\n\n\t// Resolve preference, model metadata, harness fallback, and capability clamping through the\n\t// same contract used by CLI startup and isolated lanes.\n\tif (!model) {\n\t\tthinkingLevel = \"off\";\n\t} else {\n\t\tthinkingLevel = resolveModelThinkingLevel(\n\t\t\tmodel,\n\t\t\tthinkingLevel ?? settingsManager.getDefaultThinkingLevel(),\n\t\t) as ThinkingLevel;\n\t}\n\n\tconst defaultActiveToolNames = [\n\t\t...DEFAULT_ACTIVE_TOOL_NAMES,\n\t\t...(settingsManager.getScoutSettings().enabled ? [\"context_scout\"] : []),\n\t];\n\tconst toolProfileFilter = orchestrationProfile\n\t\t? settingsManager.getResourceProfileFilter(\"tools\")\n\t\t: (options.toolProfileFilter ?? settingsManager.getResourceProfileFilter(\"tools\"));\n\tconst allowedToolNames = orchestrationProfile\n\t\t? [...orchestrationProfile.toolNames]\n\t\t: (options.tools ?? (options.noTools === \"all\" ? [] : undefined));\n\tconst excludedToolNames = orchestrationProfile ? undefined : options.excludeTools;\n\tconst excludedToolNameSet = excludedToolNames ? new Set(excludedToolNames) : undefined;\n\tconst initialActiveToolNames: string[] = (\n\t\torchestrationProfile\n\t\t\t? [...orchestrationProfile.toolNames]\n\t\t\t: options.tools\n\t\t\t\t? [...options.tools]\n\t\t\t\t: options.noTools\n\t\t\t\t\t? []\n\t\t\t\t\t: defaultActiveToolNames\n\t).filter((name) => !excludedToolNameSet?.has(name));\n\n\tlet agent: Agent;\n\n\t// Create convertToLlm wrapper that filters images if blockImages is enabled (defense-in-depth)\n\tconst convertToLlmWithBlockImages = (messages: AgentMessage[]): Message[] => {\n\t\tconst converted = convertToLlm(messages);\n\t\t// Check setting dynamically so mid-session changes take effect\n\t\tif (!settingsManager.getBlockImages()) {\n\t\t\treturn converted;\n\t\t}\n\t\t// Filter out ImageContent from all messages, replacing with text placeholder\n\t\treturn converted.map((msg) => {\n\t\t\tif (msg.role === \"user\" || msg.role === \"toolResult\") {\n\t\t\t\tconst content = msg.content;\n\t\t\t\tif (Array.isArray(content)) {\n\t\t\t\t\tconst hasImages = content.some((c) => c.type === \"image\");\n\t\t\t\t\tif (hasImages) {\n\t\t\t\t\t\tconst filteredContent = content\n\t\t\t\t\t\t\t.map((c) =>\n\t\t\t\t\t\t\t\tc.type === \"image\" ? { type: \"text\" as const, text: \"Image reading is disabled.\" } : c,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(c, i, arr) =>\n\t\t\t\t\t\t\t\t\t// Dedupe consecutive \"Image reading is disabled.\" texts\n\t\t\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\t\t\tc.type === \"text\" &&\n\t\t\t\t\t\t\t\t\t\tc.text === \"Image reading is disabled.\" &&\n\t\t\t\t\t\t\t\t\t\ti > 0 &&\n\t\t\t\t\t\t\t\t\t\tarr[i - 1].type === \"text\" &&\n\t\t\t\t\t\t\t\t\t\t(arr[i - 1] as { type: \"text\"; text: string }).text === \"Image reading is disabled.\"\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\treturn { ...msg, content: filteredContent };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn msg;\n\t\t});\n\t};\n\n\tconst extensionRunnerRef: { current?: ExtensionRunner } = {};\n\n\tagent = new Agent({\n\t\tinitialState: {\n\t\t\tsystemPrompt: \"\",\n\t\t\tmodel,\n\t\t\tthinkingLevel,\n\t\t\ttools: [],\n\t\t},\n\t\tconvertToLlm: convertToLlmWithBlockImages,\n\t\tstreamFn: async (model, context, options) => {\n\t\t\tconst auth = await modelRegistry.getApiKeyAndHeaders(model);\n\t\t\tif (!auth.ok) {\n\t\t\t\tthrow new Error(auth.error);\n\t\t\t}\n\t\t\tconst providerRetrySettings = settingsManager.getProviderRetrySettings();\n\t\t\tconst httpIdleTimeoutMs = settingsManager.getHttpIdleTimeoutMs();\n\t\t\t// SDKs treat timeout=0 as 0ms (immediate timeout), not \"no timeout\".\n\t\t\t// Use max int32 to effectively disable the timeout.\n\t\t\tconst effectiveTimeoutMs = httpIdleTimeoutMs === 0 ? 2147483647 : httpIdleTimeoutMs;\n\t\t\tconst timeoutMs = options?.timeoutMs ?? providerRetrySettings.timeoutMs ?? effectiveTimeoutMs;\n\t\t\tconst websocketConnectTimeoutMs =\n\t\t\t\toptions?.websocketConnectTimeoutMs ?? settingsManager.getWebSocketConnectTimeoutMs();\n\t\t\tconst attributionHeaders = getAttributionHeaders(model, settingsManager, options?.sessionId);\n\t\t\treturn streamSimple(model, context, {\n\t\t\t\t...options,\n\t\t\t\tinteractionMode: forceBackgroundRequests ? \"background\" : (options?.interactionMode ?? \"user\"),\n\t\t\t\tonInteractiveAuthRecovery: options?.onInteractiveAuthRecovery ?? recoverBedrockSsoAuthentication,\n\t\t\t\tapiKey: auth.apiKey,\n\t\t\t\tonAuthRejection:\n\t\t\t\t\tauth.apiKey && model.provider === \"openai-codex\"\n\t\t\t\t\t\t? async () => modelRegistry.recoverRejectedOAuthApiKey(model.provider, auth.apiKey as string)\n\t\t\t\t\t\t: options?.onAuthRejection,\n\t\t\t\ttimeoutMs,\n\t\t\t\twebsocketConnectTimeoutMs,\n\t\t\t\tmaxRetries: options?.maxRetries ?? providerRetrySettings.maxRetries,\n\t\t\t\tmaxRetryDelayMs: options?.maxRetryDelayMs ?? providerRetrySettings.maxRetryDelayMs,\n\t\t\t\theaders:\n\t\t\t\t\tattributionHeaders || auth.headers || options?.headers\n\t\t\t\t\t\t? { ...attributionHeaders, ...auth.headers, ...options?.headers }\n\t\t\t\t\t\t: undefined,\n\t\t\t});\n\t\t},\n\t\tonPayload: async (payload, _model) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner?.hasHandlers(\"before_provider_request\")) {\n\t\t\t\treturn payload;\n\t\t\t}\n\t\t\treturn runner.emitBeforeProviderRequest(payload);\n\t\t},\n\t\tonResponse: async (response, _model) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner?.hasHandlers(\"after_provider_response\")) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait runner.emit({\n\t\t\t\ttype: \"after_provider_response\",\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t});\n\t\t},\n\t\tsessionId: sessionManager.getSessionId(),\n\t\ttransformContext: async (messages) => {\n\t\t\tconst runner = extensionRunnerRef.current;\n\t\t\tif (!runner) return messages;\n\t\t\treturn runner.emitContext(messages);\n\t\t},\n\t\tsteeringMode: settingsManager.getSteeringMode(),\n\t\tfollowUpMode: settingsManager.getFollowUpMode(),\n\t\ttransport: settingsManager.getTransport(),\n\t\tthinkingBudgets: settingsManager.getThinkingBudgets(),\n\t\tmaxRetryDelayMs: settingsManager.getProviderRetrySettings().maxRetryDelayMs,\n\t\tmaxStallTurns: settingsManager.getAutonomySettings().maxStallTurns,\n\t});\n\n\t// Restore messages if session has existing data\n\tif (hasExistingSession) {\n\t\tagent.state.messages = existingSession.messages;\n\t\tif (!hasThinkingEntry) {\n\t\t\tsessionManager.appendThinkingLevelChange(thinkingLevel);\n\t\t}\n\t} else {\n\t\t// Save initial model and thinking level for new sessions so they can be restored on resume\n\t\tif (model) {\n\t\t\tsessionManager.appendModelChange(model.provider, model.id);\n\t\t}\n\t\tsessionManager.appendThinkingLevelChange(thinkingLevel);\n\t}\n\n\tconst session = new AgentSession({\n\t\tagent,\n\t\tsessionManager,\n\t\tsettingsManager,\n\t\tcwd,\n\t\tagentDir,\n\t\tscopedModels: orchestrationModel\n\t\t\t? [{ model: orchestrationModel.model, thinkingLevel: orchestrationModel.binding.thinkingLevel }]\n\t\t\t: options.scopedModels,\n\t\tresourceLoader,\n\t\tcustomTools: options.customTools,\n\t\tmodelRegistry,\n\t\tinitialActiveToolNames,\n\t\tallowedToolNames,\n\t\texcludedToolNames,\n\t\textensionRunnerRef,\n\t\ttoolProfileFilter,\n\t\tisExplicitModel: orchestrationProfile ? true : (options.isExplicitModel ?? options.model != null),\n\t\tisExplicitThinking: orchestrationProfile\n\t\t\t? true\n\t\t\t: (options.isExplicitThinking ?? options.thinkingLevel !== undefined),\n\t\tisChildSession,\n\t\torchestrationProfile,\n\t\tsessionStartEvent: options.sessionStartEvent,\n\t});\n\ttry {\n\t\t// The initial runtime has now bound providers from profile-granted extensions. Re-resolve the\n\t\t// profile model against that authoritative registry generation, then resync model capability.\n\t\tawait session.reapplyActiveProfileModelSettings();\n\t\tif (modelFallbackMessage?.startsWith(\"Profile model resolution error:\")) {\n\t\t\tmodelFallbackMessage = undefined;\n\t\t}\n\t} catch (error) {\n\t\t// Preserve the established non-fatal fallback for a genuinely unresolved profile model.\n\t\tif (!modelFallbackMessage?.startsWith(\"Profile model resolution error:\")) {\n\t\t\tawait session.disposeAndWait();\n\t\t\tthrow error;\n\t\t}\n\t}\n\tconst extensionsResult = resourceLoader.getExtensions();\n\n\treturn {\n\t\tsession,\n\t\textensionsResult,\n\t\tmodelFallbackMessage,\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-exposure-guard.d.ts","sourceRoot":"","sources":["../../../src/core/secrets/credential-exposure-guard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsBrD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CA8BpG;AAgFD,yFAAyF;AACzF,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,WAAW,GACjB,MAAM,GAAG,SAAS,CAqDpB;AAuCD,wGAAwG;AACxG,wBAAgB,mCAAmC,CAAC,WAAW,SAAS,OAAO,EAAE,QAAQ,EACxF,IAAI,EAAE,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,EACtC,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,WAAW,GACjB,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,CAqBlC","sourcesContent":["import { realpathSync, statSync } from \"node:fs\";\nimport { basename, isAbsolute, relative, resolve, sep } from \"node:path\";\nimport type { AgentTool, AgentToolResult } from \"@caupulican/pi-agent-core\";\nimport type { TSchema } from \"typebox\";\nimport { redactKnownSecrets } from \"../security/secret-text.ts\";\nimport type { SecretVault } from \"./secret-vault.ts\";\n\nconst DIRECT_PATH_TOOLS = new Set([\"read\", \"edit\", \"write\", \"ls\"]);\nconst SHELL_INSPECTION_COMMAND_RE =\n\t/\\b(cat|head|tail|less|more|sed|awk|grep|rg|type|get-content|select-string|source)\\b([^\\n;&|]*)/gi;\nconst SHELL_SECRET_READ_RE =\n\t/\\b(?:cat|head|tail|less|more|sed|awk|grep|rg|type|get-content|select-string|source)\\b[^\\n;&|]*(?:^|[\\\\/])?\\.env(?:\\.[A-Za-z0-9._-]+)?\\b/i;\nconst PYTHON_SECRET_READ_RE = /\\b(?:open|read_text|read_bytes)\\s*\\([^\\n)]*(?:^|[\\\\/])?\\.env(?:\\.[A-Za-z0-9._-]+)?\\b/i;\nconst PYTHON_INSPECTION_RE = /\\b(?:open|read_text|read_bytes)\\b/;\nconst QUOTED_TEXT_RE = /([\"'])([^\"'\\\\]*(?:\\\\.[^\"'\\\\]*)*)\\1/g;\nconst MAX_REDACTED_DETAIL_DEPTH = 8;\nconst MAX_REDACTED_DETAIL_NODES = 10_000;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isInside(root: string, target: string): boolean {\n\tconst fromRoot = relative(root, target);\n\treturn fromRoot === \"\" || (!fromRoot.startsWith(`..${sep}`) && fromRoot !== \"..\" && !isAbsolute(fromRoot));\n}\n\nexport function isProtectedCredentialPath(rawPath: string, cwd: string, vault?: SecretVault): boolean {\n\tconst resolved = resolve(cwd, rawPath);\n\tconst candidates = [resolved];\n\ttry {\n\t\tconst canonical = realpathSync.native(resolved);\n\t\tif (canonical !== resolved) candidates.push(canonical);\n\t} catch {\n\t\t// Nonexistent write targets still receive the lexical filename check.\n\t}\n\tconst vaultPaths = vault ? [resolve(vault.vaultPath)] : [];\n\tconst materializedRoots = vault ? [resolve(vault.materializedDir)] : [];\n\tif (vault) {\n\t\ttry {\n\t\t\tvaultPaths.push(realpathSync.native(vault.vaultPath));\n\t\t} catch {\n\t\t\t// A not-yet-created vault still retains its lexical protected path.\n\t\t}\n\t\ttry {\n\t\t\tmaterializedRoots.push(realpathSync.native(vault.materializedDir));\n\t\t} catch {\n\t\t\t// A not-yet-created materialization directory still retains its lexical protected root.\n\t\t}\n\t}\n\treturn candidates.some((candidate) => {\n\t\tif (vault && (vaultPaths.includes(candidate) || materializedRoots.some((root) => isInside(root, candidate)))) {\n\t\t\treturn true;\n\t\t}\n\t\tconst fileName = basename(candidate);\n\t\treturn fileName === \".env\" || fileName.startsWith(\".env.\") || fileName.endsWith(\".env\");\n\t});\n}\n\nfunction shellCredentialRisk(\n\tcommand: string,\n\tcwd: string,\n\tvault?: SecretVault,\n): \"broad_search\" | \"credential_path\" | undefined {\n\tSHELL_INSPECTION_COMMAND_RE.lastIndex = 0;\n\tfor (const match of command.matchAll(SHELL_INSPECTION_COMMAND_RE)) {\n\t\tconst toolName = (match[1] ?? \"\").toLowerCase();\n\t\tconst tokens = (match[2] ?? \"\").match(/\"[^\"]*\"|'[^']*'|\\S+/g) ?? [];\n\t\tfor (const rawToken of tokens) {\n\t\t\tconst token = rawToken.replace(/^[\"']|[\"']$/g, \"\");\n\t\t\tif (!token || token.startsWith(\"-\") || token === \".\") continue;\n\t\t\tif (isProtectedCredentialPath(token, cwd, vault)) return \"credential_path\";\n\t\t}\n\t\tif ((toolName === \"grep\" || toolName === \"rg\") && !shellSearchHasCredentialSafeScope(tokens, cwd)) {\n\t\t\treturn \"broad_search\";\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction isCredentialSafeGlob(glob: string): boolean {\n\tif (/(?:^|[\\\\/])?\\.env(?:\\.|\\*|$)/i.test(glob)) return false;\n\tconst filePattern = glob.replace(/\\\\/g, \"/\").split(\"/\").at(-1) ?? \"\";\n\tconst suffix = filePattern.match(/\\.([A-Za-z0-9_-]+)$/)?.[1]?.toLowerCase();\n\treturn suffix !== undefined && suffix !== \"env\";\n}\n\nfunction isExistingRegularFile(rawPath: string, cwd: string): boolean {\n\ttry {\n\t\treturn statSync(resolve(cwd, rawPath)).isFile();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction shellSearchHasCredentialSafeScope(rawTokens: readonly string[], cwd: string): boolean {\n\tconst tokens = rawTokens.map((token) => token.replace(/^[\"']|[\"']$/g, \"\"));\n\tconst positiveGlobs: string[] = [];\n\tfor (let index = 0; index < tokens.length; index++) {\n\t\tconst token = tokens[index] ?? \"\";\n\t\tif (token === \"-g\" || token === \"--glob\") {\n\t\t\tconst glob = tokens[++index];\n\t\t\tif (glob && !glob.startsWith(\"!\")) positiveGlobs.push(glob);\n\t\t} else if (token.startsWith(\"--glob=\")) {\n\t\t\tconst glob = token.slice(\"--glob=\".length);\n\t\t\tif (glob && !glob.startsWith(\"!\")) positiveGlobs.push(glob);\n\t\t}\n\t}\n\tif (positiveGlobs.length > 0) return positiveGlobs.every(isCredentialSafeGlob);\n\n\tlet skippedPattern = false;\n\tfor (const token of tokens) {\n\t\tif (!token || token.startsWith(\"-\")) continue;\n\t\tif (!skippedPattern) {\n\t\t\tskippedPattern = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isExistingRegularFile(token, cwd)) return true;\n\t}\n\treturn false;\n}\n\nfunction pythonInspectsCredentialPath(code: string, cwd: string, vault?: SecretVault): boolean {\n\tif (!PYTHON_INSPECTION_RE.test(code)) return false;\n\tQUOTED_TEXT_RE.lastIndex = 0;\n\tfor (const match of code.matchAll(QUOTED_TEXT_RE)) {\n\t\tconst candidate = match[2]?.replace(/\\\\([\\\\\"'])/g, \"$1\");\n\t\tif (candidate && isProtectedCredentialPath(candidate, cwd, vault)) return true;\n\t}\n\treturn false;\n}\n\nfunction directPathFromArgs(args: unknown): string | undefined {\n\tif (!isRecord(args)) return undefined;\n\treturn typeof args.path === \"string\" ? args.path : undefined;\n}\n\n/** Stable model-facing refusal for direct inspection/mutation of credential material. */\nexport function credentialToolBlockReason(\n\ttoolName: string,\n\targs: unknown,\n\tcwd: string,\n\tvault?: SecretVault,\n): string | undefined {\n\tif (toolName === \"secret_store\" || !isRecord(args)) return undefined;\n\tif (DIRECT_PATH_TOOLS.has(toolName)) {\n\t\tconst path = directPathFromArgs(args);\n\t\tif (path && isProtectedCredentialPath(path, cwd, vault)) {\n\t\t\treturn \"Credential file access is model-blind. Use secret_store to edit or materialize the bound profile, then run the consuming application without inspecting the dotenv file.\";\n\t\t}\n\t}\n\tif (toolName === \"grep\") {\n\t\tconst path = typeof args.path === \"string\" ? args.path : undefined;\n\t\tconst glob = typeof args.glob === \"string\" ? args.glob : undefined;\n\t\tif (\n\t\t\t(path && isProtectedCredentialPath(path, cwd, vault)) ||\n\t\t\t(glob && /(?:^|[\\\\/])?\\.env(?:\\.|\\*|$)/i.test(glob))\n\t\t) {\n\t\t\treturn \"Credential dotenv files are excluded from model-facing search. Use secret_store metadata instead.\";\n\t\t}\n\t\tif (!(path && isExistingRegularFile(path, cwd)) && !(glob && isCredentialSafeGlob(glob))) {\n\t\t\treturn \"Credential-safe grep requires one explicit regular file or a narrow non-dotenv file glob (for example *.ts). Refine the search instead of scanning a directory without a file filter.\";\n\t\t}\n\t}\n\tif (toolName === \"find\") {\n\t\tconst path = typeof args.path === \"string\" ? args.path : undefined;\n\t\tconst pattern = typeof args.pattern === \"string\" ? args.pattern : undefined;\n\t\tif (\n\t\t\t(path && isProtectedCredentialPath(path, cwd, vault)) ||\n\t\t\t(pattern && /(?:^|[\\\\/])?\\.env(?:\\.|\\*|$)/i.test(pattern))\n\t\t) {\n\t\t\treturn \"Credential dotenv files are excluded from model-facing discovery. Use secret_store list instead.\";\n\t\t}\n\t}\n\tif (toolName === \"bash\" || toolName === \"powershell\" || toolName === \"run_process\") {\n\t\tconst command = typeof args.command === \"string\" ? args.command : \"\";\n\t\tconst shellRisk = shellCredentialRisk(command, cwd, vault);\n\t\tif (shellRisk === \"broad_search\") {\n\t\t\treturn \"Credential-safe shell search requires a narrow non-dotenv file glob (for example -g '*.ts') or one explicit regular file. Refine the rg/grep command before retrying.\";\n\t\t}\n\t\tif (SHELL_SECRET_READ_RE.test(command) || shellRisk === \"credential_path\") {\n\t\t\treturn \"Direct shell inspection of credential dotenv files is blocked. Use secret_store, then run the credential-consuming command normally.\";\n\t\t}\n\t}\n\tif (toolName === \"python\") {\n\t\tconst code = typeof args.code === \"string\" ? args.code : \"\";\n\t\tconst scriptPath = typeof args.scriptPath === \"string\" ? args.scriptPath : undefined;\n\t\tif (\n\t\t\tPYTHON_SECRET_READ_RE.test(code) ||\n\t\t\tpythonInspectsCredentialPath(code, cwd, vault) ||\n\t\t\t(scriptPath !== undefined && isProtectedCredentialPath(scriptPath, cwd, vault))\n\t\t) {\n\t\t\treturn \"Direct Python inspection of credential dotenv files is blocked. Use secret_store, then run the credential-consuming program normally.\";\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction redactResult<T>(result: AgentToolResult<T>, vault?: SecretVault): AgentToolResult<T> {\n\tconst redact = (text: string) => (vault ? vault.redactSensitiveText(text) : redactKnownSecrets(text));\n\tconst budget = { nodes: 0 };\n\treturn {\n\t\t...result,\n\t\tcontent: result.content.map((block) => (block.type === \"text\" ? { ...block, text: redact(block.text) } : block)),\n\t\tdetails: redactStructuredDetails(result.details, redact, budget) as T,\n\t};\n}\n\nfunction redactStructuredDetails(\n\tvalue: unknown,\n\tredact: (text: string) => string,\n\tbudget: { nodes: number },\n\tdepth = 0,\n): unknown {\n\tif (typeof value === \"string\") return redact(value);\n\tif (value === null || typeof value !== \"object\") return value;\n\tbudget.nodes++;\n\tif (depth >= MAX_REDACTED_DETAIL_DEPTH || budget.nodes > MAX_REDACTED_DETAIL_NODES) {\n\t\treturn \"[DETAIL OMITTED AT CREDENTIAL BOUNDARY]\";\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn value.map((entry) => redactStructuredDetails(entry, redact, budget, depth + 1));\n\t}\n\tlet prototype: object | null;\n\ttry {\n\t\tprototype = Object.getPrototypeOf(value);\n\t} catch {\n\t\treturn \"[UNREADABLE DETAIL OMITTED AT CREDENTIAL BOUNDARY]\";\n\t}\n\tif (prototype !== Object.prototype && prototype !== null) return value;\n\treturn Object.fromEntries(\n\t\tObject.entries(value).map(([key, entry]) => [key, redactStructuredDetails(entry, redact, budget, depth + 1)]),\n\t);\n}\n\n/** Apply the same path refusal and output redaction to foreground, extension, scout, and lane tools. */\nexport function wrapToolWithCredentialExposureGuard<TParameters extends TSchema, TDetails>(\n\ttool: AgentTool<TParameters, TDetails>,\n\tcwd: string,\n\tvault?: SecretVault,\n): AgentTool<TParameters, TDetails> {\n\treturn {\n\t\t...tool,\n\t\tasync execute(toolCallId, params, signal, onUpdate) {\n\t\t\tconst refusal = credentialToolBlockReason(tool.name, params, cwd, vault);\n\t\t\tif (refusal) throw new Error(refusal);\n\t\t\tconst safeUpdate = onUpdate\n\t\t\t\t? (partial: AgentToolResult<TDetails>) => {\n\t\t\t\t\t\tonUpdate(redactResult(partial, vault));\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t\ttry {\n\t\t\t\treturn redactResult(await tool.execute(toolCallId, params, signal, safeUpdate), vault);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error) {\n\t\t\t\t\tthrow new Error(vault ? vault.redactSensitiveText(error.message) : redactKnownSecrets(error.message));\n\t\t\t\t}\n\t\t\t\tthrow new Error(\"Credential-safe tool execution failed without retaining raw error output.\");\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"credential-exposure-guard.d.ts","sourceRoot":"","sources":["../../../src/core/secrets/credential-exposure-guard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsCrD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CA8BpG;AAyHD,yFAAyF;AACzF,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,WAAW,GACjB,MAAM,GAAG,SAAS,CAwDpB;AAuCD,wGAAwG;AACxG,wBAAgB,mCAAmC,CAAC,WAAW,SAAS,OAAO,EAAE,QAAQ,EACxF,IAAI,EAAE,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,EACtC,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,WAAW,GACjB,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,CAqBlC"}
|
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
import { realpathSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { redactKnownSecrets } from "../security/secret-text.js";
|
|
4
|
+
import { parseShellSearchInvocationScope } from "../tools/search-command-guard.js";
|
|
5
|
+
import { tokenizeShellCommand } from "../tools/shell-command-parser.js";
|
|
4
6
|
const DIRECT_PATH_TOOLS = new Set(["read", "edit", "write", "ls"]);
|
|
5
|
-
const
|
|
7
|
+
const SHELL_INSPECTION_COMMANDS = new Set([
|
|
8
|
+
"cat",
|
|
9
|
+
"head",
|
|
10
|
+
"tail",
|
|
11
|
+
"less",
|
|
12
|
+
"more",
|
|
13
|
+
"sed",
|
|
14
|
+
"awk",
|
|
15
|
+
"grep",
|
|
16
|
+
"rg",
|
|
17
|
+
"ripgrep",
|
|
18
|
+
"type",
|
|
19
|
+
"get-content",
|
|
20
|
+
"select-string",
|
|
21
|
+
"source",
|
|
22
|
+
]);
|
|
6
23
|
const SHELL_SECRET_READ_RE = /\b(?:cat|head|tail|less|more|sed|awk|grep|rg|type|get-content|select-string|source)\b[^\n;&|]*(?:^|[\\/])?\.env(?:\.[A-Za-z0-9._-]+)?\b/i;
|
|
7
24
|
const PYTHON_SECRET_READ_RE = /\b(?:open|read_text|read_bytes)\s*\([^\n)]*(?:^|[\\/])?\.env(?:\.[A-Za-z0-9._-]+)?\b/i;
|
|
8
25
|
const PYTHON_INSPECTION_RE = /\b(?:open|read_text|read_bytes)\b/;
|
|
9
26
|
const QUOTED_TEXT_RE = /(["'])([^"'\\]*(?:\\.[^"'\\]*)*)\1/g;
|
|
10
27
|
const MAX_REDACTED_DETAIL_DEPTH = 8;
|
|
11
28
|
const MAX_REDACTED_DETAIL_NODES = 10_000;
|
|
29
|
+
const JQ_OPTIONS_WITH_ONE_OPERAND = new Set(["-L", "--indent"]);
|
|
30
|
+
const JQ_OPTIONS_WITH_TWO_OPERANDS = new Set(["--arg", "--argjson", "--rawfile", "--slurpfile"]);
|
|
12
31
|
function isRecord(value) {
|
|
13
32
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
33
|
}
|
|
@@ -52,23 +71,90 @@ export function isProtectedCredentialPath(rawPath, cwd, vault) {
|
|
|
52
71
|
});
|
|
53
72
|
}
|
|
54
73
|
function shellCredentialRisk(command, cwd, vault) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
for (
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
74
|
+
const shellTokens = tokenizeShellCommand(command);
|
|
75
|
+
if (!shellTokens)
|
|
76
|
+
return /\b(?:grep|rg)\b/iu.test(command) ? "broad_search" : undefined;
|
|
77
|
+
const assessInvocation = (invocation, readsPipe) => {
|
|
78
|
+
for (let commandIndex = 0; commandIndex < invocation.length; commandIndex++) {
|
|
79
|
+
const toolName = (invocation[commandIndex].split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.exe$/u, "");
|
|
80
|
+
if (toolName === "jq") {
|
|
81
|
+
const filter = jqFilterFromArgs(invocation.slice(commandIndex + 1));
|
|
82
|
+
if (filter && jqFilterReadsProcessEnvironment(filter))
|
|
83
|
+
return "process_environment";
|
|
84
|
+
}
|
|
85
|
+
if (!SHELL_INSPECTION_COMMANDS.has(toolName))
|
|
86
|
+
continue;
|
|
87
|
+
const args = invocation.slice(commandIndex + 1);
|
|
88
|
+
const searchTool = toolName === "rg" || toolName === "ripgrep" ? "rg" : toolName === "grep" ? "grep" : undefined;
|
|
89
|
+
if (searchTool) {
|
|
90
|
+
const scope = parseShellSearchInvocationScope(searchTool, args, readsPipe);
|
|
91
|
+
if (scope.targets.some((target) => target !== "-" && isProtectedCredentialPath(target, cwd, vault))) {
|
|
92
|
+
return "credential_path";
|
|
93
|
+
}
|
|
94
|
+
const hasSafeGlob = scope.positiveGlobs.length > 0 && scope.positiveGlobs.every((glob) => isCredentialSafeGlob(glob));
|
|
95
|
+
const hasOnlyExplicitFiles = scope.targets.length > 0 &&
|
|
96
|
+
scope.targets.every((target) => target === "-" || isExistingRegularFile(target, cwd));
|
|
97
|
+
if (!scope.metaOnly && !scope.readsStdin && !hasSafeGlob && !hasOnlyExplicitFiles)
|
|
98
|
+
return "broad_search";
|
|
62
99
|
continue;
|
|
63
|
-
|
|
64
|
-
|
|
100
|
+
}
|
|
101
|
+
for (const token of args) {
|
|
102
|
+
if (!token || token.startsWith("-") || token === ".")
|
|
103
|
+
continue;
|
|
104
|
+
if (isProtectedCredentialPath(token, cwd, vault))
|
|
105
|
+
return "credential_path";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
};
|
|
110
|
+
let invocation = [];
|
|
111
|
+
let skipRedirectTarget = false;
|
|
112
|
+
let readsPipe = false;
|
|
113
|
+
for (const token of shellTokens) {
|
|
114
|
+
if (token.kind === "arg") {
|
|
115
|
+
if (skipRedirectTarget)
|
|
116
|
+
skipRedirectTarget = false;
|
|
117
|
+
else
|
|
118
|
+
invocation.push(token.value);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (token.kind === "redirect") {
|
|
122
|
+
// Descriptor duplication (`2>&1`) has no following path operand. Other
|
|
123
|
+
// redirects do, and that target must never count as search scope.
|
|
124
|
+
skipRedirectTarget = !/^\d*[<>]&[\d-]+$/u.test(token.value);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const risk = assessInvocation(invocation, readsPipe);
|
|
128
|
+
if (risk)
|
|
129
|
+
return risk;
|
|
130
|
+
invocation = [];
|
|
131
|
+
skipRedirectTarget = false;
|
|
132
|
+
readsPipe = token.kind === "pipe";
|
|
133
|
+
}
|
|
134
|
+
return assessInvocation(invocation, readsPipe);
|
|
135
|
+
}
|
|
136
|
+
function jqFilterFromArgs(args) {
|
|
137
|
+
for (let index = 0; index < args.length; index++) {
|
|
138
|
+
const token = args[index];
|
|
139
|
+
if (token === "--")
|
|
140
|
+
return args[index + 1];
|
|
141
|
+
if (JQ_OPTIONS_WITH_TWO_OPERANDS.has(token)) {
|
|
142
|
+
index += 2;
|
|
143
|
+
continue;
|
|
65
144
|
}
|
|
66
|
-
if ((
|
|
67
|
-
|
|
145
|
+
if (JQ_OPTIONS_WITH_ONE_OPERAND.has(token)) {
|
|
146
|
+
index++;
|
|
147
|
+
continue;
|
|
68
148
|
}
|
|
149
|
+
if (token.startsWith("-"))
|
|
150
|
+
continue;
|
|
151
|
+
return token;
|
|
69
152
|
}
|
|
70
153
|
return undefined;
|
|
71
154
|
}
|
|
155
|
+
function jqFilterReadsProcessEnvironment(filter) {
|
|
156
|
+
return /(?:^|[\s|,(:;[])(?:env|\$ENV)(?=$|[\s|),.;[\]}])/u.test(filter);
|
|
157
|
+
}
|
|
72
158
|
function isCredentialSafeGlob(glob) {
|
|
73
159
|
if (/(?:^|[\\/])?\.env(?:\.|\*|$)/i.test(glob))
|
|
74
160
|
return false;
|
|
@@ -84,37 +170,6 @@ function isExistingRegularFile(rawPath, cwd) {
|
|
|
84
170
|
return false;
|
|
85
171
|
}
|
|
86
172
|
}
|
|
87
|
-
function shellSearchHasCredentialSafeScope(rawTokens, cwd) {
|
|
88
|
-
const tokens = rawTokens.map((token) => token.replace(/^["']|["']$/g, ""));
|
|
89
|
-
const positiveGlobs = [];
|
|
90
|
-
for (let index = 0; index < tokens.length; index++) {
|
|
91
|
-
const token = tokens[index] ?? "";
|
|
92
|
-
if (token === "-g" || token === "--glob") {
|
|
93
|
-
const glob = tokens[++index];
|
|
94
|
-
if (glob && !glob.startsWith("!"))
|
|
95
|
-
positiveGlobs.push(glob);
|
|
96
|
-
}
|
|
97
|
-
else if (token.startsWith("--glob=")) {
|
|
98
|
-
const glob = token.slice("--glob=".length);
|
|
99
|
-
if (glob && !glob.startsWith("!"))
|
|
100
|
-
positiveGlobs.push(glob);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (positiveGlobs.length > 0)
|
|
104
|
-
return positiveGlobs.every(isCredentialSafeGlob);
|
|
105
|
-
let skippedPattern = false;
|
|
106
|
-
for (const token of tokens) {
|
|
107
|
-
if (!token || token.startsWith("-"))
|
|
108
|
-
continue;
|
|
109
|
-
if (!skippedPattern) {
|
|
110
|
-
skippedPattern = true;
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (isExistingRegularFile(token, cwd))
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
173
|
function pythonInspectsCredentialPath(code, cwd, vault) {
|
|
119
174
|
if (!PYTHON_INSPECTION_RE.test(code))
|
|
120
175
|
return false;
|
|
@@ -166,6 +221,9 @@ export function credentialToolBlockReason(toolName, args, cwd, vault) {
|
|
|
166
221
|
if (shellRisk === "broad_search") {
|
|
167
222
|
return "Credential-safe shell search requires a narrow non-dotenv file glob (for example -g '*.ts') or one explicit regular file. Refine the rg/grep command before retrying.";
|
|
168
223
|
}
|
|
224
|
+
if (shellRisk === "process_environment") {
|
|
225
|
+
return "Direct jq projection of the process environment is blocked because it can expose credentials. Query bounded JSON inputs instead.";
|
|
226
|
+
}
|
|
169
227
|
if (SHELL_SECRET_READ_RE.test(command) || shellRisk === "credential_path") {
|
|
170
228
|
return "Direct shell inspection of credential dotenv files is blocked. Use secret_store, then run the credential-consuming command normally.";
|
|
171
229
|
}
|