@radheim/ai 0.0.0-stage → 2.4.3
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/README.md +1890 -3
- package/dist/ai.d.ts +36 -0
- package/dist/ai.js +46 -0
- package/dist/cache-policy.d.ts +6 -0
- package/dist/cache-policy.js +205 -0
- package/dist/decision-client.d.ts +10 -0
- package/dist/decision-client.js +42 -0
- package/dist/decision.d.ts +378 -0
- package/dist/decision.js +171 -0
- package/dist/effect.d.ts +59 -0
- package/dist/effect.js +33 -0
- package/dist/effort-updates.d.ts +12 -0
- package/dist/effort-updates.js +23 -0
- package/dist/embedding-client.d.ts +10 -0
- package/dist/embedding-client.js +17 -0
- package/dist/embedding.d.ts +113 -0
- package/dist/embedding.js +76 -0
- package/dist/experimental/cloudflare-run-extraction.d.ts +17 -0
- package/dist/experimental/cloudflare-run-extraction.js +85 -0
- package/dist/experimental/extraction.d.ts +153 -0
- package/dist/experimental/extraction.js +103 -0
- package/dist/experimental/realtime.d.ts +80 -0
- package/dist/experimental/realtime.js +96 -0
- package/dist/experimental.d.ts +10 -0
- package/dist/experimental.js +6 -0
- package/dist/fetch-middleware.d.ts +7 -0
- package/dist/fetch-middleware.js +41 -0
- package/dist/generation.d.ts +77 -0
- package/dist/generation.js +109 -0
- package/dist/image-client.d.ts +14 -0
- package/dist/image-client.js +39 -0
- package/dist/image.d.ts +323 -0
- package/dist/image.js +103 -0
- package/dist/index.d.ts +300 -0
- package/dist/index.js +179 -0
- package/dist/llm.d.ts +109 -0
- package/dist/llm.js +177 -0
- package/dist/loop.d.ts +38 -0
- package/dist/loop.js +139 -0
- package/dist/media-client.d.ts +30 -0
- package/dist/media-client.js +44 -0
- package/dist/media-model.d.ts +49 -0
- package/dist/media-model.js +55 -0
- package/dist/media.d.ts +237 -0
- package/dist/media.js +285 -0
- package/dist/promise-media.d.ts +20 -0
- package/dist/promise-media.js +16 -0
- package/dist/protocols/alibaba-chat.d.ts +315 -0
- package/dist/protocols/alibaba-chat.js +78 -0
- package/dist/protocols/alibaba-images.d.ts +22 -0
- package/dist/protocols/alibaba-images.js +77 -0
- package/dist/protocols/alibaba-messages.d.ts +413 -0
- package/dist/protocols/alibaba-messages.js +44 -0
- package/dist/protocols/alibaba-responses.d.ts +298 -0
- package/dist/protocols/alibaba-responses.js +67 -0
- package/dist/protocols/anthropic-messages.d.ts +1213 -0
- package/dist/protocols/anthropic-messages.js +1412 -0
- package/dist/protocols/assemblyai-transcription.d.ts +41 -0
- package/dist/protocols/assemblyai-transcription.js +137 -0
- package/dist/protocols/bedrock-converse.d.ts +548 -0
- package/dist/protocols/bedrock-converse.js +801 -0
- package/dist/protocols/bedrock-event-stream.d.ts +14 -0
- package/dist/protocols/bedrock-event-stream.js +100 -0
- package/dist/protocols/cartesia-speech.d.ts +117 -0
- package/dist/protocols/cartesia-speech.js +120 -0
- package/dist/protocols/cloudflare-run-decisions.d.ts +9 -0
- package/dist/protocols/cloudflare-run-decisions.js +36 -0
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +23 -0
- package/dist/protocols/cloudflare-workers-ai-images.js +80 -0
- package/dist/protocols/cohere-chat.d.ts +184 -0
- package/dist/protocols/cohere-chat.js +317 -0
- package/dist/protocols/deepgram-speech.d.ts +109 -0
- package/dist/protocols/deepgram-speech.js +93 -0
- package/dist/protocols/deepgram-transcription.d.ts +26 -0
- package/dist/protocols/deepgram-transcription.js +119 -0
- package/dist/protocols/elevenlabs-speech.d.ts +112 -0
- package/dist/protocols/elevenlabs-speech.js +111 -0
- package/dist/protocols/elevenlabs-transcription.d.ts +28 -0
- package/dist/protocols/elevenlabs-transcription.js +137 -0
- package/dist/protocols/gemini.d.ts +388 -0
- package/dist/protocols/gemini.js +741 -0
- package/dist/protocols/google-decisions.d.ts +13 -0
- package/dist/protocols/google-decisions.js +133 -0
- package/dist/protocols/google-embed-content.d.ts +34 -0
- package/dist/protocols/google-embed-content.js +110 -0
- package/dist/protocols/google-images.d.ts +18 -0
- package/dist/protocols/google-images.js +169 -0
- package/dist/protocols/google-interactions-video.d.ts +38 -0
- package/dist/protocols/google-interactions-video.js +185 -0
- package/dist/protocols/google-interactions.d.ts +554 -0
- package/dist/protocols/google-interactions.js +756 -0
- package/dist/protocols/google-speech.d.ts +120 -0
- package/dist/protocols/google-speech.js +94 -0
- package/dist/protocols/google-transcription.d.ts +148 -0
- package/dist/protocols/google-transcription.js +129 -0
- package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
- package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
- package/dist/protocols/index.d.ts +21 -0
- package/dist/protocols/index.js +21 -0
- package/dist/protocols/meta-images.d.ts +26 -0
- package/dist/protocols/meta-images.js +101 -0
- package/dist/protocols/meta-messages.d.ts +423 -0
- package/dist/protocols/meta-messages.js +63 -0
- package/dist/protocols/meta-responses.d.ts +533 -0
- package/dist/protocols/meta-responses.js +189 -0
- package/dist/protocols/minimax-images.d.ts +25 -0
- package/dist/protocols/minimax-images.js +150 -0
- package/dist/protocols/minimax-video.d.ts +45 -0
- package/dist/protocols/minimax-video.js +296 -0
- package/dist/protocols/mistral-chat.d.ts +565 -0
- package/dist/protocols/mistral-chat.js +606 -0
- package/dist/protocols/open-responses-channel.d.ts +25 -0
- package/dist/protocols/open-responses-channel.js +137 -0
- package/dist/protocols/open-responses-continuation.d.ts +18 -0
- package/dist/protocols/open-responses-continuation.js +172 -0
- package/dist/protocols/open-responses.d.ts +2509 -0
- package/dist/protocols/open-responses.js +1335 -0
- package/dist/protocols/openai-chat.d.ts +2571 -0
- package/dist/protocols/openai-chat.js +1140 -0
- package/dist/protocols/openai-compatible-chat.d.ts +184 -0
- package/dist/protocols/openai-compatible-chat.js +19 -0
- package/dist/protocols/openai-compatible-responses.d.ts +231 -0
- package/dist/protocols/openai-compatible-responses.js +18 -0
- package/dist/protocols/openai-decisions.d.ts +22 -0
- package/dist/protocols/openai-decisions.js +141 -0
- package/dist/protocols/openai-embeddings.d.ts +16 -0
- package/dist/protocols/openai-embeddings.js +76 -0
- package/dist/protocols/openai-freeform.d.ts +78 -0
- package/dist/protocols/openai-freeform.js +222 -0
- package/dist/protocols/openai-images.d.ts +148 -0
- package/dist/protocols/openai-images.js +303 -0
- package/dist/protocols/openai-responses.d.ts +1600 -0
- package/dist/protocols/openai-responses.js +360 -0
- package/dist/protocols/openai-speech.d.ts +110 -0
- package/dist/protocols/openai-speech.js +112 -0
- package/dist/protocols/openai-transcription.d.ts +185 -0
- package/dist/protocols/openai-transcription.js +206 -0
- package/dist/protocols/openrouter-video.d.ts +36 -0
- package/dist/protocols/openrouter-video.js +139 -0
- package/dist/protocols/seedance-video.d.ts +45 -0
- package/dist/protocols/seedance-video.js +217 -0
- package/dist/protocols/shared.d.ts +249 -0
- package/dist/protocols/shared.js +446 -0
- package/dist/protocols/system-one.d.ts +145 -0
- package/dist/protocols/system-one.js +272 -0
- package/dist/protocols/utils/bedrock-auth.d.ts +60 -0
- package/dist/protocols/utils/bedrock-auth.js +86 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +19 -0
- package/dist/protocols/utils/bedrock-cache.js +49 -0
- package/dist/protocols/utils/bedrock-media.d.ts +53 -0
- package/dist/protocols/utils/bedrock-media.js +98 -0
- package/dist/protocols/utils/cache.d.ts +25 -0
- package/dist/protocols/utils/cache.js +33 -0
- package/dist/protocols/utils/claude-model.d.ts +8 -0
- package/dist/protocols/utils/claude-model.js +15 -0
- package/dist/protocols/utils/gateway-protocol.d.ts +17 -0
- package/dist/protocols/utils/gateway-protocol.js +59 -0
- package/dist/protocols/utils/gemini-generate-content.d.ts +75 -0
- package/dist/protocols/utils/gemini-generate-content.js +96 -0
- package/dist/protocols/utils/gemini-json-schema.d.ts +8 -0
- package/dist/protocols/utils/gemini-json-schema.js +76 -0
- package/dist/protocols/utils/image-sizing.d.ts +31 -0
- package/dist/protocols/utils/image-sizing.js +73 -0
- package/dist/protocols/utils/lifecycle.d.ts +24 -0
- package/dist/protocols/utils/lifecycle.js +62 -0
- package/dist/protocols/utils/media-input.d.ts +32 -0
- package/dist/protocols/utils/media-input.js +62 -0
- package/dist/protocols/utils/mistral-tool-id.d.ts +5 -0
- package/dist/protocols/utils/mistral-tool-id.js +31 -0
- package/dist/protocols/utils/open-responses-options.d.ts +54 -0
- package/dist/protocols/utils/open-responses-options.js +59 -0
- package/dist/protocols/utils/partial-json-options.d.ts +61 -0
- package/dist/protocols/utils/partial-json-options.js +51 -0
- package/dist/protocols/utils/partial-json.d.ts +8 -0
- package/dist/protocols/utils/partial-json.js +280 -0
- package/dist/protocols/utils/responses-checkpoint.d.ts +4 -0
- package/dist/protocols/utils/responses-checkpoint.js +103 -0
- package/dist/protocols/utils/responses-compaction.d.ts +6 -0
- package/dist/protocols/utils/responses-compaction.js +162 -0
- package/dist/protocols/utils/responses-hosted-tools.d.ts +122 -0
- package/dist/protocols/utils/responses-hosted-tools.js +63 -0
- package/dist/protocols/utils/speaker-turns.d.ts +3 -0
- package/dist/protocols/utils/speaker-turns.js +9 -0
- package/dist/protocols/utils/speech-stream.d.ts +49 -0
- package/dist/protocols/utils/speech-stream.js +64 -0
- package/dist/protocols/utils/tool-schema.d.ts +10 -0
- package/dist/protocols/utils/tool-schema.js +109 -0
- package/dist/protocols/utils/tool-stream.d.ts +478 -0
- package/dist/protocols/utils/tool-stream.js +153 -0
- package/dist/protocols/venice-chat.d.ts +340 -0
- package/dist/protocols/venice-chat.js +283 -0
- package/dist/protocols/xai-images.d.ts +25 -0
- package/dist/protocols/xai-images.js +87 -0
- package/dist/protocols/xai-responses.d.ts +294 -0
- package/dist/protocols/xai-responses.js +86 -0
- package/dist/protocols/xai-video.d.ts +35 -0
- package/dist/protocols/xai-video.js +159 -0
- package/dist/protocols/zai-chat.d.ts +296 -0
- package/dist/protocols/zai-chat.js +56 -0
- package/dist/protocols/zai-images.d.ts +20 -0
- package/dist/protocols/zai-images.js +79 -0
- package/dist/protocols/zai-messages.d.ts +409 -0
- package/dist/protocols/zai-messages.js +30 -0
- package/dist/protocols.d.ts +1 -0
- package/dist/protocols.js +1 -0
- package/dist/provider-error.d.ts +22 -0
- package/dist/provider-error.js +228 -0
- package/dist/provider-package.d.ts +17 -0
- package/dist/provider-package.js +1 -0
- package/dist/providers/alibaba/chat.d.ts +1 -0
- package/dist/providers/alibaba/chat.js +1 -0
- package/dist/providers/alibaba/embeddings.d.ts +2 -0
- package/dist/providers/alibaba/embeddings.js +1 -0
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba/messages.d.ts +3 -0
- package/dist/providers/alibaba/messages.js +1 -0
- package/dist/providers/alibaba/responses.d.ts +3 -0
- package/dist/providers/alibaba/responses.js +1 -0
- package/dist/providers/alibaba.d.ts +905 -0
- package/dist/providers/alibaba.js +119 -0
- package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
- package/dist/providers/amazon-bedrock/mantle/messages.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/messages.js +1 -0
- package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
- package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle.js +1 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +789 -0
- package/dist/providers/amazon-bedrock-mantle.js +107 -0
- package/dist/providers/amazon-bedrock.d.ts +190 -0
- package/dist/providers/amazon-bedrock.js +44 -0
- package/dist/providers/anthropic-compatible.d.ts +364 -0
- package/dist/providers/anthropic-compatible.js +47 -0
- package/dist/providers/anthropic.d.ts +362 -0
- package/dist/providers/anthropic.js +36 -0
- package/dist/providers/assemblyai.d.ts +19 -0
- package/dist/providers/assemblyai.js +19 -0
- package/dist/providers/azure/chat.d.ts +2 -0
- package/dist/providers/azure/chat.js +1 -0
- package/dist/providers/azure/embeddings.d.ts +2 -0
- package/dist/providers/azure/embeddings.js +1 -0
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure/messages.d.ts +2 -0
- package/dist/providers/azure/messages.js +1 -0
- package/dist/providers/azure/responses.d.ts +2 -0
- package/dist/providers/azure/responses.js +1 -0
- package/dist/providers/azure.d.ts +1074 -0
- package/dist/providers/azure.js +150 -0
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +384 -0
- package/dist/providers/baseten.js +56 -0
- package/dist/providers/byteplus/videos.d.ts +2 -0
- package/dist/providers/byteplus/videos.js +1 -0
- package/dist/providers/byteplus.d.ts +24 -0
- package/dist/providers/byteplus.js +21 -0
- package/dist/providers/cartesia.d.ts +18 -0
- package/dist/providers/cartesia.js +17 -0
- package/dist/providers/cerebras.d.ts +375 -0
- package/dist/providers/cerebras.js +33 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +1581 -0
- package/dist/providers/cloudflare-ai-gateway.js +120 -0
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
- package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/images.js +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +391 -0
- package/dist/providers/cloudflare-workers-ai.js +69 -0
- package/dist/providers/cohere/chat.d.ts +4 -0
- package/dist/providers/cohere/chat.js +3 -0
- package/dist/providers/cohere/embeddings.d.ts +2 -0
- package/dist/providers/cohere/embeddings.js +1 -0
- package/dist/providers/cohere.d.ts +502 -0
- package/dist/providers/cohere.js +55 -0
- package/dist/providers/deepgram.d.ts +22 -0
- package/dist/providers/deepgram.js +20 -0
- package/dist/providers/deepinfra/embeddings.d.ts +2 -0
- package/dist/providers/deepinfra/embeddings.js +1 -0
- package/dist/providers/deepinfra.d.ts +378 -0
- package/dist/providers/deepinfra.js +52 -0
- package/dist/providers/deepseek.d.ts +376 -0
- package/dist/providers/deepseek.js +30 -0
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.js +1 -0
- package/dist/providers/digitalocean/embeddings.d.ts +2 -0
- package/dist/providers/digitalocean/embeddings.js +1 -0
- package/dist/providers/digitalocean/images.d.ts +2 -0
- package/dist/providers/digitalocean/images.js +1 -0
- package/dist/providers/digitalocean/responses.d.ts +4 -0
- package/dist/providers/digitalocean/responses.js +1 -0
- package/dist/providers/digitalocean.d.ts +874 -0
- package/dist/providers/digitalocean.js +106 -0
- package/dist/providers/elevenlabs.d.ts +22 -0
- package/dist/providers/elevenlabs.js +22 -0
- package/dist/providers/fireworks/embeddings.d.ts +2 -0
- package/dist/providers/fireworks/embeddings.js +1 -0
- package/dist/providers/fireworks.d.ts +379 -0
- package/dist/providers/fireworks.js +40 -0
- package/dist/providers/google/decisions.d.ts +2 -0
- package/dist/providers/google/decisions.js +1 -0
- package/dist/providers/google/embeddings.d.ts +2 -0
- package/dist/providers/google/embeddings.js +1 -0
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google/interactions.d.ts +7 -0
- package/dist/providers/google/interactions.js +3 -0
- package/dist/providers/google/videos.d.ts +2 -0
- package/dist/providers/google/videos.js +1 -0
- package/dist/providers/google-vertex/chat.d.ts +2 -0
- package/dist/providers/google-vertex/chat.js +1 -0
- package/dist/providers/google-vertex/embeddings.d.ts +2 -0
- package/dist/providers/google-vertex/embeddings.js +1 -0
- package/dist/providers/google-vertex/gemini.d.ts +2 -0
- package/dist/providers/google-vertex/gemini.js +1 -0
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex/interactions.d.ts +2 -0
- package/dist/providers/google-vertex/interactions.js +1 -0
- package/dist/providers/google-vertex/messages.d.ts +2 -0
- package/dist/providers/google-vertex/messages.js +1 -0
- package/dist/providers/google-vertex/mistral.d.ts +2 -0
- package/dist/providers/google-vertex/mistral.js +1 -0
- package/dist/providers/google-vertex/responses.d.ts +2 -0
- package/dist/providers/google-vertex/responses.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +204 -0
- package/dist/providers/google-vertex-chat.js +29 -0
- package/dist/providers/google-vertex-interactions.d.ts +111 -0
- package/dist/providers/google-vertex-interactions.js +62 -0
- package/dist/providers/google-vertex-messages.d.ts +362 -0
- package/dist/providers/google-vertex-messages.js +51 -0
- package/dist/providers/google-vertex-mistral.d.ts +120 -0
- package/dist/providers/google-vertex-mistral.js +43 -0
- package/dist/providers/google-vertex-responses.d.ts +253 -0
- package/dist/providers/google-vertex-responses.js +30 -0
- package/dist/providers/google-vertex-shared.d.ts +58 -0
- package/dist/providers/google-vertex-shared.js +128 -0
- package/dist/providers/google-vertex.d.ts +132 -0
- package/dist/providers/google-vertex.js +161 -0
- package/dist/providers/google.d.ts +246 -0
- package/dist/providers/google.js +80 -0
- package/dist/providers/groq.d.ts +470 -0
- package/dist/providers/groq.js +63 -0
- package/dist/providers/index.d.ts +45 -0
- package/dist/providers/index.js +45 -0
- package/dist/providers/meta/chat.d.ts +2 -0
- package/dist/providers/meta/chat.js +1 -0
- package/dist/providers/meta/images.d.ts +2 -0
- package/dist/providers/meta/images.js +1 -0
- package/dist/providers/meta/messages.d.ts +2 -0
- package/dist/providers/meta/messages.js +1 -0
- package/dist/providers/meta/responses.d.ts +2 -0
- package/dist/providers/meta/responses.js +1 -0
- package/dist/providers/meta.d.ts +804 -0
- package/dist/providers/meta.js +96 -0
- package/dist/providers/minimax/chat.d.ts +4 -0
- package/dist/providers/minimax/chat.js +3 -0
- package/dist/providers/minimax/images.d.ts +3 -0
- package/dist/providers/minimax/images.js +1 -0
- package/dist/providers/minimax/messages.d.ts +1 -0
- package/dist/providers/minimax/messages.js +1 -0
- package/dist/providers/minimax/responses.d.ts +4 -0
- package/dist/providers/minimax/responses.js +3 -0
- package/dist/providers/minimax/videos.d.ts +3 -0
- package/dist/providers/minimax/videos.js +1 -0
- package/dist/providers/minimax.d.ts +798 -0
- package/dist/providers/minimax.js +99 -0
- package/dist/providers/mistral.d.ts +208 -0
- package/dist/providers/mistral.js +17 -0
- package/dist/providers/moonshot/chat.d.ts +1 -0
- package/dist/providers/moonshot/chat.js +1 -0
- package/dist/providers/moonshot/messages.d.ts +4 -0
- package/dist/providers/moonshot/messages.js +3 -0
- package/dist/providers/moonshot/responses.d.ts +4 -0
- package/dist/providers/moonshot/responses.js +3 -0
- package/dist/providers/moonshot.d.ts +785 -0
- package/dist/providers/moonshot.js +78 -0
- package/dist/providers/open-responses-options.d.ts +5 -0
- package/dist/providers/open-responses-options.js +1 -0
- package/dist/providers/openai/chat.d.ts +2 -0
- package/dist/providers/openai/chat.js +1 -0
- package/dist/providers/openai/embeddings.d.ts +2 -0
- package/dist/providers/openai/embeddings.js +1 -0
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.js +1 -0
- package/dist/providers/openai/responses.d.ts +2 -0
- package/dist/providers/openai/responses.js +1 -0
- package/dist/providers/openai-compatible/decisions.d.ts +2 -0
- package/dist/providers/openai-compatible/decisions.js +1 -0
- package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
- package/dist/providers/openai-compatible/embeddings.js +1 -0
- package/dist/providers/openai-compatible/images.d.ts +2 -0
- package/dist/providers/openai-compatible/images.js +1 -0
- package/dist/providers/openai-compatible/responses.d.ts +1 -0
- package/dist/providers/openai-compatible/responses.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +250 -0
- package/dist/providers/openai-compatible-responses.js +26 -0
- package/dist/providers/openai-compatible.d.ts +208 -0
- package/dist/providers/openai-compatible.js +71 -0
- package/dist/providers/openai-options.d.ts +21 -0
- package/dist/providers/openai-options.js +37 -0
- package/dist/providers/openai.d.ts +522 -0
- package/dist/providers/openai.js +118 -0
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +23 -0
- package/dist/providers/opencode.js +25 -0
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.js +1 -0
- package/dist/providers/openrouter/embeddings.d.ts +2 -0
- package/dist/providers/openrouter/embeddings.js +1 -0
- package/dist/providers/openrouter/images.d.ts +2 -0
- package/dist/providers/openrouter/images.js +1 -0
- package/dist/providers/openrouter/responses.d.ts +3 -0
- package/dist/providers/openrouter/responses.js +1 -0
- package/dist/providers/openrouter/videos.d.ts +2 -0
- package/dist/providers/openrouter/videos.js +1 -0
- package/dist/providers/openrouter.d.ts +1204 -0
- package/dist/providers/openrouter.js +210 -0
- package/dist/providers/settings.d.ts +40 -0
- package/dist/providers/settings.js +18 -0
- package/dist/providers/togetherai.d.ts +375 -0
- package/dist/providers/togetherai.js +30 -0
- package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
- package/dist/providers/typesafe-ai/decisions.js +1 -0
- package/dist/providers/typesafe-ai.d.ts +23 -0
- package/dist/providers/typesafe-ai.js +25 -0
- package/dist/providers/venice/responses.d.ts +4 -0
- package/dist/providers/venice/responses.js +1 -0
- package/dist/providers/venice.d.ts +632 -0
- package/dist/providers/venice.js +57 -0
- package/dist/providers/vercel-ai-gateway/chat.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/chat.js +1 -0
- package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
- package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
- package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway/messages.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/messages.js +1 -0
- package/dist/providers/vercel-ai-gateway/responses.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/responses.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +111 -0
- package/dist/providers/vercel-ai-gateway.js +181 -0
- package/dist/providers/volcengine/videos.d.ts +2 -0
- package/dist/providers/volcengine/videos.js +1 -0
- package/dist/providers/volcengine.d.ts +24 -0
- package/dist/providers/volcengine.js +21 -0
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai/videos.d.ts +2 -0
- package/dist/providers/xai/videos.js +1 -0
- package/dist/providers/xai.d.ts +235 -0
- package/dist/providers/xai.js +89 -0
- package/dist/providers/zai/chat.d.ts +1 -0
- package/dist/providers/zai/chat.js +1 -0
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan/chat.d.ts +1 -0
- package/dist/providers/zai-coding-plan/chat.js +1 -0
- package/dist/providers/zai-coding-plan/messages.d.ts +4 -0
- package/dist/providers/zai-coding-plan/messages.js +3 -0
- package/dist/providers/zai-coding-plan/responses.d.ts +4 -0
- package/dist/providers/zai-coding-plan/responses.js +3 -0
- package/dist/providers/zai-coding-plan.d.ts +846 -0
- package/dist/providers/zai-coding-plan.js +56 -0
- package/dist/providers/zai.d.ts +285 -0
- package/dist/providers/zai.js +44 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1 -0
- package/dist/public.d.ts +18 -0
- package/dist/public.js +7 -0
- package/dist/route/auth-options.d.ts +35 -0
- package/dist/route/auth-options.js +17 -0
- package/dist/route/auth.d.ts +52 -0
- package/dist/route/auth.js +92 -0
- package/dist/route/client.d.ts +229 -0
- package/dist/route/client.js +293 -0
- package/dist/route/decision.d.ts +55 -0
- package/dist/route/decision.js +73 -0
- package/dist/route/embedding.d.ts +58 -0
- package/dist/route/embedding.js +85 -0
- package/dist/route/endpoint.d.ts +29 -0
- package/dist/route/endpoint.js +21 -0
- package/dist/route/executor-service.d.ts +54 -0
- package/dist/route/executor-service.js +115 -0
- package/dist/route/executor.d.ts +37 -0
- package/dist/route/executor.js +225 -0
- package/dist/route/framing.d.ts +44 -0
- package/dist/route/framing.js +63 -0
- package/dist/route/index.d.ts +21 -0
- package/dist/route/index.js +18 -0
- package/dist/route/media-protocol.d.ts +187 -0
- package/dist/route/media-protocol.js +117 -0
- package/dist/route/media.d.ts +91 -0
- package/dist/route/media.js +251 -0
- package/dist/route/protocol.d.ts +85 -0
- package/dist/route/protocol.js +19 -0
- package/dist/route/transport/http.d.ts +34 -0
- package/dist/route/transport/http.js +67 -0
- package/dist/route/transport/index.d.ts +42 -0
- package/dist/route/transport/index.js +4 -0
- package/dist/route/transport/websocket-channel.d.ts +56 -0
- package/dist/route/transport/websocket-channel.js +1 -0
- package/dist/route/transport/websocket.d.ts +32 -0
- package/dist/route/transport/websocket.js +315 -0
- package/dist/route.d.ts +1 -0
- package/dist/route.js +1 -0
- package/dist/schema/errors.d.ts +194 -0
- package/dist/schema/errors.js +217 -0
- package/dist/schema/events.d.ts +11001 -0
- package/dist/schema/events.js +542 -0
- package/dist/schema/ids.d.ts +17 -0
- package/dist/schema/ids.js +10 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/messages.d.ts +2706 -0
- package/dist/schema/messages.js +344 -0
- package/dist/schema/options.d.ts +270 -0
- package/dist/schema/options.js +198 -0
- package/dist/speech.d.ts +266 -0
- package/dist/speech.js +114 -0
- package/dist/test-ai.d.ts +15 -0
- package/dist/test-ai.js +49 -0
- package/dist/testing.d.ts +1585 -0
- package/dist/testing.js +108 -0
- package/dist/tool-history.d.ts +2 -0
- package/dist/tool-history.js +91 -0
- package/dist/tool-runtime.d.ts +22 -0
- package/dist/tool-runtime.js +55 -0
- package/dist/tool-updates.d.ts +34 -0
- package/dist/tool-updates.js +93 -0
- package/dist/tool.d.ts +150 -0
- package/dist/tool.js +159 -0
- package/dist/transcription.d.ts +254 -0
- package/dist/transcription.js +119 -0
- package/dist/utils/bytes.d.ts +1 -0
- package/dist/utils/bytes.js +10 -0
- package/dist/utils/json.d.ts +4 -0
- package/dist/utils/json.js +4 -0
- package/dist/utils/media-type.d.ts +8 -0
- package/dist/utils/media-type.js +93 -0
- package/dist/utils/provider-codes.d.ts +3 -0
- package/dist/utils/provider-codes.js +41 -0
- package/dist/utils/record.d.ts +2 -0
- package/dist/utils/record.js +2 -0
- package/dist/utils/sanitize.d.ts +5 -0
- package/dist/utils/sanitize.js +31 -0
- package/dist/video-client.d.ts +12 -0
- package/dist/video-client.js +24 -0
- package/dist/video.d.ts +178 -0
- package/dist/video.js +79 -0
- package/package.json +648 -4
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { Route } from "../route/client.js";
|
|
3
|
+
import { type ModelID, type RequestOptions } from "../schema/index.js";
|
|
4
|
+
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
5
|
+
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
6
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
+
export type Config = RequestOptions & GoogleVertexShared.OAuthOptions & {
|
|
8
|
+
readonly baseURL?: string;
|
|
9
|
+
readonly location?: string;
|
|
10
|
+
readonly project?: string;
|
|
11
|
+
readonly providerOptions?: OpenResponsesProviderOptionsInput;
|
|
12
|
+
};
|
|
13
|
+
export type Settings = ProviderPackage.Settings & OpenResponsesProviderOptionsInput & {
|
|
14
|
+
readonly accessToken?: string;
|
|
15
|
+
readonly apiKey?: never;
|
|
16
|
+
readonly baseURL?: string;
|
|
17
|
+
readonly location?: string;
|
|
18
|
+
readonly project?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const routes: Route<{
|
|
21
|
+
readonly model: string;
|
|
22
|
+
readonly input: readonly ({
|
|
23
|
+
readonly type: "configuration_update";
|
|
24
|
+
readonly reasoning: {
|
|
25
|
+
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: "additional_tools";
|
|
29
|
+
readonly role: "developer";
|
|
30
|
+
readonly tools: readonly ({
|
|
31
|
+
readonly type: "custom";
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly description: string;
|
|
34
|
+
readonly format: {
|
|
35
|
+
readonly type: "text";
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: "grammar";
|
|
38
|
+
readonly syntax: "lark" | "regex";
|
|
39
|
+
readonly definition: string;
|
|
40
|
+
};
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: "function";
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly description: string;
|
|
45
|
+
readonly parameters: {
|
|
46
|
+
readonly [x: string]: unknown;
|
|
47
|
+
};
|
|
48
|
+
readonly strict?: boolean | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
readonly [x: string]: unknown;
|
|
51
|
+
readonly type: string;
|
|
52
|
+
})[];
|
|
53
|
+
} | {
|
|
54
|
+
readonly type: "message";
|
|
55
|
+
readonly role: "system";
|
|
56
|
+
readonly content: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly type: "message";
|
|
59
|
+
readonly role: "developer";
|
|
60
|
+
readonly content: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
63
|
+
readonly call_id: string;
|
|
64
|
+
readonly output: string | readonly ({
|
|
65
|
+
readonly type: "input_text";
|
|
66
|
+
readonly text: string;
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: "input_video";
|
|
69
|
+
readonly video_url: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "input_image";
|
|
72
|
+
readonly image_url: string;
|
|
73
|
+
readonly detail?: string | undefined;
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: "input_file";
|
|
76
|
+
readonly filename?: string | undefined;
|
|
77
|
+
readonly detail?: string | undefined;
|
|
78
|
+
readonly file_data?: string | undefined;
|
|
79
|
+
readonly file_url?: string | undefined;
|
|
80
|
+
})[];
|
|
81
|
+
} | {
|
|
82
|
+
readonly type: "reasoning";
|
|
83
|
+
readonly id?: string | undefined;
|
|
84
|
+
readonly summary: readonly {
|
|
85
|
+
readonly type: "summary_text";
|
|
86
|
+
readonly text: string;
|
|
87
|
+
}[];
|
|
88
|
+
readonly encrypted_content?: string | null | undefined;
|
|
89
|
+
} | {
|
|
90
|
+
readonly type: "compaction";
|
|
91
|
+
readonly id?: string | null | undefined;
|
|
92
|
+
readonly encrypted_content: string;
|
|
93
|
+
} | {
|
|
94
|
+
readonly type: "message";
|
|
95
|
+
readonly role: "user";
|
|
96
|
+
readonly content: readonly ({
|
|
97
|
+
readonly type: "input_text";
|
|
98
|
+
readonly text: string;
|
|
99
|
+
} | {
|
|
100
|
+
readonly type: "input_video";
|
|
101
|
+
readonly video_url: string;
|
|
102
|
+
} | {
|
|
103
|
+
readonly type: "input_image";
|
|
104
|
+
readonly image_url: string;
|
|
105
|
+
readonly detail?: string | undefined;
|
|
106
|
+
} | {
|
|
107
|
+
readonly type: "input_file";
|
|
108
|
+
readonly filename?: string | undefined;
|
|
109
|
+
readonly detail?: string | undefined;
|
|
110
|
+
readonly file_data?: string | undefined;
|
|
111
|
+
readonly file_url?: string | undefined;
|
|
112
|
+
})[];
|
|
113
|
+
readonly id?: string | undefined;
|
|
114
|
+
readonly status?: string | undefined;
|
|
115
|
+
} | {
|
|
116
|
+
readonly type: "message";
|
|
117
|
+
readonly id?: string | undefined;
|
|
118
|
+
readonly role: "assistant";
|
|
119
|
+
readonly content: readonly {
|
|
120
|
+
readonly type: "output_text";
|
|
121
|
+
readonly text: string;
|
|
122
|
+
}[];
|
|
123
|
+
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
124
|
+
readonly status?: string | undefined;
|
|
125
|
+
} | {
|
|
126
|
+
readonly type: "function_call";
|
|
127
|
+
readonly id?: string | undefined;
|
|
128
|
+
readonly call_id: string;
|
|
129
|
+
readonly name: string;
|
|
130
|
+
readonly namespace?: string | undefined;
|
|
131
|
+
readonly arguments: string;
|
|
132
|
+
} | {
|
|
133
|
+
readonly type: "custom_tool_call";
|
|
134
|
+
readonly id?: string | undefined;
|
|
135
|
+
readonly call_id: string;
|
|
136
|
+
readonly name: string;
|
|
137
|
+
readonly input: string;
|
|
138
|
+
} | {
|
|
139
|
+
readonly [x: string]: unknown;
|
|
140
|
+
readonly type: "web_search_call";
|
|
141
|
+
readonly id: string;
|
|
142
|
+
readonly status?: string | undefined;
|
|
143
|
+
readonly action?: {
|
|
144
|
+
readonly [x: string]: unknown;
|
|
145
|
+
} | null | undefined;
|
|
146
|
+
} | {
|
|
147
|
+
readonly [x: string]: unknown;
|
|
148
|
+
readonly type: "file_search_call";
|
|
149
|
+
readonly id: string;
|
|
150
|
+
readonly status?: string | undefined;
|
|
151
|
+
readonly queries?: readonly string[] | undefined;
|
|
152
|
+
readonly results?: readonly {
|
|
153
|
+
readonly [x: string]: unknown;
|
|
154
|
+
}[] | null | undefined;
|
|
155
|
+
} | {
|
|
156
|
+
readonly [x: string]: unknown;
|
|
157
|
+
readonly type: "code_interpreter_call";
|
|
158
|
+
readonly id: string;
|
|
159
|
+
readonly status?: string | undefined;
|
|
160
|
+
readonly code?: string | null | undefined;
|
|
161
|
+
readonly container_id?: string | null | undefined;
|
|
162
|
+
readonly outputs?: readonly {
|
|
163
|
+
readonly [x: string]: unknown;
|
|
164
|
+
}[] | null | undefined;
|
|
165
|
+
} | {
|
|
166
|
+
readonly [x: string]: unknown;
|
|
167
|
+
readonly type: "mcp_call";
|
|
168
|
+
readonly id: string;
|
|
169
|
+
readonly status?: string | undefined;
|
|
170
|
+
readonly server_label?: string | undefined;
|
|
171
|
+
readonly name?: string | undefined;
|
|
172
|
+
readonly arguments?: string | undefined;
|
|
173
|
+
readonly output?: string | null | undefined;
|
|
174
|
+
readonly error?: unknown;
|
|
175
|
+
} | {
|
|
176
|
+
readonly [x: string]: unknown;
|
|
177
|
+
readonly type: string;
|
|
178
|
+
readonly id: string;
|
|
179
|
+
})[];
|
|
180
|
+
readonly instructions?: string | undefined;
|
|
181
|
+
readonly tools?: readonly ({
|
|
182
|
+
readonly type: "custom";
|
|
183
|
+
readonly name: string;
|
|
184
|
+
readonly description: string;
|
|
185
|
+
readonly format: {
|
|
186
|
+
readonly type: "text";
|
|
187
|
+
} | {
|
|
188
|
+
readonly type: "grammar";
|
|
189
|
+
readonly syntax: "lark" | "regex";
|
|
190
|
+
readonly definition: string;
|
|
191
|
+
};
|
|
192
|
+
} | {
|
|
193
|
+
readonly type: "function";
|
|
194
|
+
readonly name: string;
|
|
195
|
+
readonly description: string;
|
|
196
|
+
readonly parameters: {
|
|
197
|
+
readonly [x: string]: unknown;
|
|
198
|
+
};
|
|
199
|
+
readonly strict?: boolean | undefined;
|
|
200
|
+
} | {
|
|
201
|
+
readonly [x: string]: unknown;
|
|
202
|
+
readonly type: string;
|
|
203
|
+
})[] | undefined;
|
|
204
|
+
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
205
|
+
readonly type: "custom" | "function";
|
|
206
|
+
readonly name: string;
|
|
207
|
+
} | {
|
|
208
|
+
readonly type: "allowed_tools";
|
|
209
|
+
readonly mode: "auto" | "none" | "required";
|
|
210
|
+
readonly tools: readonly {
|
|
211
|
+
readonly type: "custom" | "function";
|
|
212
|
+
readonly name: string;
|
|
213
|
+
}[];
|
|
214
|
+
} | undefined;
|
|
215
|
+
readonly store?: boolean | undefined;
|
|
216
|
+
readonly metadata?: {
|
|
217
|
+
readonly [x: string]: string;
|
|
218
|
+
} | undefined;
|
|
219
|
+
readonly safety_identifier?: string | undefined;
|
|
220
|
+
readonly stream_options?: {
|
|
221
|
+
readonly include_obfuscation?: boolean | undefined;
|
|
222
|
+
} | undefined;
|
|
223
|
+
readonly top_logprobs?: number | undefined;
|
|
224
|
+
readonly truncation?: "auto" | "disabled" | undefined;
|
|
225
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
226
|
+
readonly prompt_cache_key?: string | undefined;
|
|
227
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
228
|
+
readonly reasoning?: {
|
|
229
|
+
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
230
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
231
|
+
} | undefined;
|
|
232
|
+
readonly text?: {
|
|
233
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
234
|
+
} | undefined;
|
|
235
|
+
readonly max_output_tokens?: number | undefined;
|
|
236
|
+
readonly max_tool_calls?: number | undefined;
|
|
237
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
238
|
+
readonly temperature?: number | undefined;
|
|
239
|
+
readonly top_p?: number | undefined;
|
|
240
|
+
readonly presence_penalty?: number | undefined;
|
|
241
|
+
readonly frequency_penalty?: number | undefined;
|
|
242
|
+
readonly stream: true;
|
|
243
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
|
|
244
|
+
export declare const configure: (input?: Config) => {
|
|
245
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
246
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
247
|
+
configure: typeof configure;
|
|
248
|
+
};
|
|
249
|
+
export declare const provider: {
|
|
250
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
251
|
+
configure: typeof configure;
|
|
252
|
+
};
|
|
253
|
+
export declare const model: ProviderPackage.Model<Settings, OpenResponsesProviderOptionsInput>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OpenResponses } from "../protocols/open-responses.js";
|
|
2
|
+
import { Route } from "../route/client.js";
|
|
3
|
+
import { Endpoint } from "../route/endpoint.js";
|
|
4
|
+
import { ProviderID } from "../schema/index.js";
|
|
5
|
+
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
6
|
+
export const id = ProviderID.make("google-vertex");
|
|
7
|
+
const route = Route.make({
|
|
8
|
+
id: "google-vertex-responses",
|
|
9
|
+
provider: id,
|
|
10
|
+
providerMetadataKey: "vertex",
|
|
11
|
+
protocol: OpenResponses.protocol,
|
|
12
|
+
endpoint: Endpoint.path(OpenResponses.PATH),
|
|
13
|
+
transport: OpenResponses.httpTransport,
|
|
14
|
+
options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
15
|
+
});
|
|
16
|
+
export const routes = [route];
|
|
17
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Responses", input, (project, location) => `https://aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/endpoints/openapi`);
|
|
18
|
+
export const configure = (input = {}) => {
|
|
19
|
+
const route = configuredRoute(input);
|
|
20
|
+
return {
|
|
21
|
+
id,
|
|
22
|
+
model: (modelID) => route.model({ id: modelID }),
|
|
23
|
+
configure,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export const provider = {
|
|
27
|
+
id,
|
|
28
|
+
configure,
|
|
29
|
+
};
|
|
30
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Responses", settings)).model(modelID);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { AnyAuthClient } from "google-auth-library";
|
|
2
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
3
|
+
import { Auth } from "../route/auth.js";
|
|
4
|
+
import type { CompactionOperations, Route } from "../route/client.js";
|
|
5
|
+
import { type RequestOptions } from "../schema/index.js";
|
|
6
|
+
export declare const loadADCClient: (project?: string) => Promise<AnyAuthClient>;
|
|
7
|
+
export type OAuthOptions = {
|
|
8
|
+
readonly accessToken?: string;
|
|
9
|
+
readonly auth?: never;
|
|
10
|
+
} | {
|
|
11
|
+
readonly accessToken?: never;
|
|
12
|
+
readonly auth?: Auth.Definition;
|
|
13
|
+
};
|
|
14
|
+
export type ApiKeyOptions = (OAuthOptions & {
|
|
15
|
+
readonly apiKey?: never;
|
|
16
|
+
}) | {
|
|
17
|
+
readonly accessToken?: never;
|
|
18
|
+
readonly apiKey?: string;
|
|
19
|
+
readonly auth?: never;
|
|
20
|
+
};
|
|
21
|
+
export declare const project: (value?: string) => string | undefined;
|
|
22
|
+
export declare const location: (value: string | undefined) => string;
|
|
23
|
+
export declare const host: (location: string) => string;
|
|
24
|
+
export declare const requireProject: (value: string | undefined) => string;
|
|
25
|
+
export declare const apiKey: (input: ApiKeyOptions & {
|
|
26
|
+
readonly project?: string;
|
|
27
|
+
readonly location?: string;
|
|
28
|
+
}) => string | undefined;
|
|
29
|
+
export declare const oauth: (input: OAuthOptions, project?: string) => Auth.Definition;
|
|
30
|
+
export declare const oauthRoute: <Body, Prepared, Compact extends CompactionOperations | undefined>(route: Route<Body, Prepared, Compact>, label: string, input: RequestOptions & OAuthOptions & {
|
|
31
|
+
readonly baseURL?: string;
|
|
32
|
+
readonly location?: string;
|
|
33
|
+
readonly project?: string;
|
|
34
|
+
}, url: (project: string, location: string) => string) => Route<Body, Prepared, Compact>;
|
|
35
|
+
export declare const oauthSettings: <Options>(label: string, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }: ProviderPackage.Settings & Options & {
|
|
36
|
+
readonly accessToken?: string;
|
|
37
|
+
readonly apiKey?: never;
|
|
38
|
+
readonly baseURL?: string;
|
|
39
|
+
readonly location?: string;
|
|
40
|
+
readonly project?: string;
|
|
41
|
+
}) => {
|
|
42
|
+
accessToken: string | undefined;
|
|
43
|
+
baseURL: string | undefined;
|
|
44
|
+
http: {
|
|
45
|
+
headers: Readonly<Record<string, string>> | undefined;
|
|
46
|
+
body: Readonly<Record<string, unknown>> | undefined;
|
|
47
|
+
};
|
|
48
|
+
location: string | undefined;
|
|
49
|
+
project: string | undefined;
|
|
50
|
+
providerOptions: Omit<ProviderPackage.Settings & Options & {
|
|
51
|
+
readonly accessToken?: string;
|
|
52
|
+
readonly apiKey?: never;
|
|
53
|
+
readonly baseURL?: string;
|
|
54
|
+
readonly location?: string;
|
|
55
|
+
readonly project?: string;
|
|
56
|
+
}, "accessToken" | "apiKey" | "baseURL" | "body" | "headers" | "location" | "project">;
|
|
57
|
+
};
|
|
58
|
+
export * as GoogleVertexShared from "./google-vertex-shared.js";
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Effect, Redacted } from "effect";
|
|
2
|
+
import { Auth, MissingCredentialError } from "../route/auth.js";
|
|
3
|
+
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
4
|
+
const SCOPE = "https://www.googleapis.com/auth/cloud-platform";
|
|
5
|
+
const id = ProviderID.make("google-vertex");
|
|
6
|
+
export const loadADCClient = async (project) => {
|
|
7
|
+
const { GoogleAuth } = await import("google-auth-library");
|
|
8
|
+
// google-auth-library 10.5.0 ignores CLOUDSDK_CONFIG during ADC file discovery.
|
|
9
|
+
// Fix this in shipped AI code: a repository-level Bun dependency patch would not
|
|
10
|
+
// reach npm or Bun consumers of the published @radheim/ai package.
|
|
11
|
+
// Override only the well-known-file lookup: keyFilename bypasses ADC's quota-project
|
|
12
|
+
// preparation. Keep explicit credentials and metadata fallback in Google's ADC chain.
|
|
13
|
+
class CloudSDKAuth extends GoogleAuth {
|
|
14
|
+
async _tryGetApplicationCredentialsFromWellKnownFile(options) {
|
|
15
|
+
const config = process.env.CLOUDSDK_CONFIG;
|
|
16
|
+
if (!config)
|
|
17
|
+
return super._tryGetApplicationCredentialsFromWellKnownFile(options);
|
|
18
|
+
// Keep local filesystem helpers lazy for explicitly authenticated Worker callers;
|
|
19
|
+
// this ADC-file lookup itself requires a Node-compatible filesystem.
|
|
20
|
+
const { existsSync } = await import("node:fs");
|
|
21
|
+
const { homedir } = await import("node:os");
|
|
22
|
+
const { join } = await import("node:path");
|
|
23
|
+
const directory = config === "~" ? homedir() : config.startsWith("~/") ? join(homedir(), config.slice(2)) : config;
|
|
24
|
+
const file = join(directory, "application_default_credentials.json");
|
|
25
|
+
if (!existsSync(file))
|
|
26
|
+
return null;
|
|
27
|
+
return this._getApplicationCredentialsFromFilePath(file, options);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return new CloudSDKAuth({ projectId: project, scopes: [SCOPE] }).getClient();
|
|
31
|
+
};
|
|
32
|
+
export const project = (value) => value ??
|
|
33
|
+
process.env.GOOGLE_VERTEX_PROJECT ??
|
|
34
|
+
process.env.GOOGLE_CLOUD_PROJECT ??
|
|
35
|
+
process.env.GCP_PROJECT ??
|
|
36
|
+
process.env.GCLOUD_PROJECT;
|
|
37
|
+
export const location = (value) => value ??
|
|
38
|
+
process.env.GOOGLE_VERTEX_LOCATION ??
|
|
39
|
+
process.env.GOOGLE_CLOUD_LOCATION ??
|
|
40
|
+
process.env.VERTEX_LOCATION ??
|
|
41
|
+
"global";
|
|
42
|
+
export const host = (location) => {
|
|
43
|
+
if (location === "global")
|
|
44
|
+
return "aiplatform.googleapis.com";
|
|
45
|
+
// Jurisdictional multi-regions use Regional Endpoint Platform domains.
|
|
46
|
+
if (location === "eu" || location === "us")
|
|
47
|
+
return `aiplatform.${location}.rep.googleapis.com`;
|
|
48
|
+
return `${location}-aiplatform.googleapis.com`;
|
|
49
|
+
};
|
|
50
|
+
export const requireProject = (value) => {
|
|
51
|
+
if (value)
|
|
52
|
+
return value;
|
|
53
|
+
throw new ProviderConfigurationError({
|
|
54
|
+
provider: id,
|
|
55
|
+
message: "Google Vertex requires a project when baseURL is not configured",
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
export const apiKey = (input) => {
|
|
59
|
+
if (input.apiKey !== undefined && (input.accessToken !== undefined || input.auth !== undefined))
|
|
60
|
+
throw new ProviderConfigurationError({
|
|
61
|
+
provider: id,
|
|
62
|
+
message: "Google Vertex apiKey cannot be combined with accessToken or auth",
|
|
63
|
+
});
|
|
64
|
+
if (input.accessToken !== undefined || input.auth !== undefined)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (input.apiKey !== undefined)
|
|
67
|
+
return input.apiKey;
|
|
68
|
+
// Same precedence as Google's Gen AI SDK: an explicit project or location selects Google credentials,
|
|
69
|
+
// so an ambient API key cannot replace them.
|
|
70
|
+
if (input.project !== undefined || input.location !== undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
return process.env.GOOGLE_VERTEX_API_KEY;
|
|
73
|
+
};
|
|
74
|
+
const adc = (project) => {
|
|
75
|
+
let client;
|
|
76
|
+
const loadClient = () => {
|
|
77
|
+
if (client)
|
|
78
|
+
return client;
|
|
79
|
+
client = loadADCClient(project);
|
|
80
|
+
return client;
|
|
81
|
+
};
|
|
82
|
+
return Auth.effect(Effect.tryPromise({
|
|
83
|
+
try: async () => {
|
|
84
|
+
const token = await (await loadClient()).getAccessToken();
|
|
85
|
+
if (!token.token)
|
|
86
|
+
throw new Error("Google ADC returned an empty access token");
|
|
87
|
+
return Redacted.make(token.token);
|
|
88
|
+
},
|
|
89
|
+
catch: () => new MissingCredentialError("Google Application Default Credentials"),
|
|
90
|
+
})).bearer();
|
|
91
|
+
};
|
|
92
|
+
export const oauth = (input, project) => {
|
|
93
|
+
if (input.accessToken !== undefined && input.auth !== undefined)
|
|
94
|
+
throw new ProviderConfigurationError({
|
|
95
|
+
provider: id,
|
|
96
|
+
message: "Google Vertex accessToken cannot be combined with auth",
|
|
97
|
+
});
|
|
98
|
+
if (input.auth)
|
|
99
|
+
return input.auth;
|
|
100
|
+
if (input.accessToken !== undefined)
|
|
101
|
+
return Auth.bearer(input.accessToken);
|
|
102
|
+
return adc(project);
|
|
103
|
+
};
|
|
104
|
+
export const oauthRoute = (route, label, input, url) => {
|
|
105
|
+
if ("apiKey" in input && input.apiKey !== undefined)
|
|
106
|
+
throw new ProviderConfigurationError({ provider: id, message: `Google Vertex ${label} does not support API keys` });
|
|
107
|
+
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
108
|
+
const resolvedLocation = location(inputLocation);
|
|
109
|
+
const resolvedProject = project(inputProject);
|
|
110
|
+
return route.with({
|
|
111
|
+
...rest,
|
|
112
|
+
endpoint: { baseURL: baseURL ?? url(requireProject(resolvedProject), resolvedLocation) },
|
|
113
|
+
auth: oauth(input, resolvedProject),
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
export const oauthSettings = (label, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
|
|
117
|
+
if (apiKey !== undefined)
|
|
118
|
+
throw new ProviderConfigurationError({ provider: id, message: `Google Vertex ${label} does not support API keys` });
|
|
119
|
+
return {
|
|
120
|
+
accessToken,
|
|
121
|
+
baseURL,
|
|
122
|
+
http: { headers, body },
|
|
123
|
+
location,
|
|
124
|
+
project,
|
|
125
|
+
providerOptions,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export * as GoogleVertexShared from "./google-vertex-shared.js";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { Gemini } from "../protocols/gemini.js";
|
|
3
|
+
import { type VertexOptionsInput } from "../protocols/google-embed-content.js";
|
|
4
|
+
import { type OptionsInput as PredictOptionsInput } from "../protocols/google-vertex-predict-embeddings.js";
|
|
5
|
+
import { Route } from "../route/client.js";
|
|
6
|
+
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
7
|
+
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
8
|
+
export interface GeminiOptionsInput extends Gemini.OptionsInput {
|
|
9
|
+
readonly labels?: Readonly<Record<string, string>>;
|
|
10
|
+
}
|
|
11
|
+
export type GeminiProviderOptionsInput = GeminiOptionsInput;
|
|
12
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
13
|
+
export type Config = RequestOptions & GoogleVertexShared.ApiKeyOptions & {
|
|
14
|
+
readonly baseURL?: string;
|
|
15
|
+
readonly location?: string;
|
|
16
|
+
readonly project?: string;
|
|
17
|
+
readonly providerOptions?: GeminiProviderOptionsInput;
|
|
18
|
+
};
|
|
19
|
+
export type Settings = ProviderPackage.Settings & GeminiProviderOptionsInput & ({
|
|
20
|
+
readonly accessToken?: string;
|
|
21
|
+
readonly apiKey?: never;
|
|
22
|
+
} | {
|
|
23
|
+
readonly accessToken?: never;
|
|
24
|
+
readonly apiKey?: string;
|
|
25
|
+
}) & {
|
|
26
|
+
readonly baseURL?: string;
|
|
27
|
+
readonly location?: string;
|
|
28
|
+
readonly project?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const routes: Route<{
|
|
31
|
+
readonly cachedContent?: string | undefined;
|
|
32
|
+
readonly contents: readonly {
|
|
33
|
+
readonly role?: "model" | "user" | null | undefined;
|
|
34
|
+
readonly parts?: readonly ({
|
|
35
|
+
readonly fileData: {
|
|
36
|
+
readonly mimeType: string;
|
|
37
|
+
readonly fileUri: string;
|
|
38
|
+
};
|
|
39
|
+
} | {
|
|
40
|
+
readonly functionResponse: {
|
|
41
|
+
readonly id?: string | undefined;
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly response: unknown;
|
|
44
|
+
readonly parts?: readonly {
|
|
45
|
+
readonly inlineData: {
|
|
46
|
+
readonly mimeType: string;
|
|
47
|
+
readonly data: string;
|
|
48
|
+
};
|
|
49
|
+
readonly thoughtSignature?: string | null | undefined;
|
|
50
|
+
}[] | undefined;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
readonly text: string;
|
|
54
|
+
readonly thought?: boolean | null | undefined;
|
|
55
|
+
readonly thoughtSignature?: string | null | undefined;
|
|
56
|
+
} | {
|
|
57
|
+
readonly inlineData: {
|
|
58
|
+
readonly mimeType: string;
|
|
59
|
+
readonly data: string;
|
|
60
|
+
};
|
|
61
|
+
readonly thoughtSignature?: string | null | undefined;
|
|
62
|
+
} | {
|
|
63
|
+
readonly functionCall: {
|
|
64
|
+
readonly id?: string | null | undefined;
|
|
65
|
+
readonly name: string;
|
|
66
|
+
readonly args?: unknown;
|
|
67
|
+
};
|
|
68
|
+
readonly thoughtSignature?: string | null | undefined;
|
|
69
|
+
})[] | null | undefined;
|
|
70
|
+
}[];
|
|
71
|
+
readonly labels?: {
|
|
72
|
+
readonly [x: string]: string;
|
|
73
|
+
} | undefined;
|
|
74
|
+
readonly safetySettings?: readonly {
|
|
75
|
+
readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">;
|
|
76
|
+
readonly threshold: import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">;
|
|
77
|
+
}[] | undefined;
|
|
78
|
+
readonly serviceTier?: string | undefined;
|
|
79
|
+
readonly systemInstruction?: {
|
|
80
|
+
readonly parts: readonly {
|
|
81
|
+
readonly text: string;
|
|
82
|
+
}[];
|
|
83
|
+
} | undefined;
|
|
84
|
+
readonly tools?: readonly {
|
|
85
|
+
readonly functionDeclarations: readonly {
|
|
86
|
+
readonly name: string;
|
|
87
|
+
readonly description: string;
|
|
88
|
+
readonly parametersJsonSchema: {
|
|
89
|
+
readonly [x: string]: unknown;
|
|
90
|
+
};
|
|
91
|
+
}[];
|
|
92
|
+
}[] | undefined;
|
|
93
|
+
readonly toolConfig?: {
|
|
94
|
+
readonly functionCallingConfig: {
|
|
95
|
+
readonly mode: "ANY" | "AUTO" | "NONE";
|
|
96
|
+
readonly allowedFunctionNames?: readonly string[] | undefined;
|
|
97
|
+
};
|
|
98
|
+
} | undefined;
|
|
99
|
+
readonly generationConfig?: {
|
|
100
|
+
readonly maxOutputTokens?: number | undefined;
|
|
101
|
+
readonly temperature?: number | undefined;
|
|
102
|
+
readonly topP?: number | undefined;
|
|
103
|
+
readonly topK?: number | undefined;
|
|
104
|
+
readonly frequencyPenalty?: number | undefined;
|
|
105
|
+
readonly presencePenalty?: number | undefined;
|
|
106
|
+
readonly seed?: number | undefined;
|
|
107
|
+
readonly stopSequences?: readonly string[] | undefined;
|
|
108
|
+
readonly thinkingConfig?: {
|
|
109
|
+
readonly thinkingBudget?: number | undefined;
|
|
110
|
+
readonly includeThoughts?: boolean | undefined;
|
|
111
|
+
readonly thinkingLevel?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
|
|
112
|
+
} | undefined;
|
|
113
|
+
} | undefined;
|
|
114
|
+
readonly continuationToken?: string | undefined;
|
|
115
|
+
}, Gemini.Prepared, import("../route/client.js").CompactionOperations | undefined>[];
|
|
116
|
+
export type { VertexOptionsInput as GoogleVertexEmbeddingOptions } from "../protocols/google-embed-content.js";
|
|
117
|
+
export type { OptionsInput as GoogleVertexPredictEmbeddingOptions } from "../protocols/google-vertex-predict-embeddings.js";
|
|
118
|
+
export declare const configure: (input?: Config) => {
|
|
119
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
120
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<GeminiOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
121
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
122
|
+
/** `gemini-embedding-2*` through `embedContent`, other models through `:predict`; see `embeddingTarget`. */
|
|
123
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<VertexOptionsInput & PredictOptionsInput>;
|
|
124
|
+
configure: typeof configure;
|
|
125
|
+
};
|
|
126
|
+
export declare const provider: {
|
|
127
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
128
|
+
configure: typeof configure;
|
|
129
|
+
};
|
|
130
|
+
export declare const model: ProviderPackage.Model<Settings, GeminiProviderOptionsInput>;
|
|
131
|
+
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
|
|
132
|
+
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<VertexOptionsInput & PredictOptionsInput>;
|