@prometheus-ai/ai 0.5.4 → 0.5.8
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/dist/types/auth-broker/remote-store.d.ts +2 -1
- package/dist/types/auth-broker/wire-schemas.d.ts +4 -1
- package/dist/types/auth-gateway/server.d.ts +19 -0
- package/dist/types/auth-gateway/types.d.ts +9 -3
- package/dist/types/auth-retry.d.ts +119 -0
- package/dist/types/auth-storage.d.ts +217 -8
- package/dist/types/errors.d.ts +24 -0
- package/dist/types/index.d.ts +5 -9
- package/dist/types/provider-details.d.ts +1 -1
- package/dist/types/providers/amazon-bedrock.d.ts +12 -6
- package/dist/types/providers/anthropic-client.d.ts +10 -3
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +2 -2
- package/dist/types/providers/anthropic-messages-server.d.ts +3 -3
- package/dist/types/providers/anthropic-wire.d.ts +3 -3
- package/dist/types/providers/anthropic.d.ts +41 -34
- package/dist/types/providers/aws-credentials.d.ts +8 -0
- package/dist/types/providers/azure-openai-responses.d.ts +1 -0
- package/dist/types/providers/google-gemini-cli.d.ts +22 -1
- package/dist/types/providers/google-shared.d.ts +22 -0
- package/dist/types/providers/google-types.d.ts +13 -1
- package/dist/types/providers/mock.d.ts +8 -3
- package/dist/types/providers/ollama.d.ts +6 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +6 -3
- package/dist/types/providers/openai-chat-server.d.ts +3 -3
- package/dist/types/providers/openai-chat-wire.d.ts +644 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +8 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +9 -0
- package/dist/types/providers/openai-codex-responses.d.ts +31 -2
- package/dist/types/providers/openai-completions-compat.d.ts +2 -25
- package/dist/types/providers/openai-completions.d.ts +2 -10
- package/dist/types/providers/openai-responses-server-schema.d.ts +4 -4
- package/dist/types/providers/openai-responses-server.d.ts +2 -2
- package/dist/types/providers/openai-responses-shared.d.ts +49 -9
- package/dist/types/providers/openai-responses-wire.d.ts +6065 -0
- package/dist/types/providers/openai-responses.d.ts +13 -4
- package/dist/types/providers/prometheus-native-client.d.ts +9 -0
- package/dist/types/providers/prometheus-native-server.d.ts +4 -3
- package/dist/types/providers/transform-messages.d.ts +1 -2
- package/dist/types/rate-limit-utils.d.ts +3 -2
- package/dist/types/registry/aimlapi.d.ts +4 -0
- package/dist/types/registry/alibaba-coding-plan.d.ts +7 -0
- package/dist/types/registry/amazon-bedrock.d.ts +5 -0
- package/dist/types/registry/anthropic.d.ts +10 -0
- package/dist/types/{utils/oauth → registry}/api-key-login.d.ts +8 -2
- package/dist/types/{utils/oauth → registry}/api-key-validation.d.ts +15 -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/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/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.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/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/{utils → registry}/oauth/anthropic.d.ts +2 -1
- package/dist/types/{utils → registry}/oauth/github-copilot.d.ts +15 -23
- package/dist/types/{utils → registry}/oauth/index.d.ts +1 -0
- package/dist/types/{utils → registry}/oauth/minimax-code.d.ts +5 -5
- package/dist/types/{utils → registry}/oauth/types.d.ts +6 -1
- package/dist/types/{utils → registry}/oauth/xai-oauth.d.ts +2 -1
- 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 +272 -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/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-pass.d.ts +6 -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 +9 -1
- package/dist/types/types.d.ts +56 -295
- package/dist/types/usage/google-antigravity.d.ts +15 -1
- package/dist/types/usage/openai-codex-reset.d.ts +79 -0
- package/dist/types/usage/openai-codex.d.ts +1 -0
- package/dist/types/usage.d.ts +77 -4
- package/dist/types/utils/abort.d.ts +6 -0
- package/dist/types/utils/event-stream.d.ts +2 -0
- package/dist/types/utils/http-inspector.d.ts +0 -1
- package/dist/types/utils/idle-iterator.d.ts +35 -0
- package/dist/types/utils/openai-http.d.ts +58 -0
- package/dist/types/utils/request-debug.d.ts +3 -0
- package/dist/types/utils/retry-after.d.ts +1 -0
- package/dist/types/utils/schema/fields.d.ts +5 -0
- package/dist/types/utils/schema/json-schema-validator.d.ts +8 -0
- package/dist/types/utils/schema/stamps.d.ts +7 -15
- package/dist/types/utils/sse-debug.d.ts +0 -5
- package/dist/types/utils/stream-markup-healing.d.ts +2 -0
- package/dist/types/utils.d.ts +1 -5
- package/package.json +17 -29
- package/src/auth-broker/remote-store.ts +10 -1
- package/src/auth-broker/snapshot-cache.ts +1 -1
- package/src/auth-broker/wire-schemas.ts +1 -1
- package/src/auth-gateway/http.ts +1 -1
- package/src/auth-gateway/server.ts +95 -30
- package/src/auth-gateway/types.ts +10 -2
- package/src/auth-retry.ts +238 -0
- package/src/auth-storage.ts +935 -430
- package/src/errors.ts +32 -0
- package/src/index.ts +9 -14
- package/src/provider-details.ts +1 -1
- package/src/providers/__tests__/google-auth.test.ts +144 -0
- package/src/providers/amazon-bedrock.ts +70 -40
- package/src/providers/anthropic-client.ts +15 -13
- package/src/providers/anthropic-messages-server-schema.ts +17 -7
- package/src/providers/anthropic-messages-server.ts +88 -20
- package/src/providers/anthropic-wire.ts +4 -3
- package/src/providers/anthropic.ts +1234 -621
- package/src/providers/aws-credentials.ts +47 -5
- package/src/providers/aws-eventstream.ts +5 -0
- package/src/providers/azure-openai-responses.ts +117 -67
- package/src/providers/cursor.ts +30 -30
- package/src/providers/github-copilot-headers.ts +1 -1
- package/src/providers/gitlab-duo.ts +36 -29
- package/src/providers/google-auth.ts +71 -8
- package/src/providers/google-gemini-cli.ts +118 -22
- package/src/providers/google-shared.ts +163 -43
- package/src/providers/google-types.ts +10 -1
- package/src/providers/kimi.ts +1 -1
- package/src/providers/mock.ts +11 -3
- package/src/providers/ollama.ts +64 -7
- package/src/providers/openai-anthropic-shim.ts +17 -8
- package/src/providers/openai-chat-server-schema.ts +9 -3
- package/src/providers/openai-chat-server.ts +82 -16
- package/src/providers/openai-chat-wire.ts +847 -0
- package/src/providers/openai-codex/request-transformer.ts +129 -34
- package/src/providers/openai-codex/response-handler.ts +22 -1
- package/src/providers/openai-codex-responses.ts +699 -247
- package/src/providers/openai-completions-compat.ts +8 -308
- package/src/providers/openai-completions.ts +416 -267
- package/src/providers/openai-responses-server-schema.ts +15 -9
- package/src/providers/openai-responses-server.ts +162 -114
- package/src/providers/openai-responses-shared.ts +320 -82
- package/src/providers/openai-responses-wire.ts +6391 -0
- package/src/providers/openai-responses.ts +382 -176
- package/src/providers/prometheus-native-client.ts +27 -11
- package/src/providers/prometheus-native-server.ts +44 -17
- package/src/providers/transform-messages.ts +311 -120
- package/src/providers/vision-guard.ts +5 -3
- package/src/rate-limit-utils.ts +13 -3
- package/src/registry/aimlapi.ts +6 -0
- package/src/{utils/oauth → registry}/alibaba-coding-plan.ts +8 -18
- package/src/registry/amazon-bedrock.ts +22 -0
- package/src/registry/anthropic.ts +26 -0
- package/src/{utils/oauth → registry}/api-key-login.ts +25 -3
- package/src/{utils/oauth → registry}/api-key-validation.ts +62 -2
- package/src/{utils/oauth → registry}/cerebras.ts +8 -1
- package/src/{utils/oauth → registry}/cloudflare-ai-gateway.ts +8 -12
- package/src/registry/cursor.ts +20 -0
- package/src/{utils/oauth → registry}/deepseek.ts +9 -17
- package/src/registry/derived.ts +9 -0
- package/src/{utils/oauth → registry}/firepass.ts +10 -2
- package/src/{utils/oauth → registry}/fireworks.ts +8 -1
- package/src/registry/github-copilot.ts +22 -0
- package/src/registry/gitlab-duo.ts +19 -0
- package/src/registry/google-antigravity.ts +21 -0
- package/src/registry/google-gemini-cli.ts +21 -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/{utils/oauth → registry}/huggingface.ts +8 -19
- package/src/registry/index.ts +4 -0
- package/src/{utils/oauth → registry}/kagi.ts +9 -11
- package/src/{utils/oauth → registry}/kilo.ts +11 -6
- package/src/registry/kimi-code.ts +17 -0
- package/src/{utils/oauth → registry}/litellm.ts +8 -12
- package/src/{utils/oauth → registry}/lm-studio.ts +9 -17
- 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/{utils/oauth → registry}/moonshot.ts +8 -9
- package/src/{utils/oauth → registry}/nanogpt.ts +8 -1
- package/src/{utils/oauth → registry}/nvidia.ts +8 -18
- package/src/{utils → registry}/oauth/__tests__/xai-oauth.test.ts +4 -7
- package/src/{utils → registry}/oauth/anthropic.ts +38 -17
- package/src/{utils → registry}/oauth/github-copilot.ts +79 -115
- package/src/registry/oauth/gitlab-duo.ts +198 -0
- package/src/{utils → registry}/oauth/google-antigravity.ts +1 -4
- package/src/{utils → registry}/oauth/google-gemini-cli.ts +1 -4
- package/src/registry/oauth/index.ts +164 -0
- package/src/{utils → registry}/oauth/minimax-code.ts +16 -14
- package/src/{utils → registry}/oauth/types.ts +7 -51
- package/src/{utils → registry}/oauth/wafer.ts +1 -1
- package/src/{utils → registry}/oauth/xai-oauth.ts +16 -8
- package/src/{utils → registry}/oauth/xiaomi.ts +9 -4
- package/src/{utils/oauth → registry}/ollama-cloud.ts +8 -1
- package/src/{utils/oauth → registry}/ollama.ts +8 -13
- 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/{utils/oauth → registry}/openrouter.ts +10 -2
- package/src/{utils/oauth → registry}/parallel.ts +9 -11
- package/src/registry/perplexity.ts +13 -0
- package/src/{utils/oauth → registry}/qianfan.ts +8 -17
- package/src/{utils/oauth → registry}/qwen-portal.ts +8 -19
- package/src/registry/registry.ts +149 -0
- package/src/{utils/oauth → registry}/synthetic.ts +7 -1
- package/src/{utils/oauth → registry}/tavily.ts +10 -12
- package/src/{utils/oauth → registry}/together.ts +7 -1
- package/src/registry/types.ts +56 -0
- package/src/{utils/oauth → registry}/venice.ts +8 -12
- package/src/{utils/oauth → registry}/vercel-ai-gateway.ts +8 -18
- package/src/{utils/oauth → registry}/vllm.ts +9 -16
- package/src/registry/wafer-pass.ts +12 -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/{utils/oauth → registry}/zai.ts +10 -22
- package/src/{utils/oauth → registry}/zenmux.ts +8 -1
- package/src/{utils/oauth/zhipu.ts → registry/zhipu-coding-plan.ts} +9 -21
- package/src/stream.ts +229 -199
- package/src/types.ts +63 -384
- package/src/usage/claude.ts +4 -2
- package/src/usage/github-copilot.ts +4 -2
- package/src/usage/google-antigravity.ts +196 -28
- package/src/usage/kimi.ts +1 -1
- package/src/usage/minimax-code.ts +5 -6
- package/src/usage/openai-codex-reset.ts +174 -0
- package/src/usage/openai-codex.ts +19 -2
- package/src/usage/zai.ts +2 -1
- package/src/usage.ts +93 -4
- package/src/utils/abort.ts +14 -0
- package/src/utils/event-stream.ts +17 -0
- package/src/utils/http-inspector.ts +4 -12
- package/src/utils/idle-iterator.ts +250 -79
- package/src/utils/openai-http.ts +157 -0
- package/src/utils/request-debug.ts +67 -19
- package/src/utils/retry-after.ts +1 -1
- package/src/utils/retry.ts +23 -2
- package/src/utils/schema/CONSTRAINTS.md +4 -2
- package/src/utils/schema/fields.ts +16 -0
- package/src/utils/schema/json-schema-validator.ts +19 -1
- package/src/utils/schema/normalize.ts +80 -8
- package/src/utils/schema/stamps.ts +22 -10
- package/src/utils/schema/wire.ts +2 -2
- package/src/utils/sse-debug.ts +0 -271
- package/src/utils/stream-markup-healing.ts +50 -8
- package/src/utils/validation.ts +49 -13
- package/src/utils.ts +2 -26
- package/dist/types/model-cache.d.ts +0 -17
- package/dist/types/model-manager.d.ts +0 -64
- package/dist/types/model-thinking.d.ts +0 -100
- package/dist/types/models.d.ts +0 -12
- package/dist/types/provider-models/bundled-references.d.ts +0 -4
- package/dist/types/provider-models/descriptors.d.ts +0 -50
- package/dist/types/provider-models/google.d.ts +0 -24
- package/dist/types/provider-models/index.d.ts +0 -5
- package/dist/types/provider-models/ollama.d.ts +0 -7
- package/dist/types/provider-models/openai-compat.d.ts +0 -323
- package/dist/types/provider-models/special.d.ts +0 -16
- package/dist/types/utils/discovery/antigravity.d.ts +0 -61
- package/dist/types/utils/discovery/codex.d.ts +0 -38
- package/dist/types/utils/discovery/cursor.d.ts +0 -23
- package/dist/types/utils/discovery/gemini.d.ts +0 -25
- package/dist/types/utils/discovery/index.d.ts +0 -4
- package/dist/types/utils/discovery/openai-compatible.d.ts +0 -72
- package/dist/types/utils/oauth/alibaba-coding-plan.d.ts +0 -18
- package/dist/types/utils/oauth/cerebras.d.ts +0 -1
- package/dist/types/utils/oauth/cloudflare-ai-gateway.d.ts +0 -18
- package/dist/types/utils/oauth/deepseek.d.ts +0 -10
- package/dist/types/utils/oauth/firepass.d.ts +0 -1
- package/dist/types/utils/oauth/fireworks.d.ts +0 -1
- package/dist/types/utils/oauth/huggingface.d.ts +0 -19
- package/dist/types/utils/oauth/kagi.d.ts +0 -17
- package/dist/types/utils/oauth/kilo.d.ts +0 -5
- package/dist/types/utils/oauth/litellm.d.ts +0 -18
- package/dist/types/utils/oauth/lm-studio.d.ts +0 -17
- package/dist/types/utils/oauth/moonshot.d.ts +0 -1
- package/dist/types/utils/oauth/nanogpt.d.ts +0 -1
- package/dist/types/utils/oauth/nvidia.d.ts +0 -18
- package/dist/types/utils/oauth/ollama-cloud.d.ts +0 -2
- package/dist/types/utils/oauth/ollama.d.ts +0 -18
- package/dist/types/utils/oauth/openrouter.d.ts +0 -1
- package/dist/types/utils/oauth/parallel.d.ts +0 -17
- package/dist/types/utils/oauth/qianfan.d.ts +0 -17
- package/dist/types/utils/oauth/qwen-portal.d.ts +0 -19
- package/dist/types/utils/oauth/synthetic.d.ts +0 -1
- package/dist/types/utils/oauth/tavily.d.ts +0 -17
- package/dist/types/utils/oauth/together.d.ts +0 -1
- package/dist/types/utils/oauth/venice.d.ts +0 -18
- package/dist/types/utils/oauth/vercel-ai-gateway.d.ts +0 -18
- package/dist/types/utils/oauth/vllm.d.ts +0 -16
- package/dist/types/utils/oauth/zai.d.ts +0 -18
- package/dist/types/utils/oauth/zenmux.d.ts +0 -1
- package/dist/types/utils/oauth/zhipu.d.ts +0 -18
- package/src/model-cache.ts +0 -129
- package/src/model-manager.ts +0 -469
- package/src/model-thinking.ts +0 -756
- package/src/models.json +0 -60287
- package/src/models.json.d.ts +0 -9
- package/src/models.ts +0 -56
- package/src/provider-models/bundled-references.ts +0 -38
- package/src/provider-models/descriptors.ts +0 -364
- package/src/provider-models/google.ts +0 -88
- package/src/provider-models/index.ts +0 -5
- package/src/provider-models/ollama.ts +0 -153
- package/src/provider-models/openai-compat.ts +0 -2904
- package/src/provider-models/special.ts +0 -67
- package/src/utils/discovery/antigravity.ts +0 -261
- package/src/utils/discovery/codex.ts +0 -371
- package/src/utils/discovery/cursor.ts +0 -306
- package/src/utils/discovery/gemini.ts +0 -248
- package/src/utils/discovery/index.ts +0 -4
- package/src/utils/discovery/openai-compatible.ts +0 -224
- package/src/utils/oauth/gitlab-duo.ts +0 -123
- package/src/utils/oauth/index.ts +0 -502
- /package/dist/types/{utils/oauth/__tests__/xai-oauth.test.d.ts → providers/__tests__/google-auth.test.d.ts} +0 -0
- /package/dist/types/{utils → registry}/oauth/callback-server.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/cursor.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/gitlab-duo.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/google-antigravity.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/google-gemini-cli.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/google-oauth-shared.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/kimi.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/openai-codex.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/opencode.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/perplexity.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/pkce.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/wafer.d.ts +0 -0
- /package/dist/types/{utils → registry}/oauth/xiaomi.d.ts +0 -0
- /package/src/{utils → registry}/oauth/callback-server.ts +0 -0
- /package/src/{utils → registry}/oauth/cursor.ts +0 -0
- /package/src/{utils → registry}/oauth/google-oauth-shared.ts +0 -0
- /package/src/{utils → registry}/oauth/kimi.ts +0 -0
- /package/src/{utils → registry}/oauth/oauth.html +0 -0
- /package/src/{utils → registry}/oauth/openai-codex.ts +0 -0
- /package/src/{utils → registry}/oauth/opencode.ts +0 -0
- /package/src/{utils → registry}/oauth/perplexity.ts +0 -0
- /package/src/{utils → registry}/oauth/pkce.ts +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProviderHttpError } from "../../errors";
|
|
1
2
|
export type CodexRateLimit = {
|
|
2
3
|
used_percent?: number;
|
|
3
4
|
window_minutes?: number;
|
|
@@ -10,8 +11,16 @@ export type CodexRateLimits = {
|
|
|
10
11
|
export type CodexErrorInfo = {
|
|
11
12
|
message: string;
|
|
12
13
|
status: number;
|
|
14
|
+
/** Machine-readable error code (`error.code` or `error.type` from the response body), when present. */
|
|
15
|
+
code?: string;
|
|
13
16
|
friendlyMessage?: string;
|
|
14
17
|
rateLimits?: CodexRateLimits;
|
|
15
18
|
raw?: string;
|
|
16
19
|
};
|
|
20
|
+
/** Non-2xx response from the Codex backend, with the parsed body retained. */
|
|
21
|
+
export declare class CodexApiError extends ProviderHttpError {
|
|
22
|
+
readonly info: CodexErrorInfo;
|
|
23
|
+
constructor(info: CodexErrorInfo, headers?: Headers);
|
|
24
|
+
static fromResponse(response: Response): Promise<CodexApiError>;
|
|
25
|
+
}
|
|
17
26
|
export declare function parseCodexError(response: Response): Promise<CodexErrorInfo>;
|
|
@@ -1,16 +1,45 @@
|
|
|
1
|
-
import type { ResponseInput } from "openai/resources/responses/responses";
|
|
2
1
|
import { type Context, type Model, type ProviderSessionState, type ServiceTier, type StreamFunction, type StreamOptions, type Tool, type ToolChoice } from "../types";
|
|
2
|
+
import { type CodexReasoningContext } from "./openai-codex/request-transformer";
|
|
3
|
+
import type { ResponseInput } from "./openai-responses-wire";
|
|
3
4
|
export interface OpenAICodexResponsesOptions extends StreamOptions {
|
|
4
5
|
reasoning?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
5
6
|
reasoningSummary?: "auto" | "concise" | "detailed" | null;
|
|
7
|
+
/** `reasoning.context` replay scope. Defaults to `all_turns` under {@link OpenAICodexResponsesOptions.responsesLite}, otherwise omitted (server default is `current_turn`). */
|
|
8
|
+
reasoningContext?: CodexReasoningContext;
|
|
6
9
|
textVerbosity?: "low" | "medium" | "high";
|
|
7
10
|
include?: string[];
|
|
8
11
|
codexMode?: boolean;
|
|
9
12
|
toolChoice?: ToolChoice;
|
|
10
13
|
preferWebsockets?: boolean;
|
|
11
14
|
serviceTier?: ServiceTier;
|
|
15
|
+
/**
|
|
16
|
+
* Opt into the Responses Lite transport contract. Sends
|
|
17
|
+
* `x-openai-internal-codex-responses-lite: true` on HTTP requests and on the
|
|
18
|
+
* WebSocket upgrade (the marker is connection-scoped there, so lite and
|
|
19
|
+
* non-lite turns never share a pooled socket), strips image detail from
|
|
20
|
+
* input, and defaults `reasoning.context` to `all_turns` — mirroring codex-rs.
|
|
21
|
+
*/
|
|
22
|
+
responsesLite?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Extra `client_metadata` to include in the request body on both transports.
|
|
25
|
+
* The canonical Codex envelope is `client_metadata["x-codex-turn-metadata"]`
|
|
26
|
+
* (JSON string of thread/turn identifiers); flat keys are also accepted.
|
|
27
|
+
*/
|
|
28
|
+
clientMetadata?: Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Invoked when the server streams a `response.metadata` event carrying
|
|
31
|
+
* ChatGPT moderation metadata (`metadata.openai_chatgpt_moderation_metadata`)
|
|
32
|
+
* for first-party presentation parity. Diagnostic observer: failures are
|
|
33
|
+
* swallowed and must not alter the stream.
|
|
34
|
+
*/
|
|
35
|
+
onModerationMetadata?: (metadata: unknown) => void;
|
|
12
36
|
}
|
|
13
37
|
type CodexTransport = "sse" | "websocket";
|
|
38
|
+
/**
|
|
39
|
+
* Per-session request-shape counters. Despite the name, these cover both
|
|
40
|
+
* transports: once stateful SSE chaining is enabled, SSE requests are counted
|
|
41
|
+
* too (the shared chained-request builder records every request it shapes).
|
|
42
|
+
*/
|
|
14
43
|
export interface OpenAICodexWebSocketDebugStats {
|
|
15
44
|
fullContextRequests: number;
|
|
16
45
|
deltaRequests: number;
|
|
@@ -21,7 +50,7 @@ export interface OpenAICodexWebSocketDebugStats {
|
|
|
21
50
|
/** @internal Exported for tests. */
|
|
22
51
|
export declare function normalizeCodexToolChoice(choice: ToolChoice | undefined, tools?: Tool[], model?: Model<"openai-codex-responses">): string | Record<string, unknown> | undefined;
|
|
23
52
|
export declare const streamOpenAICodexResponses: StreamFunction<"openai-codex-responses">;
|
|
24
|
-
export declare function prewarmOpenAICodexResponses(model: Model<"openai-codex-responses">, options?: Pick<OpenAICodexResponsesOptions, "apiKey" | "headers" | "sessionId" | "signal" | "preferWebsockets" | "providerSessionState">): Promise<void>;
|
|
53
|
+
export declare function prewarmOpenAICodexResponses(model: Model<"openai-codex-responses">, options?: Pick<OpenAICodexResponsesOptions, "apiKey" | "headers" | "sessionId" | "signal" | "preferWebsockets" | "providerSessionState" | "responsesLite">): Promise<void>;
|
|
25
54
|
export interface OpenAICodexTransportDetails {
|
|
26
55
|
websocketPreferred: boolean;
|
|
27
56
|
lastTransport?: CodexTransport;
|
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
import type { Model,
|
|
2
|
-
type
|
|
3
|
-
export type ResolvedOpenAICompat = Required<Omit<OpenAICompat, "openRouterRouting" | "vercelGatewayRouting" | "extraBody" | "toolStrictMode" | "cacheControlFormat" | "thinkingKeep">> & {
|
|
4
|
-
openRouterRouting?: OpenAICompat["openRouterRouting"];
|
|
5
|
-
vercelGatewayRouting?: OpenAICompat["vercelGatewayRouting"];
|
|
6
|
-
extraBody?: OpenAICompat["extraBody"];
|
|
7
|
-
cacheControlFormat?: OpenAICompat["cacheControlFormat"];
|
|
8
|
-
thinkingKeep?: OpenAICompat["thinkingKeep"];
|
|
9
|
-
toolStrictMode: ResolvedToolStrictMode;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Detect compatibility settings from provider and baseUrl for known providers.
|
|
13
|
-
* Provider takes precedence over URL-based detection since it's explicitly configured.
|
|
14
|
-
* @param model - The model configuration
|
|
15
|
-
* @param resolvedBaseUrl - Optional resolved base URL (e.g., after GitHub Copilot proxy-ep resolution).
|
|
16
|
-
* If provided, this takes precedence over model.baseUrl for URL-based checks.
|
|
17
|
-
*/
|
|
1
|
+
import type { Model, ResolvedOpenAICompat } from "../types";
|
|
2
|
+
export type { ResolvedOpenAICompat };
|
|
18
3
|
export declare function detectOpenAICompat(model: Model<"openai-completions">, resolvedBaseUrl?: string): ResolvedOpenAICompat;
|
|
19
|
-
/**
|
|
20
|
-
* Resolve compatibility settings by layering explicit model.compat overrides onto
|
|
21
|
-
* the detected defaults. This is the canonical compat view for both metadata and transport.
|
|
22
|
-
* @param model - The model configuration
|
|
23
|
-
* @param resolvedBaseUrl - Optional resolved base URL (e.g., after GitHub Copilot proxy-ep resolution).
|
|
24
|
-
* If provided, this takes precedence over model.baseUrl for URL-based checks.
|
|
25
|
-
*/
|
|
26
4
|
export declare function resolveOpenAICompat(model: Model<"openai-completions">, resolvedBaseUrl?: string): ResolvedOpenAICompat;
|
|
27
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResolvedOpenAICompat } from "@prometheus-ai/catalog/types";
|
|
2
2
|
import { type AssistantMessage, type Context, type Model, type ServiceTier, type StreamFunction, type StreamOptions, type ToolChoice } from "../types";
|
|
3
|
-
import {
|
|
3
|
+
import type { ChatCompletionMessageParam } from "./openai-chat-wire";
|
|
4
4
|
/**
|
|
5
5
|
* Identify "real progress" stream chunks vs. keepalives, role-only preambles,
|
|
6
6
|
* and empty `{choices:[]}` no-ops emitted by some OpenAI-compatible endpoints.
|
|
@@ -41,14 +41,6 @@ export interface OpenAICompletionsOptions extends StreamOptions {
|
|
|
41
41
|
* Exported for unit testing.
|
|
42
42
|
*/
|
|
43
43
|
export declare function applyOpenRouterRoutingVariant(modelId: string, variant: string | undefined): string;
|
|
44
|
-
/** Returns the widened OpenAI stream watchdog floor for slow GLM coding-plan reasoning models. */
|
|
45
|
-
export declare function getOpenAICompletionsStreamIdleTimeoutFallbackMs(model: Model<"openai-completions">): number | undefined;
|
|
46
44
|
export declare const streamOpenAICompletions: StreamFunction<"openai-completions">;
|
|
47
45
|
export declare function parseChunkUsage(rawUsage: object, model: Model<"openai-completions">, premiumRequests: number | undefined): AssistantMessage["usage"];
|
|
48
46
|
export declare function convertMessages(model: Model<"openai-completions">, context: Context, compat: ResolvedOpenAICompat): ChatCompletionMessageParam[];
|
|
49
|
-
/**
|
|
50
|
-
* Detect compatibility settings from provider and baseUrl for known providers.
|
|
51
|
-
* Provider takes precedence over URL-based detection since it's explicitly configured.
|
|
52
|
-
* Returns a fully resolved OpenAICompat object with all fields set.
|
|
53
|
-
*/
|
|
54
|
-
export declare function detectCompat(model: Model<"openai-completions">): ResolvedOpenAICompat;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* Real clients (codex, openai-python, llm-git) routinely send these and a 400
|
|
8
8
|
* is a worse outcome than dropping them on the floor.
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import { z } from "zod/v4";
|
|
11
|
+
import type { EasyInputMessage, ResponseCreateParams, ResponseFunctionToolCall, ResponseInputContent, ResponseInputItem, ResponseOutputMessage, ResponseReasoningItem, Tool as ResponsesTool } from "./openai-responses-wire";
|
|
12
12
|
declare const inputImageBlockSchema: z.ZodObject<{
|
|
13
13
|
type: z.ZodLiteral<"input_image">;
|
|
14
14
|
detail: z.ZodOptional<z.ZodEnum<{
|
|
@@ -118,7 +118,7 @@ export declare const inputItemSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
118
118
|
type: z.ZodLiteral<"reasoning_text">;
|
|
119
119
|
text: z.ZodString;
|
|
120
120
|
}, z.core.$strip>>>;
|
|
121
|
-
}, z.core.$
|
|
121
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
122
122
|
type: z.ZodLiteral<"function_call">;
|
|
123
123
|
id: z.ZodOptional<z.ZodString>;
|
|
124
124
|
call_id: z.ZodString;
|
|
@@ -279,7 +279,7 @@ export declare const openaiResponsesRequestSchema: z.ZodObject<{
|
|
|
279
279
|
type: z.ZodLiteral<"reasoning_text">;
|
|
280
280
|
text: z.ZodString;
|
|
281
281
|
}, z.core.$strip>>>;
|
|
282
|
-
}, z.core.$
|
|
282
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
283
283
|
type: z.ZodLiteral<"function_call">;
|
|
284
284
|
id: z.ZodOptional<z.ZodString>;
|
|
285
285
|
call_id: z.ZodString;
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* Spec: https://platform.openai.com/docs/api-reference/responses
|
|
9
9
|
* Inverse direction (source-of-truth for item shapes): ../../providers/openai-responses.ts
|
|
10
10
|
*/
|
|
11
|
-
import type { AuthGatewayParsedRequest as ParsedRequest } from "../auth-gateway/types";
|
|
11
|
+
import type { AuthGatewayStreamControl, AuthGatewayParsedRequest as ParsedRequest } from "../auth-gateway/types";
|
|
12
12
|
import type { AssistantMessage, AssistantMessageEventStream } from "../types";
|
|
13
13
|
export type { ParsedRequest };
|
|
14
14
|
export declare function parseRequest(body: unknown, headers?: Headers): ParsedRequest;
|
|
15
15
|
export declare function formatError(status: number, type: string, message: string): Response;
|
|
16
16
|
export declare function encodeResponse(message: AssistantMessage, requestedModelId: string): Record<string, unknown>;
|
|
17
|
-
export declare function encodeStream(events: AssistantMessageEventStream, requestedModelId: string): ReadableStream<Uint8Array>;
|
|
17
|
+
export declare function encodeStream(events: AssistantMessageEventStream, requestedModelId: string, _options?: ParsedRequest["options"], control?: AuthGatewayStreamControl): ReadableStream<Uint8Array>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type OpenAI from "openai";
|
|
2
|
-
import type { ResponseInput, ResponseInputContent, ResponseOutputItem } from "openai/resources/responses/responses";
|
|
3
1
|
import { type Api, type AssistantMessage, type ImageContent, type Model, type ServiceTier, type StopReason, type StreamOptions, type TextContent, type TextSignatureV1, type ToolResultMessage } from "../types";
|
|
4
2
|
import type { AssistantMessageEventStream } from "../utils/event-stream";
|
|
3
|
+
import type { ResponseCreateParamsStreaming, ResponseInput, ResponseInputContent, ResponseOutputItem, ResponseStatus, ResponseStreamEvent } from "./openai-responses-wire";
|
|
5
4
|
export declare const OPENAI_RESPONSES_PROGRESS_EVENT_TYPES: ReadonlySet<string>;
|
|
6
5
|
export declare function isOpenAIResponsesProgressEvent(event: unknown): boolean;
|
|
7
6
|
export declare function encodeTextSignatureV1(id: string, phase?: TextSignatureV1["phase"]): string;
|
|
@@ -38,15 +37,38 @@ export declare function collectCustomCallIds(messages: ResponseInput): Set<strin
|
|
|
38
37
|
* codex provider — issue #1351 / regression of #472.
|
|
39
38
|
*/
|
|
40
39
|
export declare function repairOrphanResponsesToolOutputs(input: ResponseInput): ResponseInput;
|
|
40
|
+
/**
|
|
41
|
+
* Synthesize a placeholder `function_call_output` / `custom_tool_call_output`
|
|
42
|
+
* for every `function_call` / `custom_tool_call` whose `call_id` has no matching
|
|
43
|
+
* output later in the same input. The Responses API rejects an unpaired call
|
|
44
|
+
* with `400 No tool output found for function call …`.
|
|
45
|
+
*
|
|
46
|
+
* Orphan calls surface when the user branches/navigates the session tree to a
|
|
47
|
+
* node that ends on a tool call (the tool-result child is excluded from the
|
|
48
|
+
* reconstructed history) or when a turn is aborted/crashes after the call
|
|
49
|
+
* streamed but before its result persisted. Dropping the call would erase the
|
|
50
|
+
* assistant's action; a placeholder output keeps the call visible so the model
|
|
51
|
+
* can recover (e.g. re-issue the call). Symmetric to
|
|
52
|
+
* {@link repairOrphanResponsesToolOutputs}.
|
|
53
|
+
*/
|
|
54
|
+
export declare function repairOrphanResponsesToolCalls(input: ResponseInput): ResponseInput;
|
|
41
55
|
export declare function convertResponsesInputContent(content: string | Array<TextContent | ImageContent>, supportsImages: boolean): ResponseInputContent[] | undefined;
|
|
42
56
|
export declare function convertResponsesAssistantMessage<TApi extends Api>(assistantMsg: AssistantMessage, model: Model<TApi>, msgIndex: number, knownCallIds: Set<string>, includeThinkingSignatures?: boolean, customCallIds?: Set<string>): ResponseInput;
|
|
43
57
|
export declare function appendResponsesToolResultMessages<TApi extends Api>(messages: ResponseInput, toolResult: ToolResultMessage, model: Model<TApi>, strictResponsesPairing: boolean, knownCallIds: ReadonlySet<string>, customCallIds?: ReadonlySet<string>): void;
|
|
44
58
|
export interface ProcessResponsesStreamOptions {
|
|
45
59
|
onFirstToken?: () => void;
|
|
46
60
|
onOutputItemDone?: (item: ResponseOutputItem) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Called when a terminal `response.completed` or `response.incomplete` event
|
|
63
|
+
* is successfully processed. Only invoked on the successful-completion path;
|
|
64
|
+
* thrown failure (`response.failed`) and cancellation paths never call this.
|
|
65
|
+
* Used by callers to detect premature stream closure (i.e. the stream ended
|
|
66
|
+
* without a recognized terminal event).
|
|
67
|
+
*/
|
|
68
|
+
onCompleted?: () => void;
|
|
47
69
|
}
|
|
48
|
-
export declare function processResponsesStream<TApi extends Api>(openaiStream: AsyncIterable<
|
|
49
|
-
export declare function mapOpenAIResponsesStopReason(status:
|
|
70
|
+
export declare function processResponsesStream<TApi extends Api>(openaiStream: AsyncIterable<ResponseStreamEvent>, output: AssistantMessage, stream: AssistantMessageEventStream, model: Model<TApi>, options?: ProcessResponsesStreamOptions): Promise<void>;
|
|
71
|
+
export declare function mapOpenAIResponsesStopReason(status: ResponseStatus | undefined): StopReason;
|
|
50
72
|
/** Initial empty `AssistantMessage` that streaming providers accumulate into. */
|
|
51
73
|
export declare function createInitialResponsesAssistantMessage(api: Api, provider: string, modelId: string): AssistantMessage;
|
|
52
74
|
/** Extension fields we add on top of `ResponseCreateParamsStreaming` across the Responses-family providers. */
|
|
@@ -57,7 +79,7 @@ export type ResponsesSamplingParamsExtras = {
|
|
|
57
79
|
presence_penalty?: number;
|
|
58
80
|
repetition_penalty?: number;
|
|
59
81
|
};
|
|
60
|
-
type CommonResponsesParams =
|
|
82
|
+
type CommonResponsesParams = ResponseCreateParamsStreaming & ResponsesSamplingParamsExtras;
|
|
61
83
|
type CommonSamplingOptions = Pick<StreamOptions, "temperature" | "topP" | "topK" | "minP" | "presencePenalty" | "repetitionPenalty" | "maxTokens"> & {
|
|
62
84
|
serviceTier?: ServiceTier;
|
|
63
85
|
};
|
|
@@ -70,15 +92,19 @@ type CommonSamplingOptions = Pick<StreamOptions, "temperature" | "topP" | "topK"
|
|
|
70
92
|
* can let the upstream apply its own default instead of 400-ing on `maxTokens` values that
|
|
71
93
|
* reflect the model's context window rather than the upstream output limit.
|
|
72
94
|
*/
|
|
73
|
-
export declare function applyCommonResponsesSamplingParams<P extends CommonResponsesParams>(params: P, options: CommonSamplingOptions | undefined, model: Pick<Model, "provider" | "omitMaxOutputTokens">): void;
|
|
95
|
+
export declare function applyCommonResponsesSamplingParams<P extends CommonResponsesParams>(params: P, options: CommonSamplingOptions | undefined, model: Pick<Model, "provider" | "omitMaxOutputTokens" | "maxTokens">): void;
|
|
74
96
|
type ReasoningOptions = {
|
|
75
97
|
reasoning?: string;
|
|
76
98
|
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
77
99
|
};
|
|
78
100
|
/**
|
|
79
101
|
* Apply reasoning-related Responses parameters: enable encrypted reasoning content for replay,
|
|
80
|
-
* set effort/summary when requested, and otherwise inject the
|
|
81
|
-
*
|
|
102
|
+
* set effort/summary when requested, and otherwise inject the "Juice: 0" no-reasoning hack
|
|
103
|
+
* when `model.compat.requiresJuiceZeroHack` is set (GPT-5 family by default).
|
|
104
|
+
* Mutates `params` and may push a developer message into `messages`. Returns
|
|
105
|
+
* the number of per-turn trailing scaffolding items appended to `messages`
|
|
106
|
+
* (the "Juice: 0" developer item), so callers doing stateful
|
|
107
|
+
* `previous_response_id` chaining can exclude them from append-baseline math.
|
|
82
108
|
*
|
|
83
109
|
* @param omitReasoningEffort - When `true`, suppresses `params.reasoning.effort` from the wire
|
|
84
110
|
* body. Set by `xai-responses.ts` via {@link OpenAIResponsesOptions.omitReasoningEffort} for
|
|
@@ -89,7 +115,7 @@ type ReasoningOptions = {
|
|
|
89
115
|
* without needing explicit activation. Callers that pass `options.reasoning` for such models
|
|
90
116
|
* should expect this documented downgrade: the model will reason, but at its default effort.
|
|
91
117
|
*/
|
|
92
|
-
export declare function applyResponsesReasoningParams<P extends
|
|
118
|
+
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;
|
|
93
119
|
/** Populate `output.usage` from a Responses-API `response.usage` payload. Does not invoke `calculateCost`. */
|
|
94
120
|
export declare function populateResponsesUsageFromResponse(output: AssistantMessage, usage: {
|
|
95
121
|
input_tokens?: number | null;
|
|
@@ -102,4 +128,18 @@ export declare function populateResponsesUsageFromResponse(output: AssistantMess
|
|
|
102
128
|
reasoning_tokens?: number | null;
|
|
103
129
|
} | null;
|
|
104
130
|
} | null | undefined): void;
|
|
131
|
+
/**
|
|
132
|
+
* Strict-prefix delta for stateful `previous_response_id` chaining (used by the
|
|
133
|
+
* platform Responses provider and the Codex provider on both transports):
|
|
134
|
+
* returns the input items the current request appends beyond the previous
|
|
135
|
+
* request's input plus the previous response's output items, or null when the
|
|
136
|
+
* request options differ or history mutated (the chain must break). Per-turn
|
|
137
|
+
* `client_metadata` (e.g. rotating turn ids) is excluded from the option
|
|
138
|
+
* comparison; codex-rs excludes it from the same check.
|
|
139
|
+
*/
|
|
140
|
+
export declare function buildResponsesDeltaInput<TItem>(previous: {
|
|
141
|
+
input?: unknown;
|
|
142
|
+
} | undefined, previousResponseItems: readonly TItem[] | undefined, current: {
|
|
143
|
+
input?: unknown;
|
|
144
|
+
}): TItem[] | null;
|
|
105
145
|
export {};
|