@linxiraos/pi-ai 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5066 -0
- package/README.md +1195 -0
- package/dist/types/api-registry.d.ts +30 -0
- package/dist/types/auth/sqlite-credential-store.d.ts +117 -0
- package/dist/types/auth-broker/client.d.ts +93 -0
- package/dist/types/auth-broker/discover.d.ts +39 -0
- package/dist/types/auth-broker/index.d.ts +7 -0
- package/dist/types/auth-broker/refresher.d.ts +25 -0
- package/dist/types/auth-broker/remote-store.d.ts +136 -0
- package/dist/types/auth-broker/server.d.ts +48 -0
- package/dist/types/auth-broker/snapshot-cache.d.ts +17 -0
- package/dist/types/auth-broker/types.d.ts +152 -0
- package/dist/types/auth-broker/wire-schema-resource.d.ts +53 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +5 -0
- package/dist/types/auth-gateway/http.d.ts +56 -0
- package/dist/types/auth-gateway/index.d.ts +3 -0
- package/dist/types/auth-gateway/server.d.ts +36 -0
- package/dist/types/auth-gateway/types.d.ts +127 -0
- package/dist/types/auth-retry.d.ts +150 -0
- package/dist/types/auth-storage.d.ts +1258 -0
- package/dist/types/dialect/anthropic.d.ts +15 -0
- package/dist/types/dialect/catalog.d.ts +3 -0
- package/dist/types/dialect/coercion.d.ts +23 -0
- package/dist/types/dialect/deepseek.d.ts +14 -0
- package/dist/types/dialect/demotion.d.ts +30 -0
- package/dist/types/dialect/examples.d.ts +18 -0
- package/dist/types/dialect/factory.d.ts +3 -0
- package/dist/types/dialect/fenced-thinking.d.ts +53 -0
- package/dist/types/dialect/gemini.d.ts +17 -0
- package/dist/types/dialect/gemma.d.ts +15 -0
- package/dist/types/dialect/glm.d.ts +9 -0
- package/dist/types/dialect/harmony.d.ts +8 -0
- package/dist/types/dialect/hermes.d.ts +9 -0
- package/dist/types/dialect/history.d.ts +3 -0
- package/dist/types/dialect/index.d.ts +11 -0
- package/dist/types/dialect/inventory.d.ts +9 -0
- package/dist/types/dialect/kimi.d.ts +14 -0
- package/dist/types/dialect/minimax.d.ts +3 -0
- package/dist/types/dialect/owned-stream.d.ts +4 -0
- package/dist/types/dialect/qwen3.d.ts +9 -0
- package/dist/types/dialect/rendering.d.ts +54 -0
- package/dist/types/dialect/thinking.d.ts +6 -0
- package/dist/types/dialect/types.d.ts +68 -0
- package/dist/types/dialect/xml.d.ts +9 -0
- package/dist/types/error/abort.d.ts +14 -0
- package/dist/types/error/auth-classify.d.ts +20 -0
- package/dist/types/error/auth.d.ts +27 -0
- package/dist/types/error/aws.d.ts +27 -0
- package/dist/types/error/classes.d.ts +106 -0
- package/dist/types/error/finalize.d.ts +39 -0
- package/dist/types/error/flags.d.ts +94 -0
- package/dist/types/error/format.d.ts +20 -0
- package/dist/types/error/gateway.d.ts +20 -0
- package/dist/types/error/index.d.ts +14 -0
- package/dist/types/error/oauth.d.ts +43 -0
- package/dist/types/error/provider.d.ts +42 -0
- package/dist/types/error/rate-limit.d.ts +80 -0
- package/dist/types/error/retryable.d.ts +27 -0
- package/dist/types/error/validation.d.ts +32 -0
- package/dist/types/index.d.ts +51 -0
- package/dist/types/provider-details.d.ts +24 -0
- package/dist/types/providers/amazon-bedrock.d.ts +39 -0
- package/dist/types/providers/anthropic-client.d.ts +106 -0
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +937 -0
- package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
- package/dist/types/providers/anthropic-wire.d.ts +345 -0
- package/dist/types/providers/anthropic.d.ts +261 -0
- package/dist/types/providers/aws-credentials.d.ts +48 -0
- package/dist/types/providers/aws-eventstream.d.ts +39 -0
- package/dist/types/providers/aws-sigv4.d.ts +55 -0
- package/dist/types/providers/azure-openai-responses.d.ts +16 -0
- package/dist/types/providers/bedrock-mantle.d.ts +13 -0
- package/dist/types/providers/claude-code-fingerprint.d.ts +19 -0
- package/dist/types/providers/cowork-fetch.d.ts +3 -0
- package/dist/types/providers/cursor/exec-modern.d.ts +98 -0
- package/dist/types/providers/cursor-pi-args.d.ts +105 -0
- package/dist/types/providers/cursor.d.ts +221 -0
- package/dist/types/providers/devin.d.ts +12 -0
- package/dist/types/providers/error-message.d.ts +25 -0
- package/dist/types/providers/github-copilot-headers.d.ts +40 -0
- package/dist/types/providers/gitlab-duo-workflow.d.ts +254 -0
- package/dist/types/providers/gitlab-duo.d.ts +27 -0
- package/dist/types/providers/google-auth.d.ts +24 -0
- package/dist/types/providers/google-gemini-cli.d.ts +120 -0
- package/dist/types/providers/google-shared.d.ts +203 -0
- package/dist/types/providers/google-types.d.ts +155 -0
- package/dist/types/providers/google-vertex.d.ts +7 -0
- package/dist/types/providers/google.d.ts +4 -0
- package/dist/types/providers/grammar.d.ts +1 -0
- package/dist/types/providers/kimi.d.ts +27 -0
- package/dist/types/providers/mock.d.ts +179 -0
- package/dist/types/providers/ollama.d.ts +8 -0
- package/dist/types/providers/openai-anthropic-shim.d.ts +35 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +1311 -0
- package/dist/types/providers/openai-chat-server.d.ts +16 -0
- package/dist/types/providers/openai-chat-wire.d.ts +669 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +109 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +26 -0
- package/dist/types/providers/openai-codex-responses.d.ts +238 -0
- package/dist/types/providers/openai-completions.d.ts +48 -0
- package/dist/types/providers/openai-reasoning-fallback.d.ts +25 -0
- package/dist/types/providers/openai-responses-server-schema.d.ts +1314 -0
- package/dist/types/providers/openai-responses-server.d.ts +17 -0
- package/dist/types/providers/openai-responses-wire.d.ts +6099 -0
- package/dist/types/providers/openai-responses.d.ts +131 -0
- package/dist/types/providers/openai-shared.d.ts +624 -0
- package/dist/types/providers/pi-native-client.d.ts +13 -0
- package/dist/types/providers/pi-native-server.d.ts +69 -0
- package/dist/types/providers/register-builtins.d.ts +37 -0
- package/dist/types/providers/synthetic.d.ts +26 -0
- package/dist/types/providers/transform-messages.d.ts +32 -0
- package/dist/types/providers/vision-guard.d.ts +20 -0
- package/dist/types/registry/aiand.d.ts +7 -0
- package/dist/types/registry/aimlapi.d.ts +4 -0
- package/dist/types/registry/alibaba-coding-plan.d.ts +8 -0
- package/dist/types/registry/alibaba-token-plan.d.ts +18 -0
- package/dist/types/registry/amazon-bedrock.d.ts +5 -0
- package/dist/types/registry/anthropic.d.ts +10 -0
- package/dist/types/registry/api-key-login.d.ts +42 -0
- package/dist/types/registry/api-key-validation.d.ts +43 -0
- package/dist/types/registry/aws.d.ts +13 -0
- package/dist/types/registry/azure.d.ts +4 -0
- package/dist/types/registry/baseten.d.ts +7 -0
- package/dist/types/registry/bedrock-mantle.d.ts +22 -0
- package/dist/types/registry/cerebras.d.ts +7 -0
- package/dist/types/registry/cloudflare-ai-gateway.d.ts +13 -0
- package/dist/types/registry/coreweave.d.ts +7 -0
- package/dist/types/registry/cursor.d.ts +7 -0
- package/dist/types/registry/deepseek.d.ts +8 -0
- package/dist/types/registry/derived.d.ts +5 -0
- package/dist/types/registry/devin.d.ts +8 -0
- package/dist/types/registry/exa.d.ts +8 -0
- package/dist/types/registry/firepass.d.ts +16 -0
- package/dist/types/registry/fireworks.d.ts +7 -0
- package/dist/types/registry/github-copilot.d.ts +7 -0
- package/dist/types/registry/gitlab-duo-workflow.d.ts +10 -0
- package/dist/types/registry/gitlab-duo.d.ts +9 -0
- package/dist/types/registry/gmi-cloud.d.ts +7 -0
- package/dist/types/registry/google-antigravity.d.ts +9 -0
- package/dist/types/registry/google-gemini-cli.d.ts +9 -0
- package/dist/types/registry/google-vertex.d.ts +5 -0
- package/dist/types/registry/google.d.ts +4 -0
- package/dist/types/registry/groq.d.ts +4 -0
- package/dist/types/registry/huggingface.d.ts +7 -0
- package/dist/types/registry/index.d.ts +4 -0
- package/dist/types/registry/kagi.d.ts +14 -0
- package/dist/types/registry/kilo.d.ts +7 -0
- package/dist/types/registry/kimi-code.d.ts +7 -0
- package/dist/types/registry/litellm.d.ts +13 -0
- package/dist/types/registry/llama-cpp.d.ts +8 -0
- package/dist/types/registry/lm-studio.d.ts +8 -0
- package/dist/types/registry/meta.d.ts +7 -0
- package/dist/types/registry/minimax-code-cn.d.ts +6 -0
- package/dist/types/registry/minimax-code.d.ts +6 -0
- package/dist/types/registry/minimax.d.ts +4 -0
- package/dist/types/registry/mistral.d.ts +4 -0
- package/dist/types/registry/moonshot.d.ts +7 -0
- package/dist/types/registry/nanogpt.d.ts +7 -0
- package/dist/types/registry/novita.d.ts +6 -0
- package/dist/types/registry/nvidia.d.ts +7 -0
- package/dist/types/registry/oauth/anthropic-constants.d.ts +12 -0
- package/dist/types/registry/oauth/anthropic.d.ts +24 -0
- package/dist/types/registry/oauth/callback-server.d.ts +74 -0
- package/dist/types/registry/oauth/cursor.d.ts +16 -0
- package/dist/types/registry/oauth/device-code.d.ts +25 -0
- package/dist/types/registry/oauth/devin.d.ts +5 -0
- package/dist/types/registry/oauth/github-copilot.d.ts +30 -0
- package/dist/types/registry/oauth/gitlab-duo-workflow.d.ts +6 -0
- package/dist/types/registry/oauth/gitlab-duo.d.ts +3 -0
- package/dist/types/registry/oauth/google-antigravity.d.ts +11 -0
- package/dist/types/registry/oauth/google-gemini-cli.d.ts +22 -0
- package/dist/types/registry/oauth/google-oauth-shared.d.ts +56 -0
- package/dist/types/registry/oauth/index.d.ts +45 -0
- package/dist/types/registry/oauth/kimi.d.ts +21 -0
- package/dist/types/registry/oauth/minimax-code.d.ts +27 -0
- package/dist/types/registry/oauth/openai-codex.d.ts +33 -0
- package/dist/types/registry/oauth/opencode.d.ts +18 -0
- package/dist/types/registry/oauth/perplexity.d.ts +9 -0
- package/dist/types/registry/oauth/pkce.d.ts +8 -0
- package/dist/types/registry/oauth/types.d.ts +87 -0
- package/dist/types/registry/oauth/wafer.d.ts +1 -0
- package/dist/types/registry/oauth/xai-oauth.d.ts +46 -0
- package/dist/types/registry/oauth/xiaomi.d.ts +25 -0
- package/dist/types/registry/oauth/zai.d.ts +25 -0
- package/dist/types/registry/ollama-cloud.d.ts +7 -0
- package/dist/types/registry/ollama.d.ts +12 -0
- package/dist/types/registry/openai-codex-device.d.ts +8 -0
- package/dist/types/registry/openai-codex.d.ts +9 -0
- package/dist/types/registry/openai.d.ts +4 -0
- package/dist/types/registry/opencode-go.d.ts +6 -0
- package/dist/types/registry/opencode-zen.d.ts +6 -0
- package/dist/types/registry/openrouter.d.ts +13 -0
- package/dist/types/registry/parallel.d.ts +14 -0
- package/dist/types/registry/perplexity.d.ts +7 -0
- package/dist/types/registry/qianfan.d.ts +7 -0
- package/dist/types/registry/qwen-portal.d.ts +7 -0
- package/dist/types/registry/registry.d.ts +367 -0
- package/dist/types/registry/sakana.d.ts +7 -0
- package/dist/types/registry/siliconflow-cn.d.ts +7 -0
- package/dist/types/registry/siliconflow.d.ts +7 -0
- package/dist/types/registry/synthetic.d.ts +6 -0
- package/dist/types/registry/tavily.d.ts +14 -0
- package/dist/types/registry/together.d.ts +6 -0
- package/dist/types/registry/types.d.ts +75 -0
- package/dist/types/registry/umans.d.ts +7 -0
- package/dist/types/registry/venice.d.ts +13 -0
- package/dist/types/registry/vercel-ai-gateway.d.ts +7 -0
- package/dist/types/registry/vllm.d.ts +7 -0
- package/dist/types/registry/wafer-serverless.d.ts +6 -0
- package/dist/types/registry/xai-oauth.d.ts +7 -0
- package/dist/types/registry/xai.d.ts +7 -0
- package/dist/types/registry/xiaomi-token-plan-ams.d.ts +6 -0
- package/dist/types/registry/xiaomi-token-plan-cn.d.ts +6 -0
- package/dist/types/registry/xiaomi-token-plan-sgp.d.ts +6 -0
- package/dist/types/registry/xiaomi.d.ts +6 -0
- package/dist/types/registry/zai.d.ts +15 -0
- package/dist/types/registry/zenmux.d.ts +7 -0
- package/dist/types/registry/zhipu-coding-plan.d.ts +7 -0
- package/dist/types/stream.d.ts +46 -0
- package/dist/types/types.d.ts +1064 -0
- package/dist/types/usage/alibaba-token-plan.d.ts +3 -0
- package/dist/types/usage/claude.d.ts +4 -0
- package/dist/types/usage/cursor.d.ts +4 -0
- package/dist/types/usage/gemini.d.ts +2 -0
- package/dist/types/usage/github-copilot.d.ts +7 -0
- package/dist/types/usage/google-antigravity.d.ts +15 -0
- package/dist/types/usage/kimi.d.ts +2 -0
- package/dist/types/usage/minimax-code.d.ts +3 -0
- package/dist/types/usage/ollama.d.ts +5 -0
- package/dist/types/usage/openai-codex-base-url.d.ts +18 -0
- package/dist/types/usage/openai-codex-reset.d.ts +88 -0
- package/dist/types/usage/openai-codex.d.ts +10 -0
- package/dist/types/usage/opencode-go.d.ts +2 -0
- package/dist/types/usage/shared.d.ts +1 -0
- package/dist/types/usage/synthetic.d.ts +2 -0
- package/dist/types/usage/umans.d.ts +2 -0
- package/dist/types/usage/xai-oauth.d.ts +12 -0
- package/dist/types/usage/zai.d.ts +3 -0
- package/dist/types/usage.d.ts +527 -0
- package/dist/types/utils/abort.d.ts +25 -0
- package/dist/types/utils/anthropic-auth.d.ts +35 -0
- package/dist/types/utils/aws-profile.d.ts +17 -0
- package/dist/types/utils/block-symbols.d.ts +62 -0
- package/dist/types/utils/deterministic-id.d.ts +16 -0
- package/dist/types/utils/empty-completion-retry.d.ts +21 -0
- package/dist/types/utils/event-stream.d.ts +39 -0
- package/dist/types/utils/foundry.d.ts +1 -0
- package/dist/types/utils/google-validation.d.ts +2 -0
- package/dist/types/utils/harmony-leak.d.ts +135 -0
- package/dist/types/utils/http-inspector.d.ts +49 -0
- package/dist/types/utils/idle-iterator.d.ts +149 -0
- package/dist/types/utils/leaked-thinking-stream.d.ts +33 -0
- package/dist/types/utils/openai-http.d.ts +48 -0
- package/dist/types/utils/openrouter-headers.d.ts +1 -0
- package/dist/types/utils/parse-bind.d.ts +23 -0
- package/dist/types/utils/provider-response.d.ts +3 -0
- package/dist/types/utils/proxy.d.ts +39 -0
- package/dist/types/utils/request-debug.d.ts +29 -0
- package/dist/types/utils/retry-after.d.ts +4 -0
- package/dist/types/utils/retry.d.ts +14 -0
- package/dist/types/utils/schema/adapt.d.ts +24 -0
- package/dist/types/utils/schema/compatibility.d.ts +30 -0
- package/dist/types/utils/schema/dereference.d.ts +11 -0
- package/dist/types/utils/schema/draft.d.ts +10 -0
- package/dist/types/utils/schema/equality.d.ts +4 -0
- package/dist/types/utils/schema/fields.d.ts +54 -0
- package/dist/types/utils/schema/index.d.ts +14 -0
- package/dist/types/utils/schema/json-schema-validator.d.ts +20 -0
- package/dist/types/utils/schema/meta-validator.d.ts +2 -0
- package/dist/types/utils/schema/normalize.d.ts +153 -0
- package/dist/types/utils/schema/spill.d.ts +8 -0
- package/dist/types/utils/schema/stamps.d.ts +17 -0
- package/dist/types/utils/schema/strict-tool-validation.d.ts +16 -0
- package/dist/types/utils/schema/types.d.ts +4 -0
- package/dist/types/utils/schema/typescript.d.ts +24 -0
- package/dist/types/utils/schema/wire.d.ts +52 -0
- package/dist/types/utils/sdk-stream-timeout.d.ts +33 -0
- package/dist/types/utils/sse-debug.d.ts +5 -0
- package/dist/types/utils/stream-markup-healing.d.ts +87 -0
- package/dist/types/utils/thinking-loop.d.ts +102 -0
- package/dist/types/utils/tool-call-loop-guard.d.ts +26 -0
- package/dist/types/utils/tool-choice.d.ts +52 -0
- package/dist/types/utils/validation.d.ts +28 -0
- package/dist/types/utils.d.ts +57 -0
- package/package.json +138 -0
- package/src/api-registry.ts +109 -0
- package/src/auth/sqlite-credential-store.ts +2066 -0
- package/src/auth-broker/client.ts +471 -0
- package/src/auth-broker/discover.ts +310 -0
- package/src/auth-broker/index.ts +7 -0
- package/src/auth-broker/refresher.ts +117 -0
- package/src/auth-broker/remote-store.ts +1332 -0
- package/src/auth-broker/server.ts +898 -0
- package/src/auth-broker/snapshot-cache.ts +200 -0
- package/src/auth-broker/types.ts +193 -0
- package/src/auth-broker/wire-schema-resource.ts +487 -0
- package/src/auth-broker/wire-schemas.ts +43 -0
- package/src/auth-gateway/http.ts +227 -0
- package/src/auth-gateway/index.ts +3 -0
- package/src/auth-gateway/server.ts +836 -0
- package/src/auth-gateway/types.ts +153 -0
- package/src/auth-retry.ts +401 -0
- package/src/auth-storage.ts +6540 -0
- package/src/dialect/anthropic.md +31 -0
- package/src/dialect/anthropic.ts +608 -0
- package/src/dialect/catalog.ts +29 -0
- package/src/dialect/coercion.ts +136 -0
- package/src/dialect/deepseek.md +24 -0
- package/src/dialect/deepseek.ts +609 -0
- package/src/dialect/demotion.ts +40 -0
- package/src/dialect/examples.ts +71 -0
- package/src/dialect/factory.ts +34 -0
- package/src/dialect/fenced-thinking.ts +184 -0
- package/src/dialect/gemini.md +44 -0
- package/src/dialect/gemini.ts +583 -0
- package/src/dialect/gemma.md +33 -0
- package/src/dialect/gemma.ts +387 -0
- package/src/dialect/glm.md +32 -0
- package/src/dialect/glm.ts +579 -0
- package/src/dialect/harmony.md +31 -0
- package/src/dialect/harmony.ts +345 -0
- package/src/dialect/hermes.md +25 -0
- package/src/dialect/hermes.ts +206 -0
- package/src/dialect/history.ts +81 -0
- package/src/dialect/index.ts +15 -0
- package/src/dialect/inventory.ts +30 -0
- package/src/dialect/kimi.md +24 -0
- package/src/dialect/kimi.ts +340 -0
- package/src/dialect/minimax.md +31 -0
- package/src/dialect/minimax.ts +95 -0
- package/src/dialect/owned-stream.ts +481 -0
- package/src/dialect/prompt-template.md +12 -0
- package/src/dialect/qwen3.md +28 -0
- package/src/dialect/qwen3.ts +240 -0
- package/src/dialect/rendering.ts +304 -0
- package/src/dialect/thinking.ts +292 -0
- package/src/dialect/types.ts +56 -0
- package/src/dialect/xml.md +22 -0
- package/src/dialect/xml.ts +90 -0
- package/src/error/abort.ts +18 -0
- package/src/error/auth-classify.ts +47 -0
- package/src/error/auth.ts +48 -0
- package/src/error/aws.ts +35 -0
- package/src/error/classes.ts +281 -0
- package/src/error/finalize.ts +69 -0
- package/src/error/flags.ts +602 -0
- package/src/error/format.ts +45 -0
- package/src/error/gateway.ts +96 -0
- package/src/error/index.ts +14 -0
- package/src/error/oauth.ts +58 -0
- package/src/error/provider.ts +63 -0
- package/src/error/rate-limit.ts +303 -0
- package/src/error/retryable.ts +70 -0
- package/src/error/validation.ts +44 -0
- package/src/index.ts +51 -0
- package/src/provider-details.ts +90 -0
- package/src/providers/amazon-bedrock.ts +1064 -0
- package/src/providers/anthropic-client.ts +317 -0
- package/src/providers/anthropic-messages-server-schema.ts +252 -0
- package/src/providers/anthropic-messages-server.ts +818 -0
- package/src/providers/anthropic-wire.ts +359 -0
- package/src/providers/anthropic.ts +4539 -0
- package/src/providers/aws-credentials.ts +772 -0
- package/src/providers/aws-eventstream.ts +181 -0
- package/src/providers/aws-sigv4.ts +218 -0
- package/src/providers/azure-openai-responses.ts +438 -0
- package/src/providers/bedrock-mantle.ts +110 -0
- package/src/providers/claude-code-fingerprint.ts +20 -0
- package/src/providers/cowork-fetch.ts +201 -0
- package/src/providers/cursor/exec-modern.ts +496 -0
- package/src/providers/cursor/proto/agent.proto +4533 -0
- package/src/providers/cursor/proto/buf.gen.yaml +6 -0
- package/src/providers/cursor/proto/buf.yaml +17 -0
- package/src/providers/cursor-pi-args.ts +165 -0
- package/src/providers/cursor.ts +4689 -0
- package/src/providers/devin/proto/buf/validate/validate.proto +468 -0
- package/src/providers/devin/proto/buf.gen.yaml +33 -0
- package/src/providers/devin/proto/buf.yaml +17 -0
- package/src/providers/devin/proto/cel/expr/checked.proto +103 -0
- package/src/providers/devin/proto/cel/expr/eval.proto +38 -0
- package/src/providers/devin/proto/cel/expr/explain.proto +15 -0
- package/src/providers/devin/proto/cel/expr/syntax.proto +113 -0
- package/src/providers/devin/proto/cel/expr/value.proto +41 -0
- package/src/providers/devin/proto/connectext/grpc/status/v1/status.proto +11 -0
- package/src/providers/devin/proto/errorspb/errors.proto +56 -0
- package/src/providers/devin/proto/errorspb/hintdetail.proto +7 -0
- package/src/providers/devin/proto/errorspb/markers.proto +10 -0
- package/src/providers/devin/proto/errorspb/tags.proto +12 -0
- package/src/providers/devin/proto/errorspb/testing.proto +6 -0
- package/src/providers/devin/proto/exa/analytics_pb/analytics.proto +188 -0
- package/src/providers/devin/proto/exa/api_server_pb/api_server.proto +2461 -0
- package/src/providers/devin/proto/exa/auth_pb/auth.proto +19 -0
- package/src/providers/devin/proto/exa/auto_cascade_common_pb/auto_cascade_common.proto +79 -0
- package/src/providers/devin/proto/exa/browser_preview_pb/browser_preview.proto +32 -0
- package/src/providers/devin/proto/exa/bug_checker_pb/bug_checker.proto +22 -0
- package/src/providers/devin/proto/exa/cascade_plugins_pb/cascade_plugins.proto +262 -0
- package/src/providers/devin/proto/exa/chat_client_server_pb/chat_client_server.proto +57 -0
- package/src/providers/devin/proto/exa/chat_pb/chat.proto +449 -0
- package/src/providers/devin/proto/exa/code_edit/code_edit_pb/code_edit.proto +186 -0
- package/src/providers/devin/proto/exa/codeium_common_pb/codeium_common.proto +4157 -0
- package/src/providers/devin/proto/exa/context_module_pb/context_module.proto +175 -0
- package/src/providers/devin/proto/exa/cortex_pb/cortex.proto +3268 -0
- package/src/providers/devin/proto/exa/dev_pb/dev.proto +26 -0
- package/src/providers/devin/proto/exa/diff_action_pb/diff_action.proto +75 -0
- package/src/providers/devin/proto/exa/eval/pr_eval/datasets_pb/datasets.proto +103 -0
- package/src/providers/devin/proto/exa/eval_pb/eval.proto +1315 -0
- package/src/providers/devin/proto/exa/extension_server_pb/extension_server.proto +556 -0
- package/src/providers/devin/proto/exa/file_system_provider_pb/file_system_provider.proto +75 -0
- package/src/providers/devin/proto/exa/index_pb/index.proto +461 -0
- package/src/providers/devin/proto/exa/knowledge_base_pb/knowledge_base.proto +144 -0
- package/src/providers/devin/proto/exa/language_server_pb/language_server.proto +2385 -0
- package/src/providers/devin/proto/exa/model_management_pb/model_management.proto +186 -0
- package/src/providers/devin/proto/exa/opensearch_clients_pb/opensearch_clients.proto +503 -0
- package/src/providers/devin/proto/exa/product_analytics_pb/product_analytics.proto +37 -0
- package/src/providers/devin/proto/exa/prompt_pb/prompt.proto +92 -0
- package/src/providers/devin/proto/exa/reactive_component_pb/reactive_component.proto +96 -0
- package/src/providers/devin/proto/exa/seat_management_pb/seat_management.proto +2680 -0
- package/src/providers/devin/proto/exa/tokenizer_pb/tokenizer.proto +37 -0
- package/src/providers/devin/proto/exa/trainer_pb/config.proto +647 -0
- package/src/providers/devin/proto/exa/tree_sitter/language_data_pb/language_data.proto +14 -0
- package/src/providers/devin/proto/exa/trust_pb/trust.proto +157 -0
- package/src/providers/devin/proto/exa/user_analytics_pb/user_analytics.proto +519 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/base/api_base.proto +28 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/datastore/datastore_v3.proto +484 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/log/log_service.proto +136 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/remote_api/remote_api.proto +42 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +61 -0
- package/src/providers/devin/proto/grpc/binlog/v1/binarylog.proto +84 -0
- package/src/providers/devin/proto/io/prometheus/client/metrics.proto +98 -0
- package/src/providers/devin.ts +679 -0
- package/src/providers/error-message.ts +23 -0
- package/src/providers/github-copilot-headers.ts +141 -0
- package/src/providers/gitlab-duo-workflow-chatml-note.md +1 -0
- package/src/providers/gitlab-duo-workflow.ts +3135 -0
- package/src/providers/gitlab-duo.ts +399 -0
- package/src/providers/google-auth.ts +330 -0
- package/src/providers/google-gemini-cli.ts +1370 -0
- package/src/providers/google-shared.ts +1122 -0
- package/src/providers/google-types.ts +180 -0
- package/src/providers/google-vertex.ts +135 -0
- package/src/providers/google.ts +47 -0
- package/src/providers/grammar.ts +70 -0
- package/src/providers/kimi.ts +51 -0
- package/src/providers/mock.ts +514 -0
- package/src/providers/ollama.ts +776 -0
- package/src/providers/openai-anthropic-shim.ts +166 -0
- package/src/providers/openai-chat-server-schema.ts +243 -0
- package/src/providers/openai-chat-server.ts +752 -0
- package/src/providers/openai-chat-wire.ts +859 -0
- package/src/providers/openai-codex/request-transformer.ts +491 -0
- package/src/providers/openai-codex/response-handler.ts +102 -0
- package/src/providers/openai-codex-responses.ts +4716 -0
- package/src/providers/openai-completions.ts +2389 -0
- package/src/providers/openai-reasoning-fallback.ts +269 -0
- package/src/providers/openai-responses-server-schema.ts +397 -0
- package/src/providers/openai-responses-server.ts +1466 -0
- package/src/providers/openai-responses-wire.ts +6416 -0
- package/src/providers/openai-responses.ts +1393 -0
- package/src/providers/openai-shared.ts +3500 -0
- package/src/providers/pi-native-client.ts +275 -0
- package/src/providers/pi-native-server.ts +245 -0
- package/src/providers/register-builtins.ts +503 -0
- package/src/providers/synthetic.ts +50 -0
- package/src/providers/transform-messages.ts +1083 -0
- package/src/providers/vision-guard.ts +54 -0
- package/src/registry/aiand.ts +22 -0
- package/src/registry/aimlapi.ts +6 -0
- package/src/registry/alibaba-coding-plan.ts +104 -0
- package/src/registry/alibaba-token-plan.ts +125 -0
- package/src/registry/amazon-bedrock.ts +22 -0
- package/src/registry/anthropic.ts +26 -0
- package/src/registry/api-key-login.ts +115 -0
- package/src/registry/api-key-validation.ts +145 -0
- package/src/registry/aws.ts +57 -0
- package/src/registry/azure.ts +6 -0
- package/src/registry/baseten.ts +22 -0
- package/src/registry/bedrock-mantle.ts +34 -0
- package/src/registry/cerebras.ts +23 -0
- package/src/registry/cloudflare-ai-gateway.ts +45 -0
- package/src/registry/coreweave.ts +40 -0
- package/src/registry/cursor.ts +20 -0
- package/src/registry/deepseek.ts +46 -0
- package/src/registry/derived.ts +9 -0
- package/src/registry/devin.ts +15 -0
- package/src/registry/exa.ts +19 -0
- package/src/registry/firepass.ts +32 -0
- package/src/registry/fireworks.ts +28 -0
- package/src/registry/github-copilot.ts +22 -0
- package/src/registry/gitlab-duo-workflow.ts +20 -0
- package/src/registry/gitlab-duo.ts +19 -0
- package/src/registry/gmi-cloud.ts +22 -0
- package/src/registry/google-antigravity.ts +22 -0
- package/src/registry/google-gemini-cli.ts +22 -0
- package/src/registry/google-vertex.ts +38 -0
- package/src/registry/google.ts +6 -0
- package/src/registry/groq.ts +6 -0
- package/src/registry/huggingface.ts +29 -0
- package/src/registry/index.ts +4 -0
- package/src/registry/kagi.ts +46 -0
- package/src/registry/kilo.ts +114 -0
- package/src/registry/kimi-code.ts +17 -0
- package/src/registry/litellm.ts +45 -0
- package/src/registry/llama-cpp.ts +35 -0
- package/src/registry/lm-studio.ts +31 -0
- package/src/registry/meta.ts +22 -0
- package/src/registry/minimax-code-cn.ts +12 -0
- package/src/registry/minimax-code.ts +12 -0
- package/src/registry/minimax.ts +6 -0
- package/src/registry/mistral.ts +6 -0
- package/src/registry/moonshot.ts +28 -0
- package/src/registry/nanogpt.ts +22 -0
- package/src/registry/novita.ts +25 -0
- package/src/registry/nvidia.ts +61 -0
- package/src/registry/oauth/anthropic-constants.ts +12 -0
- package/src/registry/oauth/anthropic.ts +346 -0
- package/src/registry/oauth/callback-server.ts +438 -0
- package/src/registry/oauth/cursor.ts +187 -0
- package/src/registry/oauth/device-code.ts +92 -0
- package/src/registry/oauth/devin.ts +124 -0
- package/src/registry/oauth/github-copilot.ts +369 -0
- package/src/registry/oauth/gitlab-duo-workflow.ts +146 -0
- package/src/registry/oauth/gitlab-duo.ts +222 -0
- package/src/registry/oauth/google-antigravity.ts +225 -0
- package/src/registry/oauth/google-gemini-cli.ts +297 -0
- package/src/registry/oauth/google-oauth-shared.ts +211 -0
- package/src/registry/oauth/index.ts +187 -0
- package/src/registry/oauth/kimi.ts +297 -0
- package/src/registry/oauth/minimax-code.ts +53 -0
- package/src/registry/oauth/oauth.html +317 -0
- package/src/registry/oauth/openai-codex.ts +384 -0
- package/src/registry/oauth/opencode.ts +50 -0
- package/src/registry/oauth/perplexity.ts +228 -0
- package/src/registry/oauth/pkce.ts +18 -0
- package/src/registry/oauth/types.ts +96 -0
- package/src/registry/oauth/wafer.ts +24 -0
- package/src/registry/oauth/xai-oauth.ts +559 -0
- package/src/registry/oauth/xiaomi.ts +211 -0
- package/src/registry/oauth/zai.ts +285 -0
- package/src/registry/ollama-cloud.ts +36 -0
- package/src/registry/ollama.ts +43 -0
- package/src/registry/openai-codex-device.ts +18 -0
- package/src/registry/openai-codex.ts +19 -0
- package/src/registry/openai.ts +6 -0
- package/src/registry/opencode-go.ts +12 -0
- package/src/registry/opencode-zen.ts +12 -0
- package/src/registry/openrouter.ts +28 -0
- package/src/registry/parallel.ts +45 -0
- package/src/registry/perplexity.ts +13 -0
- package/src/registry/qianfan.ts +27 -0
- package/src/registry/qwen-portal.ts +50 -0
- package/src/registry/registry.ts +182 -0
- package/src/registry/sakana.ts +22 -0
- package/src/registry/siliconflow-cn.ts +22 -0
- package/src/registry/siliconflow.ts +22 -0
- package/src/registry/synthetic.ts +21 -0
- package/src/registry/tavily.ts +45 -0
- package/src/registry/together.ts +22 -0
- package/src/registry/types.ts +86 -0
- package/src/registry/umans.ts +23 -0
- package/src/registry/venice.ts +33 -0
- package/src/registry/vercel-ai-gateway.ts +38 -0
- package/src/registry/vllm.ts +34 -0
- package/src/registry/wafer-serverless.ts +12 -0
- package/src/registry/xai-oauth.ts +17 -0
- package/src/registry/xai.ts +22 -0
- package/src/registry/xiaomi-token-plan-ams.ts +12 -0
- package/src/registry/xiaomi-token-plan-cn.ts +12 -0
- package/src/registry/xiaomi-token-plan-sgp.ts +12 -0
- package/src/registry/xiaomi.ts +12 -0
- package/src/registry/zai.ts +41 -0
- package/src/registry/zenmux.ts +22 -0
- package/src/registry/zhipu-coding-plan.ts +27 -0
- package/src/stream.ts +1944 -0
- package/src/types.ts +1243 -0
- package/src/usage/alibaba-token-plan.ts +230 -0
- package/src/usage/claude.ts +830 -0
- package/src/usage/cursor.ts +335 -0
- package/src/usage/gemini.ts +258 -0
- package/src/usage/github-copilot.ts +424 -0
- package/src/usage/google-antigravity.ts +497 -0
- package/src/usage/kimi.ts +277 -0
- package/src/usage/minimax-code.ts +291 -0
- package/src/usage/ollama.ts +41 -0
- package/src/usage/openai-codex-base-url.ts +35 -0
- package/src/usage/openai-codex-reset.ts +205 -0
- package/src/usage/openai-codex.ts +627 -0
- package/src/usage/opencode-go.ts +89 -0
- package/src/usage/shared.ts +10 -0
- package/src/usage/synthetic.ts +180 -0
- package/src/usage/umans.ts +192 -0
- package/src/usage/xai-oauth.ts +414 -0
- package/src/usage/zai.ts +370 -0
- package/src/usage.ts +411 -0
- package/src/utils/abort.ts +67 -0
- package/src/utils/anthropic-auth.ts +93 -0
- package/src/utils/aws-profile.ts +88 -0
- package/src/utils/block-symbols.ts +78 -0
- package/src/utils/deterministic-id.ts +20 -0
- package/src/utils/empty-completion-retry.ts +161 -0
- package/src/utils/event-stream.ts +202 -0
- package/src/utils/foundry.ts +8 -0
- package/src/utils/google-validation.ts +25 -0
- package/src/utils/harmony-leak.ts +500 -0
- package/src/utils/http-inspector.ts +196 -0
- package/src/utils/idle-iterator.ts +531 -0
- package/src/utils/leaked-thinking-stream.ts +483 -0
- package/src/utils/openai-http.ts +119 -0
- package/src/utils/openrouter-headers.ts +12 -0
- package/src/utils/parse-bind.ts +56 -0
- package/src/utils/provider-response.ts +30 -0
- package/src/utils/proxy.ts +314 -0
- package/src/utils/request-debug.ts +351 -0
- package/src/utils/retry-after.ts +121 -0
- package/src/utils/retry.ts +77 -0
- package/src/utils/schema/CONSTRAINTS.md +168 -0
- package/src/utils/schema/adapt.ts +36 -0
- package/src/utils/schema/compatibility.ts +435 -0
- package/src/utils/schema/dereference.ts +98 -0
- package/src/utils/schema/draft.ts +341 -0
- package/src/utils/schema/equality.ts +97 -0
- package/src/utils/schema/fields.ts +210 -0
- package/src/utils/schema/index.ts +14 -0
- package/src/utils/schema/json-schema-validator.ts +595 -0
- package/src/utils/schema/meta-validator.ts +167 -0
- package/src/utils/schema/normalize.ts +2314 -0
- package/src/utils/schema/spill.ts +43 -0
- package/src/utils/schema/stamps.ts +109 -0
- package/src/utils/schema/strict-tool-validation.ts +117 -0
- package/src/utils/schema/types.ts +10 -0
- package/src/utils/schema/typescript.ts +212 -0
- package/src/utils/schema/wire.ts +662 -0
- package/src/utils/sdk-stream-timeout.ts +43 -0
- package/src/utils/sse-debug.ts +18 -0
- package/src/utils/stream-markup-healing.ts +247 -0
- package/src/utils/thinking-loop.ts +552 -0
- package/src/utils/tool-call-loop-guard.ts +107 -0
- package/src/utils/tool-choice.ts +101 -0
- package/src/utils/validation.ts +1932 -0
- package/src/utils.ts +492 -0
|
@@ -0,0 +1,1064 @@
|
|
|
1
|
+
export * from "@linxiraos/pi-catalog/effort";
|
|
2
|
+
export * from "@linxiraos/pi-catalog/types";
|
|
3
|
+
import type { DeleteArgs, DeleteResult, DiagnosticsArgs, DiagnosticsResult, GrepArgs, GrepResult, LsArgs, LsResult, McpResult, PiBashExecArgs, PiBashExecResult, PiEditExecArgs, PiEditExecResult, PiFindExecArgs, PiFindExecResult, PiGrepExecArgs, PiGrepExecResult, PiLsExecArgs, PiLsExecResult, PiReadExecArgs, PiReadExecResult, PiWriteExecArgs, PiWriteExecResult, ReadArgs, ReadResult, ShellArgs, ShellResult, WriteArgs, WriteResult } from "@linxiraos/pi-catalog/discovery/cursor-gen/agent_pb";
|
|
4
|
+
import type { Effort } from "@linxiraos/pi-catalog/effort";
|
|
5
|
+
import type { Api, FetchImpl, Model, Provider, ThinkingBudgets, Usage } from "@linxiraos/pi-catalog/types";
|
|
6
|
+
import type { Type } from "@linxiraos/pi-omptype";
|
|
7
|
+
import type { ApiKey } from "./auth-retry.js";
|
|
8
|
+
import type { BedrockOptions } from "./providers/amazon-bedrock.js";
|
|
9
|
+
import type { AnthropicOptions } from "./providers/anthropic.js";
|
|
10
|
+
import type { FallbackParam, StopDetails } from "./providers/anthropic-wire.js";
|
|
11
|
+
import type { AzureOpenAIResponsesOptions } from "./providers/azure-openai-responses.js";
|
|
12
|
+
import type { CursorOptions } from "./providers/cursor.js";
|
|
13
|
+
import type { DevinOptions } from "./providers/devin.js";
|
|
14
|
+
import type { GitLabDuoWorkflowOptions } from "./providers/gitlab-duo-workflow.js";
|
|
15
|
+
import type { GoogleOptions } from "./providers/google.js";
|
|
16
|
+
import type { GoogleGeminiCliOptions } from "./providers/google-gemini-cli.js";
|
|
17
|
+
import type { GoogleVertexOptions } from "./providers/google-vertex.js";
|
|
18
|
+
import type { OllamaChatOptions } from "./providers/ollama.js";
|
|
19
|
+
import type { OpenAICodexResponsesOptions } from "./providers/openai-codex-responses.js";
|
|
20
|
+
import type { OpenAICompletionsOptions } from "./providers/openai-completions.js";
|
|
21
|
+
import type { OpenAIResponsesOptions } from "./providers/openai-responses.js";
|
|
22
|
+
import type { kStreamingPartialJson } from "./utils/block-symbols.js";
|
|
23
|
+
import type { AssistantMessageEventStream } from "./utils/event-stream.js";
|
|
24
|
+
export type { StopDetails } from "./providers/anthropic-wire.js";
|
|
25
|
+
export type { AssistantMessageEventStream } from "./utils/event-stream.js";
|
|
26
|
+
/**
|
|
27
|
+
* Ceiling on the output-token count omp requests from any OpenAI-family endpoint
|
|
28
|
+
* (openai-responses, azure/xai responses, and openai-completions). Mirrors
|
|
29
|
+
* Anthropic's {@link CLAUDE_CODE_MAX_OUTPUT_TOKENS}.
|
|
30
|
+
*
|
|
31
|
+
* Catalog `maxTokens` frequently reflects a model's context window rather than a
|
|
32
|
+
* given upstream's real per-request output cap. OpenRouter, for instance,
|
|
33
|
+
* advertises 131072 output tokens for `z-ai/glm-4.7`, but the Cerebras upstream
|
|
34
|
+
* only allows ~131072 tokens total — so requesting the full ceiling overflows
|
|
35
|
+
* with a 400. Requested output is clamped to this value (and to `model.maxTokens`).
|
|
36
|
+
*/
|
|
37
|
+
export declare const OPENAI_MAX_OUTPUT_TOKENS = 64000;
|
|
38
|
+
export interface ApiOptionsMap {
|
|
39
|
+
"anthropic-messages": AnthropicOptions;
|
|
40
|
+
"bedrock-converse-stream": BedrockOptions;
|
|
41
|
+
"openai-completions": OpenAICompletionsOptions;
|
|
42
|
+
"openai-responses": OpenAIResponsesOptions;
|
|
43
|
+
openrouter: OpenAIResponsesOptions | OpenAICompletionsOptions;
|
|
44
|
+
"openai-codex-responses": OpenAICodexResponsesOptions;
|
|
45
|
+
"azure-openai-responses": AzureOpenAIResponsesOptions;
|
|
46
|
+
"google-generative-ai": GoogleOptions;
|
|
47
|
+
"google-gemini-cli": GoogleGeminiCliOptions;
|
|
48
|
+
"google-vertex": GoogleVertexOptions;
|
|
49
|
+
"ollama-chat": OllamaChatOptions;
|
|
50
|
+
"cursor-agent": CursorOptions;
|
|
51
|
+
"gitlab-duo-agent": GitLabDuoWorkflowOptions;
|
|
52
|
+
"devin-agent": DevinOptions;
|
|
53
|
+
}
|
|
54
|
+
export type OptionsForApi<TApi extends Api> = StreamOptions | (TApi extends keyof ApiOptionsMap ? ApiOptionsMap[TApi] : never);
|
|
55
|
+
export interface TokenTaskBudget {
|
|
56
|
+
type: "tokens";
|
|
57
|
+
total: number;
|
|
58
|
+
remaining?: number;
|
|
59
|
+
}
|
|
60
|
+
export type MessageAttribution = "user" | "agent";
|
|
61
|
+
export type NativeToolMarker = {
|
|
62
|
+
type: "computer";
|
|
63
|
+
};
|
|
64
|
+
export type ToolChoice = "auto" | "none" | "any" | "required" | {
|
|
65
|
+
type: "function";
|
|
66
|
+
name: string;
|
|
67
|
+
} | {
|
|
68
|
+
type: "function";
|
|
69
|
+
function: {
|
|
70
|
+
name: string;
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
type: "tool";
|
|
74
|
+
name: string;
|
|
75
|
+
} | {
|
|
76
|
+
type: "computer";
|
|
77
|
+
};
|
|
78
|
+
export type CacheRetention = "none" | "short" | "long";
|
|
79
|
+
/**
|
|
80
|
+
* Service tier hint for processing priority / cost control. These are the
|
|
81
|
+
* values providers consume on the wire:
|
|
82
|
+
*
|
|
83
|
+
* - OpenAI / OpenAI-Codex: sent verbatim as the `service_tier` field
|
|
84
|
+
* (`flex`/`scale`/`priority`).
|
|
85
|
+
* - Google (Gemini API + Vertex AI): sent as the top-level `serviceTier`
|
|
86
|
+
* field (`flex`/`priority`).
|
|
87
|
+
* - OpenRouter: passed through as `service_tier`; OpenRouter realizes it for
|
|
88
|
+
* the OpenAI- and Google-family upstreams it supports and ignores it
|
|
89
|
+
* otherwise.
|
|
90
|
+
* - Direct Anthropic: `"priority"` is translated into `speed: "fast"` plus the
|
|
91
|
+
* fast-mode beta on supported Opus models. Other tiers are ignored.
|
|
92
|
+
*
|
|
93
|
+
* Per-family scoping is expressed by {@link ServiceTierByFamily}, not by
|
|
94
|
+
* scoped sentinel values — see {@link serviceTierFamily}.
|
|
95
|
+
*/
|
|
96
|
+
export type ServiceTier = "auto" | "default" | "flex" | "scale" | "priority";
|
|
97
|
+
/** Provider families that expose an independent service-tier knob. */
|
|
98
|
+
export type ServiceTierFamily = "openai" | "anthropic" | "google";
|
|
99
|
+
/**
|
|
100
|
+
* Per-family service-tier selection. A request consults only the entry for the
|
|
101
|
+
* family its model belongs to (see {@link resolveModelServiceTier}), so a user
|
|
102
|
+
* can opt one family into priority without affecting the others when switching
|
|
103
|
+
* models mid-session.
|
|
104
|
+
*/
|
|
105
|
+
export type ServiceTierByFamily = Partial<Record<ServiceTierFamily, ServiceTier>>;
|
|
106
|
+
type ServiceTierModel = Pick<Model, "provider" | "api" | "id">;
|
|
107
|
+
/**
|
|
108
|
+
* Classify a model into the service-tier family whose knob governs it, or
|
|
109
|
+
* `undefined` when the model exposes no serving-priority control.
|
|
110
|
+
*
|
|
111
|
+
* OpenRouter models are classified by id namespace (`anthropic/`, `google/`,
|
|
112
|
+
* `openai/`); Claude on Bedrock/Vertex (api `anthropic-messages`) is the
|
|
113
|
+
* anthropic family even though its provider is `amazon-bedrock`/`google-vertex`.
|
|
114
|
+
* Custom OpenAI-compatible relays that serve OpenAI model ids are OpenAI family
|
|
115
|
+
* too unless the provider owns a separate tier control (Fireworks) or rejects
|
|
116
|
+
* OpenAI's service-tier field (GitHub Copilot).
|
|
117
|
+
*/
|
|
118
|
+
export declare function serviceTierFamily(model: ServiceTierModel): ServiceTierFamily | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Reduce a per-family tier map to the single wire tier for `model` — the entry
|
|
121
|
+
* for the model's family, or `undefined` when the model has no family.
|
|
122
|
+
*/
|
|
123
|
+
export declare function resolveModelServiceTier(tiers: ServiceTierByFamily | null | undefined, model: Pick<Model, "provider" | "api" | "id">): ServiceTier | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* True when the tier should be sent on the wire as the provider's service-tier
|
|
126
|
+
* request field. `auto` is never forwarded — it is OpenAI's implicit default, so
|
|
127
|
+
* omitting `service_tier` is identical to requesting `auto`, and the Codex
|
|
128
|
+
* (ChatGPT OAuth) endpoint rejects an explicit `auto` outright. OpenAI /
|
|
129
|
+
* OpenAI-Codex accept every other {@link ServiceTier}; Google (Gemini API +
|
|
130
|
+
* Vertex) and OpenRouter accept `flex`/`priority`; Fireworks Serverless
|
|
131
|
+
* realizes only its Priority serving path. Anthropic is absent because it
|
|
132
|
+
* realizes `priority` via `speed: "fast"`.
|
|
133
|
+
*/
|
|
134
|
+
export declare function shouldSendServiceTier(serviceTier: ServiceTier | null | undefined, target: Provider | ServiceTierModel | undefined): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* True when `priority` will actually be realized on the wire for `model`.
|
|
137
|
+
* Direct Anthropic realizes fast mode; OpenAI/Google/Fireworks emit the
|
|
138
|
+
* service-tier field; OpenRouter realizes it only for its OpenAI- and
|
|
139
|
+
* Google-family upstreams. Bedrock/Vertex Claude and OpenRouter Anthropic
|
|
140
|
+
* models do not realize priority and return `false`.
|
|
141
|
+
*/
|
|
142
|
+
export declare function realizesPriorityServiceTier(serviceTier: ServiceTier | null | undefined, model: Pick<Model, "provider" | "api" | "id">): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Premium-request weight contributed by a priority request to a provider that
|
|
145
|
+
* realizes it and bills extra. Mirrors GitHub Copilot's `premiumRequests`
|
|
146
|
+
* accounting so the "premium requests" stat aggregates priority traffic across
|
|
147
|
+
* the OpenAI family, direct Anthropic fast mode, and Google priority.
|
|
148
|
+
*
|
|
149
|
+
* Returns 1 only when priority is actually realized on the wire for `model`
|
|
150
|
+
* (see {@link realizesPriorityServiceTier}) and the provider bills it as a
|
|
151
|
+
* premium request. OpenRouter is excluded — it bills per its own pricing, not
|
|
152
|
+
* Copilot-premium semantics — as are Bedrock/Vertex Claude, where priority is
|
|
153
|
+
* silently dropped.
|
|
154
|
+
*/
|
|
155
|
+
export declare function getPriorityPremiumRequests(serviceTier: ServiceTier | null | undefined, model: Pick<Model, "provider" | "api" | "id">): number;
|
|
156
|
+
/**
|
|
157
|
+
* Coerce a persisted service-tier value to a {@link ServiceTierByFamily}. Newer
|
|
158
|
+
* sessions store the family map directly; legacy sessions stored a single
|
|
159
|
+
* scalar — `"priority"` applied everywhere, `"openai-only"`/`"claude-only"`
|
|
160
|
+
* scoped to one family, and the remaining values were OpenAI-only semantics.
|
|
161
|
+
*/
|
|
162
|
+
export declare function coerceServiceTierByFamily(value: unknown): ServiceTierByFamily | undefined;
|
|
163
|
+
export interface ProviderSessionState {
|
|
164
|
+
close(): void;
|
|
165
|
+
}
|
|
166
|
+
export interface ProviderResponseMetadata {
|
|
167
|
+
status: number;
|
|
168
|
+
headers: Record<string, string>;
|
|
169
|
+
requestId?: string | null;
|
|
170
|
+
metadata?: Record<string, unknown>;
|
|
171
|
+
}
|
|
172
|
+
export interface RawSseEvent {
|
|
173
|
+
event: string | null;
|
|
174
|
+
data: string;
|
|
175
|
+
raw: string[];
|
|
176
|
+
}
|
|
177
|
+
/** Lifecycle fields shared by every Codex compaction implementation. */
|
|
178
|
+
export interface CodexCompactionContext {
|
|
179
|
+
/** Stable only for one logical compaction, including parallel summary calls. */
|
|
180
|
+
operationId: string;
|
|
181
|
+
trigger: "manual" | "auto";
|
|
182
|
+
reason: "user_requested" | "context_limit" | "model_downshift" | "comp_hash_changed";
|
|
183
|
+
phase: "standalone_turn" | "pre_turn" | "mid_turn";
|
|
184
|
+
strategy: "memento" | "prefix_compaction";
|
|
185
|
+
}
|
|
186
|
+
/** Canonical nested metadata serialized into the Codex turn envelope. */
|
|
187
|
+
export interface CodexCompactionMetadata {
|
|
188
|
+
trigger: "manual" | "auto";
|
|
189
|
+
reason: "user_requested" | "context_limit" | "model_downshift" | "comp_hash_changed";
|
|
190
|
+
implementation: "responses" | "responses_compaction_v2" | "responses_compact";
|
|
191
|
+
phase: "standalone_turn" | "pre_turn" | "mid_turn";
|
|
192
|
+
strategy: "memento" | "prefix_compaction";
|
|
193
|
+
}
|
|
194
|
+
/** Dispatch context combining canonical metadata with its local operation identity. */
|
|
195
|
+
export interface CodexCompactionRequestContext extends CodexCompactionMetadata {
|
|
196
|
+
operationId: string;
|
|
197
|
+
}
|
|
198
|
+
/** OpenAI's GPT-5.6+ explicit prompt-cache controls. */
|
|
199
|
+
export interface OpenAIPromptCacheOptions {
|
|
200
|
+
/** `explicit` disables OpenAI's automatic latest-message breakpoint. */
|
|
201
|
+
mode: "implicit" | "explicit";
|
|
202
|
+
/** The only currently supported minimum breakpoint lifetime. */
|
|
203
|
+
ttl?: "30m";
|
|
204
|
+
/** By default, mark one existing block from stable history; `none` suppresses that marker. */
|
|
205
|
+
breakpoint?: "latest-stable-message" | "none";
|
|
206
|
+
}
|
|
207
|
+
export type OpenAIResponseInclude = "file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs";
|
|
208
|
+
export interface StreamOptions {
|
|
209
|
+
temperature?: number;
|
|
210
|
+
topP?: number;
|
|
211
|
+
topK?: number;
|
|
212
|
+
minP?: number;
|
|
213
|
+
presencePenalty?: number;
|
|
214
|
+
repetitionPenalty?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Stop sequences. Anthropic encodes as `stop_sequences` (array, max 4);
|
|
217
|
+
* OpenAI chat-completions encodes as `stop` (string or array of up to 4);
|
|
218
|
+
* OpenAI Responses API has no `stop` field today (silently dropped by the
|
|
219
|
+
* provider when present).
|
|
220
|
+
*/
|
|
221
|
+
stopSequences?: string[];
|
|
222
|
+
/**
|
|
223
|
+
* Frequency penalty (OpenAI). Penalizes new tokens based on existing frequency
|
|
224
|
+
* in the text so far. Range -2.0 to 2.0. Parallel to {@link presencePenalty}.
|
|
225
|
+
*/
|
|
226
|
+
frequencyPenalty?: number;
|
|
227
|
+
maxTokens?: number;
|
|
228
|
+
signal?: AbortSignal;
|
|
229
|
+
apiKey?: string;
|
|
230
|
+
cacheRetention?: CacheRetention;
|
|
231
|
+
/**
|
|
232
|
+
* Additional headers to include in provider requests.
|
|
233
|
+
* These are merged on top of model-defined headers.
|
|
234
|
+
*/
|
|
235
|
+
headers?: Record<string, string>;
|
|
236
|
+
/**
|
|
237
|
+
* Optional explicit request attribution override for providers that support it.
|
|
238
|
+
*/
|
|
239
|
+
initiatorOverride?: MessageAttribution;
|
|
240
|
+
/**
|
|
241
|
+
* Maximum delay in milliseconds to wait for a retry when the server requests a long wait.
|
|
242
|
+
* If the server's requested delay exceeds this value, the request fails immediately
|
|
243
|
+
* with an error containing the requested delay, allowing higher-level retry logic
|
|
244
|
+
* to handle it with user visibility.
|
|
245
|
+
* Default: 60000 (60 seconds). Set to 0 to disable the cap.
|
|
246
|
+
*/
|
|
247
|
+
maxRetryDelayMs?: number;
|
|
248
|
+
/**
|
|
249
|
+
* Optional metadata to include in API requests.
|
|
250
|
+
* Providers extract the fields they understand and ignore the rest.
|
|
251
|
+
* For example, Anthropic uses `user_id` for abuse tracking and rate limiting.
|
|
252
|
+
*/
|
|
253
|
+
metadata?: Record<string, unknown>;
|
|
254
|
+
/**
|
|
255
|
+
* Provider-owned request configuration. Provider hooks interpret this bag;
|
|
256
|
+
* generic API transports do not forward its fields onto the wire.
|
|
257
|
+
*/
|
|
258
|
+
providerOptions?: Readonly<Record<string, unknown>>;
|
|
259
|
+
/** OpenAI Responses/Codex response fields to include verbatim. */
|
|
260
|
+
include?: OpenAIResponseInclude[];
|
|
261
|
+
/**
|
|
262
|
+
* Config options for the thinking/response loop guard.
|
|
263
|
+
*/
|
|
264
|
+
loopGuard?: {
|
|
265
|
+
enabled?: boolean;
|
|
266
|
+
checkAssistantContent?: boolean;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Advisory token budget for a full agentic loop. Anthropic encodes this as
|
|
270
|
+
* `output_config.task_budget` with the `task-budgets-2026-03-13` beta header.
|
|
271
|
+
*/
|
|
272
|
+
taskBudget?: TokenTaskBudget;
|
|
273
|
+
/**
|
|
274
|
+
* Optional session identifier for providers that support session-based
|
|
275
|
+
* routing, request affinity, or transport reuse. Providers may also use this
|
|
276
|
+
* as the prompt-cache key when `promptCacheKey` is not set.
|
|
277
|
+
*/
|
|
278
|
+
sessionId?: string;
|
|
279
|
+
/**
|
|
280
|
+
* Optional prompt-cache identity. OpenAI-family providers use this for
|
|
281
|
+
* `prompt_cache_key` payloads and cache-affinity headers such as
|
|
282
|
+
* `x-grok-conv-id`; when omitted, they fall back to `sessionId`.
|
|
283
|
+
*/
|
|
284
|
+
promptCacheKey?: string;
|
|
285
|
+
/**
|
|
286
|
+
* OpenAI GPT-5.6+ prompt-cache policy. Ignored by providers that do not
|
|
287
|
+
* support explicit OpenAI cache breakpoints; explicit mode fails locally on
|
|
288
|
+
* incompatible OpenAI-compatible endpoints.
|
|
289
|
+
*/
|
|
290
|
+
promptCache?: OpenAIPromptCacheOptions;
|
|
291
|
+
/**
|
|
292
|
+
* Disable OpenAI Responses server-side turn chaining for this request.
|
|
293
|
+
* Diagnostic callers that compare independent requests can set this to
|
|
294
|
+
* `false` so `previous_response_id` cannot explain a result.
|
|
295
|
+
*/
|
|
296
|
+
statefulResponses?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Provider-scoped mutable state store for this agent session.
|
|
299
|
+
* Providers can use this to persist transport/session state between turns.
|
|
300
|
+
*/
|
|
301
|
+
providerSessionState?: Map<string, ProviderSessionState>;
|
|
302
|
+
/** Canonical Codex compaction classification; ignored by other providers. */
|
|
303
|
+
codexCompaction?: CodexCompactionRequestContext;
|
|
304
|
+
/**
|
|
305
|
+
* Optional per-provider concurrent request cap for LLM stream calls. Keys are
|
|
306
|
+
* provider ids (`model.provider`); positive numeric values cap in-flight
|
|
307
|
+
* requests across local OMP processes that share the same config root. Omitted
|
|
308
|
+
* providers are unlimited. Non-chat provider APIs that bypass stream helpers
|
|
309
|
+
* are not covered.
|
|
310
|
+
*/
|
|
311
|
+
maxInFlightRequests?: Record<string, number>;
|
|
312
|
+
/**
|
|
313
|
+
* Optional callback for inspecting or replacing provider payloads before sending.
|
|
314
|
+
* Return undefined to keep the payload unchanged.
|
|
315
|
+
*/
|
|
316
|
+
onPayload?: (payload: unknown, model?: Model<Api>) => unknown | undefined | Promise<unknown | undefined>;
|
|
317
|
+
/**
|
|
318
|
+
* Optional callback for provider response metadata after headers are received.
|
|
319
|
+
*/
|
|
320
|
+
onResponse?: (response: ProviderResponseMetadata, model?: Model<Api>) => void | Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Optional callback for raw Server-Sent Events as they arrive from HTTP streaming providers,
|
|
323
|
+
* plus synthesized SSE-shaped frames for the Codex WebSocket transport (one synthetic frame
|
|
324
|
+
* per JSON request/response message). WebSocket frames are tagged with a leading
|
|
325
|
+
* `: ws → <type>` (outbound) or `: ws ← <type>` (inbound) comment line in `RawSseEvent.raw`.
|
|
326
|
+
*
|
|
327
|
+
* Diagnostic only: provider implementations must ignore callback failures and must not
|
|
328
|
+
* let observers alter stream contents.
|
|
329
|
+
*/
|
|
330
|
+
onSseEvent?: (event: RawSseEvent, model?: Model<Api>) => void;
|
|
331
|
+
/**
|
|
332
|
+
* Optional override for the first-event watchdog in milliseconds. Built-in
|
|
333
|
+
* providers apply this budget twice when they can: once to the underlying
|
|
334
|
+
* SDK/request while waiting for the HTTP stream object to exist, then again
|
|
335
|
+
* in the iterator while waiting for the first semantic stream event. Set to
|
|
336
|
+
* `0` to disable both layers for this request. After the first semantic
|
|
337
|
+
* event arrives, `streamIdleTimeoutMs` governs inter-event stalls. Falls
|
|
338
|
+
* back to `PI_STREAM_FIRST_EVENT_TIMEOUT_MS` and then to a 100s default.
|
|
339
|
+
* OpenAI-family transports additionally honor
|
|
340
|
+
* `PI_OPENAI_STREAM_FIRST_EVENT_TIMEOUT_MS` as the most-specific override and
|
|
341
|
+
* floor the first-event budget at the resolved idle (per-call
|
|
342
|
+
* `streamIdleTimeoutMs` or `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS`) so slow local
|
|
343
|
+
* OpenAI-compatible servers are not undercut during prompt processing.
|
|
344
|
+
*
|
|
345
|
+
* Iterator-level honored by: every built-in provider (via the lazy-stream
|
|
346
|
+
* forwarder in `register-builtins`). SDK-request honored by:
|
|
347
|
+
* `openai-completions`, `openai-responses`, `azure-openai-responses`,
|
|
348
|
+
* `anthropic-messages`.
|
|
349
|
+
*/
|
|
350
|
+
streamFirstEventTimeoutMs?: number;
|
|
351
|
+
/**
|
|
352
|
+
* Optional override for the maximum idle gap between streamed events in
|
|
353
|
+
* milliseconds. Once the first event arrives, this guards against silent
|
|
354
|
+
* mid-stream stalls (broker dies, half-open socket, model produces no real
|
|
355
|
+
* progress for too long). Set to `0` to disable. Falls back to
|
|
356
|
+
* `PI_STREAM_IDLE_TIMEOUT_MS` (alias: `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS`)
|
|
357
|
+
* and then to a 120s default.
|
|
358
|
+
*/
|
|
359
|
+
streamIdleTimeoutMs?: number;
|
|
360
|
+
/**
|
|
361
|
+
* Optional cap on Codex SSE pre-response attempts, including the initial
|
|
362
|
+
* request. WebSocket retries and outer agent retries have separate budgets.
|
|
363
|
+
* Finite values below `1` and non-finite values are clamped to one request;
|
|
364
|
+
* omission preserves the provider default.
|
|
365
|
+
*/
|
|
366
|
+
codexSseMaxAttempts?: number;
|
|
367
|
+
/**
|
|
368
|
+
* Optional retry delay hook for tests and transports that need custom scheduling.
|
|
369
|
+
*/
|
|
370
|
+
providerRetryWait?: (delayMs: number, signal?: AbortSignal) => Promise<void>;
|
|
371
|
+
/**
|
|
372
|
+
* Optional `fetch` implementation override. Providers route every HTTP
|
|
373
|
+
* request — direct calls, SDK clients, and retry helpers — through this
|
|
374
|
+
* implementation when set. Defaults to `globalThis.fetch`. Providers that
|
|
375
|
+
* do not use `fetch` (Bedrock's AWS SDK transport, Cursor's HTTP/2
|
|
376
|
+
* channel) silently ignore the override.
|
|
377
|
+
*/
|
|
378
|
+
fetch?: FetchImpl;
|
|
379
|
+
/** Current session working directory for providers that need workspace-scoped discovery. */
|
|
380
|
+
cwd?: string;
|
|
381
|
+
/** Cursor exec/MCP tool handlers (cursor-agent only). */
|
|
382
|
+
execHandlers?: CursorExecHandlers;
|
|
383
|
+
}
|
|
384
|
+
export interface SimpleStreamOptions extends Omit<StreamOptions, "apiKey"> {
|
|
385
|
+
/**
|
|
386
|
+
* API key for the request: either a static bearer string, or an
|
|
387
|
+
* {@link ApiKeyResolver} that mints/rotates the key across the central
|
|
388
|
+
* a/b/c auth-retry policy. `streamSimple`/`completeSimple` resolve a
|
|
389
|
+
* resolver to a string before per-provider dispatch, so providers only
|
|
390
|
+
* ever see the resolved {@link StreamOptions.apiKey} string.
|
|
391
|
+
*/
|
|
392
|
+
apiKey?: ApiKey;
|
|
393
|
+
reasoning?: Effort;
|
|
394
|
+
/**
|
|
395
|
+
* Force-disable reasoning for the request even when the model supports it.
|
|
396
|
+
* Takes precedence over `reasoning`. Useful for fast utility calls
|
|
397
|
+
* (e.g. title generation) where the model would otherwise burn the entire
|
|
398
|
+
* output budget on internal thinking. Provider support is format-specific:
|
|
399
|
+
* some transports can disable reasoning directly, while generic
|
|
400
|
+
* effort-based OpenAI-compatible endpoints use the lowest supported effort.
|
|
401
|
+
*/
|
|
402
|
+
disableReasoning?: boolean;
|
|
403
|
+
/**
|
|
404
|
+
* If true, request that the provider omit thinking/reasoning summaries
|
|
405
|
+
* from the response (e.g. Anthropic `thinking.display = "omitted"`,
|
|
406
|
+
* OpenAI Responses `reasoning.summary` left unset). The model still
|
|
407
|
+
* reasons internally; only the human-readable summary stream is dropped.
|
|
408
|
+
* Useful when the UI hides thinking blocks anyway and the summary is wasted bandwidth.
|
|
409
|
+
*/
|
|
410
|
+
hideThinkingSummary?: boolean;
|
|
411
|
+
/** OpenAI Responses/Codex `text.verbosity` response detail level. */
|
|
412
|
+
textVerbosity?: "low" | "medium" | "high";
|
|
413
|
+
/** Custom token budgets for thinking levels (token-based providers only) */
|
|
414
|
+
thinkingBudgets?: ThinkingBudgets;
|
|
415
|
+
/** Cursor exec handlers for local tool execution */
|
|
416
|
+
cursorExecHandlers?: CursorExecHandlers;
|
|
417
|
+
/**
|
|
418
|
+
* Optional rewrite of Cursor exec-channel tool results. May return a Promise.
|
|
419
|
+
*
|
|
420
|
+
* The Agent reserves the original result in its buffer before awaiting this
|
|
421
|
+
* hook, and the `message_end` drain waits for a still-pending rewrite, so an
|
|
422
|
+
* async transformer is honored even when the turn closes in the same chunk.
|
|
423
|
+
* A rejecting transformer is swallowed and the reserved payload stands in.
|
|
424
|
+
*/
|
|
425
|
+
cursorOnToolResult?: CursorToolResultHandler;
|
|
426
|
+
/** Optional tool choice override for compatible providers */
|
|
427
|
+
toolChoice?: ToolChoice;
|
|
428
|
+
/** OpenAI service tier for processing priority/cost control. Ignored by non-OpenAI providers. */
|
|
429
|
+
serviceTier?: ServiceTier;
|
|
430
|
+
/** Explicit Kimi Code API format override; omitted uses live per-model protocol metadata. */
|
|
431
|
+
kimiApiFormat?: "openai" | "anthropic";
|
|
432
|
+
/** API format for Synthetic provider: "openai" or "anthropic" (default: "openai") */
|
|
433
|
+
syntheticApiFormat?: "openai" | "anthropic";
|
|
434
|
+
/** Hint that websocket transport should be preferred when supported by the provider implementation. */
|
|
435
|
+
preferWebsockets?: boolean;
|
|
436
|
+
/**
|
|
437
|
+
* OpenRouter routing-variant suffix automatically appended to model IDs when
|
|
438
|
+
* the request targets OpenRouter (`model.provider === "openrouter"`). Common
|
|
439
|
+
* values: `"nitro"` (throughput), `"floor"` (cheapest), `"online"` (web
|
|
440
|
+
* search plugin), `"exacto"` (cherry-picked high-quality providers, only
|
|
441
|
+
* defined for some models). Ignored when the resolved model id already
|
|
442
|
+
* contains a `:<variant>` suffix (e.g. the user typed `:nitro` explicitly
|
|
443
|
+
* or the catalog entry already names the variant).
|
|
444
|
+
*/
|
|
445
|
+
openrouterVariant?: string;
|
|
446
|
+
/**
|
|
447
|
+
* Caller-owned Google context-cache resource name. Forwarded only to the
|
|
448
|
+
* direct Gemini GenerateContent and Vertex GenerateContent APIs; all other
|
|
449
|
+
* providers ignore it. Callers own the cache lifecycle and compatibility.
|
|
450
|
+
*/
|
|
451
|
+
cachedContent?: string;
|
|
452
|
+
/** Antigravity endpoint routing mode: "auto" (default with failover), "production", "sandbox". */
|
|
453
|
+
antigravityEndpointMode?: "auto" | "production" | "sandbox";
|
|
454
|
+
/**
|
|
455
|
+
* Anthropic `server-side-fallback-2026-06-01` fallback chain (top-level
|
|
456
|
+
* `fallbacks` request field). Opt-in ONLY — leaving this undefined is
|
|
457
|
+
* the default and preserves the pre-fallback behavior on every
|
|
458
|
+
* provider. Non-Anthropic providers ignore the field.
|
|
459
|
+
*/
|
|
460
|
+
fallbacks?: FallbackParam[];
|
|
461
|
+
}
|
|
462
|
+
export type StreamFunction<TApi extends Api> = (model: Model<TApi>, context: Context, options: OptionsForApi<TApi>) => AssistantMessageEventStream;
|
|
463
|
+
export interface TextSignatureV1 {
|
|
464
|
+
v: 1;
|
|
465
|
+
id: string;
|
|
466
|
+
phase?: "commentary" | "final_answer";
|
|
467
|
+
}
|
|
468
|
+
export interface TextContent {
|
|
469
|
+
type: "text";
|
|
470
|
+
text: string;
|
|
471
|
+
textSignature?: string;
|
|
472
|
+
}
|
|
473
|
+
export interface ThinkingContent {
|
|
474
|
+
type: "thinking";
|
|
475
|
+
thinking: string;
|
|
476
|
+
thinkingSignature?: string;
|
|
477
|
+
itemId?: string;
|
|
478
|
+
}
|
|
479
|
+
export interface RedactedThinkingContent {
|
|
480
|
+
type: "redactedThinking";
|
|
481
|
+
data: string;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Anthropic server-side-fallback boundary marker persisted on assistant
|
|
485
|
+
* turns whose provider request opted into
|
|
486
|
+
* `AnthropicOptions.fallbacks`. Consumers other than the Anthropic
|
|
487
|
+
* provider MUST ignore it — `transformMessages` strips the block on any
|
|
488
|
+
* cross-provider hop and on non-official Anthropic replays, so downstream
|
|
489
|
+
* converters never see it.
|
|
490
|
+
*/
|
|
491
|
+
export interface AnthropicFallbackContent {
|
|
492
|
+
type: "fallback";
|
|
493
|
+
from: {
|
|
494
|
+
model: string;
|
|
495
|
+
};
|
|
496
|
+
to: {
|
|
497
|
+
model: string;
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Verbatim Anthropic web-search call/result retained for same-provider
|
|
502
|
+
* history replay. Other providers discard it in `transformMessages`.
|
|
503
|
+
*/
|
|
504
|
+
export interface AnthropicServerToolContent {
|
|
505
|
+
type: "anthropicServerTool";
|
|
506
|
+
block: {
|
|
507
|
+
type: "server_tool_use";
|
|
508
|
+
id: string;
|
|
509
|
+
name: "web_search";
|
|
510
|
+
input?: Record<string, unknown> | null;
|
|
511
|
+
[key: string]: unknown;
|
|
512
|
+
} | {
|
|
513
|
+
type: "web_search_tool_result";
|
|
514
|
+
tool_use_id: string;
|
|
515
|
+
content: unknown;
|
|
516
|
+
[key: string]: unknown;
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
export interface ImageContent {
|
|
520
|
+
type: "image";
|
|
521
|
+
data: string;
|
|
522
|
+
mimeType: string;
|
|
523
|
+
/**
|
|
524
|
+
* OpenAI-only resolution hint. `"original"` preserves native resolution
|
|
525
|
+
* (required for snapcompact frames, whose glyphs do not survive the
|
|
526
|
+
* default `auto` downscale). Providers without a detail knob ignore it.
|
|
527
|
+
*/
|
|
528
|
+
detail?: "auto" | "low" | "high" | "original";
|
|
529
|
+
}
|
|
530
|
+
export type ComputerAction = {
|
|
531
|
+
type: "click";
|
|
532
|
+
button: "left" | "right" | "wheel" | "back" | "forward";
|
|
533
|
+
x: number;
|
|
534
|
+
y: number;
|
|
535
|
+
keys?: string[] | null;
|
|
536
|
+
} | {
|
|
537
|
+
type: "double_click";
|
|
538
|
+
x: number;
|
|
539
|
+
y: number;
|
|
540
|
+
keys: string[] | null;
|
|
541
|
+
} | {
|
|
542
|
+
type: "drag";
|
|
543
|
+
path: Array<{
|
|
544
|
+
x: number;
|
|
545
|
+
y: number;
|
|
546
|
+
}>;
|
|
547
|
+
keys?: string[] | null;
|
|
548
|
+
} | {
|
|
549
|
+
type: "keypress";
|
|
550
|
+
keys: string[];
|
|
551
|
+
} | {
|
|
552
|
+
type: "move";
|
|
553
|
+
x: number;
|
|
554
|
+
y: number;
|
|
555
|
+
keys?: string[] | null;
|
|
556
|
+
} | {
|
|
557
|
+
type: "screenshot";
|
|
558
|
+
} | {
|
|
559
|
+
type: "scroll";
|
|
560
|
+
x: number;
|
|
561
|
+
y: number;
|
|
562
|
+
scroll_x: number;
|
|
563
|
+
scroll_y: number;
|
|
564
|
+
keys?: string[] | null;
|
|
565
|
+
} | {
|
|
566
|
+
type: "type";
|
|
567
|
+
text: string;
|
|
568
|
+
} | {
|
|
569
|
+
type: "wait";
|
|
570
|
+
};
|
|
571
|
+
export interface ComputerSafetyCheck {
|
|
572
|
+
id: string;
|
|
573
|
+
code?: string | null;
|
|
574
|
+
message?: string | null;
|
|
575
|
+
}
|
|
576
|
+
export interface ComputerToolCallMetadata {
|
|
577
|
+
type: "computer";
|
|
578
|
+
providerItemId: string;
|
|
579
|
+
actions: ComputerAction[];
|
|
580
|
+
pendingSafetyChecks: ComputerSafetyCheck[];
|
|
581
|
+
}
|
|
582
|
+
export type ToolCallProviderMetadata = ComputerToolCallMetadata;
|
|
583
|
+
export type ComputerScreenshotRef = {
|
|
584
|
+
type: "computer_screenshot";
|
|
585
|
+
image_url: string;
|
|
586
|
+
file_id?: never;
|
|
587
|
+
} | {
|
|
588
|
+
type: "computer_screenshot";
|
|
589
|
+
file_id: string;
|
|
590
|
+
image_url?: never;
|
|
591
|
+
};
|
|
592
|
+
export interface ComputerToolResultMetadata {
|
|
593
|
+
type: "computer";
|
|
594
|
+
screenshot: ComputerScreenshotRef;
|
|
595
|
+
acknowledgedSafetyChecks: ComputerSafetyCheck[];
|
|
596
|
+
}
|
|
597
|
+
export type ToolResultProviderMetadata = ComputerToolResultMetadata;
|
|
598
|
+
export interface ToolCall {
|
|
599
|
+
type: "toolCall";
|
|
600
|
+
id: string;
|
|
601
|
+
name: string;
|
|
602
|
+
arguments: Record<string, unknown>;
|
|
603
|
+
[kStreamingPartialJson]?: string;
|
|
604
|
+
thoughtSignature?: string;
|
|
605
|
+
intent?: string;
|
|
606
|
+
/**
|
|
607
|
+
* Verbatim in-band syntax block that produced this synthetic `ptc_*` call.
|
|
608
|
+
* Present only for owned prompt/tool-call formats; provider-native calls omit it.
|
|
609
|
+
*/
|
|
610
|
+
rawBlock?: string;
|
|
611
|
+
/**
|
|
612
|
+
* Original wire-level name when the tool was invoked via OpenAI's custom-tool
|
|
613
|
+
* mechanism (e.g., `apply_patch`). Set by `openai-responses` on receive so
|
|
614
|
+
* the history-replay path can re-emit the call as `custom_tool_call` with
|
|
615
|
+
* its paired tool-result as `custom_tool_call_output`. Absent for regular
|
|
616
|
+
* JSON function tools.
|
|
617
|
+
*/
|
|
618
|
+
customWireName?: string;
|
|
619
|
+
/** Provider-native metadata required to execute and faithfully replay this call. */
|
|
620
|
+
providerMetadata?: ToolCallProviderMetadata;
|
|
621
|
+
}
|
|
622
|
+
export type StopReason = "stop" | "length" | "toolUse" | "error" | "aborted";
|
|
623
|
+
export interface OpenAIResponsesHistoryPayload {
|
|
624
|
+
type: "openaiResponsesHistory";
|
|
625
|
+
provider?: string;
|
|
626
|
+
dt?: boolean;
|
|
627
|
+
items: Array<Record<string, unknown>>;
|
|
628
|
+
}
|
|
629
|
+
export type ProviderPayload = OpenAIResponsesHistoryPayload;
|
|
630
|
+
export interface UserMessage {
|
|
631
|
+
role: "user";
|
|
632
|
+
content: string | (TextContent | ImageContent)[];
|
|
633
|
+
/** True if the message was injected by the system (e.g., auto-continue). */
|
|
634
|
+
synthetic?: boolean;
|
|
635
|
+
/** True when injected mid-turn as a steer; consumed by the agent's pre-LLM transform to wrap it for emphasis. Never rendered. */
|
|
636
|
+
steering?: boolean;
|
|
637
|
+
/** Who initiated this message for billing/attribution semantics. */
|
|
638
|
+
attribution?: MessageAttribution;
|
|
639
|
+
/** Provider-specific opaque payload used to reconstruct transport-native history. */
|
|
640
|
+
providerPayload?: ProviderPayload;
|
|
641
|
+
timestamp: number;
|
|
642
|
+
}
|
|
643
|
+
export interface DeveloperMessage {
|
|
644
|
+
role: "developer";
|
|
645
|
+
content: string | (TextContent | ImageContent)[];
|
|
646
|
+
/** Who initiated this message for billing/attribution semantics. */
|
|
647
|
+
attribution?: MessageAttribution;
|
|
648
|
+
/** Provider-specific opaque payload used to reconstruct transport-native history. */
|
|
649
|
+
providerPayload?: ProviderPayload;
|
|
650
|
+
timestamp: number;
|
|
651
|
+
}
|
|
652
|
+
/** How an automatic retry recovered or ultimately settled a failed attempt. */
|
|
653
|
+
export type AssistantRetryRecoveryKind = "credential" | "model" | "wait" | "plain";
|
|
654
|
+
/** Persisted presentation state for an assistant error superseded by an automatic retry saga. */
|
|
655
|
+
export type AssistantRetryRecovery = {
|
|
656
|
+
kind: "auto-retry";
|
|
657
|
+
status: "recovered";
|
|
658
|
+
attempt: number;
|
|
659
|
+
recoveredAt: string;
|
|
660
|
+
recovery: AssistantRetryRecoveryKind;
|
|
661
|
+
note: string;
|
|
662
|
+
supersededBy?: {
|
|
663
|
+
timestamp: number;
|
|
664
|
+
responseId?: string;
|
|
665
|
+
provider: string;
|
|
666
|
+
model: string;
|
|
667
|
+
};
|
|
668
|
+
} | {
|
|
669
|
+
kind: "auto-retry";
|
|
670
|
+
status: "superseded";
|
|
671
|
+
attempt: number;
|
|
672
|
+
recovery: AssistantRetryRecoveryKind;
|
|
673
|
+
note: string;
|
|
674
|
+
};
|
|
675
|
+
export interface ContextSnapshot {
|
|
676
|
+
promptTokens: number;
|
|
677
|
+
nonMessageTokens: number;
|
|
678
|
+
/** Estimated prompt tokens removed by local history rewrites after this provider snapshot was recorded. */
|
|
679
|
+
historyRewriteTokensRemoved?: number;
|
|
680
|
+
lastMessageTimestamp?: number;
|
|
681
|
+
}
|
|
682
|
+
export interface AssistantMessage {
|
|
683
|
+
role: "assistant";
|
|
684
|
+
content: (TextContent | ThinkingContent | RedactedThinkingContent | AnthropicFallbackContent | AnthropicServerToolContent | ImageContent | ToolCall)[];
|
|
685
|
+
api: Api;
|
|
686
|
+
provider: Provider;
|
|
687
|
+
model: string;
|
|
688
|
+
contextSnapshot?: ContextSnapshot;
|
|
689
|
+
retryRecovery?: AssistantRetryRecovery;
|
|
690
|
+
responseId?: string;
|
|
691
|
+
/**
|
|
692
|
+
* Name of the upstream provider an aggregator routed this request to, as
|
|
693
|
+
* reported in the response (e.g. OpenRouter's top-level `provider` field:
|
|
694
|
+
* `"OpenAI"`, `"Anthropic"`, `"Together"`). Distinct from `provider`, which
|
|
695
|
+
* is the configured gateway we called (`"openrouter"`). Undefined for direct
|
|
696
|
+
* providers that expose no such field.
|
|
697
|
+
*/
|
|
698
|
+
upstreamProvider?: string;
|
|
699
|
+
usage: Usage;
|
|
700
|
+
stopReason: StopReason;
|
|
701
|
+
stopDetails?: StopDetails | null;
|
|
702
|
+
errorMessage?: string;
|
|
703
|
+
/** Per-tool abort messages used when an aborted assistant turn needs different placeholder results per tool call. */
|
|
704
|
+
toolCallAbortMessages?: Record<string, string>;
|
|
705
|
+
/** HTTP status surfaced by the provider when the request failed. Populated by every provider's catch block alongside `errorMessage` so consumers (auth retry, telemetry, UI) can branch without regex-scraping the message. */
|
|
706
|
+
errorStatus?: number;
|
|
707
|
+
/** Structured machine-readable error classifier; see `utils/error-id.ts` for bit layout and helpers. */
|
|
708
|
+
errorId?: number;
|
|
709
|
+
/**
|
|
710
|
+
* Stable identifiers for request features the provider silently dropped
|
|
711
|
+
* during this turn (e.g. `"priority"`). Set when a server-side rejection
|
|
712
|
+
* triggered an in-provider fallback retry that succeeded without the
|
|
713
|
+
* feature. Callers can use this to sync user-facing toggles back to the
|
|
714
|
+
* server's actual state.
|
|
715
|
+
*/
|
|
716
|
+
disabledFeatures?: string[];
|
|
717
|
+
/** Provider-specific opaque payload used to reconstruct transport-native history. */
|
|
718
|
+
providerPayload?: ProviderPayload;
|
|
719
|
+
timestamp: number;
|
|
720
|
+
duration?: number;
|
|
721
|
+
ttft?: number;
|
|
722
|
+
}
|
|
723
|
+
export interface ToolResultMessage<TDetails = unknown> {
|
|
724
|
+
role: "toolResult";
|
|
725
|
+
toolCallId: string;
|
|
726
|
+
toolName: string;
|
|
727
|
+
content: (TextContent | ImageContent)[];
|
|
728
|
+
details?: TDetails;
|
|
729
|
+
isError: boolean;
|
|
730
|
+
/** Who initiated this message for billing/attribution semantics. */
|
|
731
|
+
attribution?: MessageAttribution;
|
|
732
|
+
/** Timestamp when output was pruned (ms since epoch). Undefined if unpruned. */
|
|
733
|
+
prunedAt?: number;
|
|
734
|
+
/** Provider-native metadata required to faithfully replay this result. */
|
|
735
|
+
providerMetadata?: ToolResultProviderMetadata;
|
|
736
|
+
/**
|
|
737
|
+
* Tool-declared: this result carried no information worth retaining once
|
|
738
|
+
* consumed (zero matches, elapsed wait). Compaction passes may elide it.
|
|
739
|
+
* Never set together with isError.
|
|
740
|
+
*/
|
|
741
|
+
useless?: boolean;
|
|
742
|
+
timestamp: number;
|
|
743
|
+
}
|
|
744
|
+
export type Message = UserMessage | DeveloperMessage | AssistantMessage | ToolResultMessage;
|
|
745
|
+
export type CursorExecHandlerResult<T> = {
|
|
746
|
+
result: T;
|
|
747
|
+
toolResult?: ToolResultMessage;
|
|
748
|
+
} | T | ToolResultMessage;
|
|
749
|
+
/**
|
|
750
|
+
* Optional rewrite of a Cursor exec-channel tool result.
|
|
751
|
+
* May return a Promise. Returning `undefined` keeps the original result.
|
|
752
|
+
*
|
|
753
|
+
* The Agent reserves the original result in its buffer before awaiting this
|
|
754
|
+
* hook, and the `message_end` drain waits for a still-pending rewrite, so an
|
|
755
|
+
* async transformer is honored even when the turn closes in the same chunk.
|
|
756
|
+
* A rejecting transformer is swallowed and the reserved payload stands in.
|
|
757
|
+
*/
|
|
758
|
+
export type CursorToolResultHandler = (result: ToolResultMessage) => ToolResultMessage | undefined | Promise<ToolResultMessage | undefined>;
|
|
759
|
+
/**
|
|
760
|
+
* Identifies the synthesized assistant block a Cursor exec call was filed
|
|
761
|
+
* under, so paths that produce no handler `toolResult` can still pair one.
|
|
762
|
+
*/
|
|
763
|
+
export interface CursorExecPairing {
|
|
764
|
+
toolCallId: string;
|
|
765
|
+
toolName: string;
|
|
766
|
+
}
|
|
767
|
+
export interface CursorMcpCall {
|
|
768
|
+
name: string;
|
|
769
|
+
providerIdentifier: string;
|
|
770
|
+
toolName: string;
|
|
771
|
+
toolCallId: string;
|
|
772
|
+
args: Record<string, unknown>;
|
|
773
|
+
rawArgs: Record<string, Uint8Array>;
|
|
774
|
+
/**
|
|
775
|
+
* The frame asks only whether this call would be permitted — it must not
|
|
776
|
+
* run. The server sends it to resolve a smart-mode approval decision ahead
|
|
777
|
+
* of the real invocation, and answers with the dedicated `approved`
|
|
778
|
+
* variant, so executing here would fire a side-effecting tool the user has
|
|
779
|
+
* not yet been asked about (and fire it twice once the real call arrives).
|
|
780
|
+
*/
|
|
781
|
+
approvalOnly?: boolean;
|
|
782
|
+
}
|
|
783
|
+
export interface CursorTodoSnapshotItem {
|
|
784
|
+
content: string;
|
|
785
|
+
status: "pending" | "in_progress" | "completed" | "abandoned";
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Authoritative todo list state settled by Cursor's server-side
|
|
789
|
+
* `update_todos` / `read_todos` tools.
|
|
790
|
+
*/
|
|
791
|
+
export interface CursorTodoSnapshot {
|
|
792
|
+
todos: CursorTodoSnapshotItem[];
|
|
793
|
+
/** True when the server reported the update as a merge. Presentation only. */
|
|
794
|
+
merged: boolean;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Settles a native todo call in the host.
|
|
798
|
+
*
|
|
799
|
+
* Called for every completed native todo call, not just successful ones: the
|
|
800
|
+
* interactive todo card only resolves on a matching `tool_execution_end`, so a
|
|
801
|
+
* refused or failed call that stayed silent would animate forever.
|
|
802
|
+
*
|
|
803
|
+
* `snapshot` is the server-confirmed list, or `null` when there is nothing to
|
|
804
|
+
* mirror — a server error (`error` set), or a benign refusal with `error` null:
|
|
805
|
+
* a filtered, truncated, or empty read, or a snapshot the local model cannot
|
|
806
|
+
* represent (two rows sharing content). Local state MUST be left untouched
|
|
807
|
+
* unless a snapshot is supplied.
|
|
808
|
+
*
|
|
809
|
+
* `toolCallId` is the id of the streamed native call, which is also the key the
|
|
810
|
+
* interactive transcript filed the visible block under. The host MUST reuse it
|
|
811
|
+
* when emitting the synthetic completion, or that block never resolves.
|
|
812
|
+
*
|
|
813
|
+
* Returns the result to persist for that block — always, since every settle
|
|
814
|
+
* needs a paired result or `buildSessionContext` strips the block as dangling.
|
|
815
|
+
* Only the host knows the phase grouping the todo renderer replays from, so the
|
|
816
|
+
* provider persists this value verbatim. When no handler is registered at all,
|
|
817
|
+
* the provider falls back to its own summary-only result.
|
|
818
|
+
*/
|
|
819
|
+
export type CursorTodoSyncHandler = (snapshot: CursorTodoSnapshot | null, toolCallId: string, error: string | null) => ToolResultMessage;
|
|
820
|
+
export interface CursorShellStreamCallbacks {
|
|
821
|
+
onStdout(data: string): void;
|
|
822
|
+
onStderr(data: string): void;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* A modern Pi exec frame plus the call id the dispatcher minted for it.
|
|
826
|
+
*
|
|
827
|
+
* Unlike the legacy exec args (`ReadArgs`, `ShellArgs`, ...), the Pi frames
|
|
828
|
+
* carry no `tool_call_id` field: on modern builds the id rides the streamed
|
|
829
|
+
* `ToolCall` envelope (`ToolCall.tool_call_id = 57`) instead of each variant's
|
|
830
|
+
* args. The exec channel has no access to that envelope, so the dispatcher
|
|
831
|
+
* mints an id and hands it to the handler, keeping the synthesized transcript
|
|
832
|
+
* block and its paired `toolResult` on the same key.
|
|
833
|
+
*/
|
|
834
|
+
export interface CursorPiCall<TArgs> {
|
|
835
|
+
args: TArgs;
|
|
836
|
+
toolCallId: string;
|
|
837
|
+
}
|
|
838
|
+
/** One resource a host's MCP servers advertise. */
|
|
839
|
+
export interface CursorMcpResource {
|
|
840
|
+
uri: string;
|
|
841
|
+
name?: string;
|
|
842
|
+
description?: string;
|
|
843
|
+
mimeType?: string;
|
|
844
|
+
/** The server advertising it; Cursor addresses reads by this name. */
|
|
845
|
+
server: string;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* The content of one resource read.
|
|
849
|
+
*
|
|
850
|
+
* `text` and `blob` are the wire's content oneof: exactly one is sent, with
|
|
851
|
+
* `text` winning when a host supplies both. A download instead sets
|
|
852
|
+
* `downloadPath` and no content at all — the model is told where the file
|
|
853
|
+
* landed rather than being handed its bytes.
|
|
854
|
+
*/
|
|
855
|
+
export interface CursorMcpResourceContent {
|
|
856
|
+
uri: string;
|
|
857
|
+
name?: string;
|
|
858
|
+
description?: string;
|
|
859
|
+
mimeType?: string;
|
|
860
|
+
text?: string;
|
|
861
|
+
blob?: Uint8Array;
|
|
862
|
+
/**
|
|
863
|
+
* Where the host wrote the resource, workspace-relative, when the frame
|
|
864
|
+
* asked for a download. Set this INSTEAD of `text`/`blob`: the wire
|
|
865
|
+
* contract is that a download returns no content to the model.
|
|
866
|
+
*/
|
|
867
|
+
downloadPath?: string;
|
|
868
|
+
}
|
|
869
|
+
export interface CursorExecHandlers {
|
|
870
|
+
read?: (args: ReadArgs) => Promise<CursorExecHandlerResult<ReadResult>>;
|
|
871
|
+
ls?: (args: LsArgs) => Promise<CursorExecHandlerResult<LsResult>>;
|
|
872
|
+
grep?: (args: GrepArgs) => Promise<CursorExecHandlerResult<GrepResult>>;
|
|
873
|
+
write?: (args: WriteArgs) => Promise<CursorExecHandlerResult<WriteResult>>;
|
|
874
|
+
delete?: (args: DeleteArgs) => Promise<CursorExecHandlerResult<DeleteResult>>;
|
|
875
|
+
shell?: (args: ShellArgs) => Promise<CursorExecHandlerResult<ShellResult>>;
|
|
876
|
+
shellStream?: (args: ShellArgs, callbacks: CursorShellStreamCallbacks) => Promise<CursorExecHandlerResult<ShellResult>>;
|
|
877
|
+
diagnostics?: (args: DiagnosticsArgs) => Promise<CursorExecHandlerResult<DiagnosticsResult>>;
|
|
878
|
+
mcp?: (call: CursorMcpCall) => Promise<CursorExecHandlerResult<McpResult>>;
|
|
879
|
+
/**
|
|
880
|
+
* Answers "would this MCP call be permitted", without running it.
|
|
881
|
+
*
|
|
882
|
+
* A modern `mcpArgs` frame carrying `smart_mode_approval_only` asks for the
|
|
883
|
+
* permission decision alone, ahead of the real invocation. Executing the
|
|
884
|
+
* tool to answer it would fire a side effect the user never approved — and
|
|
885
|
+
* fire it twice once the real call arrives.
|
|
886
|
+
*
|
|
887
|
+
* `true` only when the host's policy resolves to a definite allow. A pending
|
|
888
|
+
* prompt is `false`: it can only be answered interactively at execution
|
|
889
|
+
* time, and there is no "ask me later" reply in this frame's result. When no
|
|
890
|
+
* handler is registered the provider refuses, since it cannot decide.
|
|
891
|
+
*/
|
|
892
|
+
mcpApprovalPreflight?: (call: CursorMcpCall) => Promise<boolean>;
|
|
893
|
+
/**
|
|
894
|
+
* Modern Cursor CLI Pi tool frames (`ExecServerMessage` 45-51). They are a
|
|
895
|
+
* distinct frame family from the legacy `readArgs`/`shellArgs`/... set, not
|
|
896
|
+
* an alias: different args, different result oneofs, and no `tool_call_id`.
|
|
897
|
+
*/
|
|
898
|
+
piRead?: (call: CursorPiCall<PiReadExecArgs>) => Promise<CursorExecHandlerResult<PiReadExecResult>>;
|
|
899
|
+
piBash?: (call: CursorPiCall<PiBashExecArgs>) => Promise<CursorExecHandlerResult<PiBashExecResult>>;
|
|
900
|
+
piEdit?: (call: CursorPiCall<PiEditExecArgs>) => Promise<CursorExecHandlerResult<PiEditExecResult>>;
|
|
901
|
+
piWrite?: (call: CursorPiCall<PiWriteExecArgs>) => Promise<CursorExecHandlerResult<PiWriteExecResult>>;
|
|
902
|
+
piGrep?: (call: CursorPiCall<PiGrepExecArgs>) => Promise<CursorExecHandlerResult<PiGrepExecResult>>;
|
|
903
|
+
piFind?: (call: CursorPiCall<PiFindExecArgs>) => Promise<CursorExecHandlerResult<PiFindExecResult>>;
|
|
904
|
+
piLs?: (call: CursorPiCall<PiLsExecArgs>) => Promise<CursorExecHandlerResult<PiLsExecResult>>;
|
|
905
|
+
/**
|
|
906
|
+
* The resources the host's MCP servers advertise, optionally filtered to one
|
|
907
|
+
* server. Without a handler the provider answers an empty catalog, which
|
|
908
|
+
* hides resources a host is in fact holding live connections to.
|
|
909
|
+
*/
|
|
910
|
+
listMcpResources?: (args: {
|
|
911
|
+
server?: string;
|
|
912
|
+
}) => Promise<CursorMcpResource[]>;
|
|
913
|
+
/**
|
|
914
|
+
* Read one resource. `null` means the server or uri is genuinely unknown,
|
|
915
|
+
* which the provider answers as `not_found`; throwing surfaces as `error`.
|
|
916
|
+
*/
|
|
917
|
+
readMcpResource?: (args: {
|
|
918
|
+
server: string;
|
|
919
|
+
uri: string;
|
|
920
|
+
/**
|
|
921
|
+
* When set, write the resource here (workspace-relative) and return
|
|
922
|
+
* `downloadPath` instead of content.
|
|
923
|
+
*/
|
|
924
|
+
downloadPath?: string;
|
|
925
|
+
}) => Promise<CursorMcpResourceContent | null>;
|
|
926
|
+
/** Mirror Cursor's server-owned todo list into local session state. */
|
|
927
|
+
todoSync?: CursorTodoSyncHandler;
|
|
928
|
+
onToolResult?: CursorToolResultHandler;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Plain JSON Schema document used by extension-authored tools (legacy TypeBox
|
|
932
|
+
* emits this shape). Distinguished from arktype at runtime.
|
|
933
|
+
*/
|
|
934
|
+
export type TJsonSchema = Record<string, unknown>;
|
|
935
|
+
/**
|
|
936
|
+
* Schema type accepted by the {@link Tool} interface.
|
|
937
|
+
*
|
|
938
|
+
* Canonical authoring uses ArkType. Extension compat may supply a JSON Schema
|
|
939
|
+
* object (including TypeBox static schema objects).
|
|
940
|
+
*/
|
|
941
|
+
export type TSchema = Type | TJsonSchema;
|
|
942
|
+
/** Resolve parameter types for tool execution / handlers. */
|
|
943
|
+
export type Static<S> = S extends Type ? S["infer"] : S extends {
|
|
944
|
+
static: infer T;
|
|
945
|
+
} ? T : unknown;
|
|
946
|
+
export interface ToolCallExample<TArgs = Record<string, unknown>> {
|
|
947
|
+
caption?: string;
|
|
948
|
+
call: TArgs;
|
|
949
|
+
}
|
|
950
|
+
export interface ToolCompareExample<TArgs = Record<string, unknown>> {
|
|
951
|
+
caption?: string;
|
|
952
|
+
bad: TArgs;
|
|
953
|
+
good: TArgs;
|
|
954
|
+
}
|
|
955
|
+
export interface ToolNoteExample {
|
|
956
|
+
caption: string;
|
|
957
|
+
note?: string;
|
|
958
|
+
}
|
|
959
|
+
export type ToolExample<TArgs = Record<string, unknown>> = ToolCallExample<TArgs> | ToolCompareExample<TArgs> | ToolNoteExample;
|
|
960
|
+
export interface Tool<TParameters extends TSchema = TSchema> {
|
|
961
|
+
name: string;
|
|
962
|
+
description: string;
|
|
963
|
+
parameters: TParameters;
|
|
964
|
+
/** If true, tool is strictly typed and validated against the parameters schema before execution */
|
|
965
|
+
strict?: boolean;
|
|
966
|
+
/**
|
|
967
|
+
* Optional grammar constraint for OpenAI custom-tool emission.
|
|
968
|
+
* When set, providers that support grammar-constrained tools (currently only
|
|
969
|
+
* `openai-responses` against models with the right capability flag) may emit
|
|
970
|
+
* this tool as `{type: "custom", format: {type: "grammar", …}}` instead of a
|
|
971
|
+
* JSON function tool. Other providers ignore the field.
|
|
972
|
+
*/
|
|
973
|
+
customFormat?: {
|
|
974
|
+
syntax: "lark" | "regex";
|
|
975
|
+
definition: string;
|
|
976
|
+
};
|
|
977
|
+
/**
|
|
978
|
+
* Optional wire-level name used when this tool is emitted as a custom tool
|
|
979
|
+
* (e.g. OpenAI's `{type: "custom"}` shape). Models trained on specific tool
|
|
980
|
+
* names — like GPT-5 on `apply_patch` — need to see that exact name on the
|
|
981
|
+
* wire, but it may differ from the harness-internal `name`. The agent-loop
|
|
982
|
+
* dispatcher matches both `name` and `customWireName` so returned tool
|
|
983
|
+
* calls route correctly. Absent for regular JSON function tools.
|
|
984
|
+
*/
|
|
985
|
+
customWireName?: string;
|
|
986
|
+
/** Selects a provider-native hosted tool instead of a JSON-schema function tool. */
|
|
987
|
+
native?: NativeToolMarker;
|
|
988
|
+
/**
|
|
989
|
+
* Illustrative calls/notes; the AI layer renders them into an `<examples>`
|
|
990
|
+
* block in the model's native tool-call syntax and appends to the wire
|
|
991
|
+
* description. Author `call`/`bad`/`good` as plain argument objects WITHOUT
|
|
992
|
+
* `i` — when intent tracing injects `i` into the schema, the renderer adds
|
|
993
|
+
* a placeholder `i` automatically. Type each tool's `examples` against its
|
|
994
|
+
* own schema (e.g. `readonly ToolExample<typeof schema["type"]>[]`).
|
|
995
|
+
*/
|
|
996
|
+
examples?: readonly ToolExample[];
|
|
997
|
+
}
|
|
998
|
+
export interface Context {
|
|
999
|
+
systemPrompt?: string[];
|
|
1000
|
+
messages: Message[];
|
|
1001
|
+
tools?: Tool[];
|
|
1002
|
+
}
|
|
1003
|
+
export type AssistantMessageEvent = {
|
|
1004
|
+
type: "start";
|
|
1005
|
+
contentIndex?: undefined;
|
|
1006
|
+
partial: AssistantMessage;
|
|
1007
|
+
} | {
|
|
1008
|
+
type: "text_start";
|
|
1009
|
+
contentIndex: number;
|
|
1010
|
+
partial: AssistantMessage;
|
|
1011
|
+
} | {
|
|
1012
|
+
type: "text_delta";
|
|
1013
|
+
contentIndex: number;
|
|
1014
|
+
delta: string;
|
|
1015
|
+
partial: AssistantMessage;
|
|
1016
|
+
} | {
|
|
1017
|
+
type: "text_end";
|
|
1018
|
+
contentIndex: number;
|
|
1019
|
+
content: string;
|
|
1020
|
+
partial: AssistantMessage;
|
|
1021
|
+
} | {
|
|
1022
|
+
type: "thinking_start";
|
|
1023
|
+
contentIndex: number;
|
|
1024
|
+
partial: AssistantMessage;
|
|
1025
|
+
} | {
|
|
1026
|
+
type: "thinking_delta";
|
|
1027
|
+
contentIndex: number;
|
|
1028
|
+
delta: string;
|
|
1029
|
+
partial: AssistantMessage;
|
|
1030
|
+
} | {
|
|
1031
|
+
type: "thinking_end";
|
|
1032
|
+
contentIndex: number;
|
|
1033
|
+
content: string;
|
|
1034
|
+
partial: AssistantMessage;
|
|
1035
|
+
} | {
|
|
1036
|
+
type: "image_end";
|
|
1037
|
+
contentIndex: number;
|
|
1038
|
+
content: ImageContent;
|
|
1039
|
+
partial: AssistantMessage;
|
|
1040
|
+
} | {
|
|
1041
|
+
type: "toolcall_start";
|
|
1042
|
+
contentIndex: number;
|
|
1043
|
+
partial: AssistantMessage;
|
|
1044
|
+
} | {
|
|
1045
|
+
type: "toolcall_delta";
|
|
1046
|
+
contentIndex: number;
|
|
1047
|
+
delta: string;
|
|
1048
|
+
partial: AssistantMessage;
|
|
1049
|
+
} | {
|
|
1050
|
+
type: "toolcall_end";
|
|
1051
|
+
contentIndex: number;
|
|
1052
|
+
toolCall: ToolCall;
|
|
1053
|
+
partial: AssistantMessage;
|
|
1054
|
+
} | {
|
|
1055
|
+
type: "done";
|
|
1056
|
+
contentIndex?: undefined;
|
|
1057
|
+
reason: Extract<StopReason, "stop" | "length" | "toolUse">;
|
|
1058
|
+
message: AssistantMessage;
|
|
1059
|
+
} | {
|
|
1060
|
+
type: "error";
|
|
1061
|
+
contentIndex?: undefined;
|
|
1062
|
+
reason: Extract<StopReason, "aborted" | "error">;
|
|
1063
|
+
error: AssistantMessage;
|
|
1064
|
+
};
|