jeopi-ai 16.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4347 -0
- package/README.md +1193 -0
- package/dist/types/api-registry.d.ts +30 -0
- package/dist/types/auth-broker/client.d.ts +73 -0
- package/dist/types/auth-broker/discover.d.ts +35 -0
- package/dist/types/auth-broker/index.d.ts +7 -0
- package/dist/types/auth-broker/refresher.d.ts +25 -0
- package/dist/types/auth-broker/remote-store.d.ts +102 -0
- package/dist/types/auth-broker/server.d.ts +43 -0
- package/dist/types/auth-broker/snapshot-cache.d.ts +17 -0
- package/dist/types/auth-broker/types.d.ts +107 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +411 -0
- package/dist/types/auth-gateway/http.d.ts +39 -0
- package/dist/types/auth-gateway/index.d.ts +3 -0
- package/dist/types/auth-gateway/server.d.ts +36 -0
- package/dist/types/auth-gateway/types.d.ts +123 -0
- package/dist/types/auth-retry.d.ts +124 -0
- package/dist/types/auth-storage.d.ts +1026 -0
- package/dist/types/dialect/anthropic.d.ts +15 -0
- package/dist/types/dialect/catalog.d.ts +3 -0
- package/dist/types/dialect/coercion.d.ts +23 -0
- package/dist/types/dialect/deepseek.d.ts +14 -0
- package/dist/types/dialect/demotion.d.ts +23 -0
- package/dist/types/dialect/examples.d.ts +2 -0
- package/dist/types/dialect/factory.d.ts +3 -0
- package/dist/types/dialect/fenced-thinking.d.ts +53 -0
- package/dist/types/dialect/gemini.d.ts +17 -0
- package/dist/types/dialect/gemma.d.ts +15 -0
- package/dist/types/dialect/glm.d.ts +9 -0
- package/dist/types/dialect/harmony.d.ts +8 -0
- package/dist/types/dialect/hermes.d.ts +9 -0
- package/dist/types/dialect/history.d.ts +3 -0
- package/dist/types/dialect/index.d.ts +11 -0
- package/dist/types/dialect/inventory.d.ts +12 -0
- package/dist/types/dialect/kimi.d.ts +14 -0
- package/dist/types/dialect/minimax.d.ts +3 -0
- package/dist/types/dialect/owned-stream.d.ts +4 -0
- package/dist/types/dialect/qwen3.d.ts +9 -0
- package/dist/types/dialect/rendering.d.ts +45 -0
- package/dist/types/dialect/thinking.d.ts +6 -0
- package/dist/types/dialect/types.d.ts +69 -0
- package/dist/types/dialect/xml.d.ts +9 -0
- package/dist/types/error/abort.d.ts +14 -0
- package/dist/types/error/auth-classify.d.ts +16 -0
- package/dist/types/error/auth.d.ts +27 -0
- package/dist/types/error/aws.d.ts +23 -0
- package/dist/types/error/classes.d.ts +102 -0
- package/dist/types/error/finalize.d.ts +39 -0
- package/dist/types/error/flags.d.ts +79 -0
- package/dist/types/error/format.d.ts +20 -0
- package/dist/types/error/gateway.d.ts +20 -0
- package/dist/types/error/index.d.ts +13 -0
- package/dist/types/error/oauth.d.ts +43 -0
- package/dist/types/error/provider.d.ts +42 -0
- package/dist/types/error/rate-limit.d.ts +59 -0
- package/dist/types/error/retryable.d.ts +27 -0
- package/dist/types/error/validation.d.ts +32 -0
- package/dist/types/index.d.ts +49 -0
- package/dist/types/provider-details.d.ts +24 -0
- package/dist/types/providers/__tests__/google-auth.test.d.ts +1 -0
- package/dist/types/providers/__tests__/kimi-code-thinking.test.d.ts +1 -0
- package/dist/types/providers/__tests__/openai-codex-error.test.d.ts +1 -0
- package/dist/types/providers/amazon-bedrock.d.ts +39 -0
- package/dist/types/providers/anthropic-client.d.ts +94 -0
- package/dist/types/providers/anthropic-messages-server-schema.d.ts +497 -0
- package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
- package/dist/types/providers/anthropic-wire.d.ts +318 -0
- package/dist/types/providers/anthropic.d.ts +248 -0
- package/dist/types/providers/aws-credentials.d.ts +53 -0
- package/dist/types/providers/aws-eventstream.d.ts +39 -0
- package/dist/types/providers/aws-sigv4.d.ts +55 -0
- package/dist/types/providers/azure-openai-responses.d.ts +16 -0
- package/dist/types/providers/cursor.d.ts +91 -0
- package/dist/types/providers/devin.d.ts +12 -0
- package/dist/types/providers/error-message.d.ts +27 -0
- package/dist/types/providers/github-copilot-headers.d.ts +40 -0
- package/dist/types/providers/gitlab-duo-workflow.d.ts +254 -0
- package/dist/types/providers/gitlab-duo.d.ts +27 -0
- package/dist/types/providers/google-auth.d.ts +32 -0
- package/dist/types/providers/google-gemini-cli.d.ts +118 -0
- package/dist/types/providers/google-interactions.d.ts +65 -0
- package/dist/types/providers/google-shared.d.ts +203 -0
- package/dist/types/providers/google-types.d.ts +155 -0
- package/dist/types/providers/google-vertex.d.ts +7 -0
- package/dist/types/providers/google.d.ts +4 -0
- package/dist/types/providers/grammar.d.ts +1 -0
- package/dist/types/providers/kimi.d.ts +27 -0
- package/dist/types/providers/mock.d.ts +178 -0
- package/dist/types/providers/ollama.d.ts +7 -0
- package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
- package/dist/types/providers/openai-chat-server-schema.d.ts +695 -0
- package/dist/types/providers/openai-chat-server.d.ts +16 -0
- package/dist/types/providers/openai-chat-wire.d.ts +644 -0
- package/dist/types/providers/openai-codex/request-transformer.d.ts +54 -0
- package/dist/types/providers/openai-codex/response-handler.d.ts +26 -0
- package/dist/types/providers/openai-codex-responses.d.ts +108 -0
- package/dist/types/providers/openai-completions.d.ts +45 -0
- package/dist/types/providers/openai-reasoning-fallback.d.ts +25 -0
- package/dist/types/providers/openai-responses-server-schema.d.ts +349 -0
- package/dist/types/providers/openai-responses-server.d.ts +17 -0
- package/dist/types/providers/openai-responses-wire.d.ts +6065 -0
- package/dist/types/providers/openai-responses.d.ts +126 -0
- package/dist/types/providers/openai-shared.d.ts +506 -0
- package/dist/types/providers/pi-native-client.d.ts +13 -0
- package/dist/types/providers/pi-native-server.d.ts +69 -0
- package/dist/types/providers/register-builtins.d.ts +32 -0
- package/dist/types/providers/synthetic.d.ts +26 -0
- package/dist/types/providers/transform-messages.d.ts +11 -0
- package/dist/types/providers/vision-guard.d.ts +20 -0
- package/dist/types/registry/aimlapi.d.ts +4 -0
- package/dist/types/registry/alibaba-coding-plan.d.ts +8 -0
- package/dist/types/registry/amazon-bedrock.d.ts +5 -0
- package/dist/types/registry/anthropic.d.ts +10 -0
- package/dist/types/registry/api-key-login.d.ts +42 -0
- package/dist/types/registry/api-key-validation.d.ts +43 -0
- package/dist/types/registry/azure.d.ts +4 -0
- package/dist/types/registry/cerebras.d.ts +7 -0
- package/dist/types/registry/cloudflare-ai-gateway.d.ts +13 -0
- package/dist/types/registry/coreweave.d.ts +7 -0
- package/dist/types/registry/cursor.d.ts +7 -0
- package/dist/types/registry/deepseek.d.ts +8 -0
- package/dist/types/registry/derived.d.ts +5 -0
- package/dist/types/registry/devin.d.ts +8 -0
- package/dist/types/registry/firepass.d.ts +16 -0
- package/dist/types/registry/fireworks.d.ts +7 -0
- package/dist/types/registry/github-copilot.d.ts +7 -0
- package/dist/types/registry/gitlab-duo-workflow.d.ts +10 -0
- package/dist/types/registry/gitlab-duo.d.ts +9 -0
- package/dist/types/registry/google-antigravity.d.ts +9 -0
- package/dist/types/registry/google-gemini-cli.d.ts +9 -0
- package/dist/types/registry/google-vertex.d.ts +5 -0
- package/dist/types/registry/google.d.ts +4 -0
- package/dist/types/registry/groq.d.ts +4 -0
- package/dist/types/registry/huggingface.d.ts +7 -0
- package/dist/types/registry/index.d.ts +4 -0
- package/dist/types/registry/kagi.d.ts +14 -0
- package/dist/types/registry/kilo.d.ts +7 -0
- package/dist/types/registry/kimi-code.d.ts +7 -0
- package/dist/types/registry/litellm.d.ts +13 -0
- package/dist/types/registry/llama-cpp.d.ts +8 -0
- package/dist/types/registry/lm-studio.d.ts +8 -0
- package/dist/types/registry/minimax-code-cn.d.ts +6 -0
- package/dist/types/registry/minimax-code.d.ts +6 -0
- package/dist/types/registry/minimax.d.ts +4 -0
- package/dist/types/registry/mistral.d.ts +4 -0
- package/dist/types/registry/moonshot.d.ts +7 -0
- package/dist/types/registry/nanogpt.d.ts +7 -0
- package/dist/types/registry/nvidia.d.ts +7 -0
- package/dist/types/registry/oauth/__tests__/xai-oauth.test.d.ts +1 -0
- package/dist/types/registry/oauth/anthropic.d.ts +23 -0
- package/dist/types/registry/oauth/callback-server.d.ts +72 -0
- package/dist/types/registry/oauth/cursor.d.ts +15 -0
- package/dist/types/registry/oauth/devin.d.ts +5 -0
- package/dist/types/registry/oauth/github-copilot.d.ts +30 -0
- package/dist/types/registry/oauth/gitlab-duo-workflow.d.ts +6 -0
- package/dist/types/registry/oauth/gitlab-duo.d.ts +3 -0
- package/dist/types/registry/oauth/google-antigravity.d.ts +11 -0
- package/dist/types/registry/oauth/google-gemini-cli.d.ts +10 -0
- package/dist/types/registry/oauth/google-oauth-shared.d.ts +22 -0
- package/dist/types/registry/oauth/index.d.ts +64 -0
- package/dist/types/registry/oauth/kimi.d.ts +21 -0
- package/dist/types/registry/oauth/minimax-code.d.ts +27 -0
- package/dist/types/registry/oauth/openai-codex.d.ts +33 -0
- package/dist/types/registry/oauth/opencode.d.ts +18 -0
- package/dist/types/registry/oauth/perplexity.d.ts +9 -0
- package/dist/types/registry/oauth/pkce.d.ts +8 -0
- package/dist/types/registry/oauth/types.d.ts +56 -0
- package/dist/types/registry/oauth/wafer.d.ts +1 -0
- package/dist/types/registry/oauth/xai-oauth.d.ts +52 -0
- package/dist/types/registry/oauth/xiaomi.d.ts +25 -0
- package/dist/types/registry/ollama-cloud.d.ts +7 -0
- package/dist/types/registry/ollama.d.ts +12 -0
- package/dist/types/registry/openai-codex-device.d.ts +8 -0
- package/dist/types/registry/openai-codex.d.ts +9 -0
- package/dist/types/registry/openai.d.ts +4 -0
- package/dist/types/registry/opencode-go.d.ts +6 -0
- package/dist/types/registry/opencode-zen.d.ts +6 -0
- package/dist/types/registry/openrouter.d.ts +13 -0
- package/dist/types/registry/parallel.d.ts +14 -0
- package/dist/types/registry/perplexity.d.ts +7 -0
- package/dist/types/registry/qianfan.d.ts +7 -0
- package/dist/types/registry/qwen-portal.d.ts +7 -0
- package/dist/types/registry/registry.d.ts +303 -0
- package/dist/types/registry/sakana.d.ts +7 -0
- package/dist/types/registry/synthetic.d.ts +6 -0
- package/dist/types/registry/tavily.d.ts +14 -0
- package/dist/types/registry/together.d.ts +6 -0
- package/dist/types/registry/types.d.ts +51 -0
- package/dist/types/registry/umans.d.ts +7 -0
- package/dist/types/registry/venice.d.ts +13 -0
- package/dist/types/registry/vercel-ai-gateway.d.ts +7 -0
- package/dist/types/registry/vllm.d.ts +7 -0
- package/dist/types/registry/wafer-serverless.d.ts +6 -0
- package/dist/types/registry/xai-oauth.d.ts +7 -0
- package/dist/types/registry/xai.d.ts +4 -0
- package/dist/types/registry/xiaomi-token-plan-ams.d.ts +6 -0
- package/dist/types/registry/xiaomi-token-plan-cn.d.ts +6 -0
- package/dist/types/registry/xiaomi-token-plan-sgp.d.ts +6 -0
- package/dist/types/registry/xiaomi.d.ts +6 -0
- package/dist/types/registry/zai.d.ts +7 -0
- package/dist/types/registry/zenmux.d.ts +7 -0
- package/dist/types/registry/zhipu-coding-plan.d.ts +7 -0
- package/dist/types/stream.d.ts +44 -0
- package/dist/types/types.d.ts +715 -0
- package/dist/types/usage/claude.d.ts +4 -0
- package/dist/types/usage/gemini.d.ts +2 -0
- package/dist/types/usage/github-copilot.d.ts +7 -0
- package/dist/types/usage/google-antigravity.d.ts +15 -0
- package/dist/types/usage/kimi.d.ts +2 -0
- package/dist/types/usage/minimax-code.d.ts +2 -0
- package/dist/types/usage/ollama.d.ts +5 -0
- package/dist/types/usage/openai-codex-base-url.d.ts +18 -0
- package/dist/types/usage/openai-codex-reset.d.ts +79 -0
- package/dist/types/usage/openai-codex.d.ts +3 -0
- package/dist/types/usage/opencode-go.d.ts +2 -0
- package/dist/types/usage/shared.d.ts +1 -0
- package/dist/types/usage/zai.d.ts +2 -0
- package/dist/types/usage.d.ts +346 -0
- package/dist/types/utils/abort.d.ts +25 -0
- package/dist/types/utils/anthropic-auth.d.ts +35 -0
- package/dist/types/utils/block-symbols.d.ts +20 -0
- package/dist/types/utils/deterministic-id.d.ts +16 -0
- package/dist/types/utils/empty-completion-retry.d.ts +21 -0
- package/dist/types/utils/event-stream.d.ts +30 -0
- package/dist/types/utils/foundry.d.ts +1 -0
- package/dist/types/utils/google-validation.d.ts +2 -0
- package/dist/types/utils/harmony-leak.d.ts +118 -0
- package/dist/types/utils/http-inspector.d.ts +30 -0
- package/dist/types/utils/idle-iterator.d.ts +137 -0
- package/dist/types/utils/leaked-thinking-stream.d.ts +29 -0
- package/dist/types/utils/openai-http.d.ts +54 -0
- package/dist/types/utils/openrouter-headers.d.ts +1 -0
- package/dist/types/utils/parse-bind.d.ts +23 -0
- package/dist/types/utils/provider-response.d.ts +3 -0
- package/dist/types/utils/proxy.d.ts +29 -0
- package/dist/types/utils/request-debug.d.ts +29 -0
- package/dist/types/utils/retry-after.d.ts +4 -0
- package/dist/types/utils/retry.d.ts +14 -0
- package/dist/types/utils/schema/adapt.d.ts +24 -0
- package/dist/types/utils/schema/compatibility.d.ts +30 -0
- package/dist/types/utils/schema/dereference.d.ts +11 -0
- package/dist/types/utils/schema/draft.d.ts +10 -0
- package/dist/types/utils/schema/equality.d.ts +4 -0
- package/dist/types/utils/schema/fields.d.ts +54 -0
- package/dist/types/utils/schema/index.d.ts +15 -0
- package/dist/types/utils/schema/json-schema-validator.d.ts +20 -0
- package/dist/types/utils/schema/meta-validator.d.ts +2 -0
- package/dist/types/utils/schema/normalize.d.ts +124 -0
- package/dist/types/utils/schema/spill.d.ts +8 -0
- package/dist/types/utils/schema/stamps.d.ts +17 -0
- package/dist/types/utils/schema/strict-tool-validation.d.ts +16 -0
- package/dist/types/utils/schema/types.d.ts +4 -0
- package/dist/types/utils/schema/typescript.d.ts +18 -0
- package/dist/types/utils/schema/wire.d.ts +92 -0
- package/dist/types/utils/schema/zod-decontaminate.d.ts +31 -0
- package/dist/types/utils/sdk-stream-timeout.d.ts +33 -0
- package/dist/types/utils/sse-debug.d.ts +5 -0
- package/dist/types/utils/stream-markup-healing.d.ts +87 -0
- package/dist/types/utils/thinking-loop.d.ts +102 -0
- package/dist/types/utils/tool-call-loop-guard.d.ts +26 -0
- package/dist/types/utils/tool-choice.d.ts +50 -0
- package/dist/types/utils/validation.d.ts +42 -0
- package/dist/types/utils.d.ts +24 -0
- package/package.json +139 -0
- package/src/api-registry.ts +109 -0
- package/src/auth-broker/client.ts +359 -0
- package/src/auth-broker/discover.ts +222 -0
- package/src/auth-broker/index.ts +7 -0
- package/src/auth-broker/refresher.ts +117 -0
- package/src/auth-broker/remote-store.ts +657 -0
- package/src/auth-broker/server.ts +646 -0
- package/src/auth-broker/snapshot-cache.ts +191 -0
- package/src/auth-broker/types.ts +130 -0
- package/src/auth-broker/wire-schemas.ts +249 -0
- package/src/auth-gateway/http.ts +194 -0
- package/src/auth-gateway/index.ts +3 -0
- package/src/auth-gateway/server.ts +802 -0
- package/src/auth-gateway/types.ts +151 -0
- package/src/auth-retry.ts +250 -0
- package/src/auth-storage.ts +5576 -0
- package/src/dialect/anthropic.md +31 -0
- package/src/dialect/anthropic.ts +608 -0
- package/src/dialect/catalog.ts +29 -0
- package/src/dialect/coercion.ts +136 -0
- package/src/dialect/deepseek.md +24 -0
- package/src/dialect/deepseek.ts +609 -0
- package/src/dialect/demotion.ts +36 -0
- package/src/dialect/examples.ts +33 -0
- package/src/dialect/factory.ts +34 -0
- package/src/dialect/fenced-thinking.ts +184 -0
- package/src/dialect/gemini.md +44 -0
- package/src/dialect/gemini.ts +597 -0
- package/src/dialect/gemma.md +33 -0
- package/src/dialect/gemma.ts +387 -0
- package/src/dialect/glm.md +32 -0
- package/src/dialect/glm.ts +456 -0
- package/src/dialect/harmony.md +31 -0
- package/src/dialect/harmony.ts +346 -0
- package/src/dialect/hermes.md +25 -0
- package/src/dialect/hermes.ts +206 -0
- package/src/dialect/history.ts +81 -0
- package/src/dialect/index.ts +15 -0
- package/src/dialect/inventory.ts +73 -0
- package/src/dialect/kimi.md +24 -0
- package/src/dialect/kimi.ts +340 -0
- package/src/dialect/minimax.md +31 -0
- package/src/dialect/minimax.ts +95 -0
- package/src/dialect/owned-stream.ts +470 -0
- package/src/dialect/prompt-template.md +12 -0
- package/src/dialect/qwen3.md +28 -0
- package/src/dialect/qwen3.ts +240 -0
- package/src/dialect/rendering.ts +249 -0
- package/src/dialect/thinking.ts +122 -0
- package/src/dialect/types.ts +57 -0
- package/src/dialect/xml.md +22 -0
- package/src/dialect/xml.ts +90 -0
- package/src/error/abort.ts +18 -0
- package/src/error/auth-classify.ts +30 -0
- package/src/error/auth.ts +48 -0
- package/src/error/aws.ts +31 -0
- package/src/error/classes.ts +186 -0
- package/src/error/finalize.ts +69 -0
- package/src/error/flags.ts +506 -0
- package/src/error/format.ts +45 -0
- package/src/error/gateway.ts +96 -0
- package/src/error/index.ts +13 -0
- package/src/error/oauth.ts +58 -0
- package/src/error/provider.ts +62 -0
- package/src/error/rate-limit.ts +161 -0
- package/src/error/retryable.ts +70 -0
- package/src/error/validation.ts +44 -0
- package/src/index.ts +49 -0
- package/src/provider-details.ts +90 -0
- package/src/providers/__tests__/google-auth.test.ts +144 -0
- package/src/providers/__tests__/kimi-code-thinking.test.ts +112 -0
- package/src/providers/__tests__/openai-codex-error.test.ts +84 -0
- package/src/providers/amazon-bedrock.ts +1042 -0
- package/src/providers/anthropic-client.ts +295 -0
- package/src/providers/anthropic-messages-server-schema.ts +252 -0
- package/src/providers/anthropic-messages-server.ts +756 -0
- package/src/providers/anthropic-wire.ts +318 -0
- package/src/providers/anthropic.ts +4078 -0
- package/src/providers/aws-credentials.ts +586 -0
- package/src/providers/aws-eventstream.ts +181 -0
- package/src/providers/aws-sigv4.ts +218 -0
- package/src/providers/azure-openai-responses.ts +382 -0
- package/src/providers/cursor/proto/agent.proto +3526 -0
- package/src/providers/cursor/proto/buf.gen.yaml +6 -0
- package/src/providers/cursor/proto/buf.yaml +17 -0
- package/src/providers/cursor.ts +2695 -0
- package/src/providers/devin/proto/buf/validate/validate.proto +468 -0
- package/src/providers/devin/proto/buf.gen.yaml +33 -0
- package/src/providers/devin/proto/buf.yaml +17 -0
- package/src/providers/devin/proto/cel/expr/checked.proto +103 -0
- package/src/providers/devin/proto/cel/expr/eval.proto +38 -0
- package/src/providers/devin/proto/cel/expr/explain.proto +15 -0
- package/src/providers/devin/proto/cel/expr/syntax.proto +113 -0
- package/src/providers/devin/proto/cel/expr/value.proto +41 -0
- package/src/providers/devin/proto/connectext/grpc/status/v1/status.proto +11 -0
- package/src/providers/devin/proto/errorspb/errors.proto +56 -0
- package/src/providers/devin/proto/errorspb/hintdetail.proto +7 -0
- package/src/providers/devin/proto/errorspb/markers.proto +10 -0
- package/src/providers/devin/proto/errorspb/tags.proto +12 -0
- package/src/providers/devin/proto/errorspb/testing.proto +6 -0
- package/src/providers/devin/proto/exa/analytics_pb/analytics.proto +188 -0
- package/src/providers/devin/proto/exa/api_server_pb/api_server.proto +2461 -0
- package/src/providers/devin/proto/exa/auth_pb/auth.proto +19 -0
- package/src/providers/devin/proto/exa/auto_cascade_common_pb/auto_cascade_common.proto +79 -0
- package/src/providers/devin/proto/exa/browser_preview_pb/browser_preview.proto +32 -0
- package/src/providers/devin/proto/exa/bug_checker_pb/bug_checker.proto +22 -0
- package/src/providers/devin/proto/exa/cascade_plugins_pb/cascade_plugins.proto +262 -0
- package/src/providers/devin/proto/exa/chat_client_server_pb/chat_client_server.proto +57 -0
- package/src/providers/devin/proto/exa/chat_pb/chat.proto +449 -0
- package/src/providers/devin/proto/exa/code_edit/code_edit_pb/code_edit.proto +186 -0
- package/src/providers/devin/proto/exa/codeium_common_pb/codeium_common.proto +4157 -0
- package/src/providers/devin/proto/exa/context_module_pb/context_module.proto +175 -0
- package/src/providers/devin/proto/exa/cortex_pb/cortex.proto +3268 -0
- package/src/providers/devin/proto/exa/dev_pb/dev.proto +26 -0
- package/src/providers/devin/proto/exa/diff_action_pb/diff_action.proto +75 -0
- package/src/providers/devin/proto/exa/eval/pr_eval/datasets_pb/datasets.proto +103 -0
- package/src/providers/devin/proto/exa/eval_pb/eval.proto +1315 -0
- package/src/providers/devin/proto/exa/extension_server_pb/extension_server.proto +556 -0
- package/src/providers/devin/proto/exa/file_system_provider_pb/file_system_provider.proto +75 -0
- package/src/providers/devin/proto/exa/index_pb/index.proto +461 -0
- package/src/providers/devin/proto/exa/knowledge_base_pb/knowledge_base.proto +144 -0
- package/src/providers/devin/proto/exa/language_server_pb/language_server.proto +2385 -0
- package/src/providers/devin/proto/exa/model_management_pb/model_management.proto +186 -0
- package/src/providers/devin/proto/exa/opensearch_clients_pb/opensearch_clients.proto +503 -0
- package/src/providers/devin/proto/exa/product_analytics_pb/product_analytics.proto +37 -0
- package/src/providers/devin/proto/exa/prompt_pb/prompt.proto +92 -0
- package/src/providers/devin/proto/exa/reactive_component_pb/reactive_component.proto +96 -0
- package/src/providers/devin/proto/exa/seat_management_pb/seat_management.proto +2680 -0
- package/src/providers/devin/proto/exa/tokenizer_pb/tokenizer.proto +37 -0
- package/src/providers/devin/proto/exa/trainer_pb/config.proto +647 -0
- package/src/providers/devin/proto/exa/tree_sitter/language_data_pb/language_data.proto +14 -0
- package/src/providers/devin/proto/exa/trust_pb/trust.proto +157 -0
- package/src/providers/devin/proto/exa/user_analytics_pb/user_analytics.proto +519 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/base/api_base.proto +28 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/datastore/datastore_v3.proto +484 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/log/log_service.proto +136 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/remote_api/remote_api.proto +42 -0
- package/src/providers/devin/proto/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +61 -0
- package/src/providers/devin/proto/grpc/binlog/v1/binarylog.proto +84 -0
- package/src/providers/devin/proto/io/prometheus/client/metrics.proto +98 -0
- package/src/providers/devin.ts +577 -0
- package/src/providers/error-message.ts +21 -0
- package/src/providers/github-copilot-headers.ts +141 -0
- package/src/providers/gitlab-duo-workflow-chatml-note.md +1 -0
- package/src/providers/gitlab-duo-workflow.ts +3058 -0
- package/src/providers/gitlab-duo.ts +395 -0
- package/src/providers/google-auth.ts +350 -0
- package/src/providers/google-gemini-cli.ts +1362 -0
- package/src/providers/google-interactions.ts +753 -0
- package/src/providers/google-shared.ts +1103 -0
- package/src/providers/google-types.ts +180 -0
- package/src/providers/google-vertex.ts +183 -0
- package/src/providers/google.ts +87 -0
- package/src/providers/grammar.ts +70 -0
- package/src/providers/kimi.ts +52 -0
- package/src/providers/mock.ts +507 -0
- package/src/providers/ollama.ts +773 -0
- package/src/providers/openai-anthropic-shim.ts +152 -0
- package/src/providers/openai-chat-server-schema.ts +242 -0
- package/src/providers/openai-chat-server.ts +715 -0
- package/src/providers/openai-chat-wire.ts +847 -0
- package/src/providers/openai-codex/request-transformer.ts +295 -0
- package/src/providers/openai-codex/response-handler.ts +102 -0
- package/src/providers/openai-codex-responses.ts +3468 -0
- package/src/providers/openai-completions.ts +2173 -0
- package/src/providers/openai-reasoning-fallback.ts +269 -0
- package/src/providers/openai-responses-reasoning-suppression.md +1 -0
- package/src/providers/openai-responses-server-schema.ts +282 -0
- package/src/providers/openai-responses-server.ts +1280 -0
- package/src/providers/openai-responses-wire.ts +6391 -0
- package/src/providers/openai-responses.ts +1022 -0
- package/src/providers/openai-shared.ts +2648 -0
- package/src/providers/pi-native-client.ts +266 -0
- package/src/providers/pi-native-server.ts +242 -0
- package/src/providers/register-builtins.ts +475 -0
- package/src/providers/synthetic.ts +50 -0
- package/src/providers/transform-messages.ts +787 -0
- package/src/providers/vision-guard.ts +54 -0
- package/src/registry/aimlapi.ts +6 -0
- package/src/registry/alibaba-coding-plan.ts +95 -0
- package/src/registry/amazon-bedrock.ts +22 -0
- package/src/registry/anthropic.ts +26 -0
- package/src/registry/api-key-login.ts +112 -0
- package/src/registry/api-key-validation.ts +161 -0
- package/src/registry/azure.ts +6 -0
- package/src/registry/cerebras.ts +23 -0
- package/src/registry/cloudflare-ai-gateway.ts +45 -0
- package/src/registry/coreweave.ts +40 -0
- package/src/registry/cursor.ts +20 -0
- package/src/registry/deepseek.ts +46 -0
- package/src/registry/derived.ts +9 -0
- package/src/registry/devin.ts +15 -0
- package/src/registry/firepass.ts +32 -0
- package/src/registry/fireworks.ts +28 -0
- package/src/registry/github-copilot.ts +22 -0
- package/src/registry/gitlab-duo-workflow.ts +20 -0
- package/src/registry/gitlab-duo.ts +19 -0
- package/src/registry/google-antigravity.ts +22 -0
- package/src/registry/google-gemini-cli.ts +22 -0
- package/src/registry/google-vertex.ts +38 -0
- package/src/registry/google.ts +6 -0
- package/src/registry/groq.ts +6 -0
- package/src/registry/huggingface.ts +29 -0
- package/src/registry/index.ts +4 -0
- package/src/registry/kagi.ts +46 -0
- package/src/registry/kilo.ts +114 -0
- package/src/registry/kimi-code.ts +17 -0
- package/src/registry/litellm.ts +45 -0
- package/src/registry/llama-cpp.ts +35 -0
- package/src/registry/lm-studio.ts +31 -0
- package/src/registry/minimax-code-cn.ts +12 -0
- package/src/registry/minimax-code.ts +12 -0
- package/src/registry/minimax.ts +6 -0
- package/src/registry/mistral.ts +6 -0
- package/src/registry/moonshot.ts +22 -0
- package/src/registry/nanogpt.ts +22 -0
- package/src/registry/nvidia.ts +61 -0
- package/src/registry/oauth/__tests__/xai-oauth.test.ts +104 -0
- package/src/registry/oauth/anthropic.ts +311 -0
- package/src/registry/oauth/callback-server.ts +315 -0
- package/src/registry/oauth/cursor.ts +171 -0
- package/src/registry/oauth/devin.ts +124 -0
- package/src/registry/oauth/github-copilot.ts +369 -0
- package/src/registry/oauth/gitlab-duo-workflow.ts +146 -0
- package/src/registry/oauth/gitlab-duo.ts +222 -0
- package/src/registry/oauth/google-antigravity.ts +209 -0
- package/src/registry/oauth/google-gemini-cli.ts +273 -0
- package/src/registry/oauth/google-oauth-shared.ts +125 -0
- package/src/registry/oauth/index.ts +269 -0
- package/src/registry/oauth/kimi.ts +289 -0
- package/src/registry/oauth/minimax-code.ts +53 -0
- package/src/registry/oauth/oauth.html +311 -0
- package/src/registry/oauth/openai-codex.ts +364 -0
- package/src/registry/oauth/opencode.ts +50 -0
- package/src/registry/oauth/perplexity.ts +228 -0
- package/src/registry/oauth/pkce.ts +18 -0
- package/src/registry/oauth/types.ts +65 -0
- package/src/registry/oauth/wafer.ts +24 -0
- package/src/registry/oauth/xai-oauth.ts +394 -0
- package/src/registry/oauth/xiaomi.ts +211 -0
- package/src/registry/ollama-cloud.ts +36 -0
- package/src/registry/ollama.ts +43 -0
- package/src/registry/openai-codex-device.ts +18 -0
- package/src/registry/openai-codex.ts +19 -0
- package/src/registry/openai.ts +6 -0
- package/src/registry/opencode-go.ts +12 -0
- package/src/registry/opencode-zen.ts +12 -0
- package/src/registry/openrouter.ts +28 -0
- package/src/registry/parallel.ts +45 -0
- package/src/registry/perplexity.ts +13 -0
- package/src/registry/qianfan.ts +27 -0
- package/src/registry/qwen-portal.ts +50 -0
- package/src/registry/registry.ts +161 -0
- package/src/registry/sakana.ts +22 -0
- package/src/registry/synthetic.ts +21 -0
- package/src/registry/tavily.ts +45 -0
- package/src/registry/together.ts +22 -0
- package/src/registry/types.ts +56 -0
- package/src/registry/umans.ts +23 -0
- package/src/registry/venice.ts +33 -0
- package/src/registry/vercel-ai-gateway.ts +38 -0
- package/src/registry/vllm.ts +34 -0
- package/src/registry/wafer-serverless.ts +12 -0
- package/src/registry/xai-oauth.ts +17 -0
- package/src/registry/xai.ts +6 -0
- package/src/registry/xiaomi-token-plan-ams.ts +12 -0
- package/src/registry/xiaomi-token-plan-cn.ts +12 -0
- package/src/registry/xiaomi-token-plan-sgp.ts +12 -0
- package/src/registry/xiaomi.ts +12 -0
- package/src/registry/zai.ts +27 -0
- package/src/registry/zenmux.ts +22 -0
- package/src/registry/zhipu-coding-plan.ts +27 -0
- package/src/stream.ts +1778 -0
- package/src/types.ts +856 -0
- package/src/usage/claude.ts +485 -0
- package/src/usage/gemini.ts +258 -0
- package/src/usage/github-copilot.ts +424 -0
- package/src/usage/google-antigravity.ts +497 -0
- package/src/usage/kimi.ts +271 -0
- package/src/usage/minimax-code.ts +30 -0
- package/src/usage/ollama.ts +41 -0
- package/src/usage/openai-codex-base-url.ts +35 -0
- package/src/usage/openai-codex-reset.ts +174 -0
- package/src/usage/openai-codex.ts +535 -0
- package/src/usage/opencode-go.ts +89 -0
- package/src/usage/shared.ts +10 -0
- package/src/usage/zai.ts +321 -0
- package/src/usage.ts +333 -0
- package/src/utils/abort.ts +67 -0
- package/src/utils/anthropic-auth.ts +93 -0
- package/src/utils/block-symbols.ts +32 -0
- package/src/utils/deterministic-id.ts +20 -0
- package/src/utils/empty-completion-retry.ts +159 -0
- package/src/utils/event-stream.ts +171 -0
- package/src/utils/foundry.ts +8 -0
- package/src/utils/google-validation.ts +25 -0
- package/src/utils/harmony-leak.ts +456 -0
- package/src/utils/http-inspector.ts +168 -0
- package/src/utils/idle-iterator.ts +473 -0
- package/src/utils/leaked-thinking-stream.ts +294 -0
- package/src/utils/openai-http.ts +122 -0
- package/src/utils/openrouter-headers.ts +12 -0
- package/src/utils/parse-bind.ts +56 -0
- package/src/utils/provider-response.ts +30 -0
- package/src/utils/proxy.ts +240 -0
- package/src/utils/request-debug.ts +351 -0
- package/src/utils/retry-after.ts +110 -0
- package/src/utils/retry.ts +59 -0
- package/src/utils/schema/CONSTRAINTS.md +166 -0
- package/src/utils/schema/adapt.ts +36 -0
- package/src/utils/schema/compatibility.ts +435 -0
- package/src/utils/schema/dereference.ts +98 -0
- package/src/utils/schema/draft.ts +341 -0
- package/src/utils/schema/equality.ts +97 -0
- package/src/utils/schema/fields.ts +207 -0
- package/src/utils/schema/index.ts +15 -0
- package/src/utils/schema/json-schema-validator.ts +595 -0
- package/src/utils/schema/meta-validator.ts +167 -0
- package/src/utils/schema/normalize.ts +1901 -0
- package/src/utils/schema/spill.ts +43 -0
- package/src/utils/schema/stamps.ts +109 -0
- package/src/utils/schema/strict-tool-validation.ts +117 -0
- package/src/utils/schema/types.ts +10 -0
- package/src/utils/schema/typescript.ts +198 -0
- package/src/utils/schema/wire.ts +789 -0
- package/src/utils/schema/zod-decontaminate.ts +331 -0
- package/src/utils/sdk-stream-timeout.ts +43 -0
- package/src/utils/sse-debug.ts +18 -0
- package/src/utils/stream-markup-healing.ts +247 -0
- package/src/utils/thinking-loop.ts +552 -0
- package/src/utils/tool-call-loop-guard.ts +107 -0
- package/src/utils/tool-choice.ts +99 -0
- package/src/utils/validation.ts +1507 -0
- package/src/utils.ts +171 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic Messages API wire types.
|
|
3
|
+
*
|
|
4
|
+
* Hand-maintained against https://docs.anthropic.com/en/api/messages so pi-ai
|
|
5
|
+
* does not depend on `@anthropic-ai/sdk` for type information. Only the shapes
|
|
6
|
+
* this package actually reads or writes are modeled; fields we never touch are
|
|
7
|
+
* intentionally omitted. Names mirror the SDK so call sites read the same.
|
|
8
|
+
*
|
|
9
|
+
* Unlike the SDK, beta fields pi-ai uses (`speed`, `context_management`,
|
|
10
|
+
* `output_config.effort`/`task_budget`, `thinking.display`, cache-control
|
|
11
|
+
* `scope`, tool `strict`/`eager_input_streaming`, mid-conversation `system`
|
|
12
|
+
* role) are first-class here instead of being patched in via casts.
|
|
13
|
+
*/
|
|
14
|
+
import type { TokenTaskBudget } from "../types";
|
|
15
|
+
/** Ephemeral prefix-cache breakpoint marker. */
|
|
16
|
+
export type CacheControlEphemeral = {
|
|
17
|
+
type: "ephemeral";
|
|
18
|
+
ttl?: "1h" | "5m";
|
|
19
|
+
/** Claude Code prompt-caching-scope beta: shares the breakpoint across sessions. */
|
|
20
|
+
scope?: "global";
|
|
21
|
+
};
|
|
22
|
+
export type Base64ImageSource = {
|
|
23
|
+
type: "base64";
|
|
24
|
+
media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
|
|
25
|
+
data: string;
|
|
26
|
+
};
|
|
27
|
+
export type URLImageSource = {
|
|
28
|
+
type: "url";
|
|
29
|
+
url: string;
|
|
30
|
+
};
|
|
31
|
+
export type FileImageSource = {
|
|
32
|
+
type: "file";
|
|
33
|
+
file_id: string;
|
|
34
|
+
};
|
|
35
|
+
export type ImageSource = Base64ImageSource | URLImageSource | FileImageSource;
|
|
36
|
+
export type TextBlockParam = {
|
|
37
|
+
type: "text";
|
|
38
|
+
text: string;
|
|
39
|
+
cache_control?: CacheControlEphemeral | null;
|
|
40
|
+
};
|
|
41
|
+
export type ImageBlockParam = {
|
|
42
|
+
type: "image";
|
|
43
|
+
source: ImageSource;
|
|
44
|
+
cache_control?: CacheControlEphemeral | null;
|
|
45
|
+
};
|
|
46
|
+
export type ToolUseBlockParam = {
|
|
47
|
+
type: "tool_use";
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
input: unknown;
|
|
51
|
+
cache_control?: CacheControlEphemeral | null;
|
|
52
|
+
};
|
|
53
|
+
export type ToolResultBlockParam = {
|
|
54
|
+
type: "tool_result";
|
|
55
|
+
tool_use_id: string;
|
|
56
|
+
content?: string | Array<TextBlockParam | ImageBlockParam>;
|
|
57
|
+
is_error?: boolean;
|
|
58
|
+
cache_control?: CacheControlEphemeral | null;
|
|
59
|
+
};
|
|
60
|
+
export type ThinkingBlockParam = {
|
|
61
|
+
type: "thinking";
|
|
62
|
+
thinking: string;
|
|
63
|
+
signature: string;
|
|
64
|
+
};
|
|
65
|
+
export type RedactedThinkingBlockParam = {
|
|
66
|
+
type: "redacted_thinking";
|
|
67
|
+
data: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Server-side fallback beta boundary marker (server-side-fallback-2026-06-01).
|
|
71
|
+
* Emitted by the API mid-stream when a classifier block on the requested
|
|
72
|
+
* model is retried on a fallback model. Only the official Anthropic
|
|
73
|
+
* endpoint accepts this block on replay — cross-provider hops MUST strip it.
|
|
74
|
+
*/
|
|
75
|
+
export type FallbackBlockParam = {
|
|
76
|
+
type: "fallback";
|
|
77
|
+
from: {
|
|
78
|
+
model: string;
|
|
79
|
+
};
|
|
80
|
+
to: {
|
|
81
|
+
model: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type ContentBlockParam = TextBlockParam | ImageBlockParam | ToolUseBlockParam | ToolResultBlockParam | ThinkingBlockParam | RedactedThinkingBlockParam | FallbackBlockParam;
|
|
85
|
+
/**
|
|
86
|
+
* A single conversation turn.
|
|
87
|
+
*
|
|
88
|
+
* `system` is the Opus 4.8+ mid-conversation system role
|
|
89
|
+
* (`mid-conversation-system-2026-04-07` beta); the public API otherwise only
|
|
90
|
+
* accepts `user` / `assistant`.
|
|
91
|
+
*/
|
|
92
|
+
export type MessageParam = {
|
|
93
|
+
role: "user" | "assistant" | "system";
|
|
94
|
+
content: string | ContentBlockParam[];
|
|
95
|
+
};
|
|
96
|
+
export type ToolInputSchema = {
|
|
97
|
+
type: "object";
|
|
98
|
+
properties?: unknown | null;
|
|
99
|
+
required?: string[] | null;
|
|
100
|
+
[k: string]: unknown;
|
|
101
|
+
};
|
|
102
|
+
export type Tool = {
|
|
103
|
+
name: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
input_schema: ToolInputSchema;
|
|
106
|
+
cache_control?: CacheControlEphemeral | null;
|
|
107
|
+
/** Structured-outputs beta: enforce the schema as a strict grammar. */
|
|
108
|
+
strict?: boolean;
|
|
109
|
+
/** Fine-grained tool streaming beta: stream tool input as it is generated. */
|
|
110
|
+
eager_input_streaming?: boolean;
|
|
111
|
+
};
|
|
112
|
+
export type ToolChoiceAuto = {
|
|
113
|
+
type: "auto";
|
|
114
|
+
disable_parallel_tool_use?: boolean;
|
|
115
|
+
};
|
|
116
|
+
export type ToolChoiceAny = {
|
|
117
|
+
type: "any";
|
|
118
|
+
disable_parallel_tool_use?: boolean;
|
|
119
|
+
};
|
|
120
|
+
export type ToolChoiceTool = {
|
|
121
|
+
type: "tool";
|
|
122
|
+
name: string;
|
|
123
|
+
disable_parallel_tool_use?: boolean;
|
|
124
|
+
};
|
|
125
|
+
export type ToolChoiceNone = {
|
|
126
|
+
type: "none";
|
|
127
|
+
};
|
|
128
|
+
export type ToolChoice = ToolChoiceAuto | ToolChoiceAny | ToolChoiceTool | ToolChoiceNone;
|
|
129
|
+
export type Metadata = {
|
|
130
|
+
user_id?: string | null;
|
|
131
|
+
};
|
|
132
|
+
export type ThinkingConfigEnabled = {
|
|
133
|
+
type: "enabled";
|
|
134
|
+
budget_tokens: number;
|
|
135
|
+
/** Opus 4.7+ reasoning display mode. */
|
|
136
|
+
display?: "summarized" | "omitted";
|
|
137
|
+
};
|
|
138
|
+
export type ThinkingConfigDisabled = {
|
|
139
|
+
type: "disabled";
|
|
140
|
+
};
|
|
141
|
+
export type ThinkingConfigAdaptive = {
|
|
142
|
+
type: "adaptive";
|
|
143
|
+
/** Opus 4.7+ reasoning display mode. */
|
|
144
|
+
display?: "summarized" | "omitted";
|
|
145
|
+
};
|
|
146
|
+
export type ThinkingConfigParam = ThinkingConfigEnabled | ThinkingConfigDisabled | ThinkingConfigAdaptive;
|
|
147
|
+
export type OutputConfig = {
|
|
148
|
+
/** Adaptive-thinking effort level (effort beta). */
|
|
149
|
+
effort?: "low" | "medium" | "high" | "xhigh" | "max" | null;
|
|
150
|
+
/** Task-budgets beta. */
|
|
151
|
+
task_budget?: TokenTaskBudget | null;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Per-attempt override entry in `MessageCreateParams.fallbacks`
|
|
155
|
+
* (server-side-fallback-2026-06-01 beta). Every field except `model`
|
|
156
|
+
* mirrors a top-level control the beta allows re-specifying per attempt.
|
|
157
|
+
*/
|
|
158
|
+
export type FallbackParam = {
|
|
159
|
+
model: string;
|
|
160
|
+
max_tokens?: number;
|
|
161
|
+
thinking?: ThinkingConfigParam;
|
|
162
|
+
output_config?: OutputConfig;
|
|
163
|
+
speed?: "fast";
|
|
164
|
+
};
|
|
165
|
+
/** Claude Code context-management beta payload. */
|
|
166
|
+
export type ContextManagement = {
|
|
167
|
+
edits: Array<{
|
|
168
|
+
type: "clear_thinking_20251015";
|
|
169
|
+
keep: "all";
|
|
170
|
+
}>;
|
|
171
|
+
};
|
|
172
|
+
export type MessageCreateParams = {
|
|
173
|
+
model: string;
|
|
174
|
+
messages: MessageParam[];
|
|
175
|
+
max_tokens: number;
|
|
176
|
+
system?: string | TextBlockParam[];
|
|
177
|
+
temperature?: number;
|
|
178
|
+
top_p?: number;
|
|
179
|
+
top_k?: number;
|
|
180
|
+
stop_sequences?: string[];
|
|
181
|
+
stream?: boolean;
|
|
182
|
+
tools?: Tool[];
|
|
183
|
+
tool_choice?: ToolChoice;
|
|
184
|
+
metadata?: Metadata;
|
|
185
|
+
thinking?: ThinkingConfigParam;
|
|
186
|
+
output_config?: OutputConfig;
|
|
187
|
+
/** Fast-mode beta: realization of priority service tier. */
|
|
188
|
+
speed?: "fast";
|
|
189
|
+
/** Claude Code context-management beta. */
|
|
190
|
+
context_management?: ContextManagement;
|
|
191
|
+
/**
|
|
192
|
+
* Server-side fallback beta chain — up to three fallback models the API
|
|
193
|
+
* retries when a classifier blocks the primary. Required companion beta
|
|
194
|
+
* header: `server-side-fallback-2026-06-01`.
|
|
195
|
+
*/
|
|
196
|
+
fallbacks?: FallbackParam[];
|
|
197
|
+
};
|
|
198
|
+
export type MessageCreateParamsStreaming = MessageCreateParams & {
|
|
199
|
+
stream: true;
|
|
200
|
+
};
|
|
201
|
+
export type StopReason = "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "pause_turn" | "refusal" | "sensitive" | "model_context_window_exceeded";
|
|
202
|
+
export type CacheCreation = {
|
|
203
|
+
ephemeral_5m_input_tokens?: number | null;
|
|
204
|
+
ephemeral_1h_input_tokens?: number | null;
|
|
205
|
+
};
|
|
206
|
+
export type ServerToolUsage = {
|
|
207
|
+
web_search_requests?: number | null;
|
|
208
|
+
web_fetch_requests?: number | null;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Per-attempt token accounting inside a multi-run turn
|
|
212
|
+
* (server-side-fallback-2026-06-01). Populated whenever a fallback chain
|
|
213
|
+
* ran, including sticky-served turns with no `fallback` content block.
|
|
214
|
+
* A `fallback_message` entry is the definitive "served by fallback" signal.
|
|
215
|
+
*/
|
|
216
|
+
export type UsageIteration = {
|
|
217
|
+
type?: "message" | "fallback_message" | string;
|
|
218
|
+
model?: string | null;
|
|
219
|
+
input_tokens?: number | null;
|
|
220
|
+
output_tokens?: number | null;
|
|
221
|
+
cache_read_input_tokens?: number | null;
|
|
222
|
+
cache_creation_input_tokens?: number | null;
|
|
223
|
+
};
|
|
224
|
+
export type Usage = {
|
|
225
|
+
input_tokens?: number | null;
|
|
226
|
+
output_tokens?: number | null;
|
|
227
|
+
cache_read_input_tokens?: number | null;
|
|
228
|
+
cache_creation_input_tokens?: number | null;
|
|
229
|
+
cache_creation?: CacheCreation | null;
|
|
230
|
+
server_tool_use?: ServerToolUsage | null;
|
|
231
|
+
iterations?: UsageIteration[] | null;
|
|
232
|
+
};
|
|
233
|
+
/** The `message` envelope carried by `message_start`. */
|
|
234
|
+
export type ResponseMessage = {
|
|
235
|
+
id: string;
|
|
236
|
+
type?: "message";
|
|
237
|
+
role?: "assistant";
|
|
238
|
+
model?: string;
|
|
239
|
+
content?: unknown[];
|
|
240
|
+
stop_reason?: StopReason | null;
|
|
241
|
+
stop_sequence?: string | null;
|
|
242
|
+
usage: Usage;
|
|
243
|
+
};
|
|
244
|
+
/** `content_block` payload carried by `content_block_start`. */
|
|
245
|
+
export type ResponseContentBlock = {
|
|
246
|
+
type: "text";
|
|
247
|
+
text: string;
|
|
248
|
+
} | {
|
|
249
|
+
type: "thinking";
|
|
250
|
+
thinking: string;
|
|
251
|
+
signature?: string;
|
|
252
|
+
} | {
|
|
253
|
+
type: "redacted_thinking";
|
|
254
|
+
data: string;
|
|
255
|
+
} | {
|
|
256
|
+
type: "tool_use";
|
|
257
|
+
id: string;
|
|
258
|
+
name: string;
|
|
259
|
+
input?: Record<string, unknown> | null;
|
|
260
|
+
} | {
|
|
261
|
+
type: "fallback";
|
|
262
|
+
from: {
|
|
263
|
+
model: string;
|
|
264
|
+
};
|
|
265
|
+
to: {
|
|
266
|
+
model: string;
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
export type ContentBlockDelta = {
|
|
270
|
+
type: "text_delta";
|
|
271
|
+
text: string;
|
|
272
|
+
} | {
|
|
273
|
+
type: "input_json_delta";
|
|
274
|
+
partial_json: string;
|
|
275
|
+
} | {
|
|
276
|
+
type: "thinking_delta";
|
|
277
|
+
thinking: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: "signature_delta";
|
|
280
|
+
signature: string;
|
|
281
|
+
};
|
|
282
|
+
export type StopDetails = {
|
|
283
|
+
type: string;
|
|
284
|
+
category?: string | null;
|
|
285
|
+
explanation?: string | null;
|
|
286
|
+
};
|
|
287
|
+
export type MessageDelta = {
|
|
288
|
+
stop_reason?: StopReason | null;
|
|
289
|
+
stop_sequence?: string | null;
|
|
290
|
+
stop_details?: StopDetails | null;
|
|
291
|
+
};
|
|
292
|
+
export type RawMessageStartEvent = {
|
|
293
|
+
type: "message_start";
|
|
294
|
+
message: ResponseMessage;
|
|
295
|
+
};
|
|
296
|
+
export type RawContentBlockStartEvent = {
|
|
297
|
+
type: "content_block_start";
|
|
298
|
+
index: number;
|
|
299
|
+
content_block: ResponseContentBlock;
|
|
300
|
+
};
|
|
301
|
+
export type RawContentBlockDeltaEvent = {
|
|
302
|
+
type: "content_block_delta";
|
|
303
|
+
index: number;
|
|
304
|
+
delta: ContentBlockDelta;
|
|
305
|
+
};
|
|
306
|
+
export type RawContentBlockStopEvent = {
|
|
307
|
+
type: "content_block_stop";
|
|
308
|
+
index: number;
|
|
309
|
+
};
|
|
310
|
+
export type RawMessageDeltaEvent = {
|
|
311
|
+
type: "message_delta";
|
|
312
|
+
delta: MessageDelta;
|
|
313
|
+
usage: Usage;
|
|
314
|
+
};
|
|
315
|
+
export type RawMessageStopEvent = {
|
|
316
|
+
type: "message_stop";
|
|
317
|
+
};
|
|
318
|
+
export type RawMessageStreamEvent = RawMessageStartEvent | RawContentBlockStartEvent | RawContentBlockDeltaEvent | RawContentBlockStopEvent | RawMessageDeltaEvent | RawMessageStopEvent;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { FetchImpl, Message, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, StreamFunction, StreamOptions, Usage } from "../types";
|
|
2
|
+
import { type AnthropicFetchOptions, type AnthropicMessagesClientLike } from "./anthropic-client";
|
|
3
|
+
import type { FallbackParam, MessageParam, TextBlockParam } from "./anthropic-wire";
|
|
4
|
+
export type AnthropicHeaderOptions = {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
isOAuth?: boolean;
|
|
8
|
+
extraBetas?: string[];
|
|
9
|
+
stream?: boolean;
|
|
10
|
+
modelHeaders?: Record<string, string>;
|
|
11
|
+
isCloudflareAiGateway?: boolean;
|
|
12
|
+
claudeCodeSessionId?: string;
|
|
13
|
+
claudeCodeBetas?: readonly string[];
|
|
14
|
+
};
|
|
15
|
+
export declare function normalizeAnthropicBaseUrl(baseUrl?: string): string | undefined;
|
|
16
|
+
export declare function buildBetaHeader(baseBetas: readonly string[], extraBetas: readonly string[]): string;
|
|
17
|
+
export declare function buildAnthropicHeaders(options: AnthropicHeaderOptions): Record<string, string>;
|
|
18
|
+
type AnthropicCacheControl = NonNullable<TextBlockParam["cache_control"]>;
|
|
19
|
+
/**
|
|
20
|
+
* Clears the in-session "server rejected fast mode" sticky flag. Call when the
|
|
21
|
+
* caller is explicitly re-arming `serviceTier: "priority"` (e.g. user toggled
|
|
22
|
+
* `/fast on` after a previous turn auto-disabled it) so the next request
|
|
23
|
+
* actually carries `speed: "fast"` again. No-op when the map or state entry
|
|
24
|
+
* hasn't been materialized yet.
|
|
25
|
+
*/
|
|
26
|
+
export declare function clearAnthropicFastModeFallback(providerSessionState: Map<string, ProviderSessionState> | undefined): void;
|
|
27
|
+
export declare const claudeCodeVersion = "2.1.165";
|
|
28
|
+
export declare const claudeAgentSdkVersion = "0.3.165";
|
|
29
|
+
export declare const claudeClientVersion = "1.11187.4";
|
|
30
|
+
export declare const claudeToolPrefix: string;
|
|
31
|
+
export declare const claudeCodeSystemInstruction = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
|
|
32
|
+
export declare const CLAUDE_CODE_MAX_OUTPUT_TOKENS = 64000;
|
|
33
|
+
export declare function mapStainlessOs(platform: string): "MacOS" | "Windows" | "Linux" | "FreeBSD" | `Other::${string}`;
|
|
34
|
+
export declare function mapStainlessArch(arch: string): "x64" | "arm64" | "x86" | `other::${string}`;
|
|
35
|
+
export declare const claudeCodeHeaders: {
|
|
36
|
+
"X-Stainless-Retry-Count": string;
|
|
37
|
+
"X-Stainless-Runtime-Version": string;
|
|
38
|
+
"X-Stainless-Package-Version": string;
|
|
39
|
+
"X-Stainless-Runtime": string;
|
|
40
|
+
"X-Stainless-Lang": string;
|
|
41
|
+
"X-Stainless-Arch": "arm64" | "x64" | "x86" | `other::${string}`;
|
|
42
|
+
"X-Stainless-OS": "FreeBSD" | "Linux" | "MacOS" | "Windows" | `Other::${string}`;
|
|
43
|
+
"X-Stainless-Timeout": string;
|
|
44
|
+
"anthropic-client-platform": string;
|
|
45
|
+
"anthropic-client-version": string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Wraps a fetch implementation to patch the Claude Code billing-header `cch`
|
|
49
|
+
* attestation into outgoing request bodies. Bodies without the placeholder
|
|
50
|
+
* pass through untouched, so installing it on every OAuth flow is safe.
|
|
51
|
+
*/
|
|
52
|
+
export declare function wrapFetchForCch(base: FetchImpl): FetchImpl;
|
|
53
|
+
export declare function isClaudeCloakingUserId(userId: string): boolean;
|
|
54
|
+
export declare function generateClaudeCloakingUserId(): string;
|
|
55
|
+
export declare function deriveClaudeDeviceId(installId: string, accountId?: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the `metadata.user_id` field for an Anthropic Messages request.
|
|
58
|
+
*
|
|
59
|
+
* For API-key tokens, an explicit caller-supplied `userId` is forwarded
|
|
60
|
+
* verbatim and `undefined` yields no metadata. For OAuth tokens the value
|
|
61
|
+
* must match the Claude Code attribution shape (`isClaudeCloakingUserId` or
|
|
62
|
+
* the `{session_id, account_uuid?, device_id?}` JSON envelope) — anything
|
|
63
|
+
* else is dropped and a fresh Claude-Code-style JSON id is generated from
|
|
64
|
+
* `sessionId`/`accountId` so attribution stays consistent across the main
|
|
65
|
+
* streaming path and provider-specific request builders (e.g. web search).
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveAnthropicMetadataUserId(userId: unknown, isOAuthToken: boolean, sessionId?: string, accountId?: string): string | undefined;
|
|
68
|
+
export declare const applyClaudeToolPrefix: (name: string) => string;
|
|
69
|
+
export declare const stripClaudeToolPrefix: (name: string) => string;
|
|
70
|
+
export type AnthropicOutputEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
71
|
+
export type AnthropicEffort = AnthropicOutputEffort | "adaptive";
|
|
72
|
+
export type AnthropicThinkingDisplay = "summarized" | "omitted";
|
|
73
|
+
export interface AnthropicOptions extends StreamOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Enable extended thinking.
|
|
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.
|
|
79
|
+
*/
|
|
80
|
+
thinkingEnabled?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Token budget for extended thinking (older models only).
|
|
83
|
+
* Ignored for adaptive-capable models.
|
|
84
|
+
*/
|
|
85
|
+
thinkingBudgetTokens?: number;
|
|
86
|
+
/**
|
|
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.
|
|
93
|
+
* Controls how much Claude allocates, or uses "adaptive" for MiniMax's
|
|
94
|
+
* binary adaptive-thinking tag:
|
|
95
|
+
* - "max": Always thinks with no constraints
|
|
96
|
+
* - "high": Always thinks, deep reasoning (default)
|
|
97
|
+
* - "medium": Moderate thinking, may skip for simple queries
|
|
98
|
+
* - "low": Minimal thinking, skips for simple tasks
|
|
99
|
+
* - "adaptive": Sends `thinking.type: "adaptive"` without `output_config.effort`
|
|
100
|
+
* Ignored for older models.
|
|
101
|
+
*/
|
|
102
|
+
effort?: AnthropicEffort;
|
|
103
|
+
/**
|
|
104
|
+
* Optional reasoning level fallback for direct Anthropic provider usage.
|
|
105
|
+
* Converted to adaptive effort when effort is not explicitly provided.
|
|
106
|
+
*/
|
|
107
|
+
reasoning?: SimpleStreamOptions["reasoning"];
|
|
108
|
+
/**
|
|
109
|
+
* Controls how Anthropic returns thinking content when the selected thinking
|
|
110
|
+
* transport supports a display option. Defaults to "summarized" where the
|
|
111
|
+
* API accepts it.
|
|
112
|
+
*/
|
|
113
|
+
thinkingDisplay?: AnthropicThinkingDisplay;
|
|
114
|
+
interleavedThinking?: boolean;
|
|
115
|
+
toolChoice?: "auto" | "any" | "none" | {
|
|
116
|
+
type: "tool";
|
|
117
|
+
name: string;
|
|
118
|
+
};
|
|
119
|
+
betas?: string[] | string;
|
|
120
|
+
/**
|
|
121
|
+
* Realization of `serviceTier: "priority"` on Anthropic models. When
|
|
122
|
+
* `"priority"`, sets `speed: "fast"` on the request and appends the
|
|
123
|
+
* `fast-mode-2026-02-01` beta header. Anthropic rejects unsupported models
|
|
124
|
+
* with `invalid_request_error`, which triggers an in-provider one-shot
|
|
125
|
+
* fallback (see `fastModeDisabled` provider state).
|
|
126
|
+
*
|
|
127
|
+
* Other `ServiceTier` values are currently ignored on this provider.
|
|
128
|
+
*/
|
|
129
|
+
serviceTier?: ServiceTier;
|
|
130
|
+
/** Force OAuth bearer auth mode for proxy tokens that don't match Anthropic token prefixes. */
|
|
131
|
+
isOAuth?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Pre-built Anthropic Messages client. When provided, skips internal client
|
|
134
|
+
* construction entirely. Accepts any structurally compatible client,
|
|
135
|
+
* including SDK clients such as `AnthropicVertex`.
|
|
136
|
+
*/
|
|
137
|
+
client?: AnthropicMessagesClientLike;
|
|
138
|
+
/**
|
|
139
|
+
* Server-side fallback beta chain (`server-side-fallback-2026-06-01`).
|
|
140
|
+
* When set, `fallbacks` is forwarded on the request body and the beta
|
|
141
|
+
* header is auto-attached; the response parser then honors mid-stream
|
|
142
|
+
* `fallback` content blocks and `usage.iterations` for served-model
|
|
143
|
+
* promotion and per-attempt pricing. Opt-in ONLY — leaving this
|
|
144
|
+
* undefined preserves the pre-fallback behavior on every code path.
|
|
145
|
+
*/
|
|
146
|
+
fallbacks?: FallbackParam[];
|
|
147
|
+
}
|
|
148
|
+
export type AnthropicClientOptionsArgs = {
|
|
149
|
+
model: Model<"anthropic-messages">;
|
|
150
|
+
apiKey: string;
|
|
151
|
+
extraBetas?: string[];
|
|
152
|
+
stream?: boolean;
|
|
153
|
+
interleavedThinking?: boolean;
|
|
154
|
+
headers?: Record<string, string>;
|
|
155
|
+
dynamicHeaders?: Record<string, string>;
|
|
156
|
+
isOAuth?: boolean;
|
|
157
|
+
hasTools?: boolean;
|
|
158
|
+
thinkingEnabled?: boolean;
|
|
159
|
+
thinkingDisplay?: AnthropicThinkingDisplay;
|
|
160
|
+
fetch?: FetchImpl;
|
|
161
|
+
claudeCodeSessionId?: string;
|
|
162
|
+
};
|
|
163
|
+
export type AnthropicClientOptionsResult = {
|
|
164
|
+
isOAuthToken: boolean;
|
|
165
|
+
apiKey: string | null;
|
|
166
|
+
authToken?: string | null;
|
|
167
|
+
baseURL?: string;
|
|
168
|
+
maxRetries: number;
|
|
169
|
+
defaultHeaders: Record<string, string>;
|
|
170
|
+
fetch?: FetchImpl;
|
|
171
|
+
fetchOptions?: AnthropicFetchOptions;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Returns env-supplied custom headers (`ANTHROPIC_CUSTOM_HEADERS`) when they
|
|
175
|
+
* should be forwarded to the upstream endpoint.
|
|
176
|
+
*
|
|
177
|
+
* Foundry mode forwards them unconditionally. Outside Foundry, they're applied
|
|
178
|
+
* only when the configured base URL is a non-Anthropic host — i.e. an
|
|
179
|
+
* enterprise/corporate gateway that may require its own proprietary auth
|
|
180
|
+
* header. Stock `api.anthropic.com` would reject unknown headers, so they're
|
|
181
|
+
* omitted there.
|
|
182
|
+
*/
|
|
183
|
+
export declare function resolveAnthropicCustomHeadersForBaseUrl(baseUrl: string | undefined): Record<string, string> | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Whether an Anthropic (or Copilot-over-Anthropic) stream error should be
|
|
186
|
+
* retried. The classification lives in {@link AIError.isProviderRetryableError};
|
|
187
|
+
* this wrapper injects the Copilot-specific `model_not_supported` transient
|
|
188
|
+
* check, which the error module must not import directly.
|
|
189
|
+
*/
|
|
190
|
+
export declare function isProviderRetryableError(error: unknown, provider?: string): boolean;
|
|
191
|
+
export type AnthropicUsageLike = {
|
|
192
|
+
cache_creation?: {
|
|
193
|
+
ephemeral_5m_input_tokens?: number | null;
|
|
194
|
+
ephemeral_1h_input_tokens?: number | null;
|
|
195
|
+
} | null;
|
|
196
|
+
server_tool_use?: {
|
|
197
|
+
web_search_requests?: number | null;
|
|
198
|
+
web_fetch_requests?: number | null;
|
|
199
|
+
} | null;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Capture Anthropic's optional cache-creation TTL breakdown and server-tool-use
|
|
203
|
+
* counters into the harness Usage shape. Omitted/null fields are no-ops; explicit
|
|
204
|
+
* zero-valued objects clear prior extras from earlier stream usage snapshots.
|
|
205
|
+
*/
|
|
206
|
+
export declare function applyAnthropicUsageExtras(usage: Usage, source: AnthropicUsageLike): void;
|
|
207
|
+
/**
|
|
208
|
+
* Public entry: wrap the single-attempt streamer with bounded empty-completion
|
|
209
|
+
* retries (a benign terminal stop carrying no content/usage would otherwise
|
|
210
|
+
* stall the agent loop). The inner attempt keeps its own provider-failure retry
|
|
211
|
+
* loop; this layer only re-issues a fresh request on an empty success. Shared
|
|
212
|
+
* with the OpenAI-completions provider via `withEmptyCompletionRetry`.
|
|
213
|
+
*/
|
|
214
|
+
export declare const streamAnthropic: StreamFunction<"anthropic-messages">;
|
|
215
|
+
export type AnthropicSystemBlock = {
|
|
216
|
+
type: "text";
|
|
217
|
+
text: string;
|
|
218
|
+
cache_control?: AnthropicCacheControl;
|
|
219
|
+
};
|
|
220
|
+
type SystemBlockOptions = {
|
|
221
|
+
includeClaudeCodeInstruction?: boolean;
|
|
222
|
+
extraInstructions?: string[];
|
|
223
|
+
/** Text of the first user message — used as fingerprint seed for the billing header. */
|
|
224
|
+
firstUserMessageText?: string;
|
|
225
|
+
cacheControl?: AnthropicCacheControl;
|
|
226
|
+
};
|
|
227
|
+
export declare function buildAnthropicSystemBlocks(systemPrompt: readonly string[] | undefined, options?: SystemBlockOptions): AnthropicSystemBlock[] | undefined;
|
|
228
|
+
export declare function normalizeExtraBetas(betas?: string[] | string): string[];
|
|
229
|
+
export declare function buildAnthropicClientOptions(args: AnthropicClientOptionsArgs): AnthropicClientOptionsResult;
|
|
230
|
+
/**
|
|
231
|
+
* A single Anthropic conversation turn, including the mid-conversation
|
|
232
|
+
* `system` role (Opus 4.8+ and Fable/Mythos 5).
|
|
233
|
+
*/
|
|
234
|
+
export type AnthropicMessageParam = MessageParam;
|
|
235
|
+
/**
|
|
236
|
+
* Serialize omp {@link Message}s to Anthropic wire messages.
|
|
237
|
+
*
|
|
238
|
+
* `opts.serverSideFallbackEnabled` — when the CURRENT request itself
|
|
239
|
+
* opts into the server-side-fallback beta chain. Only then may a persisted
|
|
240
|
+
* `fallback` content block from a prior turn be replayed on the wire;
|
|
241
|
+
* otherwise the block is dropped to avoid a 400 on non-fallback requests
|
|
242
|
+
* that don't send the beta.
|
|
243
|
+
*/
|
|
244
|
+
export declare function convertAnthropicMessages(messages: Message[], model: Model<"anthropic-messages">, isOAuthToken: boolean, opts?: {
|
|
245
|
+
serverSideFallbackEnabled?: boolean;
|
|
246
|
+
}): AnthropicMessageParam[];
|
|
247
|
+
export declare function normalizeAnthropicToolSchema(schema: unknown): unknown;
|
|
248
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS credential resolution for the Bedrock provider.
|
|
3
|
+
*
|
|
4
|
+
* Chain (first hit wins):
|
|
5
|
+
* 1. Static credentials from the environment
|
|
6
|
+
* (`AWS_ACCESS_KEY_ID` + `AWS_SECRET_ACCESS_KEY` [+ `AWS_SESSION_TOKEN`]).
|
|
7
|
+
* 2. Profile in `~/.aws/credentials` (and `~/.aws/config` for SSO):
|
|
8
|
+
* - static `aws_access_key_id` / `aws_secret_access_key` / `aws_session_token`
|
|
9
|
+
* - SSO profile referencing a cached token in `~/.aws/sso/cache/*.json`,
|
|
10
|
+
* which we exchange for short-lived role credentials via
|
|
11
|
+
* `https://portal.sso.{region}.amazonaws.com/federation/credentials`.
|
|
12
|
+
* - `credential_process` — an external command emitting the AWS SDK
|
|
13
|
+
* `Version: 1` JSON envelope on stdout. Used by `aws-vault`, `granted`,
|
|
14
|
+
* in-house brokers, etc.
|
|
15
|
+
* 3. EC2 IMDSv2 (only when `AWS_EC2_METADATA_DISABLED` is unset / falsey and
|
|
16
|
+
* `169.254.169.254` is reachable within a 1 s timeout).
|
|
17
|
+
*
|
|
18
|
+
* Resolved credentials are cached process-wide per profile and refreshed
|
|
19
|
+
* 60 s before `Expiration` to absorb clock skew.
|
|
20
|
+
*/
|
|
21
|
+
import type { FetchImpl } from "../types";
|
|
22
|
+
import type { AwsCredentials } from "./aws-sigv4";
|
|
23
|
+
export interface ResolvedCredentials extends AwsCredentials {
|
|
24
|
+
/** Absolute expiration timestamp in ms. `undefined` for non-expiring static creds. */
|
|
25
|
+
expiresAt?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface CredentialResolveOptions {
|
|
28
|
+
/** Named profile from `~/.aws/credentials` / `~/.aws/config`. */
|
|
29
|
+
profile?: string;
|
|
30
|
+
/** Falls back to env (`AWS_REGION` / `AWS_DEFAULT_REGION`) and finally `us-east-1`. */
|
|
31
|
+
region?: string;
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
fetch?: FetchImpl;
|
|
34
|
+
}
|
|
35
|
+
export declare function resolveAwsCredentials(opts?: CredentialResolveOptions): Promise<ResolvedCredentials>;
|
|
36
|
+
/** POSIX-shell-style tokenizer used by the AWS CLI for `credential_process`.
|
|
37
|
+
*
|
|
38
|
+
* Outside quotes a backslash escapes the next character. Inside single quotes
|
|
39
|
+
* everything is literal (no escapes, cannot contain `'`). Inside double quotes
|
|
40
|
+
* a backslash only escapes `$`, `` ` ``, `"`, and `\` — every other backslash
|
|
41
|
+
* is preserved verbatim, which is what makes Windows paths like
|
|
42
|
+
* `"C:\Program Files\tool\auth.exe"` survive tokenization. */
|
|
43
|
+
export declare function tokenizeCredentialProcessCommand(cmd: string): string[];
|
|
44
|
+
/** Test/diagnostic helper — drops cached credentials. */
|
|
45
|
+
export declare function clearAwsCredentialCache(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Drop the cache entry for one profile/region. Called by the Bedrock provider on
|
|
48
|
+
* 401/403 responses so stale credentials are re-resolved instead of served until restart.
|
|
49
|
+
*/
|
|
50
|
+
export declare function invalidateAwsCredentialCache(opts?: {
|
|
51
|
+
profile?: string;
|
|
52
|
+
region?: string;
|
|
53
|
+
}): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `application/vnd.amazon.eventstream` decoder.
|
|
3
|
+
*
|
|
4
|
+
* Wire format (all integers big-endian):
|
|
5
|
+
*
|
|
6
|
+
* [total length u32]
|
|
7
|
+
* [headers length u32]
|
|
8
|
+
* [prelude CRC32 u32] <- CRC over the first 8 bytes
|
|
9
|
+
* [headers headers_length]
|
|
10
|
+
* [payload total_length - headers_length - 16]
|
|
11
|
+
* [message CRC32 u32] <- CRC over the entire message minus the trailing 4 bytes
|
|
12
|
+
*
|
|
13
|
+
* Headers: a sequence of `[name_len u8][name utf8][value_type u8][value …]`.
|
|
14
|
+
* We only need the typed values Bedrock emits (boolean true/false, byte, short,
|
|
15
|
+
* integer, long, byte-array, string, timestamp, uuid). All are surfaced as
|
|
16
|
+
* strings for ease of consumption — Bedrock only sets string-valued headers in
|
|
17
|
+
* practice (`:event-type`, `:message-type`, `:content-type`, `:exception-type`).
|
|
18
|
+
*/
|
|
19
|
+
export interface EventStreamMessage {
|
|
20
|
+
/** Lower-cased copy is *not* applied — Bedrock uses casing like `:event-type` verbatim. */
|
|
21
|
+
headers: Record<string, string>;
|
|
22
|
+
payload: Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
/** CRC32 (IEEE / zlib polynomial 0xEDB88320), matches `@aws-crypto/crc32`. */
|
|
25
|
+
export declare function crc32(bytes: Uint8Array): number;
|
|
26
|
+
/**
|
|
27
|
+
* Decode a single, fully buffered eventstream message. Throws if the framing is
|
|
28
|
+
* malformed or either CRC mismatches. Used by both `decodeEventStream` (the
|
|
29
|
+
* streaming entry point) and the unit tests, which exercise it with hand-built
|
|
30
|
+
* frames.
|
|
31
|
+
*/
|
|
32
|
+
export declare function decodeMessage(frame: Uint8Array): EventStreamMessage;
|
|
33
|
+
/**
|
|
34
|
+
* Async generator that consumes a `ReadableStream<Uint8Array>` (e.g. a fetch
|
|
35
|
+
* response body) and yields fully-framed messages. Handles arbitrary chunk
|
|
36
|
+
* boundaries: messages may span multiple chunks, and a single chunk may carry
|
|
37
|
+
* many messages.
|
|
38
|
+
*/
|
|
39
|
+
export declare function decodeEventStream(source: ReadableStream<Uint8Array>): AsyncGenerator<EventStreamMessage>;
|