@opencode/ai 2.1.4 → 2.2.1
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 +339 -166
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +4 -0
- package/dist/cache-policy.js +20 -6
- package/dist/decision-client.d.ts +21 -0
- package/dist/decision-client.js +55 -0
- package/dist/decision.d.ts +472 -0
- package/dist/decision.js +158 -0
- package/dist/effect.d.ts +38 -0
- package/dist/effect.js +27 -0
- package/dist/effort-updates.d.ts +2 -2
- package/dist/experimental/cloudflare-run-extraction.d.ts +13 -0
- package/dist/experimental/cloudflare-run-extraction.js +83 -0
- package/dist/experimental/extraction.d.ts +183 -0
- package/dist/experimental/extraction.js +102 -0
- package/dist/experimental/realtime.d.ts +7 -2
- package/dist/experimental/realtime.js +5 -5
- package/dist/experimental.d.ts +2 -3
- package/dist/experimental.js +1 -2
- package/dist/image-client.d.ts +50 -14
- package/dist/image-client.js +0 -1
- package/dist/image.d.ts +6 -176
- package/dist/image.js +4 -11
- package/dist/index.d.ts +1444 -34
- package/dist/index.js +139 -24
- package/dist/llm.d.ts +16 -1
- package/dist/llm.js +34 -0
- package/dist/media-client.d.ts +3 -1
- package/dist/media-client.js +1 -0
- package/dist/media-model.d.ts +3 -0
- package/dist/media-model.js +4 -1
- package/dist/media.d.ts +0 -7
- package/dist/media.js +0 -6
- package/dist/protocols/alibaba-chat.d.ts +59 -4
- package/dist/protocols/alibaba-images.d.ts +22 -0
- package/dist/protocols/alibaba-images.js +77 -0
- package/dist/protocols/alibaba-messages.d.ts +52 -17
- package/dist/protocols/alibaba-responses.d.ts +26 -6
- package/dist/protocols/anthropic-messages.d.ts +160 -54
- package/dist/protocols/anthropic-messages.js +44 -13
- package/dist/protocols/bedrock-converse.d.ts +110 -15
- package/dist/protocols/bedrock-converse.js +112 -15
- package/dist/protocols/bedrock-event-stream.js +1 -0
- package/dist/protocols/cartesia-speech.d.ts +0 -18
- 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/deepgram-speech.d.ts +0 -18
- package/dist/protocols/elevenlabs-speech.d.ts +0 -18
- package/dist/protocols/gemini.d.ts +3 -0
- package/dist/protocols/gemini.js +11 -6
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-images.js +10 -37
- package/dist/protocols/google-interactions.d.ts +4 -0
- package/dist/protocols/google-interactions.js +12 -5
- package/dist/protocols/google-speech.d.ts +0 -18
- package/dist/protocols/google-speech.js +0 -1
- package/dist/protocols/google-transcription.d.ts +0 -18
- package/dist/protocols/google-transcription.js +0 -1
- package/dist/protocols/google-video.d.ts +1 -1
- package/dist/protocols/google-video.js +2 -7
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +7 -1
- package/dist/protocols/meta-images.js +10 -8
- package/dist/protocols/meta-messages.d.ts +52 -17
- package/dist/protocols/meta-messages.js +14 -1
- package/dist/protocols/meta-responses.d.ts +46 -6
- package/dist/protocols/meta-responses.js +29 -1
- package/dist/protocols/minimax-images.d.ts +25 -0
- package/dist/protocols/minimax-images.js +150 -0
- package/dist/protocols/open-responses.d.ts +212 -27
- package/dist/protocols/open-responses.js +116 -54
- package/dist/protocols/openai-chat.d.ts +1135 -31
- package/dist/protocols/openai-chat.js +155 -60
- package/dist/protocols/openai-compatible-chat.d.ts +57 -5
- package/dist/protocols/openai-compatible-responses.d.ts +28 -8
- package/dist/protocols/openai-decisions.d.ts +22 -0
- package/dist/protocols/openai-decisions.js +128 -0
- package/dist/protocols/openai-freeform.d.ts +47 -0
- package/dist/protocols/openai-freeform.js +54 -0
- package/dist/protocols/openai-images.d.ts +36 -24
- package/dist/protocols/openai-images.js +137 -39
- package/dist/protocols/openai-responses.d.ts +202 -42
- package/dist/protocols/openai-responses.js +49 -10
- package/dist/protocols/openai-speech.d.ts +0 -18
- package/dist/protocols/openai-speech.js +15 -5
- package/dist/protocols/openai-transcription.d.ts +0 -18
- package/dist/protocols/openai-transcription.js +3 -4
- package/dist/protocols/runway-video.d.ts +1 -1
- package/dist/protocols/runway-video.js +1 -1
- package/dist/protocols/shared.d.ts +9 -1
- package/dist/protocols/shared.js +13 -2
- package/dist/protocols/system-one.d.ts +101 -0
- package/dist/protocols/system-one.js +230 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.js +7 -6
- package/dist/protocols/utils/cache.d.ts +14 -3
- package/dist/protocols/utils/cache.js +11 -4
- package/dist/protocols/utils/gemini-generate-content.d.ts +3 -3
- package/dist/protocols/utils/gemini-generate-content.js +10 -16
- package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
- package/dist/protocols/utils/gemini-json-schema.js +3 -3
- package/dist/protocols/utils/image-sizing.d.ts +31 -0
- package/dist/protocols/utils/image-sizing.js +73 -0
- package/dist/protocols/utils/media-input.d.ts +4 -5
- package/dist/protocols/utils/media-input.js +8 -5
- package/dist/protocols/utils/speech-stream.d.ts +0 -1
- package/dist/protocols/utils/speech-stream.js +0 -1
- package/dist/protocols/utils/tool-schema.js +15 -5
- package/dist/protocols/utils/tool-stream.d.ts +9 -0
- package/dist/protocols/venice-chat.d.ts +58 -4
- package/dist/protocols/venice-chat.js +2 -2
- package/dist/protocols/xai-images.d.ts +7 -2
- package/dist/protocols/xai-images.js +11 -5
- package/dist/protocols/xai-responses.d.ts +30 -3
- package/dist/protocols/xai-responses.js +30 -3
- package/dist/protocols/xai-video.d.ts +1 -1
- package/dist/protocols/xai-video.js +11 -8
- package/dist/protocols/zai-chat.d.ts +60 -4
- package/dist/protocols/zai-images.d.ts +3 -1
- package/dist/protocols/zai-images.js +12 -11
- package/dist/protocols/zai-messages.d.ts +52 -17
- package/dist/provider-error.js +23 -7
- package/dist/provider-package.d.ts +2 -0
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +137 -28
- package/dist/providers/alibaba.js +16 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +259 -145
- package/dist/providers/amazon-bedrock-mantle.js +1 -1
- package/dist/providers/amazon-bedrock.d.ts +34 -14
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +53 -18
- package/dist/providers/anthropic.d.ts +53 -18
- package/dist/providers/anthropic.js +1 -1
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +129 -24
- package/dist/providers/azure.js +19 -1
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +124 -12
- package/dist/providers/baseten.js +41 -8
- package/dist/providers/cerebras.d.ts +115 -11
- package/dist/providers/cerebras.js +1 -1
- 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 +290 -60
- package/dist/providers/cloudflare-ai-gateway.js +32 -4
- 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 +128 -12
- package/dist/providers/cloudflare-workers-ai.js +45 -9
- package/dist/providers/cohere/chat.d.ts +1 -1
- package/dist/providers/cohere/chat.js +1 -1
- package/dist/providers/cohere.d.ts +115 -11
- package/dist/providers/cohere.js +1 -1
- package/dist/providers/deepinfra.d.ts +115 -11
- package/dist/providers/deepinfra.js +1 -1
- package/dist/providers/deepseek.d.ts +115 -11
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.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 +390 -20
- package/dist/providers/digitalocean.js +53 -11
- package/dist/providers/fireworks.d.ts +115 -11
- package/dist/providers/fireworks.js +1 -1
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +1 -1
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +57 -5
- package/dist/providers/google-vertex-chat.js +1 -1
- package/dist/providers/google-vertex-interactions.d.ts +1 -1
- package/dist/providers/google-vertex-interactions.js +1 -1
- package/dist/providers/google-vertex-messages.d.ts +53 -18
- package/dist/providers/google-vertex-messages.js +1 -1
- package/dist/providers/google-vertex-mistral.d.ts +1 -1
- package/dist/providers/google-vertex-mistral.js +1 -1
- package/dist/providers/google-vertex-responses.d.ts +24 -4
- package/dist/providers/google-vertex-responses.js +1 -1
- package/dist/providers/google-vertex.d.ts +4 -2
- package/dist/providers/google-vertex.js +30 -13
- package/dist/providers/google.d.ts +6 -5
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +119 -15
- package/dist/providers/groq.js +1 -7
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.js +0 -4
- package/dist/providers/meta/images.d.ts +2 -0
- package/dist/providers/meta/images.js +1 -0
- package/dist/providers/meta.d.ts +254 -146
- package/dist/providers/meta.js +2 -1
- package/dist/providers/minimax/chat.d.ts +1 -1
- package/dist/providers/minimax/chat.js +1 -1
- package/dist/providers/minimax/images.d.ts +3 -0
- package/dist/providers/minimax/images.js +1 -0
- package/dist/providers/minimax/responses.d.ts +1 -1
- package/dist/providers/minimax/responses.js +1 -1
- package/dist/providers/minimax.d.ts +139 -26
- package/dist/providers/minimax.js +22 -9
- package/dist/providers/mistral.d.ts +3 -3
- package/dist/providers/mistral.js +1 -1
- package/dist/providers/moonshot/messages.d.ts +1 -1
- package/dist/providers/moonshot/messages.js +1 -1
- package/dist/providers/moonshot/responses.d.ts +1 -1
- package/dist/providers/moonshot/responses.js +1 -1
- package/dist/providers/moonshot.d.ts +132 -25
- package/dist/providers/moonshot.js +1 -1
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.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 +24 -4
- package/dist/providers/openai-compatible.d.ts +62 -8
- package/dist/providers/openai-compatible.js +29 -10
- package/dist/providers/openai-options.d.ts +3 -1
- package/dist/providers/openai.d.ts +103 -18
- package/dist/providers/openai.js +23 -5
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +11 -12
- package/dist/providers/opencode.js +10 -8
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.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 +4 -0
- package/dist/providers/openrouter/responses.js +1 -0
- package/dist/providers/openrouter.d.ts +446 -35
- package/dist/providers/openrouter.js +78 -27
- package/dist/providers/togetherai.d.ts +115 -11
- package/dist/providers/togetherai.js +1 -1
- 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 +11 -12
- package/dist/providers/typesafe-ai.js +10 -8
- package/dist/providers/venice/responses.d.ts +4 -0
- package/dist/providers/venice/responses.js +1 -0
- package/dist/providers/venice.d.ts +261 -9
- package/dist/providers/venice.js +33 -17
- 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/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +16 -22
- package/dist/providers/vercel-ai-gateway.js +41 -85
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +66 -12
- package/dist/providers/xai.js +15 -8
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan/messages.d.ts +1 -1
- package/dist/providers/zai-coding-plan/messages.js +1 -1
- package/dist/providers/zai-coding-plan/responses.d.ts +1 -1
- package/dist/providers/zai-coding-plan/responses.js +1 -1
- package/dist/providers/zai-coding-plan.d.ts +132 -25
- package/dist/providers/zai-coding-plan.js +1 -1
- package/dist/providers/zai.d.ts +62 -9
- package/dist/providers/zai.js +15 -8
- package/dist/route/auth.d.ts +1 -1
- package/dist/route/client.d.ts +2 -2
- package/dist/route/client.js +26 -4
- package/dist/route/decision.d.ts +58 -0
- package/dist/route/decision.js +75 -0
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.js +3 -0
- package/dist/route/media-protocol.d.ts +3 -4
- package/dist/route/media-protocol.js +12 -8
- package/dist/route/media.d.ts +6 -2
- package/dist/route/media.js +8 -6
- package/dist/route/transport/http.js +1 -0
- package/dist/route/transport/index.d.ts +1 -0
- package/dist/schema/events.d.ts +148 -6
- package/dist/schema/events.js +20 -0
- package/dist/schema/messages.d.ts +41 -3
- package/dist/schema/messages.js +23 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +53 -14
- package/dist/speech-client.js +0 -1
- package/dist/speech.d.ts +0 -135
- package/dist/speech.js +2 -4
- package/dist/testing/decision.d.ts +16 -0
- package/dist/testing/decision.js +20 -0
- package/dist/testing/image.d.ts +14 -0
- package/dist/testing/image.js +12 -0
- package/dist/testing/media.d.ts +18 -0
- package/dist/testing/media.js +36 -0
- package/dist/testing/script.d.ts +28 -0
- package/dist/testing/script.js +60 -0
- package/dist/testing/speech.d.ts +14 -0
- package/dist/testing/speech.js +12 -0
- package/dist/testing/transcription.d.ts +14 -0
- package/dist/testing/transcription.js +12 -0
- package/dist/testing/video.d.ts +14 -0
- package/dist/testing/video.js +12 -0
- package/dist/testing.d.ts +35 -45
- package/dist/testing.js +14 -75
- package/dist/tool.d.ts +12 -1
- package/dist/tool.js +10 -2
- package/dist/transcription-client.d.ts +69 -14
- package/dist/transcription.d.ts +0 -135
- package/dist/transcription.js +1 -1
- package/dist/utils/media-type.js +22 -1
- package/dist/video-client.d.ts +46 -14
- package/dist/video-client.js +0 -1
- package/dist/video.d.ts +1 -136
- package/dist/video.js +3 -5
- package/package.json +497 -11
- package/dist/experimental/evaluation-client.d.ts +0 -21
- package/dist/experimental/evaluation-client.js +0 -64
- package/dist/experimental/evaluation.d.ts +0 -242
- package/dist/experimental/evaluation.js +0 -108
- package/dist/experimental/system-one.d.ts +0 -16
- package/dist/experimental/system-one.js +0 -135
- package/dist/promise.d.ts +0 -1021
- package/dist/promise.js +0 -101
- package/dist/protocols/bfl-images.d.ts +0 -38
- package/dist/protocols/bfl-images.js +0 -153
- package/dist/protocols/fal-images.d.ts +0 -25
- package/dist/protocols/fal-images.js +0 -104
- package/dist/protocols/fal-video.d.ts +0 -29
- package/dist/protocols/fal-video.js +0 -73
- package/dist/protocols/replicate-images.d.ts +0 -28
- package/dist/protocols/replicate-images.js +0 -127
- package/dist/protocols/stability-images.d.ts +0 -39
- package/dist/protocols/stability-images.js +0 -136
- package/dist/protocols/utils/fal-queue.d.ts +0 -26
- package/dist/protocols/utils/fal-queue.js +0 -67
- package/dist/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
- package/dist/providers/black-forest-labs.d.ts +0 -21
- package/dist/providers/black-forest-labs.js +0 -23
- package/dist/providers/fal.d.ts +0 -24
- package/dist/providers/fal.js +0 -26
- package/dist/providers/replicate.d.ts +0 -21
- package/dist/providers/replicate.js +0 -17
- package/dist/providers/stability.d.ts +0 -23
- package/dist/providers/stability.js +0 -18
|
@@ -35,7 +35,7 @@ export declare const routes: (Route<{
|
|
|
35
35
|
readonly role: "developer";
|
|
36
36
|
readonly content: string;
|
|
37
37
|
} | {
|
|
38
|
-
readonly type: "function_call_output";
|
|
38
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
39
39
|
readonly call_id: string;
|
|
40
40
|
readonly output: string | readonly ({
|
|
41
41
|
readonly type: "input_text";
|
|
@@ -72,6 +72,9 @@ export declare const routes: (Route<{
|
|
|
72
72
|
readonly content: readonly ({
|
|
73
73
|
readonly type: "input_text";
|
|
74
74
|
readonly text: string;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "input_video";
|
|
77
|
+
readonly video_url: string;
|
|
75
78
|
} | {
|
|
76
79
|
readonly type: "input_image";
|
|
77
80
|
readonly image_url: string;
|
|
@@ -102,6 +105,12 @@ export declare const routes: (Route<{
|
|
|
102
105
|
readonly name: string;
|
|
103
106
|
readonly namespace?: string | undefined;
|
|
104
107
|
readonly arguments: string;
|
|
108
|
+
} | {
|
|
109
|
+
readonly type: "custom_tool_call";
|
|
110
|
+
readonly id?: string | undefined;
|
|
111
|
+
readonly call_id: string;
|
|
112
|
+
readonly name: string;
|
|
113
|
+
readonly input: string;
|
|
105
114
|
} | {
|
|
106
115
|
readonly [x: string]: unknown;
|
|
107
116
|
readonly type: "web_search_call";
|
|
@@ -146,6 +155,17 @@ export declare const routes: (Route<{
|
|
|
146
155
|
})[];
|
|
147
156
|
readonly instructions?: string | undefined;
|
|
148
157
|
readonly tools?: readonly ({
|
|
158
|
+
readonly type: "custom";
|
|
159
|
+
readonly name: string;
|
|
160
|
+
readonly description: string;
|
|
161
|
+
readonly format: {
|
|
162
|
+
readonly type: "text";
|
|
163
|
+
} | {
|
|
164
|
+
readonly type: "grammar";
|
|
165
|
+
readonly syntax: "lark" | "regex";
|
|
166
|
+
readonly definition: string;
|
|
167
|
+
};
|
|
168
|
+
} | {
|
|
149
169
|
readonly type: "function";
|
|
150
170
|
readonly name: string;
|
|
151
171
|
readonly description: string;
|
|
@@ -158,13 +178,13 @@ export declare const routes: (Route<{
|
|
|
158
178
|
readonly type: string;
|
|
159
179
|
})[] | undefined;
|
|
160
180
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
161
|
-
readonly type: "function";
|
|
181
|
+
readonly type: "custom" | "function";
|
|
162
182
|
readonly name: string;
|
|
163
183
|
} | {
|
|
164
184
|
readonly type: "allowed_tools";
|
|
165
185
|
readonly mode: "auto" | "none" | "required";
|
|
166
186
|
readonly tools: readonly {
|
|
167
|
-
readonly type: "function";
|
|
187
|
+
readonly type: "custom" | "function";
|
|
168
188
|
readonly name: string;
|
|
169
189
|
}[];
|
|
170
190
|
} | undefined;
|
|
@@ -205,6 +225,11 @@ export declare const routes: (Route<{
|
|
|
205
225
|
readonly image_url: {
|
|
206
226
|
readonly url: string;
|
|
207
227
|
};
|
|
228
|
+
} | {
|
|
229
|
+
readonly type: "video_url";
|
|
230
|
+
readonly video_url: {
|
|
231
|
+
readonly url: string;
|
|
232
|
+
};
|
|
208
233
|
} | {
|
|
209
234
|
readonly type: "file";
|
|
210
235
|
readonly file: {
|
|
@@ -226,6 +251,11 @@ export declare const routes: (Route<{
|
|
|
226
251
|
readonly image_url: {
|
|
227
252
|
readonly url: string;
|
|
228
253
|
};
|
|
254
|
+
} | {
|
|
255
|
+
readonly type: "video_url";
|
|
256
|
+
readonly video_url: {
|
|
257
|
+
readonly url: string;
|
|
258
|
+
};
|
|
229
259
|
} | {
|
|
230
260
|
readonly type: "file";
|
|
231
261
|
readonly file: {
|
|
@@ -262,7 +292,14 @@ export declare const routes: (Route<{
|
|
|
262
292
|
readonly ttl?: string | undefined;
|
|
263
293
|
} | undefined;
|
|
264
294
|
}[] | null;
|
|
265
|
-
readonly tool_calls?: readonly {
|
|
295
|
+
readonly tool_calls?: readonly ({
|
|
296
|
+
readonly id: string;
|
|
297
|
+
readonly type: "custom";
|
|
298
|
+
readonly custom: {
|
|
299
|
+
readonly name: string;
|
|
300
|
+
readonly input: string;
|
|
301
|
+
};
|
|
302
|
+
} | {
|
|
266
303
|
readonly id: string;
|
|
267
304
|
readonly type: "function";
|
|
268
305
|
readonly function: {
|
|
@@ -274,13 +311,13 @@ export declare const routes: (Route<{
|
|
|
274
311
|
readonly thought_signature: string;
|
|
275
312
|
};
|
|
276
313
|
} | undefined;
|
|
277
|
-
}[] | undefined;
|
|
314
|
+
})[] | undefined;
|
|
278
315
|
readonly reasoning_content?: string | undefined;
|
|
279
316
|
readonly reasoning?: string | undefined;
|
|
280
317
|
readonly reasoning_text?: string | undefined;
|
|
281
318
|
readonly reasoning_details?: unknown;
|
|
282
319
|
})[];
|
|
283
|
-
readonly tools?: readonly {
|
|
320
|
+
readonly tools?: readonly ({
|
|
284
321
|
readonly type: "function";
|
|
285
322
|
readonly function: {
|
|
286
323
|
readonly name: string;
|
|
@@ -294,12 +331,36 @@ export declare const routes: (Route<{
|
|
|
294
331
|
readonly type: "ephemeral";
|
|
295
332
|
readonly ttl?: string | undefined;
|
|
296
333
|
} | undefined;
|
|
297
|
-
}
|
|
334
|
+
} | {
|
|
335
|
+
readonly type: "custom";
|
|
336
|
+
readonly custom: {
|
|
337
|
+
readonly name: string;
|
|
338
|
+
readonly description: string;
|
|
339
|
+
readonly format: {
|
|
340
|
+
readonly type: "text";
|
|
341
|
+
} | {
|
|
342
|
+
readonly type: "grammar";
|
|
343
|
+
readonly grammar: {
|
|
344
|
+
readonly syntax: "lark" | "regex";
|
|
345
|
+
readonly definition: string;
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
readonly cache_control?: {
|
|
350
|
+
readonly type: "ephemeral";
|
|
351
|
+
readonly ttl?: string | undefined;
|
|
352
|
+
} | undefined;
|
|
353
|
+
})[] | undefined;
|
|
298
354
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
299
355
|
readonly type: "function";
|
|
300
356
|
readonly function: {
|
|
301
357
|
readonly name: string;
|
|
302
358
|
};
|
|
359
|
+
} | {
|
|
360
|
+
readonly type: "custom";
|
|
361
|
+
readonly custom: {
|
|
362
|
+
readonly name: string;
|
|
363
|
+
};
|
|
303
364
|
} | undefined;
|
|
304
365
|
readonly stream: true;
|
|
305
366
|
readonly stream_options?: {
|
|
@@ -307,7 +368,18 @@ export declare const routes: (Route<{
|
|
|
307
368
|
} | undefined;
|
|
308
369
|
readonly store?: boolean | undefined;
|
|
309
370
|
readonly prompt_cache_key?: string | undefined;
|
|
371
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
372
|
+
readonly prompt_cache_options?: {
|
|
373
|
+
readonly ttl?: string | undefined;
|
|
374
|
+
} | undefined;
|
|
310
375
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
376
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
377
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
378
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
379
|
+
readonly metadata?: {
|
|
380
|
+
readonly [x: string]: string;
|
|
381
|
+
} | undefined;
|
|
382
|
+
readonly safety_identifier?: string | undefined;
|
|
311
383
|
readonly tool_stream?: boolean | undefined;
|
|
312
384
|
readonly max_completion_tokens?: number | undefined;
|
|
313
385
|
readonly max_tokens?: number | undefined;
|
|
@@ -345,7 +417,7 @@ export declare const routes: (Route<{
|
|
|
345
417
|
readonly text: string;
|
|
346
418
|
readonly cache_control?: {
|
|
347
419
|
readonly type: "ephemeral";
|
|
348
|
-
readonly ttl?:
|
|
420
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
349
421
|
} | undefined;
|
|
350
422
|
}[] | undefined;
|
|
351
423
|
readonly messages: readonly ({
|
|
@@ -355,7 +427,7 @@ export declare const routes: (Route<{
|
|
|
355
427
|
readonly text: string;
|
|
356
428
|
readonly cache_control?: {
|
|
357
429
|
readonly type: "ephemeral";
|
|
358
|
-
readonly ttl?:
|
|
430
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
359
431
|
} | undefined;
|
|
360
432
|
} | {
|
|
361
433
|
readonly type: "image";
|
|
@@ -372,11 +444,28 @@ export declare const routes: (Route<{
|
|
|
372
444
|
};
|
|
373
445
|
readonly cache_control?: {
|
|
374
446
|
readonly type: "ephemeral";
|
|
375
|
-
readonly ttl?:
|
|
447
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
376
448
|
} | undefined;
|
|
377
449
|
readonly transformations?: {
|
|
378
450
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
379
451
|
} | undefined;
|
|
452
|
+
} | {
|
|
453
|
+
readonly type: "video";
|
|
454
|
+
readonly source: {
|
|
455
|
+
readonly type: "base64";
|
|
456
|
+
readonly media_type: string;
|
|
457
|
+
readonly data: string;
|
|
458
|
+
} | {
|
|
459
|
+
readonly type: "url";
|
|
460
|
+
readonly url: string;
|
|
461
|
+
} | {
|
|
462
|
+
readonly type: "file";
|
|
463
|
+
readonly file_id: string;
|
|
464
|
+
};
|
|
465
|
+
readonly cache_control?: {
|
|
466
|
+
readonly type: "ephemeral";
|
|
467
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
468
|
+
} | undefined;
|
|
380
469
|
} | {
|
|
381
470
|
readonly type: "document";
|
|
382
471
|
readonly source: {
|
|
@@ -396,7 +485,7 @@ export declare const routes: (Route<{
|
|
|
396
485
|
};
|
|
397
486
|
readonly cache_control?: {
|
|
398
487
|
readonly type: "ephemeral";
|
|
399
|
-
readonly ttl?:
|
|
488
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
400
489
|
} | undefined;
|
|
401
490
|
readonly title?: string | undefined;
|
|
402
491
|
readonly context?: string | undefined;
|
|
@@ -411,7 +500,7 @@ export declare const routes: (Route<{
|
|
|
411
500
|
readonly text: string;
|
|
412
501
|
readonly cache_control?: {
|
|
413
502
|
readonly type: "ephemeral";
|
|
414
|
-
readonly ttl?:
|
|
503
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
415
504
|
} | undefined;
|
|
416
505
|
} | {
|
|
417
506
|
readonly type: "image";
|
|
@@ -428,11 +517,28 @@ export declare const routes: (Route<{
|
|
|
428
517
|
};
|
|
429
518
|
readonly cache_control?: {
|
|
430
519
|
readonly type: "ephemeral";
|
|
431
|
-
readonly ttl?:
|
|
520
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
432
521
|
} | undefined;
|
|
433
522
|
readonly transformations?: {
|
|
434
523
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
435
524
|
} | undefined;
|
|
525
|
+
} | {
|
|
526
|
+
readonly type: "video";
|
|
527
|
+
readonly source: {
|
|
528
|
+
readonly type: "base64";
|
|
529
|
+
readonly media_type: string;
|
|
530
|
+
readonly data: string;
|
|
531
|
+
} | {
|
|
532
|
+
readonly type: "url";
|
|
533
|
+
readonly url: string;
|
|
534
|
+
} | {
|
|
535
|
+
readonly type: "file";
|
|
536
|
+
readonly file_id: string;
|
|
537
|
+
};
|
|
538
|
+
readonly cache_control?: {
|
|
539
|
+
readonly type: "ephemeral";
|
|
540
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
541
|
+
} | undefined;
|
|
436
542
|
} | {
|
|
437
543
|
readonly type: "document";
|
|
438
544
|
readonly source: {
|
|
@@ -452,7 +558,7 @@ export declare const routes: (Route<{
|
|
|
452
558
|
};
|
|
453
559
|
readonly cache_control?: {
|
|
454
560
|
readonly type: "ephemeral";
|
|
455
|
-
readonly ttl?:
|
|
561
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
456
562
|
} | undefined;
|
|
457
563
|
readonly title?: string | undefined;
|
|
458
564
|
readonly context?: string | undefined;
|
|
@@ -463,7 +569,7 @@ export declare const routes: (Route<{
|
|
|
463
569
|
readonly is_error?: boolean | undefined;
|
|
464
570
|
readonly cache_control?: {
|
|
465
571
|
readonly type: "ephemeral";
|
|
466
|
-
readonly ttl?:
|
|
572
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
467
573
|
} | undefined;
|
|
468
574
|
})[];
|
|
469
575
|
} | {
|
|
@@ -476,7 +582,7 @@ export declare const routes: (Route<{
|
|
|
476
582
|
readonly text: string;
|
|
477
583
|
readonly cache_control?: {
|
|
478
584
|
readonly type: "ephemeral";
|
|
479
|
-
readonly ttl?:
|
|
585
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
480
586
|
} | undefined;
|
|
481
587
|
} | {
|
|
482
588
|
readonly type: "thinking";
|
|
@@ -484,14 +590,14 @@ export declare const routes: (Route<{
|
|
|
484
590
|
readonly signature: string;
|
|
485
591
|
readonly cache_control?: {
|
|
486
592
|
readonly type: "ephemeral";
|
|
487
|
-
readonly ttl?:
|
|
593
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
488
594
|
} | undefined;
|
|
489
595
|
} | {
|
|
490
596
|
readonly type: "redacted_thinking";
|
|
491
597
|
readonly data: string;
|
|
492
598
|
readonly cache_control?: {
|
|
493
599
|
readonly type: "ephemeral";
|
|
494
|
-
readonly ttl?:
|
|
600
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
495
601
|
} | undefined;
|
|
496
602
|
} | {
|
|
497
603
|
readonly type: "tool_use";
|
|
@@ -500,7 +606,7 @@ export declare const routes: (Route<{
|
|
|
500
606
|
readonly input: unknown;
|
|
501
607
|
readonly cache_control?: {
|
|
502
608
|
readonly type: "ephemeral";
|
|
503
|
-
readonly ttl?:
|
|
609
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
504
610
|
} | undefined;
|
|
505
611
|
} | {
|
|
506
612
|
readonly type: "server_tool_use";
|
|
@@ -509,7 +615,7 @@ export declare const routes: (Route<{
|
|
|
509
615
|
readonly input: unknown;
|
|
510
616
|
readonly cache_control?: {
|
|
511
617
|
readonly type: "ephemeral";
|
|
512
|
-
readonly ttl?:
|
|
618
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
513
619
|
} | undefined;
|
|
514
620
|
} | {
|
|
515
621
|
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
@@ -517,7 +623,7 @@ export declare const routes: (Route<{
|
|
|
517
623
|
readonly content: unknown;
|
|
518
624
|
readonly cache_control?: {
|
|
519
625
|
readonly type: "ephemeral";
|
|
520
|
-
readonly ttl?:
|
|
626
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
521
627
|
} | undefined;
|
|
522
628
|
})[];
|
|
523
629
|
} | {
|
|
@@ -527,7 +633,7 @@ export declare const routes: (Route<{
|
|
|
527
633
|
readonly text: string;
|
|
528
634
|
readonly cache_control?: {
|
|
529
635
|
readonly type: "ephemeral";
|
|
530
|
-
readonly ttl?:
|
|
636
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
531
637
|
} | undefined;
|
|
532
638
|
}[];
|
|
533
639
|
readonly output_config?: {
|
|
@@ -542,7 +648,7 @@ export declare const routes: (Route<{
|
|
|
542
648
|
};
|
|
543
649
|
readonly cache_control?: {
|
|
544
650
|
readonly type: "ephemeral";
|
|
545
|
-
readonly ttl?:
|
|
651
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
546
652
|
} | undefined;
|
|
547
653
|
}[] | undefined;
|
|
548
654
|
readonly tool_choice?: {
|
|
@@ -570,7 +676,7 @@ export declare const routes: (Route<{
|
|
|
570
676
|
} | undefined;
|
|
571
677
|
readonly cache_control?: {
|
|
572
678
|
readonly type: "ephemeral";
|
|
573
|
-
readonly ttl?:
|
|
679
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
574
680
|
} | undefined;
|
|
575
681
|
readonly container?: string | {
|
|
576
682
|
readonly id?: string | null | undefined;
|
|
@@ -583,6 +689,7 @@ export declare const routes: (Route<{
|
|
|
583
689
|
readonly user_id?: string | null | undefined;
|
|
584
690
|
} | undefined;
|
|
585
691
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
692
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
586
693
|
readonly thinking?: {
|
|
587
694
|
readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled" | "enabled">;
|
|
588
695
|
} | undefined;
|
|
@@ -686,5 +793,5 @@ export declare const messages: (modelID: string | ModelID) => import("../schema/
|
|
|
686
793
|
} | undefined;
|
|
687
794
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
688
795
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
689
|
-
export declare const model: ProviderPackage.
|
|
796
|
+
export declare const model: ProviderPackage.Model<Settings, ChatOptionsInput>;
|
|
690
797
|
export * as ZAICodingPlan from "./zai-coding-plan.js";
|
|
@@ -53,7 +53,7 @@ export const provider = configure();
|
|
|
53
53
|
export const chat = provider.chat;
|
|
54
54
|
export const messages = provider.messages;
|
|
55
55
|
export const responses = provider.responses;
|
|
56
|
-
export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
|
|
56
|
+
export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions } = {}) => configure({
|
|
57
57
|
apiKey,
|
|
58
58
|
baseURL,
|
|
59
59
|
headers,
|
package/dist/providers/zai.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ProviderPackage } from "../provider-package.js";
|
|
|
2
2
|
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
3
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
5
|
-
import { type ModelID } from "../schema/index.js";
|
|
5
|
+
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
7
|
export type ChatOptionsInput = ZAIChat.OptionsInput;
|
|
8
8
|
export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
@@ -23,6 +23,11 @@ export declare const routes: Route<{
|
|
|
23
23
|
readonly image_url: {
|
|
24
24
|
readonly url: string;
|
|
25
25
|
};
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "video_url";
|
|
28
|
+
readonly video_url: {
|
|
29
|
+
readonly url: string;
|
|
30
|
+
};
|
|
26
31
|
} | {
|
|
27
32
|
readonly type: "file";
|
|
28
33
|
readonly file: {
|
|
@@ -44,6 +49,11 @@ export declare const routes: Route<{
|
|
|
44
49
|
readonly image_url: {
|
|
45
50
|
readonly url: string;
|
|
46
51
|
};
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "video_url";
|
|
54
|
+
readonly video_url: {
|
|
55
|
+
readonly url: string;
|
|
56
|
+
};
|
|
47
57
|
} | {
|
|
48
58
|
readonly type: "file";
|
|
49
59
|
readonly file: {
|
|
@@ -80,7 +90,14 @@ export declare const routes: Route<{
|
|
|
80
90
|
readonly ttl?: string | undefined;
|
|
81
91
|
} | undefined;
|
|
82
92
|
}[] | null;
|
|
83
|
-
readonly tool_calls?: readonly {
|
|
93
|
+
readonly tool_calls?: readonly ({
|
|
94
|
+
readonly id: string;
|
|
95
|
+
readonly type: "custom";
|
|
96
|
+
readonly custom: {
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly input: string;
|
|
99
|
+
};
|
|
100
|
+
} | {
|
|
84
101
|
readonly id: string;
|
|
85
102
|
readonly type: "function";
|
|
86
103
|
readonly function: {
|
|
@@ -92,13 +109,13 @@ export declare const routes: Route<{
|
|
|
92
109
|
readonly thought_signature: string;
|
|
93
110
|
};
|
|
94
111
|
} | undefined;
|
|
95
|
-
}[] | undefined;
|
|
112
|
+
})[] | undefined;
|
|
96
113
|
readonly reasoning_content?: string | undefined;
|
|
97
114
|
readonly reasoning?: string | undefined;
|
|
98
115
|
readonly reasoning_text?: string | undefined;
|
|
99
116
|
readonly reasoning_details?: unknown;
|
|
100
117
|
})[];
|
|
101
|
-
readonly tools?: readonly {
|
|
118
|
+
readonly tools?: readonly ({
|
|
102
119
|
readonly type: "function";
|
|
103
120
|
readonly function: {
|
|
104
121
|
readonly name: string;
|
|
@@ -112,12 +129,36 @@ export declare const routes: Route<{
|
|
|
112
129
|
readonly type: "ephemeral";
|
|
113
130
|
readonly ttl?: string | undefined;
|
|
114
131
|
} | undefined;
|
|
115
|
-
}
|
|
132
|
+
} | {
|
|
133
|
+
readonly type: "custom";
|
|
134
|
+
readonly custom: {
|
|
135
|
+
readonly name: string;
|
|
136
|
+
readonly description: string;
|
|
137
|
+
readonly format: {
|
|
138
|
+
readonly type: "text";
|
|
139
|
+
} | {
|
|
140
|
+
readonly type: "grammar";
|
|
141
|
+
readonly grammar: {
|
|
142
|
+
readonly syntax: "lark" | "regex";
|
|
143
|
+
readonly definition: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
readonly cache_control?: {
|
|
148
|
+
readonly type: "ephemeral";
|
|
149
|
+
readonly ttl?: string | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
})[] | undefined;
|
|
116
152
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
117
153
|
readonly type: "function";
|
|
118
154
|
readonly function: {
|
|
119
155
|
readonly name: string;
|
|
120
156
|
};
|
|
157
|
+
} | {
|
|
158
|
+
readonly type: "custom";
|
|
159
|
+
readonly custom: {
|
|
160
|
+
readonly name: string;
|
|
161
|
+
};
|
|
121
162
|
} | undefined;
|
|
122
163
|
readonly stream: true;
|
|
123
164
|
readonly stream_options?: {
|
|
@@ -125,7 +166,18 @@ export declare const routes: Route<{
|
|
|
125
166
|
} | undefined;
|
|
126
167
|
readonly store?: boolean | undefined;
|
|
127
168
|
readonly prompt_cache_key?: string | undefined;
|
|
169
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
170
|
+
readonly prompt_cache_options?: {
|
|
171
|
+
readonly ttl?: string | undefined;
|
|
172
|
+
} | undefined;
|
|
128
173
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
174
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
175
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
176
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
177
|
+
readonly metadata?: {
|
|
178
|
+
readonly [x: string]: string;
|
|
179
|
+
} | undefined;
|
|
180
|
+
readonly safety_identifier?: string | undefined;
|
|
129
181
|
readonly tool_stream?: boolean | undefined;
|
|
130
182
|
readonly max_completion_tokens?: number | undefined;
|
|
131
183
|
readonly max_tokens?: number | undefined;
|
|
@@ -176,7 +228,7 @@ export declare const configure: (input?: Config) => {
|
|
|
176
228
|
readonly requestID?: string | undefined;
|
|
177
229
|
readonly userID?: string | undefined;
|
|
178
230
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
179
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
231
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
180
232
|
configure: typeof configure;
|
|
181
233
|
};
|
|
182
234
|
export declare const provider: {
|
|
@@ -209,10 +261,10 @@ export declare const provider: {
|
|
|
209
261
|
readonly requestID?: string | undefined;
|
|
210
262
|
readonly userID?: string | undefined;
|
|
211
263
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
212
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
264
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
213
265
|
configure: typeof configure;
|
|
214
266
|
};
|
|
215
|
-
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
267
|
+
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
216
268
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
217
269
|
readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
218
270
|
readonly thinking?: {
|
|
@@ -227,5 +279,6 @@ export declare const chat: (modelID: string | ModelID) => import("../schema/opti
|
|
|
227
279
|
readonly requestID?: string | undefined;
|
|
228
280
|
readonly userID?: string | undefined;
|
|
229
281
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
230
|
-
export declare const model: ProviderPackage.
|
|
282
|
+
export declare const model: ProviderPackage.Model<Settings, ChatOptionsInput>;
|
|
283
|
+
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
231
284
|
export * as ZAI from "./zai.js";
|
package/dist/providers/zai.js
CHANGED
|
@@ -27,7 +27,7 @@ export const configure = (input = {}) => {
|
|
|
27
27
|
})
|
|
28
28
|
.model({ id: modelID, compatibility: ZAIChat.compatibility });
|
|
29
29
|
const media = MediaRoute.deployment(input, auth(input));
|
|
30
|
-
const image = (modelID) => ZAIImages.model({ ...media, id: modelID });
|
|
30
|
+
const image = (modelID, providerOptions) => ZAIImages.model({ ...media, id: modelID, providerOptions });
|
|
31
31
|
return {
|
|
32
32
|
id,
|
|
33
33
|
model: chat,
|
|
@@ -39,11 +39,18 @@ export const configure = (input = {}) => {
|
|
|
39
39
|
export const provider = configure();
|
|
40
40
|
export const image = provider.image;
|
|
41
41
|
export const chat = provider.chat;
|
|
42
|
-
export const model = (modelID,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
export const model = (modelID, settings) => configure(config(settings)).model(modelID);
|
|
43
|
+
export const imageModel = (modelID, settings) => {
|
|
44
|
+
const input = config(settings);
|
|
45
|
+
return configure(input).image(modelID, input.providerOptions);
|
|
46
|
+
};
|
|
47
|
+
function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
|
|
48
|
+
return {
|
|
49
|
+
apiKey,
|
|
50
|
+
baseURL,
|
|
51
|
+
headers,
|
|
52
|
+
http: body === undefined ? undefined : { body },
|
|
53
|
+
providerOptions,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
49
56
|
export * as ZAI from "./zai.js";
|
package/dist/route/auth.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare function header(name: string): (source: Secret | Credential) => D
|
|
|
45
45
|
export declare function header(name: string, source: Secret | Credential): Definition;
|
|
46
46
|
export declare function bearerHeader(name: string): (source: Secret | Credential) => Definition;
|
|
47
47
|
export declare function bearerHeader(name: string, source: Secret | Credential): Definition;
|
|
48
|
-
/** `Authorization: <scheme> <secret>` for providers whose scheme is not `Bearer`, such as
|
|
48
|
+
/** `Authorization: <scheme> <secret>` for providers whose scheme is not `Bearer`, such as Deepgram's `Token`. */
|
|
49
49
|
export declare function scheme(name: string): (source: Secret | Credential) => Definition;
|
|
50
50
|
export declare function scheme(name: string, source: Secret | Credential): Definition;
|
|
51
51
|
export declare const toEffect: (input: Definition) => (authInput: AuthInput) => Effect.Effect<Headers.Headers, AIError>;
|
package/dist/route/client.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ export declare function make<Body, Prepared, Frame, Event, State>(input: MakeTra
|
|
|
193
193
|
* the public surface preemptively.
|
|
194
194
|
*/
|
|
195
195
|
export declare function make<Body, Frame, Event, State>(input: MakeInput<Body, Frame, Event, State>): Route<Body, HttpTransport.HttpPrepared<Frame>>;
|
|
196
|
-
/**
|
|
196
|
+
/** Test-only projection of the execution compiler; exported from `@opencode/ai/testing`. */
|
|
197
197
|
export declare const compileRequest: (request: LLMRequest<LanguageModel<{
|
|
198
198
|
readonly [x: string]: unknown;
|
|
199
199
|
}, CompactionOperations | undefined>>) => Effect.Effect<{
|
|
@@ -220,7 +220,7 @@ export declare const LLMClient: {
|
|
|
220
220
|
readonly canCompact: typeof canCompact;
|
|
221
221
|
readonly compact: typeof compact;
|
|
222
222
|
readonly Service: typeof LLMClientService;
|
|
223
|
-
readonly layer: Layer.Layer<LLMClientService, never,
|
|
223
|
+
readonly layer: Layer.Layer<LLMClientService, never, RequestExecutor.RequestExecutorService>;
|
|
224
224
|
readonly stream: typeof stream;
|
|
225
225
|
readonly generate: typeof generate;
|
|
226
226
|
};
|
package/dist/route/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cause, Context, Effect, Layer, Schema, Stream } from "effect";
|
|
1
|
+
import { Cause, Context, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
2
2
|
import { Auth } from "./auth.js";
|
|
3
3
|
import { Endpoint } from "./endpoint.js";
|
|
4
4
|
import { RequestExecutor } from "./executor.js";
|
|
@@ -91,13 +91,22 @@ const incompleteStreamError = (route) => new AIError({
|
|
|
91
91
|
const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
|
|
92
92
|
let terminal = false;
|
|
93
93
|
return events.pipe(Stream.mapEffect((event) => {
|
|
94
|
-
|
|
94
|
+
// Raw events carry provider frames that may trail the terminal event.
|
|
95
|
+
if (terminal && !LLMEvent.is.raw(event))
|
|
95
96
|
return Effect.fail(ProviderShared.eventError(route, `Provider emitted ${event.type} after the terminal event`));
|
|
96
97
|
if (LLMEvent.is.finish(event) || LLMEvent.is.providerError(event))
|
|
97
98
|
terminal = true;
|
|
98
99
|
return Effect.succeed(event);
|
|
99
100
|
}), Stream.onEnd(Effect.suspend(() => (terminal ? Effect.void : Effect.fail(incompleteStreamError(route))))));
|
|
100
101
|
});
|
|
102
|
+
const decodeJsonOption = Schema.decodeUnknownOption(ProviderShared.Json);
|
|
103
|
+
// JSON text frames are parsed; non-JSON sentinels such as `[DONE]` stay strings.
|
|
104
|
+
const rawFrame = (frame) => typeof frame === "string" ? Option.getOrElse(decodeJsonOption(frame), () => frame) : frame;
|
|
105
|
+
// Transports may interleave their own marker objects with provider frames, e.g. Gemini's continuation boundary.
|
|
106
|
+
const isProviderFrame = (frame) => typeof frame !== "object" ||
|
|
107
|
+
frame === null ||
|
|
108
|
+
Array.isArray(frame) ||
|
|
109
|
+
Object.getPrototypeOf(frame) === Object.prototype;
|
|
101
110
|
function makeFromTransport(input) {
|
|
102
111
|
const protocol = input.protocol;
|
|
103
112
|
const decodeEventEffect = Schema.decodeUnknownEffect(protocol.stream.event);
|
|
@@ -165,7 +174,9 @@ function makeFromTransport(input) {
|
|
|
165
174
|
let state = protocol.stream.initial(request);
|
|
166
175
|
const parsed = events.pipe(Stream.mapEffect(({ event, frame }) => protocol.stream.step(state, event).pipe(Effect.catchCause((cause) => Effect.fail(streamError(route, `Failed to parse ${route} event`, cause))), Effect.map(([next, output]) => {
|
|
167
176
|
state = next;
|
|
168
|
-
return
|
|
177
|
+
return request.includeRaw && isProviderFrame(frame)
|
|
178
|
+
? [LLMEvent.raw({ data: execution.raw?.(frame) ?? rawFrame(frame) }), ...output]
|
|
179
|
+
: output;
|
|
169
180
|
}), Effect.mapError(frameError(frame, event)))), Stream.flatMap(Stream.fromIterable));
|
|
170
181
|
const onHalt = protocol.stream.onHalt;
|
|
171
182
|
return onHalt
|
|
@@ -216,6 +227,17 @@ const prepareRequest = (request) => {
|
|
|
216
227
|
: LLMRequest.update(resolved, { http: mergeHttpOptions(new HttpOptions({ headers }), resolved.http) });
|
|
217
228
|
};
|
|
218
229
|
const compile = Effect.fn("LLM.compile")(function* (request, options) {
|
|
230
|
+
const references = request.messages.flatMap((message) => message.content.flatMap((part) => {
|
|
231
|
+
if (part.type === "media") {
|
|
232
|
+
const source = part.media.source;
|
|
233
|
+
return source.type === "url" ? [source.url] : source.type === "ref" ? [source.id] : [];
|
|
234
|
+
}
|
|
235
|
+
if (part.type !== "tool-result" || part.result.type !== "content")
|
|
236
|
+
return [];
|
|
237
|
+
return part.result.value.flatMap((item) => (item.type === "file" ? [item.uri] : []));
|
|
238
|
+
}));
|
|
239
|
+
if (references.some((reference) => /^\s*file:/i.test(reference)))
|
|
240
|
+
return yield* ProviderShared.invalidRequest("Local file references must be read with Media.file(path) before sending");
|
|
219
241
|
const resolved = prepareRequest(request);
|
|
220
242
|
const route = resolved.model.route;
|
|
221
243
|
const body = yield* route.body.from(resolved);
|
|
@@ -227,7 +249,7 @@ const compile = Effect.fn("LLM.compile")(function* (request, options) {
|
|
|
227
249
|
prepared,
|
|
228
250
|
};
|
|
229
251
|
});
|
|
230
|
-
/**
|
|
252
|
+
/** Test-only projection of the execution compiler; exported from `@opencode/ai/testing`. */
|
|
231
253
|
export const compileRequest = Effect.fn("LLM.compileRequest")(function* (request) {
|
|
232
254
|
const compiled = yield* compile(request);
|
|
233
255
|
return {
|