@code-yeongyu/senpi 2026.9.9 → 2026.9.10
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 +82 -1
- package/README.md +2 -0
- package/dist/beta/omo-local-update-worker.js.map +1 -1
- package/dist/beta/omo-local-update.d.ts.map +1 -1
- package/dist/brand-dir-migration.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.js.map +1 -1
- package/dist/cli/experimental/command.d.ts.map +1 -1
- package/dist/cli/grok-neo-gate.js.map +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client/remote-session.d.ts.map +1 -1
- package/dist/client/remote-session.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +43 -19
- package/dist/config.js.map +1 -1
- package/dist/core/agent-abort-provenance.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +46 -7
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +109 -6
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/agent-settled-delivery.d.ts.map +1 -1
- package/dist/core/auth-providers.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/brand.js.map +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/lifecycle.d.ts.map +1 -1
- package/dist/core/compaction/stream-watchdog.d.ts.map +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/credential-accounts.js.map +1 -1
- package/dist/core/credential-pool/classify.js.map +1 -1
- package/dist/core/credential-pool/failover.d.ts.map +1 -1
- package/dist/core/credential-pool/rotation-stream.js.map +1 -1
- package/dist/core/credential-pool/state-store.d.ts +2 -2
- package/dist/core/credential-pool/state-store.d.ts.map +1 -1
- package/dist/core/credential-pool/state-store.js.map +1 -1
- package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
- package/dist/core/edited-assistant-message.d.ts +24 -0
- package/dist/core/edited-assistant-message.d.ts.map +1 -0
- package/dist/core/edited-assistant-message.js +57 -0
- package/dist/core/edited-assistant-message.js.map +1 -0
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ask-user/extension.d.ts +3 -0
- package/dist/core/extensions/builtin/ask-user/extension.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/extension.js +47 -0
- package/dist/core/extensions/builtin/ask-user/extension.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/family.d.ts +8 -0
- package/dist/core/extensions/builtin/ask-user/family.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/family.js +6 -0
- package/dist/core/extensions/builtin/ask-user/family.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/format.d.ts +22 -0
- package/dist/core/extensions/builtin/ask-user/format.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/format.js +109 -0
- package/dist/core/extensions/builtin/ask-user/format.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/index.d.ts +4 -0
- package/dist/core/extensions/builtin/ask-user/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/index.js +4 -0
- package/dist/core/extensions/builtin/ask-user/index.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/params.d.ts +27 -0
- package/dist/core/extensions/builtin/ask-user/params.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/params.js +78 -0
- package/dist/core/extensions/builtin/ask-user/params.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/pending.d.ts +58 -0
- package/dist/core/extensions/builtin/ask-user/pending.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/pending.js +130 -0
- package/dist/core/extensions/builtin/ask-user/pending.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/registry.d.ts +21 -0
- package/dist/core/extensions/builtin/ask-user/registry.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/registry.js +20 -0
- package/dist/core/extensions/builtin/ask-user/registry.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/render.d.ts +4 -0
- package/dist/core/extensions/builtin/ask-user/render.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/render.js +25 -0
- package/dist/core/extensions/builtin/ask-user/render.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/resume.d.ts +4 -0
- package/dist/core/extensions/builtin/ask-user/resume.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/resume.js +85 -0
- package/dist/core/extensions/builtin/ask-user/resume.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/schema.d.ts +40 -0
- package/dist/core/extensions/builtin/ask-user/schema.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/schema.js +102 -0
- package/dist/core/extensions/builtin/ask-user/schema.js.map +1 -0
- package/dist/core/extensions/builtin/ask-user/tool.d.ts +8 -0
- package/dist/core/extensions/builtin/ask-user/tool.d.ts.map +1 -0
- package/dist/core/extensions/builtin/ask-user/tool.js +195 -0
- package/dist/core/extensions/builtin/ask-user/tool.js.map +1 -0
- package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
- package/dist/core/extensions/builtin/btw/panel.d.ts.map +1 -1
- package/dist/core/extensions/builtin/btw/side-query.js.map +1 -1
- package/dist/core/extensions/builtin/cache-keepalive/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cache-keepalive/index.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/account-management.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/accounts.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/accounts.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/affinity.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/affinity.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts +11 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js +12 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/custom-tools.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/executable-path-lookup.d.ts +14 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/executable-path-lookup.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/executable-path-lookup.js +42 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/executable-path-lookup.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/executable.d.ts +18 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/executable.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/executable.js +105 -36
- package/dist/core/extensions/builtin/claude-sdk-oauth/executable.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/failover.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/refusal.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +4 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-attempt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/settings.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream-protocol.d.ts +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/tool-watch.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/context-reduction.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/lane-policy.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-convert.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/resume-admission.d.ts +7 -0
- package/dist/core/extensions/builtin/compaction/resume-admission.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/resume-admission.js +7 -0
- package/dist/core/extensions/builtin/compaction/resume-admission.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/resume-slice.d.ts +23 -0
- package/dist/core/extensions/builtin/compaction/resume-slice.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/resume-slice.js +99 -0
- package/dist/core/extensions/builtin/compaction/resume-slice.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/summarization-retry.js.map +1 -1
- package/dist/core/extensions/builtin/config-reload/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/config-reload/index.js.map +1 -1
- package/dist/core/extensions/builtin/config-reload/log.js.map +1 -1
- package/dist/core/extensions/builtin/config-reload/protocol.d.ts.map +1 -1
- package/dist/core/extensions/builtin/config-reload/reload-deferral.d.ts.map +1 -1
- package/dist/core/extensions/builtin/config-reload/watch-engine.d.ts.map +1 -1
- package/dist/core/extensions/builtin/config-reload/watch-event-source.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/account-command.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/accounts.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/affinity.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/affinity.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/diagnostics.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/diagnostics.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/executable.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/executable.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/failover.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/guardrails.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/guardrails.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/index.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/oauth-login.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/session-router.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/session-router.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream-parser.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream-parser.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/transport.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/cache-warm-renderer.js.map +1 -1
- package/dist/core/extensions/builtin/goal/command-registration.js.map +1 -1
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/elapsed-ticker.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +57 -4
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/persistence.js.map +1 -1
- package/dist/core/extensions/builtin/goal/prompt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/prompt.js +9 -6
- package/dist/core/extensions/builtin/goal/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/goal/store.js.map +1 -1
- package/dist/core/extensions/builtin/goal/tool-registration.js +1 -1
- package/dist/core/extensions/builtin/goal/tool-registration.js.map +1 -1
- package/dist/core/extensions/builtin/goal/turn-usage.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/ui.js.map +1 -1
- package/dist/core/extensions/builtin/goal/wait-progress.js.map +1 -1
- package/dist/core/extensions/builtin/goal/wait-ticker.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-account.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-account.js +1 -0
- package/dist/core/extensions/builtin/gpt-account.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/preview.js.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.d.ts.map +1 -1
- package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
- package/dist/core/extensions/builtin/help/panel.d.ts.map +1 -1
- package/dist/core/extensions/builtin/history-search/index.js.map +1 -1
- package/dist/core/extensions/builtin/history-search/overlay.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/command-runner.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/dispatcher.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/plugin-loader.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/tool-adapter.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust-storage.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/imagegen/index.js.map +1 -1
- package/dist/core/extensions/builtin/imagegen/params.d.ts +45 -0
- package/dist/core/extensions/builtin/imagegen/params.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/params.js +81 -0
- package/dist/core/extensions/builtin/imagegen/params.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/paths.d.ts +10 -4
- package/dist/core/extensions/builtin/imagegen/paths.d.ts.map +1 -1
- package/dist/core/extensions/builtin/imagegen/paths.js +43 -10
- package/dist/core/extensions/builtin/imagegen/paths.js.map +1 -1
- package/dist/core/extensions/builtin/imagegen/reference-images.d.ts +20 -0
- package/dist/core/extensions/builtin/imagegen/reference-images.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/reference-images.js +70 -0
- package/dist/core/extensions/builtin/imagegen/reference-images.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/skill/SKILL.md +58 -33
- package/dist/core/extensions/builtin/imagegen/tool.d.ts +15 -19
- package/dist/core/extensions/builtin/imagegen/tool.d.ts.map +1 -1
- package/dist/core/extensions/builtin/imagegen/tool.js +74 -52
- package/dist/core/extensions/builtin/imagegen/tool.js.map +1 -1
- package/dist/core/extensions/builtin/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/index.js +2 -0
- package/dist/core/extensions/builtin/index.js.map +1 -1
- package/dist/core/extensions/builtin/look-at/model-selector.d.ts.map +1 -1
- package/dist/core/extensions/builtin/look-at/runner.js.map +1 -1
- package/dist/core/extensions/builtin/loop/command.js.map +1 -1
- package/dist/core/extensions/builtin/loop/cron-planner.js.map +1 -1
- package/dist/core/extensions/builtin/loop/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop/index.js.map +1 -1
- package/dist/core/extensions/builtin/loop/loopfile.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop/scheduler.js.map +1 -1
- package/dist/core/extensions/builtin/loop/status.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop/store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/detectors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/escalation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/escalation.js.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/index.js.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/notice.js.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/renderer.js.map +1 -1
- package/dist/core/extensions/builtin/loop-guard/tracker.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/active-set.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/callback.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/oauth-errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/oauth-errors.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/oauth-provider.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/oauth-refresh.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/oauth-refresh.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/oauth.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/auth/token-store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/catalog.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/config-schema.d.ts +28 -28
- package/dist/core/extensions/builtin/mcp/config.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/connection.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/elicitation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/elicitation.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/errors.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/register.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/guard/output-guard.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/guard/output-guard.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/log.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/reconnect.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/nested-agents-md/core/errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/nested-agents-md/core/injection-cache.d.ts.map +1 -1
- package/dist/core/extensions/builtin/nested-agents-md/core/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/oauth-login-interaction.d.ts +13 -6
- package/dist/core/extensions/builtin/oauth-login-interaction.d.ts.map +1 -1
- package/dist/core/extensions/builtin/oauth-login-interaction.js +43 -19
- package/dist/core/extensions/builtin/oauth-login-interaction.js.map +1 -1
- package/dist/core/extensions/builtin/openai-image-gen/inject.d.ts +5 -3
- package/dist/core/extensions/builtin/openai-image-gen/inject.d.ts.map +1 -1
- package/dist/core/extensions/builtin/openai-image-gen/inject.js +7 -4
- package/dist/core/extensions/builtin/openai-image-gen/inject.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/arity.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/service.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/wildcard.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5.d.ts +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts +4 -4
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js +4 -4
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
- package/dist/core/extensions/builtin/rule-activation/renderer.js.map +1 -1
- package/dist/core/extensions/builtin/rules/commands.js.map +1 -1
- package/dist/core/extensions/builtin/rules/config.js.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/rules/project-root.js.map +1 -1
- package/dist/core/extensions/builtin/rules/ui/dynamic-border.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/ui/rules-banner.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/manager.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/manager.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-status-ticker.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/restore.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/render.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/normalize.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-operations.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-widget-component.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/todo-widget-component.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todo.js.map +1 -1
- package/dist/core/extensions/builtin/tool-search/native-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tool-search/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tool-search/service.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/detectors/leak-context.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/detectors/token-grammar.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/manager.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/message-update.js.map +1 -1
- package/dist/core/extensions/builtin/ttsr/repetitive-turns-lane.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/stream-utils.d.ts.map +1 -1
- package/dist/core/extensions/builtin/ttsr/watch.d.ts.map +1 -1
- package/dist/core/extensions/builtin/webfetch/webfetch/errors.d.ts.map +1 -1
- package/dist/core/extensions/builtin/webfetch/webfetch/tool.d.ts +1 -1
- package/dist/core/extensions/builtin/websearch/websearch/native.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +2 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +17 -8
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/notice/box.d.ts.map +1 -1
- package/dist/core/extensions/notice/box.js +13 -5
- package/dist/core/extensions/notice/box.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +11 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +23 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +76 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +182 -177
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +5 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/lockfile-policy.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config-schema.d.ts +150 -150
- package/dist/core/model-config-schema.d.ts.map +1 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +2 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +11 -7
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/retry-fallback/controller.d.ts.map +1 -1
- package/dist/core/retry-fallback/cooldown.d.ts.map +1 -1
- package/dist/core/retry-fallback/cooldown.js.map +1 -1
- package/dist/core/retry-fallback/expansion.js.map +1 -1
- package/dist/core/retry-fallback/log.js.map +1 -1
- package/dist/core/retry-fallback/probe-scheduler.d.ts.map +1 -1
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +24 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-activity.d.ts.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-log.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-resident-store.d.ts.map +1 -1
- package/dist/core/session-sidecar-store.d.ts.map +1 -1
- package/dist/core/session-summary-lru.d.ts.map +1 -1
- package/dist/core/session-work-barrier.d.ts.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +14 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-shapes.d.ts +7 -0
- package/dist/core/settings-shapes.d.ts.map +1 -1
- package/dist/core/settings-shapes.js +3 -1
- package/dist/core/settings-shapes.js.map +1 -1
- package/dist/core/telemetry.js.map +1 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bounded-realpath.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/read-classifiers.d.ts +17 -0
- package/dist/core/tools/read-classifiers.d.ts.map +1 -0
- package/dist/core/tools/read-classifiers.js +26 -0
- package/dist/core/tools/read-classifiers.js.map +1 -0
- package/dist/core/tools/read.d.ts +5 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +21 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/tail-window.d.ts.map +1 -1
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write-result.js.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/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/huggingface.d.ts.map +1 -1
- package/dist/extensions/llama/huggingface.js.map +1 -1
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/from-source-config-guard.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/app-server/daemon/occupancy.d.ts.map +1 -1
- package/dist/modes/app-server/daemon/process.d.ts.map +1 -1
- package/dist/modes/app-server/daemon/process.js.map +1 -1
- package/dist/modes/app-server/daemon.js.map +1 -1
- package/dist/modes/app-server/protocol/collaboration-mode.d.ts.map +1 -1
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputAnswer.d.ts +7 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputAnswer.d.ts.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputAnswer.js +4 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputAnswer.js.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputOption.d.ts +8 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputOption.d.ts.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputOption.js +4 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputOption.js.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputParams.d.ts +12 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputParams.d.ts.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputParams.js +4 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputParams.js.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputQuestion.d.ts +13 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputQuestion.d.ts.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputQuestion.js +4 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputQuestion.js.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputResponse.d.ts +10 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputResponse.d.ts.map +1 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputResponse.js +4 -0
- package/dist/modes/app-server/protocol/generated/v2/ToolRequestUserInputResponse.js.map +1 -0
- package/dist/modes/app-server/protocol/index.d.ts +2 -0
- package/dist/modes/app-server/protocol/index.d.ts.map +1 -1
- package/dist/modes/app-server/protocol/index.js.map +1 -1
- package/dist/modes/app-server/protocol/methods.d.ts +1 -0
- package/dist/modes/app-server/protocol/methods.d.ts.map +1 -1
- package/dist/modes/app-server/protocol/methods.js +1 -0
- package/dist/modes/app-server/protocol/methods.js.map +1 -1
- package/dist/modes/app-server/rpc/errors.d.ts.map +1 -1
- package/dist/modes/app-server/runtime.d.ts.map +1 -1
- package/dist/modes/app-server/runtime.js +22 -6
- package/dist/modes/app-server/runtime.js.map +1 -1
- package/dist/modes/app-server/search/fuzzy-files.js.map +1 -1
- package/dist/modes/app-server/search/fuzzy-search-service.d.ts.map +1 -1
- package/dist/modes/app-server/server/account.js.map +1 -1
- package/dist/modes/app-server/server/approval-bridge.d.ts.map +1 -1
- package/dist/modes/app-server/server/approval-types.d.ts.map +1 -1
- package/dist/modes/app-server/server/approval-ui-context.d.ts +2 -1
- package/dist/modes/app-server/server/approval-ui-context.d.ts.map +1 -1
- package/dist/modes/app-server/server/approval-ui-context.js +9 -1
- package/dist/modes/app-server/server/approval-ui-context.js.map +1 -1
- package/dist/modes/app-server/server/catalogs.js.map +1 -1
- package/dist/modes/app-server/server/config.js.map +1 -1
- package/dist/modes/app-server/server/connection.d.ts.map +1 -1
- package/dist/modes/app-server/server/models.js.map +1 -1
- package/dist/modes/app-server/server/notifications.d.ts.map +1 -1
- package/dist/modes/app-server/server/notifications.js.map +1 -1
- package/dist/modes/app-server/server/server-core.d.ts.map +1 -1
- package/dist/modes/app-server/server/server-core.js.map +1 -1
- package/dist/modes/app-server/server/skills.js.map +1 -1
- package/dist/modes/app-server/server/user-input-bridge.d.ts +16 -0
- package/dist/modes/app-server/server/user-input-bridge.d.ts.map +1 -0
- package/dist/modes/app-server/server/user-input-bridge.js +142 -0
- package/dist/modes/app-server/server/user-input-bridge.js.map +1 -0
- package/dist/modes/app-server/server/user-input-types.d.ts +43 -0
- package/dist/modes/app-server/server/user-input-types.d.ts.map +1 -0
- package/dist/modes/app-server/server/user-input-types.js +51 -0
- package/dist/modes/app-server/server/user-input-types.js.map +1 -0
- package/dist/modes/app-server/threads/archive-state.d.ts.map +1 -1
- package/dist/modes/app-server/threads/handlers.js.map +1 -1
- package/dist/modes/app-server/threads/mcp-wire-status.d.ts.map +1 -1
- package/dist/modes/app-server/threads/metadata-state.d.ts.map +1 -1
- package/dist/modes/app-server/threads/projection-file-changes.js.map +1 -1
- package/dist/modes/app-server/threads/projection-message-items.d.ts.map +1 -1
- package/dist/modes/app-server/threads/projection-turn-diff.d.ts.map +1 -1
- package/dist/modes/app-server/threads/projection-web-search.js.map +1 -1
- package/dist/modes/app-server/threads/projection.d.ts.map +1 -1
- package/dist/modes/app-server/threads/registry.d.ts.map +1 -1
- package/dist/modes/app-server/threads/registry.js.map +1 -1
- package/dist/modes/app-server/threads/search-cache.d.ts.map +1 -1
- package/dist/modes/app-server/threads/turn-log.d.ts.map +1 -1
- package/dist/modes/app-server/threads/turn-runtime.d.ts.map +1 -1
- package/dist/modes/app-server/threads/turn-runtime.js.map +1 -1
- package/dist/modes/app-server/threads/turns.js.map +1 -1
- package/dist/modes/app-server/threads/wire-thread.js.map +1 -1
- package/dist/modes/app-server/transports/unix-socket.d.ts.map +1 -1
- package/dist/modes/app-server/transports/unix-socket.js.map +1 -1
- package/dist/modes/app-server/transports/websocket.d.ts.map +1 -1
- package/dist/modes/app-server/turn-adapter.d.ts +3 -3
- package/dist/modes/app-server/turn-adapter.d.ts.map +1 -1
- package/dist/modes/app-server/turn-adapter.js +36 -5
- package/dist/modes/app-server/turn-adapter.js.map +1 -1
- package/dist/modes/interactive/compaction-queue-transfer.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/ask-user-async-widget.d.ts +39 -0
- package/dist/modes/interactive/components/ask-user-async-widget.d.ts.map +1 -0
- package/dist/modes/interactive/components/ask-user-async-widget.js +82 -0
- package/dist/modes/interactive/components/ask-user-async-widget.js.map +1 -0
- package/dist/modes/interactive/components/ask-user-question-keys.d.ts +21 -0
- package/dist/modes/interactive/components/ask-user-question-keys.d.ts.map +1 -0
- package/dist/modes/interactive/components/ask-user-question-keys.js +115 -0
- package/dist/modes/interactive/components/ask-user-question-keys.js.map +1 -0
- package/dist/modes/interactive/components/ask-user-question-render.d.ts +17 -0
- package/dist/modes/interactive/components/ask-user-question-render.d.ts.map +1 -0
- package/dist/modes/interactive/components/ask-user-question-render.js +75 -0
- package/dist/modes/interactive/components/ask-user-question-render.js.map +1 -0
- package/dist/modes/interactive/components/ask-user-question-state.d.ts +52 -0
- package/dist/modes/interactive/components/ask-user-question-state.d.ts.map +1 -0
- package/dist/modes/interactive/components/ask-user-question-state.js +134 -0
- package/dist/modes/interactive/components/ask-user-question-state.js.map +1 -0
- package/dist/modes/interactive/components/ask-user-question.d.ts +50 -0
- package/dist/modes/interactive/components/ask-user-question.d.ts.map +1 -0
- package/dist/modes/interactive/components/ask-user-question.js +148 -0
- package/dist/modes/interactive/components/ask-user-question.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/assistant-render-descriptors.js.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/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/continuity-notice.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-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js.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/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/favorite-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js.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/progressive-transcript-container.d.ts.map +1 -1
- package/dist/modes/interactive/components/render-signature.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/shortcut-overlay.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/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.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-images.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-renderer-boundary.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +4 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +17 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/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/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/grok/chrome.d.ts.map +1 -1
- package/dist/modes/interactive/grok/footer.d.ts.map +1 -1
- package/dist/modes/interactive/grok/input-card.d.ts.map +1 -1
- package/dist/modes/interactive/grok/palette.d.ts.map +1 -1
- package/dist/modes/interactive/grok/tool-row.d.ts.map +1 -1
- package/dist/modes/interactive/grok/welcome-card.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-host-runtime.d.ts +6 -0
- package/dist/modes/interactive/interactive-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-host-runtime.js +32 -3
- package/dist/modes/interactive/interactive-host-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +35 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +413 -100
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/login-outcome.d.ts +20 -0
- package/dist/modes/interactive/login-outcome.d.ts.map +1 -0
- package/dist/modes/interactive/login-outcome.js +35 -0
- package/dist/modes/interactive/login-outcome.js.map +1 -0
- package/dist/modes/interactive/startup-tools.js.map +1 -1
- package/dist/modes/interactive/streaming-reveal-content.d.ts.map +1 -1
- package/dist/modes/interactive/streaming-reveal-content.js.map +1 -1
- package/dist/modes/interactive/streaming-reveal.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/input-tips.d.ts +7 -7
- package/dist/modes/interactive/tips/catalog/input-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/input-tips.js +5 -0
- package/dist/modes/interactive/tips/catalog/input-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/model-tips.d.ts +1 -1
- package/dist/modes/interactive/tips/catalog/workspace-tips.d.ts +1 -1
- package/dist/modes/interactive/tips/scheduler.js.map +1 -1
- package/dist/modes/interactive/tips/working-tip.d.ts.map +1 -1
- package/dist/modes/interactive/tool-args-reveal.d.ts.map +1 -1
- package/dist/modes/interactive/tool-result-reveal.d.ts.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +8 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/provider-native-rendering.d.ts.map +1 -1
- package/dist/modes/provider-native-rendering.js +35 -0
- package/dist/modes/provider-native-rendering.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +72 -1
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/connection-question-bridge.d.ts +18 -0
- package/dist/modes/rpc/connection-question-bridge.d.ts.map +1 -0
- package/dist/modes/rpc/connection-question-bridge.js +156 -0
- package/dist/modes/rpc/connection-question-bridge.js.map +1 -0
- package/dist/modes/rpc/custom-capability.d.ts +2 -0
- package/dist/modes/rpc/custom-capability.d.ts.map +1 -1
- package/dist/modes/rpc/custom-capability.js +2 -0
- package/dist/modes/rpc/custom-capability.js.map +1 -1
- package/dist/modes/rpc/event-output-buffer.js.map +1 -1
- package/dist/modes/rpc/host-ensure.js.map +1 -1
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
- package/dist/modes/rpc/host-lifecycle.js.map +1 -1
- package/dist/modes/rpc/host-watchdog.js.map +1 -1
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/ownership-safe-lock.d.ts.map +1 -1
- package/dist/modes/rpc/ownership-safe-lock.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +20 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +35 -3
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-input-validation.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +103 -3
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +6 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/rpc/session-binding.js.map +1 -1
- package/dist/modes/rpc/session-command-router.d.ts +4 -4
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +14 -8
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-event-fanout.d.ts +2 -0
- package/dist/modes/rpc/session-event-fanout.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-fanout.js +25 -1
- package/dist/modes/rpc/session-event-fanout.js.map +1 -1
- package/dist/modes/rpc/session-event-writer.d.ts +7 -1
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-writer.js +17 -4
- package/dist/modes/rpc/session-event-writer.js.map +1 -1
- package/dist/modes/rpc/session-extension-ui-requests.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +11 -1
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/dist/modes/rpc/session-worker-client.d.ts.map +1 -1
- package/dist/modes/rpc/session-worker-client.js.map +1 -1
- package/dist/modes/rpc/session-worker-protocol.d.ts.map +1 -1
- package/dist/modes/rpc/session-worker-requests.d.ts.map +1 -1
- package/dist/modes/rpc/session-worker-requests.js +1 -1
- package/dist/modes/rpc/session-worker-requests.js.map +1 -1
- package/dist/modes/rpc/session-worker.js +10 -2
- package/dist/modes/rpc/session-worker.js.map +1 -1
- package/dist/modes/rpc/socket-event-fanout.d.ts +14 -1
- package/dist/modes/rpc/socket-event-fanout.d.ts.map +1 -1
- package/dist/modes/rpc/socket-event-fanout.js +48 -2
- package/dist/modes/rpc/socket-event-fanout.js.map +1 -1
- package/dist/modes/rpc/socket-ownership.js.map +1 -1
- package/dist/modes/rpc/worker-session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/worker-session-registry.js +2 -1
- package/dist/modes/rpc/worker-session-registry.js.map +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/self-update-bootstrap.js.map +1 -1
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/management-http.js.map +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/app-server.md +14 -0
- package/docs/extensions.md +28 -1
- package/docs/keybindings.md +1 -0
- package/docs/providers.md +1 -0
- package/docs/rpc.md +95 -3
- package/docs/settings.md +18 -0
- package/docs/skills.md +1 -1
- package/docs/tui.md +6 -0
- package/docs/usage.md +2 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +30 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +17 -2
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/config/settings.ts +35 -15
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +13 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt-template.ts +76 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +6 -77
- package/node_modules/@code-yeongyu/senpi-codemode/src/timeouts/run-budget.ts +107 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-deadlines.ts +76 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-execution.ts +25 -14
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-contract.ts +4 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-manager.ts +47 -40
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-notification.ts +2 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-snapshot.ts +5 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +8 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +17 -187
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/run-eval-cell.ts +189 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +66 -56
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/result.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.d.ts +36 -36
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +5 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
- package/node_modules/@earendil-works/pi-ai/README.md +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +6 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/context-room.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/gen/agent_pb.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/stream-retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.lazy.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.d.ts +60 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.js +93 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-result.d.ts +12 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-result.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-result.js +96 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-result.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts +3 -6
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js +26 -119
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth-refresh.d.ts +47 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth-refresh.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth-refresh.js +126 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth-refresh.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/failover.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/select.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/refresh-credential.d.ts +12 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/refresh-credential.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/refresh-credential.js +44 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/refresh-credential.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +26 -35
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/model-capabilities.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/selection-descriptor.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +99 -66
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +34 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/images.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/images.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/images.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/images.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +3 -28
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/venice.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/ollama.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/venice.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/venice.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/venice.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/venice.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/venice.models.d.ts +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/venice.models.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/venice.models.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/venice.models.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/recovery-wrapper-state.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/kimi-xtml/parse.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-content-lifecycle.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-event-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-native-projection.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-native-projection.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-stream-terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-stream-wrapper.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-text-projection.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-text-projection.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-thinking-projection.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +20 -3
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +3 -3
- package/node_modules/@earendil-works/pi-pty/dist/loader.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/loader.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/quarantine.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry-types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/registry.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/screen.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/session-bun.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/session.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/session.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +2 -2
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/latex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/stack.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/image-markers.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mux.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-module-path.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/paste-markers.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-capabilities.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tmux-image-probe.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +2 -2
- package/node_modules/css-tree/cjs/data-patch.cjs +853 -5
- package/node_modules/css-tree/cjs/data.cjs +13598 -3
- package/node_modules/css-tree/cjs/version.cjs +1 -3
- package/node_modules/css-tree/lib/data-patch.js +853 -4
- package/node_modules/css-tree/lib/data.js +13598 -5
- package/node_modules/css-tree/lib/version.js +1 -5
- package/package.json +8 -8
- package/vendor/pi-client/client.d.ts.map +1 -1
- package/vendor/pi-client/client.js.map +1 -1
- package/vendor/pi-client/connection.d.ts.map +1 -1
- package/vendor/pi-client/connection.js.map +1 -1
- package/vendor/pi-client/errors.d.ts.map +1 -1
- package/vendor/pi-client/session-handle.d.ts.map +1 -1
- package/vendor/pi-client/state.d.ts.map +1 -1
- package/vendor/pi-protocol/cbor/decoder.js.map +1 -1
- package/vendor/pi-protocol/cbor/options.d.ts.map +1 -1
- package/vendor/pi-protocol/codec.d.ts.map +1 -1
- package/vendor/pi-protocol/codec.js.map +1 -1
- package/vendor/pi-protocol/framing.d.ts.map +1 -1
- package/vendor/pi-protocol/schemas.d.ts +678 -678
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAucA,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { TelemetryContext } from \"@earendil-works/pi-telemetry\";\nimport type { AnthropicOptions } from \"./api/anthropic-messages.ts\";\nimport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nimport type { BedrockOptions } from \"./api/bedrock-converse-stream.ts\";\nimport type { CursorAgentOptions } from \"./api/cursor-agent/types.ts\";\nimport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nimport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nimport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nimport type { OpenAICodexResponsesOptions } from \"./api/openai-codex-responses.ts\";\nimport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nimport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nimport type { PiMessagesOptions } from \"./api/pi-messages.ts\";\nimport type { Model } from \"./model.ts\";\nimport type {\n\tOpenAIResponsesCompat as BaseOpenAIResponsesCompat,\n\tSessionAffinityFormat,\n} from \"./openai-responses-compat.ts\";\nimport type { AssistantMessageDiagnostic } from \"./utils/diagnostics.ts\";\nimport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type { Model } from \"./model.ts\";\nexport type { SessionAffinityFormat } from \"./openai-responses-compat.ts\";\nexport type OpenAIResponsesCompat = BaseOpenAIResponsesCompat & {\n\t/** Whether the model supports message-anchored `additional_tools` input items. Default: false. */\n\tsupportsAdditionalTools?: boolean;\n};\nexport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type KnownApi =\n\t| \"openai-completions\"\n\t| \"mistral-conversations\"\n\t| \"openai-responses\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex-responses\"\n\t| \"cursor-agent\"\n\t| \"anthropic-messages\"\n\t| \"bedrock-converse-stream\"\n\t| \"google-generative-ai\"\n\t| \"google-vertex\"\n\t| \"pi-messages\";\n\nexport type Api = KnownApi | (string & {});\n\nexport type KnownImagesApi = \"openrouter-images\" | \"openai-images\";\n\nexport type ImagesApi = KnownImagesApi | (string & {});\n\nexport type KnownProvider =\n\t| \"alibaba-token-plan\"\n\t| \"amazon-bedrock\"\n\t| \"ant-ling\"\n\t| \"anthropic\"\n\t| \"google\"\n\t| \"google-vertex\"\n\t| \"openai\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex\"\n\t| \"ollama\"\n\t| \"cursor\"\n\t| \"radius\"\n\t| \"nvidia\"\n\t| \"deepseek\"\n\t| \"github-copilot\"\n\t| \"xai\"\n\t| \"groq\"\n\t| \"cerebras\"\n\t| \"openrouter\"\n\t| \"vercel-ai-gateway\"\n\t| \"opengateway\"\n\t| \"zai\"\n\t| \"zai-coding-cn\"\n\t| \"mistral\"\n\t| \"minimax\"\n\t| \"minimax-cn\"\n\t| \"moonshotai\"\n\t| \"moonshotai-cn\"\n\t| \"huggingface\"\n\t| \"fireworks\"\n\t| \"together\"\n\t| \"baseten\"\n\t| \"opencode\"\n\t| \"opencode-go\"\n\t| \"kimi-coding\"\n\t| \"cloudflare-workers-ai\"\n\t| \"cloudflare-ai-gateway\"\n\t| \"qwen-token-plan\"\n\t| \"qwen-token-plan-cn\"\n\t| \"qwen-token-plan-individual\"\n\t| \"xiaomi\"\n\t| \"xiaomi-token-plan-cn\"\n\t| \"xiaomi-token-plan-ams\"\n\t| \"xiaomi-token-plan-sgp\";\nexport type ProviderId = KnownProvider | string;\n\nexport type KnownImagesProvider = \"openrouter\";\n\nexport type ImagesProviderId = KnownImagesProvider | string;\n\nexport type ToolChoice = \"auto\" | \"none\";\nexport type ThinkingLevel = \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\nexport type ModelThinkingLevel = \"off\" | ThinkingLevel;\n\n/**\n * Provenance-bearing thinking selection. Distinct from the always-materialized\n * effective level: a selection exists only when the user (or a legacy variant\n * alias) explicitly chose a level. See .omo/plans/cursor-reasoning-levels.md §4.1.\n */\nexport interface ThinkingSelection {\n\treadonly level: ModelThinkingLevel;\n\treadonly source: \"explicit\" | \"legacy-variant\";\n\t/** Required when source is \"legacy-variant\": the exact allowlisted original variant id. */\n\treadonly legacyVariantId?: string;\n}\nexport type ThinkingLevelMap = Partial<Record<ModelThinkingLevel, string | null>>;\nexport type ChatTemplateKwargValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| {\n\t\t\t$var: \"thinking.enabled\" | \"thinking.effort\" | \"thinking.budget\";\n\t\t\tomitWhenOff?: boolean;\n\t };\n\n/** Top-level request field used to cap reasoning tokens on OpenAI-compatible servers. */\nexport type ThinkingTokenBudgetField = \"thinking_token_budget\" | \"thinking_budget\" | \"thinking_budget_tokens\";\n\n/** Token budgets for each thinking level (token-based providers only) */\nexport interface ThinkingBudgets {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n\tmax?: number;\n}\n\n// Base options all providers share\nexport type CacheRetention = \"none\" | \"short\" | \"long\";\n\nexport type Transport = \"sse\" | \"websocket\" | \"websocket-cached\" | \"auto\";\n\n/** Provider-scoped environment overrides. Values take precedence over process.env. */\nexport type ProviderEnv = Record<string, string>;\nexport type ProviderHeaders = Record<string, string | null>;\n/** Effective model and fully transformed headers for a request payload hook. */\nexport type ProviderRequestMetadata = {\n\tmodel: Model<Api>;\n\theaders: ProviderHeaders;\n};\nexport type FetchFunction = typeof globalThis.fetch;\n\nexport interface ProviderResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n}\n\n/** Authentication, HTTP transport, and lifecycle callbacks shared by provider requests. */\nexport interface ProviderRequestOptions<TModel = Model<Api>> {\n\tsignal?: AbortSignal;\n\t/**\n\t * Abort the request when the provider reports that a safety classifier\n\t * declined the requested model and a substitute model served the turn\n\t * instead (Anthropic `server-side-fallback-*` betas). The substitute's output\n\t * is billed but was never requested, so aborting keeps model selection with\n\t * the caller. Providers without server-side fallback ignore this.\n\t * Default: undefined (honor the substituted response).\n\t */\n\tabortServerSideFallback?: boolean;\n\t/** Explicit parent context for telemetry produced by this logical request. */\n\ttelemetryContext?: TelemetryContext;\n\tapiKey?: string;\n\t/**\n\t * Stable identity of the originating session for account-affinity providers,\n\t * preserved across auxiliary calls that replace `sessionId` (for example\n\t * compaction). Providers without account affinity ignore this.\n\t */\n\taffinitySessionId?: string;\n\t/**\n\t * Identifies whether the stream belongs to the main agent loop or an auxiliary request.\n\t * An absent value must be treated as auxiliary as a fail-safe.\n\t */\n\tstreamKind?: \"main\" | \"auxiliary\";\n\t/**\n\t * Optional fetch implementation for provider HTTP requests.\n\t * Defaults to `globalThis.fetch`. Provider adapters that cannot inject a custom implementation may reject it.\n\t * This does not affect WebSocket transports.\n\t */\n\tfetch?: FetchFunction;\n\t/**\n\t * Provider-scoped environment values. These take precedence over process.env for\n\t * provider configuration such as regional settings, endpoint placeholders, and\n\t * proxy variables.\n\t */\n\tenv?: ProviderEnv;\n\t/**\n\t * Optional callback for inspecting or replacing provider payloads before sending.\n\t * Return undefined to keep the payload unchanged.\n\t */\n\tonPayload?: (\n\t\tpayload: unknown,\n\t\tmodel: TModel,\n\t\trequest?: ProviderRequestMetadata,\n\t) => unknown | undefined | Promise<unknown | undefined>;\n\t/**\n\t * Optional callback invoked after an HTTP response is received.\n\t */\n\tonResponse?: (response: ProviderResponse, model: TModel) => void | Promise<void>;\n\t/**\n\t * Optional custom HTTP headers to include in API requests.\n\t * Merged with provider defaults; caller values override default headers.\n\t * On AWS Bedrock these are injected via a Smithy `build`-step middleware so\n\t * they are covered by SigV4 signing; reserved headers (`x-amz-*`,\n\t * `authorization`, `host`) are silently ignored to preserve SigV4 / bearer auth.\n\t * A null value suppresses a provider/API default header with the same name.\n\t */\n\theaders?: ProviderHeaders;\n\t/**\n\t * HTTP request timeout in milliseconds for providers/SDKs that support it.\n\t * For example, OpenAI and Anthropic SDK clients default to 10 minutes.\n\t */\n\ttimeoutMs?: number;\n\t/**\n\t * Maximum retry attempts for providers/SDKs that support client-side retries.\n\t * For example, OpenAI and Anthropic SDK clients default to 2.\n\t */\n\tmaxRetries?: number;\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately\n\t * with an error containing the requested delay, allowing higher-level retry logic\n\t * to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n}\n\nexport interface StreamOptions extends ProviderRequestOptions<Model<Api>> {\n\ttemperature?: number;\n\t/**\n\t * Arbitrary sampling parameters merged into the request body as-is, after the named request\n\t * fields, so keys here override them. Lets custom OpenAI-compatible servers (llama.cpp, vLLM,\n\t * SGLang, ...) receive parameters pi does not model, e.g. `top_p`, `top_k`, `min_p`,\n\t * `repetition_penalty`. Merged over `Model.samplingParams` per key. Only applied by\n\t * OpenAI-compatible adapters (completions, responses, Azure responses); other APIs ignore it.\n\t */\n\tsamplingParams?: Record<string, unknown>;\n\tmaxTokens?: number;\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t * Providers that do not support this option ignore it.\n\t */\n\ttransport?: Transport;\n\t/**\n\t * Prompt cache retention preference. Providers map this to their supported values.\n\t * Default: \"short\".\n\t */\n\tcacheRetention?: CacheRetention;\n\t/**\n\t * Optional session identifier for providers that support session-based caching.\n\t * Providers can use this to enable prompt caching, request routing, or other\n\t * session-aware features. Ignored by providers that don't support it.\n\t */\n\tsessionId?: string;\n\t/**\n\t * Optional custom fields to merge into the outgoing provider request body.\n\t * Applied before `onPayload` so `onPayload` can observe/override them.\n\t * Provider-managed fields (e.g. `model`, `messages`, `stream`) are preserved\n\t * and cannot be overridden to avoid breaking core request semantics.\n\t */\n\textraBody?: Record<string, unknown>;\n\t/**\n\t * WebSocket connect timeout in milliseconds for providers that support\n\t * WebSocket transports. This covers the connection/open handshake only;\n\t * stream idleness after connection uses timeoutMs.\n\t */\n\twebsocketConnectTimeoutMs?: number;\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t * For example, Anthropic uses `user_id` for abuse tracking and rate limiting.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderStreamOptions = StreamOptions & Record<string, unknown>;\n\nexport interface DeferredFetchOptions extends ProviderRequestOptions<Model<Api>> {\n\t/**\n\t * Maximum provider long-poll duration in milliseconds.\n\t * Defaults to 0, which performs one status check.\n\t */\n\twait?: number;\n}\n\n/** Request options for best-effort deferred-response cancellation. */\nexport type DeferredCancelOptions = ProviderRequestOptions<Model<Api>>;\n\n/**\n * Maps known APIs to their full provider-specific stream option types.\n * Type-only imports from API implementation modules are erased at emit, so\n * this is tree-shake safe.\n */\nexport interface ApiOptionsMap {\n\t\"anthropic-messages\": AnthropicOptions;\n\t\"openai-completions\": OpenAICompletionsOptions;\n\t\"openai-responses\": OpenAIResponsesOptions;\n\t\"openai-codex-responses\": OpenAICodexResponsesOptions;\n\t\"cursor-agent\": CursorAgentOptions;\n\t\"azure-openai-responses\": AzureOpenAIResponsesOptions;\n\t\"google-generative-ai\": GoogleOptions;\n\t\"google-vertex\": GoogleVertexOptions;\n\t\"mistral-conversations\": MistralOptions;\n\t\"bedrock-converse-stream\": BedrockOptions;\n\t\"pi-messages\": PiMessagesOptions;\n}\n\n/**\n * Full stream options for an API. Known APIs resolve to their concrete option\n * type; custom API strings fall back to the generic shape.\n */\nexport type ApiStreamOptions<TApi extends Api> = TApi extends keyof ApiOptionsMap\n\t? ApiOptionsMap[TApi]\n\t: StreamOptions & Record<string, unknown>;\n\n/**\n * The uniform stream contract of an API implementation module: every module\n * under `src/api/` exports `stream` and `streamSimple`; capable modules may also\n * export deferred-response methods. Lazy wrappers (`lazyApi()`) and provider\n * factories pass these around as values. This is the untyped dispatch shape;\n * per-API option typing lives on the implementation modules themselves and on\n * `Provider.stream()` via `ApiStreamOptions`.\n */\nexport interface ProviderStreams {\n\tstream(model: Model<Api>, context: Context, options?: StreamOptions): AssistantMessageEventStream;\n\tstreamSimple(model: Model<Api>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<Api>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n}\n\n/**\n * The uniform contract of an image-generation API implementation module:\n * every image API module under `src/api/` exports exactly `generateImages`,\n * so the module itself satisfies this interface. Lazy wrappers and image\n * provider factories pass these around as values.\n */\nexport interface ProviderImages {\n\tgenerateImages(\n\t\tmodel: ImagesModel<ImagesApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ImagesOptions,\n\t): Promise<AssistantImages>;\n}\n\nexport interface ImagesOptions extends ProviderRequestOptions<ImagesModel<ImagesApi>> {\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderImagesOptions = ImagesOptions & Record<string, unknown>;\n\nexport interface AnthropicAllowedFallbackModel {\n\tprovider: ProviderId;\n\tmodel: string;\n\tcost: ModelCost;\n}\n\nexport type AnthropicRefusalFallback = \"default\" | readonly { model: string }[];\n\n// Unified options with reasoning passed to streamSimple() and completeSimple()\nexport interface SimpleStreamOptions extends StreamOptions {\n\t/** Provider-neutral tool selection for simple requests. When omitted, adapters use provider-specific behavior. */\n\ttoolChoice?: ToolChoice;\n\treasoning?: ThinkingLevel;\n\t/**\n\t * Provenance-bearing thinking selection. Providers that need to distinguish\n\t * an explicit user choice from the always-materialized effective level read\n\t * this; `reasoning` remains the normalized effective level for everyone.\n\t */\n\tthinkingSelection?: ThinkingSelection;\n\t/** Anthropic server-side fallback for eligible refusal stop reasons. Anthropic providers only. */\n\trefusalFallbacks?: AnthropicRefusalFallback;\n\t/** Ask a capable provider to return a durable handle and continue the request asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n\t/** Custom token budgets for thinking levels (token-based providers only) */\n\tthinkingBudgets?: ThinkingBudgets;\n\t/**\n\t * Requested processing tier for providers that price and schedule by tier (OpenAI Responses and\n\t * the ChatGPT Codex backend send it as `service_tier`). Adapters without the concept ignore it.\n\t */\n\tserviceTier?: ServiceTierPreference;\n}\n\n/** Tier preferences a caller can express; providers map `\"auto\"` to their default lane. */\nexport type ServiceTierPreference = \"auto\" | \"flex\" | \"priority\";\n\n// Generic StreamFunction with typed options.\n//\n// Contract:\n// - Must return an AssistantMessageEventStream.\n// - Once invoked, request/model/runtime failures should be encoded in the\n// returned stream, not thrown.\n// - Error termination must produce an AssistantMessage with stopReason\n// \"error\" or \"aborted\" and errorMessage, emitted via the stream protocol.\nexport type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: TOptions,\n) => AssistantMessageEventStream;\n\nexport type ImagesFunction<TApi extends ImagesApi = ImagesApi, TOptions extends ImagesOptions = ImagesOptions> = (\n\tmodel: ImagesModel<TApi>,\n\tcontext: ImagesContext,\n\toptions?: TOptions,\n) => Promise<AssistantImages>;\n\nexport interface TextSignatureV1 {\n\tv: 1;\n\tid: string;\n\tphase?: \"commentary\" | \"final_answer\";\n}\n\nexport interface TextContent {\n\ttype: \"text\";\n\ttext: string;\n\ttextSignature?: string; // e.g., for OpenAI responses, message metadata (legacy id string or TextSignatureV1 JSON)\n}\n\nexport interface ThinkingContent {\n\ttype: \"thinking\";\n\tthinking: string;\n\t/** Epoch ms, stamped by the agent loop at stream-event receipt, best-effort. */\n\tstartedAt?: number;\n\t/** Epoch ms, stamped by the agent loop at stream-event receipt, best-effort. */\n\tendedAt?: number;\n\tthinkingSignature?: string; // e.g., for OpenAI responses, the reasoning item ID\n\t/** When true, the thinking content was redacted by safety filters. The opaque\n\t * encrypted payload is stored in `thinkingSignature` so it can be passed back\n\t * to the API for multi-turn continuity. */\n\tredacted?: boolean;\n}\n\nexport interface ImageContent {\n\ttype: \"image\";\n\tdata: string; // base64 encoded image data\n\tmimeType: string; // e.g., \"image/jpeg\", \"image/png\". Video payloads (e.g. \"video/mp4\") ride this\n\t// same block for models that declare the \"video\" input modality; use isVideoMimeType() to branch.\n}\n\n/** True when an ImageContent block actually carries video data (e.g. \"video/mp4\"). */\nexport function isVideoMimeType(mimeType: string): boolean {\n\treturn mimeType.toLowerCase().startsWith(\"video/\");\n}\n\nexport interface ToolCall {\n\ttype: \"toolCall\";\n\tid: string;\n\tname: string;\n\targuments: Record<string, any>;\n\t/** Set by text tool-call middleware when a truncated call could not be recovered. Carriers of `incomplete` MUST NOT be executed. */\n\tincomplete?: true;\n\t/** Error explaining why an incomplete tool call could not be recovered. */\n\terrorMessage?: string;\n\tthoughtSignature?: string; // Google-specific: opaque signature for reusing thought context\n\t/** OpenAI Responses namespace for calls to dynamically loaded or namespaced tools. */\n\tnamespace?: string;\n}\n\n/**\n * Provider-emitted content block whose semantics are owned by the originating\n * provider. Surfaces server-side tool invocations (web_search), server-side\n * tool results (web_search_tool_result), code execution traces, grounding\n * metadata fragments, and any other vendor-specific block the core does not\n * normalize.\n *\n * `subtype` mirrors the provider's wire `type` discriminator (e.g.\n * \"server_tool_use\", \"web_search_tool_result\", \"executableCode\"). `raw` is\n * the verbatim wire payload — extensions interpret it per provider+subtype.\n *\n * The owning provider id lives on the parent `AssistantMessage.provider`, not\n * here, to avoid drift on replay.\n *\n * On replay across providers, `convertMessages` implementations MUST drop\n * these blocks (they are not portable). This mirrors the existing\n * `redacted_thinking` skip pattern.\n */\nexport interface ProviderNativeContent {\n\ttype: \"providerNative\";\n\tsubtype: string;\n\traw: unknown;\n}\n\nexport interface Usage {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\t/** Subset of `cacheWrite` written with 1h retention. Only Anthropic reports this split. */\n\tcacheWrite1h?: number;\n\t/**\n\t * Reasoning/thinking tokens, when the provider reports them. This is a subset of\n\t * `output`: `output` already includes these tokens. Set to a number (possibly 0) by\n\t * providers that expose a reasoning breakdown; left undefined by providers that don't.\n\t */\n\treasoning?: number;\n\ttotalTokens: number;\n\tcost: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n}\n\nexport type StopReason = \"pending\" | \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\" | \"deferred\";\n\nexport type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\n\nexport interface DeferredHandle {\n\tprovider: string;\n\tmodelId: string;\n\tapi: string;\n\t/** Provider token, such as a response id or batch id plus row id. */\n\tid: string;\n\texpiresAt?: number;\n\tpollAfterMs?: number;\n\t/** Provider conversion data required to reconstruct the final assistant message. */\n\tdata?: JsonValue;\n}\n\nexport type AssistantStopDetails = { type: \"refusal\"; explanation?: string } | { type: \"sensitive\" };\n\nexport interface UserMessage {\n\trole: \"user\";\n\tcontent: string | (TextContent | ImageContent)[];\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\n/** A durable Responses configuration change projected into the message stream. */\nexport interface ConfigurationUpdateMessage {\n\trole: \"configurationUpdate\";\n\tcontent: (TextContent | ImageContent)[];\n\teffort: string;\n\ttimestamp: number;\n}\n\nexport interface AssistantMessage {\n\trole: \"assistant\";\n\tcontent: (TextContent | ThinkingContent | ToolCall | ProviderNativeContent)[];\n\tapi: Api;\n\tprovider: ProviderId;\n\tmodel: string;\n\tresponseModel?: string; // Concrete `chunk.model` when different from the requested `model` (e.g. OpenRouter `auto` -> `anthropic/...`)\n\tresponseId?: string; // Provider-specific response/message identifier when the upstream API exposes one\n\t/** Exact provider-native effort level used for this response. Absent for legacy or unmanaged responses. */\n\tproviderThinkingLevel?: string;\n\tdiagnostics?: AssistantMessageDiagnostic[]; // Redacted provider/runtime diagnostics for failures and recoveries.\n\tusage: Usage;\n\tstopReason: StopReason;\n\tstopDetails?: AssistantStopDetails;\n\tdeferred?: DeferredHandle;\n\terrorMessage?: string;\n\t/** Explicit owner for an abort initiated by the provider retry watchdog. */\n\tabortSource?: \"provider\";\n\trawStopReason?: string;\n\t/**\n\t * Provider indication of whether the model explicitly ended its turn.\n\t * Preserved for debugging and does not currently affect agent control flow.\n\t */\n\tendTurn?: boolean;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface ToolResultMessage<TDetails = any> {\n\trole: \"toolResult\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tcontent: (TextContent | ImageContent)[]; // Supports text and images\n\tdetails?: TDetails;\n\t/** Usage from the tool execution itself, if available. Not part of main LLM context accounting. */\n\tusage?: Usage;\n\t/**\n\t * Names from `Context.tools` that became available after this result.\n\t * Providers with native deferred tool loading use this as the load point;\n\t * other providers ignore it and use `Context.tools` normally.\n\t */\n\taddedToolNames?: string[];\n\tisError: boolean;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport type Message = UserMessage | AssistantMessage | ToolResultMessage | ConfigurationUpdateMessage;\n\nexport type ImagesInputContent = TextContent | ImageContent;\nexport type ImagesOutputContent = TextContent | ImageContent;\n\nexport interface ImagesContext {\n\tinput: ImagesInputContent[];\n}\n\nexport type ImagesStopReason = \"stop\" | \"error\" | \"aborted\";\n\nexport interface AssistantImages {\n\tapi: ImagesApi;\n\tprovider: ImagesProviderId;\n\tmodel: string;\n\toutput: ImagesOutputContent[];\n\tresponseId?: string;\n\tusage?: Usage;\n\tstopReason: ImagesStopReason;\n\terrorMessage?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nimport type { TSchema } from \"typebox\";\n\nexport interface FreeformToolFormat {\n\ttype: \"grammar\";\n\tsyntax: \"lark\";\n\tdefinition: string;\n}\n\n/** OpenAI grammar variants for constrained sampling. */\nexport type GrammarFormat = \"openai_lark\" | \"openai_regex\";\n\nexport type GrammarVariants = Partial<Record<GrammarFormat, string>>;\n\n/**\n * Optional provider-side constrained sampling configs for a tool.\n *\n * The `json_schema` value roughly maps to the concept of `strict` in APIs which is\n * implemented as json-schema constrained sampling by APIs. Grammar variants let\n * callers provide provider-specific encodings of the same intended language.\n */\nexport type ConstrainedSamplingConfig =\n\t| {\n\t\t\ttype: \"json_schema\";\n\t\t\tstrict: \"prefer\" | \"require\";\n\t }\n\t| {\n\t\t\ttype: \"grammar\";\n\t\t\tvariants: GrammarVariants;\n\t };\nexport interface Tool<TParameters extends TSchema = TSchema> {\n\tname: string;\n\tdescription: string;\n\tparameters: TParameters;\n\tfreeform?: FreeformToolFormat;\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n}\n\nexport interface Context {\n\tsystemPrompt?: string;\n\tmessages: Message[];\n\ttools?: Tool[];\n}\n\n/**\n * Event protocol for AssistantMessageEventStream.\n *\n * Streams should emit `start` before partial updates, then terminate with either:\n * - `done` carrying the final successful AssistantMessage, or\n * - `error` carrying the final AssistantMessage with stopReason \"error\" or \"aborted\"\n * and errorMessage.\n */\nexport type AssistantMessageEvent =\n\t| { type: \"start\"; partial: AssistantMessage }\n\t| { type: \"text_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"text_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"text_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"thinking_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"thinking_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"thinking_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"toolcall_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"toolcall_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t/** Finalized - executable iff `incomplete !== true` on `toolCall`. */\n\t| { type: \"toolcall_end\"; contentIndex: number; toolCall: ToolCall; partial: AssistantMessage }\n\t| {\n\t\t\ttype: \"done\";\n\t\t\treason: Extract<StopReason, \"stop\" | \"length\" | \"toolUse\" | \"deferred\">;\n\t\t\tmessage: AssistantMessage;\n\t }\n\t| { type: \"error\"; reason: Extract<StopReason, \"aborted\" | \"error\">; error: AssistantMessage };\n\n/**\n * Compatibility settings for OpenAI-compatible completions APIs.\n * Use this to override URL-based auto-detection for custom providers.\n */\nexport interface OpenAICompletionsCompat {\n\t/** Whether the provider supports the `store` field. Default: auto-detected from URL. */\n\tsupportsStore?: boolean;\n\t/** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */\n\tsupportsDeveloperRole?: boolean;\n\t/** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */\n\tsupportsReasoningEffort?: boolean;\n\t/** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */\n\tsupportsUsageInStreaming?: boolean;\n\t/** Whether streamed responses include `finish_reason`. When false, pi infers `stop` or `toolUse` when the stream ends. Default: true. */\n\tsupportsFinishReason?: boolean;\n\t/** Which field to use for max tokens. Default: auto-detected from URL. */\n\tmaxTokensField?: \"max_completion_tokens\" | \"max_tokens\";\n\t/** Whether tool results require the `name` field. Default: auto-detected from URL. */\n\trequiresToolResultName?: boolean;\n\t/** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */\n\trequiresAssistantAfterToolResult?: boolean;\n\t/** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */\n\trequiresThinkingAsText?: boolean;\n\t/** Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. */\n\trequiresReasoningContentOnAssistantMessages?: boolean;\n\t/** Format for reasoning/thinking parameter. \"openai\" uses reasoning_effort, \"openrouter\" uses reasoning: { effort }, \"deepseek\" uses thinking: { type } plus reasoning_effort when supported, \"together\" uses reasoning: { enabled } plus reasoning_effort when supported, \"baseten\" uses configurable chat_template_args plus reasoning_effort when supported, \"zai\" uses thinking: { type }, \"qwen\" uses top-level enable_thinking: boolean, \"qwen-chat-template\" uses chat_template_kwargs.enable_thinking and preserve_thinking, \"chat-template\" uses configurable chat_template_kwargs, \"string-thinking\" uses top-level thinking: string, and \"ant-ling\" uses reasoning: { effort } only when the mapped effort is non-null. Default: \"openai\". */\n\tthinkingFormat?:\n\t\t| \"openai\"\n\t\t| \"openrouter\"\n\t\t| \"deepseek\"\n\t\t| \"together\"\n\t\t| \"baseten\"\n\t\t| \"zai\"\n\t\t| \"qwen\"\n\t\t| \"chat-template\"\n\t\t| \"qwen-chat-template\"\n\t\t| \"string-thinking\"\n\t\t| \"ant-ling\";\n\t/** Whether the provider accepts explicit disabled-thinking markers when thinking is off. Default: true. */\n\tsupportsDisabledThinking?: boolean;\n\t/** Kwargs to send as `chat_template_kwargs` when `thinkingFormat` is `chat-template`. Use `{ \"$var\": \"thinking.enabled\" }`, `{ \"$var\": \"thinking.effort\" }`, or `{ \"$var\": \"thinking.budget\" }` for pi-controlled thinking values. */\n\tchatTemplateKwargs?: Record<string, ChatTemplateKwargValue>;\n\t/** Arguments to send as `chat_template_args` when `thinkingFormat` is `baseten`. Use `{ \"$var\": \"thinking.enabled\" }`, `{ \"$var\": \"thinking.effort\" }`, or `{ \"$var\": \"thinking.budget\" }` for pi-controlled thinking values. */\n\tchatTemplateArgs?: Record<string, ChatTemplateKwargValue>;\n\t/** OpenRouter-compatible routing preferences sent as the `provider` request field. */\n\topenRouterRouting?: OpenRouterRouting;\n\t/** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */\n\tvercelGatewayRouting?: VercelGatewayRouting;\n\t/** Whether z.ai supports top-level `tool_stream: true` for streaming tool call deltas. Default: false. */\n\tzaiToolStream?: boolean;\n\t/**\n\t * Top-level request field used to cap reasoning tokens from `thinkingBudgets`.\n\t * Reasoning and the answer share `max_tokens` on these endpoints, so without a budget a\n\t * reasoning-heavy turn can consume the whole response and emit no answer.\n\t * `\"thinking_token_budget\"` is vLLM, `\"thinking_budget\"` is Qwen/DashScope/SGLang,\n\t * `\"thinking_budget_tokens\"` is llama.cpp. Off by default; not set on the generated catalog.\n\t */\n\tthinkingTokenBudgetField?: ThinkingTokenBudgetField;\n\t/** Alias for `thinkingTokenBudgetField: \"thinking_token_budget\"` (vLLM). Prefer `thinkingTokenBudgetField`. Default: false. */\n\tsupportsThinkingTokenBudget?: boolean;\n\t/** Whether the provider supports OpenAI custom tools with Lark/regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. Default: false; the generated model catalog enables it for capable models. */\n\tsupportsOpenAIGrammarTools?: boolean;\n\t/** Whether the provider supports the `strict` field in tool definitions. Default: true. */\n\tsupportsStrictMode?: boolean;\n\t/**\n\t * Provider-specific JSON Schema flavor for tool parameters. `\"moonshot-mfjs\"`\n\t * normalizes schemas for Moonshot / Kimi backends that enforce a stricter subset.\n\t */\n\ttoolSchemaFlavor?: \"moonshot-mfjs\";\n\t/**\n\t * Tool call format for models that don't natively support tool calling.\n\t * When set, the middleware will intercept tool calls and format them as text.\n\t * Supported values: \"hermes\", \"morph-xml\", \"xml\" (deprecated alias for \"morph-xml\"), \"yaml-xml\", \"gemma4-delimiter\", \"anthropic-xml\", \"antml\", \"kimi-xtml\"\n\t */\n\ttoolCallFormat?: string;\n\t/** Cache control convention for prompt caching. \"anthropic\" applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. */\n\tcacheControlFormat?: \"anthropic\";\n\t/** Whether to send session-affinity data from `options.sessionId`. Default: false. */\n\tsendSessionAffinityHeaders?: boolean;\n\t/** Provider-specific deferred tool serialization mode. */\n\tdeferredToolsMode?: \"kimi\";\n\t/** Session-affinity header format: `openai` sends `session_id`, `x-client-request-id`, and `x-session-affinity`; `openai-nosession` sends `x-client-request-id` and `x-session-affinity`; `openrouter` sends `x-session-id`. Does not affect the `prompt_cache_key` body param, which is governed by cache retention. Default: auto-detected. */\n\tsessionAffinityFormat?: SessionAffinityFormat;\n\t/** Whether the provider accepts the `prompt_cache_key` request field. Default: auto-detected. */\n\tsupportsPromptCacheKey?: boolean;\n\t/** Whether the provider supports long prompt cache retention (`prompt_cache_retention: \"24h\"` or Anthropic-style `cache_control.ttl: \"1h\"`, depending on format). Default: true. */\n\tsupportsLongCacheRetention?: boolean;\n\t/** Whether the provider accepts the `max_output_tokens` parameter. Some Codex-protocol gateways reject it. Default: true. */\n\tsupportsMaxOutputTokens?: boolean;\n\t/**\n\t * vLLM scheduler priority sent as the top-level `priority` request field (lower values are\n\t * handled earlier; server default 0). Only meaningful when vLLM runs with\n\t * `--scheduling-policy priority`; useful for keeping background/batch work from stalling\n\t * interactive sessions. Off by default; not set on the generated catalog.\n\t */\n\tvllmPriority?: number;\n}\n\n/** Compatibility settings for Anthropic Messages-compatible APIs. */\nexport interface AnthropicMessagesCompat {\n\t/**\n\t * Whether the provider accepts per-tool `eager_input_streaming`.\n\t * When false, the Anthropic provider omits `tools[].eager_input_streaming`\n\t * and sends the legacy `fine-grained-tool-streaming-2025-05-14` beta header\n\t * for tool-enabled requests.\n\t * Default: true.\n\t */\n\tsupportsEagerToolInputStreaming?: boolean;\n\t/** Whether the provider supports Anthropic long cache retention (`cache_control.ttl: \"1h\"`). Default: true. */\n\tsupportsLongCacheRetention?: boolean;\n\t/**\n\t * Whether to send the `x-session-affinity` header from `options.sessionId`\n\t * when caching is enabled. Required for providers like Fireworks that use\n\t * session affinity for prompt cache routing (requests to the same replica\n\t * maximize cache hits).\n\t * Default: false.\n\t */\n\tsendSessionAffinityHeaders?: boolean;\n\t/**\n\t * Whether the provider supports Anthropic-style `cache_control` markers on\n\t * tool definitions. When false, `cache_control` is omitted from tool params.\n\t * Some Anthropic-compatible providers (e.g., Fireworks) do not support this\n\t * field on tools and may reject or ignore it.\n\t * Default: true.\n\t */\n\tsupportsCacheControlOnTools?: boolean;\n\t/**\n\t * Whether the provider accepts `thinking: { type: \"disabled\" }` when\n\t * extended thinking is off. Some Anthropic-compatible providers support\n\t * thinking but reject Anthropic's explicit disabled marker.\n\t * Default: true.\n\t */\n\tsupportsDisabledThinking?: boolean;\n\t/**\n\t * Whether the model accepts the Anthropic `temperature` request field.\n\t * Claude Opus 4.7+ rejects non-default temperature values.\n\t * Default: true.\n\t */\n\tsupportsTemperature?: boolean;\n\t/** Whether the model accepts Anthropic `tool_choice`. Default: true. */\n\tsupportsToolChoice?: boolean;\n\t/**\n\t * Whether the model accepts forced Anthropic tool choices (`any` or a named\n\t * tool). Default: true, except Claude Fable/Mythos models.\n\t */\n\tsupportsForcedToolChoice?: boolean;\n\t/**\n\t * Whether to force adaptive thinking (`thinking.type: \"adaptive\"` plus\n\t * `output_config.effort`) regardless of the model id. Built-in models that\n\t * require adaptive thinking set this in generated metadata. Custom\n\t * Anthropic-compatible providers can set this to `true` for any model whose\n\t * upstream requires the adaptive format. Set to `false` to opt out on\n\t * overridden built-in models and disable model id/name inference.\n\t * Default: infer from adaptive Claude model ids/names when possible.\n\t */\n\tforceAdaptiveThinking?: boolean;\n\t/** Whether to replay empty thinking signatures as `signature: \"\"` instead of converting thinking to text. Default: false. */\n\tallowEmptySignature?: boolean;\n\t/** Whether the provider supports Anthropic strict tool schemas. Default: false; generated Anthropic models enable it explicitly. */\n\tsupportsStrictTools?: boolean;\n\t/** Whether the exact model transport supports effort-only system messages and thinking binding controls. Default: false. */\n\tsupportsMidConvoEffort?: boolean;\n\t/**\n\t * How to replay thinking blocks that have no usable Anthropic signature.\n\t * `\"text\"` demotes them to text; `\"empty-signature\"` preserves Anthropic's\n\t * thinking shape with `signature: \"\"`. Defaults to `\"text\"`; the legacy\n\t * `allowEmptySignature` setting remains a compatibility alias for\n\t * `\"empty-signature\"`.\n\t */\n\tunsignedThinkingReplay?: \"text\" | \"empty-signature\";\n\t/**\n\t * Model ids Anthropic accepts in `fallbacks` for server-side refusal fallback.\n\t * When absent or empty, callers must omit `fallbacks`; Anthropic rejects the\n\t * field for models with no permitted fallback targets.\n\t */\n\tallowedFallbackModels?: Array<AnthropicAllowedFallbackModel | string>;\n\t/**\n\t * Whether the provider supports deferred tools loaded by `tool_reference`\n\t * blocks in tool results. Default: true for first-party Anthropic models\n\t * except Haiku and models older than Claude 4.5; false for other providers.\n\t */\n\tsupportsToolReferences?: boolean;\n\t/**\n\t * Whether the provider executes Anthropic server-side `web_search_*` native\n\t * tools and accepts their `server_tool_use` / `web_search_tool_result`\n\t * blocks on replay. Anthropic-compatible endpoints (e.g., kimi-coding) may\n\t * run the search but reject the replayed server-tool blocks on the next\n\t * request. When false, hook-injected `web_search_*` tools are stripped from\n\t * the payload. Default: true only for the first-party Anthropic endpoint.\n\t */\n\tsupportsWebSearch?: boolean;\n}\n\n/** Compatibility settings for Amazon Bedrock models. */\nexport interface BedrockCompat {\n\t/** Whether the model supports Bedrock strict tool schemas. Default: false. */\n\tsupportsStrictMode?: boolean;\n}\n\n/**\n * OpenRouter provider routing preferences.\n * Controls which upstream providers OpenRouter routes requests to.\n * Sent as the `provider` field in the OpenRouter API request body.\n * @see https://openrouter.ai/docs/guides/routing/provider-selection\n */\nexport interface OpenRouterRouting {\n\t/** Whether to allow backup providers to serve requests. Default: true. */\n\tallow_fallbacks?: boolean;\n\t/** Whether to filter providers to only those that support all parameters in the request. Default: false. */\n\trequire_parameters?: boolean;\n\t/** Data collection setting. \"allow\" (default): allow providers that may store/train on data. \"deny\": only use providers that don't collect user data. */\n\tdata_collection?: \"deny\" | \"allow\";\n\t/** Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. */\n\tzdr?: boolean;\n\t/** Whether to restrict routing to only models that allow text distillation. */\n\tenforce_distillable_text?: boolean;\n\t/** An ordered list of provider names/slugs to try in sequence, falling back to the next if unavailable. */\n\torder?: string[];\n\t/** List of provider names/slugs to exclusively allow for this request. */\n\tonly?: string[];\n\t/** List of provider names/slugs to skip for this request. */\n\tignore?: string[];\n\t/** A list of quantization levels to filter providers by (e.g., [\"fp16\", \"bf16\", \"fp8\", \"fp6\", \"int8\", \"int4\", \"fp4\", \"fp32\"]). */\n\tquantizations?: string[];\n\t/** Sorting strategy. Can be a string (e.g., \"price\", \"throughput\", \"latency\") or an object with `by` and `partition`. */\n\tsort?:\n\t\t| string\n\t\t| {\n\t\t\t\t/** The sorting metric: \"price\", \"throughput\", \"latency\". */\n\t\t\t\tby?: string;\n\t\t\t\t/** Partitioning strategy: \"model\" (default) or \"none\". */\n\t\t\t\tpartition?: string | null;\n\t\t };\n\t/** Maximum price per million tokens (USD). */\n\tmax_price?: {\n\t\t/** Price per million prompt tokens. */\n\t\tprompt?: number | string;\n\t\t/** Price per million completion tokens. */\n\t\tcompletion?: number | string;\n\t\t/** Price per image. */\n\t\timage?: number | string;\n\t\t/** Price per audio unit. */\n\t\taudio?: number | string;\n\t\t/** Price per request. */\n\t\trequest?: number | string;\n\t};\n\t/** Preferred minimum throughput (tokens/second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */\n\tpreferred_min_throughput?:\n\t\t| number\n\t\t| {\n\t\t\t\t/** Minimum tokens/second at the 50th percentile. */\n\t\t\t\tp50?: number;\n\t\t\t\t/** Minimum tokens/second at the 75th percentile. */\n\t\t\t\tp75?: number;\n\t\t\t\t/** Minimum tokens/second at the 90th percentile. */\n\t\t\t\tp90?: number;\n\t\t\t\t/** Minimum tokens/second at the 99th percentile. */\n\t\t\t\tp99?: number;\n\t\t };\n\t/** Preferred maximum latency (seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */\n\tpreferred_max_latency?:\n\t\t| number\n\t\t| {\n\t\t\t\t/** Maximum latency in seconds at the 50th percentile. */\n\t\t\t\tp50?: number;\n\t\t\t\t/** Maximum latency in seconds at the 75th percentile. */\n\t\t\t\tp75?: number;\n\t\t\t\t/** Maximum latency in seconds at the 90th percentile. */\n\t\t\t\tp90?: number;\n\t\t\t\t/** Maximum latency in seconds at the 99th percentile. */\n\t\t\t\tp99?: number;\n\t\t };\n}\n\n/**\n * Vercel AI Gateway routing preferences.\n * Controls which upstream providers the gateway routes requests to.\n * @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options\n */\nexport interface VercelGatewayRouting {\n\t/** List of provider slugs to exclusively use for this request (e.g., [\"bedrock\", \"anthropic\"]). */\n\tonly?: string[];\n\t/** List of provider slugs to try in order (e.g., [\"anthropic\", \"openai\"]). */\n\torder?: string[];\n}\n\nexport interface ModelCostRates {\n\tinput: number; // $/million tokens\n\toutput: number; // $/million tokens\n\tcacheRead: number; // $/million tokens\n\tcacheWrite: number; // $/million tokens\n}\n\nexport interface ModelCostTier extends ModelCostRates {\n\t/** Use this tier for requests whose total input usage exceeds this token count. */\n\tinputTokensAbove: number;\n}\n\nexport interface ModelCost extends ModelCostRates {\n\t/** Request-wide pricing tiers. The highest matching input threshold applies to the full request. */\n\ttiers?: ModelCostTier[];\n}\n\nexport interface ImagesModel<TApi extends ImagesApi>\n\textends Omit<Model<Api>, \"api\" | \"provider\" | \"reasoning\" | \"contextWindow\" | \"maxTokens\" | \"compat\"> {\n\tapi: TApi;\n\tprovider: ImagesProviderId;\n\toutput: (\"text\" | \"image\")[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAwcA,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { TelemetryContext } from \"@earendil-works/pi-telemetry\";\nimport type { AnthropicOptions } from \"./api/anthropic-messages.ts\";\nimport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nimport type { BedrockOptions } from \"./api/bedrock-converse-stream.ts\";\nimport type { CursorAgentOptions } from \"./api/cursor-agent/types.ts\";\nimport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nimport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nimport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nimport type { OpenAICodexResponsesOptions } from \"./api/openai-codex-responses.ts\";\nimport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nimport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nimport type { PiMessagesOptions } from \"./api/pi-messages.ts\";\nimport type { Model } from \"./model.ts\";\nimport type {\n\tOpenAIResponsesCompat as BaseOpenAIResponsesCompat,\n\tSessionAffinityFormat,\n} from \"./openai-responses-compat.ts\";\nimport type { AssistantMessageDiagnostic } from \"./utils/diagnostics.ts\";\nimport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type { Model } from \"./model.ts\";\nexport type { SessionAffinityFormat } from \"./openai-responses-compat.ts\";\nexport type OpenAIResponsesCompat = BaseOpenAIResponsesCompat & {\n\t/** Whether the model supports message-anchored `additional_tools` input items. Default: false. */\n\tsupportsAdditionalTools?: boolean;\n};\nexport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type KnownApi =\n\t| \"openai-completions\"\n\t| \"mistral-conversations\"\n\t| \"openai-responses\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex-responses\"\n\t| \"cursor-agent\"\n\t| \"anthropic-messages\"\n\t| \"bedrock-converse-stream\"\n\t| \"google-generative-ai\"\n\t| \"google-vertex\"\n\t| \"pi-messages\";\n\nexport type Api = KnownApi | (string & {});\n\nexport type KnownImagesApi = \"openrouter-images\" | \"openai-images\";\n\nexport type ImagesApi = KnownImagesApi | (string & {});\n\nexport type KnownProvider =\n\t| \"alibaba-token-plan\"\n\t| \"amazon-bedrock\"\n\t| \"ant-ling\"\n\t| \"anthropic\"\n\t| \"google\"\n\t| \"google-vertex\"\n\t| \"openai\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex\"\n\t| \"ollama\"\n\t| \"cursor\"\n\t| \"radius\"\n\t| \"nvidia\"\n\t| \"deepseek\"\n\t| \"github-copilot\"\n\t| \"xai\"\n\t| \"groq\"\n\t| \"cerebras\"\n\t| \"openrouter\"\n\t| \"vercel-ai-gateway\"\n\t| \"opengateway\"\n\t| \"zai\"\n\t| \"zai-coding-cn\"\n\t| \"mistral\"\n\t| \"minimax\"\n\t| \"minimax-cn\"\n\t| \"moonshotai\"\n\t| \"moonshotai-cn\"\n\t| \"huggingface\"\n\t| \"fireworks\"\n\t| \"together\"\n\t| \"baseten\"\n\t| \"opencode\"\n\t| \"opencode-go\"\n\t| \"kimi-coding\"\n\t| \"cloudflare-workers-ai\"\n\t| \"cloudflare-ai-gateway\"\n\t| \"qwen-token-plan\"\n\t| \"qwen-token-plan-cn\"\n\t| \"qwen-token-plan-individual\"\n\t| \"xiaomi\"\n\t| \"xiaomi-token-plan-cn\"\n\t| \"xiaomi-token-plan-ams\"\n\t| \"xiaomi-token-plan-sgp\"\n\t| \"venice\";\nexport type ProviderId = KnownProvider | string;\n\nexport type KnownImagesProvider = \"openai\" | \"openrouter\";\n\nexport type ImagesProviderId = KnownImagesProvider | string;\n\nexport type ToolChoice = \"auto\" | \"none\";\nexport type ThinkingLevel = \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\nexport type ModelThinkingLevel = \"off\" | ThinkingLevel;\n\n/**\n * Provenance-bearing thinking selection. Distinct from the always-materialized\n * effective level: a selection exists only when the user (or a legacy variant\n * alias) explicitly chose a level. See .omo/plans/cursor-reasoning-levels.md §4.1.\n */\nexport interface ThinkingSelection {\n\treadonly level: ModelThinkingLevel;\n\treadonly source: \"explicit\" | \"legacy-variant\";\n\t/** Required when source is \"legacy-variant\": the exact allowlisted original variant id. */\n\treadonly legacyVariantId?: string;\n}\nexport type ThinkingLevelMap = Partial<Record<ModelThinkingLevel, string | null>>;\nexport type ChatTemplateKwargValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| {\n\t\t\t$var: \"thinking.enabled\" | \"thinking.effort\" | \"thinking.budget\";\n\t\t\tomitWhenOff?: boolean;\n\t };\n\n/** Top-level request field used to cap reasoning tokens on OpenAI-compatible servers. */\nexport type ThinkingTokenBudgetField = \"thinking_token_budget\" | \"thinking_budget\" | \"thinking_budget_tokens\";\n\n/** Token budgets for each thinking level (token-based providers only) */\nexport interface ThinkingBudgets {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n\tmax?: number;\n}\n\n// Base options all providers share\nexport type CacheRetention = \"none\" | \"short\" | \"long\";\n\nexport type Transport = \"sse\" | \"websocket\" | \"websocket-cached\" | \"auto\";\n\n/** Provider-scoped environment overrides. Values take precedence over process.env. */\nexport type ProviderEnv = Record<string, string>;\nexport type ProviderHeaders = Record<string, string | null>;\n/** Effective model and fully transformed headers for a request payload hook. */\nexport type ProviderRequestMetadata = {\n\tmodel: Model<Api>;\n\theaders: ProviderHeaders;\n};\nexport type FetchFunction = typeof globalThis.fetch;\n\nexport interface ProviderResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n}\n\n/** Authentication, HTTP transport, and lifecycle callbacks shared by provider requests. */\nexport interface ProviderRequestOptions<TModel = Model<Api>> {\n\tsignal?: AbortSignal;\n\t/**\n\t * Abort the request when the provider reports that a safety classifier\n\t * declined the requested model and a substitute model served the turn\n\t * instead (Anthropic `server-side-fallback-*` betas). The substitute's output\n\t * is billed but was never requested, so aborting keeps model selection with\n\t * the caller. Providers without server-side fallback ignore this.\n\t * Default: undefined (honor the substituted response).\n\t */\n\tabortServerSideFallback?: boolean;\n\t/** Explicit parent context for telemetry produced by this logical request. */\n\ttelemetryContext?: TelemetryContext;\n\tapiKey?: string;\n\t/**\n\t * Stable identity of the originating session for account-affinity providers,\n\t * preserved across auxiliary calls that replace `sessionId` (for example\n\t * compaction). Providers without account affinity ignore this.\n\t */\n\taffinitySessionId?: string;\n\t/**\n\t * Identifies whether the stream belongs to the main agent loop or an auxiliary request.\n\t * An absent value must be treated as auxiliary as a fail-safe.\n\t */\n\tstreamKind?: \"main\" | \"auxiliary\";\n\t/**\n\t * Optional fetch implementation for provider HTTP requests.\n\t * Defaults to `globalThis.fetch`. Provider adapters that cannot inject a custom implementation may reject it.\n\t * This does not affect WebSocket transports.\n\t */\n\tfetch?: FetchFunction;\n\t/**\n\t * Provider-scoped environment values. These take precedence over process.env for\n\t * provider configuration such as regional settings, endpoint placeholders, and\n\t * proxy variables.\n\t */\n\tenv?: ProviderEnv;\n\t/**\n\t * Optional callback for inspecting or replacing provider payloads before sending.\n\t * Return undefined to keep the payload unchanged.\n\t */\n\tonPayload?: (\n\t\tpayload: unknown,\n\t\tmodel: TModel,\n\t\trequest?: ProviderRequestMetadata,\n\t) => unknown | undefined | Promise<unknown | undefined>;\n\t/**\n\t * Optional callback invoked after an HTTP response is received.\n\t */\n\tonResponse?: (response: ProviderResponse, model: TModel) => void | Promise<void>;\n\t/**\n\t * Optional custom HTTP headers to include in API requests.\n\t * Merged with provider defaults; caller values override default headers.\n\t * On AWS Bedrock these are injected via a Smithy `build`-step middleware so\n\t * they are covered by SigV4 signing; reserved headers (`x-amz-*`,\n\t * `authorization`, `host`) are silently ignored to preserve SigV4 / bearer auth.\n\t * A null value suppresses a provider/API default header with the same name.\n\t */\n\theaders?: ProviderHeaders;\n\t/**\n\t * HTTP request timeout in milliseconds for providers/SDKs that support it.\n\t * For example, OpenAI and Anthropic SDK clients default to 10 minutes.\n\t */\n\ttimeoutMs?: number;\n\t/**\n\t * Maximum retry attempts for providers/SDKs that support client-side retries.\n\t * For example, OpenAI and Anthropic SDK clients default to 2.\n\t */\n\tmaxRetries?: number;\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately\n\t * with an error containing the requested delay, allowing higher-level retry logic\n\t * to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n}\n\nexport interface StreamOptions extends ProviderRequestOptions<Model<Api>> {\n\ttemperature?: number;\n\t/**\n\t * Arbitrary sampling parameters merged into the request body as-is, after the named request\n\t * fields, so keys here override them. Lets custom OpenAI-compatible servers (llama.cpp, vLLM,\n\t * SGLang, ...) receive parameters pi does not model, e.g. `top_p`, `top_k`, `min_p`,\n\t * `repetition_penalty`. Merged over `Model.samplingParams` per key. Only applied by\n\t * OpenAI-compatible adapters (completions, responses, Azure responses); other APIs ignore it.\n\t */\n\tsamplingParams?: Record<string, unknown>;\n\tmaxTokens?: number;\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t * Providers that do not support this option ignore it.\n\t */\n\ttransport?: Transport;\n\t/**\n\t * Prompt cache retention preference. Providers map this to their supported values.\n\t * Default: \"short\".\n\t */\n\tcacheRetention?: CacheRetention;\n\t/**\n\t * Optional session identifier for providers that support session-based caching.\n\t * Providers can use this to enable prompt caching, request routing, or other\n\t * session-aware features. Ignored by providers that don't support it.\n\t */\n\tsessionId?: string;\n\t/**\n\t * Optional custom fields to merge into the outgoing provider request body.\n\t * Applied before `onPayload` so `onPayload` can observe/override them.\n\t * Provider-managed fields (e.g. `model`, `messages`, `stream`) are preserved\n\t * and cannot be overridden to avoid breaking core request semantics.\n\t */\n\textraBody?: Record<string, unknown>;\n\t/**\n\t * WebSocket connect timeout in milliseconds for providers that support\n\t * WebSocket transports. This covers the connection/open handshake only;\n\t * stream idleness after connection uses timeoutMs.\n\t */\n\twebsocketConnectTimeoutMs?: number;\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t * For example, Anthropic uses `user_id` for abuse tracking and rate limiting.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderStreamOptions = StreamOptions & Record<string, unknown>;\n\nexport interface DeferredFetchOptions extends ProviderRequestOptions<Model<Api>> {\n\t/**\n\t * Maximum provider long-poll duration in milliseconds.\n\t * Defaults to 0, which performs one status check.\n\t */\n\twait?: number;\n}\n\n/** Request options for best-effort deferred-response cancellation. */\nexport type DeferredCancelOptions = ProviderRequestOptions<Model<Api>>;\n\n/**\n * Maps known APIs to their full provider-specific stream option types.\n * Type-only imports from API implementation modules are erased at emit, so\n * this is tree-shake safe.\n */\nexport interface ApiOptionsMap {\n\t\"anthropic-messages\": AnthropicOptions;\n\t\"openai-completions\": OpenAICompletionsOptions;\n\t\"openai-responses\": OpenAIResponsesOptions;\n\t\"openai-codex-responses\": OpenAICodexResponsesOptions;\n\t\"cursor-agent\": CursorAgentOptions;\n\t\"azure-openai-responses\": AzureOpenAIResponsesOptions;\n\t\"google-generative-ai\": GoogleOptions;\n\t\"google-vertex\": GoogleVertexOptions;\n\t\"mistral-conversations\": MistralOptions;\n\t\"bedrock-converse-stream\": BedrockOptions;\n\t\"pi-messages\": PiMessagesOptions;\n}\n\n/**\n * Full stream options for an API. Known APIs resolve to their concrete option\n * type; custom API strings fall back to the generic shape.\n */\nexport type ApiStreamOptions<TApi extends Api> = TApi extends keyof ApiOptionsMap\n\t? ApiOptionsMap[TApi]\n\t: StreamOptions & Record<string, unknown>;\n\n/**\n * The uniform stream contract of an API implementation module: every module\n * under `src/api/` exports `stream` and `streamSimple`; capable modules may also\n * export deferred-response methods. Lazy wrappers (`lazyApi()`) and provider\n * factories pass these around as values. This is the untyped dispatch shape;\n * per-API option typing lives on the implementation modules themselves and on\n * `Provider.stream()` via `ApiStreamOptions`.\n */\nexport interface ProviderStreams {\n\tstream(model: Model<Api>, context: Context, options?: StreamOptions): AssistantMessageEventStream;\n\tstreamSimple(model: Model<Api>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<Api>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n}\n\n/**\n * The uniform contract of an image-generation API implementation module:\n * every image API module under `src/api/` exports exactly `generateImages`,\n * so the module itself satisfies this interface. Lazy wrappers and image\n * provider factories pass these around as values.\n */\nexport interface ProviderImages {\n\tgenerateImages(\n\t\tmodel: ImagesModel<ImagesApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ImagesOptions,\n\t): Promise<AssistantImages>;\n}\n\nexport interface ImagesOptions extends ProviderRequestOptions<ImagesModel<ImagesApi>> {\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderImagesOptions = ImagesOptions & Record<string, unknown>;\n\nexport interface AnthropicAllowedFallbackModel {\n\tprovider: ProviderId;\n\tmodel: string;\n\tcost: ModelCost;\n}\n\nexport type AnthropicRefusalFallback = \"default\" | readonly { model: string }[];\n\n// Unified options with reasoning passed to streamSimple() and completeSimple()\nexport interface SimpleStreamOptions extends StreamOptions {\n\t/** Provider-neutral tool selection for simple requests. When omitted, adapters use provider-specific behavior. */\n\ttoolChoice?: ToolChoice;\n\treasoning?: ThinkingLevel;\n\t/**\n\t * Provenance-bearing thinking selection. Providers that need to distinguish\n\t * an explicit user choice from the always-materialized effective level read\n\t * this; `reasoning` remains the normalized effective level for everyone.\n\t */\n\tthinkingSelection?: ThinkingSelection;\n\t/** Anthropic server-side fallback for eligible refusal stop reasons. Anthropic providers only. */\n\trefusalFallbacks?: AnthropicRefusalFallback;\n\t/** Ask a capable provider to return a durable handle and continue the request asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n\t/** Custom token budgets for thinking levels (token-based providers only) */\n\tthinkingBudgets?: ThinkingBudgets;\n\t/**\n\t * Requested processing tier for providers that price and schedule by tier (OpenAI Responses and\n\t * the ChatGPT Codex backend send it as `service_tier`). Adapters without the concept ignore it.\n\t */\n\tserviceTier?: ServiceTierPreference;\n}\n\n/** Tier preferences a caller can express; providers map `\"auto\"` to their default lane. */\nexport type ServiceTierPreference = \"auto\" | \"flex\" | \"priority\";\n\n// Generic StreamFunction with typed options.\n//\n// Contract:\n// - Must return an AssistantMessageEventStream.\n// - Once invoked, request/model/runtime failures should be encoded in the\n// returned stream, not thrown.\n// - Error termination must produce an AssistantMessage with stopReason\n// \"error\" or \"aborted\" and errorMessage, emitted via the stream protocol.\nexport type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: TOptions,\n) => AssistantMessageEventStream;\n\nexport type ImagesFunction<TApi extends ImagesApi = ImagesApi, TOptions extends ImagesOptions = ImagesOptions> = (\n\tmodel: ImagesModel<TApi>,\n\tcontext: ImagesContext,\n\toptions?: TOptions,\n) => Promise<AssistantImages>;\n\nexport interface TextSignatureV1 {\n\tv: 1;\n\tid: string;\n\tphase?: \"commentary\" | \"final_answer\";\n}\n\nexport interface TextContent {\n\ttype: \"text\";\n\ttext: string;\n\ttextSignature?: string; // e.g., for OpenAI responses, message metadata (legacy id string or TextSignatureV1 JSON)\n}\n\nexport interface ThinkingContent {\n\ttype: \"thinking\";\n\tthinking: string;\n\t/** Epoch ms, stamped by the agent loop at stream-event receipt, best-effort. */\n\tstartedAt?: number;\n\t/** Epoch ms, stamped by the agent loop at stream-event receipt, best-effort. */\n\tendedAt?: number;\n\tthinkingSignature?: string; // e.g., for OpenAI responses, the reasoning item ID\n\t/** When true, the thinking content was redacted by safety filters. The opaque\n\t * encrypted payload is stored in `thinkingSignature` so it can be passed back\n\t * to the API for multi-turn continuity. */\n\tredacted?: boolean;\n}\n\nexport interface ImageContent {\n\ttype: \"image\";\n\tdata: string; // base64 encoded image data\n\tmimeType: string; // e.g., \"image/jpeg\", \"image/png\". Video payloads (e.g. \"video/mp4\") ride this\n\t// same block for models that declare the \"video\" input modality; use isVideoMimeType() to branch.\n}\n\n/** True when an ImageContent block actually carries video data (e.g. \"video/mp4\"). */\nexport function isVideoMimeType(mimeType: string): boolean {\n\treturn mimeType.toLowerCase().startsWith(\"video/\");\n}\n\nexport interface ToolCall {\n\ttype: \"toolCall\";\n\tid: string;\n\tname: string;\n\targuments: Record<string, any>;\n\t/** Set by text tool-call middleware when a truncated call could not be recovered. Carriers of `incomplete` MUST NOT be executed. */\n\tincomplete?: true;\n\t/** Error explaining why an incomplete tool call could not be recovered. */\n\terrorMessage?: string;\n\tthoughtSignature?: string; // Google-specific: opaque signature for reusing thought context\n\t/** OpenAI Responses namespace for calls to dynamically loaded or namespaced tools. */\n\tnamespace?: string;\n}\n\n/**\n * Provider-emitted content block whose semantics are owned by the originating\n * provider. Surfaces server-side tool invocations (web_search), server-side\n * tool results (web_search_tool_result), code execution traces, grounding\n * metadata fragments, and any other vendor-specific block the core does not\n * normalize.\n *\n * `subtype` mirrors the provider's wire `type` discriminator (e.g.\n * \"server_tool_use\", \"web_search_tool_result\", \"executableCode\"). `raw` is\n * the verbatim wire payload — extensions interpret it per provider+subtype.\n *\n * The owning provider id lives on the parent `AssistantMessage.provider`, not\n * here, to avoid drift on replay.\n *\n * On replay across providers, `convertMessages` implementations MUST drop\n * these blocks (they are not portable). This mirrors the existing\n * `redacted_thinking` skip pattern.\n */\nexport interface ProviderNativeContent {\n\ttype: \"providerNative\";\n\tsubtype: string;\n\traw: unknown;\n}\n\nexport interface Usage {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\t/** Subset of `cacheWrite` written with 1h retention. Only Anthropic reports this split. */\n\tcacheWrite1h?: number;\n\t/**\n\t * Reasoning/thinking tokens, when the provider reports them. This is a subset of\n\t * `output`: `output` already includes these tokens. Set to a number (possibly 0) by\n\t * providers that expose a reasoning breakdown; left undefined by providers that don't.\n\t */\n\treasoning?: number;\n\ttotalTokens: number;\n\tcost: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n}\n\nexport type StopReason = \"pending\" | \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\" | \"deferred\";\n\nexport type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\n\nexport interface DeferredHandle {\n\tprovider: string;\n\tmodelId: string;\n\tapi: string;\n\t/** Provider token, such as a response id or batch id plus row id. */\n\tid: string;\n\texpiresAt?: number;\n\tpollAfterMs?: number;\n\t/** Provider conversion data required to reconstruct the final assistant message. */\n\tdata?: JsonValue;\n}\n\nexport type AssistantStopDetails = { type: \"refusal\"; explanation?: string } | { type: \"sensitive\" };\n\nexport interface UserMessage {\n\trole: \"user\";\n\tcontent: string | (TextContent | ImageContent)[];\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\n/** A durable Responses configuration change projected into the message stream. */\nexport interface ConfigurationUpdateMessage {\n\trole: \"configurationUpdate\";\n\tcontent: (TextContent | ImageContent)[];\n\teffort: string;\n\ttimestamp: number;\n}\n\nexport interface AssistantMessage {\n\trole: \"assistant\";\n\tcontent: (TextContent | ThinkingContent | ToolCall | ProviderNativeContent)[];\n\tapi: Api;\n\tprovider: ProviderId;\n\tmodel: string;\n\tresponseModel?: string; // Concrete `chunk.model` when different from the requested `model` (e.g. OpenRouter `auto` -> `anthropic/...`)\n\tresponseId?: string; // Provider-specific response/message identifier when the upstream API exposes one\n\t/** Exact provider-native effort level used for this response. Absent for legacy or unmanaged responses. */\n\tproviderThinkingLevel?: string;\n\tdiagnostics?: AssistantMessageDiagnostic[]; // Redacted provider/runtime diagnostics for failures and recoveries.\n\tusage: Usage;\n\tstopReason: StopReason;\n\tstopDetails?: AssistantStopDetails;\n\tdeferred?: DeferredHandle;\n\terrorMessage?: string;\n\t/** Explicit owner for an abort initiated by the provider retry watchdog. */\n\tabortSource?: \"provider\";\n\trawStopReason?: string;\n\t/**\n\t * Provider indication of whether the model explicitly ended its turn.\n\t * Preserved for debugging and does not currently affect agent control flow.\n\t */\n\tendTurn?: boolean;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface ToolResultMessage<TDetails = any> {\n\trole: \"toolResult\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tcontent: (TextContent | ImageContent)[]; // Supports text and images\n\tdetails?: TDetails;\n\t/** Usage from the tool execution itself, if available. Not part of main LLM context accounting. */\n\tusage?: Usage;\n\t/**\n\t * Names from `Context.tools` that became available after this result.\n\t * Providers with native deferred tool loading use this as the load point;\n\t * other providers ignore it and use `Context.tools` normally.\n\t */\n\taddedToolNames?: string[];\n\tisError: boolean;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport type Message = UserMessage | AssistantMessage | ToolResultMessage | ConfigurationUpdateMessage;\n\nexport type ImagesInputContent = TextContent | ImageContent;\nexport type ImagesOutputContent = TextContent | ImageContent;\n\nexport interface ImagesContext {\n\tinput: ImagesInputContent[];\n}\n\nexport type ImagesStopReason = \"stop\" | \"error\" | \"aborted\";\n\nexport interface AssistantImages {\n\tapi: ImagesApi;\n\tprovider: ImagesProviderId;\n\tmodel: string;\n\toutput: ImagesOutputContent[];\n\tresponseId?: string;\n\tusage?: Usage;\n\t/** Background the provider reports for the returned images; unset when it reports `auto` or nothing. */\n\tbackground?: \"transparent\" | \"opaque\";\n\tstopReason: ImagesStopReason;\n\terrorMessage?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nimport type { TSchema } from \"typebox\";\n\nexport interface FreeformToolFormat {\n\ttype: \"grammar\";\n\tsyntax: \"lark\";\n\tdefinition: string;\n}\n\n/** OpenAI grammar variants for constrained sampling. */\nexport type GrammarFormat = \"openai_lark\" | \"openai_regex\";\n\nexport type GrammarVariants = Partial<Record<GrammarFormat, string>>;\n\n/**\n * Optional provider-side constrained sampling configs for a tool.\n *\n * The `json_schema` value roughly maps to the concept of `strict` in APIs which is\n * implemented as json-schema constrained sampling by APIs. Grammar variants let\n * callers provide provider-specific encodings of the same intended language.\n */\nexport type ConstrainedSamplingConfig =\n\t| {\n\t\t\ttype: \"json_schema\";\n\t\t\tstrict: \"prefer\" | \"require\";\n\t }\n\t| {\n\t\t\ttype: \"grammar\";\n\t\t\tvariants: GrammarVariants;\n\t };\nexport interface Tool<TParameters extends TSchema = TSchema> {\n\tname: string;\n\tdescription: string;\n\tparameters: TParameters;\n\tfreeform?: FreeformToolFormat;\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n}\n\nexport interface Context {\n\tsystemPrompt?: string;\n\tmessages: Message[];\n\ttools?: Tool[];\n}\n\n/**\n * Event protocol for AssistantMessageEventStream.\n *\n * Streams should emit `start` before partial updates, then terminate with either:\n * - `done` carrying the final successful AssistantMessage, or\n * - `error` carrying the final AssistantMessage with stopReason \"error\" or \"aborted\"\n * and errorMessage.\n */\nexport type AssistantMessageEvent =\n\t| { type: \"start\"; partial: AssistantMessage }\n\t| { type: \"text_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"text_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"text_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"thinking_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"thinking_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"thinking_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"toolcall_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"toolcall_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t/** Finalized - executable iff `incomplete !== true` on `toolCall`. */\n\t| { type: \"toolcall_end\"; contentIndex: number; toolCall: ToolCall; partial: AssistantMessage }\n\t| {\n\t\t\ttype: \"done\";\n\t\t\treason: Extract<StopReason, \"stop\" | \"length\" | \"toolUse\" | \"deferred\">;\n\t\t\tmessage: AssistantMessage;\n\t }\n\t| { type: \"error\"; reason: Extract<StopReason, \"aborted\" | \"error\">; error: AssistantMessage };\n\n/**\n * Compatibility settings for OpenAI-compatible completions APIs.\n * Use this to override URL-based auto-detection for custom providers.\n */\nexport interface OpenAICompletionsCompat {\n\t/** Whether the provider supports the `store` field. Default: auto-detected from URL. */\n\tsupportsStore?: boolean;\n\t/** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */\n\tsupportsDeveloperRole?: boolean;\n\t/** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */\n\tsupportsReasoningEffort?: boolean;\n\t/** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */\n\tsupportsUsageInStreaming?: boolean;\n\t/** Whether streamed responses include `finish_reason`. When false, pi infers `stop` or `toolUse` when the stream ends. Default: true. */\n\tsupportsFinishReason?: boolean;\n\t/** Which field to use for max tokens. Default: auto-detected from URL. */\n\tmaxTokensField?: \"max_completion_tokens\" | \"max_tokens\";\n\t/** Whether tool results require the `name` field. Default: auto-detected from URL. */\n\trequiresToolResultName?: boolean;\n\t/** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */\n\trequiresAssistantAfterToolResult?: boolean;\n\t/** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */\n\trequiresThinkingAsText?: boolean;\n\t/** Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. */\n\trequiresReasoningContentOnAssistantMessages?: boolean;\n\t/** Format for reasoning/thinking parameter. \"openai\" uses reasoning_effort, \"openrouter\" uses reasoning: { effort }, \"deepseek\" uses thinking: { type } plus reasoning_effort when supported, \"together\" uses reasoning: { enabled } plus reasoning_effort when supported, \"baseten\" uses configurable chat_template_args plus reasoning_effort when supported, \"zai\" uses thinking: { type }, \"qwen\" uses top-level enable_thinking: boolean, \"qwen-chat-template\" uses chat_template_kwargs.enable_thinking and preserve_thinking, \"chat-template\" uses configurable chat_template_kwargs, \"string-thinking\" uses top-level thinking: string, and \"ant-ling\" uses reasoning: { effort } only when the mapped effort is non-null. Default: \"openai\". */\n\tthinkingFormat?:\n\t\t| \"openai\"\n\t\t| \"openrouter\"\n\t\t| \"deepseek\"\n\t\t| \"together\"\n\t\t| \"baseten\"\n\t\t| \"zai\"\n\t\t| \"qwen\"\n\t\t| \"chat-template\"\n\t\t| \"qwen-chat-template\"\n\t\t| \"string-thinking\"\n\t\t| \"ant-ling\";\n\t/** Whether the provider accepts explicit disabled-thinking markers when thinking is off. Default: true. */\n\tsupportsDisabledThinking?: boolean;\n\t/** Kwargs to send as `chat_template_kwargs` when `thinkingFormat` is `chat-template`. Use `{ \"$var\": \"thinking.enabled\" }`, `{ \"$var\": \"thinking.effort\" }`, or `{ \"$var\": \"thinking.budget\" }` for pi-controlled thinking values. */\n\tchatTemplateKwargs?: Record<string, ChatTemplateKwargValue>;\n\t/** Arguments to send as `chat_template_args` when `thinkingFormat` is `baseten`. Use `{ \"$var\": \"thinking.enabled\" }`, `{ \"$var\": \"thinking.effort\" }`, or `{ \"$var\": \"thinking.budget\" }` for pi-controlled thinking values. */\n\tchatTemplateArgs?: Record<string, ChatTemplateKwargValue>;\n\t/** OpenRouter-compatible routing preferences sent as the `provider` request field. */\n\topenRouterRouting?: OpenRouterRouting;\n\t/**\n\t * Sent as the top-level `venice_parameters` request field on Venice models.\n\t * Venice's request schema is `additionalProperties: false`, so the object\n\t * can only be shaped here — user-supplied `extraBody` can still override it.\n\t * `include_venice_system_prompt: false` stops Venice from prepending its\n\t * own default system prompt ahead of the caller's.\n\t */\n\tveniceParameters?: { include_venice_system_prompt?: boolean };\n\t/** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */\n\tvercelGatewayRouting?: VercelGatewayRouting;\n\t/** Whether z.ai supports top-level `tool_stream: true` for streaming tool call deltas. Default: false. */\n\tzaiToolStream?: boolean;\n\t/**\n\t * Top-level request field used to cap reasoning tokens from `thinkingBudgets`.\n\t * Reasoning and the answer share `max_tokens` on these endpoints, so without a budget a\n\t * reasoning-heavy turn can consume the whole response and emit no answer.\n\t * `\"thinking_token_budget\"` is vLLM, `\"thinking_budget\"` is Qwen/DashScope/SGLang,\n\t * `\"thinking_budget_tokens\"` is llama.cpp. Off by default; not set on the generated catalog.\n\t */\n\tthinkingTokenBudgetField?: ThinkingTokenBudgetField;\n\t/** Alias for `thinkingTokenBudgetField: \"thinking_token_budget\"` (vLLM). Prefer `thinkingTokenBudgetField`. Default: false. */\n\tsupportsThinkingTokenBudget?: boolean;\n\t/** Whether the provider supports OpenAI custom tools with Lark/regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. Default: false; the generated model catalog enables it for capable models. */\n\tsupportsOpenAIGrammarTools?: boolean;\n\t/** Whether the provider supports the `strict` field in tool definitions. Default: true. */\n\tsupportsStrictMode?: boolean;\n\t/**\n\t * Provider-specific JSON Schema flavor for tool parameters. `\"moonshot-mfjs\"`\n\t * normalizes schemas for Moonshot / Kimi backends that enforce a stricter subset.\n\t */\n\ttoolSchemaFlavor?: \"moonshot-mfjs\";\n\t/**\n\t * Tool call format for models that don't natively support tool calling.\n\t * When set, the middleware will intercept tool calls and format them as text.\n\t * Supported values: \"hermes\", \"morph-xml\", \"xml\" (deprecated alias for \"morph-xml\"), \"yaml-xml\", \"gemma4-delimiter\", \"anthropic-xml\", \"antml\", \"kimi-xtml\"\n\t */\n\ttoolCallFormat?: string;\n\t/** Cache control convention for prompt caching. \"anthropic\" applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. */\n\tcacheControlFormat?: \"anthropic\";\n\t/** Whether to send session-affinity data from `options.sessionId`. Default: false. */\n\tsendSessionAffinityHeaders?: boolean;\n\t/** Provider-specific deferred tool serialization mode. */\n\tdeferredToolsMode?: \"kimi\";\n\t/** Session-affinity header format: `openai` sends `session_id`, `x-client-request-id`, and `x-session-affinity`; `openai-nosession` sends `x-client-request-id` and `x-session-affinity`; `openrouter` sends `x-session-id`. Does not affect the `prompt_cache_key` body param, which is governed by cache retention. Default: auto-detected. */\n\tsessionAffinityFormat?: SessionAffinityFormat;\n\t/** Whether the provider accepts the `prompt_cache_key` request field. Default: auto-detected. */\n\tsupportsPromptCacheKey?: boolean;\n\t/** Whether the provider supports long prompt cache retention (`prompt_cache_retention: \"24h\"` or Anthropic-style `cache_control.ttl: \"1h\"`, depending on format). Default: true. */\n\tsupportsLongCacheRetention?: boolean;\n\t/** Whether the provider accepts the `max_output_tokens` parameter. Some Codex-protocol gateways reject it. Default: true. */\n\tsupportsMaxOutputTokens?: boolean;\n\t/**\n\t * vLLM scheduler priority sent as the top-level `priority` request field (lower values are\n\t * handled earlier; server default 0). Only meaningful when vLLM runs with\n\t * `--scheduling-policy priority`; useful for keeping background/batch work from stalling\n\t * interactive sessions. Off by default; not set on the generated catalog.\n\t */\n\tvllmPriority?: number;\n}\n\n/** Compatibility settings for Anthropic Messages-compatible APIs. */\nexport interface AnthropicMessagesCompat {\n\t/**\n\t * Whether the provider accepts per-tool `eager_input_streaming`.\n\t * When false, the Anthropic provider omits `tools[].eager_input_streaming`\n\t * and sends the legacy `fine-grained-tool-streaming-2025-05-14` beta header\n\t * for tool-enabled requests.\n\t * Default: true.\n\t */\n\tsupportsEagerToolInputStreaming?: boolean;\n\t/** Whether the provider supports Anthropic long cache retention (`cache_control.ttl: \"1h\"`). Default: true. */\n\tsupportsLongCacheRetention?: boolean;\n\t/**\n\t * Whether to send the `x-session-affinity` header from `options.sessionId`\n\t * when caching is enabled. Required for providers like Fireworks that use\n\t * session affinity for prompt cache routing (requests to the same replica\n\t * maximize cache hits).\n\t * Default: false.\n\t */\n\tsendSessionAffinityHeaders?: boolean;\n\t/**\n\t * Whether the provider supports Anthropic-style `cache_control` markers on\n\t * tool definitions. When false, `cache_control` is omitted from tool params.\n\t * Some Anthropic-compatible providers (e.g., Fireworks) do not support this\n\t * field on tools and may reject or ignore it.\n\t * Default: true.\n\t */\n\tsupportsCacheControlOnTools?: boolean;\n\t/**\n\t * Whether the provider accepts `thinking: { type: \"disabled\" }` when\n\t * extended thinking is off. Some Anthropic-compatible providers support\n\t * thinking but reject Anthropic's explicit disabled marker.\n\t * Default: true.\n\t */\n\tsupportsDisabledThinking?: boolean;\n\t/**\n\t * Whether the model accepts the Anthropic `temperature` request field.\n\t * Claude Opus 4.7+ rejects non-default temperature values.\n\t * Default: true.\n\t */\n\tsupportsTemperature?: boolean;\n\t/** Whether the model accepts Anthropic `tool_choice`. Default: true. */\n\tsupportsToolChoice?: boolean;\n\t/**\n\t * Whether the model accepts forced Anthropic tool choices (`any` or a named\n\t * tool). Default: true, except Claude Fable/Mythos models.\n\t */\n\tsupportsForcedToolChoice?: boolean;\n\t/**\n\t * Whether to force adaptive thinking (`thinking.type: \"adaptive\"` plus\n\t * `output_config.effort`) regardless of the model id. Built-in models that\n\t * require adaptive thinking set this in generated metadata. Custom\n\t * Anthropic-compatible providers can set this to `true` for any model whose\n\t * upstream requires the adaptive format. Set to `false` to opt out on\n\t * overridden built-in models and disable model id/name inference.\n\t * Default: infer from adaptive Claude model ids/names when possible.\n\t */\n\tforceAdaptiveThinking?: boolean;\n\t/** Whether to replay empty thinking signatures as `signature: \"\"` instead of converting thinking to text. Default: false. */\n\tallowEmptySignature?: boolean;\n\t/** Whether the provider supports Anthropic strict tool schemas. Default: false; generated Anthropic models enable it explicitly. */\n\tsupportsStrictTools?: boolean;\n\t/** Whether the exact model transport supports effort-only system messages and thinking binding controls. Default: false. */\n\tsupportsMidConvoEffort?: boolean;\n\t/**\n\t * How to replay thinking blocks that have no usable Anthropic signature.\n\t * `\"text\"` demotes them to text; `\"empty-signature\"` preserves Anthropic's\n\t * thinking shape with `signature: \"\"`. Defaults to `\"text\"`; the legacy\n\t * `allowEmptySignature` setting remains a compatibility alias for\n\t * `\"empty-signature\"`.\n\t */\n\tunsignedThinkingReplay?: \"text\" | \"empty-signature\";\n\t/**\n\t * Model ids Anthropic accepts in `fallbacks` for server-side refusal fallback.\n\t * When absent or empty, callers must omit `fallbacks`; Anthropic rejects the\n\t * field for models with no permitted fallback targets.\n\t */\n\tallowedFallbackModels?: Array<AnthropicAllowedFallbackModel | string>;\n\t/**\n\t * Whether the provider supports deferred tools loaded by `tool_reference`\n\t * blocks in tool results. Default: true for first-party Anthropic models\n\t * except Haiku and models older than Claude 4.5; false for other providers.\n\t */\n\tsupportsToolReferences?: boolean;\n\t/**\n\t * Whether the provider executes Anthropic server-side `web_search_*` native\n\t * tools and accepts their `server_tool_use` / `web_search_tool_result`\n\t * blocks on replay. Anthropic-compatible endpoints (e.g., kimi-coding) may\n\t * run the search but reject the replayed server-tool blocks on the next\n\t * request. When false, hook-injected `web_search_*` tools are stripped from\n\t * the payload. Default: true only for the first-party Anthropic endpoint.\n\t */\n\tsupportsWebSearch?: boolean;\n}\n\n/** Compatibility settings for Amazon Bedrock models. */\nexport interface BedrockCompat {\n\t/** Whether the model supports Bedrock strict tool schemas. Default: false. */\n\tsupportsStrictMode?: boolean;\n}\n\n/**\n * OpenRouter provider routing preferences.\n * Controls which upstream providers OpenRouter routes requests to.\n * Sent as the `provider` field in the OpenRouter API request body.\n * @see https://openrouter.ai/docs/guides/routing/provider-selection\n */\nexport interface OpenRouterRouting {\n\t/** Whether to allow backup providers to serve requests. Default: true. */\n\tallow_fallbacks?: boolean;\n\t/** Whether to filter providers to only those that support all parameters in the request. Default: false. */\n\trequire_parameters?: boolean;\n\t/** Data collection setting. \"allow\" (default): allow providers that may store/train on data. \"deny\": only use providers that don't collect user data. */\n\tdata_collection?: \"deny\" | \"allow\";\n\t/** Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. */\n\tzdr?: boolean;\n\t/** Whether to restrict routing to only models that allow text distillation. */\n\tenforce_distillable_text?: boolean;\n\t/** An ordered list of provider names/slugs to try in sequence, falling back to the next if unavailable. */\n\torder?: string[];\n\t/** List of provider names/slugs to exclusively allow for this request. */\n\tonly?: string[];\n\t/** List of provider names/slugs to skip for this request. */\n\tignore?: string[];\n\t/** A list of quantization levels to filter providers by (e.g., [\"fp16\", \"bf16\", \"fp8\", \"fp6\", \"int8\", \"int4\", \"fp4\", \"fp32\"]). */\n\tquantizations?: string[];\n\t/** Sorting strategy. Can be a string (e.g., \"price\", \"throughput\", \"latency\") or an object with `by` and `partition`. */\n\tsort?:\n\t\t| string\n\t\t| {\n\t\t\t\t/** The sorting metric: \"price\", \"throughput\", \"latency\". */\n\t\t\t\tby?: string;\n\t\t\t\t/** Partitioning strategy: \"model\" (default) or \"none\". */\n\t\t\t\tpartition?: string | null;\n\t\t };\n\t/** Maximum price per million tokens (USD). */\n\tmax_price?: {\n\t\t/** Price per million prompt tokens. */\n\t\tprompt?: number | string;\n\t\t/** Price per million completion tokens. */\n\t\tcompletion?: number | string;\n\t\t/** Price per image. */\n\t\timage?: number | string;\n\t\t/** Price per audio unit. */\n\t\taudio?: number | string;\n\t\t/** Price per request. */\n\t\trequest?: number | string;\n\t};\n\t/** Preferred minimum throughput (tokens/second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */\n\tpreferred_min_throughput?:\n\t\t| number\n\t\t| {\n\t\t\t\t/** Minimum tokens/second at the 50th percentile. */\n\t\t\t\tp50?: number;\n\t\t\t\t/** Minimum tokens/second at the 75th percentile. */\n\t\t\t\tp75?: number;\n\t\t\t\t/** Minimum tokens/second at the 90th percentile. */\n\t\t\t\tp90?: number;\n\t\t\t\t/** Minimum tokens/second at the 99th percentile. */\n\t\t\t\tp99?: number;\n\t\t };\n\t/** Preferred maximum latency (seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */\n\tpreferred_max_latency?:\n\t\t| number\n\t\t| {\n\t\t\t\t/** Maximum latency in seconds at the 50th percentile. */\n\t\t\t\tp50?: number;\n\t\t\t\t/** Maximum latency in seconds at the 75th percentile. */\n\t\t\t\tp75?: number;\n\t\t\t\t/** Maximum latency in seconds at the 90th percentile. */\n\t\t\t\tp90?: number;\n\t\t\t\t/** Maximum latency in seconds at the 99th percentile. */\n\t\t\t\tp99?: number;\n\t\t };\n}\n\n/**\n * Vercel AI Gateway routing preferences.\n * Controls which upstream providers the gateway routes requests to.\n * @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options\n */\nexport interface VercelGatewayRouting {\n\t/** List of provider slugs to exclusively use for this request (e.g., [\"bedrock\", \"anthropic\"]). */\n\tonly?: string[];\n\t/** List of provider slugs to try in order (e.g., [\"anthropic\", \"openai\"]). */\n\torder?: string[];\n}\n\nexport interface ModelCostRates {\n\tinput: number; // $/million tokens\n\toutput: number; // $/million tokens\n\tcacheRead: number; // $/million tokens\n\tcacheWrite: number; // $/million tokens\n}\n\nexport interface ModelCostTier extends ModelCostRates {\n\t/** Use this tier for requests whose total input usage exceeds this token count. */\n\tinputTokensAbove: number;\n}\n\nexport interface ModelCost extends ModelCostRates {\n\t/** Request-wide pricing tiers. The highest matching input threshold applies to the full request. */\n\ttiers?: ModelCostTier[];\n}\n\nexport interface ImagesModelCost extends ModelCost {\n\t/** $/million image input tokens (reference and edit inputs). Falls back to `input` when absent. */\n\timageInput?: number;\n}\n\nexport interface ImagesModel<TApi extends ImagesApi>\n\textends Omit<Model<Api>, \"api\" | \"provider\" | \"reasoning\" | \"contextWindow\" | \"maxTokens\" | \"compat\" | \"cost\"> {\n\tapi: TApi;\n\tprovider: ImagesProviderId;\n\toutput: (\"text\" | \"image\")[];\n\tcost: ImagesModelCost;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred-tools.js","sourceRoot":"","sources":["../../src/utils/deferred-tools.ts"],"names":[],"mappings":"AAIA,MAAM,gBAAgB,GAAuB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;AAE5D,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CACjC,OAAgB,EAChB,OAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"deferred-tools.js","sourceRoot":"","sources":["../../src/utils/deferred-tools.ts"],"names":[],"mappings":"AAIA,MAAM,gBAAgB,GAAuB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;AAE5D,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CACjC,OAAgB,EAChB,OAAgB,EAChB,aAAa,GAAuB,gBAAgB;IAEpD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAgB,CAAC;IAC5C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,EAAE;QAAE,WAAW,C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;YACjD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC","sourcesContent":["import type { Context, Tool } from \"../types.ts\";\n\ntype ToolNameNormalizer = (name: string) => string;\n\nconst identityToolName: ToolNameNormalizer = (name) => name;\n\n/** Split current tools into prefix and transcript-loaded definitions. */\nexport function splitDeferredTools(\n\tcontext: Context,\n\tenabled: boolean,\n\tnormalizeName: ToolNameNormalizer = identityToolName,\n): { immediate: Tool[]; deferred: Map<string, Tool> } {\n\tconst uniqueTools = new Map<string, Tool>();\n\tfor (const tool of context.tools ?? []) uniqueTools.set(normalizeName(tool.name), tool);\n\tif (!enabled) return { immediate: [...uniqueTools.values()], deferred: new Map() };\n\n\tconst deferredNames = new Set<string>();\n\tconst usedNames = new Set<string>();\n\tfor (const message of context.messages) {\n\t\tif (message.role === \"assistant\") {\n\t\t\tfor (const block of message.content) {\n\t\t\t\tif (block.type === \"toolCall\") usedNames.add(normalizeName(block.name));\n\t\t\t}\n\t\t} else if (message.role === \"toolResult\") {\n\t\t\tfor (const name of message.addedToolNames ?? []) {\n\t\t\t\tconst normalizedName = normalizeName(name);\n\t\t\t\tif (!usedNames.has(normalizedName)) deferredNames.add(normalizedName);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst immediate: Tool[] = [];\n\tconst deferred = new Map<string, Tool>();\n\tfor (const [name, tool] of uniqueTools) {\n\t\tif (deferredNames.has(name)) deferred.set(name, tool);\n\t\telse immediate.push(tool);\n\t}\n\treturn { immediate, deferred };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-stream.d.ts","sourceRoot":"","sources":["../../src/utils/event-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAG3E,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,CA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AC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAOhE;IAED,2EAA2E;IAC3E,mBAAmB,IAAI,OAAO,CAE7B;CACD;AAED,qBAAa,2BAA4B,SAAQ,WAAW,CAAC,qBAAqB,EAAE,gBAAgB,CAAC;IACpG,cAYC;CACD;AAED,+EAA+E;AAC/E,wBAAgB,iCAAiC,IAAI,2BAA2B,CAE/E"}
|
|
@@ -3,7 +3,7 @@ export declare const PROMPT_CACHE_TTL_SHORT_SECONDS = 300;
|
|
|
3
3
|
export declare const PROMPT_CACHE_TTL_LONG_SECONDS = 3600;
|
|
4
4
|
export declare function isAnthropicApiBaseUrl(baseUrl: string): boolean;
|
|
5
5
|
export declare function getAnthropicCompat(model: Model<"anthropic-messages">): Required<Omit<AnthropicMessagesCompat, "forceAdaptiveThinking" | "supportsMidConvoEffort">>;
|
|
6
|
-
export type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "vllmPriority" | "cacheControlFormat" | "toolCallFormat" | "deferredToolsMode" | "toolSchemaFlavor" | "supportsPromptCacheKey" | "chatTemplateArgs" | "supportsThinkingTokenBudget" | "thinkingTokenBudgetField"> & {
|
|
6
|
+
export type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "vllmPriority" | "cacheControlFormat" | "toolCallFormat" | "deferredToolsMode" | "toolSchemaFlavor" | "supportsPromptCacheKey" | "chatTemplateArgs" | "supportsThinkingTokenBudget" | "thinkingTokenBudgetField" | "veniceParameters"> & {
|
|
7
7
|
cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
|
|
8
8
|
supportsPromptCacheKey?: OpenAICompletionsCompat["supportsPromptCacheKey"];
|
|
9
9
|
toolCallFormat?: OpenAICompletionsCompat["toolCallFormat"];
|
|
@@ -14,6 +14,8 @@ export type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCom
|
|
|
14
14
|
thinkingTokenBudgetField?: OpenAICompletionsCompat["thinkingTokenBudgetField"];
|
|
15
15
|
/** vLLM `priority`; off by default and never set on the generated catalog. */
|
|
16
16
|
vllmPriority?: OpenAICompletionsCompat["vllmPriority"];
|
|
17
|
+
/** Venice `venice_parameters`; only set on the generated Venice catalog. */
|
|
18
|
+
veniceParameters?: OpenAICompletionsCompat["veniceParameters"];
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* Get resolved compatibility settings for a model.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-cache-ttl.d.ts","sourceRoot":"","sources":["../../src/utils/prompt-cache-ttl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,uBAAuB,EACvB,GAAG,EAEH,KAAK,EACL,uBAAuB,EACvB,WAAW,EACX,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAClD,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAM9D;AAkBD,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,GAChC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,uBAAuB,GAAG,wBAAwB,CAAC,CAAC,CA8B7F;AAED,MAAM,MAAM,+BAA+B,GAAG,IAAI,CACjD,QAAQ,CAAC,uBAAuB,CAAC,EAC/B,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,wBAAwB,GACxB,kBAAkB,GAClB,6BAA6B,GAC7B,0BAA0B,
|
|
1
|
+
{"version":3,"file":"prompt-cache-ttl.d.ts","sourceRoot":"","sources":["../../src/utils/prompt-cache-ttl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,uBAAuB,EACvB,GAAG,EAEH,KAAK,EACL,uBAAuB,EACvB,WAAW,EACX,MAAM,aAAa,CAAC;AAGrB,eAA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C,CAAC;YAClF,OAAO,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,8BAA8B,CAAC;QAC1E,CAAC;QACD;YACC,OAAO,SAAS,CAAC;IACnB,CAAC;AACF,CAAC","sourcesContent":["import type {\n\tAnthropicMessagesCompat,\n\tApi,\n\tCacheRetention,\n\tModel,\n\tOpenAICompletionsCompat,\n\tProviderEnv,\n} from \"../types.ts\";\nimport { getProviderEnvValue } from \"./provider-env.ts\";\n\nexport const PROMPT_CACHE_TTL_SHORT_SECONDS = 300;\nexport const PROMPT_CACHE_TTL_LONG_SECONDS = 3600;\n\nexport function isAnthropicApiBaseUrl(baseUrl: string): boolean {\n\ttry {\n\t\treturn new URL(baseUrl).hostname === \"api.anthropic.com\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nconst CLAUDE_FABLE_OR_MYTHOS_MODEL_ID = /^claude-(?:fable|mythos)(?:-|$)/i;\n\n/**\n * Default for `supportsToolReferences`: first-party Anthropic models except\n * Haiku (rejects client-side tool_reference blocks) and models that predate\n * tool search (Claude 3.x, Opus/Sonnet 4.0, Opus 4.1).\n */\nfunction defaultSupportsToolReferences(model: Model<\"anthropic-messages\">): boolean {\n\tif (model.provider !== \"anthropic\" || model.id.includes(\"haiku\")) return false;\n\tconst version = model.id.match(/^claude-(?:opus|sonnet|fable)-(\\d+)(?:-(\\d+))?(?:-|$)/);\n\tif (!version) return false;\n\tconst major = Number(version[1]);\n\tconst minor = version[2] && version[2].length < 8 ? Number(version[2]) : 0;\n\treturn major > 4 || (major === 4 && minor >= 5);\n}\n\nexport function getAnthropicCompat(\n\tmodel: Model<\"anthropic-messages\">,\n): Required<Omit<AnthropicMessagesCompat, \"forceAdaptiveThinking\" | \"supportsMidConvoEffort\">> {\n\t// Auto-detect session affinity and cache control support from provider\n\tconst isFireworks = model.provider === \"fireworks\";\n\tconst isCloudflareAiGatewayAnthropic =\n\t\tmodel.provider === \"cloudflare-ai-gateway\" && model.baseUrl.includes(\"anthropic\");\n\tconst isXiaomi = model.provider === \"xiaomi\" || model.provider.startsWith(\"xiaomi-token-plan-\");\n\treturn {\n\t\tsupportsEagerToolInputStreaming: model.compat?.supportsEagerToolInputStreaming ?? !isFireworks,\n\t\tsupportsLongCacheRetention: model.compat?.supportsLongCacheRetention ?? !isFireworks,\n\t\tsendSessionAffinityHeaders:\n\t\t\tmodel.compat?.sendSessionAffinityHeaders ?? !!(isFireworks || isCloudflareAiGatewayAnthropic),\n\t\tsupportsCacheControlOnTools: model.compat?.supportsCacheControlOnTools ?? !isFireworks,\n\t\tsupportsDisabledThinking: model.compat?.supportsDisabledThinking ?? !isXiaomi,\n\t\tsupportsTemperature: model.compat?.supportsTemperature ?? true,\n\t\tsupportsToolChoice: model.compat?.supportsToolChoice ?? true,\n\t\tsupportsForcedToolChoice:\n\t\t\tmodel.compat?.supportsForcedToolChoice ?? !CLAUDE_FABLE_OR_MYTHOS_MODEL_ID.test(model.id),\n\t\tallowEmptySignature: model.compat?.allowEmptySignature ?? false,\n\t\tunsignedThinkingReplay:\n\t\t\tmodel.compat?.unsignedThinkingReplay ?? (model.compat?.allowEmptySignature ? \"empty-signature\" : \"text\"),\n\t\tallowedFallbackModels: model.compat?.allowedFallbackModels ?? [],\n\t\tsupportsStrictTools: model.compat?.supportsStrictTools ?? false,\n\t\tsupportsToolReferences: model.compat?.supportsToolReferences ?? defaultSupportsToolReferences(model),\n\t\t// Default: first-party Anthropic only. Anthropic-compatible providers\n\t\t// (kimi-coding, fireworks, copilot, gateways) may execute the server-side\n\t\t// search but reject the replayed server_tool_use / web_search_tool_result\n\t\t// blocks on the next request (kimi-coding 400s with `tool_call_id is not\n\t\t// found`).\n\t\tsupportsWebSearch: model.compat?.supportsWebSearch ?? isAnthropicApiBaseUrl(model.baseUrl),\n\t};\n}\n\nexport type ResolvedOpenAICompletionsCompat = Omit<\n\tRequired<OpenAICompletionsCompat>,\n\t| \"vllmPriority\"\n\t| \"cacheControlFormat\"\n\t| \"toolCallFormat\"\n\t| \"deferredToolsMode\"\n\t| \"toolSchemaFlavor\"\n\t| \"supportsPromptCacheKey\"\n\t| \"chatTemplateArgs\"\n\t| \"supportsThinkingTokenBudget\"\n\t| \"thinkingTokenBudgetField\"\n> & {\n\tcacheControlFormat?: OpenAICompletionsCompat[\"cacheControlFormat\"];\n\tsupportsPromptCacheKey?: OpenAICompletionsCompat[\"supportsPromptCacheKey\"];\n\ttoolCallFormat?: OpenAICompletionsCompat[\"toolCallFormat\"];\n\tdeferredToolsMode?: OpenAICompletionsCompat[\"deferredToolsMode\"];\n\ttoolSchemaFlavor?: OpenAICompletionsCompat[\"toolSchemaFlavor\"];\n\tchatTemplateArgs?: OpenAICompletionsCompat[\"chatTemplateArgs\"];\n\tsupportsThinkingTokenBudget?: OpenAICompletionsCompat[\"supportsThinkingTokenBudget\"];\n\tthinkingTokenBudgetField?: OpenAICompletionsCompat[\"thinkingTokenBudgetField\"];\n\t/** vLLM `priority`; off by default and never set on the generated catalog. */\n\tvllmPriority?: OpenAICompletionsCompat[\"vllmPriority\"];\n};\n\n/**\n * Detect compatibility settings from provider and baseUrl for known providers.\n * Provider takes precedence over URL-based detection since it's explicitly configured.\n * Returns a fully resolved OpenAICompletionsCompat object with all fields set.\n */\nfunction detectOpenAICompletionsCompat(model: Model<\"openai-completions\">): ResolvedOpenAICompletionsCompat {\n\tconst provider = model.provider;\n\tconst baseUrl = model.baseUrl;\n\n\tconst isZai =\n\t\tprovider === \"zai\" ||\n\t\tprovider === \"zai-coding-cn\" ||\n\t\tbaseUrl.includes(\"api.z.ai\") ||\n\t\tbaseUrl.includes(\"open.bigmodel.cn\");\n\tconst isTogether =\n\t\tprovider === \"together\" || baseUrl.includes(\"api.together.ai\") || baseUrl.includes(\"api.together.xyz\");\n\tconst isMoonshot = provider === \"moonshotai\" || provider === \"moonshotai-cn\" || baseUrl.includes(\"api.moonshot.\");\n\tconst isOpenRouter = provider === \"openrouter\" || baseUrl.includes(\"openrouter.ai\");\n\tconst isCloudflareWorkersAI = provider === \"cloudflare-workers-ai\" || baseUrl.includes(\"api.cloudflare.com\");\n\tconst isCloudflareAiGateway = provider === \"cloudflare-ai-gateway\" || baseUrl.includes(\"gateway.ai.cloudflare.com\");\n\tconst isNvidia = provider === \"nvidia\" || baseUrl.includes(\"integrate.api.nvidia.com\");\n\tconst isAntLing = provider === \"ant-ling\" || baseUrl.includes(\"api.ant-ling.com\");\n\tconst isDeepSeek = provider === \"deepseek\" || baseUrl.toLowerCase().includes(\"deepseek.com\");\n\n\tconst isNonStandard =\n\t\tisNvidia ||\n\t\tprovider === \"cerebras\" ||\n\t\tbaseUrl.includes(\"cerebras.ai\") ||\n\t\tprovider === \"xai\" ||\n\t\tbaseUrl.includes(\"api.x.ai\") ||\n\t\tisTogether ||\n\t\tbaseUrl.includes(\"chutes.ai\") ||\n\t\tisDeepSeek ||\n\t\tisZai ||\n\t\tisMoonshot ||\n\t\tprovider === \"opencode\" ||\n\t\tbaseUrl.includes(\"opencode.ai\") ||\n\t\tisCloudflareWorkersAI ||\n\t\tisCloudflareAiGateway ||\n\t\tisAntLing;\n\n\tconst useMaxTokens =\n\t\tbaseUrl.includes(\"chutes.ai\") ||\n\t\tisDeepSeek ||\n\t\tisMoonshot ||\n\t\tisCloudflareAiGateway ||\n\t\tisTogether ||\n\t\tisNvidia ||\n\t\tisAntLing ||\n\t\tisZai;\n\n\tconst isGrok = provider === \"xai\" || baseUrl.includes(\"api.x.ai\");\n\tconst isOpenRouterDeveloperRoleModel =\n\t\tisOpenRouter && (model.id.startsWith(\"anthropic/\") || model.id.startsWith(\"openai/\"));\n\tconst openRouterCacheControlPrefixes = [\"anthropic/\", \"qwen/\", \"google/\"];\n\tconst cacheControlModelId = model.id.startsWith(\"~\") ? model.id.slice(1) : model.id;\n\tconst supportsOpenRouterCacheControl = openRouterCacheControlPrefixes.some((prefix) =>\n\t\tcacheControlModelId.startsWith(prefix),\n\t);\n\tconst cacheControlFormat = provider === \"openrouter\" && supportsOpenRouterCacheControl ? \"anthropic\" : undefined;\n\n\treturn {\n\t\tsupportsStore: !isNonStandard,\n\t\tsupportsDeveloperRole: isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter),\n\t\tsupportsReasoningEffort:\n\t\t\t!isGrok && !isZai && !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia && !isAntLing,\n\t\tsupportsUsageInStreaming: true,\n\t\tsupportsFinishReason: true,\n\t\tmaxTokensField: useMaxTokens ? \"max_tokens\" : \"max_completion_tokens\",\n\t\trequiresToolResultName: false,\n\t\trequiresAssistantAfterToolResult: false,\n\t\trequiresThinkingAsText: false,\n\t\trequiresReasoningContentOnAssistantMessages: isDeepSeek,\n\t\tthinkingFormat: isDeepSeek\n\t\t\t? \"deepseek\"\n\t\t\t: isZai\n\t\t\t\t? \"zai\"\n\t\t\t\t: isTogether\n\t\t\t\t\t? \"together\"\n\t\t\t\t\t: isAntLing\n\t\t\t\t\t\t? \"ant-ling\"\n\t\t\t\t\t\t: isOpenRouter\n\t\t\t\t\t\t\t? \"openrouter\"\n\t\t\t\t\t\t\t: \"openai\",\n\t\topenRouterRouting: {},\n\t\tvercelGatewayRouting: {},\n\t\tchatTemplateKwargs: {},\n\t\tzaiToolStream: false,\n\t\tsupportsStrictMode: !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia,\n\t\ttoolSchemaFlavor: isMoonshot ? \"moonshot-mfjs\" : undefined,\n\t\tsupportsDisabledThinking: true,\n\t\ttoolCallFormat: undefined,\n\t\tsupportsOpenAIGrammarTools: false,\n\t\tcacheControlFormat,\n\t\tsendSessionAffinityHeaders: isOpenRouter,\n\t\tdeferredToolsMode: undefined,\n\t\tsessionAffinityFormat: isOpenRouter ? \"openrouter\" : \"openai\",\n\t\tsupportsPromptCacheKey: isMoonshot || baseUrl.includes(\"api.openai.com\"),\n\t\tsupportsMaxOutputTokens: true,\n\t\tsupportsLongCacheRetention: !(\n\t\t\tisTogether ||\n\t\t\tisCloudflareWorkersAI ||\n\t\t\tisCloudflareAiGateway ||\n\t\t\tisNvidia ||\n\t\t\tisAntLing\n\t\t),\n\t};\n}\n\n/**\n * Get resolved compatibility settings for a model.\n * Auto-detects from provider/URL then overrides with explicit model.compat.\n */\nexport function getOpenAICompletionsCompat(model: Model<\"openai-completions\">): ResolvedOpenAICompletionsCompat {\n\tconst detected = detectOpenAICompletionsCompat(model);\n\tif (!model.compat) return detected;\n\n\treturn {\n\t\tsupportsStore: model.compat.supportsStore ?? detected.supportsStore,\n\t\tsupportsDeveloperRole: model.compat.supportsDeveloperRole ?? detected.supportsDeveloperRole,\n\t\tsupportsReasoningEffort: model.compat.supportsReasoningEffort ?? detected.supportsReasoningEffort,\n\t\tsupportsUsageInStreaming: model.compat.supportsUsageInStreaming ?? detected.supportsUsageInStreaming,\n\t\tsupportsFinishReason: model.compat.supportsFinishReason ?? detected.supportsFinishReason,\n\t\tmaxTokensField: model.compat.maxTokensField ?? detected.maxTokensField,\n\t\trequiresToolResultName: model.compat.requiresToolResultName ?? detected.requiresToolResultName,\n\t\trequiresAssistantAfterToolResult:\n\t\t\tmodel.compat.requiresAssistantAfterToolResult ?? detected.requiresAssistantAfterToolResult,\n\t\trequiresThinkingAsText: model.compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,\n\t\trequiresReasoningContentOnAssistantMessages:\n\t\t\tmodel.compat.requiresReasoningContentOnAssistantMessages ??\n\t\t\tdetected.requiresReasoningContentOnAssistantMessages,\n\t\tthinkingFormat: model.compat.thinkingFormat ?? detected.thinkingFormat,\n\t\tsupportsDisabledThinking: model.compat.supportsDisabledThinking ?? detected.supportsDisabledThinking,\n\t\topenRouterRouting: model.compat.openRouterRouting ?? detected.openRouterRouting,\n\t\tvercelGatewayRouting: model.compat.vercelGatewayRouting ?? detected.vercelGatewayRouting,\n\t\tchatTemplateKwargs: model.compat.chatTemplateKwargs ?? detected.chatTemplateKwargs,\n\t\tchatTemplateArgs: model.compat.chatTemplateArgs ?? detected.chatTemplateArgs,\n\t\tzaiToolStream: model.compat.zaiToolStream ?? detected.zaiToolStream,\n\t\tsupportsThinkingTokenBudget: model.compat.supportsThinkingTokenBudget ?? detected.supportsThinkingTokenBudget,\n\t\tthinkingTokenBudgetField: model.compat.thinkingTokenBudgetField ?? detected.thinkingTokenBudgetField,\n\t\tsupportsStrictMode: model.compat.supportsStrictMode ?? detected.supportsStrictMode,\n\t\ttoolSchemaFlavor: model.compat.toolSchemaFlavor ?? detected.toolSchemaFlavor,\n\t\ttoolCallFormat: model.compat.toolCallFormat ?? detected.toolCallFormat,\n\t\tsupportsOpenAIGrammarTools: model.compat.supportsOpenAIGrammarTools ?? detected.supportsOpenAIGrammarTools,\n\t\tcacheControlFormat: model.compat.cacheControlFormat ?? detected.cacheControlFormat,\n\t\tsendSessionAffinityHeaders: model.compat.sendSessionAffinityHeaders ?? detected.sendSessionAffinityHeaders,\n\t\tdeferredToolsMode: model.compat.deferredToolsMode ?? detected.deferredToolsMode,\n\t\tsessionAffinityFormat: model.compat.sessionAffinityFormat ?? detected.sessionAffinityFormat,\n\t\tsupportsPromptCacheKey: model.compat.supportsPromptCacheKey ?? detected.supportsPromptCacheKey,\n\t\tsupportsMaxOutputTokens: model.compat.supportsMaxOutputTokens ?? detected.supportsMaxOutputTokens,\n\t\tvllmPriority: model.compat.vllmPriority ?? detected.vllmPriority,\n\t\tsupportsLongCacheRetention: model.compat.supportsLongCacheRetention ?? detected.supportsLongCacheRetention,\n\t};\n}\n\nexport function getBedrockModelMatchCandidates(modelId: string, modelName?: string): string[] {\n\tconst values = modelName ? [modelId, modelName] : [modelId];\n\treturn values.flatMap((value) => {\n\t\tconst lower = value.toLowerCase();\n\t\treturn [lower, lower.replace(/[\\s_.:]+/g, \"-\")];\n\t});\n}\n\nexport function supportsOneHourCacheTtl(model: Model<\"bedrock-converse-stream\">): boolean {\n\tconst candidates = getBedrockModelMatchCandidates(model.id, model.name);\n\treturn candidates.some((candidate) =>\n\t\t[\"opus-4-5\", \"sonnet-4-5\", \"haiku-4-5\"].some((modelVersion) => candidate.includes(modelVersion)),\n\t);\n}\n\n/**\n * Check if the model supports prompt caching.\n * Supported: Claude 3.5 Haiku, Claude 3.7 Sonnet, Claude 4.x models, Claude 5 models\n *\n * For base models and system-defined inference profiles the model ID / ARN\n * contains the model name, so we can decide locally.\n *\n * For application inference profiles (whose ARNs don't contain the model name),\n * also checks model.name which is user-controlled via models.json or registerProvider.\n * As a last resort, set AWS_BEDROCK_FORCE_CACHE=1 to enable cache points.\n * Amazon Nova models have automatic caching and don't need explicit cache points.\n */\nexport function supportsPromptCaching(model: Model<\"bedrock-converse-stream\">, env?: ProviderEnv): boolean {\n\tconst candidates = getBedrockModelMatchCandidates(model.id, model.name);\n\n\tconst hasClaudeRef = candidates.some((s) => s.includes(\"claude\"));\n\tif (!hasClaudeRef) {\n\t\t// Application inference profiles don't contain the model name in the ARN.\n\t\t// Allow users to force cache points via environment variable.\n\t\tif (getProviderEnvValue(\"AWS_BEDROCK_FORCE_CACHE\", env) === \"1\") return true;\n\t\treturn false;\n\t}\n\t// Claude 5 models (fable-5, opus-5, sonnet-5)\n\tif (candidates.some((s) => s.includes(\"fable-5\") || s.includes(\"opus-5\") || s.includes(\"sonnet-5\"))) return true;\n\t// Claude 4.x models (opus-4, sonnet-4, haiku-4)\n\tif (candidates.some((s) => s.includes(\"-4-\"))) return true;\n\t// Claude 3.7 Sonnet\n\tif (candidates.some((s) => s.includes(\"claude-3-7-sonnet\"))) return true;\n\t// Claude 3.5 Haiku\n\tif (candidates.some((s) => s.includes(\"claude-3-5-haiku\"))) return true;\n\treturn false;\n}\n\nfunction resolveAnthropicCacheRetention(\n\tcacheRetention?: CacheRetention,\n\tenv?: ProviderEnv,\n\tfallback: CacheRetention = \"short\",\n): CacheRetention {\n\tif (cacheRetention) {\n\t\treturn cacheRetention;\n\t}\n\tif (getProviderEnvValue(\"PI_CACHE_RETENTION\", env) === \"long\") {\n\t\treturn \"long\";\n\t}\n\tif (typeof process !== \"undefined\" && process.env.PI_CACHE_RETENTION !== undefined) {\n\t\treturn \"short\";\n\t}\n\treturn fallback;\n}\n\nfunction resolveOpenAICompletionsCacheRetention(cacheRetention?: CacheRetention, env?: ProviderEnv): CacheRetention {\n\tif (cacheRetention) {\n\t\treturn cacheRetention;\n\t}\n\tif (getProviderEnvValue(\"PI_CACHE_RETENTION\", env) === \"long\") {\n\t\treturn \"long\";\n\t}\n\treturn \"short\";\n}\n\nfunction resolveBedrockCacheRetention(cacheRetention?: CacheRetention, env?: ProviderEnv): CacheRetention {\n\tif (cacheRetention) {\n\t\treturn cacheRetention;\n\t}\n\tif (getProviderEnvValue(\"PI_CACHE_RETENTION\", env) === \"long\") {\n\t\treturn \"long\";\n\t}\n\treturn \"short\";\n}\n\nfunction resolveOpenAIResponsesCacheRetention(cacheRetention?: CacheRetention, env?: ProviderEnv): CacheRetention {\n\tif (cacheRetention) {\n\t\treturn cacheRetention;\n\t}\n\tif (getProviderEnvValue(\"PI_CACHE_RETENTION\", env) === \"long\") {\n\t\treturn \"long\";\n\t}\n\treturn \"short\";\n}\n\nexport function resolvePromptCacheTtlSeconds(model: Model<Api>, env?: ProviderEnv): number | undefined {\n\tswitch (model.api) {\n\t\tcase \"claude-sdk-oauth\":\n\t\t\t// The Claude SDK owns prompt caching for this lane and uses Anthropic's default 5m TTL.\n\t\t\treturn PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\tcase \"anthropic-messages\": {\n\t\t\tconst anthropicModel = model as Model<\"anthropic-messages\">;\n\t\t\tconst retention = resolveAnthropicCacheRetention(anthropicModel.cacheRetention, env, \"short\");\n\t\t\tif (retention === \"none\") return undefined;\n\t\t\treturn retention === \"long\" &&\n\t\t\t\tisAnthropicApiBaseUrl(anthropicModel.baseUrl) &&\n\t\t\t\tgetAnthropicCompat(anthropicModel).supportsLongCacheRetention\n\t\t\t\t? PROMPT_CACHE_TTL_LONG_SECONDS\n\t\t\t\t: PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t}\n\t\tcase \"bedrock-converse-stream\": {\n\t\t\tconst bedrockModel = model as Model<\"bedrock-converse-stream\">;\n\t\t\tconst retention = resolveBedrockCacheRetention(bedrockModel.cacheRetention, env);\n\t\t\tif (retention === \"none\" || !supportsPromptCaching(bedrockModel, env)) return undefined;\n\t\t\treturn retention === \"long\" && supportsOneHourCacheTtl(bedrockModel)\n\t\t\t\t? PROMPT_CACHE_TTL_LONG_SECONDS\n\t\t\t\t: PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t}\n\t\tcase \"openai-completions\": {\n\t\t\tconst completionsModel = model as Model<\"openai-completions\">;\n\t\t\tconst retention = resolveOpenAICompletionsCacheRetention(completionsModel.cacheRetention, env);\n\t\t\tif (retention === \"none\") return undefined;\n\t\t\tconst compat = getOpenAICompletionsCompat(completionsModel);\n\t\t\tif (compat.cacheControlFormat === \"anthropic\") {\n\t\t\t\treturn retention === \"long\" && compat.supportsLongCacheRetention\n\t\t\t\t\t? PROMPT_CACHE_TTL_LONG_SECONDS\n\t\t\t\t\t: PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t\t}\n\t\t\treturn PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t}\n\t\tcase \"openai-responses\":\n\t\tcase \"openai-codex-responses\":\n\t\tcase \"azure-openai-responses\": {\n\t\t\tconst retention = resolveOpenAIResponsesCacheRetention(model.cacheRetention, env);\n\t\t\treturn retention === \"none\" ? undefined : PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t}\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"prompt-cache-ttl.js","sourceRoot":"","sources":["../../src/utils/prompt-cache-ttl.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAClD,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAElD,MAAM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GAAG,0BAA0B,CAAC,gBAAgB,CAAC,CAAC;YAC5D,IAAI,MAAM,CAAC,kBAAkB,KAAK,WAAW,EAAE,CAAC;gBAC/C,OAAO,SAAS,KAAK,MAAM,IAAI,MAAM,CAAC,0BAA0B;oBAC/D,CAAC,CAAC,6BAA6B;oBAC/B,CAAC,CAAC,8BAA8B,CAAC;YACnC,CAAC;YACD,OAAO,8BAA8B,CAAC;QACvC,CAAC;QACD,KAAK,kBAAkB,CAAC;QACxB,KAAK,wBAAwB,CAAC;QAC9B,KAAK,wBAAwB,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,oCAAoC,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;YAClF,OAAO,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,8BAA8B,CAAC;QAC1E,CAAC;QACD;YACC,OAAO,SAAS,CAAC;IACnB,CAAC;AACF,CAAC","sourcesContent":["import type {\n\tAnthropicMessagesCompat,\n\tApi,\n\tCacheRetention,\n\tModel,\n\tOpenAICompletionsCompat,\n\tProviderEnv,\n} from \"../types.ts\";\nimport { getProviderEnvValue } from \"./provider-env.ts\";\n\nexport const PROMPT_CACHE_TTL_SHORT_SECONDS = 300;\nexport const PROMPT_CACHE_TTL_LONG_SECONDS = 3600;\n\nexport function isAnthropicApiBaseUrl(baseUrl: string): boolean {\n\ttry {\n\t\treturn new URL(baseUrl).hostname === \"api.anthropic.com\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nconst CLAUDE_FABLE_OR_MYTHOS_MODEL_ID = /^claude-(?:fable|mythos)(?:-|$)/i;\n\n/**\n * Default for `supportsToolReferences`: first-party Anthropic models except\n * Haiku (rejects client-side tool_reference blocks) and models that predate\n * tool search (Claude 3.x, Opus/Sonnet 4.0, Opus 4.1).\n */\nfunction defaultSupportsToolReferences(model: Model<\"anthropic-messages\">): boolean {\n\tif (model.provider !== \"anthropic\" || model.id.includes(\"haiku\")) return false;\n\tconst version = model.id.match(/^claude-(?:opus|sonnet|fable)-(\\d+)(?:-(\\d+))?(?:-|$)/);\n\tif (!version) return false;\n\tconst major = Number(version[1]);\n\tconst minor = version[2] && version[2].length < 8 ? Number(version[2]) : 0;\n\treturn major > 4 || (major === 4 && minor >= 5);\n}\n\nexport function getAnthropicCompat(\n\tmodel: Model<\"anthropic-messages\">,\n): Required<Omit<AnthropicMessagesCompat, \"forceAdaptiveThinking\" | \"supportsMidConvoEffort\">> {\n\t// Auto-detect session affinity and cache control support from provider\n\tconst isFireworks = model.provider === \"fireworks\";\n\tconst isCloudflareAiGatewayAnthropic =\n\t\tmodel.provider === \"cloudflare-ai-gateway\" && model.baseUrl.includes(\"anthropic\");\n\tconst isXiaomi = model.provider === \"xiaomi\" || model.provider.startsWith(\"xiaomi-token-plan-\");\n\treturn {\n\t\tsupportsEagerToolInputStreaming: model.compat?.supportsEagerToolInputStreaming ?? !isFireworks,\n\t\tsupportsLongCacheRetention: model.compat?.supportsLongCacheRetention ?? !isFireworks,\n\t\tsendSessionAffinityHeaders:\n\t\t\tmodel.compat?.sendSessionAffinityHeaders ?? !!(isFireworks || isCloudflareAiGatewayAnthropic),\n\t\tsupportsCacheControlOnTools: model.compat?.supportsCacheControlOnTools ?? !isFireworks,\n\t\tsupportsDisabledThinking: model.compat?.supportsDisabledThinking ?? !isXiaomi,\n\t\tsupportsTemperature: model.compat?.supportsTemperature ?? true,\n\t\tsupportsToolChoice: model.compat?.supportsToolChoice ?? true,\n\t\tsupportsForcedToolChoice:\n\t\t\tmodel.compat?.supportsForcedToolChoice ?? !CLAUDE_FABLE_OR_MYTHOS_MODEL_ID.test(model.id),\n\t\tallowEmptySignature: model.compat?.allowEmptySignature ?? false,\n\t\tunsignedThinkingReplay:\n\t\t\tmodel.compat?.unsignedThinkingReplay ?? (model.compat?.allowEmptySignature ? \"empty-signature\" : \"text\"),\n\t\tallowedFallbackModels: model.compat?.allowedFallbackModels ?? [],\n\t\tsupportsStrictTools: model.compat?.supportsStrictTools ?? false,\n\t\tsupportsToolReferences: model.compat?.supportsToolReferences ?? defaultSupportsToolReferences(model),\n\t\t// Default: first-party Anthropic only. Anthropic-compatible providers\n\t\t// (kimi-coding, fireworks, copilot, gateways) may execute the server-side\n\t\t// search but reject the replayed server_tool_use / web_search_tool_result\n\t\t// blocks on the next request (kimi-coding 400s with `tool_call_id is not\n\t\t// found`).\n\t\tsupportsWebSearch: model.compat?.supportsWebSearch ?? isAnthropicApiBaseUrl(model.baseUrl),\n\t};\n}\n\nexport type ResolvedOpenAICompletionsCompat = Omit<\n\tRequired<OpenAICompletionsCompat>,\n\t| \"vllmPriority\"\n\t| \"cacheControlFormat\"\n\t| \"toolCallFormat\"\n\t| \"deferredToolsMode\"\n\t| \"toolSchemaFlavor\"\n\t| \"supportsPromptCacheKey\"\n\t| \"chatTemplateArgs\"\n\t| \"supportsThinkingTokenBudget\"\n\t| \"thinkingTokenBudgetField\"\n\t| \"veniceParameters\"\n> & {\n\tcacheControlFormat?: OpenAICompletionsCompat[\"cacheControlFormat\"];\n\tsupportsPromptCacheKey?: OpenAICompletionsCompat[\"supportsPromptCacheKey\"];\n\ttoolCallFormat?: OpenAICompletionsCompat[\"toolCallFormat\"];\n\tdeferredToolsMode?: OpenAICompletionsCompat[\"deferredToolsMode\"];\n\ttoolSchemaFlavor?: OpenAICompletionsCompat[\"toolSchemaFlavor\"];\n\tchatTemplateArgs?: OpenAICompletionsCompat[\"chatTemplateArgs\"];\n\tsupportsThinkingTokenBudget?: OpenAICompletionsCompat[\"supportsThinkingTokenBudget\"];\n\tthinkingTokenBudgetField?: OpenAICompletionsCompat[\"thinkingTokenBudgetField\"];\n\t/** vLLM `priority`; off by default and never set on the generated catalog. */\n\tvllmPriority?: OpenAICompletionsCompat[\"vllmPriority\"];\n\t/** Venice `venice_parameters`; only set on the generated Venice catalog. */\n\tveniceParameters?: OpenAICompletionsCompat[\"veniceParameters\"];\n};\n\n/**\n * Detect compatibility settings from provider and baseUrl for known providers.\n * Provider takes precedence over URL-based detection since it's explicitly configured.\n * Returns a fully resolved OpenAICompletionsCompat object with all fields set.\n */\nfunction detectOpenAICompletionsCompat(model: Model<\"openai-completions\">): ResolvedOpenAICompletionsCompat {\n\tconst provider = model.provider;\n\tconst baseUrl = model.baseUrl;\n\n\tconst isZai =\n\t\tprovider === \"zai\" ||\n\t\tprovider === \"zai-coding-cn\" ||\n\t\tbaseUrl.includes(\"api.z.ai\") ||\n\t\tbaseUrl.includes(\"open.bigmodel.cn\");\n\tconst isTogether =\n\t\tprovider === \"together\" || baseUrl.includes(\"api.together.ai\") || baseUrl.includes(\"api.together.xyz\");\n\tconst isMoonshot = provider === \"moonshotai\" || provider === \"moonshotai-cn\" || baseUrl.includes(\"api.moonshot.\");\n\tconst isOpenRouter = provider === \"openrouter\" || baseUrl.includes(\"openrouter.ai\");\n\tconst isCloudflareWorkersAI = provider === \"cloudflare-workers-ai\" || baseUrl.includes(\"api.cloudflare.com\");\n\tconst isCloudflareAiGateway = provider === \"cloudflare-ai-gateway\" || baseUrl.includes(\"gateway.ai.cloudflare.com\");\n\tconst isNvidia = provider === \"nvidia\" || baseUrl.includes(\"integrate.api.nvidia.com\");\n\tconst isAntLing = provider === \"ant-ling\" || baseUrl.includes(\"api.ant-ling.com\");\n\tconst isDeepSeek = provider === \"deepseek\" || baseUrl.toLowerCase().includes(\"deepseek.com\");\n\n\tconst isNonStandard =\n\t\tisNvidia ||\n\t\tprovider === \"cerebras\" ||\n\t\tbaseUrl.includes(\"cerebras.ai\") ||\n\t\tprovider === \"xai\" ||\n\t\tbaseUrl.includes(\"api.x.ai\") ||\n\t\tisTogether ||\n\t\tbaseUrl.includes(\"chutes.ai\") ||\n\t\tisDeepSeek ||\n\t\tisZai ||\n\t\tisMoonshot ||\n\t\tprovider === \"opencode\" ||\n\t\tbaseUrl.includes(\"opencode.ai\") ||\n\t\tisCloudflareWorkersAI ||\n\t\tisCloudflareAiGateway ||\n\t\tisAntLing;\n\n\tconst useMaxTokens =\n\t\tbaseUrl.includes(\"chutes.ai\") ||\n\t\tisDeepSeek ||\n\t\tisMoonshot ||\n\t\tisCloudflareAiGateway ||\n\t\tisTogether ||\n\t\tisNvidia ||\n\t\tisAntLing ||\n\t\tisZai;\n\n\tconst isGrok = provider === \"xai\" || baseUrl.includes(\"api.x.ai\");\n\tconst isOpenRouterDeveloperRoleModel =\n\t\tisOpenRouter && (model.id.startsWith(\"anthropic/\") || model.id.startsWith(\"openai/\"));\n\tconst openRouterCacheControlPrefixes = [\"anthropic/\", \"qwen/\", \"google/\"];\n\tconst cacheControlModelId = model.id.startsWith(\"~\") ? model.id.slice(1) : model.id;\n\tconst supportsOpenRouterCacheControl = openRouterCacheControlPrefixes.some((prefix) =>\n\t\tcacheControlModelId.startsWith(prefix),\n\t);\n\tconst cacheControlFormat = provider === \"openrouter\" && supportsOpenRouterCacheControl ? \"anthropic\" : undefined;\n\n\treturn {\n\t\tsupportsStore: !isNonStandard,\n\t\tsupportsDeveloperRole: isOpenRouterDeveloperRoleModel || (!isNonStandard && !isOpenRouter),\n\t\tsupportsReasoningEffort:\n\t\t\t!isGrok && !isZai && !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia && !isAntLing,\n\t\tsupportsUsageInStreaming: true,\n\t\tsupportsFinishReason: true,\n\t\tmaxTokensField: useMaxTokens ? \"max_tokens\" : \"max_completion_tokens\",\n\t\trequiresToolResultName: false,\n\t\trequiresAssistantAfterToolResult: false,\n\t\trequiresThinkingAsText: false,\n\t\trequiresReasoningContentOnAssistantMessages: isDeepSeek,\n\t\tthinkingFormat: isDeepSeek\n\t\t\t? \"deepseek\"\n\t\t\t: isZai\n\t\t\t\t? \"zai\"\n\t\t\t\t: isTogether\n\t\t\t\t\t? \"together\"\n\t\t\t\t\t: isAntLing\n\t\t\t\t\t\t? \"ant-ling\"\n\t\t\t\t\t\t: isOpenRouter\n\t\t\t\t\t\t\t? \"openrouter\"\n\t\t\t\t\t\t\t: \"openai\",\n\t\topenRouterRouting: {},\n\t\tvercelGatewayRouting: {},\n\t\tchatTemplateKwargs: {},\n\t\tzaiToolStream: false,\n\t\tsupportsStrictMode: !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia,\n\t\ttoolSchemaFlavor: isMoonshot ? \"moonshot-mfjs\" : undefined,\n\t\tsupportsDisabledThinking: true,\n\t\ttoolCallFormat: undefined,\n\t\tsupportsOpenAIGrammarTools: false,\n\t\tcacheControlFormat,\n\t\tsendSessionAffinityHeaders: isOpenRouter,\n\t\tdeferredToolsMode: undefined,\n\t\tsessionAffinityFormat: isOpenRouter ? \"openrouter\" : \"openai\",\n\t\tsupportsPromptCacheKey: isMoonshot || baseUrl.includes(\"api.openai.com\"),\n\t\tsupportsMaxOutputTokens: true,\n\t\tsupportsLongCacheRetention: !(\n\t\t\tisTogether ||\n\t\t\tisCloudflareWorkersAI ||\n\t\t\tisCloudflareAiGateway ||\n\t\t\tisNvidia ||\n\t\t\tisAntLing\n\t\t),\n\t};\n}\n\n/**\n * Get resolved compatibility settings for a model.\n * Auto-detects from provider/URL then overrides with explicit model.compat.\n */\nexport function getOpenAICompletionsCompat(model: Model<\"openai-completions\">): ResolvedOpenAICompletionsCompat {\n\tconst detected = detectOpenAICompletionsCompat(model);\n\tif (!model.compat) return detected;\n\n\treturn {\n\t\tsupportsStore: model.compat.supportsStore ?? detected.supportsStore,\n\t\tsupportsDeveloperRole: model.compat.supportsDeveloperRole ?? detected.supportsDeveloperRole,\n\t\tsupportsReasoningEffort: model.compat.supportsReasoningEffort ?? detected.supportsReasoningEffort,\n\t\tsupportsUsageInStreaming: model.compat.supportsUsageInStreaming ?? detected.supportsUsageInStreaming,\n\t\tsupportsFinishReason: model.compat.supportsFinishReason ?? detected.supportsFinishReason,\n\t\tmaxTokensField: model.compat.maxTokensField ?? detected.maxTokensField,\n\t\trequiresToolResultName: model.compat.requiresToolResultName ?? detected.requiresToolResultName,\n\t\trequiresAssistantAfterToolResult:\n\t\t\tmodel.compat.requiresAssistantAfterToolResult ?? detected.requiresAssistantAfterToolResult,\n\t\trequiresThinkingAsText: model.compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,\n\t\trequiresReasoningContentOnAssistantMessages:\n\t\t\tmodel.compat.requiresReasoningContentOnAssistantMessages ??\n\t\t\tdetected.requiresReasoningContentOnAssistantMessages,\n\t\tthinkingFormat: model.compat.thinkingFormat ?? detected.thinkingFormat,\n\t\tsupportsDisabledThinking: model.compat.supportsDisabledThinking ?? detected.supportsDisabledThinking,\n\t\topenRouterRouting: model.compat.openRouterRouting ?? detected.openRouterRouting,\n\t\tvercelGatewayRouting: model.compat.vercelGatewayRouting ?? detected.vercelGatewayRouting,\n\t\tchatTemplateKwargs: model.compat.chatTemplateKwargs ?? detected.chatTemplateKwargs,\n\t\tchatTemplateArgs: model.compat.chatTemplateArgs ?? detected.chatTemplateArgs,\n\t\tzaiToolStream: model.compat.zaiToolStream ?? detected.zaiToolStream,\n\t\tsupportsThinkingTokenBudget: model.compat.supportsThinkingTokenBudget ?? detected.supportsThinkingTokenBudget,\n\t\tthinkingTokenBudgetField: model.compat.thinkingTokenBudgetField ?? detected.thinkingTokenBudgetField,\n\t\tsupportsStrictMode: model.compat.supportsStrictMode ?? detected.supportsStrictMode,\n\t\ttoolSchemaFlavor: model.compat.toolSchemaFlavor ?? detected.toolSchemaFlavor,\n\t\ttoolCallFormat: model.compat.toolCallFormat ?? detected.toolCallFormat,\n\t\tsupportsOpenAIGrammarTools: model.compat.supportsOpenAIGrammarTools ?? detected.supportsOpenAIGrammarTools,\n\t\tcacheControlFormat: model.compat.cacheControlFormat ?? detected.cacheControlFormat,\n\t\tsendSessionAffinityHeaders: model.compat.sendSessionAffinityHeaders ?? detected.sendSessionAffinityHeaders,\n\t\tdeferredToolsMode: model.compat.deferredToolsMode ?? detected.deferredToolsMode,\n\t\tsessionAffinityFormat: model.compat.sessionAffinityFormat ?? detected.sessionAffinityFormat,\n\t\tsupportsPromptCacheKey: model.compat.supportsPromptCacheKey ?? detected.supportsPromptCacheKey,\n\t\tsupportsMaxOutputTokens: model.compat.supportsMaxOutputTokens ?? detected.supportsMaxOutputTokens,\n\t\tvllmPriority: model.compat.vllmPriority ?? detected.vllmPriority,\n\t\tsupportsLongCacheRetention: model.compat.supportsLongCacheRetention ?? detected.supportsLongCacheRetention,\n\t};\n}\n\nexport function getBedrockModelMatchCandidates(modelId: string, modelName?: string): string[] {\n\tconst values = modelName ? [modelId, modelName] : [modelId];\n\treturn values.flatMap((value) => {\n\t\tconst lower = value.toLowerCase();\n\t\treturn [lower, lower.replace(/[\\s_.:]+/g, \"-\")];\n\t});\n}\n\nexport function supportsOneHourCacheTtl(model: Model<\"bedrock-converse-stream\">): boolean {\n\tconst candidates = getBedrockModelMatchCandidates(model.id, model.name);\n\treturn candidates.some((candidate) =>\n\t\t[\"opus-4-5\", \"sonnet-4-5\", \"haiku-4-5\"].some((modelVersion) => candidate.includes(modelVersion)),\n\t);\n}\n\n/**\n * Check if the model supports prompt caching.\n * Supported: Claude 3.5 Haiku, Claude 3.7 Sonnet, Claude 4.x models, Claude 5 models\n *\n * For base models and system-defined inference profiles the model ID / ARN\n * contains the model name, so we can decide locally.\n *\n * For application inference profiles (whose ARNs don't contain the model name),\n * also checks model.name which is user-controlled via models.json or registerProvider.\n * As a last resort, set AWS_BEDROCK_FORCE_CACHE=1 to enable cache points.\n * Amazon Nova models have automatic caching and don't need explicit cache points.\n */\nexport function supportsPromptCaching(model: Model<\"bedrock-converse-stream\">, env?: ProviderEnv): boolean {\n\tconst candidates = getBedrockModelMatchCandidates(model.id, model.name);\n\n\tconst hasClaudeRef = candidates.some((s) => s.includes(\"claude\"));\n\tif (!hasClaudeRef) {\n\t\t// Application inference profiles don't contain the model name in the ARN.\n\t\t// Allow users to force cache points via environment variable.\n\t\tif (getProviderEnvValue(\"AWS_BEDROCK_FORCE_CACHE\", env) === \"1\") return true;\n\t\treturn false;\n\t}\n\t// Claude 5 models (fable-5, opus-5, sonnet-5)\n\tif (candidates.some((s) => s.includes(\"fable-5\") || s.includes(\"opus-5\") || s.includes(\"sonnet-5\"))) return true;\n\t// Claude 4.x models (opus-4, sonnet-4, haiku-4)\n\tif (candidates.some((s) => s.includes(\"-4-\"))) return true;\n\t// Claude 3.7 Sonnet\n\tif (candidates.some((s) => s.includes(\"claude-3-7-sonnet\"))) return true;\n\t// Claude 3.5 Haiku\n\tif (candidates.some((s) => s.includes(\"claude-3-5-haiku\"))) return true;\n\treturn false;\n}\n\nfunction resolveAnthropicCacheRetention(\n\tcacheRetention?: CacheRetention,\n\tenv?: ProviderEnv,\n\tfallback: CacheRetention = \"short\",\n): CacheRetention {\n\tif (cacheRetention) {\n\t\treturn cacheRetention;\n\t}\n\tif (getProviderEnvValue(\"PI_CACHE_RETENTION\", env) === \"long\") {\n\t\treturn \"long\";\n\t}\n\tif (typeof process !== \"undefined\" && process.env.PI_CACHE_RETENTION !== undefined) {\n\t\treturn \"short\";\n\t}\n\treturn fallback;\n}\n\nfunction resolveOpenAICompletionsCacheRetention(cacheRetention?: CacheRetention, env?: ProviderEnv): CacheRetention {\n\tif (cacheRetention) {\n\t\treturn cacheRetention;\n\t}\n\tif (getProviderEnvValue(\"PI_CACHE_RETENTION\", env) === \"long\") {\n\t\treturn \"long\";\n\t}\n\treturn \"short\";\n}\n\nfunction resolveBedrockCacheRetention(cacheRetention?: CacheRetention, env?: ProviderEnv): CacheRetention {\n\tif (cacheRetention) {\n\t\treturn cacheRetention;\n\t}\n\tif (getProviderEnvValue(\"PI_CACHE_RETENTION\", env) === \"long\") {\n\t\treturn \"long\";\n\t}\n\treturn \"short\";\n}\n\nfunction resolveOpenAIResponsesCacheRetention(cacheRetention?: CacheRetention, env?: ProviderEnv): CacheRetention {\n\tif (cacheRetention) {\n\t\treturn cacheRetention;\n\t}\n\tif (getProviderEnvValue(\"PI_CACHE_RETENTION\", env) === \"long\") {\n\t\treturn \"long\";\n\t}\n\treturn \"short\";\n}\n\nexport function resolvePromptCacheTtlSeconds(model: Model<Api>, env?: ProviderEnv): number | undefined {\n\tswitch (model.api) {\n\t\tcase \"claude-sdk-oauth\":\n\t\t\t// The Claude SDK owns prompt caching for this lane and uses Anthropic's default 5m TTL.\n\t\t\treturn PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\tcase \"anthropic-messages\": {\n\t\t\tconst anthropicModel = model as Model<\"anthropic-messages\">;\n\t\t\tconst retention = resolveAnthropicCacheRetention(anthropicModel.cacheRetention, env, \"short\");\n\t\t\tif (retention === \"none\") return undefined;\n\t\t\treturn retention === \"long\" &&\n\t\t\t\tisAnthropicApiBaseUrl(anthropicModel.baseUrl) &&\n\t\t\t\tgetAnthropicCompat(anthropicModel).supportsLongCacheRetention\n\t\t\t\t? PROMPT_CACHE_TTL_LONG_SECONDS\n\t\t\t\t: PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t}\n\t\tcase \"bedrock-converse-stream\": {\n\t\t\tconst bedrockModel = model as Model<\"bedrock-converse-stream\">;\n\t\t\tconst retention = resolveBedrockCacheRetention(bedrockModel.cacheRetention, env);\n\t\t\tif (retention === \"none\" || !supportsPromptCaching(bedrockModel, env)) return undefined;\n\t\t\treturn retention === \"long\" && supportsOneHourCacheTtl(bedrockModel)\n\t\t\t\t? PROMPT_CACHE_TTL_LONG_SECONDS\n\t\t\t\t: PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t}\n\t\tcase \"openai-completions\": {\n\t\t\tconst completionsModel = model as Model<\"openai-completions\">;\n\t\t\tconst retention = resolveOpenAICompletionsCacheRetention(completionsModel.cacheRetention, env);\n\t\t\tif (retention === \"none\") return undefined;\n\t\t\tconst compat = getOpenAICompletionsCompat(completionsModel);\n\t\t\tif (compat.cacheControlFormat === \"anthropic\") {\n\t\t\t\treturn retention === \"long\" && compat.supportsLongCacheRetention\n\t\t\t\t\t? PROMPT_CACHE_TTL_LONG_SECONDS\n\t\t\t\t\t: PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t\t}\n\t\t\treturn PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t}\n\t\tcase \"openai-responses\":\n\t\tcase \"openai-codex-responses\":\n\t\tcase \"azure-openai-responses\": {\n\t\t\tconst retention = resolveOpenAIResponsesCacheRetention(model.cacheRetention, env);\n\t\t\treturn retention === \"none\" ? undefined : PROMPT_CACHE_TTL_SHORT_SECONDS;\n\t\t}\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-retry.js","sourceRoot":"","sources":["../../src/utils/provider-retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEnF,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAC1C,MAAM,mCAAmC,GAAG,iDAAiD,CAAC;AAiB9F,SAAS,eAAe,CAAC,KAAc;IACtC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,KAAK,CAAC,OAAO,KAAK,mCAAmC;QAAE,OAAO,IAAI,CAAC;IACvE,IAAI,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAChE,OAAO,CACN,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC;QAChE,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,YAAY,OAAO,CAAC,CACjE,CAAC;AACH,CAAC;AAED,gGAAgG;AAChG,SAAS,wBAAwB,CAAC,KAAoB;IACrD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACzD,IAAI,WAAW,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,WAAW,KAAK,OAA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C;QACV,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YACnC,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QAC3B,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,OAAgE,EAChE,UAAgC,EAAE;IAElC,OAAO,oBAAoB,CAAC,KAAK,IAAI,EAAE;QACtC,MAAM,OAAO,GAAG,MAAM,OAAO,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpC,OAAO;YACN,MAAM,EAAE,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC;YAC/C,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC1B,CAAC;IACH,CAAC,EAAE,OAAO,CAAC,CAAC;AACb,CAAC","sourcesContent":["import { appendRetryAfterMsMarker, extract429RetryAfterMs } from \"./retry-hint.ts\";\n\nconst DEFAULT_MAX_RETRY_DELAY_MS = 60_000;\nconst DIGITALOCEAN_STREAM_FAILURE_MESSAGE = \"Upstream error from DigitalOcean: stream failed\";\n\nexport interface ProviderRetryDelayError extends Error {\n\treadonly retryAfterMs: number;\n}\n\ninterface ProviderRetryOptions {\n\tmaxRetries?: number;\n\tmaxRetryDelayMs?: number;\n\tsignal?: AbortSignal;\n}\n\ninterface ProviderError extends Error {\n\tstatus: number | undefined;\n\theaders: Headers | undefined;\n}\n\nfunction isProviderError(error: unknown): error is ProviderError {\n\tif (!(error instanceof Error)) return false;\n\tif (error.message === DIGITALOCEAN_STREAM_FAILURE_MESSAGE) return true;\n\tif (!(\"status\" in error) || !(\"headers\" in error)) return false;\n\treturn (\n\t\t(error.status === undefined || typeof error.status === \"number\") &&\n\t\t(error.headers === undefined || error.headers instanceof Headers)\n\t);\n}\n\n/** Mirrors the pinned OpenAI/Anthropic SDK retry policy; review when either SDK is upgraded. */\nfunction isRetryableProviderError(error: ProviderError): boolean {\n\tconst shouldRetry = error.headers?.get(\"x-should-retry\");\n\tif (shouldRetry === \"true\") return true;\n\tif (shouldRetry === \"false\") return false;\n\n\tif (error.status === undefined) return true;\n\treturn (\n\t\terror.status === 408 ||\n\t\terror.status === 409 ||\n\t\terror.status === 429 ||\n\t\t(typeof error.status === \"number\" && error.status >= 500)\n\t);\n}\n\nfunction validateServerRetryDelayMs(\n\tdelayMs: number,\n\tmaxRetryDelayMs: number | undefined,\n\tproviderErrorMessage: string,\n): number {\n\tconst maxDelayMs = maxRetryDelayMs ?? DEFAULT_MAX_RETRY_DELAY_MS;\n\tif (maxDelayMs > 0 && delayMs > maxDelayMs) {\n\t\tconst message = `Server requested ${Math.ceil(delayMs / 1000)}s retry delay (max: ${Math.ceil(maxDelayMs / 1000)}s). ${providerErrorMessage}`;\n\t\tconst error: ProviderRetryDelayError = Object.assign(new Error(appendRetryAfterMsMarker(message, delayMs)), {\n\t\t\tretryAfterMs: delayMs,\n\t\t});\n\t\tthrow error;\n\t}\n\treturn delayMs;\n}\n\nfunction getRetryDelayMs(error: ProviderError, retryIndex: number, maxRetryDelayMs: number | undefined): number {\n\tconst hintMs = extract429RetryAfterMs({\n\t\tstatus: 429,\n\t\theaders: error.headers,\n\t\tbodyText: \"\",\n\t});\n\tif (hintMs !== undefined) {\n\t\treturn validateServerRetryDelayMs(hintMs, maxRetryDelayMs, error.message);\n\t}\n\n\tconst exponentialDelay = Math.min(0.5 * 2 ** retryIndex, 8) * 1000;\n\treturn exponentialDelay * (1 - Math.random() * 0.25);\n}\n\nfunction createAbortError(): Error {\n\tconst error = new Error(\"Request aborted\");\n\terror.name = \"AbortError\";\n\treturn error;\n}\n\nfunction abortableSleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(createAbortError());\n\t\t\treturn;\n\t\t}\n\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(createAbortError());\n\t\t};\n\t\tconst timeout = setTimeout(\n\t\t\t() => {\n\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\tMath.max(0, ms),\n\t\t);\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\n/**\n * Reproduce the retry behavior used by the OpenAI and Anthropic SDKs while making\n * their backoff sleep interruptible. Their built-in retry timers ignore the\n * request AbortSignal, so callers must invoke the SDK with `maxRetries: 0` and\n * wrap the request with this helper. Provider-requested delays above\n * `maxRetryDelayMs` fail immediately (60 seconds by default); set it to zero to\n * disable the limit.\n */\nexport async function retryProviderRequest<T>(\n\trequest: () => Promise<T>,\n\toptions: ProviderRetryOptions = {},\n): Promise<T> {\n\tconst maxRetries = options.maxRetries ?? 0;\n\tlet retriesRemaining = maxRetries;\n\n\tfor (;;) {\n\t\ttry {\n\t\t\t// Each retry is a fresh SDK request, so X-Stainless-Retry-Count remains zero.\n\t\t\treturn await request();\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted) throw createAbortError();\n\t\t\tif (retriesRemaining <= 0 || !isProviderError(error) || !isRetryableProviderError(error)) throw error;\n\n\t\t\tconst retryIndex = maxRetries - retriesRemaining;\n\t\t\tretriesRemaining--;\n\t\t\tawait abortableSleep(getRetryDelayMs(error, retryIndex, options.maxRetryDelayMs), options.signal);\n\t\t}\n\t}\n}\n\ninterface ProviderStreamAttempt<TChunk, TMetadata> {\n\tstream: AsyncIterable<TChunk>;\n\tmetadata: TMetadata;\n}\n\nasync function* replayPrefetchedStream<TChunk>(\n\tfirst: IteratorResult<TChunk>,\n\titerator: AsyncIterator<TChunk>,\n): AsyncGenerator<TChunk> {\n\tif (first.done) return;\n\tlet completed = false;\n\tlet providerFailed = false;\n\ttry {\n\t\tyield first.value;\n\t\tfor (;;) {\n\t\t\tlet next: IteratorResult<TChunk>;\n\t\t\ttry {\n\t\t\t\tnext = await iterator.next();\n\t\t\t} catch (error) {\n\t\t\t\tproviderFailed = true;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (next.done) {\n\t\t\t\tcompleted = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tyield next.value;\n\t\t}\n\t} finally {\n\t\tif (!completed && !providerFailed) {\n\t\t\tawait iterator.return?.();\n\t\t}\n\t}\n}\n\nexport async function retryProviderStreamRequest<TChunk, TMetadata>(\n\trequest: () => Promise<ProviderStreamAttempt<TChunk, TMetadata>>,\n\toptions: ProviderRetryOptions = {},\n): Promise<ProviderStreamAttempt<TChunk, TMetadata>> {\n\treturn retryProviderRequest(async () => {\n\t\tconst attempt = await request();\n\t\tconst iterator = attempt.stream[Symbol.asyncIterator]();\n\t\tconst first = await iterator.next();\n\t\treturn {\n\t\t\tstream: replayPrefetchedStream(first, iterator),\n\t\t\tmetadata: attempt.metadata,\n\t\t};\n\t}, options);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"provider-retry.js","sourceRoot":"","sources":["../../src/utils/provider-retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEnF,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAC1C,MAAM,mCAAmC,GAAG,iDAAiD,CAAC;AAiB9F,SAAS,eAAe,CAAC,KAAc;IACtC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,KAAK,CAAC,OAAO,KAAK,mCAAmC;QAAE,OAAO,IAAI,CAAC;IACvE,IAAI,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAChE,OAAO,CACN,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QA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AC;gBACJ,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC9B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,cAAc,GAAG,IAAI,CAAC;gBACtB,MAAM,KAAK,CAAC;YACb,CAAC;YACD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACf,SAAS,GAAG,IAAI,CAAC;gBACjB,OAAO;YACR,CAAC;YACD,MAAM,IAAI,CAAC,KAAK,CAAC;QAClB,CAAC;IACF,CAAC;YAAS,CAAC;QACV,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YACnC,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QAC3B,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,OAAgE,EAChE,OAAO,GAAyB,EAAE;IAElC,OAAO,oBAAoB,CAAC,KAAK,IAAI,EAAE;QACtC,MAAM,OAAO,GAAG,MAAM,OAAO,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpC,OAAO;YACN,MAAM,EAAE,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC;YAC/C,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC1B,CAAC;IACH,CAAC,EAAE,OAAO,CAAC,CAAC;AACb,CAAC","sourcesContent":["import { appendRetryAfterMsMarker, extract429RetryAfterMs } from \"./retry-hint.ts\";\n\nconst DEFAULT_MAX_RETRY_DELAY_MS = 60_000;\nconst DIGITALOCEAN_STREAM_FAILURE_MESSAGE = \"Upstream error from DigitalOcean: stream failed\";\n\nexport interface ProviderRetryDelayError extends Error {\n\treadonly retryAfterMs: number;\n}\n\ninterface ProviderRetryOptions {\n\tmaxRetries?: number;\n\tmaxRetryDelayMs?: number;\n\tsignal?: AbortSignal;\n}\n\ninterface ProviderError extends Error {\n\tstatus: number | undefined;\n\theaders: Headers | undefined;\n}\n\nfunction isProviderError(error: unknown): error is ProviderError {\n\tif (!(error instanceof Error)) return false;\n\tif (error.message === DIGITALOCEAN_STREAM_FAILURE_MESSAGE) return true;\n\tif (!(\"status\" in error) || !(\"headers\" in error)) return false;\n\treturn (\n\t\t(error.status === undefined || typeof error.status === \"number\") &&\n\t\t(error.headers === undefined || error.headers instanceof Headers)\n\t);\n}\n\n/** Mirrors the pinned OpenAI/Anthropic SDK retry policy; review when either SDK is upgraded. */\nfunction isRetryableProviderError(error: ProviderError): boolean {\n\tconst shouldRetry = error.headers?.get(\"x-should-retry\");\n\tif (shouldRetry === \"true\") return true;\n\tif (shouldRetry === \"false\") return false;\n\n\tif (error.status === undefined) return true;\n\treturn (\n\t\terror.status === 408 ||\n\t\terror.status === 409 ||\n\t\terror.status === 429 ||\n\t\t(typeof error.status === \"number\" && error.status >= 500)\n\t);\n}\n\nfunction validateServerRetryDelayMs(\n\tdelayMs: number,\n\tmaxRetryDelayMs: number | undefined,\n\tproviderErrorMessage: string,\n): number {\n\tconst maxDelayMs = maxRetryDelayMs ?? DEFAULT_MAX_RETRY_DELAY_MS;\n\tif (maxDelayMs > 0 && delayMs > maxDelayMs) {\n\t\tconst message = `Server requested ${Math.ceil(delayMs / 1000)}s retry delay (max: ${Math.ceil(maxDelayMs / 1000)}s). ${providerErrorMessage}`;\n\t\tconst error: ProviderRetryDelayError = Object.assign(new Error(appendRetryAfterMsMarker(message, delayMs)), {\n\t\t\tretryAfterMs: delayMs,\n\t\t});\n\t\tthrow error;\n\t}\n\treturn delayMs;\n}\n\nfunction getRetryDelayMs(error: ProviderError, retryIndex: number, maxRetryDelayMs: number | undefined): number {\n\tconst hintMs = extract429RetryAfterMs({\n\t\tstatus: 429,\n\t\theaders: error.headers,\n\t\tbodyText: \"\",\n\t});\n\tif (hintMs !== undefined) {\n\t\treturn validateServerRetryDelayMs(hintMs, maxRetryDelayMs, error.message);\n\t}\n\n\tconst exponentialDelay = Math.min(0.5 * 2 ** retryIndex, 8) * 1000;\n\treturn exponentialDelay * (1 - Math.random() * 0.25);\n}\n\nfunction createAbortError(): Error {\n\tconst error = new Error(\"Request aborted\");\n\terror.name = \"AbortError\";\n\treturn error;\n}\n\nfunction abortableSleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(createAbortError());\n\t\t\treturn;\n\t\t}\n\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(createAbortError());\n\t\t};\n\t\tconst timeout = setTimeout(\n\t\t\t() => {\n\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\tMath.max(0, ms),\n\t\t);\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\n/**\n * Reproduce the retry behavior used by the OpenAI and Anthropic SDKs while making\n * their backoff sleep interruptible. Their built-in retry timers ignore the\n * request AbortSignal, so callers must invoke the SDK with `maxRetries: 0` and\n * wrap the request with this helper. Provider-requested delays above\n * `maxRetryDelayMs` fail immediately (60 seconds by default); set it to zero to\n * disable the limit.\n */\nexport async function retryProviderRequest<T>(\n\trequest: () => Promise<T>,\n\toptions: ProviderRetryOptions = {},\n): Promise<T> {\n\tconst maxRetries = options.maxRetries ?? 0;\n\tlet retriesRemaining = maxRetries;\n\n\tfor (;;) {\n\t\ttry {\n\t\t\t// Each retry is a fresh SDK request, so X-Stainless-Retry-Count remains zero.\n\t\t\treturn await request();\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted) throw createAbortError();\n\t\t\tif (retriesRemaining <= 0 || !isProviderError(error) || !isRetryableProviderError(error)) throw error;\n\n\t\t\tconst retryIndex = maxRetries - retriesRemaining;\n\t\t\tretriesRemaining--;\n\t\t\tawait abortableSleep(getRetryDelayMs(error, retryIndex, options.maxRetryDelayMs), options.signal);\n\t\t}\n\t}\n}\n\ninterface ProviderStreamAttempt<TChunk, TMetadata> {\n\tstream: AsyncIterable<TChunk>;\n\tmetadata: TMetadata;\n}\n\nasync function* replayPrefetchedStream<TChunk>(\n\tfirst: IteratorResult<TChunk>,\n\titerator: AsyncIterator<TChunk>,\n): AsyncGenerator<TChunk> {\n\tif (first.done) return;\n\tlet completed = false;\n\tlet providerFailed = false;\n\ttry {\n\t\tyield first.value;\n\t\tfor (;;) {\n\t\t\tlet next: IteratorResult<TChunk>;\n\t\t\ttry {\n\t\t\t\tnext = await iterator.next();\n\t\t\t} catch (error) {\n\t\t\t\tproviderFailed = true;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (next.done) {\n\t\t\t\tcompleted = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tyield next.value;\n\t\t}\n\t} finally {\n\t\tif (!completed && !providerFailed) {\n\t\t\tawait iterator.return?.();\n\t\t}\n\t}\n}\n\nexport async function retryProviderStreamRequest<TChunk, TMetadata>(\n\trequest: () => Promise<ProviderStreamAttempt<TChunk, TMetadata>>,\n\toptions: ProviderRetryOptions = {},\n): Promise<ProviderStreamAttempt<TChunk, TMetadata>> {\n\treturn retryProviderRequest(async () => {\n\t\tconst attempt = await request();\n\t\tconst iterator = attempt.stream[Symbol.asyncIterator]();\n\t\tconst first = await iterator.next();\n\t\treturn {\n\t\t\tstream: replayPrefetchedStream(first, iterator),\n\t\t\tmetadata: attempt.metadata,\n\t\t};\n\t}, options);\n}\n"]}
|