jeopi-ai 16.2.13
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 +4347 -0
- package/README.md +1193 -0
- package/dist/types/api-registry.d.ts +30 -0
- package/dist/types/auth-broker/client.d.ts +73 -0
- package/dist/types/auth-broker/discover.d.ts +35 -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 +102 -0
- package/dist/types/auth-broker/server.d.ts +43 -0
- package/dist/types/auth-broker/snapshot-cache.d.ts +17 -0
- package/dist/types/auth-broker/types.d.ts +107 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +411 -0
- package/dist/types/auth-gateway/http.d.ts +39 -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 +123 -0
- package/dist/types/auth-retry.d.ts +124 -0
- package/dist/types/auth-storage.d.ts +1026 -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 +23 -0
- package/dist/types/dialect/examples.d.ts +2 -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 +12 -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 +45 -0
- package/dist/types/dialect/thinking.d.ts +6 -0
- package/dist/types/dialect/types.d.ts +69 -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 +16 -0
- package/dist/types/error/auth.d.ts +27 -0
- package/dist/types/error/aws.d.ts +23 -0
- package/dist/types/error/classes.d.ts +102 -0
- package/dist/types/error/finalize.d.ts +39 -0
- package/dist/types/error/flags.d.ts +79 -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 +13 -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 +59 -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 +49 -0
- package/dist/types/provider-details.d.ts +24 -0
- package/dist/types/providers/__tests__/google-auth.test.d.ts +1 -0
- package/dist/types/providers/__tests__/kimi-code-thinking.test.d.ts +1 -0
- package/dist/types/providers/__tests__/openai-codex-error.test.d.ts +1 -0
- package/dist/types/providers/amazon-bedrock.d.ts +39 -0
- package/dist/types/providers/anthropic-client.d.ts +94 -0
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +497 -0
- package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
- package/dist/types/providers/anthropic-wire.d.ts +318 -0
- package/dist/types/providers/anthropic.d.ts +248 -0
- package/dist/types/providers/aws-credentials.d.ts +53 -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/cursor.d.ts +91 -0
- package/dist/types/providers/devin.d.ts +12 -0
- package/dist/types/providers/error-message.d.ts +27 -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 +32 -0
- package/dist/types/providers/google-gemini-cli.d.ts +118 -0
- package/dist/types/providers/google-interactions.d.ts +65 -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 +178 -0
- package/dist/types/providers/ollama.d.ts +7 -0
- package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +695 -0
- package/dist/types/providers/openai-chat-server.d.ts +16 -0
- package/dist/types/providers/openai-chat-wire.d.ts +644 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +54 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +26 -0
- package/dist/types/providers/openai-codex-responses.d.ts +108 -0
- package/dist/types/providers/openai-completions.d.ts +45 -0
- package/dist/types/providers/openai-reasoning-fallback.d.ts +25 -0
- package/dist/types/providers/openai-responses-server-schema.d.ts +349 -0
- package/dist/types/providers/openai-responses-server.d.ts +17 -0
- package/dist/types/providers/openai-responses-wire.d.ts +6065 -0
- package/dist/types/providers/openai-responses.d.ts +126 -0
- package/dist/types/providers/openai-shared.d.ts +506 -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 +32 -0
- package/dist/types/providers/synthetic.d.ts +26 -0
- package/dist/types/providers/transform-messages.d.ts +11 -0
- package/dist/types/providers/vision-guard.d.ts +20 -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/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/azure.d.ts +4 -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/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/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/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/nvidia.d.ts +7 -0
- package/dist/types/registry/oauth/__tests__/xai-oauth.test.d.ts +1 -0
- package/dist/types/registry/oauth/anthropic.d.ts +23 -0
- package/dist/types/registry/oauth/callback-server.d.ts +72 -0
- package/dist/types/registry/oauth/cursor.d.ts +15 -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 +10 -0
- package/dist/types/registry/oauth/google-oauth-shared.d.ts +22 -0
- package/dist/types/registry/oauth/index.d.ts +64 -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 +56 -0
- package/dist/types/registry/oauth/wafer.d.ts +1 -0
- package/dist/types/registry/oauth/xai-oauth.d.ts +52 -0
- package/dist/types/registry/oauth/xiaomi.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 +303 -0
- package/dist/types/registry/sakana.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 +51 -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 +4 -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 +7 -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 +44 -0
- package/dist/types/types.d.ts +715 -0
- package/dist/types/usage/claude.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 +2 -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 +79 -0
- package/dist/types/usage/openai-codex.d.ts +3 -0
- package/dist/types/usage/opencode-go.d.ts +2 -0
- package/dist/types/usage/shared.d.ts +1 -0
- package/dist/types/usage/zai.d.ts +2 -0
- package/dist/types/usage.d.ts +346 -0
- package/dist/types/utils/abort.d.ts +25 -0
- package/dist/types/utils/anthropic-auth.d.ts +35 -0
- package/dist/types/utils/block-symbols.d.ts +20 -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 +30 -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 +118 -0
- package/dist/types/utils/http-inspector.d.ts +30 -0
- package/dist/types/utils/idle-iterator.d.ts +137 -0
- package/dist/types/utils/leaked-thinking-stream.d.ts +29 -0
- package/dist/types/utils/openai-http.d.ts +54 -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 +29 -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 +15 -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 +124 -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 +18 -0
- package/dist/types/utils/schema/wire.d.ts +92 -0
- package/dist/types/utils/schema/zod-decontaminate.d.ts +31 -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 +50 -0
- package/dist/types/utils/validation.d.ts +42 -0
- package/dist/types/utils.d.ts +24 -0
- package/package.json +139 -0
- package/src/api-registry.ts +109 -0
- package/src/auth-broker/client.ts +359 -0
- package/src/auth-broker/discover.ts +222 -0
- package/src/auth-broker/index.ts +7 -0
- package/src/auth-broker/refresher.ts +117 -0
- package/src/auth-broker/remote-store.ts +657 -0
- package/src/auth-broker/server.ts +646 -0
- package/src/auth-broker/snapshot-cache.ts +191 -0
- package/src/auth-broker/types.ts +130 -0
- package/src/auth-broker/wire-schemas.ts +249 -0
- package/src/auth-gateway/http.ts +194 -0
- package/src/auth-gateway/index.ts +3 -0
- package/src/auth-gateway/server.ts +802 -0
- package/src/auth-gateway/types.ts +151 -0
- package/src/auth-retry.ts +250 -0
- package/src/auth-storage.ts +5576 -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 +36 -0
- package/src/dialect/examples.ts +33 -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 +597 -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 +456 -0
- package/src/dialect/harmony.md +31 -0
- package/src/dialect/harmony.ts +346 -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 +73 -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 +470 -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 +249 -0
- package/src/dialect/thinking.ts +122 -0
- package/src/dialect/types.ts +57 -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 +30 -0
- package/src/error/auth.ts +48 -0
- package/src/error/aws.ts +31 -0
- package/src/error/classes.ts +186 -0
- package/src/error/finalize.ts +69 -0
- package/src/error/flags.ts +506 -0
- package/src/error/format.ts +45 -0
- package/src/error/gateway.ts +96 -0
- package/src/error/index.ts +13 -0
- package/src/error/oauth.ts +58 -0
- package/src/error/provider.ts +62 -0
- package/src/error/rate-limit.ts +161 -0
- package/src/error/retryable.ts +70 -0
- package/src/error/validation.ts +44 -0
- package/src/index.ts +49 -0
- package/src/provider-details.ts +90 -0
- package/src/providers/__tests__/google-auth.test.ts +144 -0
- package/src/providers/__tests__/kimi-code-thinking.test.ts +112 -0
- package/src/providers/__tests__/openai-codex-error.test.ts +84 -0
- package/src/providers/amazon-bedrock.ts +1042 -0
- package/src/providers/anthropic-client.ts +295 -0
- package/src/providers/anthropic-messages-server-schema.ts +252 -0
- package/src/providers/anthropic-messages-server.ts +756 -0
- package/src/providers/anthropic-wire.ts +318 -0
- package/src/providers/anthropic.ts +4078 -0
- package/src/providers/aws-credentials.ts +586 -0
- package/src/providers/aws-eventstream.ts +181 -0
- package/src/providers/aws-sigv4.ts +218 -0
- package/src/providers/azure-openai-responses.ts +382 -0
- package/src/providers/cursor/proto/agent.proto +3526 -0
- package/src/providers/cursor/proto/buf.gen.yaml +6 -0
- package/src/providers/cursor/proto/buf.yaml +17 -0
- package/src/providers/cursor.ts +2695 -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 +577 -0
- package/src/providers/error-message.ts +21 -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 +3058 -0
- package/src/providers/gitlab-duo.ts +395 -0
- package/src/providers/google-auth.ts +350 -0
- package/src/providers/google-gemini-cli.ts +1362 -0
- package/src/providers/google-interactions.ts +753 -0
- package/src/providers/google-shared.ts +1103 -0
- package/src/providers/google-types.ts +180 -0
- package/src/providers/google-vertex.ts +183 -0
- package/src/providers/google.ts +87 -0
- package/src/providers/grammar.ts +70 -0
- package/src/providers/kimi.ts +52 -0
- package/src/providers/mock.ts +507 -0
- package/src/providers/ollama.ts +773 -0
- package/src/providers/openai-anthropic-shim.ts +152 -0
- package/src/providers/openai-chat-server-schema.ts +242 -0
- package/src/providers/openai-chat-server.ts +715 -0
- package/src/providers/openai-chat-wire.ts +847 -0
- package/src/providers/openai-codex/request-transformer.ts +295 -0
- package/src/providers/openai-codex/response-handler.ts +102 -0
- package/src/providers/openai-codex-responses.ts +3468 -0
- package/src/providers/openai-completions.ts +2173 -0
- package/src/providers/openai-reasoning-fallback.ts +269 -0
- package/src/providers/openai-responses-reasoning-suppression.md +1 -0
- package/src/providers/openai-responses-server-schema.ts +282 -0
- package/src/providers/openai-responses-server.ts +1280 -0
- package/src/providers/openai-responses-wire.ts +6391 -0
- package/src/providers/openai-responses.ts +1022 -0
- package/src/providers/openai-shared.ts +2648 -0
- package/src/providers/pi-native-client.ts +266 -0
- package/src/providers/pi-native-server.ts +242 -0
- package/src/providers/register-builtins.ts +475 -0
- package/src/providers/synthetic.ts +50 -0
- package/src/providers/transform-messages.ts +787 -0
- package/src/providers/vision-guard.ts +54 -0
- package/src/registry/aimlapi.ts +6 -0
- package/src/registry/alibaba-coding-plan.ts +95 -0
- package/src/registry/amazon-bedrock.ts +22 -0
- package/src/registry/anthropic.ts +26 -0
- package/src/registry/api-key-login.ts +112 -0
- package/src/registry/api-key-validation.ts +161 -0
- package/src/registry/azure.ts +6 -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/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/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/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 +22 -0
- package/src/registry/nanogpt.ts +22 -0
- package/src/registry/nvidia.ts +61 -0
- package/src/registry/oauth/__tests__/xai-oauth.test.ts +104 -0
- package/src/registry/oauth/anthropic.ts +311 -0
- package/src/registry/oauth/callback-server.ts +315 -0
- package/src/registry/oauth/cursor.ts +171 -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 +209 -0
- package/src/registry/oauth/google-gemini-cli.ts +273 -0
- package/src/registry/oauth/google-oauth-shared.ts +125 -0
- package/src/registry/oauth/index.ts +269 -0
- package/src/registry/oauth/kimi.ts +289 -0
- package/src/registry/oauth/minimax-code.ts +53 -0
- package/src/registry/oauth/oauth.html +311 -0
- package/src/registry/oauth/openai-codex.ts +364 -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 +65 -0
- package/src/registry/oauth/wafer.ts +24 -0
- package/src/registry/oauth/xai-oauth.ts +394 -0
- package/src/registry/oauth/xiaomi.ts +211 -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 +161 -0
- package/src/registry/sakana.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 +56 -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 +6 -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 +27 -0
- package/src/registry/zenmux.ts +22 -0
- package/src/registry/zhipu-coding-plan.ts +27 -0
- package/src/stream.ts +1778 -0
- package/src/types.ts +856 -0
- package/src/usage/claude.ts +485 -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 +271 -0
- package/src/usage/minimax-code.ts +30 -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 +174 -0
- package/src/usage/openai-codex.ts +535 -0
- package/src/usage/opencode-go.ts +89 -0
- package/src/usage/shared.ts +10 -0
- package/src/usage/zai.ts +321 -0
- package/src/usage.ts +333 -0
- package/src/utils/abort.ts +67 -0
- package/src/utils/anthropic-auth.ts +93 -0
- package/src/utils/block-symbols.ts +32 -0
- package/src/utils/deterministic-id.ts +20 -0
- package/src/utils/empty-completion-retry.ts +159 -0
- package/src/utils/event-stream.ts +171 -0
- package/src/utils/foundry.ts +8 -0
- package/src/utils/google-validation.ts +25 -0
- package/src/utils/harmony-leak.ts +456 -0
- package/src/utils/http-inspector.ts +168 -0
- package/src/utils/idle-iterator.ts +473 -0
- package/src/utils/leaked-thinking-stream.ts +294 -0
- package/src/utils/openai-http.ts +122 -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 +240 -0
- package/src/utils/request-debug.ts +351 -0
- package/src/utils/retry-after.ts +110 -0
- package/src/utils/retry.ts +59 -0
- package/src/utils/schema/CONSTRAINTS.md +166 -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 +207 -0
- package/src/utils/schema/index.ts +15 -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 +1901 -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 +198 -0
- package/src/utils/schema/wire.ts +789 -0
- package/src/utils/schema/zod-decontaminate.ts +331 -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 +99 -0
- package/src/utils/validation.ts +1507 -0
- package/src/utils.ts +171 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { Context, Model, OpenAICompat, ProviderSessionState, ServiceTier, StreamFunction, StreamOptions, Tool, ToolChoice } from "../types";
|
|
2
|
+
import { type OpenAIResponsesToolChoice } from "../utils/tool-choice";
|
|
3
|
+
import { type OpenAIReasoningEffortFallbackState } from "./openai-reasoning-fallback";
|
|
4
|
+
import type { Tool as OpenAITool, ResponseCreateParamsStreaming, ResponseInput } from "./openai-responses-wire";
|
|
5
|
+
import { type OpenAIStrictToolsScope, type OpenAIStrictToolsState } from "./openai-shared";
|
|
6
|
+
export interface OpenAIResponsesOptions extends StreamOptions {
|
|
7
|
+
reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
8
|
+
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
9
|
+
serviceTier?: ServiceTier;
|
|
10
|
+
textVerbosity?: "low" | "medium" | "high";
|
|
11
|
+
toolChoice?: ToolChoice;
|
|
12
|
+
openrouterVariant?: string;
|
|
13
|
+
maxTokensExplicit?: boolean;
|
|
14
|
+
disableReasoning?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Stateful turns: chain via `previous_response_id` + delta input instead of
|
|
17
|
+
* replaying the full transcript. Forces `store: true` (the platform only
|
|
18
|
+
* resolves stored responses). Defaults ON against the official OpenAI API
|
|
19
|
+
* and OFF for other Responses endpoints; `PI_OPENAI_STATEFUL` overrides the
|
|
20
|
+
* default, and `false` here vetoes everything. Requires `sessionId` +
|
|
21
|
+
* `providerSessionState`. Falls back to a full replay whenever history
|
|
22
|
+
* mutates or the server reports a stale id.
|
|
23
|
+
*/
|
|
24
|
+
statefulResponses?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Override catalog compat for strict tool call/result pairing when building
|
|
27
|
+
* Responses API inputs. Default behavior is catalog compat; this is only for
|
|
28
|
+
* debugging/adapter wrappers.
|
|
29
|
+
*/
|
|
30
|
+
strictResponsesPairing?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Override catalog compat for `include: ["reasoning.encrypted_content"]`.
|
|
33
|
+
* Default behavior is catalog compat; this is only for debugging/adapter wrappers.
|
|
34
|
+
*/
|
|
35
|
+
includeEncryptedReasoning?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Override catalog compat for stripping `type: "reasoning"` items from
|
|
38
|
+
* replayed conversation history before request encoding. Default behavior is
|
|
39
|
+
* catalog compat; this is only for debugging/adapter wrappers.
|
|
40
|
+
*/
|
|
41
|
+
filterReasoningHistory?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Override catalog compat for suppressing the `reasoning.effort` wire param.
|
|
44
|
+
* Default behavior is catalog compat; this is only for debugging/adapter wrappers.
|
|
45
|
+
*/
|
|
46
|
+
omitReasoningEffort?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Extra request headers merged onto the model/copilot defaults. Used by
|
|
49
|
+
* adapter wrappers to inject provider-specific
|
|
50
|
+
* routing or cache hints.
|
|
51
|
+
*/
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* Extra body fields merged into the Responses request payload. Used by
|
|
55
|
+
* adapter wrappers to inject provider-specific body keys (e.g.,
|
|
56
|
+
* prompt_cache_key for prompt-cache routing).
|
|
57
|
+
*/
|
|
58
|
+
extraBody?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
interface OpenAIResponsesProviderSessionState extends ProviderSessionState, OpenAIStrictToolsState, OpenAIReasoningEffortFallbackState {
|
|
61
|
+
nativeHistoryReplayWarmed: boolean;
|
|
62
|
+
/** Stateful `previous_response_id` chain baselines, keyed by baseUrl/model/session. */
|
|
63
|
+
chains: Map<string, OpenAIResponsesChainState>;
|
|
64
|
+
}
|
|
65
|
+
interface OpenAIResponsesChainState {
|
|
66
|
+
/**
|
|
67
|
+
* Wire params of the last successful turn, with per-turn trailing
|
|
68
|
+
* scaffolding stripped from `input` (never carries previous_response_id).
|
|
69
|
+
*/
|
|
70
|
+
lastParams?: OpenAIResponsesSamplingParams;
|
|
71
|
+
lastResponseId?: string;
|
|
72
|
+
/** Output items of the last response, in replay-sanitized form (matches next-turn input). */
|
|
73
|
+
lastResponseItems?: ResponseInput;
|
|
74
|
+
canAppend: boolean;
|
|
75
|
+
/** Consecutive stale-previous-response failures; reset on a successful chained completion. */
|
|
76
|
+
staleFailures: number;
|
|
77
|
+
/** Set once chaining is judged unsupported for this session (circuit breaker). */
|
|
78
|
+
disabled: boolean;
|
|
79
|
+
}
|
|
80
|
+
type OpenRouterAnthropicCacheControl = {
|
|
81
|
+
type: "ephemeral";
|
|
82
|
+
ttl?: "1h";
|
|
83
|
+
};
|
|
84
|
+
type OpenAIResponsesSamplingParams = ResponseCreateParamsStreaming & {
|
|
85
|
+
top_p?: number;
|
|
86
|
+
top_k?: number;
|
|
87
|
+
min_p?: number;
|
|
88
|
+
presence_penalty?: number;
|
|
89
|
+
repetition_penalty?: number;
|
|
90
|
+
session_id?: string;
|
|
91
|
+
stream_options?: {
|
|
92
|
+
include_obfuscation?: boolean;
|
|
93
|
+
};
|
|
94
|
+
provider?: OpenAICompat["openRouterRouting"];
|
|
95
|
+
reasoning?: {
|
|
96
|
+
effort?: string;
|
|
97
|
+
} | {
|
|
98
|
+
enabled: false;
|
|
99
|
+
};
|
|
100
|
+
cache_control?: OpenRouterAnthropicCacheControl;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Public entry: wrap the single-attempt Responses streamer with bounded
|
|
104
|
+
* empty-completion retries — a `response.completed` carrying no content/usage
|
|
105
|
+
* would otherwise stall the agent loop. Shared with the OpenAI-completions and
|
|
106
|
+
* Anthropic providers via `withEmptyCompletionRetry`.
|
|
107
|
+
*/
|
|
108
|
+
export declare const streamOpenAIResponses: StreamFunction<"openai-responses">;
|
|
109
|
+
export declare function buildParams(model: Model<"openai-responses">, context: Context, options: OpenAIResponsesOptions | undefined, providerSessionState: OpenAIResponsesProviderSessionState | undefined, strictToolsScope?: OpenAIStrictToolsScope, disableStrictToolsOverride?: boolean): {
|
|
110
|
+
params: OpenAIResponsesSamplingParams;
|
|
111
|
+
trailingScaffoldingItems: number;
|
|
112
|
+
strictToolsApplied: boolean;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Whether this model should get the OpenAI custom-tool grammar variant
|
|
116
|
+
* for `apply_patch`. The generated model catalog sets
|
|
117
|
+
* `model.applyPatchToolType` for first-party GPT-5 Responses models; this
|
|
118
|
+
* runtime path only consumes that metadata.
|
|
119
|
+
* @internal Exported for tests.
|
|
120
|
+
*/
|
|
121
|
+
export declare function supportsFreeformApplyPatch(model: Model<"openai-responses" | "azure-openai-responses" | "openai-codex-responses">): boolean;
|
|
122
|
+
/** @internal Exported for tests. */
|
|
123
|
+
export declare function mapOpenAIResponsesToolChoiceForTools(choice: ToolChoice | undefined, tools: Tool[], model: Model<"openai-responses">): OpenAIResponsesToolChoice;
|
|
124
|
+
/** @internal Exported for tests. */
|
|
125
|
+
export declare function convertTools(tools: Tool[], strictMode: boolean, model: Model<"openai-responses" | "azure-openai-responses" | "openai-codex-responses">, onQuarantine?: (toolName: string, schemaPath: string) => void): OpenAITool[];
|
|
126
|
+
export {};
|
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import type { OpenAICompat, OpenAIReasoningDisableMode, OpenAIStreamMarkupHealingPattern, OpenRouterRouting, ResolvedOpenAICompat, ResolvedOpenAIResponsesCompat, ResolvedOpenAISharedCompat, VercelGatewayRouting } from "jeopi-catalog/types";
|
|
2
|
+
import { type Api, type AssistantMessage, type CacheRetention, type Context, type ImageContent, type Message, type MessageAttribution, type Model, type Provider, type ServiceTier, type StopReason, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingContent, type Tool, type ToolCall, type ToolResultMessage } from "../types";
|
|
3
|
+
import { kStreamingLastParseLen, kStreamingPartialJson } from "../utils/block-symbols";
|
|
4
|
+
import type { AssistantMessageEventStream } from "../utils/event-stream";
|
|
5
|
+
import type { CapturedHttpErrorResponse } from "../utils/http-inspector";
|
|
6
|
+
import type { ChatCompletionCreateParamsStreaming } from "./openai-chat-wire";
|
|
7
|
+
import type { InputItem } from "./openai-codex/request-transformer";
|
|
8
|
+
import type { ResponseContentPartAddedEvent, ResponseCreateParamsStreaming, ResponseInput, ResponseInputContent, ResponseInputItem, ResponseOutputItem, ResponseOutputMessage, ResponseReasoningItem, ResponseStatus, ResponseStreamEvent } from "./openai-responses-wire";
|
|
9
|
+
export interface OpenAIModelIdentity {
|
|
10
|
+
provider: string;
|
|
11
|
+
id: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface OpenAIStrictToolsScope {
|
|
15
|
+
provider: string;
|
|
16
|
+
baseUrl: string | undefined;
|
|
17
|
+
modelId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface OpenAIStrictToolsState {
|
|
20
|
+
strictTools: {
|
|
21
|
+
disabledModelScopes: Set<string>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface OpenAIRequestSetupModel extends OpenAIModelIdentity {
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
premiumMultiplier?: number;
|
|
27
|
+
compat?: Pick<ResolvedOpenAISharedCompat, "promptCacheSessionHeader">;
|
|
28
|
+
}
|
|
29
|
+
export interface OpenAIResponsesCacheOptions {
|
|
30
|
+
cacheRetention?: CacheRetention;
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
promptCacheKey?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface OpenAIRequestSetupOptions {
|
|
35
|
+
apiKey?: string;
|
|
36
|
+
extraHeaders?: Record<string, string>;
|
|
37
|
+
initiatorOverride?: MessageAttribution;
|
|
38
|
+
messages: Message[];
|
|
39
|
+
defaultBaseUrl?: string;
|
|
40
|
+
prependHeaders?: () => Record<string, string>;
|
|
41
|
+
alibabaCodingPlanAuth?: boolean;
|
|
42
|
+
azureChatCompletions?: {
|
|
43
|
+
apiVersion: string;
|
|
44
|
+
deploymentName: string;
|
|
45
|
+
};
|
|
46
|
+
openAISessionId?: string;
|
|
47
|
+
promptCacheSessionId?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface OpenAIRequestSetup {
|
|
50
|
+
copilotPremiumRequests: number | undefined;
|
|
51
|
+
baseUrl: string | undefined;
|
|
52
|
+
headers: Record<string, string>;
|
|
53
|
+
query: Record<string, string> | undefined;
|
|
54
|
+
requestHeaders: Record<string, string>;
|
|
55
|
+
}
|
|
56
|
+
export declare function resolveOpenAIRequestSetup(model: OpenAIRequestSetupModel, options: OpenAIRequestSetupOptions): OpenAIRequestSetup;
|
|
57
|
+
export declare function applyOpenAIServiceTier(params: {
|
|
58
|
+
service_tier?: ServiceTier | null | undefined;
|
|
59
|
+
}, serviceTier: ServiceTier | null | undefined, provider: Provider | undefined): void;
|
|
60
|
+
/**
|
|
61
|
+
* Adjust resolved cost by the service tier OpenAI actually billed — parity with
|
|
62
|
+
* Codex (`applyCodexServiceTierPricing`), but with the standard (non-Codex)
|
|
63
|
+
* multipliers. The served tier comes from the response echo, falling back to the
|
|
64
|
+
* resolved request tier. Scoped to `provider: "openai"` (the only standard
|
|
65
|
+
* Responses biller) so an echoed `service_tier` from an Azure/OpenRouter/Copilot
|
|
66
|
+
* proxy can never skew those costs.
|
|
67
|
+
*/
|
|
68
|
+
export declare function applyOpenAIResponsesServiceTierCost(model: Pick<Model, "provider">, usage: AssistantMessage["usage"], responseServiceTier: unknown, requestServiceTier: ServiceTier | null | undefined): void;
|
|
69
|
+
export interface OpenAIUsageAccountingInput {
|
|
70
|
+
promptTokens: number;
|
|
71
|
+
outputTokens: number;
|
|
72
|
+
cachedTokens: number;
|
|
73
|
+
reasoningTokens: number;
|
|
74
|
+
cacheWriteOpenRouter: number | undefined;
|
|
75
|
+
cacheWriteDeepSeek: number | undefined;
|
|
76
|
+
hasDeepSeekCacheHitAndMiss: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface OpenAIUsageAccounting {
|
|
79
|
+
input: number;
|
|
80
|
+
output: number;
|
|
81
|
+
cacheRead: number;
|
|
82
|
+
cacheWrite: number;
|
|
83
|
+
totalTokens: number;
|
|
84
|
+
reasoningTokens?: number;
|
|
85
|
+
}
|
|
86
|
+
export declare function calculateOpenAIUsageAccounting(accounting: OpenAIUsageAccountingInput): OpenAIUsageAccounting;
|
|
87
|
+
export declare function normalizeOpenAIResponsesPromptCacheKey(sessionId: string | undefined): string | undefined;
|
|
88
|
+
export declare function normalizeOpenRouterResponsesSessionId(sessionId: string | undefined): string | undefined;
|
|
89
|
+
export declare function getOpenAIResponsesPromptCacheKey(options: OpenAIResponsesCacheOptions | undefined): string | undefined;
|
|
90
|
+
export declare function getOpenAIResponsesRoutingSessionId(options: Pick<OpenAIResponsesCacheOptions, "cacheRetention" | "sessionId"> | undefined): string | undefined;
|
|
91
|
+
export declare function getOpenRouterResponsesSessionId(options: Pick<OpenAIResponsesCacheOptions, "cacheRetention" | "sessionId"> | undefined): string | undefined;
|
|
92
|
+
export declare function parseAzureDeploymentNameMap(value: string | undefined): Map<string, string>;
|
|
93
|
+
export declare function createOpenAIStrictToolsState(): OpenAIStrictToolsState;
|
|
94
|
+
export declare function clearOpenAIStrictToolsState(state: OpenAIStrictToolsState): void;
|
|
95
|
+
export declare function getOpenAIStrictToolsScope(model: OpenAIModelIdentity, resolvedBaseUrl: string | undefined): OpenAIStrictToolsScope;
|
|
96
|
+
export declare function isStrictToolsDisabledForScope(state: OpenAIStrictToolsState | undefined, scope: OpenAIStrictToolsScope | undefined): boolean;
|
|
97
|
+
export declare function disableStrictToolsForScope(state: OpenAIStrictToolsState | undefined, scope: OpenAIStrictToolsScope | undefined): void;
|
|
98
|
+
export declare function isOpenRouterAnthropicModel(model: OpenAIModelIdentity): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Append an OpenRouter routing-variant suffix (e.g. `:nitro`, `:floor`, `:online`, `:exacto`)
|
|
101
|
+
* to a model id when no explicit variant is already present. A variant is considered
|
|
102
|
+
* "already present" when `modelId` contains a colon after the last `/` separator —
|
|
103
|
+
* which covers both user-typed selectors (`anthropic/claude-haiku:nitro`) and catalog
|
|
104
|
+
* entries that bake the variant in (`deepseek/deepseek-v3.1-terminus:exacto`).
|
|
105
|
+
*/
|
|
106
|
+
export declare function applyOpenRouterRoutingVariant(modelId: string, variant: string | undefined): string;
|
|
107
|
+
export declare function applyWireModelIdTransform(baseId: string, mode: ResolvedOpenAISharedCompat["wireModelIdMode"], openrouterVariant?: string): string;
|
|
108
|
+
export interface OpenAIOutputTokenParam {
|
|
109
|
+
field: "max_tokens" | "max_completion_tokens" | "max_output_tokens";
|
|
110
|
+
value: number;
|
|
111
|
+
}
|
|
112
|
+
export interface ResolveOpenAIOutputTokenInput {
|
|
113
|
+
/** Wire field the endpoint expects for the output cap. */
|
|
114
|
+
field: OpenAIOutputTokenParam["field"];
|
|
115
|
+
/** Caller-supplied output cap (model-defaulted by `stream.ts`, or null/undefined on direct provider calls). */
|
|
116
|
+
maxTokens: number | null | undefined;
|
|
117
|
+
/** Whether the caller explicitly set `maxTokens` (routing omission only applies when false). */
|
|
118
|
+
maxTokensExplicit: boolean;
|
|
119
|
+
/** Model output cap (`model.maxTokens`). */
|
|
120
|
+
modelMaxTokens: number | null | undefined;
|
|
121
|
+
/** Drop the field entirely — proxies with unknown upstream caps (Ollama via `model.omitMaxOutputTokens`). */
|
|
122
|
+
omitMaxOutputTokens: boolean;
|
|
123
|
+
/** The model sits behind OpenRouter (catalog default caps are omitted so each upstream self-caps). */
|
|
124
|
+
isOpenRouterHost: boolean;
|
|
125
|
+
/** Endpoint always needs a cap (Kimi-family TPM math); supplies the model default when the caller did not. */
|
|
126
|
+
alwaysSendMaxTokens: boolean;
|
|
127
|
+
/** Hard provider clamp; defaults to {@link OPENAI_MAX_OUTPUT_TOKENS}. */
|
|
128
|
+
providerOutputClamp?: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Resolve the single output-token wire parameter shared by Chat Completions
|
|
132
|
+
* (`max_tokens`/`max_completion_tokens`) and the Responses family
|
|
133
|
+
* (`max_output_tokens`). Centralizes the provider exceptions that previously
|
|
134
|
+
* lived inline in both `buildParams`:
|
|
135
|
+
* - `alwaysSendMaxTokens`: Kimi-family endpoints derive TPM limits from the
|
|
136
|
+
* cap and require one on every call, so default from the model cap (or
|
|
137
|
+
* {@link OPENAI_MAX_OUTPUT_TOKENS}) when the caller omitted it.
|
|
138
|
+
* - OpenRouter routing omission: OpenRouter fans out to upstreams whose output
|
|
139
|
+
* caps differ from the catalog value, so a catalog default above the routed
|
|
140
|
+
* upstream's cap makes OpenRouter skip that upstream. Omit catalog defaults
|
|
141
|
+
* (explicit caller caps still win) so `provider.order`/`only` is honored.
|
|
142
|
+
* - model/provider clamp: never exceed `model.maxTokens` or the provider clamp
|
|
143
|
+
* (`OPENAI_MAX_OUTPUT_TOKENS`, raised for GLM-5.2 reasoning by the caller).
|
|
144
|
+
* - `omitMaxOutputTokens`: proxies (Ollama) with unknown upstream caps drop it.
|
|
145
|
+
*/
|
|
146
|
+
export declare function resolveOpenAIOutputTokenParam(input: ResolveOpenAIOutputTokenInput): OpenAIOutputTokenParam | undefined;
|
|
147
|
+
export interface OpenAIGatewayRoutingParams {
|
|
148
|
+
provider?: OpenRouterRouting;
|
|
149
|
+
providerOptions?: {
|
|
150
|
+
gateway?: {
|
|
151
|
+
only?: string[];
|
|
152
|
+
order?: string[];
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export interface OpenAIGatewayRoutingCompat {
|
|
157
|
+
isOpenRouterHost: boolean;
|
|
158
|
+
openRouterRouting?: OpenRouterRouting;
|
|
159
|
+
isVercelGatewayHost?: boolean;
|
|
160
|
+
vercelGatewayRouting?: VercelGatewayRouting;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Apply gateway routing preferences to the request body. OpenRouter routes via
|
|
164
|
+
* the top-level `provider` field; the Vercel AI Gateway routes via
|
|
165
|
+
* `providerOptions.gateway`. Both Chat Completions and Responses call this; the
|
|
166
|
+
* Vercel branch is inert for Responses, whose resolved compat never sets
|
|
167
|
+
* `isVercelGatewayHost`.
|
|
168
|
+
*/
|
|
169
|
+
export declare function applyOpenAIGatewayRouting(params: OpenAIGatewayRoutingParams, compat: OpenAIGatewayRoutingCompat): void;
|
|
170
|
+
export interface OpenAIExtraBodyOptions {
|
|
171
|
+
/**
|
|
172
|
+
* Fireworks rejects DeepSeek-style `thinking` toggles alongside OpenAI-style
|
|
173
|
+
* `reasoning_effort`; drop `thinking` when the effort field carries the level.
|
|
174
|
+
*/
|
|
175
|
+
dropThinkingWhenReasoningEffort?: boolean;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Merge a compat/options `extraBody` blob into the request params. When
|
|
179
|
+
* `dropThinkingWhenReasoningEffort` is set and `reasoning_effort` is present,
|
|
180
|
+
* delete the conflicting `thinking` toggle (Fireworks rejects both together).
|
|
181
|
+
*/
|
|
182
|
+
export declare function applyOpenAIExtraBody<P extends object>(params: P, extraBody: Record<string, unknown> | undefined, options?: OpenAIExtraBodyOptions): void;
|
|
183
|
+
/**
|
|
184
|
+
* Chat Completions streaming request body shaped by the OpenAI-family providers.
|
|
185
|
+
* Extends the vendored SDK params with the compat dialect fields pi-ai emits
|
|
186
|
+
* (binary `thinking`, Qwen `enable_thinking`/`chat_template_kwargs`, nested
|
|
187
|
+
* `reasoning`, gateway `provider`/`providerOptions`, sampling extras). Lives in
|
|
188
|
+
* the shared module beside the request-shaping helpers that mutate it.
|
|
189
|
+
*/
|
|
190
|
+
export type OpenAICompletionsParams = Omit<ChatCompletionCreateParamsStreaming, "reasoning_effort" | "service_tier"> & {
|
|
191
|
+
top_k?: number;
|
|
192
|
+
min_p?: number;
|
|
193
|
+
repetition_penalty?: number;
|
|
194
|
+
thinking?: {
|
|
195
|
+
type: "enabled" | "disabled";
|
|
196
|
+
keep?: "all";
|
|
197
|
+
};
|
|
198
|
+
enable_thinking?: boolean;
|
|
199
|
+
preserve_thinking?: boolean;
|
|
200
|
+
chat_template_kwargs?: {
|
|
201
|
+
enable_thinking?: boolean;
|
|
202
|
+
preserve_thinking?: boolean;
|
|
203
|
+
};
|
|
204
|
+
reasoning?: {
|
|
205
|
+
effort?: string;
|
|
206
|
+
} | {
|
|
207
|
+
enabled: false;
|
|
208
|
+
};
|
|
209
|
+
reasoning_effort?: string | null;
|
|
210
|
+
service_tier?: ServiceTier;
|
|
211
|
+
tool_stream?: boolean;
|
|
212
|
+
provider?: OpenAICompat["openRouterRouting"];
|
|
213
|
+
providerOptions?: {
|
|
214
|
+
gateway?: {
|
|
215
|
+
only?: string[];
|
|
216
|
+
order?: string[];
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
/** Reasoning-relevant slice of caller options the Chat Completions dialect dispatch reads. */
|
|
221
|
+
export interface ChatCompletionsReasoningOptions {
|
|
222
|
+
reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
223
|
+
disableReasoning?: boolean;
|
|
224
|
+
}
|
|
225
|
+
export type OpenAICompatEndpoint = "chat-completions" | "responses";
|
|
226
|
+
export type OpenAIReasoningDisableReason = "caller" | "forced-tool-choice" | "tool-choice" | "not-requested";
|
|
227
|
+
export type OpenAICompatPolicyCompat = ResolvedOpenAISharedCompat & Partial<ResolvedOpenAICompat> & Partial<ResolvedOpenAIResponsesCompat>;
|
|
228
|
+
export interface ResolveOpenAICompatPolicyOptions {
|
|
229
|
+
endpoint: OpenAICompatEndpoint;
|
|
230
|
+
compat?: OpenAICompatPolicyCompat;
|
|
231
|
+
reasoning?: string;
|
|
232
|
+
disableReasoning?: boolean;
|
|
233
|
+
toolChoice?: unknown;
|
|
234
|
+
strictResponsesPairing?: boolean;
|
|
235
|
+
includeEncryptedReasoning?: boolean;
|
|
236
|
+
filterReasoningHistory?: boolean;
|
|
237
|
+
omitReasoningEffort?: boolean;
|
|
238
|
+
}
|
|
239
|
+
export interface OpenAICompatPolicy {
|
|
240
|
+
endpoint: OpenAICompatEndpoint;
|
|
241
|
+
compat: OpenAICompatPolicyCompat;
|
|
242
|
+
reasoning: {
|
|
243
|
+
modelSupported: boolean;
|
|
244
|
+
supportsParams: boolean;
|
|
245
|
+
requestedEffort?: string;
|
|
246
|
+
wireEffort?: string;
|
|
247
|
+
enabled: boolean;
|
|
248
|
+
disabled: boolean;
|
|
249
|
+
disableReason?: OpenAIReasoningDisableReason;
|
|
250
|
+
dialect: ResolvedOpenAISharedCompat["thinkingFormat"];
|
|
251
|
+
disableMode: OpenAIReasoningDisableMode;
|
|
252
|
+
omitReasoningEffort: boolean;
|
|
253
|
+
includeEncryptedReasoning: boolean;
|
|
254
|
+
filterReasoningHistory: boolean;
|
|
255
|
+
requiresReasoningContentForToolCalls: boolean;
|
|
256
|
+
requiresReasoningContentForAllAssistantTurns: boolean;
|
|
257
|
+
allowsSyntheticReasoningContentForToolCalls: boolean;
|
|
258
|
+
reasoningContentField?: OpenAICompat["reasoningContentField"];
|
|
259
|
+
requiresThinkingAsText: boolean;
|
|
260
|
+
};
|
|
261
|
+
tools: {
|
|
262
|
+
strictResponsesPairing: boolean;
|
|
263
|
+
toolCallIdKind: "default" | "openai-40" | "mistral-9-alnum";
|
|
264
|
+
};
|
|
265
|
+
messages: {
|
|
266
|
+
systemRole: "system" | "developer";
|
|
267
|
+
supportsDeveloperRole: boolean;
|
|
268
|
+
supportsMultipleSystemMessages: boolean;
|
|
269
|
+
};
|
|
270
|
+
stream: {
|
|
271
|
+
stripSpecialTokens: "deepseek" | false;
|
|
272
|
+
markupHealingPattern?: OpenAIStreamMarkupHealingPattern;
|
|
273
|
+
reasoningDeltasMayBeCumulative: boolean;
|
|
274
|
+
emptyLengthFinishIsContextError: boolean;
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
export declare function resolveOpenAICompatPolicy<TApi extends Api>(model: Model<TApi>, options: ResolveOpenAICompatPolicyOptions): OpenAICompatPolicy;
|
|
278
|
+
export declare function applyChatCompletionsCompatPolicy(params: OpenAICompletionsParams, policy: OpenAICompatPolicy): void;
|
|
279
|
+
export declare function applyChatCompletionsReasoningParams(params: OpenAICompletionsParams, model: Model<"openai-completions">, compat: ResolvedOpenAICompat, options: (ChatCompletionsReasoningOptions & {
|
|
280
|
+
toolChoice?: unknown;
|
|
281
|
+
}) | undefined): void;
|
|
282
|
+
export declare function disableChatCompletionsReasoningForDialect(params: OpenAICompletionsParams, compat: ResolvedOpenAICompat): void;
|
|
283
|
+
/**
|
|
284
|
+
* Output-token clamp for the Z.AI/GLM-5.2 reasoning dialect: these hosts accept
|
|
285
|
+
* the full model window on reasoning turns, so clamp to the model cap. Returns
|
|
286
|
+
* `undefined` for every other model, leaving {@link resolveOpenAIOutputTokenParam}
|
|
287
|
+
* on its default `OPENAI_MAX_OUTPUT_TOKENS` clamp.
|
|
288
|
+
*/
|
|
289
|
+
export declare function resolveZaiReasoningOutputClamp(model: Model<"openai-completions">, compat: ResolvedOpenAICompat): number | undefined;
|
|
290
|
+
/**
|
|
291
|
+
* Enable `tool_stream` for Z.AI/GLM-5.2 reasoning models when tools are present
|
|
292
|
+
* (GLM-5.2 streams tool-call arguments incrementally and needs the flag to do so).
|
|
293
|
+
*/
|
|
294
|
+
export declare function applyChatCompletionsToolStream(params: OpenAICompletionsParams, model: Model<"openai-completions">, compat: ResolvedOpenAICompat): void;
|
|
295
|
+
export declare function isCompiledGrammarTooLargeStrictError(error: unknown, capturedErrorResponse: CapturedHttpErrorResponse | undefined): boolean;
|
|
296
|
+
export declare function shouldRetryWithoutStrictTools(error: unknown, capturedErrorResponse: CapturedHttpErrorResponse | undefined, strictToolsApplied: boolean, tools: Tool[] | undefined): boolean;
|
|
297
|
+
export declare const OPENAI_RESPONSES_PROGRESS_EVENT_TYPES: ReadonlySet<string>;
|
|
298
|
+
export declare function isOpenAIResponsesProgressEvent(event: unknown): boolean;
|
|
299
|
+
export declare function encodeTextSignatureV1(id: string, phase?: TextSignatureV1["phase"]): string;
|
|
300
|
+
export declare function parseTextSignature(signature: string | undefined): {
|
|
301
|
+
id: string;
|
|
302
|
+
phase?: TextSignatureV1["phase"];
|
|
303
|
+
} | undefined;
|
|
304
|
+
export declare function encodeResponsesToolCallId(callId: string, itemId: string | null | undefined): string;
|
|
305
|
+
export declare function normalizeResponsesToolCallIdForTransform(id: string, model?: Model<Api>, source?: AssistantMessage): string;
|
|
306
|
+
export declare function collectKnownCallIds(messages: ResponseInput): Set<string>;
|
|
307
|
+
/** Scan replay items for call_ids that were originally custom tool calls. */
|
|
308
|
+
export declare function collectCustomCallIds(messages: ResponseInput): Set<string>;
|
|
309
|
+
/**
|
|
310
|
+
* Convert orphan `function_call_output` / `custom_tool_call_output` items —
|
|
311
|
+
* those whose `call_id` has no matching preceding `function_call` /
|
|
312
|
+
* `custom_tool_call` in the same input — into assistant text notes.
|
|
313
|
+
*
|
|
314
|
+
* The Responses API rejects unpaired outputs with
|
|
315
|
+
* `400 No tool call found for function call output with call_id …`. Orphans
|
|
316
|
+
* sneak in through two paths today:
|
|
317
|
+
*
|
|
318
|
+
* - A previous turn's `providerPayload` snapshot replaces the input array via
|
|
319
|
+
* the `dt: false` splice (see {@link convertConversationMessages}), wiping
|
|
320
|
+
* the matching `function_call` while leaving the matching
|
|
321
|
+
* `function_call_output` queued in a later `toolResult`.
|
|
322
|
+
* - A locally-rejected tool call (argument-validation failure, hook reject,
|
|
323
|
+
* aborted turn before the call streamed) produces a tool result without a
|
|
324
|
+
* `function_call` ever landing in any persisted provider payload.
|
|
325
|
+
*
|
|
326
|
+
* Dropping the result loses information the model needs to recover; sending
|
|
327
|
+
* it as-is 400s the request. Folding it into an assistant `message` preserves
|
|
328
|
+
* the payload (call_id + truncated output) while staying within the Responses
|
|
329
|
+
* input grammar. Matches the behavior of {@link transformRequestBody} in the
|
|
330
|
+
* codex provider — issue #1351 / regression of #472.
|
|
331
|
+
*/
|
|
332
|
+
export declare function repairOrphanResponsesToolOutputs(input: ResponseInput): ResponseInput;
|
|
333
|
+
/**
|
|
334
|
+
* Synthesize a placeholder `function_call_output` / `custom_tool_call_output`
|
|
335
|
+
* for every `function_call` / `custom_tool_call` whose `call_id` has no matching
|
|
336
|
+
* output later in the same input. The Responses API rejects an unpaired call
|
|
337
|
+
* with `400 No tool output found for function call …`.
|
|
338
|
+
*
|
|
339
|
+
* Orphan calls surface when the user branches/navigates the session tree to a
|
|
340
|
+
* node that ends on a tool call (the tool-result child is excluded from the
|
|
341
|
+
* reconstructed history) or when a turn is aborted/crashes after the call
|
|
342
|
+
* streamed but before its result persisted. Dropping the call would erase the
|
|
343
|
+
* assistant's action; a placeholder output keeps the call visible so the model
|
|
344
|
+
* can recover (e.g. re-issue the call). Symmetric to
|
|
345
|
+
* {@link repairOrphanResponsesToolOutputs}.
|
|
346
|
+
*/
|
|
347
|
+
export declare function repairOrphanResponsesToolCalls(input: ResponseInput): ResponseInput;
|
|
348
|
+
export declare function convertResponsesInputContent(content: string | Array<TextContent | ImageContent>, supportsImages: boolean, supportsImageDetailOriginal: boolean): ResponseInputContent[] | undefined;
|
|
349
|
+
export interface BuildResponsesInputOptions<TApi extends Api> {
|
|
350
|
+
model: Model<TApi>;
|
|
351
|
+
context: Context;
|
|
352
|
+
strictResponsesPairing: boolean;
|
|
353
|
+
supportsImageDetailOriginal: boolean;
|
|
354
|
+
systemRole?: "system" | "developer";
|
|
355
|
+
nativeHistory?: {
|
|
356
|
+
replay: boolean;
|
|
357
|
+
filterReasoning: boolean;
|
|
358
|
+
};
|
|
359
|
+
includeThinkingSignatures?: boolean;
|
|
360
|
+
developerStringContent?: boolean;
|
|
361
|
+
repairOrphanOutputs?: boolean;
|
|
362
|
+
/** Preserve assistant message item IDs from text signatures during fallback replay. */
|
|
363
|
+
preserveAssistantMessageIds?: boolean;
|
|
364
|
+
}
|
|
365
|
+
export declare function buildResponsesInput<TApi extends Api>(options: BuildResponsesInputOptions<TApi>): ResponseInput;
|
|
366
|
+
export declare function convertResponsesAssistantMessage<TApi extends Api>(assistantMsg: AssistantMessage, model: Model<TApi>, msgIndex: number, knownCallIds: Set<string>, includeThinkingSignatures?: boolean, customCallIds?: Set<string>, preserveMessageIds?: boolean): ResponseInput;
|
|
367
|
+
export declare function appendResponsesToolResultMessages<TApi extends Api>(messages: ResponseInput, toolResult: ToolResultMessage, model: Model<TApi>, strictResponsesPairing: boolean, supportsImageDetailOriginal: boolean, knownCallIds: ReadonlySet<string>, customCallIds?: ReadonlySet<string>): void;
|
|
368
|
+
/**
|
|
369
|
+
* Per-block accumulation helpers shared by the two Responses decode loops —
|
|
370
|
+
* {@link processResponsesStream} (generic Responses) and the Codex stream
|
|
371
|
+
* handler in `openai-codex-responses.ts`. Each endpoint keeps its own
|
|
372
|
+
* item-routing, terminal handling, and transport bookkeeping; these own only
|
|
373
|
+
* the leaf mutations on an already-resolved open block, so the
|
|
374
|
+
* append/parse/finalize logic lives in exactly one place. The caller passes the
|
|
375
|
+
* `contentIndex` its router resolved (generic uses `output.content.indexOf`;
|
|
376
|
+
* Codex uses the open item's recorded index) so the emitted stream events match
|
|
377
|
+
* each decoder's existing behavior byte-for-byte.
|
|
378
|
+
*/
|
|
379
|
+
type ResponsesToolCallBlock = ToolCall & {
|
|
380
|
+
[kStreamingPartialJson]: string;
|
|
381
|
+
[kStreamingLastParseLen]?: number;
|
|
382
|
+
};
|
|
383
|
+
export declare function appendReasoningSummaryPart(item: ResponseReasoningItem, part: ResponseReasoningItem["summary"][number]): void;
|
|
384
|
+
export declare function appendReasoningSummaryTextDelta(item: ResponseReasoningItem, block: ThinkingContent, delta: string, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number): void;
|
|
385
|
+
export declare function appendReasoningSummaryPartDone(item: ResponseReasoningItem, block: ThinkingContent, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number): void;
|
|
386
|
+
export declare function appendMessageContentPart(item: ResponseOutputMessage, part: ResponseContentPartAddedEvent["part"] | undefined): void;
|
|
387
|
+
export declare function appendMessageTextDelta(item: ResponseOutputMessage, block: TextContent, delta: string, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number, partType: "output_text" | "refusal"): void;
|
|
388
|
+
export declare function accumulateToolCallArgumentsDelta(block: ResponsesToolCallBlock, delta: string, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number): void;
|
|
389
|
+
/**
|
|
390
|
+
* Finalize streamed function-call arguments from the authoritative `.done`
|
|
391
|
+
* payload. The caller owns the `argumentsDone` flag (generic Responses sets it;
|
|
392
|
+
* Codex's block shape has no such field), so this only rewrites `arguments` and
|
|
393
|
+
* drops the transient accumulation fields.
|
|
394
|
+
*/
|
|
395
|
+
export declare function finalizeToolCallArgumentsDone(block: ResponsesToolCallBlock, args: string): void;
|
|
396
|
+
export declare function accumulateCustomToolCallInputDelta(block: ResponsesToolCallBlock, delta: string, stream: AssistantMessageEventStream, output: AssistantMessage, contentIndex: number): void;
|
|
397
|
+
export declare function finalizeCustomToolCallInputDone(block: ResponsesToolCallBlock, input: string): void;
|
|
398
|
+
export interface ProcessResponsesStreamOptions {
|
|
399
|
+
onFirstToken?: () => void;
|
|
400
|
+
onOutputItemDone?: (item: ResponseOutputItem) => void;
|
|
401
|
+
/**
|
|
402
|
+
* Called when a terminal `response.completed` or `response.incomplete` event
|
|
403
|
+
* is successfully processed. Only invoked on the successful-completion path;
|
|
404
|
+
* thrown failure (`response.failed`) and cancellation paths never call this.
|
|
405
|
+
* Used by callers to detect premature stream closure (i.e. the stream ended
|
|
406
|
+
* without a recognized terminal event).
|
|
407
|
+
*/
|
|
408
|
+
onCompleted?: () => void;
|
|
409
|
+
/**
|
|
410
|
+
* Caller-requested service tier, used to bill the served tier when the
|
|
411
|
+
* response omits the `service_tier` echo. Only applied for `provider: "openai"`.
|
|
412
|
+
*/
|
|
413
|
+
requestServiceTier?: ServiceTier;
|
|
414
|
+
}
|
|
415
|
+
export declare function processResponsesStream<TApi extends Api>(openaiStream: AsyncIterable<ResponseStreamEvent>, output: AssistantMessage, stream: AssistantMessageEventStream, model: Model<TApi>, options?: ProcessResponsesStreamOptions): Promise<void>;
|
|
416
|
+
export declare function mapOpenAIResponsesStopReason(status: ResponseStatus | undefined): StopReason;
|
|
417
|
+
/**
|
|
418
|
+
* Finalize any streamed toolCall block whose `output_item.done` never arrived
|
|
419
|
+
* (lossy proxy, or a terminal event that raced the per-item done): parse the
|
|
420
|
+
* accumulated `partialJson` into authoritative arguments and strip the transient
|
|
421
|
+
* streaming fields so they never persist. Shared by the chat-Responses decoder
|
|
422
|
+
* and the Codex decoder. Closed blocks already cleared these fields, so walking
|
|
423
|
+
* the full content list leaves them untouched.
|
|
424
|
+
*/
|
|
425
|
+
export declare function finalizePendingResponsesToolCalls(output: AssistantMessage): void;
|
|
426
|
+
/**
|
|
427
|
+
* Apply the Responses terminal stop-reason invariants shared by the chat-Responses
|
|
428
|
+
* and Codex decoders: a turn that produced tool calls becomes `toolUse`, and a
|
|
429
|
+
* Codex-lineage `end_turn: false` marker pauses the turn so the agent loop
|
|
430
|
+
* re-samples instead of ending. Callers set `output.stopReason` from the wire
|
|
431
|
+
* status first via {@link mapOpenAIResponsesStopReason}.
|
|
432
|
+
*/
|
|
433
|
+
export declare function promoteResponsesToolUseStopReason(output: AssistantMessage, endTurn: boolean | undefined): void;
|
|
434
|
+
/** Initial empty `AssistantMessage` that streaming providers accumulate into. */
|
|
435
|
+
export declare function createInitialResponsesAssistantMessage(api: Api, provider: string, modelId: string): AssistantMessage;
|
|
436
|
+
/** Extension fields we add on top of `ResponseCreateParamsStreaming` across the Responses-family providers. */
|
|
437
|
+
export type ResponsesSamplingParamsExtras = {
|
|
438
|
+
top_p?: number;
|
|
439
|
+
top_k?: number;
|
|
440
|
+
min_p?: number;
|
|
441
|
+
presence_penalty?: number;
|
|
442
|
+
repetition_penalty?: number;
|
|
443
|
+
};
|
|
444
|
+
type CommonResponsesParams = ResponseCreateParamsStreaming & ResponsesSamplingParamsExtras;
|
|
445
|
+
type CommonSamplingOptions = Pick<StreamOptions, "temperature" | "topP" | "topK" | "minP" | "presencePenalty" | "repetitionPenalty" | "maxTokens"> & {
|
|
446
|
+
serviceTier?: ServiceTier;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Apply the common `StreamOptions` → Responses sampling-parameter mapping (max output tokens,
|
|
450
|
+
* temperature, top-p/k, min-p, presence/repetition penalties, service tier). Mutates `params`.
|
|
451
|
+
*
|
|
452
|
+
* `max_output_tokens` is suppressed when {@link Model.omitMaxOutputTokens} is `true`, so
|
|
453
|
+
* proxies (notably Ollama) that forward to upstream APIs with an unknown output-token cap
|
|
454
|
+
* can let the upstream apply its own default instead of 400-ing on `maxTokens` values that
|
|
455
|
+
* reflect the model's context window rather than the upstream output limit.
|
|
456
|
+
*/
|
|
457
|
+
export declare function applyCommonResponsesSamplingParams<P extends CommonResponsesParams>(params: P, options: CommonSamplingOptions | undefined, model: Pick<Model, "provider" | "omitMaxOutputTokens" | "maxTokens">): void;
|
|
458
|
+
type ReasoningOptions = {
|
|
459
|
+
reasoning?: string;
|
|
460
|
+
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
461
|
+
disableReasoning?: boolean;
|
|
462
|
+
toolChoice?: unknown;
|
|
463
|
+
};
|
|
464
|
+
export interface ApplyResponsesCompatPolicyOptions {
|
|
465
|
+
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
466
|
+
mapEffort?: (effort: string) => string;
|
|
467
|
+
}
|
|
468
|
+
export declare function applyResponsesCompatPolicy<P extends ResponseCreateParamsStreaming>(params: P, messages: ResponseInput, policy: OpenAICompatPolicy, options: ApplyResponsesCompatPolicyOptions | undefined): number;
|
|
469
|
+
/**
|
|
470
|
+
* Apply reasoning-related Responses parameters. Default behavior comes from
|
|
471
|
+
* catalog compat; include/omit arguments are explicit adapter-wrapper overrides.
|
|
472
|
+
*/
|
|
473
|
+
export declare function applyResponsesReasoningParams<P extends ResponseCreateParamsStreaming>(params: P, model: Model<"openai-responses" | "azure-openai-responses" | "openai-codex-responses">, options: ReasoningOptions | undefined, messages: ResponseInput, mapEffort?: (effort: string) => string, includeEncryptedReasoning?: boolean, omitReasoningEffort?: boolean): number;
|
|
474
|
+
/** Populate `output.usage` from a Responses-API `response.usage` payload. Does not invoke `calculateCost`. */
|
|
475
|
+
export declare function populateResponsesUsageFromResponse(output: AssistantMessage, usage: {
|
|
476
|
+
input_tokens?: number | null;
|
|
477
|
+
output_tokens?: number | null;
|
|
478
|
+
total_tokens?: number | null;
|
|
479
|
+
prompt_cache_hit_tokens?: number | null;
|
|
480
|
+
prompt_cache_miss_tokens?: number | null;
|
|
481
|
+
input_tokens_details?: {
|
|
482
|
+
cached_tokens?: number | null;
|
|
483
|
+
cache_write_tokens?: number | null;
|
|
484
|
+
orchestration_input_tokens?: number | null;
|
|
485
|
+
orchestration_input_cached_tokens?: number | null;
|
|
486
|
+
} | null;
|
|
487
|
+
output_tokens_details?: {
|
|
488
|
+
reasoning_tokens?: number | null;
|
|
489
|
+
orchestration_output_tokens?: number | null;
|
|
490
|
+
} | null;
|
|
491
|
+
} | null | undefined): void;
|
|
492
|
+
/**
|
|
493
|
+
* Strict-prefix delta for stateful `previous_response_id` chaining (used by the
|
|
494
|
+
* platform Responses provider and the Codex provider on both transports):
|
|
495
|
+
* returns the input items the current request appends beyond the previous
|
|
496
|
+
* request's input plus the previous response's output items, or null when the
|
|
497
|
+
* request options differ or history mutated (the chain must break). Per-turn
|
|
498
|
+
* `client_metadata` (e.g. rotating turn ids) is excluded from the option
|
|
499
|
+
* comparison; codex-rs excludes it from the same check.
|
|
500
|
+
*/
|
|
501
|
+
export declare function buildResponsesDeltaInput<TItem extends ResponseInputItem | InputItem>(previous: {
|
|
502
|
+
input?: TItem[];
|
|
503
|
+
} | undefined, previousResponseItems: readonly TItem[] | undefined, current: {
|
|
504
|
+
input?: TItem[];
|
|
505
|
+
}): TItem[] | null;
|
|
506
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Api, AssistantMessageEventStream as AssistantMessageEventStreamType, Context, Model, SimpleStreamOptions } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Stream a turn through an `omp auth-gateway` over the pi-native protocol.
|
|
4
|
+
*
|
|
5
|
+
* The returned {@link AssistantMessageEventStream} receives each parsed
|
|
6
|
+
* `AssistantMessageEvent` verbatim from the gateway; the terminal `done` /
|
|
7
|
+
* `error` event resolves `.result()` automatically via the base class's
|
|
8
|
+
* completion check. Non-streaming consumers just call `.result()` and pay
|
|
9
|
+
* for SSE framing they don't use — that overhead is dominated by provider
|
|
10
|
+
* latency, so we always stream rather than maintaining a parallel
|
|
11
|
+
* non-streaming path.
|
|
12
|
+
*/
|
|
13
|
+
export declare function streamPiNative<TApi extends Api>(model: Model<TApi>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStreamType;
|