@bastani/atomic 0.9.8 → 0.9.9-alpha.2
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 +36 -0
- package/dist/builtin/cursor/CHANGELOG.md +12 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +13 -0
- package/dist/builtin/intercom/package.json +3 -3
- package/dist/builtin/mcp/CHANGELOG.md +13 -0
- package/dist/builtin/mcp/package.json +4 -4
- package/dist/builtin/subagents/CHANGELOG.md +13 -0
- package/dist/builtin/subagents/package.json +5 -5
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +7 -1
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +8 -2
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +2 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +6 -0
- package/dist/builtin/subagents/src/shared/types-config.ts +4 -0
- package/dist/builtin/subagents/src/shared/types-depth.ts +29 -2
- package/dist/builtin/web-access/CHANGELOG.md +13 -0
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/web-access/web-search-tool.ts +1 -2
- package/dist/builtin/workflows/CHANGELOG.md +29 -0
- package/dist/builtin/workflows/README.md +17 -8
- package/dist/builtin/workflows/builtin/goal-prompts.ts +8 -2
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +26 -9
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +1 -1
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +8 -3
- package/dist/builtin/workflows/builtin/ralph-runner.ts +2 -0
- package/dist/builtin/workflows/builtin/shared-prompts.ts +24 -1
- package/dist/builtin/workflows/package.json +3 -3
- package/dist/builtin/workflows/src/durable/backend.ts +53 -15
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +245 -0
- package/dist/builtin/workflows/src/durable/completed-inspection.ts +213 -0
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +120 -170
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +84 -8
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +98 -0
- package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +27 -0
- package/dist/builtin/workflows/src/durable/factory.ts +1 -1
- package/dist/builtin/workflows/src/durable/file-backend.ts +247 -241
- package/dist/builtin/workflows/src/durable/file-lock.ts +153 -0
- package/dist/builtin/workflows/src/durable/file-state.ts +104 -0
- package/dist/builtin/workflows/src/durable/format-version.ts +12 -0
- package/dist/builtin/workflows/src/durable/index.ts +12 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +16 -27
- package/dist/builtin/workflows/src/durable/resume-eligibility.ts +20 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +29 -29
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +20 -3
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +29 -8
- package/dist/builtin/workflows/src/durable/types.ts +3 -0
- package/dist/builtin/workflows/src/engine/primitives/task.ts +1 -0
- package/dist/builtin/workflows/src/engine/run.ts +14 -14
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +39 -9
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +10 -0
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +133 -0
- package/dist/builtin/workflows/src/extension/runtime.ts +15 -40
- package/dist/builtin/workflows/src/extension/wiring.ts +9 -6
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +226 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +1 -0
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +66 -112
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +5 -5
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +16 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +50 -43
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-output.ts +91 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +95 -46
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +3 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +3 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +36 -7
- package/dist/builtin/workflows/src/runs/shared/worktree-cache-lifecycle.ts +25 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-cwd.ts +103 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-generation.ts +57 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +134 -8
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -0
- package/dist/builtin/workflows/src/shared/resumable-workflow-notices.ts +43 -0
- package/dist/builtin/workflows/src/shared/serializable.ts +1 -1
- package/dist/builtin/workflows/src/shared/timing.ts +4 -0
- package/dist/builtin/workflows/src/shared/types.ts +5 -3
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +1 -0
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +24 -14
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +43 -13
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/internal-intercom-broker.d.ts.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/split-loader.d.ts.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/project-trust.d.ts.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/config-self-update.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +5 -7
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +6 -34
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +95 -233
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +0 -4
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +1 -5
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +5 -6
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-skill-block.d.ts.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -12
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
- package/dist/core/async/format.d.ts.map +1 -1
- package/dist/core/async/job-manager.d.ts.map +1 -1
- package/dist/core/async/session-manager.d.ts.map +1 -1
- package/dist/core/async/types.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-storage-backends.d.ts.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts +9 -0
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -0
- package/dist/core/compaction/compaction-boundary.js +115 -0
- package/dist/core/compaction/compaction-boundary.js.map +1 -0
- package/dist/core/compaction/compaction-parameters.d.ts +5 -0
- package/dist/core/compaction/compaction-parameters.d.ts.map +1 -0
- package/dist/core/compaction/compaction-parameters.js +27 -0
- package/dist/core/compaction/compaction-parameters.js.map +1 -0
- package/dist/core/compaction/compaction-runner.d.ts +14 -0
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -0
- package/dist/core/compaction/compaction-runner.js +29 -0
- package/dist/core/compaction/compaction-runner.js.map +1 -0
- package/dist/core/compaction/compaction-types.d.ts +79 -0
- package/dist/core/compaction/compaction-types.d.ts.map +1 -0
- package/dist/core/compaction/compaction-types.js +6 -0
- package/dist/core/compaction/compaction-types.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/deleted-ranges.d.ts +6 -0
- package/dist/core/compaction/deleted-ranges.d.ts.map +1 -0
- package/dist/core/compaction/deleted-ranges.js +134 -0
- package/dist/core/compaction/deleted-ranges.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -1
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +7 -1
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/range-planner.d.ts +21 -0
- package/dist/core/compaction/range-planner.d.ts.map +1 -0
- package/dist/core/compaction/range-planner.js +145 -0
- package/dist/core/compaction/range-planner.js.map +1 -0
- package/dist/core/compaction/transcript-serialization.d.ts +11 -0
- package/dist/core/compaction/transcript-serialization.d.ts.map +1 -0
- package/dist/core/compaction/transcript-serialization.js +104 -0
- package/dist/core/compaction/transcript-serialization.js.map +1 -0
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/context-window.d.ts.map +1 -1
- package/dist/core/copilot-anthropic-sse-repair.d.ts.map +1 -1
- package/dist/core/copilot-errors.d.ts.map +1 -1
- package/dist/core/copilot-gemini-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
- package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
- package/dist/core/copilot-hosts.d.ts.map +1 -1
- package/dist/core/copilot-model-catalog.d.ts.map +1 -1
- package/dist/core/copilot-model-static-fallbacks.d.ts.map +1 -1
- package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/template-script.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/command-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.d.ts +2 -2
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +2 -2
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-discovery.d.ts.map +1 -1
- package/dist/core/extensions/loader-resources.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/message-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-handlers.d.ts.map +1 -1
- package/dist/core/extensions/runner-project-trust.d.ts.map +1 -1
- package/dist/core/extensions/runner-registries.d.ts.map +1 -1
- package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
- package/dist/core/extensions/runner-ui.d.ts.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/session-events.d.ts +7 -7
- package/dist/core/extensions/session-events.d.ts.map +1 -1
- package/dist/core/extensions/session-events.js.map +1 -1
- package/dist/core/extensions/tool-events.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/messages.d.ts +4 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +11 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry-auth.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
- package/dist/core/model-registry-custom-loader.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.d.ts +65 -13
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +5 -1
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-patterns.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-types.d.ts.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
- package/dist/core/package-manager-command.d.ts.map +1 -1
- package/dist/core/package-manager-constants.d.ts.map +1 -1
- package/dist/core/package-manager-env.d.ts.map +1 -1
- package/dist/core/package-manager-git.d.ts.map +1 -1
- package/dist/core/package-manager-manifest.d.ts.map +1 -1
- package/dist/core/package-manager-npm.d.ts.map +1 -1
- package/dist/core/package-manager-operations.d.ts.map +1 -1
- package/dist/core/package-manager-paths.d.ts.map +1 -1
- package/dist/core/package-manager-progress.d.ts.map +1 -1
- package/dist/core/package-manager-resolver.d.ts.map +1 -1
- package/dist/core/package-manager-resource-accumulator.d.ts.map +1 -1
- package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
- package/dist/core/package-manager-resource-files.d.ts.map +1 -1
- package/dist/core/package-manager-resource-patterns.d.ts.map +1 -1
- package/dist/core/package-manager-settings.d.ts.map +1 -1
- package/dist/core/package-manager-source.d.ts.map +1 -1
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/prompt-templates-async.d.ts.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-context-usage.d.ts.map +1 -1
- package/dist/core/provider-context-usage.js +1 -2
- package/dist/core/provider-context-usage.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-discovery.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-helpers.d.ts.map +1 -1
- package/dist/core/resource-loader-internals.d.ts.map +1 -1
- package/dist/core/resource-loader-package-resources.d.ts.map +1 -1
- package/dist/core/resource-loader-paths.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-source-info.d.ts.map +1 -1
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/sdk-exports.d.ts.map +1 -1
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-entry-normalization.d.ts.map +1 -1
- package/dist/core/session-manager-archive.d.ts +2 -1
- package/dist/core/session-manager-archive.d.ts.map +1 -1
- package/dist/core/session-manager-archive.js +2 -2
- package/dist/core/session-manager-archive.js.map +1 -1
- package/dist/core/session-manager-classification.d.ts +9 -0
- package/dist/core/session-manager-classification.d.ts.map +1 -0
- package/dist/core/session-manager-classification.js +37 -0
- package/dist/core/session-manager-classification.js.map +1 -0
- package/dist/core/session-manager-core.d.ts +4 -4
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +13 -8
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +4 -3
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +12 -10
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +6 -23
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +23 -256
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-migrations.d.ts.map +1 -1
- package/dist/core/session-manager-paths.d.ts.map +1 -1
- package/dist/core/session-manager-storage.d.ts +1 -1
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +3 -2
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +14 -15
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager-validation.d.ts.map +1 -1
- package/dist/core/session-manager.d.ts +3 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-internals.d.ts.map +1 -1
- package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-storage.d.ts.map +1 -1
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/skills-async.d.ts.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/telemetry.d.ts.map +1 -1
- package/dist/core/thinking-blocks.d.ts.map +1 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/tools/artifact-protocol.d.ts.map +1 -1
- package/dist/core/tools/artifacts.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/config.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/index.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/inline-input.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/key-router.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/row-intent.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/focus.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/state.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/types.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/body-residual-spacer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/component-binding.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/option-list-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-box-renderer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/stateful-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-components.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
- package/dist/core/tools/bash-async-execution.d.ts.map +1 -1
- package/dist/core/tools/bash-async-jobs.d.ts.map +1 -1
- package/dist/core/tools/bash-async-output.d.ts.map +1 -1
- package/dist/core/tools/bash-interceptor.d.ts.map +1 -1
- package/dist/core/tools/bash-leading-cd.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/block-resolver.d.ts.map +1 -1
- package/dist/core/tools/conflict-registry.d.ts.map +1 -1
- package/dist/core/tools/directory-tree.d.ts.map +1 -1
- package/dist/core/tools/edit-diff-preserve.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/fetch-url.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/glob-path-utils.d.ts.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/block.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/format.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/index.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/input.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -1
- package/dist/core/tools/hashline-engine/types.d.ts.map +1 -1
- package/dist/core/tools/hashline.d.ts.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/notebook.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/read-document-extract.d.ts.map +1 -1
- package/dist/core/tools/read-selectors.d.ts.map +1 -1
- package/dist/core/tools/read-url.d.ts.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/resource-selectors.d.ts.map +1 -1
- package/dist/core/tools/search-details.d.ts.map +1 -1
- package/dist/core/tools/search-line-ranges.d.ts.map +1 -1
- package/dist/core/tools/search-native.d.ts.map +1 -1
- package/dist/core/tools/search.d.ts.map +1 -1
- package/dist/core/tools/structured-output.d.ts.map +1 -1
- package/dist/core/tools/todos-execute.d.ts.map +1 -1
- package/dist/core/tools/todos-locks.d.ts.map +1 -1
- package/dist/core/tools/todos-model.d.ts.map +1 -1
- package/dist/core/tools/todos-mutations.d.ts.map +1 -1
- package/dist/core/tools/todos-paths.d.ts.map +1 -1
- package/dist/core/tools/todos-render.d.ts.map +1 -1
- package/dist/core/tools/todos-storage.d.ts.map +1 -1
- package/dist/core/tools/todos-types.d.ts.map +1 -1
- package/dist/core/tools/todos-types.js +1 -1
- package/dist/core/tools/todos-types.js.map +1 -1
- package/dist/core/tools/todos.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +6 -2
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-limits.d.ts.map +1 -1
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/url-ip-guards.d.ts.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/typebox-compat.d.ts +12 -0
- package/dist/core/typebox-compat.d.ts.map +1 -0
- package/dist/core/typebox-compat.js +10 -0
- package/dist/core/typebox-compat.js.map +1 -0
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/main-app-mode.d.ts.map +1 -1
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-early-input.d.ts.map +1 -1
- package/dist/main-session-options.d.ts.map +1 -1
- package/dist/main-session.d.ts +1 -0
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +7 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main-stdio.d.ts.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/dist/migrations-config-values.d.ts.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/interactive/chat-input-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +12 -22
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +5 -11
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +3 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.js +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +1 -0
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts +20 -0
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-boundary-message.js +48 -0
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/context-window-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-header.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +3 -0
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-utils.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-viewport.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/working-status.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +3 -47
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-widgets.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -3
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +21 -12
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-paths.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/model-search.d.ts.map +1 -1
- package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
- package/dist/modes/interactive/theme/export-colors.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/terminal-detection.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-parse.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
- package/dist/modes/interactive/whimsical-messages.d.ts.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +3 -5
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +1 -6
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +0 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -11
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli-parser.d.ts.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/rpc-entry.d.ts.map +1 -1
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/deprecation.d.ts.map +1 -1
- package/dist/utils/event-loop.d.ts.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/git-env.d.ts.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/html.d.ts.map +1 -1
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-process.d.ts.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-worker.d.ts.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/markit.d.ts.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/module-require.d.ts.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/split-launcher.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/windows-self-update.d.ts.map +1 -1
- package/docs/compaction.md +97 -772
- package/docs/custom-provider.md +7 -1
- package/docs/extensions.md +31 -33
- package/docs/json.md +2 -2
- package/docs/rpc.md +32 -24
- package/docs/sdk.md +3 -3
- package/docs/session-format.md +49 -30
- package/docs/sessions.md +5 -3
- package/docs/settings.md +14 -4
- package/docs/usage.md +1 -1
- package/docs/workflows.md +30 -15
- package/examples/extensions/README.md +3 -1
- package/examples/extensions/custom-compaction.ts +14 -58
- package/examples/extensions/handoff.ts +2 -3
- package/examples/extensions/subagent/schemas.ts +1 -1
- package/examples/extensions/tic-tac-toe.ts +1 -2
- package/examples/extensions/todo.ts +1 -2
- package/npm-shrinkwrap.json +214 -98
- package/package.json +12 -12
- package/dist/core/compaction/context-assistant-turns.d.ts +0 -42
- package/dist/core/compaction/context-assistant-turns.d.ts.map +0 -1
- package/dist/core/compaction/context-assistant-turns.js +0 -87
- package/dist/core/compaction/context-assistant-turns.js.map +0 -1
- package/dist/core/compaction/context-compaction-critical.d.ts +0 -15
- package/dist/core/compaction/context-compaction-critical.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction-critical.js +0 -57
- package/dist/core/compaction/context-compaction-critical.js.map +0 -1
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +0 -18
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction-eviction-alternates.js +0 -186
- package/dist/core/compaction/context-compaction-eviction-alternates.js.map +0 -1
- package/dist/core/compaction/context-compaction-eviction.d.ts +0 -12
- package/dist/core/compaction/context-compaction-eviction.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction-eviction.js +0 -222
- package/dist/core/compaction/context-compaction-eviction.js.map +0 -1
- package/dist/core/compaction/context-compaction-metrics.d.ts +0 -28
- package/dist/core/compaction/context-compaction-metrics.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction-metrics.js +0 -107
- package/dist/core/compaction/context-compaction-metrics.js.map +0 -1
- package/dist/core/compaction/context-compaction-prompt.d.ts +0 -9
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction-prompt.js +0 -163
- package/dist/core/compaction/context-compaction-prompt.js.map +0 -1
- package/dist/core/compaction/context-compaction-runner.d.ts +0 -11
- package/dist/core/compaction/context-compaction-runner.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction-runner.js +0 -273
- package/dist/core/compaction/context-compaction-runner.js.map +0 -1
- package/dist/core/compaction/context-compaction-strategy.d.ts +0 -5
- package/dist/core/compaction/context-compaction-strategy.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction-strategy.js +0 -27
- package/dist/core/compaction/context-compaction-strategy.js.map +0 -1
- package/dist/core/compaction/context-compaction-types.d.ts +0 -75
- package/dist/core/compaction/context-compaction-types.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction-types.js +0 -6
- package/dist/core/compaction/context-compaction-types.js.map +0 -1
- package/dist/core/compaction/context-compaction.d.ts +0 -10
- package/dist/core/compaction/context-compaction.d.ts.map +0 -1
- package/dist/core/compaction/context-compaction.js +0 -8
- package/dist/core/compaction/context-compaction.js.map +0 -1
- package/dist/core/compaction/context-deletion-application.d.ts +0 -14
- package/dist/core/compaction/context-deletion-application.d.ts.map +0 -1
- package/dist/core/compaction/context-deletion-application.js +0 -261
- package/dist/core/compaction/context-deletion-application.js.map +0 -1
- package/dist/core/compaction/context-deletion-store.d.ts +0 -78
- package/dist/core/compaction/context-deletion-store.d.ts.map +0 -1
- package/dist/core/compaction/context-deletion-store.js +0 -162
- package/dist/core/compaction/context-deletion-store.js.map +0 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +0 -43
- package/dist/core/compaction/context-deletion-targets.d.ts.map +0 -1
- package/dist/core/compaction/context-deletion-targets.js +0 -292
- package/dist/core/compaction/context-deletion-targets.js.map +0 -1
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts +0 -193
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +0 -1
- package/dist/core/compaction/context-deletion-tool-definitions.js +0 -98
- package/dist/core/compaction/context-deletion-tool-definitions.js.map +0 -1
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts +0 -19
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +0 -1
- package/dist/core/compaction/context-deletion-tool-helpers.js +0 -210
- package/dist/core/compaction/context-deletion-tool-helpers.js.map +0 -1
- package/dist/core/compaction/context-deletion-tools.d.ts +0 -4
- package/dist/core/compaction/context-deletion-tools.d.ts.map +0 -1
- package/dist/core/compaction/context-deletion-tools.js +0 -403
- package/dist/core/compaction/context-deletion-tools.js.map +0 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts +0 -11
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +0 -1
- package/dist/core/compaction/context-transcript-analysis.js +0 -228
- package/dist/core/compaction/context-transcript-analysis.js.map +0 -1
- package/dist/core/session-manager-tool-dependencies.d.ts +0 -10
- package/dist/core/session-manager-tool-dependencies.d.ts.map +0 -1
- package/dist/core/session-manager-tool-dependencies.js +0 -133
- package/dist/core/session-manager-tool-dependencies.js.map +0 -1
- package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +0 -17
- package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/context-compaction-summary-message.js +0 -83
- package/dist/modes/interactive/components/context-compaction-summary-message.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-message-queue.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[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vF;AAED;;;GAGG;AAEH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAGvF;AAMD;;;GAGG;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;CAmB3C,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { customMessageExcludesContext, drainAgentMessageQueue, normalizeInterruptAbortMessage, type AgentQueueAccess, type DrainedAgentQueues, type InterruptQueueHold } from \"./agent-session-types.ts\";\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(this: AgentSession, \n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content ?? [],\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t} satisfies CustomMessage<T>;\n\tif (options?.deliverAs === \"nextTurn\") {\n\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t} else if (options?.deliverAs === \"interrupt\" && options.triggerTurn) {\n\t\tawait this._enqueueInterruptCustomMessage(appMessage, options);\n\t} else if (this.isStreaming && options?.excludeFromContext === true && options.triggerTurn !== true && options.deliverAs === undefined) {\n\t\tthis._appendCustomMessage(appMessage);\n\t} else if (this.isStreaming) {\n\t\tthis._queueAgentMessage(appMessage, options?.deliverAs === \"followUp\" ? \"followUp\" : \"steer\");\n\t} else if (options?.triggerTurn) {\n\t\tawait this._runAgentPrompt(appMessage);\n\t} else {\n\t\tthis._appendCustomMessage(appMessage);\n\t}\n}\n\n\nexport function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): void {\n\tthis.agent.state.messages.push(message);\n\tthis.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t);\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\n\nexport function _enqueueInterruptCustomMessage<T>(this: AgentSession, message: CustomMessage<T>, options?: SendMessageOptions): Promise<void> {\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = this._interruptDeliveryQueue.then(async () => {\n\t\ttry {\n\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t} finally {\n\t\t\tthis._pendingInterruptDeliveries -= 1;\n\t\t\tif (this._pendingInterruptDeliveries === 0) {\n\t\t\t\tthis._restoreAndClearActiveInterruptQueueHold();\n\t\t\t}\n\t\t}\n\t});\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\n\nexport async function _sendInterruptCustomMessageNow<T>(this: AgentSession, \n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tthis.abortRetry();\n\tthis._ensureActiveInterruptQueueHold();\n\tif (this.isStreaming) {\n\t\tconst previousAbortMessage = this._activeInterruptAbortMessage;\n\t\tthis._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tthis.agent.abort();\n\t\t\tawait this.agent.waitForIdle();\n\t\t\tawait this._agentEventQueue;\n\t\t} finally {\n\t\t\tthis._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tawait this.agent.prompt(message);\n}\n\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) {\n\t\treturn;\n\t}\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\n\nexport function _queueAgentMessage(this: AgentSession, message: AgentMessage, delivery: \"steer\" | \"followUp\"): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t\treturn;\n\t}\n\tif (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n}\n\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupts need to prevent the aborting run from consuming queued steer/follow-up\n\t// messages while still preserving those queues for a later turn.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n\n/**\n * Send a user message to the agent. Always triggers a turn.\n * When the agent is streaming, use deliverAs to specify how to queue the message.\n *\n * @param content User message content (string or content array)\n * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n */\n\nexport function clearQueue(this: AgentSession): { steering: string[]; followUp: string[] } {\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tthis.agent.clearAllQueues();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\tthis._activeInterruptQueueHold.steering.length = 0;\n\t\tthis._activeInterruptQueueHold.followUp.length = 0;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\n\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\n\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n\nexport async function abort(this: AgentSession): Promise<void> {\n\tthis.abortRetry();\n\tthis.agent.abort();\n\tawait this.agent.waitForIdle();\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tthis.settingsManager.setSteeringMode(mode);\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tthis.settingsManager.setFollowUpMode(mode);\n}\n\n// =========================================================================\n// Compaction\n// =========================================================================\n\n/**\n * Apply validated logical deletions and rebuild active agent context.\n * Retained transcript entries/content blocks stay verbatim.\n */\n\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\tsendCustomMessage,\n\t_appendCustomMessage,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-message-queue.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,8BAA8B,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAA+G,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEzM,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAe1G;AAED;;GAEG;AAEH,wBAAsB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAe7G;AAED;;GAEG;AAEH,wBAAgB,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G;AAED;;;;;;GAMG;AAEH,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAYzF;AAED,wEAAwE;AAExE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,CAEzE;AAED,iDAAiD;AAEjD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,CAEzE;AAGD,wBAAsB,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7D;AAOD,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAGvF;AAED;;;GAGG;AAEH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAGvF;AAKD,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;CAmB3C,CAAC"}
|
|
@@ -235,12 +235,8 @@ export function setFollowUpMode(mode) {
|
|
|
235
235
|
this.settingsManager.setFollowUpMode(mode);
|
|
236
236
|
}
|
|
237
237
|
// =========================================================================
|
|
238
|
-
//
|
|
238
|
+
// Queue and delivery settings
|
|
239
239
|
// =========================================================================
|
|
240
|
-
/**
|
|
241
|
-
* Apply validated logical deletions and rebuild active agent context.
|
|
242
|
-
* Retained transcript entries/content blocks stay verbatim.
|
|
243
|
-
*/
|
|
244
240
|
export const agentSessionMessageQueueMethods = {
|
|
245
241
|
_queueSteer,
|
|
246
242
|
_queueFollowUp,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-message-queue.js","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,8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nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { customMessageExcludesContext, drainAgentMessageQueue, normalizeInterruptAbortMessage, type AgentQueueAccess, type DrainedAgentQueues, type InterruptQueueHold } from \"./agent-session-types.ts\";\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(this: AgentSession, \n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content ?? [],\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t} satisfies CustomMessage<T>;\n\tif (options?.deliverAs === \"nextTurn\") {\n\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t} else if (options?.deliverAs === \"interrupt\" && options.triggerTurn) {\n\t\tawait this._enqueueInterruptCustomMessage(appMessage, options);\n\t} else if (this.isStreaming && options?.excludeFromContext === true && options.triggerTurn !== true && options.deliverAs === undefined) {\n\t\tthis._appendCustomMessage(appMessage);\n\t} else if (this.isStreaming) {\n\t\tthis._queueAgentMessage(appMessage, options?.deliverAs === \"followUp\" ? \"followUp\" : \"steer\");\n\t} else if (options?.triggerTurn) {\n\t\tawait this._runAgentPrompt(appMessage);\n\t} else {\n\t\tthis._appendCustomMessage(appMessage);\n\t}\n}\n\n\nexport function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): void {\n\tthis.agent.state.messages.push(message);\n\tthis.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t);\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\n\nexport function _enqueueInterruptCustomMessage<T>(this: AgentSession, message: CustomMessage<T>, options?: SendMessageOptions): Promise<void> {\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = this._interruptDeliveryQueue.then(async () => {\n\t\ttry {\n\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t} finally {\n\t\t\tthis._pendingInterruptDeliveries -= 1;\n\t\t\tif (this._pendingInterruptDeliveries === 0) {\n\t\t\t\tthis._restoreAndClearActiveInterruptQueueHold();\n\t\t\t}\n\t\t}\n\t});\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\n\nexport async function _sendInterruptCustomMessageNow<T>(this: AgentSession, \n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tthis.abortRetry();\n\tthis._ensureActiveInterruptQueueHold();\n\tif (this.isStreaming) {\n\t\tconst previousAbortMessage = this._activeInterruptAbortMessage;\n\t\tthis._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tthis.agent.abort();\n\t\t\tawait this.agent.waitForIdle();\n\t\t\tawait this._agentEventQueue;\n\t\t} finally {\n\t\t\tthis._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tawait this.agent.prompt(message);\n}\n\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) {\n\t\treturn;\n\t}\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\n\nexport function _queueAgentMessage(this: AgentSession, message: AgentMessage, delivery: \"steer\" | \"followUp\"): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t\treturn;\n\t}\n\tif (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n}\n\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupts need to prevent the aborting run from consuming queued steer/follow-up\n\t// messages while still preserving those queues for a later turn.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n\n/**\n * Send a user message to the agent. Always triggers a turn.\n * When the agent is streaming, use deliverAs to specify how to queue the message.\n *\n * @param content User message content (string or content array)\n * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n */\n\nexport function clearQueue(this: AgentSession): { steering: string[]; followUp: string[] } {\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tthis.agent.clearAllQueues();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\tthis._activeInterruptQueueHold.steering.length = 0;\n\t\tthis._activeInterruptQueueHold.followUp.length = 0;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\n\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\n\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n\nexport async function abort(this: AgentSession): Promise<void> {\n\tthis.abortRetry();\n\tthis.agent.abort();\n\tawait this.agent.waitForIdle();\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tthis.settingsManager.setSteeringMode(mode);\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tthis.settingsManager.setFollowUpMode(mode);\n}\n\n// =========================================================================\n// Compaction\n// =========================================================================\n\n/**\n * Apply validated logical deletions and rebuild active agent context.\n * Retained transcript entries/content blocks stay verbatim.\n */\n\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\tsendCustomMessage,\n\t_appendCustomMessage,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-message-queue.js","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,8BAA8B,EAA2E,MAAM,0BAA0B,CAAC;AAEzM,MAAM,CAAC,KAAK,UAAU,WAAW,CAAqB,IAAY,EAAE,MAAuB;IAC1F,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxB,MAAM,OAAO,GAAmC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,IAAI,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,CAAC,kBAAkB,CACtB;QACC,IAAI,EAAE,MAAM;QACZ,OAAO;QACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACrB,EACD,OAAO,CACP,CAAC;AACH,CAAC;AAED;;GAEG;AAEH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAqB,IAAY,EAAE,MAAuB;IAC7F,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxB,MAAM,OAAO,GAAmC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,IAAI,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,C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,MAAM,+BAA+B,GAAG;IAC9C,WAAW;IACX,cAAc;IACd,wBAAwB;IACxB,iBAAiB;IACjB,oBAAoB;IACpB,8BAA8B;IAC9B,8BAA8B;IAC9B,+BAA+B;IAC/B,wCAAwC;IACxC,kBAAkB;IAClB,yBAAyB;IACzB,2BAA2B;IAC3B,UAAU;IACV,mBAAmB;IACnB,mBAAmB;IACnB,KAAK;IACL,eAAe;IACf,eAAe;CACf,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { customMessageExcludesContext, drainAgentMessageQueue, normalizeInterruptAbortMessage, type AgentQueueAccess, type DrainedAgentQueues, type InterruptQueueHold } from \"./agent-session-types.ts\";\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(this: AgentSession, \n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content ?? [],\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t} satisfies CustomMessage<T>;\n\tif (options?.deliverAs === \"nextTurn\") {\n\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t} else if (options?.deliverAs === \"interrupt\" && options.triggerTurn) {\n\t\tawait this._enqueueInterruptCustomMessage(appMessage, options);\n\t} else if (this.isStreaming && options?.excludeFromContext === true && options.triggerTurn !== true && options.deliverAs === undefined) {\n\t\tthis._appendCustomMessage(appMessage);\n\t} else if (this.isStreaming) {\n\t\tthis._queueAgentMessage(appMessage, options?.deliverAs === \"followUp\" ? \"followUp\" : \"steer\");\n\t} else if (options?.triggerTurn) {\n\t\tawait this._runAgentPrompt(appMessage);\n\t} else {\n\t\tthis._appendCustomMessage(appMessage);\n\t}\n}\n\n\nexport function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): void {\n\tthis.agent.state.messages.push(message);\n\tthis.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t);\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\n\nexport function _enqueueInterruptCustomMessage<T>(this: AgentSession, message: CustomMessage<T>, options?: SendMessageOptions): Promise<void> {\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = this._interruptDeliveryQueue.then(async () => {\n\t\ttry {\n\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t} finally {\n\t\t\tthis._pendingInterruptDeliveries -= 1;\n\t\t\tif (this._pendingInterruptDeliveries === 0) {\n\t\t\t\tthis._restoreAndClearActiveInterruptQueueHold();\n\t\t\t}\n\t\t}\n\t});\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\n\nexport async function _sendInterruptCustomMessageNow<T>(this: AgentSession, \n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tthis.abortRetry();\n\tthis._ensureActiveInterruptQueueHold();\n\tif (this.isStreaming) {\n\t\tconst previousAbortMessage = this._activeInterruptAbortMessage;\n\t\tthis._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tthis.agent.abort();\n\t\t\tawait this.agent.waitForIdle();\n\t\t\tawait this._agentEventQueue;\n\t\t} finally {\n\t\t\tthis._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tawait this.agent.prompt(message);\n}\n\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) {\n\t\treturn;\n\t}\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\n\nexport function _queueAgentMessage(this: AgentSession, message: AgentMessage, delivery: \"steer\" | \"followUp\"): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t\treturn;\n\t}\n\tif (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n}\n\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupts need to prevent the aborting run from consuming queued steer/follow-up\n\t// messages while still preserving those queues for a later turn.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n\n/**\n * Send a user message to the agent. Always triggers a turn.\n * When the agent is streaming, use deliverAs to specify how to queue the message.\n *\n * @param content User message content (string or content array)\n * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n */\n\nexport function clearQueue(this: AgentSession): { steering: string[]; followUp: string[] } {\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tthis.agent.clearAllQueues();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\tthis._activeInterruptQueueHold.steering.length = 0;\n\t\tthis._activeInterruptQueueHold.followUp.length = 0;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\n\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\n\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n\nexport async function abort(this: AgentSession): Promise<void> {\n\tthis.abortRetry();\n\tthis.agent.abort();\n\tawait this.agent.waitForIdle();\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tthis.settingsManager.setSteeringMode(mode);\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tthis.settingsManager.setFollowUpMode(mode);\n}\n\n// =========================================================================\n// Queue and delivery settings\n// =========================================================================\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\tsendCustomMessage,\n\t_appendCustomMessage,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from "@earendil-works/pi-ai/compat";
|
|
3
3
|
import type { BashResult } from "./bash-executor.ts";
|
|
4
|
-
import type {
|
|
4
|
+
import type { VerbatimCompactionParameters, VerbatimCompactionResult } from "./compaction/index.ts";
|
|
5
5
|
import type { ContextUsage, ExtensionCommandContextActions, ExtensionErrorListener, ExtensionMode, ExtensionRunner, ExtensionUIContext, OrchestrationContext, ReplacedSessionContext, SessionStartEvent, ToolDefinition, ToolInfo } from "./extensions/index.ts";
|
|
6
6
|
import type { BashExecutionMessage, CustomMessage } from "./messages.ts";
|
|
7
7
|
import type { ModelRegistry } from "./model-registry.ts";
|
|
@@ -14,7 +14,7 @@ import type { AsyncJobManager } from "./async/job-manager.js";
|
|
|
14
14
|
import type { BashOperations } from "./tools/bash.ts";
|
|
15
15
|
import type { AgentSessionEvent, AgentSessionEventListener, ContextWindowReplayRequest, ContextWindowReplaySource, DrainedAgentQueues, ExtensionBindings, InterruptQueueHold, ModelCycleResult, PromptOptions, SessionStats, ToolDefinitionEntry } from "./agent-session-types.ts";
|
|
16
16
|
import type { SendMessageOptions } from "./extensions/index.ts";
|
|
17
|
-
export interface
|
|
17
|
+
export interface VerbatimCompactionApplyOptions {
|
|
18
18
|
resolvePlannerAuth: () => Promise<{
|
|
19
19
|
apiKey: string;
|
|
20
20
|
headers?: Record<string, string>;
|
|
@@ -171,9 +171,8 @@ export interface AgentSessionMethodSurface {
|
|
|
171
171
|
_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;
|
|
172
172
|
_applyContextWindowReplay(contextWindow: number | undefined): void;
|
|
173
173
|
_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;
|
|
174
|
-
|
|
175
|
-
compact(options?: Partial<
|
|
176
|
-
contextCompact(): Promise<ContextCompactionResult>;
|
|
174
|
+
_applyVerbatimCompaction(options: VerbatimCompactionApplyOptions): Promise<VerbatimCompactionResult | undefined>;
|
|
175
|
+
compact(options?: Partial<VerbatimCompactionParameters>): Promise<VerbatimCompactionResult>;
|
|
177
176
|
abortCompaction(): void;
|
|
178
177
|
abortBranchSummary(): void;
|
|
179
178
|
_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;
|
|
@@ -247,7 +246,7 @@ export interface AgentSessionMethodSurface {
|
|
|
247
246
|
createReplacedSessionContext(): ReplacedSessionContext;
|
|
248
247
|
hasExtensionHandlers(eventType: string): boolean;
|
|
249
248
|
}
|
|
250
|
-
export interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface, "orchestrationContext" | "modelRegistry" | "state" | "model" | "thinkingLevel" | "isStreaming" | "systemPrompt" | "retryAttempt" | "isCompacting" | "messages" | "steeringMode" | "followUpMode" | "sessionFile" | "sessionId" | "sessionName" | "scopedModels" | "promptTemplates" | "pendingMessageCount" | "resourceLoader" | "autoCompactionEnabled" | "isRetrying" | "autoRetryEnabled" | "isBashRunning" | "hasPendingBashMessages" | "extensionRunner" | "subscribe" | "dispose" | "getActiveToolNames" | "getAllTools" | "getToolDefinition" | "setActiveToolsByName" | "setScopedModels" | "prompt" | "steer" | "followUp" | "sendCustomMessage" | "sendUserMessage" | "clearQueue" | "getSteeringMessages" | "getFollowUpMessages" | "abort" | "setModel" | "cycleModel" | "setThinkingLevel" | "cycleThinkingLevel" | "getAvailableThinkingLevels" | "supportsThinking" | "getAvailableContextWindows" | "supportsContextWindowSelection" | "setContextWindow" | "setSteeringMode" | "setFollowUpMode" | "compact" | "
|
|
249
|
+
export interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface, "orchestrationContext" | "modelRegistry" | "state" | "model" | "thinkingLevel" | "isStreaming" | "systemPrompt" | "retryAttempt" | "isCompacting" | "messages" | "steeringMode" | "followUpMode" | "sessionFile" | "sessionId" | "sessionName" | "scopedModels" | "promptTemplates" | "pendingMessageCount" | "resourceLoader" | "autoCompactionEnabled" | "isRetrying" | "autoRetryEnabled" | "isBashRunning" | "hasPendingBashMessages" | "extensionRunner" | "subscribe" | "dispose" | "getActiveToolNames" | "getAllTools" | "getToolDefinition" | "setActiveToolsByName" | "setScopedModels" | "prompt" | "steer" | "followUp" | "sendCustomMessage" | "sendUserMessage" | "clearQueue" | "getSteeringMessages" | "getFollowUpMessages" | "abort" | "setModel" | "cycleModel" | "setThinkingLevel" | "cycleThinkingLevel" | "getAvailableThinkingLevels" | "supportsThinking" | "getAvailableContextWindows" | "supportsContextWindowSelection" | "setContextWindow" | "setSteeringMode" | "setFollowUpMode" | "compact" | "abortCompaction" | "abortBranchSummary" | "setAutoCompactionEnabled" | "bindExtensions" | "refreshCurrentModelFromRegistry" | "reload" | "abortRetry" | "setAutoRetryEnabled" | "executeBash" | "recordBashResult" | "abortBash" | "setSessionName" | "navigateTree" | "getUserMessagesForForking" | "getSessionStats" | "getContextUsage" | "exportToHtml" | "exportToJsonl" | "getLastAssistantText" | "createReplacedSessionContext" | "hasExtensionHandlers"> {
|
|
251
250
|
readonly agent: Agent;
|
|
252
251
|
readonly sessionManager: SessionManager;
|
|
253
252
|
readonly settingsManager: SettingsManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-methods.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3H,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MA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EAAE,8BAA8B,CAAC;IACjE,yBAAyB,CAAC,EAAE,MAAM,IAAI,CAAC;IACvC,uBAAuB,CAAC,EAAE,sBAAsB,CAAC;IACjD,2BAA2B,CAAC,EAAE,MAAM,IAAI,CAAC;IACzC,cAAc,EAAE,aAAa,CAAC;IAC9B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACnD,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACpD,gBAAgB,EAAE,eAAe,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;CAClC","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.js\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { AsyncJobManager } from \"./async/job-manager.js\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\" | \"fallback\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\" | \"fallback\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingAutoCompactionRetryAssistantIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_awaitPendingPostCompactionContinuation(): Promise<void>;\n\t_resumeAfterAutoCompaction(): Promise<void>;\n\t_resumeAfterLengthTruncation(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\trefreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(options?: { reason?: \"startup\" | \"reload\" }): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_isSafetyRefusal(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\t_trySwitchToFallbackModel(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"refreshCurrentModelFromRegistry\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_fallbackModels: string[];\n\t_fallbackAttemptedKeys: Set<string>;\n\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingPostCompactionContinuation: Promise<void> | undefined;\n\t_postCompactionContinuationToken: number;\n\t_lengthContinuationAttempts: number;\n\t_outputBudgetErrorContinuationAttempts: number;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride?: string;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\t_asyncJobManager: AsyncJobManager;\n\t_asyncJobManagerSessionId: symbol;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-methods.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3H,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,KAAK,EACX,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EA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BAAqB,CAAC,EAAE,oBAAoB,CAAC;IAC7C,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;IACzC,cAAc,EAAE,aAAa,CAAC;IAC9B,+BAA+B,CAAC,EAAE,8BAA8B,CAAC;IACjE,yBAAyB,CAAC,EAAE,MAAM,IAAI,CAAC;IACvC,uBAAuB,CAAC,EAAE,sBAAsB,CAAC;IACjD,2BAA2B,CAAC,EAAE,MAAM,IAAI,CAAC;IACzC,cAAc,EAAE,aAAa,CAAC;IAC9B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACnD,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACpD,gBAAgB,EAAE,eAAe,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-methods.js","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.js\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { AsyncJobManager } from \"./async/job-manager.js\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\" | \"fallback\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\" | \"fallback\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingAutoCompactionRetryAssistantIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_awaitPendingPostCompactionContinuation(): Promise<void>;\n\t_resumeAfterAutoCompaction(): Promise<void>;\n\t_resumeAfterLengthTruncation(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\trefreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(options?: { reason?: \"startup\" | \"reload\" }): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_isSafetyRefusal(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\t_trySwitchToFallbackModel(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"refreshCurrentModelFromRegistry\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_fallbackModels: string[];\n\t_fallbackAttemptedKeys: Set<string>;\n\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingPostCompactionContinuation: Promise<void> | undefined;\n\t_postCompactionContinuationToken: number;\n\t_lengthContinuationAttempts: number;\n\t_outputBudgetErrorContinuationAttempts: number;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride?: string;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\t_asyncJobManager: AsyncJobManager;\n\t_asyncJobManagerSessionId: symbol;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-methods.js","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type { VerbatimCompactionParameters, VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.js\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { AsyncJobManager } from \"./async/job-manager.js\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface VerbatimCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\" | \"fallback\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\" | \"fallback\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyVerbatimCompaction(options: VerbatimCompactionApplyOptions): Promise<VerbatimCompactionResult | undefined>;\n\tcompact(options?: Partial<VerbatimCompactionParameters>): Promise<VerbatimCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingAutoCompactionRetryAssistantIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_awaitPendingPostCompactionContinuation(): Promise<void>;\n\t_resumeAfterAutoCompaction(): Promise<void>;\n\t_resumeAfterLengthTruncation(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\trefreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(options?: { reason?: \"startup\" | \"reload\" }): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_isSafetyRefusal(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\t_trySwitchToFallbackModel(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"refreshCurrentModelFromRegistry\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_fallbackModels: string[];\n\t_fallbackAttemptedKeys: Set<string>;\n\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingPostCompactionContinuation: Promise<void> | undefined;\n\t_postCompactionContinuationToken: number;\n\t_lengthContinuationAttempts: number;\n\t_outputBudgetErrorContinuationAttempts: number;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride?: string;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\t_asyncJobManager: AsyncJobManager;\n\t_asyncJobManagerSessionId: symbol;\n}\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-models.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAK/D,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAA6D,KAAK,0BAA0B,EAAE,KAAK,yBAAyB,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE7L,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;IAC7F,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,CAAC,CAqBD;AAED;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,EACnD,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,EACrB,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,EACrC,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAC9C,IAAI,CAQN;AAGD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,YAAY,EACxD,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,EACrB,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,EACrC,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAC9C,OAAO,CAAC,IAAI,CAAC,CA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AAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAOlE;AAGD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAWrG;AAGD,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,YAAY,EACrE,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,EACrC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,GACnB,IAAI,CAON;AAMD;;;GAGG;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrC,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model } from \"@earendil-works/pi-ai/compat\";\nimport { clampThinkingLevel, getSupportedThinkingLevels, modelsAreEqual } from \"@earendil-works/pi-ai/compat\";\nimport { getModelDefaultContextWindow, getSupportedContextWindows, selectContextWindow } from \"./context-window.ts\";\nimport { formatNoApiKeyFoundMessage } from \"./auth-guidance.ts\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS, THINKING_LEVELS, type ContextWindowReplayRequest, type ContextWindowReplaySource, type ModelCycleResult } from \"./agent-session-types.ts\";\n\nexport async function _getRequiredRequestAuth(this: AgentSession, model: Model<Api>): Promise<{\n\tapiKey: string;\n\theaders?: Record<string, string>;\n}> {\n\tconst result = await this._modelRegistry.getApiKeyAndHeaders(model);\n\tif (!result.ok) {\n\t\tif (result.error.startsWith(\"No API key found\")) {\n\t\t\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n\t\t}\n\t\tthrow new Error(result.error);\n\t}\n\tif (result.apiKey) {\n\t\treturn { apiKey: result.apiKey, headers: result.headers };\n\t}\n\n\tconst isOAuth = this._modelRegistry.isUsingOAuth(model);\n\tif (isOAuth) {\n\t\tthrow new Error(\n\t\t\t`Authentication failed for \"${model.provider}\". ` +\n\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t`Run '/login ${model.provider}' to re-authenticate.`,\n\t\t);\n\t}\n\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n}\n\n/**\n * Install tool hooks once on the Agent instance.\n *\n * The callbacks read `this._extensionRunner` at execution time, so extension reload swaps in the\n * new runner without reinstalling hooks. Extension-specific tool wrappers are still used to adapt\n * registered tool execution to the extension context. Tool call and tool result interception now\n * happens here instead of in wrappers.\n */\n\nexport function _emitModelChanged(this: AgentSession, \n\tnextModel: Model<Api>,\n\tpreviousModel: Model<Api> | undefined,\n\tsource: \"set\" | \"cycle\" | \"restore\" | \"fallback\",\n): void {\n\tif (modelsAreEqual(previousModel, nextModel)) return;\n\tthis._emit({\n\t\ttype: \"model_changed\",\n\t\tmodel: nextModel,\n\t\tpreviousModel,\n\t\tsource,\n\t});\n}\n\n\nexport async function _emitModelSelect(this: AgentSession, \n\tnextModel: Model<Api>,\n\tpreviousModel: Model<Api> | undefined,\n\tsource: \"set\" | \"cycle\" | \"restore\" | \"fallback\",\n): Promise<void> {\n\tif (modelsAreEqual(previousModel, nextModel)) return;\n\tawait this._extensionRunner.emit({\n\t\ttype: \"model_select\",\n\t\tmodel: nextModel,\n\t\tpreviousModel,\n\t\tsource,\n\t});\n}\n\n/**\n * Set model directly.\n * Validates that auth is configured, saves to session and settings.\n * @throws Error if no auth is configured for the model\n */\n\nexport async function setModel(this: AgentSession, model: Model<Api>): Promise<void> {\n\tif (!this._modelRegistry.hasConfiguredAuth(model)) {\n\t\tthrow new Error(`No API key for ${model.provider}/${model.id}`);\n\t}\n\n\tconst previousModel = this.model;\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch();\n\tconst nextModel = this._withContextWindowForModelSwitch(model);\n\tthis.agent.state.model = nextModel;\n\tthis.sessionManager.appendModelChange(nextModel.provider, nextModel.id);\n\tthis._appendContextWindowChangeIfChanged(previousModel, nextModel);\n\tthis.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);\n\n\t// Re-clamp thinking level for new model's capabilities\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(nextModel, previousModel, \"set\");\n\tawait this._emitModelSelect(nextModel, previousModel, \"set\");\n}\n\n/**\n * Cycle to next/previous model.\n * Uses scoped models (from --models flag) if available, otherwise all available models.\n * @param direction - \"forward\" (default) or \"backward\"\n * @returns The new model info, or undefined if only one model available\n */\n\nexport async function cycleModel(this: AgentSession, direction: \"forward\" | \"backward\" = \"forward\"): Promise<ModelCycleResult | undefined> {\n\tif (this._scopedModels.length > 0) {\n\t\treturn this._cycleScopedModel(direction);\n\t}\n\treturn this._cycleAvailableModel(direction);\n}\n\n\nexport async function _cycleScopedModel(this: AgentSession, direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined> {\n\tconst scopedModels = this._scopedModels.filter((scoped) => this._modelRegistry.hasConfiguredAuth(scoped.model));\n\tif (scopedModels.length <= 1) return undefined;\n\n\tconst currentModel = this.model;\n\tlet currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));\n\n\tif (currentIndex === -1) currentIndex = 0;\n\tconst len = scopedModels.length;\n\tconst nextIndex = direction === \"forward\" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;\n\tconst next = scopedModels[nextIndex];\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch(next.thinkingLevel);\n\tconst nextModel = this._withContextWindowForModelSwitch(next.model);\n\n\t// Apply model\n\tthis.agent.state.model = nextModel;\n\tthis.sessionManager.appendModelChange(nextModel.provider, nextModel.id);\n\tthis._appendContextWindowChangeIfChanged(currentModel, nextModel);\n\tthis.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);\n\n\t// Apply thinking level.\n\t// - Explicit scoped model thinking level overrides current session level\n\t// - Undefined scoped model thinking level inherits the current session preference\n\t// setThinkingLevel clamps to model capabilities.\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(nextModel, currentModel, \"cycle\");\n\tawait this._emitModelSelect(nextModel, currentModel, \"cycle\");\n\n\treturn { model: nextModel, thinkingLevel: this.thinkingLevel, isScoped: true };\n}\n\n\nexport async function _cycleAvailableModel(this: AgentSession, direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined> {\n\tconst availableModels = await this._modelRegistry.getAvailable();\n\tif (availableModels.length <= 1) return undefined;\n\n\tconst currentModel = this.model;\n\tlet currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));\n\n\tif (currentIndex === -1) currentIndex = 0;\n\tconst len = availableModels.length;\n\tconst nextIndex = direction === \"forward\" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;\n\tconst selectedModel = this._withContextWindowForModelSwitch(availableModels[nextIndex]);\n\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch();\n\tthis.agent.state.model = selectedModel;\n\tthis.sessionManager.appendModelChange(selectedModel.provider, selectedModel.id);\n\tthis._appendContextWindowChangeIfChanged(currentModel, selectedModel);\n\tthis.settingsManager.setDefaultModelAndProvider(selectedModel.provider, selectedModel.id);\n\n\t// Re-clamp thinking level for new model's capabilities\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(selectedModel, currentModel, \"cycle\");\n\tawait this._emitModelSelect(selectedModel, currentModel, \"cycle\");\n\n\treturn { model: selectedModel, thinkingLevel: this.thinkingLevel, isScoped: false };\n}\n\n// =========================================================================\n// Thinking Level Management\n// =========================================================================\n\n/**\n * Set thinking level.\n * Clamps to model capabilities based on available thinking levels.\n * Saves to session and settings only if the level actually changes.\n */\n\nexport function setThinkingLevel(this: AgentSession, level: ThinkingLevel): void {\n\tconst availableLevels = this.getAvailableThinkingLevels();\n\tconst effectiveLevel = availableLevels.includes(level) ? level : this._clampThinkingLevel(level, availableLevels);\n\n\t// Only persist if actually changing\n\tconst previousLevel = this.agent.state.thinkingLevel;\n\tconst isChanging = effectiveLevel !== previousLevel;\n\n\tthis.agent.state.thinkingLevel = effectiveLevel;\n\n\tif (isChanging) {\n\t\tthis.sessionManager.appendThinkingLevelChange(effectiveLevel);\n\t\tthis._refreshBaseSystemPromptFromActiveTools();\n\t\tif (this.supportsThinking() || effectiveLevel !== \"off\") {\n\t\t\tthis.settingsManager.setDefaultThinkingLevel(effectiveLevel);\n\t\t}\n\t\tthis._emit({ type: \"thinking_level_changed\", level: effectiveLevel });\n\t\tvoid this._extensionRunner.emit({\n\t\t\ttype: \"thinking_level_select\",\n\t\t\tlevel: effectiveLevel,\n\t\t\tpreviousLevel,\n\t\t});\n\t}\n}\n\n/**\n * Cycle to next thinking level.\n * @returns New level, or undefined if model doesn't support thinking\n */\n\nexport function cycleThinkingLevel(this: AgentSession): ThinkingLevel | undefined {\n\tif (!this.supportsThinking()) return undefined;\n\n\tconst levels = this.getAvailableThinkingLevels();\n\tconst currentIndex = levels.indexOf(this.thinkingLevel);\n\tconst nextIndex = (currentIndex + 1) % levels.length;\n\tconst nextLevel = levels[nextIndex];\n\n\tthis.setThinkingLevel(nextLevel);\n\treturn nextLevel;\n}\n\n/**\n * Get available thinking levels for current model.\n * The provider will clamp to what the specific model supports internally.\n */\n\nexport function getAvailableThinkingLevels(this: AgentSession): ThinkingLevel[] {\n\tif (!this.model) return THINKING_LEVELS;\n\treturn getSupportedThinkingLevels(this.model) as ThinkingLevel[];\n}\n\n/**\n * Check if current model supports thinking/reasoning.\n */\n\nexport function supportsThinking(this: AgentSession): boolean {\n\treturn !!this.model?.reasoning;\n}\n\n\nexport function _getThinkingLevelForModelSwitch(this: AgentSession, explicitLevel?: ThinkingLevel): ThinkingLevel {\n\tif (explicitLevel !== undefined) {\n\t\treturn explicitLevel;\n\t}\n\tif (!this.supportsThinking()) {\n\t\treturn this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;\n\t}\n\treturn this.thinkingLevel;\n}\n\n\nexport function _clampThinkingLevel(this: AgentSession, level: ThinkingLevel, _availableLevels: ThinkingLevel[]): ThinkingLevel {\n\treturn this.model ? (clampThinkingLevel(this.model, level) as ThinkingLevel) : \"off\";\n}\n\n// =========================================================================\n// Context Window Management\n// =========================================================================\n\n\nexport function getAvailableContextWindows(this: AgentSession): number[] {\n\treturn this.model ? getSupportedContextWindows(this.model) : [];\n}\n\n\nexport function supportsContextWindowSelection(this: AgentSession): boolean {\n\treturn this.getAvailableContextWindows().length > 1;\n}\n\n\nexport function setContextWindow(this: AgentSession, contextWindow: number, options: { persistDefault?: boolean } = {}): void {\n\tif (!this.model) {\n\t\tthrow new Error(\"No model selected\");\n\t}\n\tconst selected = selectContextWindow(this.model, contextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\tif (\"error\" in selected) {\n\t\tthrow new Error(selected.error);\n\t}\n\n\tconst previousContextWindow = this.model.contextWindow;\n\tconst isChanging = previousContextWindow !== selected.contextWindow;\n\tthis.agent.state.model = selected.model;\n\n\tif (isChanging) {\n\t\tthis.sessionManager.appendContextWindowChange(selected.contextWindow);\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: selected.contextWindow });\n\t}\n\tif (options.persistDefault === true) {\n\t\tthis.settingsManager.setDefaultContextWindowForModel(selected.model.provider, selected.model.id, selected.contextWindow);\n\t}\n}\n\n\nexport function _withContextWindowForModelSwitch(this: AgentSession, model: Model<Api>): Model<Api> {\n\t// A source model's scalar contextWindow can be its natural default (for example a 1m-default\n\t// model). Do not treat that alone as an opt-in to larger windows on a 400k-default target.\n\tconst settingsDefaultContextWindow = this._getSettingsContextWindowRequestForModel(model)?.contextWindow;\n\tconst candidates: number[] = [];\n\tconst targetDefaultContextWindow = getModelDefaultContextWindow(model);\n\tif (model.contextWindow !== targetDefaultContextWindow) {\n\t\t// Preserve an explicit context-window selection already applied to the target model\n\t\t// (for example a caller passing selectContextWindow(target, 1m).model).\n\t\tcandidates.push(model.contextWindow);\n\t}\n\tconst currentModel = this.model;\n\tif (currentModel && this._shouldCarryCurrentContextWindowForModelSwitch(currentModel, settingsDefaultContextWindow)) {\n\t\tcandidates.push(currentModel.contextWindow);\n\t}\n\tif (settingsDefaultContextWindow !== undefined) {\n\t\tcandidates.push(settingsDefaultContextWindow);\n\t}\n\tcandidates.push(targetDefaultContextWindow);\n\n\tfor (const candidate of candidates) {\n\t\tconst selected = selectContextWindow(model, candidate, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\t\tif (!(\"error\" in selected)) return selected.model;\n\t}\n\treturn model;\n}\n\n\nexport function _shouldCarryCurrentContextWindowForModelSwitch(this: AgentSession, \n\tcurrentModel: Model<Api>,\n\tsettingsDefaultContextWindow: number | undefined,\n): boolean {\n\tif (currentModel.contextWindow !== getModelDefaultContextWindow(currentModel)) {\n\t\treturn true;\n\t}\n\tif (this.sessionManager.getBranch().some((entry) => entry.type === \"context_window_change\")) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tsettingsDefaultContextWindow !== undefined &&\n\t\tcurrentModel.contextWindow === settingsDefaultContextWindow &&\n\t\tgetSupportedContextWindows(currentModel).includes(settingsDefaultContextWindow)\n\t);\n}\n\n\nexport function _getSettingsContextWindowRequestForModel(this: AgentSession, model: Model<Api>): ContextWindowReplayRequest | undefined {\n\tconst modelContextWindow = this.settingsManager.getDefaultContextWindowForModel(model.provider, model.id);\n\tif (modelContextWindow !== undefined) {\n\t\treturn { contextWindow: modelContextWindow, source: \"model-settings\" };\n\t}\n\tconst globalContextWindow = this.settingsManager.getDefaultContextWindow();\n\treturn globalContextWindow === undefined\n\t\t? undefined\n\t\t: { contextWindow: globalContextWindow, source: \"global-settings\" };\n}\n\n\nexport function _getContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n\trequestedContextWindow: number | undefined,\n\tsource: ContextWindowReplaySource | undefined,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tif (requestedContextWindow !== undefined) {\n\t\tconst selected = selectContextWindow(model, requestedContextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\t\tif (!(\"error\" in selected)) {\n\t\t\treturn { model: selected.model, contextWindow: selected.contextWindow, wouldWarn: false };\n\t\t}\n\t\treturn this._getDefaultContextWindowReplayForModel(model, source !== \"global-settings\");\n\t}\n\n\treturn this._getDefaultContextWindowReplayForModel(model, false);\n}\n\n\nexport function _getDefaultContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n\twouldWarn: boolean,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tconst defaultContextWindow = getModelDefaultContextWindow(model);\n\tconst selected = selectContextWindow(model, defaultContextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\tif (!(\"error\" in selected)) {\n\t\treturn { model: selected.model, contextWindow: selected.contextWindow, wouldWarn };\n\t}\n\treturn {\n\t\tmodel: { ...model, contextWindow: defaultContextWindow, defaultContextWindow },\n\t\tcontextWindow: defaultContextWindow,\n\t\twouldWarn,\n\t};\n}\n\n\nexport function _getResumeContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tconst sessionContext = this.sessionManager.buildSessionContext();\n\tif (sessionContext.contextWindow !== undefined) {\n\t\treturn this._getContextWindowReplayForModel(model, sessionContext.contextWindow, \"session\");\n\t}\n\tconst settingsContextWindow = this._getSettingsContextWindowRequestForModel(model);\n\treturn this._getContextWindowReplayForModel(model, settingsContextWindow?.contextWindow, settingsContextWindow?.source);\n}\n\n\nexport function _applyContextWindowReplay(this: AgentSession, contextWindow: number | undefined): void {\n\tif (!this.model) return;\n\tconst previousContextWindow = this.model.contextWindow;\n\tconst settingsContextWindow = this._getSettingsContextWindowRequestForModel(this.model);\n\tconst requestedContextWindow = contextWindow ?? settingsContextWindow?.contextWindow;\n\tconst source: ContextWindowReplaySource | undefined = contextWindow !== undefined ? \"session\" : settingsContextWindow?.source;\n\tconst replay = this._getContextWindowReplayForModel(this.model, requestedContextWindow, source);\n\tthis.agent.state.model = replay.model;\n\tif (previousContextWindow !== replay.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: replay.contextWindow });\n\t}\n}\n\n\nexport function _appendContextWindowChangeIfChanged(this: AgentSession, \n\tpreviousModel: Model<Api> | undefined,\n\tnextModel: Model<Api>,\n): void {\n\tconst replay = this._getResumeContextWindowReplayForModel(nextModel);\n\tif (!replay.wouldWarn && nextModel.contextWindow === replay.contextWindow) return;\n\tthis.sessionManager.appendContextWindowChange(nextModel.contextWindow);\n\tif (previousModel?.contextWindow !== nextModel.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: nextModel.contextWindow });\n\t}\n}\n\n// =========================================================================\n// Queue Mode Management\n// =========================================================================\n\n/**\n * Set steering message mode.\n * Saves to settings.\n */\n\nexport const agentSessionModelsMethods = {\n\t_getRequiredRequestAuth,\n\t_emitModelChanged,\n\t_emitModelSelect,\n\tsetModel,\n\tcycleModel,\n\t_cycleScopedModel,\n\t_cycleAvailableModel,\n\tsetThinkingLevel,\n\tcycleThinkingLevel,\n\tgetAvailableThinkingLevels,\n\tsupportsThinking,\n\t_getThinkingLevelForModelSwitch,\n\t_clampThinkingLevel,\n\tgetAvailableContextWindows,\n\tsupportsContextWindowSelection,\n\tsetContextWindow,\n\t_withContextWindowForModelSwitch,\n\t_shouldCarryCurrentContextWindowForModelSwitch,\n\t_getSettingsContextWindowRequestForModel,\n\t_getContextWindowReplayForModel,\n\t_getDefaultContextWindowReplayForModel,\n\t_getResumeContextWindowReplayForModel,\n\t_applyContextWindowReplay,\n\t_appendContextWindowChangeIfChanged,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-models.d.ts","sourceRoot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B,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAwBpG;AAED;;;;GAIG;AAEH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAwB5E;AAED;;;;;;;GAOG;AAEH,wBAAsB,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAWpG;AAED;;;;;;GAMG;AAEH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAWvG;AAED;;GAEG;AAEH,wBAAsB,eAAe,CAAC,IAAI,EAAE,YAAY,EACvD,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,EAChD,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAA;CAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CA4Bf;AAED;;;;GAIG;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;CAWrC,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport { ATOMIC_GUIDE_COMMAND_NAME, ATOMIC_GUIDE_HELP_CHOICES, atomicGuideModeForChoice, getAtomicGuideMessage, isAtomicGuideHelpChoice, normalizeAtomicGuideMode } from \"./atomic-guide-command.ts\";\nimport { formatAuthStorageLoadFailedMessage, formatNoApiKeyFoundMessage, formatNoModelSelectedMessage, formatUnresolvedModelMessage } from \"./auth-guidance.ts\";\nimport { expandPromptTemplate } from \"./prompt-templates.ts\";\nimport { stripFrontmatter } from \"../utils/frontmatter.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { PromptOptions } from \"./agent-session-types.ts\";\n\nexport async function prompt(this: AgentSession, text: string, options?: PromptOptions): Promise<void> {\n\tconst expandPromptTemplates = options?.expandPromptTemplates ?? true;\n\tconst preflightResult = options?.preflightResult;\n\tlet messages: AgentMessage[] | undefined;\n\n\ttry {\n\t\t// Handle slash commands first (execute immediately, even during streaming).\n\t\t// Builtin and extension commands manage their own LLM interaction via custom messages.\n\t\tif (expandPromptTemplates && text.startsWith(\"/\")) {\n\t\t\tconst handledBuiltin = await this._tryExecuteBuiltinSlashCommand(text);\n\t\t\tif (handledBuiltin) {\n\t\t\t\tpreflightResult?.(true);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst handledExtension = await this._tryExecuteExtensionCommand(text);\n\t\t\tif (handledExtension) {\n\t\t\t\tpreflightResult?.(true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Emit input event for extension interception (before skill/template expansion)\n\t\tlet currentText = text;\n\t\tlet currentImages = options?.images;\n\t\tif (this._extensionRunner.hasHandlers(\"input\")) {\n\t\t\tconst inputResult = await this._extensionRunner.emitInput(\n\t\t\t\tcurrentText,\n\t\t\t\tcurrentImages,\n\t\t\t\toptions?.source ?? \"interactive\",\n\t\t\t\tthis.isStreaming ? options?.streamingBehavior : undefined,\n\t\t\t);\n\t\t\tif (inputResult.action === \"handled\") {\n\t\t\t\tpreflightResult?.(true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputResult.action === \"transform\") {\n\t\t\t\tcurrentText = inputResult.text;\n\t\t\t\tcurrentImages = inputResult.images ?? currentImages;\n\t\t\t}\n\t\t}\n\n\t\t// Expand skill commands (/skill:name args) and prompt templates (/template args)\n\t\tlet expandedText = currentText;\n\t\tif (expandPromptTemplates) {\n\t\t\texpandedText = this._expandSkillCommand(expandedText);\n\t\t\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\t\t}\n\n\t\t// If streaming, queue via steer() or followUp() based on option\n\t\tif (this.isStreaming) {\n\t\t\tif (!options?.streamingBehavior) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (options.streamingBehavior === \"followUp\") {\n\t\t\t\tawait this._queueFollowUp(expandedText, currentImages);\n\t\t\t} else {\n\t\t\t\tawait this._queueSteer(expandedText, currentImages);\n\t\t\t}\n\t\t\tpreflightResult?.(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Flush any pending bash messages before the new prompt\n\t\tthis._flushPendingBashMessages();\n\n\t\t// Validate model\n\t\tif (!this.model) {\n\t\t\tthrow new Error(formatNoModelSelectedMessage());\n\t\t}\n\n\t\t// Defensive guard: a model that never resolved to a real provider\n\t\t// (for example an unknown/unresolved model id that reached this path\n\t\t// as a bare string) has no `provider`, which would otherwise fail deep\n\t\t// in auth resolution as the confusing \"No API key found for undefined\".\n\t\t// Surface a clear, accurate \"unknown model\" error instead.\n\t\tconst resolvedProvider = (this.model as { provider?: unknown }).provider;\n\t\tif (typeof resolvedProvider !== \"string\" || resolvedProvider.length === 0) {\n\t\t\tthrow new Error(formatUnresolvedModelMessage(this.model));\n\t\t}\n\n\t\tif (!this._modelRegistry.hasConfiguredAuth(this.model)) {\n\t\t\t// A failed credential-store load (for example auth.json briefly locked\n\t\t\t// by a concurrent process, or invalid JSON) leaves an empty in-memory\n\t\t\t// credential set. That would otherwise be misreported here as\n\t\t\t// \"No API key found\" even though the credentials exist on disk. Surface\n\t\t\t// the real load failure instead so configured providers are not falsely\n\t\t\t// reported as unauthenticated (issue #1431).\n\t\t\tconst authLoadError = this._modelRegistry.authStorage.getLoadError();\n\t\t\tif (authLoadError) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\tformatAuthStorageLoadFailedMessage(this.model.provider, authLoadError),\n\t\t\t\t\t{ cause: authLoadError },\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst isOAuth = this._modelRegistry.isUsingOAuth(this.model);\n\t\t\tif (isOAuth) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Authentication failed for \"${this.model.provider}\". ` +\n\t\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t\t\t`Run '/login ${this.model.provider}' to re-authenticate.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(formatNoApiKeyFoundMessage(this.model.provider));\n\t\t}\n\n\t\t// Check if we need to compact before sending (catches aborted responses)\n\t\tconst lastAssistant = this._findLastAssistantMessage();\n\t\tif (lastAssistant) {\n\t\t\tawait this._checkCompaction(lastAssistant, false);\n\t\t}\n\n\t\t// Build messages array (custom message if any, then user message)\n\t\tmessages = [];\n\n\t\t// Add user message\n\t\tconst userContent: (TextContent | ImageContent)[] = [{ type: \"text\", text: expandedText }];\n\t\tif (currentImages) {\n\t\t\tuserContent.push(...currentImages);\n\t\t}\n\t\tmessages.push({\n\t\t\trole: \"user\",\n\t\t\tcontent: userContent,\n\t\t\ttimestamp: Date.now(),\n\t\t});\n\n\t\t// Inject any pending \"nextTurn\" messages as context alongside the user message\n\t\tfor (const msg of this._pendingNextTurnMessages) {\n\t\t\tmessages.push(msg);\n\t\t}\n\t\tthis._pendingNextTurnMessages = [];\n\n\t\t// Emit before_agent_start extension event\n\t\tconst result = await this._extensionRunner.emitBeforeAgentStart(\n\t\t\texpandedText,\n\t\t\tcurrentImages,\n\t\t\tthis._baseSystemPrompt,\n\t\t\tthis._baseSystemPromptOptions,\n\t\t);\n\t\t// Add all custom messages from extensions\n\t\tif (result?.messages) {\n\t\t\tfor (const msg of result.messages) {\n\t\t\t\tmessages.push({\n\t\t\t\t\trole: \"custom\",\n\t\t\t\t\tcustomType: msg.customType,\n\t\t\t\t\tcontent: msg.content ?? [],\n\t\t\t\t\tdisplay: msg.display,\n\t\t\t\t\tdetails: msg.details,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\t// Apply extension-modified system prompt, or reset to base\n\t\tif (result?.systemPrompt !== undefined) {\n\t\t\tthis._systemPromptOverride = result.systemPrompt;\n\t\t\tthis.agent.state.systemPrompt = result.systemPrompt;\n\t\t} else {\n\t\t\t// Ensure we're using the base prompt (in case previous turn had modifications)\n\t\t\tthis._systemPromptOverride = undefined;\n\t\t\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n\t\t}\n\t} catch (error) {\n\t\tpreflightResult?.(false);\n\t\tthrow error;\n\t}\n\n\tpreflightResult?.(true);\n\tawait this._runAgentPrompt(messages);\n}\n\n\nexport async function _runAgentPrompt(this: AgentSession, messages: AgentMessage | AgentMessage[]): Promise<void> {\n\ttry {\n\t\tawait this.agent.prompt(messages);\n\t\tawait this.waitForRetry();\n\t\tawait this._continueQueuedAgentMessages();\n\t\tawait this._awaitPendingPostCompactionContinuation();\n\t} finally {\n\t\tthis._systemPromptOverride = undefined;\n\t}\n}\n\nexport async function _runAgentContinue(this: AgentSession): Promise<void> {\n\tawait this.agent.continue();\n\tawait this.waitForRetry();\n\tawait this._continueQueuedAgentMessages();\n}\n\n\nexport async function _continueQueuedAgentMessages(this: AgentSession): Promise<void> {\n\tawait this._agentEventQueue;\n\n\twhile (this.agent.hasQueuedMessages()) {\n\t\tawait this.agent.continue();\n\t\tawait this.waitForRetry();\n\t\tawait this._agentEventQueue;\n\t}\n}\n\n/**\n * Try to execute a built-in slash command. Returns true if command was found and executed.\n */\n\nexport async function _tryExecuteBuiltinSlashCommand(this: AgentSession, text: string): Promise<boolean> {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tif (commandName !== ATOMIC_GUIDE_COMMAND_NAME) return false;\n\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1);\n\tconst mode = normalizeAtomicGuideMode(args);\n\tif (mode === \"help\" && this._extensionUIContext) {\n\t\tconst choice = await this._extensionUIContext.select(\"Atomic. Select where to start:\", [\n\t\t\t...ATOMIC_GUIDE_HELP_CHOICES,\n\t\t]);\n\t\tif (!choice || !isAtomicGuideHelpChoice(choice)) return true;\n\t\tawait this.sendCustomMessage(\n\t\t\t{\n\t\t\t\tcustomType: \"atomic\",\n\t\t\t\tcontent: getAtomicGuideMessage(atomicGuideModeForChoice(choice), this._cwd),\n\t\t\t\tdisplay: true,\n\t\t\t},\n\t\t\t{ triggerTurn: false },\n\t\t);\n\t\treturn true;\n\t}\n\n\tawait this.sendCustomMessage(\n\t\t{\n\t\t\tcustomType: \"atomic\",\n\t\t\tcontent: getAtomicGuideMessage(mode, this._cwd),\n\t\t\tdisplay: true,\n\t\t},\n\t\t{ triggerTurn: false },\n\t);\n\treturn true;\n}\n\n/**\n * Try to execute an extension command. Returns true if command was found and executed.\n */\n\nexport async function _tryExecuteExtensionCommand(this: AgentSession, text: string): Promise<boolean> {\n\t// Parse command name and args\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1);\n\n\tconst command = this._extensionRunner.getCommand(commandName);\n\tif (!command) return false;\n\n\t// Get command context from extension runner (includes session control methods)\n\tconst ctx = this._extensionRunner.createCommandContext();\n\n\ttry {\n\t\tawait command.handler(args, ctx);\n\t\treturn true;\n\t} catch (err) {\n\t\t// Emit error via extension runner\n\t\tthis._extensionRunner.emitError({\n\t\t\textensionPath: `command:${commandName}`,\n\t\t\tevent: \"command\",\n\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t});\n\t\treturn true;\n\t}\n}\n\n/**\n * Expand skill commands (/skill:name args) to their full content.\n * Returns the expanded text, or the original text if not a skill command or skill not found.\n * Emits errors via extension runner if file read fails.\n */\n\nexport function _expandSkillCommand(this: AgentSession, text: string): string {\n\tif (!text.startsWith(\"/skill:\")) return text;\n\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);\n\tconst args = spaceIndex === -1 ? \"\" : text.slice(spaceIndex + 1).trim();\n\n\tconst skill = this.resourceLoader.getSkills().skills.find((s) => s.name === skillName);\n\tif (!skill) return text; // Unknown skill, pass through\n\n\ttry {\n\t\tconst content = readFileSync(skill.filePath, \"utf-8\");\n\t\tconst body = stripFrontmatter(content).trim();\n\t\tconst skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n\t\treturn args ? `${skillBlock}\\n\\n${args}` : skillBlock;\n\t} catch (err) {\n\t\t// Emit error like extension commands do\n\t\tthis._extensionRunner.emitError({\n\t\t\textensionPath: skill.filePath,\n\t\t\tevent: \"skill_expansion\",\n\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t});\n\t\treturn text; // Return original on error\n\t}\n}\n\n/**\n * Queue a steering message while the agent is running.\n * Delivered after the current assistant turn finishes executing its tool calls,\n * before the next LLM call.\n * Expands skill commands and prompt templates. Errors on extension commands.\n * @param images Optional image attachments to include with the message\n * @throws Error if text is an extension command\n */\n\nexport async function steer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\t// Check for extension commands (cannot be queued)\n\tif (text.startsWith(\"/\")) {\n\t\tthis._throwIfExtensionCommand(text);\n\t}\n\n\t// Expand skill commands and prompt templates\n\tlet expandedText = this._expandSkillCommand(text);\n\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\tawait this._queueSteer(expandedText, images);\n}\n\n/**\n * Queue a follow-up message to be processed after the agent finishes.\n * Delivered only when agent has no more tool calls or steering messages.\n * Expands skill commands and prompt templates. Errors on extension commands.\n * @param images Optional image attachments to include with the message\n * @throws Error if text is an extension command\n */\n\nexport async function followUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\t// Check for extension commands (cannot be queued)\n\tif (text.startsWith(\"/\")) {\n\t\tthis._throwIfExtensionCommand(text);\n\t}\n\n\t// Expand skill commands and prompt templates\n\tlet expandedText = this._expandSkillCommand(text);\n\texpandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);\n\n\tawait this._queueFollowUp(expandedText, images);\n}\n\n/**\n * Internal: Queue a steering message (already expanded, no extension command check).\n */\n\nexport async function sendUserMessage(this: AgentSession, \n\tcontent: string | (TextContent | ImageContent)[],\n\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n): Promise<void> {\n\t// Normalize content to text string + optional images\n\tlet text: string;\n\tlet images: ImageContent[] | undefined;\n\n\tif (typeof content === \"string\") {\n\t\ttext = content;\n\t} else {\n\t\tconst textParts: string[] = [];\n\t\timages = [];\n\t\tfor (const part of content) {\n\t\t\tif (part.type === \"text\") {\n\t\t\t\ttextParts.push(part.text);\n\t\t\t} else {\n\t\t\t\timages.push(part);\n\t\t\t}\n\t\t}\n\t\ttext = textParts.join(\"\\n\");\n\t\tif (images.length === 0) images = undefined;\n\t}\n\n\t// Use prompt() with expandPromptTemplates: false to skip command handling and template expansion\n\tawait this.prompt(text, {\n\t\texpandPromptTemplates: false,\n\t\tstreamingBehavior: options?.deliverAs,\n\t\timages,\n\t\tsource: \"extension\",\n\t});\n}\n\n/**\n * Clear all queued messages and return them.\n * Useful for restoring to editor when user aborts.\n * @returns Object with steering and followUp arrays\n */\n\nexport const agentSessionPromptMethods = {\n\tprompt,\n\t_runAgentPrompt,\n\t_runAgentContinue,\n\t_continueQueuedAgentMessages,\n\t_tryExecuteBuiltinSlashCommand,\n\t_tryExecuteExtensionCommand,\n\t_expandSkillCommand,\n\tsteer,\n\tfollowUp,\n\tsendUserMessage,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-prompt.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-prompt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAA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OAAO,CAAC,OAAO,CAAC,CA4E3G;AAED;;GAEG;AAEH,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAInD;AAED;;;GAGG;AAEH,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAOpE;AAED,kDAAkD;AAElD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAE9E;AAMD;;;;;;;GAOG;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;CAUpC,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, Model } from \"@earendil-works/pi-ai/compat\";\nimport { clampThinkingLevel, isContextOverflow, modelsAreEqual } from \"@earendil-works/pi-ai/compat\";\nimport { sleep } from \"../utils/sleep.ts\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport { isCopilotGeminiModel } from \"./copilot-gemini-payload-sanitizer.ts\";\nimport { normalizeToolArgumentsForModel } from \"./copilot-gemini-tool-arguments.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\n\n\nconst THINKING_SUFFIXES = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const satisfies readonly ThinkingLevel[];\nconst THINKING_SUFFIX_SET: ReadonlySet<string> = new Set(THINKING_SUFFIXES);\n\nfunction modelLabel(model: Model<Api> | undefined): string {\n\treturn model ? `${model.provider}/${model.id}` : \"unknown model\";\n}\n\nfunction splitFallbackModel(value: string): { modelId: string; thinkingLevel?: ThinkingLevel } {\n\tconst trimmed = value.trim();\n\tconst index = trimmed.lastIndexOf(\":\");\n\tif (index < 0) return { modelId: trimmed };\n\tconst suffix = trimmed.slice(index + 1);\n\tif (!THINKING_SUFFIX_SET.has(suffix)) return { modelId: trimmed };\n\treturn { modelId: trimmed.slice(0, index), thinkingLevel: suffix as ThinkingLevel };\n}\n\nfunction resolveFallbackModel(this: AgentSession, value: string): { model: Model<Api>; thinkingLevel?: ThinkingLevel } | undefined {\n\tconst parsed = splitFallbackModel(value);\n\tif (!parsed.modelId.includes(\"/\")) {\n\t\tconst available = this._modelRegistry.getAvailable().filter((model) => model.id === parsed.modelId);\n\t\tconst preferredProvider = this.model?.provider ?? this.settingsManager.getDefaultProvider();\n\t\tconst model = available.find((candidate) => candidate.provider === preferredProvider) ?? (available.length === 1 ? available[0] : undefined);\n\t\treturn model ? { model, thinkingLevel: parsed.thinkingLevel } : undefined;\n\t}\n\tconst slash = parsed.modelId.indexOf(\"/\");\n\tconst provider = parsed.modelId.slice(0, slash);\n\tconst modelId = parsed.modelId.slice(slash + 1);\n\tconst model = this._modelRegistry.find(provider, modelId);\n\tif (!model || !this._modelRegistry.hasConfiguredAuth(model)) return undefined;\n\treturn { model, thinkingLevel: parsed.thinkingLevel };\n}\n\nfunction fallbackKey(model: Model<Api>, thinkingLevel: ThinkingLevel | undefined): string {\n\treturn `${model.provider}/${model.id}:${thinkingLevel ?? \"\"}`;\n}\n\nfunction hasProviderTransportDiagnostic(value: unknown, seen = new Set<unknown>(), includeMessageFields = false): boolean {\n\tif (value === null || value === undefined || seen.has(value)) return false;\n\tif (typeof value !== \"object\") {\n\t\treturn /provider_transport_failure|websocket.*error|sse.*404/i.test(String(value));\n\t}\n\tseen.add(value);\n\tconst record = value as Record<string, unknown>;\n\tconst fields = includeMessageFields\n\t\t? [record.type, record.code, record.name, record.message, record.errorMessage, record.status, record.statusCode]\n\t\t: [record.type, record.code, record.name, record.status, record.statusCode];\n\tfor (const field of fields) {\n\t\t if (typeof field === \"string\" || typeof field === \"number\") {\n\t\t\tif (/provider_transport_failure|websocket.*error|sse.*404|\\b404\\b/i.test(String(field))) return true;\n\t\t}\n\t}\n\tfor (const nested of [record.error, record.cause, ...(Array.isArray(record.diagnostics) ? record.diagnostics : [])]) {\n\t\tif (hasProviderTransportDiagnostic(nested, seen, true)) return true;\n\t}\n\treturn false;\n}\n\nfunction hasProviderModelUnavailableDiagnostic(value: unknown, seen = new Set<unknown>(), includeMessageFields = false): boolean {\n\tif (value === null || value === undefined || seen.has(value)) return false;\n\tif (typeof value !== \"object\") return false;\n\tseen.add(value);\n\tconst record = value as Record<string, unknown>;\n\tconst fields = includeMessageFields\n\t\t? [record.type, record.code, record.name, record.message, record.errorMessage]\n\t\t: [record.type, record.code, record.name, record.errorMessage];\n\tfor (const field of fields) {\n\t\tif (typeof field === \"string\" && /model(?:[_\\s-].*)?(?:not[_\\s-]?found|unavailable|unknown|disabled)|model[_-]?not[_-]?found/i.test(field)) return true;\n\t}\n\tfor (const nested of [record.error, record.cause, ...(Array.isArray(record.diagnostics) ? record.diagnostics : [])]) {\n\t\tif (hasProviderModelUnavailableDiagnostic(nested, seen, true)) return true;\n\t}\n\treturn false;\n}\nexport function _isRetryableError(this: AgentSession, message: AssistantMessage): boolean {\n\tif (message.stopReason !== \"error\") return false;\n\n\t// Context overflow is handled by compaction, not retry\n\tconst contextWindow = this.model?.contextWindow ?? 0;\n\tif (isContextOverflow(message, contextWindow)) return false;\n\n\tif (hasProviderTransportDiagnostic(message) || hasProviderModelUnavailableDiagnostic(message)) return true;\n\tif (!message.errorMessage) return false;\n\n\tconst err = message.errorMessage;\n\n\t// Safety triggers surface through structured API signals that pi-ai maps to\n\t// stopReason \"error\":\n\t// - Anthropic `refusal` stops become pi-ai's canned \"The model refused to\n\t// complete the request\" error message;\n\t// - OpenAI-style APIs (and github-copilot CAPI, which also maps spurious\n\t// Gemini RECITATION/safety blocks this way) surface\n\t// `finish_reason: content_filter`.\n\t// Spurious safety triggers are common in agentic settings, so these are\n\t// re-requested like transient failures, bounded by maxRetries (issue #1608).\n\tif (/refused to complete the request|finish.?reason:?\\s*content.?filter/i.test(err)) {\n\t\treturn true;\n\t}\n\n\t// Match: overloaded_error, provider returned error, rate limit, quota/usage-limit exhaustion (e.g. \"Codex error: The usage limit has been reached\" — retryable so configured fallbackModels can advance to a provider/model with remaining headroom), 429, 500, 502, 503, 504, service unavailable, network/connection errors (including connection lost), WebSocket transport closes/errors, fetch failed, premature stream endings, HTTP/2 closed before response, terminated, retry delay exceeded, and a bare/transient provider finish_reason \"error\" (e.g. github-copilot Gemini's CAPI mapping of MALFORMED_FUNCTION_CALL/OTHER/UNEXPECTED_TOOL_CALL). These are provider-agnostic transient failures.\n\treturn /overloaded|provider.?returned.?error|rate.?limit|usage.?limit|quota|too many requests|429|500|502|503|504|service.?unavailable|server.?error|internal.?error|network.?error|connection.?error|connection.?refused|connection.?lost|websocket.?closed|websocket.?error|other side closed|fetch failed|upstream.?connect|reset before headers|socket hang up|ended without|stream ended before message_stop|http2 request did not get a response|timed? out|timeout|terminated|retry delay|finish.?reason:?\\s*error/i.test(\n\t\terr,\n\t);\n}\n\n/**\n * For GitHub Copilot Gemini, reconstruct flattened tool-call arguments\n * (for example `edits[0].newText`) into the nested arrays/objects Gemini\n * produced before the assistant message is persisted, so saved transcripts\n * never carry the flattened CAPI wire shape and replays loaded from disk match\n * the structure Gemini signed. In-place, gated to Copilot Gemini, and a no-op\n * for well-formed arguments or any other provider/model. The outbound replay\n * normalizer still heals already-persisted (legacy) sessions on the wire.\n */\n\nexport function _normalizePersistedGeminiToolArgs(this: AgentSession, message: AssistantMessage): void {\n\tconst model = this.model;\n\tif (!model || !isCopilotGeminiModel(model)) return;\n\tfor (const block of message.content) {\n\t\tif (block.type !== \"toolCall\") continue;\n\t\tconst tool = this._toolRegistry.get(block.name);\n\t\tconst normalized = normalizeToolArgumentsForModel(block.arguments, model, tool?.parameters);\n\t\tif (normalized !== block.arguments && normalized !== null && typeof normalized === \"object\") {\n\t\t\tblock.arguments = normalized as Record<string, unknown>;\n\t\t}\n\t}\n}\n\n/**\n * Detect a degenerate empty completion: the provider ended the stream with no\n * usable content and zero output tokens. Seen with github-copilot Gemini models\n * that emit finish_reason \"stop\" (or a tool-use stop) with an empty content array\n * and 0 output tokens, leaving the turn dead instead of producing the next step.\n *\n * These are treated as retryable so the harness re-issues the request rather than\n * silently stopping mid-task. Guarded tightly (no text, no tool call, no thinking,\n * and output === 0) so legitimate non-empty turns are never matched.\n *\n * Intentionally provider-agnostic (not gated to Copilot Gemini): a degenerate\n * empty turn is a transient failure for any provider. It is bounded by\n * `maxRetries` and falls through to normal handling on exhaustion.\n */\n\nexport function _isEmptyCompletion(this: AgentSession, message: AssistantMessage): boolean {\n\t// Only \"completed\" stop reasons can be deceptively empty. Real errors are handled\n\t// by _isRetryableError; aborted/length turns are intentional outcomes.\n\tif (message.stopReason !== \"stop\" && message.stopReason !== \"toolUse\") return false;\n\n\tconst content = message.content;\n\tif (Array.isArray(content)) {\n\t\tconst hasContent = content.some((part) => {\n\t\t\tif (part.type === \"text\") return part.text.trim().length > 0;\n\t\t\tif (part.type === \"toolCall\") return true;\n\t\t\tif (part.type === \"thinking\") return part.redacted === true || part.thinking.trim().length > 0;\n\t\t\treturn true; // unknown part types count as content\n\t\t});\n\t\tif (hasContent) return false;\n\t}\n\n\t// A turn that produced output tokens but no surfaced content is not \"empty\"\n\t// (e.g. reasoning-only responses); leave those alone. Note: a provider that\n\t// fails to report `usage` (output defaults to 0) would make every\n\t// content-less turn match here; the dual requirement (empty content AND zero\n\t// output) keeps that false-positive risk low in practice.\n\treturn (message.usage?.output ?? 0) === 0;\n}\n\n/**\n * Detect a canned provider-side safety refusal that arrives as a *successful*\n * completion instead of an error. Seen with github-copilot GPT models under\n * heavy contexts: the endpoint intercepts the request and returns exactly\n * \"I'm sorry, but I cannot assist with that request.\" with zero usage and a\n * spurious stopReason of \"length\" (or \"stop\"), which the agent would otherwise\n * accept as the final answer and dead-end the turn (issue #1608).\n *\n * A text heuristic is unavoidable here: the OpenAI Responses API does signal\n * these interceptions structurally (`refusal` content parts plus\n * `incomplete_details.reason: \"content_filter\"`), but pi-ai's normalization\n * folds refusal parts into plain text blocks and collapses the `incomplete`\n * status to stopReason \"length\", discarding the reason — so no structured\n * refusal marker survives on the AssistantMessage. Providers whose safety\n * signals DO survive as structured errors (Anthropic refusal stops, OpenAI\n * `finish_reason: content_filter`) are matched in _isRetryableError instead.\n *\n * Guarded tightly so legitimate turns are never matched:\n * - only non-error completion stops (\"stop\" | \"length\" | \"toolUse\");\n * - content must be a single short canned refusal text — any tool call,\n * thinking block, or additional prose disqualifies the message;\n * - usage.output must be 0: a genuine model-authored refusal bills output\n * tokens, while the intercepted canned refusal reports zero usage.\n *\n * Treated as retryable so the harness re-requests the model call rather than\n * accepting the refusal; bounded by `maxRetries` like every other retry path.\n */\n\nconst CANNED_SAFETY_REFUSAL_PATTERN =\n\t/^(?:i['’]?m sorry[,.]?\\s+(?:but\\s+)?|sorry[,.]?\\s+(?:but\\s+)?)?i\\s+(?:cannot|can['’]?t|can\\s+not|am\\s+unable\\s+to|am\\s+not\\s+able\\s+to)\\s+(?:assist|help|comply|continue)(?:\\s+with)?(?:\\s+(?:that|this))?(?:\\s+(?:request|task))?\\.?$/i;\n\nconst CANNED_SAFETY_REFUSAL_MAX_LENGTH = 120;\n\nexport function _isSafetyRefusal(this: AgentSession, message: AssistantMessage): boolean {\n\t// Real errors are handled by _isRetryableError; aborts are user-initiated.\n\tif (message.stopReason !== \"stop\" && message.stopReason !== \"length\" && message.stopReason !== \"toolUse\") {\n\t\treturn false;\n\t}\n\n\tconst content = message.content;\n\tif (!Array.isArray(content) || content.length === 0) return false;\n\n\tlet text = \"\";\n\tfor (const part of content) {\n\t\tif (part.type === \"toolCall\") return false;\n\t\tif (part.type === \"thinking\" && (part.redacted === true || part.thinking.trim().length > 0)) return false;\n\t\tif (part.type === \"text\") text += part.text;\n\t}\n\ttext = text.trim();\n\tif (text.length === 0 || text.length > CANNED_SAFETY_REFUSAL_MAX_LENGTH) return false;\n\tif (!CANNED_SAFETY_REFUSAL_PATTERN.test(text)) return false;\n\n\t// Zero billed output distinguishes a provider interception from legitimate\n\t// model-authored refusal prose, which is never auto-retried.\n\treturn (message.usage?.output ?? 0) === 0;\n}\n\n/**\n * Handle retryable errors with exponential backoff.\n * @returns true if retry was initiated, false if max retries exceeded or disabled\n */\n\nexport async function _trySwitchToFallbackModel(this: AgentSession, message: AssistantMessage): Promise<boolean> {\n\tif (this._fallbackModels.length === 0 || !this.model) return false;\n\n\tthis._fallbackAttemptedKeys.add(fallbackKey(this.model, this.thinkingLevel));\n\tconst fromModel = this.model;\n\tfor (const rawCandidate of this._fallbackModels) {\n\t\tconst candidate = resolveFallbackModel.call(this, rawCandidate);\n\t\tif (!candidate) continue;\n\t\tconst key = fallbackKey(candidate.model, candidate.thinkingLevel);\n\t\tif (this._fallbackAttemptedKeys.has(key)) continue;\n\t\tconst nextModel = this._withContextWindowForModelSwitch(candidate.model);\n\t\tconst nextLevel = clampThinkingLevel(\n\t\t\tnextModel,\n\t\t\tcandidate.thinkingLevel ?? this.settingsManager.getDefaultThinkingLevel() ?? this.thinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t) as ThinkingLevel;\n\t\tif (modelsAreEqual(candidate.model, fromModel) && nextLevel === this.thinkingLevel) continue;\n\t\tif (this._retryAttempt > 0) {\n\t\t\tthis._emit({\n\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\tsuccess: true,\n\t\t\t\tattempt: Math.max(0, this._retryAttempt - 1),\n\t\t\t});\n\t\t}\n\t\tthis._fallbackAttemptedKeys.add(key);\n\t\tthis._emit({\n\t\t\ttype: \"model_fallback_start\",\n\t\t\tfrom: modelLabel(fromModel),\n\t\t\tto: `${nextModel.provider}/${nextModel.id}`,\n\t\t\treason: message.errorMessage || \"Retryable model error\",\n\t\t\tattempt: this._fallbackAttemptedKeys.size - 1,\n\t\t});\n\n\t\tconst messages = this.agent.state.messages;\n\t\tif (messages.length > 0 && messages[messages.length - 1]?.role === \"assistant\") {\n\t\t\tthis.agent.state.messages = messages.slice(0, -1);\n\t\t}\n\t\tthis.agent.state.model = nextModel;\n\t\tthis.sessionManager.appendModelChange(nextModel.provider, nextModel.id);\n\t\tthis._appendContextWindowChangeIfChanged(fromModel, nextModel);\n\t\tthis.agent.state.thinkingLevel = nextLevel;\n\t\tthis.sessionManager.appendThinkingLevelChange(nextLevel);\n\t\tthis._refreshBaseSystemPromptFromActiveTools();\n\t\tthis._emitModelChanged(nextModel, fromModel, \"fallback\");\n\t\tawait this._emitModelSelect(nextModel, fromModel, \"fallback\");\n\t\tthis._retryAttempt = 0;\n\n\t\tsetTimeout(() => {\n\t\t\tthis.agent.continue().then(\n\t\t\t\t() => {\n\t\t\t\t\t// A resolved continuation may still have produced an assistant\n\t\t\t\t\t// error that will be classified by agent_end and may advance to\n\t\t\t\t\t// the next fallback. Do not emit a successful fallback end here;\n\t\t\t\t\t// agent_end/turn_end clear UI state for successful turns, while\n\t\t\t\t\t// fallback exhaustion emits the failure end event.\n\t\t\t\t},\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tconst finalError = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tthis._emit({ type: \"model_fallback_end\", success: false, from: modelLabel(fromModel), to: modelLabel(nextModel), finalError });\n\t\t\t\t\tthis._retryAttempt = 0;\n\t\t\t\t\tthis._resolveRetry();\n\t\t\t\t},\n\t\t\t);\n\t\t}, 0);\n\t\treturn true;\n\t}\n\tthis._emit({ type: \"model_fallback_end\", success: false, from: modelLabel(fromModel), finalError: message.errorMessage });\n\treturn false;\n}\n\nexport async function _handleRetryableError(this: AgentSession, message: AssistantMessage): Promise<boolean> {\n\tconst settings = this.settingsManager.getRetrySettings();\n\tif (!settings.enabled) {\n\t\treturn this._trySwitchToFallbackModel(message);\n\t}\n\n\t// Retry promise is created synchronously in _handleAgentEvent for agent_end.\n\t// Keep a defensive fallback here in case a future refactor bypasses that path.\n\tif (!this._retryPromise) {\n\t\tthis._retryPromise = new Promise((resolve) => {\n\t\t\tthis._retryResolve = resolve;\n\t\t});\n\t}\n\n\tthis._retryAttempt++;\n\n\tif (this._retryAttempt > settings.maxRetries) {\n\t\tif (await this._trySwitchToFallbackModel(message)) {\n\t\t\treturn true;\n\t\t}\n\t\t// Max retries exceeded, emit final failure and reset\n\t\tthis._emit({\n\t\t\ttype: \"auto_retry_end\",\n\t\t\tsuccess: false,\n\t\t\tattempt: this._retryAttempt - 1,\n\t\t\tfinalError: message.errorMessage,\n\t\t});\n\t\tthis._retryAttempt = 0;\n\t\tthis._resolveRetry(); // Resolve so waitForRetry() completes\n\t\treturn false;\n\t}\n\n\tconst delayMs = settings.baseDelayMs * 2 ** (this._retryAttempt - 1);\n\n\tthis._emit({\n\t\ttype: \"auto_retry_start\",\n\t\tattempt: this._retryAttempt,\n\t\tmaxAttempts: settings.maxRetries,\n\t\tdelayMs,\n\t\terrorMessage: message.errorMessage || \"Unknown error\",\n\t});\n\n\t// Remove error message from agent state (keep in session for history)\n\tconst messages = this.agent.state.messages;\n\tif (messages.length > 0 && messages[messages.length - 1].role === \"assistant\") {\n\t\tthis.agent.state.messages = messages.slice(0, -1);\n\t}\n\n\t// Wait with exponential backoff (abortable)\n\tthis._retryAbortController = new AbortController();\n\ttry {\n\t\tawait sleep(delayMs, this._retryAbortController.signal);\n\t} catch {\n\t\t// Aborted during sleep - emit end event so UI can clean up\n\t\tconst attempt = this._retryAttempt;\n\t\tthis._retryAttempt = 0;\n\t\tthis._retryAbortController = undefined;\n\t\tthis._emit({\n\t\t\ttype: \"auto_retry_end\",\n\t\t\tsuccess: false,\n\t\t\tattempt,\n\t\t\tfinalError: \"Retry cancelled\",\n\t\t});\n\t\tthis._resolveRetry();\n\t\treturn false;\n\t}\n\tthis._retryAbortController = undefined;\n\n\t// Retry via continue() - use setTimeout to break out of event handler chain\n\tsetTimeout(() => {\n\t\tthis.agent.continue().catch(() => {\n\t\t\t// Retry failed - will be caught by next agent_end\n\t\t});\n\t}, 0);\n\n\treturn true;\n}\n\n/**\n * Cancel in-progress retry.\n */\n\nexport function abortRetry(this: AgentSession): void {\n\tthis._retryAbortController?.abort();\n\t// Note: _retryAttempt is reset in the catch block of _autoRetry\n\tthis._resolveRetry();\n}\n\n/**\n * Wait for any in-progress retry to complete.\n * Returns immediately if no retry is in progress.\n */\n\nexport async function waitForRetry(this: AgentSession): Promise<void> {\n\tif (!this._retryPromise) {\n\t\treturn;\n\t}\n\n\tawait this._retryPromise;\n\tawait this.agent.waitForIdle();\n}\n\n/** Whether auto-retry is currently in progress */\n\nexport function setAutoRetryEnabled(this: AgentSession, enabled: boolean): void {\n\tthis.settingsManager.setRetryEnabled(enabled);\n}\n\n// =========================================================================\n// Bash Execution\n// =========================================================================\n\n/**\n * Execute a bash command.\n * Adds result to agent context and session.\n * @param command The bash command to execute\n * @param onChunk Optional streaming callback for output\n * @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)\n * @param options.operations Custom BashOperations for remote execution\n */\n\nexport const agentSessionRetryMethods = {\n\t_isRetryableError,\n\t_normalizePersistedGeminiToolArgs,\n\t_isEmptyCompletion,\n\t_isSafetyRefusal,\n\t_handleRetryableError,\n\t_trySwitchToFallbackModel,\n\tabortRetry,\n\twaitForRetry,\n\tsetAutoRetryEnabled,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-retry.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-retry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAO,gBAAgB,EAAS,MAAM,8BAA8B,CAAC;AAMjF,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AA4E9F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CA6BxF;AAED;;;;;;;;GAQG;AAEH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAWrG;AAED;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAsBzF;AAmCD,wBAAgB,gBAAgB,CAAC,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