@opencode/ai 2.1.4 → 2.2.0
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 +283 -114
- 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 +5 -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 +1426 -34
- package/dist/index.js +127 -24
- package/dist/llm.d.ts +16 -1
- package/dist/llm.js +34 -0
- package/dist/media-client.d.ts +2 -1
- 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 +20 -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 +52 -17
- package/dist/protocols/alibaba-responses.d.ts +6 -3
- 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/bfl-images.d.ts +9 -0
- package/dist/protocols/bfl-images.js +17 -15
- 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/fal-images.d.ts +10 -1
- package/dist/protocols/fal-images.js +16 -25
- package/dist/protocols/fal-video.js +1 -1
- 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 +8 -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 +6 -0
- package/dist/protocols/meta-responses.js +29 -1
- package/dist/protocols/open-responses.d.ts +30 -0
- package/dist/protocols/open-responses.js +8 -18
- package/dist/protocols/openai-chat.d.ts +713 -1
- package/dist/protocols/openai-chat.js +35 -22
- package/dist/protocols/openai-compatible-chat.d.ts +22 -1
- package/dist/protocols/openai-compatible-responses.d.ts +8 -5
- package/dist/protocols/openai-decisions.d.ts +22 -0
- package/dist/protocols/openai-decisions.js +128 -0
- package/dist/protocols/openai-images.d.ts +21 -24
- package/dist/protocols/openai-images.js +100 -34
- package/dist/protocols/openai-responses.d.ts +82 -24
- package/dist/protocols/openai-responses.js +32 -2
- 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/replicate-images.js +1 -1
- 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/stability-images.d.ts +5 -0
- package/dist/protocols/stability-images.js +4 -9
- 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 +19 -0
- package/dist/protocols/venice-chat.js +1 -1
- package/dist/protocols/xai-images.d.ts +1 -2
- package/dist/protocols/xai-images.js +9 -2
- package/dist/protocols/xai-responses.d.ts +10 -0
- package/dist/protocols/xai-responses.js +28 -2
- package/dist/protocols/xai-video.d.ts +1 -1
- package/dist/protocols/xai-video.js +11 -8
- package/dist/protocols/zai-chat.d.ts +21 -0
- 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 +19 -4
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +79 -18
- package/dist/providers/alibaba.js +16 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +197 -138
- package/dist/providers/amazon-bedrock.d.ts +34 -14
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +52 -17
- package/dist/providers/anthropic.d.ts +52 -17
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +50 -9
- 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 +51 -1
- package/dist/providers/baseten.js +41 -8
- package/dist/providers/cerebras.d.ts +42 -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 +177 -43
- 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 +55 -1
- package/dist/providers/cloudflare-workers-ai.js +45 -9
- package/dist/providers/cohere.d.ts +42 -0
- package/dist/providers/deepinfra.d.ts +42 -0
- package/dist/providers/deepseek.d.ts +42 -0
- 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.d.ts +72 -1
- package/dist/providers/digitalocean.js +39 -8
- package/dist/providers/fireworks.d.ts +42 -0
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.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-chat.d.ts +21 -0
- package/dist/providers/google-vertex-messages.d.ts +52 -17
- package/dist/providers/google-vertex-responses.d.ts +3 -0
- package/dist/providers/google-vertex.d.ts +3 -1
- package/dist/providers/google-vertex.js +30 -13
- package/dist/providers/google.d.ts +5 -4
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +42 -4
- package/dist/providers/groq.js +0 -6
- package/dist/providers/meta.d.ts +197 -138
- package/dist/providers/minimax.d.ts +76 -17
- package/dist/providers/moonshot.d.ts +76 -17
- 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 +3 -0
- package/dist/providers/openai-compatible.d.ts +24 -1
- package/dist/providers/openai-compatible.js +21 -9
- package/dist/providers/openai-options.d.ts +3 -1
- package/dist/providers/openai.d.ts +46 -9
- package/dist/providers/openai.js +20 -4
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +9 -10
- 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.d.ts +92 -11
- package/dist/providers/openrouter.js +38 -16
- package/dist/providers/togetherai.d.ts +42 -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 +9 -10
- package/dist/providers/typesafe-ai.js +10 -8
- package/dist/providers/venice.d.ts +19 -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/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +10 -16
- package/dist/providers/vercel-ai-gateway.js +31 -85
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +28 -5
- 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.d.ts +76 -17
- package/dist/providers/zai.d.ts +26 -4
- package/dist/providers/zai.js +15 -8
- 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 +1 -0
- package/dist/route/media-protocol.js +12 -8
- package/dist/route/media.d.ts +5 -1
- package/dist/route/media.js +6 -2
- 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 +6 -2
- package/dist/schema/messages.js +3 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +5 -14
- package/dist/speech-client.js +0 -1
- package/dist/speech.d.ts +0 -135
- package/dist/speech.js +2 -4
- package/dist/testing.d.ts +25 -24
- package/dist/testing.js +3 -21
- package/dist/transcription-client.d.ts +5 -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 +5 -14
- package/dist/video-client.js +0 -1
- package/dist/video.d.ts +1 -136
- package/dist/video.js +3 -5
- package/package.json +513 -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/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
|
@@ -4,12 +4,13 @@ import { AlibabaMessages } from "../protocols/alibaba-messages.js";
|
|
|
4
4
|
import { AlibabaResponses } from "../protocols/alibaba-responses.js";
|
|
5
5
|
import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js";
|
|
6
6
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
7
|
-
import { ToolDefinition, type ModelID } from "../schema/index.js";
|
|
7
|
+
import { ToolDefinition, type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
8
8
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
9
9
|
export type Region = "ap-southeast-1" | "cn-beijing" | "cn-hongkong" | "us-east-1" | "eu-central-1" | "ap-northeast-1" | (string & {});
|
|
10
10
|
export type ChatOptionsInput = AlibabaChat.OptionsInput;
|
|
11
11
|
export type MessagesOptionsInput = AlibabaMessages.OptionsInput;
|
|
12
12
|
export type ResponsesOptionsInput = AlibabaResponses.OptionsInput;
|
|
13
|
+
export type { AlibabaImageOptions } from "../protocols/alibaba-images.js";
|
|
13
14
|
type Location = AtLeastOne<{
|
|
14
15
|
readonly region: Region;
|
|
15
16
|
/** Overrides the selected API's complete base URL, including its version prefix. */
|
|
@@ -32,6 +33,11 @@ export declare const routes: (Route<{
|
|
|
32
33
|
readonly image_url: {
|
|
33
34
|
readonly url: string;
|
|
34
35
|
};
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: "video_url";
|
|
38
|
+
readonly video_url: {
|
|
39
|
+
readonly url: string;
|
|
40
|
+
};
|
|
35
41
|
} | {
|
|
36
42
|
readonly type: "file";
|
|
37
43
|
readonly file: {
|
|
@@ -53,6 +59,11 @@ export declare const routes: (Route<{
|
|
|
53
59
|
readonly image_url: {
|
|
54
60
|
readonly url: string;
|
|
55
61
|
};
|
|
62
|
+
} | {
|
|
63
|
+
readonly type: "video_url";
|
|
64
|
+
readonly video_url: {
|
|
65
|
+
readonly url: string;
|
|
66
|
+
};
|
|
56
67
|
} | {
|
|
57
68
|
readonly type: "file";
|
|
58
69
|
readonly file: {
|
|
@@ -134,7 +145,17 @@ export declare const routes: (Route<{
|
|
|
134
145
|
} | undefined;
|
|
135
146
|
readonly store?: boolean | undefined;
|
|
136
147
|
readonly prompt_cache_key?: string | undefined;
|
|
148
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
149
|
+
readonly prompt_cache_options?: {
|
|
150
|
+
readonly ttl?: string | undefined;
|
|
151
|
+
} | undefined;
|
|
137
152
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
153
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
154
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
155
|
+
readonly metadata?: {
|
|
156
|
+
readonly [x: string]: string;
|
|
157
|
+
} | undefined;
|
|
158
|
+
readonly safety_identifier?: string | undefined;
|
|
138
159
|
readonly tool_stream?: boolean | undefined;
|
|
139
160
|
readonly max_completion_tokens?: number | undefined;
|
|
140
161
|
readonly max_tokens?: number | undefined;
|
|
@@ -184,7 +205,7 @@ export declare const routes: (Route<{
|
|
|
184
205
|
readonly text: string;
|
|
185
206
|
readonly cache_control?: {
|
|
186
207
|
readonly type: "ephemeral";
|
|
187
|
-
readonly ttl?:
|
|
208
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
188
209
|
} | undefined;
|
|
189
210
|
}[] | undefined;
|
|
190
211
|
readonly messages: readonly ({
|
|
@@ -194,7 +215,7 @@ export declare const routes: (Route<{
|
|
|
194
215
|
readonly text: string;
|
|
195
216
|
readonly cache_control?: {
|
|
196
217
|
readonly type: "ephemeral";
|
|
197
|
-
readonly ttl?:
|
|
218
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
198
219
|
} | undefined;
|
|
199
220
|
} | {
|
|
200
221
|
readonly type: "image";
|
|
@@ -211,11 +232,28 @@ export declare const routes: (Route<{
|
|
|
211
232
|
};
|
|
212
233
|
readonly cache_control?: {
|
|
213
234
|
readonly type: "ephemeral";
|
|
214
|
-
readonly ttl?:
|
|
235
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
215
236
|
} | undefined;
|
|
216
237
|
readonly transformations?: {
|
|
217
238
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
218
239
|
} | undefined;
|
|
240
|
+
} | {
|
|
241
|
+
readonly type: "video";
|
|
242
|
+
readonly source: {
|
|
243
|
+
readonly type: "base64";
|
|
244
|
+
readonly media_type: string;
|
|
245
|
+
readonly data: string;
|
|
246
|
+
} | {
|
|
247
|
+
readonly type: "url";
|
|
248
|
+
readonly url: string;
|
|
249
|
+
} | {
|
|
250
|
+
readonly type: "file";
|
|
251
|
+
readonly file_id: string;
|
|
252
|
+
};
|
|
253
|
+
readonly cache_control?: {
|
|
254
|
+
readonly type: "ephemeral";
|
|
255
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
256
|
+
} | undefined;
|
|
219
257
|
} | {
|
|
220
258
|
readonly type: "document";
|
|
221
259
|
readonly source: {
|
|
@@ -235,7 +273,7 @@ export declare const routes: (Route<{
|
|
|
235
273
|
};
|
|
236
274
|
readonly cache_control?: {
|
|
237
275
|
readonly type: "ephemeral";
|
|
238
|
-
readonly ttl?:
|
|
276
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
239
277
|
} | undefined;
|
|
240
278
|
readonly title?: string | undefined;
|
|
241
279
|
readonly context?: string | undefined;
|
|
@@ -250,7 +288,7 @@ export declare const routes: (Route<{
|
|
|
250
288
|
readonly text: string;
|
|
251
289
|
readonly cache_control?: {
|
|
252
290
|
readonly type: "ephemeral";
|
|
253
|
-
readonly ttl?:
|
|
291
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
254
292
|
} | undefined;
|
|
255
293
|
} | {
|
|
256
294
|
readonly type: "image";
|
|
@@ -267,11 +305,28 @@ export declare const routes: (Route<{
|
|
|
267
305
|
};
|
|
268
306
|
readonly cache_control?: {
|
|
269
307
|
readonly type: "ephemeral";
|
|
270
|
-
readonly ttl?:
|
|
308
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
271
309
|
} | undefined;
|
|
272
310
|
readonly transformations?: {
|
|
273
311
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
274
312
|
} | undefined;
|
|
313
|
+
} | {
|
|
314
|
+
readonly type: "video";
|
|
315
|
+
readonly source: {
|
|
316
|
+
readonly type: "base64";
|
|
317
|
+
readonly media_type: string;
|
|
318
|
+
readonly data: string;
|
|
319
|
+
} | {
|
|
320
|
+
readonly type: "url";
|
|
321
|
+
readonly url: string;
|
|
322
|
+
} | {
|
|
323
|
+
readonly type: "file";
|
|
324
|
+
readonly file_id: string;
|
|
325
|
+
};
|
|
326
|
+
readonly cache_control?: {
|
|
327
|
+
readonly type: "ephemeral";
|
|
328
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
329
|
+
} | undefined;
|
|
275
330
|
} | {
|
|
276
331
|
readonly type: "document";
|
|
277
332
|
readonly source: {
|
|
@@ -291,7 +346,7 @@ export declare const routes: (Route<{
|
|
|
291
346
|
};
|
|
292
347
|
readonly cache_control?: {
|
|
293
348
|
readonly type: "ephemeral";
|
|
294
|
-
readonly ttl?:
|
|
349
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
295
350
|
} | undefined;
|
|
296
351
|
readonly title?: string | undefined;
|
|
297
352
|
readonly context?: string | undefined;
|
|
@@ -302,7 +357,7 @@ export declare const routes: (Route<{
|
|
|
302
357
|
readonly is_error?: boolean | undefined;
|
|
303
358
|
readonly cache_control?: {
|
|
304
359
|
readonly type: "ephemeral";
|
|
305
|
-
readonly ttl?:
|
|
360
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
306
361
|
} | undefined;
|
|
307
362
|
})[];
|
|
308
363
|
} | {
|
|
@@ -315,7 +370,7 @@ export declare const routes: (Route<{
|
|
|
315
370
|
readonly text: string;
|
|
316
371
|
readonly cache_control?: {
|
|
317
372
|
readonly type: "ephemeral";
|
|
318
|
-
readonly ttl?:
|
|
373
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
319
374
|
} | undefined;
|
|
320
375
|
} | {
|
|
321
376
|
readonly type: "thinking";
|
|
@@ -323,14 +378,14 @@ export declare const routes: (Route<{
|
|
|
323
378
|
readonly signature: string;
|
|
324
379
|
readonly cache_control?: {
|
|
325
380
|
readonly type: "ephemeral";
|
|
326
|
-
readonly ttl?:
|
|
381
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
327
382
|
} | undefined;
|
|
328
383
|
} | {
|
|
329
384
|
readonly type: "redacted_thinking";
|
|
330
385
|
readonly data: string;
|
|
331
386
|
readonly cache_control?: {
|
|
332
387
|
readonly type: "ephemeral";
|
|
333
|
-
readonly ttl?:
|
|
388
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
334
389
|
} | undefined;
|
|
335
390
|
} | {
|
|
336
391
|
readonly type: "tool_use";
|
|
@@ -339,7 +394,7 @@ export declare const routes: (Route<{
|
|
|
339
394
|
readonly input: unknown;
|
|
340
395
|
readonly cache_control?: {
|
|
341
396
|
readonly type: "ephemeral";
|
|
342
|
-
readonly ttl?:
|
|
397
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
343
398
|
} | undefined;
|
|
344
399
|
} | {
|
|
345
400
|
readonly type: "server_tool_use";
|
|
@@ -348,7 +403,7 @@ export declare const routes: (Route<{
|
|
|
348
403
|
readonly input: unknown;
|
|
349
404
|
readonly cache_control?: {
|
|
350
405
|
readonly type: "ephemeral";
|
|
351
|
-
readonly ttl?:
|
|
406
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
352
407
|
} | undefined;
|
|
353
408
|
} | {
|
|
354
409
|
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
@@ -356,7 +411,7 @@ export declare const routes: (Route<{
|
|
|
356
411
|
readonly content: unknown;
|
|
357
412
|
readonly cache_control?: {
|
|
358
413
|
readonly type: "ephemeral";
|
|
359
|
-
readonly ttl?:
|
|
414
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
360
415
|
} | undefined;
|
|
361
416
|
})[];
|
|
362
417
|
} | {
|
|
@@ -366,7 +421,7 @@ export declare const routes: (Route<{
|
|
|
366
421
|
readonly text: string;
|
|
367
422
|
readonly cache_control?: {
|
|
368
423
|
readonly type: "ephemeral";
|
|
369
|
-
readonly ttl?:
|
|
424
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
370
425
|
} | undefined;
|
|
371
426
|
}[];
|
|
372
427
|
readonly output_config?: {
|
|
@@ -381,7 +436,7 @@ export declare const routes: (Route<{
|
|
|
381
436
|
};
|
|
382
437
|
readonly cache_control?: {
|
|
383
438
|
readonly type: "ephemeral";
|
|
384
|
-
readonly ttl?:
|
|
439
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
385
440
|
} | undefined;
|
|
386
441
|
}[] | undefined;
|
|
387
442
|
readonly tool_choice?: {
|
|
@@ -409,7 +464,7 @@ export declare const routes: (Route<{
|
|
|
409
464
|
} | undefined;
|
|
410
465
|
readonly cache_control?: {
|
|
411
466
|
readonly type: "ephemeral";
|
|
412
|
-
readonly ttl?:
|
|
467
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
413
468
|
} | undefined;
|
|
414
469
|
readonly container?: string | {
|
|
415
470
|
readonly id?: string | null | undefined;
|
|
@@ -422,6 +477,7 @@ export declare const routes: (Route<{
|
|
|
422
477
|
readonly user_id?: string | null | undefined;
|
|
423
478
|
} | undefined;
|
|
424
479
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
480
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
425
481
|
readonly thinking?: {
|
|
426
482
|
readonly type: string;
|
|
427
483
|
readonly budget_tokens?: number | undefined;
|
|
@@ -479,6 +535,9 @@ export declare const routes: (Route<{
|
|
|
479
535
|
readonly content: readonly ({
|
|
480
536
|
readonly type: "input_text";
|
|
481
537
|
readonly text: string;
|
|
538
|
+
} | {
|
|
539
|
+
readonly type: "input_video";
|
|
540
|
+
readonly video_url: string;
|
|
482
541
|
} | {
|
|
483
542
|
readonly type: "input_image";
|
|
484
543
|
readonly image_url: string;
|
|
@@ -667,6 +726,7 @@ export declare const configure: (input: Config) => {
|
|
|
667
726
|
readonly previousResponseId?: string | undefined;
|
|
668
727
|
readonly conversation?: string | undefined;
|
|
669
728
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
729
|
+
image: (id: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
|
|
670
730
|
configure: typeof configure;
|
|
671
731
|
};
|
|
672
732
|
export declare const provider: {
|
|
@@ -676,6 +736,7 @@ export declare const provider: {
|
|
|
676
736
|
export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
|
|
677
737
|
export declare const messagesModel: ProviderPackage.Definition<Settings<MessagesOptionsInput>, MessagesOptionsInput>["model"];
|
|
678
738
|
export declare const responsesModel: ProviderPackage.Definition<Settings<ResponsesOptionsInput>, ResponsesOptionsInput>["model"];
|
|
739
|
+
export declare const imageModel: (id: string, settings: Settings) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
|
|
679
740
|
export declare const webSearch: () => ToolDefinition;
|
|
680
741
|
export declare const webExtractor: () => ToolDefinition;
|
|
681
742
|
export declare const codeInterpreter: () => ToolDefinition;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Struct } from "effect";
|
|
2
2
|
import { AlibabaChat } from "../protocols/alibaba-chat.js";
|
|
3
|
+
import { AlibabaImages } from "../protocols/alibaba-images.js";
|
|
3
4
|
import { AlibabaMessages } from "../protocols/alibaba-messages.js";
|
|
4
5
|
import { AlibabaResponses } from "../protocols/alibaba-responses.js";
|
|
5
6
|
import { AuthOptions } from "../route/auth-options.js";
|
|
6
7
|
import { Route } from "../route/client.js";
|
|
7
8
|
import { Endpoint } from "../route/endpoint.js";
|
|
8
9
|
import { Framing } from "../route/framing.js";
|
|
9
|
-
import {
|
|
10
|
+
import { MediaRoute } from "../route/media.js";
|
|
11
|
+
import { ProviderConfigurationError, ProviderID, ToolDefinition, } from "../schema/index.js";
|
|
10
12
|
export const id = ProviderID.make("alibaba");
|
|
11
13
|
const hosts = new Map([
|
|
12
14
|
["ap-southeast-1", "dashscope-intl.aliyuncs.com"],
|
|
@@ -66,19 +68,25 @@ export const configure = (input) => {
|
|
|
66
68
|
})
|
|
67
69
|
.model({ id, compatibility: { requireSignature: false } });
|
|
68
70
|
const responses = (id) => responsesRoute.with(common).model({ id });
|
|
69
|
-
|
|
71
|
+
const media = MediaRoute.deployment({ ...input, baseURL: baseURL ?? `https://${host}/api/v1` }, opts.auth);
|
|
72
|
+
const image = (id, providerOptions) => AlibabaImages.model({ ...media, id, providerOptions });
|
|
73
|
+
return { id, model: chat, chat, messages, responses, image, configure };
|
|
70
74
|
};
|
|
71
75
|
export const provider = { id, configure };
|
|
72
|
-
export const model = (id, input) =>
|
|
73
|
-
export const messagesModel = (id, input) =>
|
|
74
|
-
export const responsesModel = (id, input) =>
|
|
75
|
-
|
|
76
|
+
export const model = (id, input) => configure(config(input)).chat(id);
|
|
77
|
+
export const messagesModel = (id, input) => configure(config(input)).messages(id);
|
|
78
|
+
export const responsesModel = (id, input) => configure(config(input)).responses(id);
|
|
79
|
+
export const imageModel = (id, settings) => {
|
|
80
|
+
const input = config(settings);
|
|
81
|
+
return configure(input).image(id, input.providerOptions);
|
|
82
|
+
};
|
|
83
|
+
function config(input) {
|
|
76
84
|
const { body, ...rest } = input;
|
|
77
|
-
return
|
|
85
|
+
return {
|
|
78
86
|
...rest,
|
|
79
87
|
http: body === undefined ? undefined : { body },
|
|
80
88
|
providerOptions: Struct.omit(rest, ["apiKey", "baseURL", "headers", "region", "workspaceID"]),
|
|
81
|
-
}
|
|
89
|
+
};
|
|
82
90
|
}
|
|
83
91
|
export const webSearch = () => hostedTool("web_search", "Search the web with Alibaba's hosted search tool.");
|
|
84
92
|
export const webExtractor = () => hostedTool("web_extractor", "Extract web page content with Alibaba's hosted tool.");
|