@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
|
@@ -6,8 +6,13 @@
|
|
|
6
6
|
* No `@aws-sdk/*`, no `@smithy/*`, no `proxy-agent`. Proxies are honored via
|
|
7
7
|
* Bun's native `HTTPS_PROXY` support.
|
|
8
8
|
*/
|
|
9
|
-
import type { Effort } from "
|
|
9
|
+
import type { Effort } from "@prometheus-ai/catalog/effort";
|
|
10
|
+
import { ProviderHttpError } from "../errors";
|
|
10
11
|
import type { StreamFunction, StreamOptions, ThinkingBudgets } from "../types";
|
|
12
|
+
/** Non-2xx response (or in-stream exception event) from the Bedrock runtime API. */
|
|
13
|
+
export declare class BedrockApiError extends ProviderHttpError {
|
|
14
|
+
readonly name = "BedrockApiError";
|
|
15
|
+
}
|
|
11
16
|
export type BedrockThinkingDisplay = "summarized" | "omitted";
|
|
12
17
|
export interface BedrockOptions extends StreamOptions {
|
|
13
18
|
region?: string;
|
|
@@ -27,11 +32,12 @@ export interface BedrockOptions extends StreamOptions {
|
|
|
27
32
|
* - `"omitted"`: thinking content is suppressed; the encrypted signature still
|
|
28
33
|
* travels back for multi-turn continuity.
|
|
29
34
|
*
|
|
30
|
-
* Starting with Claude Opus 4.7
|
|
31
|
-
* leaves callers waiting on a silent stream during
|
|
32
|
-
* #1373). We default to `"summarized"` so adaptive-
|
|
33
|
-
* the field keep producing visible thinking deltas.
|
|
34
|
-
* models (Opus 4.6, Sonnet 4.6+) reject the field, so
|
|
35
|
+
* Starting with Claude Opus 4.7 and Claude Fable/Mythos 5 the Anthropic API
|
|
36
|
+
* default is `"omitted"`, which leaves callers waiting on a silent stream during
|
|
37
|
+
* long reasoning runs (issue #1373). We default to `"summarized"` so adaptive-
|
|
38
|
+
* thinking models that accept the field keep producing visible thinking deltas.
|
|
39
|
+
* Older adaptive-thinking models (Opus 4.6, Sonnet 4.6+) reject the field, so
|
|
40
|
+
* we omit it for them.
|
|
35
41
|
*/
|
|
36
42
|
thinkingDisplay?: BedrockThinkingDisplay;
|
|
37
43
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProviderHttpError } from "../errors";
|
|
1
2
|
import type { FetchImpl } from "../types";
|
|
2
3
|
import type { MessageCreateParamsStreaming } from "./anthropic-wire";
|
|
3
4
|
/** Per-request options accepted by {@link AnthropicMessages.create}. */
|
|
@@ -11,7 +12,9 @@ export interface AnthropicRequestOptions {
|
|
|
11
12
|
/**
|
|
12
13
|
* Extra `RequestInit` fields merged into every fetch call. Bun extends
|
|
13
14
|
* `RequestInit` with a `tls` option used for the Claude Code TLS profile and
|
|
14
|
-
* Foundry mTLS.
|
|
15
|
+
* Foundry mTLS. Core request fields (`method`, `headers`, `body`, `signal`)
|
|
16
|
+
* are owned by the client and cannot be overridden from here — the timeout
|
|
17
|
+
* controller's signal in particular must always win.
|
|
15
18
|
*/
|
|
16
19
|
export type AnthropicFetchOptions = RequestInit & {
|
|
17
20
|
tls?: {
|
|
@@ -22,6 +25,8 @@ export type AnthropicFetchOptions = RequestInit & {
|
|
|
22
25
|
cert?: string;
|
|
23
26
|
key?: string;
|
|
24
27
|
};
|
|
28
|
+
/** Bun extension: see {@link FetchWithRetryOptions.timeout} — `false` disables Bun's native fetch TTFT timeout (issue #2422). */
|
|
29
|
+
timeout?: number | false;
|
|
25
30
|
};
|
|
26
31
|
export interface AnthropicClientOptions {
|
|
27
32
|
/** Sent as `X-Api-Key` unless the header is already present in `defaultHeaders`. */
|
|
@@ -37,8 +42,7 @@ export interface AnthropicClientOptions {
|
|
|
37
42
|
fetchOptions?: AnthropicFetchOptions;
|
|
38
43
|
}
|
|
39
44
|
/** Non-2xx response from the Anthropic API. */
|
|
40
|
-
export declare class AnthropicApiError extends
|
|
41
|
-
readonly status: number;
|
|
45
|
+
export declare class AnthropicApiError extends ProviderHttpError {
|
|
42
46
|
readonly headers: Headers;
|
|
43
47
|
readonly requestId: string | null;
|
|
44
48
|
constructor(status: number, message: string, headers: Headers);
|
|
@@ -52,6 +56,9 @@ export declare class AnthropicConnectionError extends Error {
|
|
|
52
56
|
export declare class AnthropicConnectionTimeoutError extends Error {
|
|
53
57
|
constructor();
|
|
54
58
|
}
|
|
59
|
+
/** Server-suggested delay (`retry-after-ms`, then `retry-after` seconds or HTTP date). */
|
|
60
|
+
export declare function retryDelayFromHeaders(headers: Headers | undefined): number | undefined;
|
|
61
|
+
export declare function calculateAnthropicRetryDelayMs(attempt: number): number;
|
|
55
62
|
/**
|
|
56
63
|
* Lazy in-flight request handle. The HTTP request starts on the first
|
|
57
64
|
* `asResponse()` call; subsequent calls return the same promise.
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* `.refine(...)` so the error mentions them explicitly.
|
|
6
6
|
*
|
|
7
7
|
* Used by `anthropic-messages.ts:parseRequest` to validate the inbound JSON
|
|
8
|
-
* before walking it into
|
|
8
|
+
* before walking it into Prometheus AI's canonical `Context`.
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import { z } from "zod/v4";
|
|
11
11
|
import type { ContentBlockParam, ImageBlockParam, MessageCreateParams, MessageParam, TextBlockParam, Tool, ToolChoice } from "./anthropic-wire";
|
|
12
12
|
export declare const cacheControlSchema: z.ZodObject<{
|
|
13
13
|
type: z.ZodLiteral<"ephemeral">;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { AssistantMessage, AssistantMessageEventStream } from "../types";
|
|
2
2
|
/**
|
|
3
|
-
* Anthropic Messages API (https://docs.anthropic.com/en/api/messages) ↔
|
|
3
|
+
* Anthropic Messages API (https://docs.anthropic.com/en/api/messages) ↔ Prometheus AI
|
|
4
4
|
* gateway translation. Inbound: foreign HTTP body → prometheus Context. Outbound:
|
|
5
5
|
* prometheus AssistantMessage[Stream] → Anthropic-shaped JSON / SSE.
|
|
6
6
|
*/
|
|
7
|
-
import type { AuthGatewayParsedRequest as ParsedRequest } from "../auth-gateway/types";
|
|
7
|
+
import type { AuthGatewayStreamControl, AuthGatewayParsedRequest as ParsedRequest } from "../auth-gateway/types";
|
|
8
8
|
export type { ParsedRequest };
|
|
9
9
|
export declare function parseRequest(body: unknown, headers?: Headers): ParsedRequest;
|
|
10
10
|
export declare function encodeResponse(message: AssistantMessage, requestedModelId: string): Record<string, unknown>;
|
|
11
|
-
export declare function encodeStream(events: AssistantMessageEventStream, requestedModelId: string): ReadableStream<Uint8Array>;
|
|
11
|
+
export declare function encodeStream(events: AssistantMessageEventStream, requestedModelId: string, _options?: ParsedRequest["options"], control?: AuthGatewayStreamControl): ReadableStream<Uint8Array>;
|
|
12
12
|
/**
|
|
13
13
|
* Anthropic error envelope: `{ type: "error", error: { type, message } }`.
|
|
14
14
|
* See https://docs.anthropic.com/en/api/errors. Returned as a `Response` so
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anthropic Messages API wire types.
|
|
3
3
|
*
|
|
4
|
-
* Hand-maintained against https://docs.anthropic.com/en/api/messages so
|
|
4
|
+
* Hand-maintained against https://docs.anthropic.com/en/api/messages so Prometheus AI
|
|
5
5
|
* does not depend on `@anthropic-ai/sdk` for type information. Only the shapes
|
|
6
6
|
* this package actually reads or writes are modeled; fields we never touch are
|
|
7
7
|
* intentionally omitted. Names mirror the SDK so call sites read the same.
|
|
8
8
|
*
|
|
9
|
-
* Unlike the SDK, beta fields
|
|
9
|
+
* Unlike the SDK, beta fields Prometheus AI uses (`speed`, `context_management`,
|
|
10
10
|
* `output_config.effort`/`task_budget`, `thinking.display`, cache-control
|
|
11
11
|
* `scope`, tool `strict`/`eager_input_streaming`, mid-conversation `system`
|
|
12
12
|
* role) are first-class here instead of being patched in via casts.
|
|
@@ -165,7 +165,7 @@ export type MessageCreateParams = {
|
|
|
165
165
|
export type MessageCreateParamsStreaming = MessageCreateParams & {
|
|
166
166
|
stream: true;
|
|
167
167
|
};
|
|
168
|
-
export type StopReason = "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "pause_turn" | "refusal" | "sensitive";
|
|
168
|
+
export type StopReason = "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "pause_turn" | "refusal" | "sensitive" | "model_context_window_exceeded";
|
|
169
169
|
export type CacheCreation = {
|
|
170
170
|
ephemeral_5m_input_tokens?: number | null;
|
|
171
171
|
ephemeral_1h_input_tokens?: number | null;
|
|
@@ -14,7 +14,6 @@ export type AnthropicHeaderOptions = {
|
|
|
14
14
|
};
|
|
15
15
|
export declare function normalizeAnthropicBaseUrl(baseUrl?: string): string | undefined;
|
|
16
16
|
export declare function buildBetaHeader(baseBetas: readonly string[], extraBetas: readonly string[]): string;
|
|
17
|
-
export declare function isAnthropicApiBaseUrl(baseUrl?: string): boolean;
|
|
18
17
|
export declare function buildAnthropicHeaders(options: AnthropicHeaderOptions): Record<string, string>;
|
|
19
18
|
type AnthropicCacheControl = NonNullable<TextBlockParam["cache_control"]>;
|
|
20
19
|
/**
|
|
@@ -26,9 +25,12 @@ type AnthropicCacheControl = NonNullable<TextBlockParam["cache_control"]>;
|
|
|
26
25
|
*/
|
|
27
26
|
export declare function clearAnthropicFastModeFallback(providerSessionState: Map<string, ProviderSessionState> | undefined): void;
|
|
28
27
|
export declare function isAnthropicFastModeUnsupportedError(error: unknown): boolean;
|
|
29
|
-
export declare const claudeCodeVersion = "2.1.
|
|
28
|
+
export declare const claudeCodeVersion = "2.1.165";
|
|
29
|
+
export declare const claudeAgentSdkVersion = "0.3.165";
|
|
30
|
+
export declare const claudeClientVersion = "1.11187.4";
|
|
30
31
|
export declare const claudeToolPrefix: string;
|
|
31
|
-
export declare const claudeCodeSystemInstruction = "You are Claude
|
|
32
|
+
export declare const claudeCodeSystemInstruction = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
|
|
33
|
+
export declare const CLAUDE_CODE_MAX_OUTPUT_TOKENS = 64000;
|
|
32
34
|
export declare function mapStainlessOs(platform: string): "MacOS" | "Windows" | "Linux" | "FreeBSD" | `Other::${string}`;
|
|
33
35
|
export declare function mapStainlessArch(arch: string): "x64" | "arm64" | "x86" | `other::${string}`;
|
|
34
36
|
export declare const claudeCodeHeaders: {
|
|
@@ -40,27 +42,54 @@ export declare const claudeCodeHeaders: {
|
|
|
40
42
|
"X-Stainless-Arch": "arm64" | "x64" | "x86" | `other::${string}`;
|
|
41
43
|
"X-Stainless-OS": "FreeBSD" | "Linux" | "MacOS" | "Windows" | `Other::${string}`;
|
|
42
44
|
"X-Stainless-Timeout": string;
|
|
45
|
+
"anthropic-client-platform": string;
|
|
46
|
+
"anthropic-client-version": string;
|
|
43
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Wraps a fetch implementation to patch the Claude Code billing-header `cch`
|
|
50
|
+
* attestation into outgoing request bodies. Bodies without the placeholder
|
|
51
|
+
* pass through untouched, so installing it on every OAuth flow is safe.
|
|
52
|
+
*/
|
|
53
|
+
export declare function wrapFetchForCch(base: FetchImpl): FetchImpl;
|
|
44
54
|
export declare function isClaudeCloakingUserId(userId: string): boolean;
|
|
45
55
|
export declare function generateClaudeCloakingUserId(): string;
|
|
46
|
-
export declare
|
|
47
|
-
|
|
56
|
+
export declare function deriveClaudeDeviceId(installId: string, accountId?: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the `metadata.user_id` field for an Anthropic Messages request.
|
|
59
|
+
*
|
|
60
|
+
* For API-key tokens, an explicit caller-supplied `userId` is forwarded
|
|
61
|
+
* verbatim and `undefined` yields no metadata. For OAuth tokens the value
|
|
62
|
+
* must match the Claude Code attribution shape (`isClaudeCloakingUserId` or
|
|
63
|
+
* the `{session_id, account_uuid?, device_id?}` JSON envelope) — anything
|
|
64
|
+
* else is dropped and a fresh Claude-Code-style JSON id is generated from
|
|
65
|
+
* `sessionId`/`accountId` so attribution stays consistent across the main
|
|
66
|
+
* streaming path and provider-specific request builders (e.g. web search).
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveAnthropicMetadataUserId(userId: unknown, isOAuthToken: boolean, sessionId?: string, accountId?: string): string | undefined;
|
|
69
|
+
export declare const applyClaudeToolPrefix: (name: string) => string;
|
|
70
|
+
export declare const stripClaudeToolPrefix: (name: string) => string;
|
|
48
71
|
export type AnthropicEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
49
72
|
export type AnthropicThinkingDisplay = "summarized" | "omitted";
|
|
50
73
|
export interface AnthropicOptions extends StreamOptions {
|
|
51
74
|
/**
|
|
52
75
|
* Enable extended thinking.
|
|
53
|
-
* For Opus 4.6
|
|
54
|
-
*
|
|
76
|
+
* For adaptive-capable models (Opus 4.6+, Sonnet 4.6+, Fable/Mythos 5):
|
|
77
|
+
* uses adaptive thinking (Claude decides when/how much to think). For older
|
|
78
|
+
* models: uses budget-based thinking with thinkingBudgetTokens.
|
|
55
79
|
*/
|
|
56
80
|
thinkingEnabled?: boolean;
|
|
57
81
|
/**
|
|
58
82
|
* Token budget for extended thinking (older models only).
|
|
59
|
-
* Ignored for
|
|
83
|
+
* Ignored for adaptive-capable models.
|
|
60
84
|
*/
|
|
61
85
|
thinkingBudgetTokens?: number;
|
|
62
86
|
/**
|
|
63
|
-
*
|
|
87
|
+
* Upstream wire model id override for collapsed effort-tier variants.
|
|
88
|
+
* Serialized as `requestModelId ?? model.requestModelId ?? model.id`.
|
|
89
|
+
*/
|
|
90
|
+
requestModelId?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Effort level for adaptive thinking.
|
|
64
93
|
* Controls how much thinking Claude allocates:
|
|
65
94
|
* - "max": Always thinks with no constraints
|
|
66
95
|
* - "high": Always thinks, deep reasoning (default)
|
|
@@ -117,7 +146,6 @@ export type AnthropicClientOptionsArgs = {
|
|
|
117
146
|
hasTools?: boolean;
|
|
118
147
|
thinkingEnabled?: boolean;
|
|
119
148
|
thinkingDisplay?: AnthropicThinkingDisplay;
|
|
120
|
-
onSseEvent?: AnthropicOptions["onSseEvent"];
|
|
121
149
|
fetch?: FetchImpl;
|
|
122
150
|
claudeCodeSessionId?: string;
|
|
123
151
|
};
|
|
@@ -155,9 +183,8 @@ export type AnthropicUsageLike = {
|
|
|
155
183
|
};
|
|
156
184
|
/**
|
|
157
185
|
* Capture Anthropic's optional cache-creation TTL breakdown and server-tool-use
|
|
158
|
-
* counters into the harness Usage shape.
|
|
159
|
-
*
|
|
160
|
-
* established at `message_start`.
|
|
186
|
+
* counters into the harness Usage shape. Omitted/null fields are no-ops; explicit
|
|
187
|
+
* zero-valued objects clear prior extras from earlier stream usage snapshots.
|
|
161
188
|
*/
|
|
162
189
|
export declare function applyAnthropicUsageExtras(usage: Usage, source: AnthropicUsageLike): void;
|
|
163
190
|
export declare const streamAnthropic: StreamFunction<"anthropic-messages">;
|
|
@@ -178,29 +205,9 @@ export declare function normalizeExtraBetas(betas?: string[] | string): string[]
|
|
|
178
205
|
export declare function buildAnthropicClientOptions(args: AnthropicClientOptionsArgs): AnthropicClientOptionsResult;
|
|
179
206
|
/**
|
|
180
207
|
* A single Anthropic conversation turn, including the mid-conversation
|
|
181
|
-
* `system` role (Opus 4.8+).
|
|
208
|
+
* `system` role (Opus 4.8+ and Fable/Mythos 5).
|
|
182
209
|
*/
|
|
183
210
|
export type AnthropicMessageParam = MessageParam;
|
|
184
211
|
export declare function convertAnthropicMessages(messages: Message[], model: Model<"anthropic-messages">, isOAuthToken: boolean): AnthropicMessageParam[];
|
|
185
|
-
/**
|
|
186
|
-
* Normalize a JSON Schema node for Anthropic tool `input_schema`.
|
|
187
|
-
*
|
|
188
|
-
* Applies the full whitelist semantics from the Anthropic Python SDK's
|
|
189
|
-
* `lib/_parse/_transform.py::transform_schema`:
|
|
190
|
-
*
|
|
191
|
-
* 1. Universal keys (`$ref`, `$defs`, `type`, `anyOf`/`oneOf`/`allOf`, `enum`, `const`,
|
|
192
|
-
* `description`, `title`, `default`, `nullable`) are preserved on every node.
|
|
193
|
-
* 2. Per-type keys are kept additively (object → `properties`/`required`/`additionalProperties`,
|
|
194
|
-
* array → `items`/`prefixItems` plus `minItems` only when 0 or 1, string → `format`
|
|
195
|
-
* only when in the supported value set).
|
|
196
|
-
* 3. Everything else is demoted into the node's `description` as `\n\n{key: value, ...}`
|
|
197
|
-
* so the model still sees the constraint as a natural-language hint.
|
|
198
|
-
*
|
|
199
|
-
* Object nodes default to `additionalProperties: false`, but explicit open-map
|
|
200
|
-
* declarations (`additionalProperties: true` or a schema literal — Zod's
|
|
201
|
-
* `z.record(z.string(), z.unknown())` produces `{}`) are preserved. The strict-mode
|
|
202
|
-
* pass downstream demotes those shapes to non-strict instead of fabricating a closed
|
|
203
|
-
* object, so callers like the resolve tool keep working open-map semantics.
|
|
204
|
-
*/
|
|
205
212
|
export declare function normalizeAnthropicToolSchema(schema: unknown): unknown;
|
|
206
213
|
export {};
|
|
@@ -41,3 +41,11 @@ export declare function resolveAwsCredentials(opts?: CredentialResolveOptions):
|
|
|
41
41
|
export declare function tokenizeCredentialProcessCommand(cmd: string): string[];
|
|
42
42
|
/** Test/diagnostic helper — drops cached credentials. */
|
|
43
43
|
export declare function clearAwsCredentialCache(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Drop the cache entry for one profile/region. Called by the Bedrock provider on
|
|
46
|
+
* 401/403 responses so stale credentials are re-resolved instead of served until restart.
|
|
47
|
+
*/
|
|
48
|
+
export declare function invalidateAwsCredentialCache(opts?: {
|
|
49
|
+
profile?: string;
|
|
50
|
+
region?: string;
|
|
51
|
+
}): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ServiceTier, StreamFunction, StreamOptions, ToolChoice } from "../types";
|
|
2
|
+
export declare function parseAzureDeploymentNameMap(value: string | undefined): Map<string, string>;
|
|
2
3
|
export interface AzureOpenAIResponsesOptions extends StreamOptions {
|
|
3
4
|
reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
4
5
|
reasoningSummary?: "auto" | "detailed" | "concise" | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProviderHttpError } from "../errors";
|
|
1
2
|
import type { Context, Model, StreamFunction, StreamOptions } from "../types";
|
|
2
3
|
import type { Content, FunctionCallingConfigMode, ThinkingConfig } from "./google-shared";
|
|
3
4
|
import { type GoogleThinkingLevel } from "./google-shared";
|
|
@@ -6,6 +7,10 @@ import { type GoogleThinkingLevel } from "./google-shared";
|
|
|
6
7
|
* `import { GoogleThinkingLevel } from "./google-gemini-cli"` callers keep working.
|
|
7
8
|
*/
|
|
8
9
|
export type { GoogleThinkingLevel };
|
|
10
|
+
/** Non-2xx response (or in-stream error chunk) from the Cloud Code Assist API. */
|
|
11
|
+
export declare class GeminiCliApiError extends ProviderHttpError {
|
|
12
|
+
readonly name = "GeminiCliApiError";
|
|
13
|
+
}
|
|
9
14
|
export interface GoogleGeminiCliOptions extends StreamOptions {
|
|
10
15
|
/**
|
|
11
16
|
* Tool selection mode. String forms map directly to Gemini
|
|
@@ -29,10 +34,26 @@ export interface GoogleGeminiCliOptions extends StreamOptions {
|
|
|
29
34
|
budgetTokens?: number;
|
|
30
35
|
/** Thinking level. Use for Gemini 3 models (LOW/HIGH for Pro, MINIMAL/LOW/MEDIUM/HIGH for Flash). */
|
|
31
36
|
level?: GoogleThinkingLevel;
|
|
37
|
+
/**
|
|
38
|
+
* Explicit wire suppression when `enabled` is false. Cloud Code Assist
|
|
39
|
+
* re-applies the per-id baked server default when thinkingConfig is
|
|
40
|
+
* omitted, so models with `thinking.suppressWhenOff` must send
|
|
41
|
+
* `includeThoughts: false` plus a MINIMAL level (or zero budget).
|
|
42
|
+
*/
|
|
43
|
+
suppress?: {
|
|
44
|
+
level: GoogleThinkingLevel;
|
|
45
|
+
} | {
|
|
46
|
+
budget: number;
|
|
47
|
+
};
|
|
32
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Upstream wire model id override for collapsed effort-tier variants.
|
|
51
|
+
* Serialized as `requestModelId ?? model.requestModelId ?? model.id`.
|
|
52
|
+
*/
|
|
53
|
+
requestModelId?: string;
|
|
33
54
|
projectId?: string;
|
|
34
55
|
}
|
|
35
|
-
export { ANTIGRAVITY_SYSTEM_INSTRUCTION, getAntigravityUserAgent, getGeminiCliHeaders, getGeminiCliUserAgent, } from "
|
|
56
|
+
export { ANTIGRAVITY_NO_PREAMBLE_INSTRUCTION, ANTIGRAVITY_SYSTEM_INSTRUCTION, getAntigravityUserAgent, getGeminiCliHeaders, getGeminiCliUserAgent, } from "@prometheus-ai/catalog/wire/gemini-headers";
|
|
36
57
|
interface ParsedGeminiCliCredentials {
|
|
37
58
|
accessToken: string;
|
|
38
59
|
projectId: string;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared utilities for Google Generative AI and Google Cloud Code Assist providers.
|
|
3
3
|
*/
|
|
4
|
+
import { ProviderHttpError } from "../errors";
|
|
4
5
|
import type { AssistantMessage, Context, FetchImpl, Model, StopReason, StreamOptions, TextContent, ThinkingContent, Tool, ToolCall } from "../types";
|
|
5
6
|
import { AssistantMessageEventStream } from "../utils/event-stream";
|
|
6
7
|
import { normalizeSchemaForGoogle } from "../utils/schema";
|
|
7
8
|
import type { Content, FinishReason, FunctionCallingConfigMode, GenerateContentParameters, GenerateContentResponse, Part } from "./google-types";
|
|
8
9
|
export type { Content, FunctionCallingConfigMode, GenerateContentParameters, GenerateContentResponse, ThinkingConfig, } from "./google-types";
|
|
9
10
|
export { normalizeSchemaForGoogle };
|
|
11
|
+
/** Non-2xx response (or in-stream error chunk) from the Google Generative Language / Vertex API. */
|
|
12
|
+
export declare class GoogleApiError extends ProviderHttpError {
|
|
13
|
+
readonly name = "GoogleApiError";
|
|
14
|
+
}
|
|
10
15
|
type GoogleApiType = "google-generative-ai" | "google-gemini-cli" | "google-vertex";
|
|
11
16
|
/**
|
|
12
17
|
* Thinking level for Gemini 3 models. Mirrors Google's `ThinkingLevel` enum values.
|
|
@@ -92,6 +97,23 @@ export declare function mapStopReason(reason: FinishReason): StopReason;
|
|
|
92
97
|
* Map string finish reason to our StopReason (for raw API responses).
|
|
93
98
|
*/
|
|
94
99
|
export declare function mapStopReasonString(reason: string): StopReason;
|
|
100
|
+
/**
|
|
101
|
+
* Bounded retries for the well-known Gemini "empty response" failure: a benign
|
|
102
|
+
* `finishReason: STOP` carrying only an empty/whitespace text part and no tool call.
|
|
103
|
+
* Shared by the public/Vertex `streamGoogleGenAI` path and the Cloud Code Assist
|
|
104
|
+
* (`google-gemini-cli`/`google-antigravity`) provider so both apply the same policy.
|
|
105
|
+
*/
|
|
106
|
+
export declare const MAX_EMPTY_STREAM_RETRIES = 2;
|
|
107
|
+
export declare const EMPTY_STREAM_BASE_DELAY_MS = 500;
|
|
108
|
+
/**
|
|
109
|
+
* Whether a completed Google assistant message carries content worth delivering.
|
|
110
|
+
*
|
|
111
|
+
* A tool call or any non-whitespace text counts as meaningful. An empty/whitespace-only
|
|
112
|
+
* text part — or thinking that never produced an answer — is the "empty response" failure:
|
|
113
|
+
* delivered as-is the agent loop has nothing to act on and silently halts, so the request
|
|
114
|
+
* must be retried instead of surfaced.
|
|
115
|
+
*/
|
|
116
|
+
export declare function hasMeaningfulGoogleContent(output: AssistantMessage): boolean;
|
|
95
117
|
export declare function nextToolCallId(name: string): string;
|
|
96
118
|
/**
|
|
97
119
|
* Push the appropriate `text_end` / `thinking_end` event for the given block.
|
|
@@ -128,11 +128,23 @@ export interface UsageMetadata {
|
|
|
128
128
|
totalTokenCount?: number;
|
|
129
129
|
cachedContentTokenCount?: number;
|
|
130
130
|
}
|
|
131
|
+
/** Prompt-level safety feedback; `blockReason` is set (with no candidates) when the prompt is blocked. */
|
|
132
|
+
export interface PromptFeedback {
|
|
133
|
+
blockReason?: string;
|
|
134
|
+
blockReasonMessage?: string;
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
}
|
|
131
137
|
/** Single SSE chunk's parsed JSON body. */
|
|
132
138
|
export interface GenerateContentResponse {
|
|
133
139
|
candidates?: Candidate[];
|
|
134
140
|
usageMetadata?: UsageMetadata;
|
|
135
141
|
modelVersion?: string;
|
|
136
142
|
responseId?: string;
|
|
137
|
-
promptFeedback?:
|
|
143
|
+
promptFeedback?: PromptFeedback;
|
|
144
|
+
/** In-band stream failure (quota, internal error) delivered as a final JSON event. */
|
|
145
|
+
error?: {
|
|
146
|
+
code?: number;
|
|
147
|
+
message?: string;
|
|
148
|
+
status?: string;
|
|
149
|
+
};
|
|
138
150
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Mock provider for tests.
|
|
3
3
|
*
|
|
4
4
|
* Implements `Model<"mock">` + `streamMock` so test code can drive
|
|
5
|
-
*
|
|
5
|
+
* agent-core / streamSimple-shaped consumers without an HTTP client.
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
8
|
*
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* // Inspect calls afterwards.
|
|
42
42
|
* expect(mock.calls).toHaveLength(2);
|
|
43
43
|
*/
|
|
44
|
-
import type { Api, Context, Model, SimpleStreamOptions, StopReason, Usage } from "../types";
|
|
44
|
+
import type { Api, Context, Model, SimpleStreamOptions, StopDetails, StopReason, Usage } from "../types";
|
|
45
45
|
import { AssistantMessageEventStream } from "../utils/event-stream";
|
|
46
46
|
/** The API string this provider serves. */
|
|
47
47
|
export declare const MOCK_API: "mock";
|
|
@@ -67,6 +67,10 @@ export interface MockResponse {
|
|
|
67
67
|
content?: ReadonlyArray<MockContent>;
|
|
68
68
|
/** Stop reason. Defaults to `"toolUse"` when content has tool calls, else `"stop"`. */
|
|
69
69
|
stopReason?: StopReason;
|
|
70
|
+
/** Structured terminal stop classification, e.g. Anthropic refusal metadata. */
|
|
71
|
+
stopDetails?: StopDetails | null;
|
|
72
|
+
/** Error text paired with an explicit `"error"` stop reason. */
|
|
73
|
+
errorMessage?: string;
|
|
70
74
|
/** Usage stats. Missing fields default to 0; missing `cost.total` is recomputed from components. */
|
|
71
75
|
usage?: Partial<Omit<Usage, "cost">> & {
|
|
72
76
|
cost?: Partial<Usage["cost"]>;
|
|
@@ -142,6 +146,7 @@ export declare class MockModel implements Model<MockApi> {
|
|
|
142
146
|
readonly cost: Model["cost"];
|
|
143
147
|
readonly contextWindow: number;
|
|
144
148
|
readonly maxTokens: number;
|
|
149
|
+
readonly compat: undefined;
|
|
145
150
|
/** Recorded calls in invocation order. */
|
|
146
151
|
readonly calls: MockCall[];
|
|
147
152
|
iterator?: Iterator<MockHandler> | AsyncIterator<MockHandler>;
|
|
@@ -167,7 +172,7 @@ export declare class MockModel implements Model<MockApi> {
|
|
|
167
172
|
export declare function isMockModel(model: Model<Api>): model is MockModel;
|
|
168
173
|
/** Construct a mock model. */
|
|
169
174
|
export declare function createMockModel(options?: MockModelOptions): MockModel;
|
|
170
|
-
/** Stream function for `Model<"mock">`. Matches the
|
|
175
|
+
/** Stream function for `Model<"mock">`. Matches the Prometheus AI per-provider stream signature. */
|
|
171
176
|
export declare function streamMock(model: Model<Api>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;
|
|
172
177
|
/** Convenience: register the mock provider with the global custom API registry. */
|
|
173
178
|
export declare function registerMockApi(sourceId?: string): void;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { ProviderHttpError } from "../errors";
|
|
1
2
|
import type { StreamFunction, StreamOptions, ToolChoice } from "../types";
|
|
3
|
+
/** Non-2xx response from the Ollama `/api/chat` endpoint. */
|
|
4
|
+
export declare class OllamaApiError extends ProviderHttpError {
|
|
5
|
+
readonly name = "OllamaApiError";
|
|
6
|
+
}
|
|
2
7
|
export interface OllamaChatOptions extends StreamOptions {
|
|
3
8
|
reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
9
|
+
disableReasoning?: boolean;
|
|
4
10
|
toolChoice?: ToolChoice;
|
|
5
11
|
}
|
|
6
12
|
export declare const streamOllama: StreamFunction<"ollama-chat">;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* non-strict defaults (e.g. `stream_options.include_obfuscation`) — does not
|
|
8
8
|
* trip 400s on shapes we simply ignore.
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import { z } from "zod/v4";
|
|
11
|
+
import type { ChatCompletionContentPart, ChatCompletionCreateParams, ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionTool, ChatCompletionToolChoiceOption } from "./openai-chat-wire";
|
|
12
12
|
export declare const textPartSchema: z.ZodObject<{
|
|
13
13
|
type: z.ZodLiteral<"text">;
|
|
14
14
|
text: z.ZodString;
|
|
@@ -16,7 +16,7 @@ export declare const textPartSchema: z.ZodObject<{
|
|
|
16
16
|
/**
|
|
17
17
|
* OpenAI documents `image_url` as either `{ url: string, detail?: ... }` or —
|
|
18
18
|
* older clients — a bare string. Accept both shapes; downstream we extract a
|
|
19
|
-
* URL. `detail` is accepted for forward-compat but currently dropped (
|
|
19
|
+
* URL. `detail` is accepted for forward-compat but currently dropped (Prometheus AI's
|
|
20
20
|
* `ImageContent` has no detail field — TODO: plumb through if/when added).
|
|
21
21
|
*/
|
|
22
22
|
export declare const imagePartSchema: z.ZodObject<{
|
|
@@ -283,6 +283,7 @@ export declare const assistantMessageSchema: z.ZodObject<{
|
|
|
283
283
|
arguments: z.ZodString;
|
|
284
284
|
}, z.core.$strip>;
|
|
285
285
|
}, z.core.$strip>>>;
|
|
286
|
+
reasoning_content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
286
287
|
}, z.core.$strip>;
|
|
287
288
|
export declare const toolMessageSchema: z.ZodObject<{
|
|
288
289
|
role: z.ZodLiteral<"tool">;
|
|
@@ -489,6 +490,7 @@ export declare const messageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
489
490
|
arguments: z.ZodString;
|
|
490
491
|
}, z.core.$strip>;
|
|
491
492
|
}, z.core.$strip>>>;
|
|
493
|
+
reasoning_content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
492
494
|
}, z.core.$strip>, z.ZodObject<{
|
|
493
495
|
role: z.ZodLiteral<"tool">;
|
|
494
496
|
content: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -700,6 +702,7 @@ export declare const openaiChatRequestSchema: z.ZodObject<{
|
|
|
700
702
|
arguments: z.ZodString;
|
|
701
703
|
}, z.core.$strip>;
|
|
702
704
|
}, z.core.$strip>>>;
|
|
705
|
+
reasoning_content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
703
706
|
}, z.core.$strip>, z.ZodObject<{
|
|
704
707
|
role: z.ZodLiteral<"tool">;
|
|
705
708
|
content: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Parsed inbound OpenAI chat-completions request, ready to feed into
|
|
2
|
+
* Parsed inbound OpenAI chat-completions request, ready to feed into Prometheus AI
|
|
3
3
|
* `stream(model, context, options)`.
|
|
4
4
|
*/
|
|
5
|
-
import type { AuthGatewayParsedRequest as ParsedRequest } from "../auth-gateway/types";
|
|
5
|
+
import type { AuthGatewayStreamControl, AuthGatewayParsedRequest as ParsedRequest } from "../auth-gateway/types";
|
|
6
6
|
import type { AssistantMessage, AssistantMessageEventStream } from "../types";
|
|
7
7
|
export type { ParsedRequest };
|
|
8
8
|
export declare function parseRequest(body: unknown, headers?: Headers): ParsedRequest;
|
|
9
9
|
export declare function encodeResponse(message: AssistantMessage, requestedModelId: string): Record<string, unknown>;
|
|
10
|
-
export declare function encodeStream(events: AssistantMessageEventStream, requestedModelId: string, options?: ParsedRequest["options"]): ReadableStream<Uint8Array>;
|
|
10
|
+
export declare function encodeStream(events: AssistantMessageEventStream, requestedModelId: string, options?: ParsedRequest["options"], control?: AuthGatewayStreamControl): ReadableStream<Uint8Array>;
|
|
11
11
|
/**
|
|
12
12
|
* OpenAI chat-completions error envelope:
|
|
13
13
|
* `{ error: { message, type } }`
|