@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,344 @@
|
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
|
+
import { withStatics } from "@radheim/schema/schema";
|
|
3
|
+
import { Tool } from "@radheim/schema/tool";
|
|
4
|
+
import { CacheHint, JsonSchema, ProviderMetadata, ReasoningEffort, } from "./options.js";
|
|
5
|
+
import { ProviderID } from "./ids.js";
|
|
6
|
+
import { Media } from "../media.js";
|
|
7
|
+
import { Json } from "../utils/json.js";
|
|
8
|
+
import { toEntry } from "../tool.js";
|
|
9
|
+
export const MessageRole = Schema.Literals(["system", "user", "assistant", "tool"]);
|
|
10
|
+
const systemPartSchema = Schema.Struct({
|
|
11
|
+
type: Schema.Literal("text"),
|
|
12
|
+
text: Schema.String,
|
|
13
|
+
cache: Schema.optional(CacheHint),
|
|
14
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
15
|
+
}).annotate({ identifier: "AI.SystemPart" });
|
|
16
|
+
// Typed as a plain codec so the schema's own object `make` doesn't overload this one.
|
|
17
|
+
export const SystemPart = withStatics(systemPartSchema, {
|
|
18
|
+
make: (text, options) => ({ type: "text", text, ...options }),
|
|
19
|
+
});
|
|
20
|
+
const textPartSchema = Schema.Struct({
|
|
21
|
+
type: Schema.Literal("text"),
|
|
22
|
+
text: Schema.String,
|
|
23
|
+
cache: Schema.optional(CacheHint),
|
|
24
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
25
|
+
}).annotate({ identifier: "AI.Content.Text" });
|
|
26
|
+
export const TextPart = withStatics(textPartSchema, {
|
|
27
|
+
make: (text, options) => ({ type: "text", text, ...options }),
|
|
28
|
+
});
|
|
29
|
+
const mediaPartSchema = Schema.Struct({
|
|
30
|
+
type: Schema.Literal("media"),
|
|
31
|
+
media: Media.AssetSchema,
|
|
32
|
+
filename: Schema.optional(Schema.String),
|
|
33
|
+
cache: Schema.optional(CacheHint),
|
|
34
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
35
|
+
}).annotate({ identifier: "AI.Content.Media" });
|
|
36
|
+
const mediaPart = (input) => {
|
|
37
|
+
const { mediaType, ...part } = input;
|
|
38
|
+
return { ...part, media: Media.make(input.media, mediaType) };
|
|
39
|
+
};
|
|
40
|
+
export const MediaPart = withStatics(mediaPartSchema, {
|
|
41
|
+
// Typed through `MediaPartInput` so packages that infer types from `MediaPart` can still emit declarations.
|
|
42
|
+
make: (media, options) => mediaPart({ type: "media", media, ...options }),
|
|
43
|
+
});
|
|
44
|
+
const toolResultValueSchema = Schema.Union([
|
|
45
|
+
Schema.Struct({
|
|
46
|
+
type: Schema.Literal("json"),
|
|
47
|
+
value: Schema.Unknown,
|
|
48
|
+
}),
|
|
49
|
+
Schema.Struct({
|
|
50
|
+
type: Schema.Literal("text"),
|
|
51
|
+
value: Schema.Unknown,
|
|
52
|
+
}),
|
|
53
|
+
Schema.Struct({
|
|
54
|
+
type: Schema.Literal("error"),
|
|
55
|
+
value: Schema.Unknown,
|
|
56
|
+
}),
|
|
57
|
+
Schema.Struct({
|
|
58
|
+
type: Schema.Literal("content"),
|
|
59
|
+
value: Schema.Array(Tool.Content),
|
|
60
|
+
}),
|
|
61
|
+
])
|
|
62
|
+
.annotate({ identifier: "AI.ToolResult" })
|
|
63
|
+
.pipe(Schema.toTaggedUnion("type"));
|
|
64
|
+
const isToolResultValue = Schema.is(toolResultValueSchema);
|
|
65
|
+
export const ToolResultValue = withStatics(toolResultValueSchema, {
|
|
66
|
+
make: (value, type = "json") => {
|
|
67
|
+
if (isToolResultValue(value))
|
|
68
|
+
return value;
|
|
69
|
+
if (type === "content")
|
|
70
|
+
return { type, value: Array.isArray(value) ? value : [] };
|
|
71
|
+
return { type, value };
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
export const ToolOutput = withStatics(Schema.Struct({
|
|
75
|
+
structured: Schema.Unknown,
|
|
76
|
+
content: Schema.Array(Tool.Content),
|
|
77
|
+
}).annotate({ identifier: "AI.ToolOutput" }), {
|
|
78
|
+
make: (structured, content = []) => ({ structured, content }),
|
|
79
|
+
fromResultValue: (result) => {
|
|
80
|
+
switch (result.type) {
|
|
81
|
+
case "json":
|
|
82
|
+
return { structured: result.value, content: [] };
|
|
83
|
+
case "text":
|
|
84
|
+
return { structured: {}, content: [{ type: "text", text: toolResultText(result.value) }] };
|
|
85
|
+
case "content":
|
|
86
|
+
return { structured: {}, content: result.value };
|
|
87
|
+
case "error":
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
toResultValue: (output) => {
|
|
92
|
+
if (output.content.length === 0)
|
|
93
|
+
return { type: "json", value: output.structured };
|
|
94
|
+
if (output.content.length === 1 && output.content[0]?.type === "text")
|
|
95
|
+
return { type: "text", value: output.content[0].text };
|
|
96
|
+
return { type: "content", value: output.content };
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const encodeJsonOption = Schema.encodeUnknownOption(Json);
|
|
100
|
+
const toolResultText = (value) => {
|
|
101
|
+
if (typeof value === "string")
|
|
102
|
+
return value;
|
|
103
|
+
return Option.getOrElse(encodeJsonOption(value), () => String(value));
|
|
104
|
+
};
|
|
105
|
+
export const ToolCallPart = withStatics(Schema.Struct({
|
|
106
|
+
type: Schema.Literal("tool-call"),
|
|
107
|
+
id: Schema.String,
|
|
108
|
+
name: Schema.String,
|
|
109
|
+
namespace: Schema.optional(Schema.String),
|
|
110
|
+
input: Schema.Unknown,
|
|
111
|
+
providerExecuted: Schema.optional(Schema.Boolean),
|
|
112
|
+
cache: Schema.optional(CacheHint),
|
|
113
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
114
|
+
}).annotate({ identifier: "AI.Content.ToolCall" }), {
|
|
115
|
+
make: (input) => ({ type: "tool-call", ...input }),
|
|
116
|
+
});
|
|
117
|
+
export const ToolResultPart = withStatics(Schema.Struct({
|
|
118
|
+
type: Schema.Literal("tool-result"),
|
|
119
|
+
id: Schema.String,
|
|
120
|
+
name: Schema.String,
|
|
121
|
+
namespace: Schema.optional(Schema.String),
|
|
122
|
+
result: ToolResultValue,
|
|
123
|
+
providerExecuted: Schema.optional(Schema.Boolean),
|
|
124
|
+
cache: Schema.optional(CacheHint),
|
|
125
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
126
|
+
}).annotate({ identifier: "AI.Content.ToolResult" }), {
|
|
127
|
+
make: (input) => ({
|
|
128
|
+
type: "tool-result",
|
|
129
|
+
id: input.id,
|
|
130
|
+
name: input.name,
|
|
131
|
+
namespace: input.namespace,
|
|
132
|
+
result: ToolResultValue.make(input.result, input.resultType),
|
|
133
|
+
providerExecuted: input.providerExecuted,
|
|
134
|
+
cache: input.cache,
|
|
135
|
+
providerMetadata: input.providerMetadata,
|
|
136
|
+
}),
|
|
137
|
+
});
|
|
138
|
+
const reasoningPartSchema = Schema.Struct({
|
|
139
|
+
type: Schema.Literal("reasoning"),
|
|
140
|
+
text: Schema.String,
|
|
141
|
+
encrypted: Schema.optional(Schema.String),
|
|
142
|
+
cache: Schema.optional(CacheHint),
|
|
143
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
144
|
+
}).annotate({ identifier: "AI.Content.Reasoning" });
|
|
145
|
+
export const ReasoningPart = withStatics(reasoningPartSchema, {
|
|
146
|
+
make: (text, options) => ({
|
|
147
|
+
type: "reasoning",
|
|
148
|
+
text,
|
|
149
|
+
...options,
|
|
150
|
+
}),
|
|
151
|
+
});
|
|
152
|
+
const compactionPartSchema = Schema.Struct({
|
|
153
|
+
type: Schema.Literal("compaction"),
|
|
154
|
+
provider: ProviderID,
|
|
155
|
+
id: Schema.optional(Schema.String),
|
|
156
|
+
encrypted: Schema.optional(Schema.String),
|
|
157
|
+
/** Null means the provider failed to produce a summary; prior history must be retained. */
|
|
158
|
+
text: Schema.optional(Schema.NullOr(Schema.String)),
|
|
159
|
+
})
|
|
160
|
+
.pipe(Schema.refine((part) => (part.encrypted !== undefined) !== (part.text !== undefined), { message: "Compaction requires either encrypted content or a summary" }))
|
|
161
|
+
.annotate({ identifier: "AI.Content.Compaction" });
|
|
162
|
+
export const CompactionPart = withStatics(compactionPartSchema, {
|
|
163
|
+
make: (input) => Schema.decodeUnknownSync(compactionPartSchema)({ type: "compaction", ...input }),
|
|
164
|
+
});
|
|
165
|
+
/** Reasoning effort changed here, from `previous` to `effort`; `undefined` is the model default. */
|
|
166
|
+
const effortPartSchema = Schema.Struct({
|
|
167
|
+
type: Schema.Literal("effort"),
|
|
168
|
+
effort: Schema.optional(ReasoningEffort),
|
|
169
|
+
previous: Schema.optional(ReasoningEffort),
|
|
170
|
+
}).annotate({ identifier: "AI.Content.Effort" });
|
|
171
|
+
export const EffortPart = withStatics(effortPartSchema, {
|
|
172
|
+
make: (input = {}) => ({ type: "effort", ...input }),
|
|
173
|
+
});
|
|
174
|
+
export const ContentPart = Schema.Union([
|
|
175
|
+
TextPart,
|
|
176
|
+
MediaPart,
|
|
177
|
+
ToolCallPart,
|
|
178
|
+
ToolResultPart,
|
|
179
|
+
ReasoningPart,
|
|
180
|
+
CompactionPart,
|
|
181
|
+
EffortPart,
|
|
182
|
+
]).pipe(Schema.toTaggedUnion("type"));
|
|
183
|
+
/** Tools changed here: `add` appends or redefines tools by name, `remove` drops them by name. */
|
|
184
|
+
export const ToolChanges = Schema.Struct({
|
|
185
|
+
add: Schema.Array(Schema.suspend(() => ToolEntry)),
|
|
186
|
+
remove: Schema.Array(Schema.String),
|
|
187
|
+
}).annotate({ identifier: "AI.ToolChanges" });
|
|
188
|
+
export class SystemMessage extends Schema.Class("AI.SystemMessage")({
|
|
189
|
+
id: Schema.optional(Schema.String),
|
|
190
|
+
role: Schema.Literal("system"),
|
|
191
|
+
content: Schema.Array(Schema.Union([TextPart, EffortPart]).pipe(Schema.toTaggedUnion("type"))),
|
|
192
|
+
tools: Schema.optional(ToolChanges),
|
|
193
|
+
}) {
|
|
194
|
+
}
|
|
195
|
+
export class UserMessage extends Schema.Class("AI.UserMessage")({
|
|
196
|
+
id: Schema.optional(Schema.String),
|
|
197
|
+
role: Schema.Literal("user"),
|
|
198
|
+
content: Schema.Array(Schema.Union([TextPart, MediaPart]).pipe(Schema.toTaggedUnion("type"))),
|
|
199
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
200
|
+
}) {
|
|
201
|
+
}
|
|
202
|
+
export class AssistantMessage extends Schema.Class("AI.AssistantMessage")({
|
|
203
|
+
id: Schema.optional(Schema.String),
|
|
204
|
+
role: Schema.Literal("assistant"),
|
|
205
|
+
content: Schema.Array(Schema.Union([TextPart, ReasoningPart, ToolCallPart, ToolResultPart, MediaPart, CompactionPart]).pipe(Schema.toTaggedUnion("type"))),
|
|
206
|
+
providerMetadata: Schema.optional(ProviderMetadata),
|
|
207
|
+
}) {
|
|
208
|
+
}
|
|
209
|
+
export class ToolMessage extends Schema.Class("AI.ToolMessage")({
|
|
210
|
+
id: Schema.optional(Schema.String),
|
|
211
|
+
role: Schema.Literal("tool"),
|
|
212
|
+
content: Schema.Array(ToolResultPart),
|
|
213
|
+
}) {
|
|
214
|
+
}
|
|
215
|
+
const messageSchema = Schema.Union([SystemMessage, UserMessage, AssistantMessage, ToolMessage]).pipe(Schema.toTaggedUnion("role"), Schema.annotate({ identifier: "AI.Message" }));
|
|
216
|
+
const isParts = (input) => Array.isArray(input);
|
|
217
|
+
const content = (input) => typeof input === "string" ? [TextPart.make(input)] : isParts(input) ? [...input] : [input];
|
|
218
|
+
function contentWithMedia(input) {
|
|
219
|
+
return content(input).map((part) => (part.type === "media" ? mediaPart(part) : part));
|
|
220
|
+
}
|
|
221
|
+
function make(input) {
|
|
222
|
+
switch (input.role) {
|
|
223
|
+
case "system": {
|
|
224
|
+
if (input instanceof SystemMessage)
|
|
225
|
+
return input;
|
|
226
|
+
const { tools, ...rest } = input;
|
|
227
|
+
return new SystemMessage({
|
|
228
|
+
...rest,
|
|
229
|
+
content: content(input.content),
|
|
230
|
+
...(tools === undefined ? {} : { tools: toolChanges(tools) }),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
case "user":
|
|
234
|
+
return input instanceof UserMessage
|
|
235
|
+
? input
|
|
236
|
+
: new UserMessage({ ...input, content: contentWithMedia(input.content) });
|
|
237
|
+
case "assistant":
|
|
238
|
+
return input instanceof AssistantMessage
|
|
239
|
+
? input
|
|
240
|
+
: new AssistantMessage({ ...input, content: contentWithMedia(input.content) });
|
|
241
|
+
case "tool":
|
|
242
|
+
return input instanceof ToolMessage
|
|
243
|
+
? input
|
|
244
|
+
: new ToolMessage({ ...input, content: isParts(input.content) ? [...input.content] : [input.content] });
|
|
245
|
+
}
|
|
246
|
+
// Untyped callers can still pass an unknown role; reject it the way the schema does.
|
|
247
|
+
return Schema.decodeUnknownSync(messageSchema)(input);
|
|
248
|
+
}
|
|
249
|
+
const contentOf = (message) => message.content;
|
|
250
|
+
export const Message = withStatics(messageSchema, {
|
|
251
|
+
/** Concatenated text of a message's text parts. */
|
|
252
|
+
text: (message) => contentOf(message)
|
|
253
|
+
.flatMap((part) => (part.type === "text" ? [part.text] : []))
|
|
254
|
+
.join(""),
|
|
255
|
+
/** Concatenated text of an assistant message's reasoning parts. */
|
|
256
|
+
reasoning: (message) => message.content.flatMap((part) => (part.type === "reasoning" ? [part.text] : [])).join(""),
|
|
257
|
+
/** The tool calls in an assistant message, provider-executed ones included. */
|
|
258
|
+
toolCalls: (message) => message.content.filter((part) => part.type === "tool-call"),
|
|
259
|
+
make,
|
|
260
|
+
user: (input) => make({ role: "user", content: input }),
|
|
261
|
+
assistant: (input) => make({ role: "assistant", content: input }),
|
|
262
|
+
/**
|
|
263
|
+
* Add an operator-authored instruction at this chronological point in the
|
|
264
|
+
* conversation. This is distinct from the initial `LLMRequest.system`
|
|
265
|
+
* prompt. Keep raw retrieved, tool, and web content out of privileged system
|
|
266
|
+
* updates; pass that untrusted content through ordinary user/tool channels.
|
|
267
|
+
*/
|
|
268
|
+
system: (input) => make({ role: "system", content: input }),
|
|
269
|
+
effort: (input) => make({ role: "system", content: [{ type: "effort", effort: input.effort, previous: input.previous }] }),
|
|
270
|
+
/**
|
|
271
|
+
* Change the available tools at this point. A route sends the change in place when the model's `tools.updates`
|
|
272
|
+
* allows it, and otherwise folds it into the top-level `tools`. Returns message input that keeps the tool objects,
|
|
273
|
+
* so `ai.loop` can run an executable tool added here.
|
|
274
|
+
*/
|
|
275
|
+
tools: (input) => ({ role: "system", content: [], tools: input }),
|
|
276
|
+
tool: (result) => make({ role: "tool", content: ["type" in result ? result : ToolResultPart.make(result)] }),
|
|
277
|
+
});
|
|
278
|
+
const toolChanges = (input) => ({
|
|
279
|
+
add: (input.add ?? []).map(toEntry),
|
|
280
|
+
remove: (input.remove ?? []).map((item) => (typeof item === "string" ? item : item.name)),
|
|
281
|
+
});
|
|
282
|
+
/**
|
|
283
|
+
* Raw-text wire encoding for a tool with exactly one required string parameter, or the one its `field` names among
|
|
284
|
+
* others. Models that accept the format write that parameter's value directly instead of JSON arguments, after a
|
|
285
|
+
* first line holding the others; calls still decode to the normal object input.
|
|
286
|
+
*/
|
|
287
|
+
export const Freeform = Tool.Freeform;
|
|
288
|
+
const toolDefinitionFields = {
|
|
289
|
+
name: Schema.String,
|
|
290
|
+
description: Schema.String,
|
|
291
|
+
inputSchema: JsonSchema,
|
|
292
|
+
outputSchema: Schema.optional(JsonSchema),
|
|
293
|
+
freeform: Schema.optional(Freeform),
|
|
294
|
+
cache: Schema.optional(CacheHint),
|
|
295
|
+
native: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
296
|
+
};
|
|
297
|
+
export class ToolDefinition extends Schema.Class("AI.ToolDefinition")({
|
|
298
|
+
type: Schema.Literal("tool"),
|
|
299
|
+
...toolDefinitionFields,
|
|
300
|
+
}) {
|
|
301
|
+
constructor(input) {
|
|
302
|
+
super({ ...input, type: "tool" });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
(function (ToolDefinition) {
|
|
306
|
+
/** Normalize tool definition input into the canonical `ToolDefinition` class. */
|
|
307
|
+
ToolDefinition.make = (input) => (input instanceof ToolDefinition ? input : new ToolDefinition(input));
|
|
308
|
+
/**
|
|
309
|
+
* The parameter a freeform call fills, when it is a required string: the one the format's `field` names, otherwise
|
|
310
|
+
* the input schema's only property.
|
|
311
|
+
*/
|
|
312
|
+
ToolDefinition.freeformField = (schema, freeform) => {
|
|
313
|
+
const properties = Object.entries(Schema.is(JsonSchema)(schema.properties) ? schema.properties : {});
|
|
314
|
+
if (freeform?.field === undefined && properties.length !== 1)
|
|
315
|
+
return undefined;
|
|
316
|
+
const [name, property] = properties.find(([name]) => (freeform?.field ?? name) === name) ?? [];
|
|
317
|
+
if (name === undefined || !Schema.is(JsonSchema)(property) || property.type !== "string")
|
|
318
|
+
return undefined;
|
|
319
|
+
return Array.isArray(schema.required) && schema.required.includes(name) ? name : undefined;
|
|
320
|
+
};
|
|
321
|
+
})(ToolDefinition || (ToolDefinition = {}));
|
|
322
|
+
export const ToolNamespace = withStatics(Schema.Struct({
|
|
323
|
+
type: Schema.Literal("namespace"),
|
|
324
|
+
name: Schema.String,
|
|
325
|
+
description: Schema.optional(Schema.UndefinedOr(Schema.String)),
|
|
326
|
+
tools: Schema.Array(Schema.suspend(() => ToolEntry)),
|
|
327
|
+
}).annotate({ identifier: "AI.ToolNamespace" }), {
|
|
328
|
+
make: (input) => ({
|
|
329
|
+
...input,
|
|
330
|
+
type: "namespace",
|
|
331
|
+
tools: input.tools.map(ToolEntry.make),
|
|
332
|
+
}),
|
|
333
|
+
});
|
|
334
|
+
export const ToolEntry = withStatics(Schema.Union([ToolDefinition, ToolNamespace]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "AI.ToolEntry" })), {
|
|
335
|
+
make: (input) => "type" in input && input.type === "namespace" ? ToolNamespace.make(input) : ToolDefinition.make(input),
|
|
336
|
+
});
|
|
337
|
+
const disableParallelToolUse = Schema.optional(Schema.Boolean);
|
|
338
|
+
const toolChoiceSchema = Schema.Union([
|
|
339
|
+
Schema.Struct({ type: Schema.Literal("auto"), disableParallelToolUse }),
|
|
340
|
+
Schema.Struct({ type: Schema.Literal("none"), disableParallelToolUse }),
|
|
341
|
+
Schema.Struct({ type: Schema.Literal("required"), disableParallelToolUse }),
|
|
342
|
+
Schema.Struct({ type: Schema.Literal("tool"), name: Schema.String, disableParallelToolUse }),
|
|
343
|
+
]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "AI.ToolChoice" }));
|
|
344
|
+
export const ToolChoice = toolChoiceSchema;
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { ModelID, ProviderID } from "./ids.js";
|
|
3
|
+
import type { AnyRoute, CompactionOperations } from "../route/client.js";
|
|
4
|
+
export declare const JsonSchema: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
5
|
+
export type JsonSchema = Schema.Schema.Type<typeof JsonSchema>;
|
|
6
|
+
export declare const mergeJsonRecords: (...items: ReadonlyArray<Record<string, unknown> | undefined>) => Record<string, unknown> | undefined;
|
|
7
|
+
export declare const ProviderOptions: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
8
|
+
export type ProviderOptions = Schema.Schema.Type<typeof ProviderOptions>;
|
|
9
|
+
export declare const ProviderMetadata: Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
10
|
+
export type ProviderMetadata = Schema.Schema.Type<typeof ProviderMetadata>;
|
|
11
|
+
export declare const mergeProviderOptions: (...items: ReadonlyArray<ProviderOptions | undefined>) => ProviderOptions | undefined;
|
|
12
|
+
/** Milliseconds for an HTTP timeout, or `false` to disable it. */
|
|
13
|
+
export declare const HttpTimeout: Schema.Union<readonly [Schema.Number, Schema.Literal<false>]>;
|
|
14
|
+
export type HttpTimeout = Schema.Schema.Type<typeof HttpTimeout>;
|
|
15
|
+
/** Applied to `timeout.headers` when a request leaves it unset. */
|
|
16
|
+
export declare const DEFAULT_HTTP_TIMEOUT_MS = 300000;
|
|
17
|
+
/**
|
|
18
|
+
* Applied to `timeout.chunk` when a request leaves it unset. Some providers, such as DeepSeek, have specifically asked
|
|
19
|
+
* clients to allow at least 15 minutes, because their models can stream nothing for minutes while they reason.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_CHUNK_TIMEOUT_MS = 900000;
|
|
22
|
+
/** `Content-Encoding` for JSON request bodies; `none` sends plain JSON. */
|
|
23
|
+
export declare const RequestEncoding: Schema.Literals<readonly ["zstd", "gzip", "none"]>;
|
|
24
|
+
export type RequestEncoding = Schema.Schema.Type<typeof RequestEncoding>;
|
|
25
|
+
/** PEM client certificate and private key, with the passphrase of an encrypted key. */
|
|
26
|
+
export interface ClientTls {
|
|
27
|
+
readonly cert: string;
|
|
28
|
+
readonly key: string;
|
|
29
|
+
readonly passphrase?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Per-phase time limits in milliseconds. */
|
|
32
|
+
export interface TimeoutConfig {
|
|
33
|
+
/** The whole request, from send until the response completes. Unbounded when unset. */
|
|
34
|
+
readonly total?: HttpTimeout;
|
|
35
|
+
/** Until response headers arrive. */
|
|
36
|
+
readonly headers?: HttpTimeout;
|
|
37
|
+
/** Between streamed response chunks once headers have arrived. */
|
|
38
|
+
readonly chunk?: HttpTimeout;
|
|
39
|
+
}
|
|
40
|
+
/** Milliseconds for the whole request, `false` to disable it, or per-phase limits. */
|
|
41
|
+
export type RequestTimeout = HttpTimeout | TimeoutConfig;
|
|
42
|
+
/** HTTP settings shared by requests, models and routes. */
|
|
43
|
+
export interface HttpOptions {
|
|
44
|
+
/** Merged over the provider's headers; these win. */
|
|
45
|
+
readonly headers?: Record<string, string>;
|
|
46
|
+
/** Applied to every HTTP request. */
|
|
47
|
+
readonly timeout?: RequestTimeout;
|
|
48
|
+
readonly query?: Record<string, string>;
|
|
49
|
+
/** Deep-merged over the provider-native JSON body. */
|
|
50
|
+
readonly body?: Record<string, unknown>;
|
|
51
|
+
/** Compression for JSON request bodies. Only set it for endpoints known to decode it. */
|
|
52
|
+
readonly encoding?: RequestEncoding;
|
|
53
|
+
/** Client certificate presented to HTTPS endpoints that request one (mutual TLS). */
|
|
54
|
+
readonly tls?: ClientTls;
|
|
55
|
+
}
|
|
56
|
+
/** HTTP settings for one request. */
|
|
57
|
+
export interface RequestHttpOptions extends HttpOptions {
|
|
58
|
+
/** Sends this call through `fetch` instead of the client's HTTP executor. */
|
|
59
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
60
|
+
}
|
|
61
|
+
/** Transport settings shared by requests, models and routes. */
|
|
62
|
+
export interface TransportOptions {
|
|
63
|
+
readonly http?: HttpOptions;
|
|
64
|
+
}
|
|
65
|
+
/** The fields every request shares, whatever its modality. */
|
|
66
|
+
export interface BaseRequest<Model, Options = ProviderOptions> {
|
|
67
|
+
readonly model: Model;
|
|
68
|
+
readonly providerOptions?: Options;
|
|
69
|
+
readonly http?: RequestHttpOptions;
|
|
70
|
+
}
|
|
71
|
+
export declare const timeoutConfig: (timeout: RequestTimeout | undefined) => TimeoutConfig;
|
|
72
|
+
/** Merge transport settings; later items win, headers, query and body merge by key. */
|
|
73
|
+
export declare const mergeTransport: (...items: ReadonlyArray<TransportOptions | undefined>) => TransportOptions;
|
|
74
|
+
/** Portable sampling knobs, set at the top level of text requests, model defaults and route defaults. */
|
|
75
|
+
export declare const GenerationOptions: Schema.Struct<{
|
|
76
|
+
readonly maxTokens: Schema.optionalKey<Schema.Number>;
|
|
77
|
+
readonly temperature: Schema.optionalKey<Schema.Number>;
|
|
78
|
+
readonly topP: Schema.optionalKey<Schema.Number>;
|
|
79
|
+
readonly topK: Schema.optionalKey<Schema.Number>;
|
|
80
|
+
readonly frequencyPenalty: Schema.optionalKey<Schema.Number>;
|
|
81
|
+
readonly presencePenalty: Schema.optionalKey<Schema.Number>;
|
|
82
|
+
readonly seed: Schema.optionalKey<Schema.Number>;
|
|
83
|
+
readonly stop: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
84
|
+
}>;
|
|
85
|
+
export interface GenerationOptionsFields extends Schema.Schema.Type<typeof GenerationOptions> {
|
|
86
|
+
}
|
|
87
|
+
/** Pick the generation knobs out of each item; later items win per knob. */
|
|
88
|
+
export declare const mergeGeneration: (...items: ReadonlyArray<GenerationOptionsFields | undefined>) => GenerationOptionsFields;
|
|
89
|
+
/** Request options a model applies under each request: the same keys as a request, and the request wins. */
|
|
90
|
+
export interface RequestOptions extends TransportOptions, GenerationOptionsFields {
|
|
91
|
+
readonly providerOptions?: ProviderOptions;
|
|
92
|
+
}
|
|
93
|
+
/** Merge model options; later items win per key. Empty results are `undefined`. */
|
|
94
|
+
export declare const mergeRequestOptions: (...items: ReadonlyArray<RequestOptions | undefined>) => RequestOptions | undefined;
|
|
95
|
+
/** Provider-defined string enum: known values for autocomplete, any string accepted. */
|
|
96
|
+
export type OpenString<Known extends string> = Known | (string & {});
|
|
97
|
+
export declare const ReasoningEfforts: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
98
|
+
export type ReasoningEffort = OpenString<(typeof ReasoningEfforts)[number]>;
|
|
99
|
+
export declare const ReasoningEffort: Schema.declare<ReasoningEffort, ReasoningEffort>;
|
|
100
|
+
/** Tool schema sanitizer for a model family. `none` opts out of the protocol and model-name defaults. */
|
|
101
|
+
export declare const LanguageModelSanitizerCompatibility: Schema.Literals<readonly ["gemini", "moonshot", "none"]>;
|
|
102
|
+
export type LanguageModelSanitizerCompatibility = Schema.Schema.Type<typeof LanguageModelSanitizerCompatibility>;
|
|
103
|
+
export declare const LanguageModelMaxTokensFieldCompatibility: Schema.Literals<readonly ["max_completion_tokens", "max_tokens"]>;
|
|
104
|
+
export type LanguageModelMaxTokensFieldCompatibility = Schema.Schema.Type<typeof LanguageModelMaxTokensFieldCompatibility>;
|
|
105
|
+
export declare const LanguageModelCacheFormatCompatibility: Schema.Literals<readonly ["anthropic", "alibaba"]>;
|
|
106
|
+
export type LanguageModelCacheFormatCompatibility = Schema.Schema.Type<typeof LanguageModelCacheFormatCompatibility>;
|
|
107
|
+
declare const LanguageModelCompatibility_base: Schema.Class<LanguageModelCompatibility, Schema.Struct<{
|
|
108
|
+
readonly sanitizer: Schema.optional<Schema.Literals<readonly ["gemini", "moonshot", "none"]>>;
|
|
109
|
+
readonly reasoningField: Schema.optional<Schema.String>;
|
|
110
|
+
/** Require every assistant message to include its reasoning field, even when empty. */
|
|
111
|
+
readonly requireReasoning: Schema.optional<Schema.Boolean>;
|
|
112
|
+
readonly maxTokensField: Schema.optional<Schema.Literals<readonly ["max_completion_tokens", "max_tokens"]>>;
|
|
113
|
+
readonly requireFinishReason: Schema.optional<Schema.Boolean>;
|
|
114
|
+
readonly requireAssistantAfterTool: Schema.optional<Schema.Boolean>;
|
|
115
|
+
/** Prompt-cache marker syntax the endpoint accepts. Overrides the route default; both send `cache_control`, and `alibaba` skips tool definitions. */
|
|
116
|
+
readonly cacheFormat: Schema.optional<Schema.Literals<readonly ["anthropic", "alibaba"]>>;
|
|
117
|
+
readonly zaiToolStream: Schema.optional<Schema.Boolean>;
|
|
118
|
+
readonly requireSignature: Schema.optional<Schema.Boolean>;
|
|
119
|
+
/** Supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
|
|
120
|
+
readonly supportsThinkingBlockBinding: Schema.optional<Schema.Boolean>;
|
|
121
|
+
}>, {}>;
|
|
122
|
+
export declare class LanguageModelCompatibility extends LanguageModelCompatibility_base {
|
|
123
|
+
}
|
|
124
|
+
export declare namespace LanguageModelCompatibility {
|
|
125
|
+
type Input = LanguageModelCompatibility | ConstructorParameters<typeof LanguageModelCompatibility>[0];
|
|
126
|
+
/** Normalize model/upstream compatibility metadata without projecting requests. */
|
|
127
|
+
const make: (input: Input) => LanguageModelCompatibility;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* What the model accepts on its API: models.dev v2 `capabilities` in camelCase, with the API's own overrides merged in.
|
|
131
|
+
* Unset fields keep the protocol default, which may still guess from the provider, base URL or model ID.
|
|
132
|
+
*/
|
|
133
|
+
export interface Capabilities {
|
|
134
|
+
readonly tools?: {
|
|
135
|
+
readonly supported?: boolean;
|
|
136
|
+
/** Accepts `strict` on function tools. OpenAI Chat detects it from the provider when unset. */
|
|
137
|
+
readonly strict?: boolean;
|
|
138
|
+
readonly choice?: ReadonlyArray<"auto" | "none" | "required" | "tool">;
|
|
139
|
+
readonly search?: boolean;
|
|
140
|
+
/** Input formats accepted by custom (free-form) tools. Unset or empty: freeform tools go out as JSON tools. */
|
|
141
|
+
readonly freeform?: ReadonlyArray<"text" | "lark" | "regex">;
|
|
142
|
+
/**
|
|
143
|
+
* Tool changes the model takes mid-conversation without changing the leading tool declaration, so the prompt
|
|
144
|
+
* cache holds. `add`: declares a tool not declared before. `remove`: withdraws a declared tool. `replace`:
|
|
145
|
+
* declares a tool under a name declared before (a redefinition, or re-adding a removed tool). Unset or empty:
|
|
146
|
+
* every change folds into the top-level tools. Anthropic Messages sends all three as native blocks. OpenAI
|
|
147
|
+
* Responses needs `add` for any of them: it declares every tool in `additional_tools` items with a short
|
|
148
|
+
* incremental-update hint before each later item, and announces a removal as developer text while the tool
|
|
149
|
+
* stays declared, so list `remove` only for models that follow that announcement.
|
|
150
|
+
*/
|
|
151
|
+
readonly updates?: ReadonlyArray<"add" | "remove" | "replace">;
|
|
152
|
+
};
|
|
153
|
+
readonly reasoning?: {
|
|
154
|
+
readonly supported?: boolean;
|
|
155
|
+
readonly default?: {
|
|
156
|
+
readonly type: "toggle";
|
|
157
|
+
readonly value: boolean;
|
|
158
|
+
} | {
|
|
159
|
+
readonly type: "effort";
|
|
160
|
+
readonly value: ReasoningEffort;
|
|
161
|
+
} | {
|
|
162
|
+
readonly type: "budget";
|
|
163
|
+
readonly value: number;
|
|
164
|
+
};
|
|
165
|
+
readonly toggle?: boolean;
|
|
166
|
+
readonly effort?: ReadonlyArray<ReasoningEffort>;
|
|
167
|
+
readonly budget?: {
|
|
168
|
+
readonly min?: number;
|
|
169
|
+
readonly max?: number;
|
|
170
|
+
};
|
|
171
|
+
/** Accepts per-message effort updates. Detected from the model ID when unset. */
|
|
172
|
+
readonly updates?: boolean;
|
|
173
|
+
};
|
|
174
|
+
readonly cache?: false | {
|
|
175
|
+
readonly implicit?: true | {
|
|
176
|
+
readonly ttl?: ReadonlyArray<CacheTTL>;
|
|
177
|
+
readonly minTokens?: number;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Accepts the request's `affinity` in the body, such as `prompt_cache_key`. OpenAI Chat omits it unless
|
|
181
|
+
* this is true; other protocols omit it only when this is false. Session-affinity headers still flow regardless.
|
|
182
|
+
*/
|
|
183
|
+
readonly affinity?: boolean;
|
|
184
|
+
readonly explicit?: true | {
|
|
185
|
+
readonly ttl?: ReadonlyArray<CacheTTL>;
|
|
186
|
+
readonly maxBreakpoints?: number;
|
|
187
|
+
readonly targets?: ReadonlyArray<"tools" | "system" | "messages">;
|
|
188
|
+
readonly minTokens?: number;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
readonly structuredOutput?: boolean;
|
|
192
|
+
readonly temperature?: boolean;
|
|
193
|
+
readonly topP?: boolean;
|
|
194
|
+
readonly topK?: boolean;
|
|
195
|
+
/** Accepts mid-conversation system messages. Anthropic Messages detects it from the model ID when unset. */
|
|
196
|
+
readonly systemUpdates?: boolean;
|
|
197
|
+
/** Accepts `store`. OpenAI Chat detects it from the provider when unset. */
|
|
198
|
+
readonly store?: boolean;
|
|
199
|
+
/** Accepts `stream_options.include_usage`. OpenAI Chat defaults to true. */
|
|
200
|
+
readonly streamUsage?: boolean;
|
|
201
|
+
readonly serviceTier?: ReadonlyArray<OpenString<"flex" | "priority" | "fast" | "ultrafast" | "standby">>;
|
|
202
|
+
}
|
|
203
|
+
export declare class LanguageModel<Options extends ProviderOptions = ProviderOptions, Compact extends CompactionOperations | undefined = CompactionOperations | undefined> {
|
|
204
|
+
protected readonly _ProviderOptions: Options;
|
|
205
|
+
readonly id: ModelID;
|
|
206
|
+
readonly provider: ProviderID;
|
|
207
|
+
readonly route: AnyRoute<Compact>;
|
|
208
|
+
readonly options?: RequestOptions;
|
|
209
|
+
readonly capabilities?: Capabilities;
|
|
210
|
+
readonly compatibility?: LanguageModelCompatibility;
|
|
211
|
+
constructor(input: LanguageModel.ConstructorInput<Compact>);
|
|
212
|
+
static make<Options extends ProviderOptions = ProviderOptions, Compact extends CompactionOperations | undefined = CompactionOperations | undefined>(input: LanguageModel.Input<Compact>): LanguageModel<Options, Compact>;
|
|
213
|
+
static input<Options extends ProviderOptions, Compact extends CompactionOperations | undefined>(model: LanguageModel<Options, Compact>): LanguageModel.ConstructorInput<Compact>;
|
|
214
|
+
static update<Options extends ProviderOptions, Compact extends CompactionOperations | undefined>(model: LanguageModel<Options>, patch: Partial<LanguageModel.Input<Compact>> & {
|
|
215
|
+
readonly route: AnyRoute<Compact>;
|
|
216
|
+
}): LanguageModel<Options, Compact>;
|
|
217
|
+
static update<Options extends ProviderOptions, Compact extends CompactionOperations | undefined>(model: LanguageModel<Options, Compact>, patch: Partial<Omit<LanguageModel.Input, "route">> & {
|
|
218
|
+
readonly route?: undefined;
|
|
219
|
+
}): LanguageModel<Options, Compact>;
|
|
220
|
+
static update<Options extends ProviderOptions>(model: LanguageModel<Options>, patch: Partial<LanguageModel.Input>): LanguageModel<Options>;
|
|
221
|
+
}
|
|
222
|
+
export declare namespace LanguageModel {
|
|
223
|
+
type ConstructorInput<Compact extends CompactionOperations | undefined = CompactionOperations | undefined> = {
|
|
224
|
+
readonly id: ModelID;
|
|
225
|
+
readonly provider: ProviderID;
|
|
226
|
+
readonly route: AnyRoute<Compact>;
|
|
227
|
+
readonly options?: RequestOptions;
|
|
228
|
+
readonly capabilities?: Capabilities;
|
|
229
|
+
readonly compatibility?: LanguageModelCompatibility;
|
|
230
|
+
};
|
|
231
|
+
type Input<Compact extends CompactionOperations | undefined = CompactionOperations | undefined> = Omit<ConstructorInput<Compact>, "id" | "provider" | "compatibility"> & {
|
|
232
|
+
readonly id: string | ModelID;
|
|
233
|
+
readonly provider: string | ProviderID;
|
|
234
|
+
readonly compatibility?: LanguageModelCompatibility.Input;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
export type LanguageModelInput = LanguageModel.Input;
|
|
238
|
+
export type LanguageModelProviderOptions<SelectedModel> = SelectedModel extends LanguageModel<infer Options> ? Options : never;
|
|
239
|
+
export declare const LanguageModelSchema: Schema.declare<LanguageModel<{
|
|
240
|
+
readonly [x: string]: unknown;
|
|
241
|
+
}, CompactionOperations | undefined>, LanguageModel<{
|
|
242
|
+
readonly [x: string]: unknown;
|
|
243
|
+
}, CompactionOperations | undefined>>;
|
|
244
|
+
export declare const CacheTTL: Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>;
|
|
245
|
+
export type CacheTTL = typeof CacheTTL.Type;
|
|
246
|
+
declare const CacheHint_base: Schema.Class<CacheHint, Schema.Struct<{
|
|
247
|
+
readonly type: Schema.Literals<readonly ["ephemeral", "persistent"]>;
|
|
248
|
+
readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
|
|
249
|
+
}>, {}>;
|
|
250
|
+
export declare class CacheHint extends CacheHint_base {
|
|
251
|
+
}
|
|
252
|
+
export declare const CachePolicyObject: Schema.Struct<{
|
|
253
|
+
readonly tools: Schema.optional<Schema.Boolean>;
|
|
254
|
+
readonly system: Schema.optional<Schema.Boolean>;
|
|
255
|
+
readonly messages: Schema.optional<Schema.Union<readonly [Schema.Literal<"latest-user-message">, Schema.Literal<"latest-assistant">, Schema.Struct<{
|
|
256
|
+
readonly tail: Schema.Natural;
|
|
257
|
+
}>]>>;
|
|
258
|
+
readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
|
|
259
|
+
}>;
|
|
260
|
+
export type CachePolicyObject = Schema.Schema.Type<typeof CachePolicyObject>;
|
|
261
|
+
export declare const CachePolicy: Schema.Union<readonly [Schema.Literal<"auto">, Schema.Literal<"none">, Schema.Struct<{
|
|
262
|
+
readonly tools: Schema.optional<Schema.Boolean>;
|
|
263
|
+
readonly system: Schema.optional<Schema.Boolean>;
|
|
264
|
+
readonly messages: Schema.optional<Schema.Union<readonly [Schema.Literal<"latest-user-message">, Schema.Literal<"latest-assistant">, Schema.Struct<{
|
|
265
|
+
readonly tail: Schema.Natural;
|
|
266
|
+
}>]>>;
|
|
267
|
+
readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
|
|
268
|
+
}>]>;
|
|
269
|
+
export type CachePolicy = Schema.Schema.Type<typeof CachePolicy>;
|
|
270
|
+
export {};
|