@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,251 @@
|
|
|
1
|
+
import { Duration, Effect, Schedule, Schema, Stream } from "effect";
|
|
2
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
|
+
import { Auth } from "./auth.js";
|
|
4
|
+
import { Endpoint } from "./endpoint.js";
|
|
5
|
+
import { RequestExecutor } from "./executor.js";
|
|
6
|
+
import { MediaProtocol } from "./media-protocol.js";
|
|
7
|
+
import { Generation } from "../generation.js";
|
|
8
|
+
import { isRetryable } from "../provider-error.js";
|
|
9
|
+
import { AIError, AIErrorReason, InvalidRequestError, ProviderID, UnsupportedOperationError, mergeProviderOptions, mergeTransport, } from "../schema/index.js";
|
|
10
|
+
import { encodeJson } from "../utils/json.js";
|
|
11
|
+
import { sanitizeSurrogates } from "../utils/sanitize.js";
|
|
12
|
+
/** A provider facade's `configure(...)` input as the `ModelInput` every media selector shares, minus the model id. */
|
|
13
|
+
export const deployment = (input, auth) => ({ auth, baseURL: input.baseURL, transport: mergeTransport(input) });
|
|
14
|
+
/**
|
|
15
|
+
* Compose an inline media protocol with an endpoint and auth into a runnable route. The route owns the transport
|
|
16
|
+
* plumbing every media protocol would otherwise duplicate: option merging, surrogate sanitizing, unsupported-field
|
|
17
|
+
* rejection, URL and query rendering, auth headers, JSON, multipart, or binary encoding, and handing responses back
|
|
18
|
+
* to the protocol.
|
|
19
|
+
*/
|
|
20
|
+
export const inline = (input) => {
|
|
21
|
+
const transport = makeTransport(input);
|
|
22
|
+
return {
|
|
23
|
+
kind: "inline",
|
|
24
|
+
id: input.protocol.id,
|
|
25
|
+
provider: input.protocol.provider,
|
|
26
|
+
protocol: input.protocol.id,
|
|
27
|
+
generate: Effect.fn(`MediaRoute.generate`)(function* (request, execute) {
|
|
28
|
+
const submitted = yield* transport.submit(request, { unsupported: input.protocol.unsupported, from: input.protocol.body.from }, execute);
|
|
29
|
+
return yield* input.protocol.response.decode(submitted.response, submitted.context);
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const READ_RETRY_MAX_DELAY = Duration.seconds(30);
|
|
34
|
+
/**
|
|
35
|
+
* Status and result reads retry transient failures; `start` and `cancel` never do. Gaps grow exponentially from 1s,
|
|
36
|
+
* jittered, up to 30s each, for at most 8 retries (about two minutes when every attempt fails), so a direct
|
|
37
|
+
* `Generation.result()` stays bounded; `await` and `events` also cut retries off at `poll.timeout`. A provider
|
|
38
|
+
* `retryAfterMs` raises the gap, still capped at 30s.
|
|
39
|
+
*/
|
|
40
|
+
const READ_RETRY = Schedule.max([
|
|
41
|
+
Schedule.min([Schedule.exponential("1 second"), Schedule.spaced(READ_RETRY_MAX_DELAY)]),
|
|
42
|
+
Schedule.recurs(8),
|
|
43
|
+
]).pipe(Schedule.jittered, Schedule.setInputType(), Schedule.modifyDelay(({ input, duration }) => Effect.succeed(Duration.min(input.reason._tag === "RateLimit" || input.reason._tag === "ProviderInternal"
|
|
44
|
+
? Duration.max(duration, Duration.millis(input.reason.retryAfterMs ?? 0))
|
|
45
|
+
: duration, READ_RETRY_MAX_DELAY))));
|
|
46
|
+
/**
|
|
47
|
+
* Compose a queued media protocol the same way, adding `start`/`resume` handles whose polls reuse the route's auth,
|
|
48
|
+
* deployment headers, and (for `start`) the request's `http` overlay. The token is decoded once at the boundary and
|
|
49
|
+
* closed over by the resulting `Generation.Route`.
|
|
50
|
+
*/
|
|
51
|
+
export const queued = (input) => {
|
|
52
|
+
const transport = makeTransport(input);
|
|
53
|
+
const protocol = input.protocol;
|
|
54
|
+
const decodeToken = Schema.decodeUnknownEffect(protocol.token);
|
|
55
|
+
// A protocol producing a token its own codec rejects is a programmer defect, not a provider error.
|
|
56
|
+
const encodeToken = Schema.encodeSync(protocol.token);
|
|
57
|
+
const generationRoute = (token, exchange, execute) => {
|
|
58
|
+
// Only the GET exchange retries: a decoded terminal failure (`output.ended`) can be a `ProviderInternal` too, and
|
|
59
|
+
// re-reading it would spin until the caller's deadline.
|
|
60
|
+
const get = (path) => transport.call("GET", path, exchange, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.map((sent) => sent.response));
|
|
61
|
+
const poll = (operation) => get(operation.path(token)).pipe(Effect.flatMap((response) => operation.decode(response, {
|
|
62
|
+
token,
|
|
63
|
+
get,
|
|
64
|
+
credentials: (url) => Effect.gen(function* () {
|
|
65
|
+
const headers = yield* transport.headers(url, exchange);
|
|
66
|
+
if (headers === undefined)
|
|
67
|
+
return {};
|
|
68
|
+
return { headers, middleware: yield* RequestExecutor.CurrentMiddleware };
|
|
69
|
+
}),
|
|
70
|
+
})));
|
|
71
|
+
const status = poll(protocol.status);
|
|
72
|
+
const cancel = protocol.cancel;
|
|
73
|
+
return {
|
|
74
|
+
status,
|
|
75
|
+
result: poll(protocol.result),
|
|
76
|
+
cancel: cancel === undefined
|
|
77
|
+
? undefined
|
|
78
|
+
: transport.call(cancel.method, cancel.path(token), exchange, execute).pipe(Effect.asVoid),
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
const start = Effect.fn("MediaRoute.start")(function* (request, execute) {
|
|
82
|
+
const submitted = yield* transport.submit(request, { unsupported: protocol.unsupported, prepare: protocol.start.prepare, from: protocol.start.body.from }, execute);
|
|
83
|
+
const started = yield* protocol.start.decode(submitted.response, submitted.context);
|
|
84
|
+
const route = generationRoute(started.token, submitted.exchange, execute);
|
|
85
|
+
return new Generation(route, encodeToken(started.token), started.snapshot);
|
|
86
|
+
});
|
|
87
|
+
const decode = (raw) => decodeToken(raw).pipe(Effect.mapError((cause) => new AIError({
|
|
88
|
+
reason: new InvalidRequestError({
|
|
89
|
+
message: `${protocol.id} cannot resume a generation from this token`,
|
|
90
|
+
cause,
|
|
91
|
+
}),
|
|
92
|
+
})));
|
|
93
|
+
const attach = (model, raw, execute) => decode(raw).pipe(Effect.map((token) => generationRoute(token, transport.exchange(model), execute)));
|
|
94
|
+
const resume = Effect.fn("MediaRoute.resume")(function* (model, raw, execute) {
|
|
95
|
+
const token = yield* decode(raw);
|
|
96
|
+
const route = generationRoute(token, transport.exchange(model), execute);
|
|
97
|
+
return new Generation(route, encodeToken(token), yield* route.status);
|
|
98
|
+
});
|
|
99
|
+
return { kind: "queued", id: protocol.id, provider: protocol.provider, protocol: protocol.id, start, resume, attach };
|
|
100
|
+
};
|
|
101
|
+
/** Compose a streaming media protocol; `generate` runs the same stream in `generate` mode and folds it with `collect`. */
|
|
102
|
+
export const stream = (input) => {
|
|
103
|
+
const transport = makeTransport(input);
|
|
104
|
+
const protocol = input.protocol;
|
|
105
|
+
const events = (request, execute, mode) => Stream.unwrap(Effect.gen(function* () {
|
|
106
|
+
const submitted = yield* transport.submit({ ...request, mode }, { unsupported: protocol.unsupported, from: protocol.body.from }, execute);
|
|
107
|
+
const http = RequestExecutor.responseHttp(submitted.response);
|
|
108
|
+
return Stream.suspend(() => {
|
|
109
|
+
// Parser state is local to one response, exactly like `Route.make`'s LLM stream loop.
|
|
110
|
+
let state = protocol.initial();
|
|
111
|
+
return protocol.frames(RequestExecutor.responseStream(submitted.response), submitted.context).pipe(Stream.mapEffect((frame) => protocol.step(state, frame).pipe(Effect.map(([next, output]) => {
|
|
112
|
+
state = next;
|
|
113
|
+
return output;
|
|
114
|
+
}))), Stream.flattenIterable, Stream.concat(Stream.suspend(() => Stream.fromIterableEffect(protocol.finish(state, { ...submitted.context, http })))), Stream.mapError((error) => error.reason.http !== undefined
|
|
115
|
+
? error
|
|
116
|
+
: new AIError({
|
|
117
|
+
reason: AIErrorReason.make({
|
|
118
|
+
...error.reason,
|
|
119
|
+
message: error.reason.message,
|
|
120
|
+
cause: error.reason.cause,
|
|
121
|
+
http,
|
|
122
|
+
}),
|
|
123
|
+
})));
|
|
124
|
+
});
|
|
125
|
+
}));
|
|
126
|
+
return {
|
|
127
|
+
kind: "stream",
|
|
128
|
+
id: protocol.id,
|
|
129
|
+
provider: protocol.provider,
|
|
130
|
+
protocol: protocol.id,
|
|
131
|
+
stream: (request, execute) => events(request, execute, "stream"),
|
|
132
|
+
generate: (request, execute) => events(request, execute, "generate").pipe(Stream.runCollect, Effect.flatMap(input.collect)),
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
// Transport plumbing shared by every kind
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
const makeTransport = (input) => {
|
|
139
|
+
const authorize = Auth.toEffect(input.auth);
|
|
140
|
+
const baseURL = (path) => new URL(`${Endpoint.trimBaseUrl(input.endpoint.baseURL ?? "")}${path}`);
|
|
141
|
+
const send = Effect.fn("MediaRoute.send")(function* (call, fetch, execute) {
|
|
142
|
+
const encoded = encode(call.body, call.headers);
|
|
143
|
+
const url = call.url.toString();
|
|
144
|
+
const headers = yield* authorize({
|
|
145
|
+
request: call.request,
|
|
146
|
+
method: call.method,
|
|
147
|
+
url,
|
|
148
|
+
body: encoded.text,
|
|
149
|
+
headers: encoded.headers,
|
|
150
|
+
});
|
|
151
|
+
const response = yield* RequestExecutor.withTimeout(RequestExecutor.withTls(execute, call.request.http?.tls), call.timeout)(encoded.apply(HttpClientRequest.make(call.method)(url).pipe(HttpClientRequest.setHeaders(headers))), RequestExecutor.withFetch(fetch));
|
|
152
|
+
return { response };
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
/** Route and model overlays; `start` additionally merges the request's own. */
|
|
156
|
+
exchange: (model) => mergeTransport({ http: { headers: input.headers } }, model.transport),
|
|
157
|
+
/** POST the protocol body to the route endpoint. */
|
|
158
|
+
submit: Effect.fn("MediaRoute.submit")(function* (request, protocol, execute) {
|
|
159
|
+
yield* rejectUnsupported(input.protocol.id, input.protocol.provider, request, protocol.unsupported);
|
|
160
|
+
const http = mergeTransport({ http: { headers: input.headers } }, request.model.transport, request).http;
|
|
161
|
+
const timeout = http?.timeout;
|
|
162
|
+
const exchange = { http: { ...http, fetch: request.http?.fetch } };
|
|
163
|
+
const providerOptions = mergeProviderOptions(request.model.providerOptions, request.providerOptions);
|
|
164
|
+
const headers = Headers.fromInput(http?.headers);
|
|
165
|
+
const prepared = protocol.prepare === undefined
|
|
166
|
+
? request
|
|
167
|
+
: yield* protocol.prepare(request, (path, body) => send({ method: "POST", url: baseURL(path), headers, request: { ...request, http }, body, timeout }, request.http?.fetch, execute).pipe(Effect.map((sent) => sent.response)));
|
|
168
|
+
// Sanitize after merging so model-level overlays are covered; the model value is restored, not sanitized.
|
|
169
|
+
const resolved = {
|
|
170
|
+
...sanitizeSurrogates({ ...prepared, http, providerOptions }),
|
|
171
|
+
model: request.model,
|
|
172
|
+
};
|
|
173
|
+
const body = yield* protocol.from(resolved);
|
|
174
|
+
const url = withQuery(withQuery(Endpoint.render(input.endpoint, { request: resolved, body }), body.type === "multipart" ? undefined : body.query), http?.query);
|
|
175
|
+
const sent = yield* send({ method: "POST", url, headers, request: resolved, body, timeout }, request.http?.fetch, execute);
|
|
176
|
+
return { response: sent.response, context: { request: resolved, body }, exchange };
|
|
177
|
+
}),
|
|
178
|
+
/**
|
|
179
|
+
* The headers a follow-up GET of `url` sends, for result URLs that only download with the same credentials. A URL
|
|
180
|
+
* on another origin than the route's base URL gets undefined, so credentials never leave the provider's host.
|
|
181
|
+
*/
|
|
182
|
+
headers: (url, exchange) => URL.canParse(url) && new URL(url).origin === baseURL("").origin
|
|
183
|
+
? authorize({
|
|
184
|
+
request: { http: exchange.http },
|
|
185
|
+
method: "GET",
|
|
186
|
+
url,
|
|
187
|
+
body: "",
|
|
188
|
+
headers: Headers.fromInput(exchange.http?.headers),
|
|
189
|
+
}).pipe(Effect.map((headers) => ({ ...headers })))
|
|
190
|
+
: Effect.succeed(undefined),
|
|
191
|
+
/** Bodiless follow-up call (status, result, cancel) with the same auth and headers as `submit`. */
|
|
192
|
+
call: (method, path, exchange, execute) => {
|
|
193
|
+
// Provider-issued absolute URLs are used as-is; everything else resolves against the base.
|
|
194
|
+
const url = withQuery(/^https?:\/\//.test(path) ? new URL(path) : baseURL(path), exchange.http?.query);
|
|
195
|
+
for (const [key, value] of Object.entries(input.endpoint.query ?? {}))
|
|
196
|
+
url.searchParams.set(key, value);
|
|
197
|
+
const headers = Headers.fromInput(exchange.http?.headers);
|
|
198
|
+
return send({ method, url, headers, request: { http: exchange.http }, timeout: exchange.http?.timeout }, exchange.http?.fetch, execute);
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
const withQuery = (url, query) => {
|
|
203
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
204
|
+
url.searchParams.delete(key);
|
|
205
|
+
for (const item of typeof value === "string" ? [value] : value)
|
|
206
|
+
url.searchParams.append(key, item);
|
|
207
|
+
}
|
|
208
|
+
return url;
|
|
209
|
+
};
|
|
210
|
+
const encode = (body, headers) => {
|
|
211
|
+
if (body === undefined)
|
|
212
|
+
return { text: "", headers, apply: (request) => request };
|
|
213
|
+
if (body.type === "json") {
|
|
214
|
+
const text = encodeJson(body.value);
|
|
215
|
+
return { text, headers, apply: HttpClientRequest.bodyText(text, "application/json") };
|
|
216
|
+
}
|
|
217
|
+
if (body.type === "binary")
|
|
218
|
+
return {
|
|
219
|
+
text: `[${body.contentType}]`,
|
|
220
|
+
headers,
|
|
221
|
+
apply: HttpClientRequest.bodyUint8Array(body.value, body.contentType),
|
|
222
|
+
};
|
|
223
|
+
return {
|
|
224
|
+
text: "[multipart/form-data]",
|
|
225
|
+
// The HTTP client sets the multipart boundary; a caller-supplied content-type would corrupt it.
|
|
226
|
+
headers: Headers.remove(headers, "content-type"),
|
|
227
|
+
apply: HttpClientRequest.bodyFormData(body.value),
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Common fields are never silently dropped: a present field the protocol declared unsupported fails typed. `false`
|
|
232
|
+
* counts as present because some booleans mean something when false (video `audio`); protocols reject opt-in
|
|
233
|
+
* booleans such as speech `timestamps` with `=== true` in `body.from` instead of listing them.
|
|
234
|
+
*/
|
|
235
|
+
const rejectUnsupported = (route, provider, request, unsupported) => {
|
|
236
|
+
const present = (unsupported ?? []).filter((field) => {
|
|
237
|
+
const value = request[field];
|
|
238
|
+
return Array.isArray(value) ? value.length > 0 : value !== undefined;
|
|
239
|
+
});
|
|
240
|
+
if (present.length === 0)
|
|
241
|
+
return Effect.void;
|
|
242
|
+
return Effect.fail(new AIError({
|
|
243
|
+
reason: new UnsupportedOperationError({
|
|
244
|
+
operation: `media.${present[0]}`,
|
|
245
|
+
provider,
|
|
246
|
+
route,
|
|
247
|
+
message: `${provider}/${route} does not support ${present.join(", ")}`,
|
|
248
|
+
}),
|
|
249
|
+
}));
|
|
250
|
+
};
|
|
251
|
+
export * as MediaRoute from "./media.js";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Schema, type Effect } from "effect";
|
|
2
|
+
import type { AIError, LanguageModelSanitizerCompatibility, StreamEvent, LLMRequest, ProtocolID } from "../schema/index.js";
|
|
3
|
+
import type { ToolUpdateEncoding } from "../tool-updates.js";
|
|
4
|
+
/**
|
|
5
|
+
* The semantic API contract of one model server family.
|
|
6
|
+
*
|
|
7
|
+
* A `Protocol` owns the parts of a route that are intrinsic to "what does
|
|
8
|
+
* this API look like": how a common `LLMRequest` becomes a provider-native
|
|
9
|
+
* body, what schema that body must satisfy before it is JSON-encoded, and
|
|
10
|
+
* how the streaming response decodes back into common `StreamEvent`s.
|
|
11
|
+
*
|
|
12
|
+
* Examples:
|
|
13
|
+
*
|
|
14
|
+
* - `OpenAIChat.protocol` — chat completions style
|
|
15
|
+
* - `OpenResponses.protocol` — provider-neutral Responses API baseline
|
|
16
|
+
* - `OpenAIResponses.protocol` — OpenAI extensions to that baseline
|
|
17
|
+
* - `AnthropicMessages.protocol` — messages API with content blocks
|
|
18
|
+
* - `Gemini.protocol` — generateContent
|
|
19
|
+
* - `BedrockConverse.protocol` — Converse with binary event-stream framing
|
|
20
|
+
*
|
|
21
|
+
* A `Protocol` is **not** a deployment. It does not know which URL, which
|
|
22
|
+
* headers, or which auth scheme to use. Those are deployment concerns owned
|
|
23
|
+
* by `Route.make(...)` along with the chosen `Endpoint`, `Auth`,
|
|
24
|
+
* and `Framing`. This separation is what lets DeepSeek, TogetherAI, Cerebras,
|
|
25
|
+
* etc. all reuse `OpenAIChat.protocol` without forking 300 lines per provider.
|
|
26
|
+
*
|
|
27
|
+
* The four type parameters reflect the pipeline:
|
|
28
|
+
*
|
|
29
|
+
* - `Body` — provider-native request body candidate. `Route.make(...)`
|
|
30
|
+
* validates and JSON-encodes it with `body.schema`.
|
|
31
|
+
* - `Frame` — one unit of the framed response stream. SSE: a JSON data
|
|
32
|
+
* string. AWS event stream: a parsed binary frame.
|
|
33
|
+
* - `Event` — schema-decoded provider event produced from one frame.
|
|
34
|
+
* - `State` — accumulator threaded through `stream.step` to translate event
|
|
35
|
+
* sequences into `StreamEvent` sequences.
|
|
36
|
+
*/
|
|
37
|
+
export interface Protocol<Body, Frame, Event, State> {
|
|
38
|
+
/** Stable id for the wire protocol implementation. */
|
|
39
|
+
readonly id: ProtocolID;
|
|
40
|
+
/** Request side: schema for the provider-native body and how to build it. */
|
|
41
|
+
readonly body: ProtocolBody<Body>;
|
|
42
|
+
/** Response side: streaming state machine. */
|
|
43
|
+
readonly stream: ProtocolStream<Frame, Event, State>;
|
|
44
|
+
/** Whether `body.from` lowers `Message.effort(...)` markers; wrappers around another `body.from` must forward it. */
|
|
45
|
+
readonly supportsEffortUpdates?: (request: LLMRequest) => boolean;
|
|
46
|
+
/** Tool changes `body.from` can send in place of `Message.tools(...)` markers; wrappers around another `body.from` must forward it. */
|
|
47
|
+
readonly toolUpdates?: ToolUpdateEncoding;
|
|
48
|
+
/** Whether `body.from` sends tool namespaces natively; otherwise `make` hands it flattened requests. Wrappers around another `body.from` must forward it. */
|
|
49
|
+
readonly namespaces?: boolean;
|
|
50
|
+
/** Tool schema sanitizer for every model on this protocol unless the model's compatibility sets one; wrappers around another `body.from` must forward it. */
|
|
51
|
+
readonly sanitizer?: LanguageModelSanitizerCompatibility;
|
|
52
|
+
}
|
|
53
|
+
export interface ProtocolBody<Body> {
|
|
54
|
+
/** Schema for the validated provider-native body sent as the JSON request. */
|
|
55
|
+
readonly schema: Schema.Codec<Body, unknown>;
|
|
56
|
+
/** Build the provider-native body from a common `LLMRequest`. */
|
|
57
|
+
readonly from: (request: LLMRequest) => Effect.Effect<Body, AIError>;
|
|
58
|
+
}
|
|
59
|
+
export interface ProtocolStream<Frame, Event, State> {
|
|
60
|
+
/** Schema for one decoded streaming event, decoded from a transport frame. */
|
|
61
|
+
readonly event: Schema.Codec<Event, Frame>;
|
|
62
|
+
/** Initial parser state. Called once per response with the resolved request. */
|
|
63
|
+
readonly initial: (request: LLMRequest) => State;
|
|
64
|
+
/** Translate one event into emitted `StreamEvent`s plus the next state. */
|
|
65
|
+
readonly step: (state: State, event: Event) => Effect.Effect<readonly [State, ReadonlyArray<StreamEvent>], AIError>;
|
|
66
|
+
/** Optional request-completion signal for transports that do not end naturally. */
|
|
67
|
+
readonly terminal?: (event: Event) => boolean;
|
|
68
|
+
/** Optional effectful flush emitted when the framed stream ends. */
|
|
69
|
+
readonly onHalt?: (state: State) => Effect.Effect<ReadonlyArray<StreamEvent>, AIError>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Construct a `Protocol` from its body and stream pieces:
|
|
73
|
+
*
|
|
74
|
+
* - `body.schema` infers the provider-native request body shape.
|
|
75
|
+
* - `body.from` ties the common `LLMRequest` to the provider body.
|
|
76
|
+
* - `stream.event` infers the decoded streaming event and the wire frame.
|
|
77
|
+
* - `stream.initial`, `stream.step`, and `stream.onHalt` infer the parser state.
|
|
78
|
+
*
|
|
79
|
+
* Provider implementations should usually call `Protocol.make({ ... })`
|
|
80
|
+
* without explicit type arguments; the schemas and parser functions are the
|
|
81
|
+
* source of truth.
|
|
82
|
+
*/
|
|
83
|
+
export declare const make: <Body, Frame, Event, State>(input: Protocol<Body, Frame, Event, State>) => Protocol<Body, Frame, Event, State>;
|
|
84
|
+
export declare const jsonEvent: <const S extends Schema.Top>(schema: S) => Schema.fromJsonString<S>;
|
|
85
|
+
export * as Protocol from "./protocol.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { flattenRequest } from "../protocols/shared.js";
|
|
3
|
+
/**
|
|
4
|
+
* Construct a `Protocol` from its body and stream pieces:
|
|
5
|
+
*
|
|
6
|
+
* - `body.schema` infers the provider-native request body shape.
|
|
7
|
+
* - `body.from` ties the common `LLMRequest` to the provider body.
|
|
8
|
+
* - `stream.event` infers the decoded streaming event and the wire frame.
|
|
9
|
+
* - `stream.initial`, `stream.step`, and `stream.onHalt` infer the parser state.
|
|
10
|
+
*
|
|
11
|
+
* Provider implementations should usually call `Protocol.make({ ... })`
|
|
12
|
+
* without explicit type arguments; the schemas and parser functions are the
|
|
13
|
+
* source of truth.
|
|
14
|
+
*/
|
|
15
|
+
export const make = (input) => input.namespaces
|
|
16
|
+
? input
|
|
17
|
+
: { ...input, body: { ...input.body, from: (request) => input.body.from(flattenRequest(request)) } };
|
|
18
|
+
export const jsonEvent = (schema) => Schema.fromJsonString(schema);
|
|
19
|
+
export * as Protocol from "./protocol.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
|
+
import { Framing } from "../framing.js";
|
|
4
|
+
import type { HttpMiddleware, Transport, TransportPrepareInput } from "./index.js";
|
|
5
|
+
export type JsonRequestInput<Body> = TransportPrepareInput<Body>;
|
|
6
|
+
export interface JsonRequestParts<Body = unknown> {
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly jsonBody: Body | Record<string, unknown>;
|
|
9
|
+
readonly bodyText: string;
|
|
10
|
+
readonly headers: Headers.Headers;
|
|
11
|
+
}
|
|
12
|
+
export interface HttpPrepared<Frame> {
|
|
13
|
+
readonly request: HttpClientRequest.HttpClientRequest;
|
|
14
|
+
readonly framing: Framing.Definition<Frame>;
|
|
15
|
+
readonly middleware?: HttpMiddleware;
|
|
16
|
+
}
|
|
17
|
+
export declare const jsonRequestParts: <Body>(input: JsonRequestInput<Body>) => Effect.Effect<{
|
|
18
|
+
url: string;
|
|
19
|
+
jsonBody: Body | Record<string, unknown>;
|
|
20
|
+
bodyText: string;
|
|
21
|
+
headers: Headers.Headers;
|
|
22
|
+
}, import("../../schema/errors.js").AIError, never>;
|
|
23
|
+
export interface HttpJsonInput<_Body, Frame> {
|
|
24
|
+
readonly framing: Framing.Definition<Frame>;
|
|
25
|
+
}
|
|
26
|
+
export type HttpJsonPatch<Body, Frame> = Partial<HttpJsonInput<Body, Frame>>;
|
|
27
|
+
export interface HttpJsonTransport<Body, Frame> extends Transport<Body, HttpPrepared<Frame>, Frame> {
|
|
28
|
+
readonly with: (patch: HttpJsonPatch<Body, Frame>) => HttpJsonTransport<Body, Frame>;
|
|
29
|
+
}
|
|
30
|
+
export declare const httpJson: <Body, Frame>(input: HttpJsonInput<Body, Frame>) => HttpJsonTransport<Body, Frame>;
|
|
31
|
+
export declare const sseJson: {
|
|
32
|
+
readonly id: "http-json/sse";
|
|
33
|
+
readonly with: <Body>() => HttpJsonTransport<Body, string>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
|
+
import { Auth } from "../auth.js";
|
|
4
|
+
import { render as renderEndpoint } from "../endpoint.js";
|
|
5
|
+
import { Framing } from "../framing.js";
|
|
6
|
+
import * as ProviderShared from "../../protocols/shared.js";
|
|
7
|
+
import { mergeJsonRecords } from "../../schema/index.js";
|
|
8
|
+
import { RequestExecutor } from "../executor.js";
|
|
9
|
+
const bodyWithOverlay = (body, request, encodeBody) => Effect.gen(function* () {
|
|
10
|
+
if (request.http?.body === undefined)
|
|
11
|
+
return { jsonBody: body, bodyText: encodeBody(body) };
|
|
12
|
+
if (ProviderShared.isRecord(body)) {
|
|
13
|
+
const overlaid = mergeJsonRecords(body, request.http.body) ?? {};
|
|
14
|
+
return { jsonBody: overlaid, bodyText: ProviderShared.encodeJson(overlaid) };
|
|
15
|
+
}
|
|
16
|
+
return yield* ProviderShared.invalidRequest("http.body can only overlay JSON object request bodies");
|
|
17
|
+
});
|
|
18
|
+
export const jsonRequestParts = (input) => Effect.gen(function* () {
|
|
19
|
+
const endpoint = renderEndpoint(input.endpoint, { request: input.request, body: input.body });
|
|
20
|
+
if (input.request.http?.query) {
|
|
21
|
+
Object.entries(input.request.http.query).forEach(([key, value]) => endpoint.searchParams.set(key, value));
|
|
22
|
+
}
|
|
23
|
+
const url = endpoint.toString();
|
|
24
|
+
const body = yield* bodyWithOverlay(input.body, input.request, input.encodeBody);
|
|
25
|
+
const headers = yield* Auth.toEffect(input.auth)({
|
|
26
|
+
request: input.request,
|
|
27
|
+
method: "POST",
|
|
28
|
+
url,
|
|
29
|
+
body: body.bodyText,
|
|
30
|
+
headers: Headers.fromInput({
|
|
31
|
+
...input.headers?.({ request: input.request }),
|
|
32
|
+
...input.request.http?.headers,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
return { url, jsonBody: body.jsonBody, bodyText: body.bodyText, headers };
|
|
36
|
+
});
|
|
37
|
+
export const httpJson = (input) => ({
|
|
38
|
+
id: "http-json",
|
|
39
|
+
with: (patch) => httpJson({ ...input, ...patch }),
|
|
40
|
+
prepare: (prepareInput) => Effect.gen(function* () {
|
|
41
|
+
const parts = yield* jsonRequestParts({ ...prepareInput });
|
|
42
|
+
const request = yield* ProviderShared.jsonPostEffect({
|
|
43
|
+
url: parts.url,
|
|
44
|
+
body: parts.bodyText,
|
|
45
|
+
headers: parts.headers,
|
|
46
|
+
encoding: prepareInput.request.http?.encoding,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
request,
|
|
50
|
+
framing: input.framing,
|
|
51
|
+
middleware: prepareInput.middleware,
|
|
52
|
+
};
|
|
53
|
+
}),
|
|
54
|
+
execute: (prepared, request, runtime) => Effect.gen(function* () {
|
|
55
|
+
const response = yield* RequestExecutor.withTimeout(RequestExecutor.withTls(runtime.http.execute, request.http?.tls), request.http?.timeout)(prepared.request, prepared.middleware);
|
|
56
|
+
return {
|
|
57
|
+
frames: prepared.framing.frame(RequestExecutor.responseStream(response)),
|
|
58
|
+
http: RequestExecutor.responseHttp(response),
|
|
59
|
+
body: prepared.framing.body,
|
|
60
|
+
raw: prepared.framing.raw,
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
export const sseJson = {
|
|
65
|
+
id: "http-json/sse",
|
|
66
|
+
with: () => httpJson({ framing: Framing.sse }),
|
|
67
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Effect, Scope, Stream } from "effect";
|
|
2
|
+
import { Endpoint } from "../endpoint.js";
|
|
3
|
+
import { Auth } from "../auth.js";
|
|
4
|
+
import type { HttpMiddleware, Interface as RequestExecutorInterface } from "../executor.js";
|
|
5
|
+
import type { WebSocketChannelExecutor } from "./websocket-channel.js";
|
|
6
|
+
import type { AIError, HttpContext, LLMRequest } from "../../schema/index.js";
|
|
7
|
+
export interface TransportRuntime {
|
|
8
|
+
readonly http: RequestExecutorInterface;
|
|
9
|
+
}
|
|
10
|
+
export interface TransportExecution<Frame> {
|
|
11
|
+
readonly frames: Stream.Stream<Frame, AIError>;
|
|
12
|
+
readonly http?: HttpContext;
|
|
13
|
+
body?(frame: Frame): string | undefined;
|
|
14
|
+
raw?(frame: Frame): unknown;
|
|
15
|
+
/** Optional successful-consumption acknowledgement. HTTP leaves this absent. */
|
|
16
|
+
readonly complete?: Effect.Effect<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface TransportExecuteOptions {
|
|
19
|
+
readonly webSocket?: WebSocketChannelExecutor;
|
|
20
|
+
}
|
|
21
|
+
export interface Transport<Body, Prepared, Frame> {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly prepare: (input: TransportPrepareInput<Body>) => Effect.Effect<Prepared, AIError>;
|
|
24
|
+
readonly execute: (prepared: Prepared, request: LLMRequest, runtime: TransportRuntime, options?: TransportExecuteOptions) => Effect.Effect<TransportExecution<Frame>, AIError, Scope.Scope>;
|
|
25
|
+
}
|
|
26
|
+
export interface TransportPrepareInput<Body> {
|
|
27
|
+
readonly body: Body;
|
|
28
|
+
readonly request: LLMRequest;
|
|
29
|
+
readonly endpoint: Endpoint.Definition<Body>;
|
|
30
|
+
readonly auth: Auth.Definition;
|
|
31
|
+
readonly encodeBody: (body: Body) => string;
|
|
32
|
+
readonly headers?: (input: {
|
|
33
|
+
readonly request: LLMRequest;
|
|
34
|
+
}) => Record<string, string>;
|
|
35
|
+
readonly middleware?: HttpMiddleware;
|
|
36
|
+
readonly webSocket?: WebSocketChannelExecutor;
|
|
37
|
+
}
|
|
38
|
+
export * as HttpTransport from "./http.js";
|
|
39
|
+
export type { HttpHandler, HttpMiddleware } from "../executor.js";
|
|
40
|
+
export type { ChannelCheckpoint, ChannelCreate, ChannelObservation, WebSocketChannelDriver, WebSocketChannelExchange, WebSocketChannelExecution, WebSocketChannelExecutor, } from "./websocket-channel.js";
|
|
41
|
+
export type { WebSocketConnection, WebSocketConnector, WebSocketRequest } from "./websocket.js";
|
|
42
|
+
export { WebSocketTransport } from "./websocket.js";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Effect, Scope, Stream } from "effect";
|
|
2
|
+
import type { Headers } from "effect/http";
|
|
3
|
+
import type { AIError, HttpContext } from "../../schema/index.js";
|
|
4
|
+
export interface WebSocketChannelExecutor {
|
|
5
|
+
readonly execute: (exchange: WebSocketChannelExchange) => Effect.Effect<WebSocketChannelExecution, AIError, Scope.Scope>;
|
|
6
|
+
}
|
|
7
|
+
export interface WebSocketChannelExecution {
|
|
8
|
+
readonly frames: Stream.Stream<string, AIError>;
|
|
9
|
+
readonly http?: HttpContext;
|
|
10
|
+
/** Commits staged state after the decoded Route stream ends successfully. */
|
|
11
|
+
readonly complete: Effect.Effect<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface WebSocketChannelExchange {
|
|
14
|
+
readonly connect: {
|
|
15
|
+
readonly url: string;
|
|
16
|
+
readonly headers: Headers.Headers;
|
|
17
|
+
/** Provider-safe connection age after which the channel executor should reconnect before sending. */
|
|
18
|
+
readonly rotateAfterMs?: number;
|
|
19
|
+
};
|
|
20
|
+
readonly fallback: () => Stream.Stream<string, AIError>;
|
|
21
|
+
readonly driver: WebSocketChannelDriver;
|
|
22
|
+
}
|
|
23
|
+
export interface WebSocketChannelDriver {
|
|
24
|
+
readonly create: (checkpoint: ChannelCheckpoint | undefined) => Effect.Effect<ChannelCreate, AIError>;
|
|
25
|
+
readonly observe: (create: ChannelCreate, frame: string) => Effect.Effect<ChannelObservation, AIError>;
|
|
26
|
+
}
|
|
27
|
+
export interface ChannelCreate {
|
|
28
|
+
readonly message: string;
|
|
29
|
+
readonly mode: "full" | "incremental";
|
|
30
|
+
}
|
|
31
|
+
export type ChannelObservation = {
|
|
32
|
+
readonly type: "frame";
|
|
33
|
+
readonly frame: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "completed";
|
|
36
|
+
readonly frame: string;
|
|
37
|
+
readonly checkpoint?: ChannelCheckpoint;
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: "incomplete";
|
|
40
|
+
readonly frame: string;
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: "provider-failure";
|
|
43
|
+
readonly error: AIError;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: "rejected";
|
|
46
|
+
readonly error: AIError;
|
|
47
|
+
readonly recovery: "retry-full";
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "rejected";
|
|
50
|
+
readonly error: AIError;
|
|
51
|
+
readonly recovery: "rotate-and-retry-full";
|
|
52
|
+
};
|
|
53
|
+
export interface ChannelCheckpoint {
|
|
54
|
+
readonly protocol: string;
|
|
55
|
+
readonly value: unknown;
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Effect, Stream } from "effect";
|
|
2
|
+
import { Headers } from "effect/http";
|
|
3
|
+
import { Socket } from "effect/socket";
|
|
4
|
+
import { AIError, type HttpContext } from "../../schema/index.js";
|
|
5
|
+
import type { WebSocketChannelExecutor } from "./websocket-channel.js";
|
|
6
|
+
export interface WebSocketRequest {
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly headers: Headers.Headers;
|
|
9
|
+
}
|
|
10
|
+
export interface WebSocketConnection {
|
|
11
|
+
readonly http?: HttpContext;
|
|
12
|
+
readonly sendText: (message: string) => Effect.Effect<void, AIError>;
|
|
13
|
+
readonly messages: Stream.Stream<string | Uint8Array, AIError>;
|
|
14
|
+
readonly close: Effect.Effect<void, never>;
|
|
15
|
+
}
|
|
16
|
+
export interface WebSocketConnector {
|
|
17
|
+
readonly open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError>;
|
|
18
|
+
}
|
|
19
|
+
export declare const toWebSocketUrl: (value: string) => Effect.Effect<string, AIError, never>;
|
|
20
|
+
export declare const open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError, Socket.WebSocketConstructor>;
|
|
21
|
+
export declare const fromWebSocket: (ws: Socket.WebSocketLike, input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError>;
|
|
22
|
+
export declare const messageText: (message: string | Uint8Array, decoder: TextDecoder) => string;
|
|
23
|
+
export declare const makeDirect: (connector: WebSocketConnector) => WebSocketChannelExecutor;
|
|
24
|
+
export declare const direct: Effect.Effect<WebSocketChannelExecutor, never, Socket.WebSocketConstructor>;
|
|
25
|
+
export declare const WebSocketTransport: {
|
|
26
|
+
readonly direct: Effect.Effect<WebSocketChannelExecutor, never, Socket.WebSocketConstructor>;
|
|
27
|
+
readonly makeDirect: typeof makeDirect;
|
|
28
|
+
readonly open: typeof open;
|
|
29
|
+
readonly fromWebSocket: typeof fromWebSocket;
|
|
30
|
+
readonly messageText: typeof messageText;
|
|
31
|
+
readonly toWebSocketUrl: typeof toWebSocketUrl;
|
|
32
|
+
};
|