@opencode/ai 2.1.1 → 2.1.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/dist/cache-policy.js +6 -5
- package/dist/experimental/evaluation.d.ts +7 -6
- package/dist/experimental/evaluation.js +2 -3
- package/dist/experimental/realtime.d.ts +59 -0
- package/dist/experimental/realtime.js +32 -19
- package/dist/experimental/system-one.js +8 -8
- package/dist/experimental.d.ts +1 -1
- package/dist/generation.js +1 -1
- package/dist/image-client.d.ts +3 -1
- package/dist/image.d.ts +10 -2
- package/dist/image.js +2 -2
- package/dist/llm.d.ts +2 -4
- package/dist/llm.js +2 -2
- package/dist/media-model.d.ts +2 -2
- package/dist/media-model.js +1 -1
- package/dist/media.js +3 -3
- package/dist/promise.d.ts +1 -1
- package/dist/promise.js +3 -5
- package/dist/protocols/alibaba-chat.d.ts +6 -6
- package/dist/protocols/alibaba-chat.js +3 -3
- package/dist/protocols/alibaba-messages.d.ts +1 -1
- package/dist/protocols/alibaba-messages.js +1 -1
- package/dist/protocols/alibaba-responses.d.ts +3 -3
- package/dist/protocols/anthropic-messages.js +10 -12
- package/dist/protocols/bedrock-converse.d.ts +6 -53
- package/dist/protocols/bedrock-converse.js +4 -3
- package/dist/protocols/bedrock-event-stream.d.ts +6 -1
- package/dist/protocols/bedrock-event-stream.js +9 -8
- package/dist/protocols/cohere-chat.d.ts +6 -2
- package/dist/protocols/cohere-chat.js +2 -2
- package/dist/protocols/gemini.d.ts +12 -2
- package/dist/protocols/gemini.js +10 -13
- package/dist/protocols/google-interactions.d.ts +2 -1
- package/dist/protocols/google-interactions.js +14 -9
- package/dist/protocols/meta-responses.d.ts +6 -6
- package/dist/protocols/mistral-chat.js +1 -4
- package/dist/protocols/open-responses.d.ts +21 -21
- package/dist/protocols/open-responses.js +3 -3
- package/dist/protocols/openai-chat.d.ts +8 -7
- package/dist/protocols/openai-chat.js +4 -5
- package/dist/protocols/openai-compatible-responses.d.ts +3 -3
- package/dist/protocols/openai-responses.d.ts +18 -18
- package/dist/protocols/utils/open-responses-options.d.ts +8 -8
- package/dist/protocols/utils/open-responses-options.js +4 -6
- package/dist/protocols/utils/partial-json.js +5 -4
- package/dist/protocols/utils/tool-schema.d.ts +0 -3
- package/dist/protocols/utils/tool-schema.js +0 -4
- package/dist/protocols/venice-chat.js +6 -6
- package/dist/protocols/xai-images.js +3 -4
- package/dist/protocols/xai-responses.d.ts +3 -3
- package/dist/provider-error.js +4 -5
- package/dist/providers/alibaba.d.ts +30 -30
- package/dist/providers/amazon-bedrock-mantle.d.ts +3 -3
- package/dist/providers/amazon-bedrock.d.ts +11 -8
- package/dist/providers/azure.d.ts +6 -6
- package/dist/providers/cloudflare-ai-gateway.d.ts +7 -7
- package/dist/providers/cloudflare-ai-gateway.js +2 -4
- package/dist/providers/cohere.d.ts +6 -2
- package/dist/providers/google-vertex-interactions.d.ts +3 -3
- package/dist/providers/google-vertex-messages.d.ts +18 -18
- package/dist/providers/google-vertex-mistral.d.ts +3 -3
- package/dist/providers/google-vertex-responses.d.ts +3 -3
- package/dist/providers/google.d.ts +66 -66
- package/dist/providers/meta.d.ts +21 -21
- package/dist/providers/minimax.d.ts +195 -195
- package/dist/providers/moonshot.d.ts +3 -3
- package/dist/providers/openai-compatible-responses.d.ts +3 -3
- package/dist/providers/openai-options.d.ts +3 -3
- package/dist/providers/openai.d.ts +3 -3
- package/dist/providers/openrouter.d.ts +135 -76
- package/dist/providers/openrouter.js +40 -33
- package/dist/providers/vercel-ai-gateway.js +7 -6
- package/dist/providers/zai-coding-plan.d.ts +3 -3
- package/dist/route/client.d.ts +0 -216
- package/dist/route/client.js +1 -5
- package/dist/route/executor-service.d.ts +6 -2
- package/dist/route/executor-service.js +7 -0
- package/dist/route/executor.d.ts +2 -3
- package/dist/route/executor.js +6 -11
- package/dist/route/media-protocol.d.ts +1 -1
- package/dist/route/media-protocol.js +3 -3
- package/dist/route/transport/http.js +5 -8
- package/dist/route/transport/websocket.d.ts +0 -24
- package/dist/route/transport/websocket.js +0 -50
- package/dist/schema/errors.d.ts +9 -8
- package/dist/schema/errors.js +9 -5
- package/dist/schema/messages.js +4 -7
- package/dist/speech-client.d.ts +3 -1
- package/dist/speech.d.ts +10 -2
- package/dist/speech.js +2 -2
- package/dist/transcription-client.d.ts +3 -1
- package/dist/transcription.d.ts +10 -2
- package/dist/transcription.js +2 -2
- package/dist/video-client.d.ts +3 -1
- package/dist/video.d.ts +10 -2
- package/dist/video.js +2 -2
- package/package.json +4 -4
- package/dist/protocols/utils/openai-options.d.ts +0 -16
- package/dist/protocols/utils/openai-options.js +0 -15
|
@@ -4,7 +4,7 @@ import { Media } from "../media.js";
|
|
|
4
4
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
5
5
|
import { MediaRoute } from "../route/media.js";
|
|
6
6
|
import { mergeJsonRecords } from "../schema/index.js";
|
|
7
|
-
import { ProviderShared, optionalNull } from "./shared.js";
|
|
7
|
+
import { JsonObject, ProviderShared, lenient, optionalNull } from "./shared.js";
|
|
8
8
|
import { MediaInput } from "./utils/media-input.js";
|
|
9
9
|
const route = MediaProtocol.identity({ id: "xai-images", name: "xAI Images", provider: "xai" });
|
|
10
10
|
export const DEFAULT_BASE_URL = "https://api.x.ai/v1";
|
|
@@ -20,7 +20,7 @@ const XAIImageResponse = Schema.Struct({
|
|
|
20
20
|
revised_prompt: optionalNull(Schema.String),
|
|
21
21
|
mime_type: optionalNull(Schema.String),
|
|
22
22
|
})),
|
|
23
|
-
usage:
|
|
23
|
+
usage: lenient(JsonObject),
|
|
24
24
|
});
|
|
25
25
|
// ---------------------------------------------------------------------------
|
|
26
26
|
// 5. Request body construction
|
|
@@ -59,12 +59,11 @@ const decodeResponse = Effect.fn("XAIImages.decodeResponse")(function* (response
|
|
|
59
59
|
}));
|
|
60
60
|
if (images.length === 0)
|
|
61
61
|
return yield* output.invalid(`${route.name} returned no images`);
|
|
62
|
-
const usage = ProviderShared.isRecord(decoded.usage) ? decoded.usage : undefined;
|
|
63
62
|
// xAI reports a USD cost (`cost_in_usd_ticks`) rather than tokens, seconds, or credits; the raw record stays in
|
|
64
63
|
// provider metadata.
|
|
65
64
|
return new ImageResponse({
|
|
66
65
|
images,
|
|
67
|
-
providerMetadata: usage === undefined ? undefined : { xai: { usage } },
|
|
66
|
+
providerMetadata: decoded.usage === undefined ? undefined : { xai: { usage: decoded.usage } },
|
|
68
67
|
});
|
|
69
68
|
});
|
|
70
69
|
// ---------------------------------------------------------------------------
|
|
@@ -159,15 +159,15 @@ export declare const protocol: Protocol<{
|
|
|
159
159
|
} | undefined;
|
|
160
160
|
readonly top_logprobs?: number | undefined;
|
|
161
161
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
162
|
-
readonly service_tier?: import("
|
|
162
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
163
163
|
readonly prompt_cache_key?: string | undefined;
|
|
164
|
-
readonly include?: readonly import("
|
|
164
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
165
165
|
readonly reasoning?: {
|
|
166
166
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
167
167
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
168
168
|
} | undefined;
|
|
169
169
|
readonly text?: {
|
|
170
|
-
readonly verbosity?: import("
|
|
170
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
171
171
|
} | undefined;
|
|
172
172
|
readonly max_output_tokens?: number | undefined;
|
|
173
173
|
readonly max_tool_calls?: number | undefined;
|
package/dist/provider-error.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Option, Schema, SchemaGetter } from "effect";
|
|
2
2
|
import { AuthenticationError, ContentPolicyError, InvalidRequestError, AIError, ProviderErrorEvent, ProviderInternalError, QuotaExceededError, RateLimitError, UnknownProviderError, } from "./schema/index.js";
|
|
3
|
+
import { Json } from "./utils/json.js";
|
|
4
|
+
import { isRecord } from "./utils/record.js";
|
|
3
5
|
const patterns = [
|
|
4
6
|
/prompt is too long/i,
|
|
5
7
|
/input is too long for requested model/i,
|
|
@@ -93,7 +95,7 @@ export const isRetryable = (error) => {
|
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
};
|
|
96
|
-
const decodeJson = Schema.decodeUnknownOption(
|
|
98
|
+
const decodeJson = Schema.decodeUnknownOption(Json);
|
|
97
99
|
// OpenCode Zen reports account caps as typed 429/402 errors that are not throttles.
|
|
98
100
|
const QUOTA_CODES = new Set([
|
|
99
101
|
"insufficient_quota",
|
|
@@ -201,7 +203,7 @@ export function classifyProviderFailure(input) {
|
|
|
201
203
|
if (input.status === 402 ||
|
|
202
204
|
codes.some((code) => QUOTA_CODES.has(code)) ||
|
|
203
205
|
(input.status === 429 && QUOTA_TEXT.test(text)))
|
|
204
|
-
return new QuotaExceededError(details);
|
|
206
|
+
return new QuotaExceededError({ ...details, retryAfterMs: input.retryAfterMs });
|
|
205
207
|
if (input.status === 401 ||
|
|
206
208
|
input.status === 403 ||
|
|
207
209
|
codes.some((code) => AUTH_CODES.has(code)) ||
|
|
@@ -265,6 +267,3 @@ function providerCodes(value) {
|
|
|
265
267
|
exception?.type,
|
|
266
268
|
].filter((value) => typeof value === "string");
|
|
267
269
|
}
|
|
268
|
-
function isRecord(value) {
|
|
269
|
-
return typeof value === "object" && value !== null;
|
|
270
|
-
}
|
|
@@ -149,13 +149,13 @@ export declare const routes: (Route<{
|
|
|
149
149
|
readonly preserve_thinking?: boolean | undefined;
|
|
150
150
|
readonly clear_thinking?: boolean | undefined;
|
|
151
151
|
readonly thinking?: {
|
|
152
|
-
readonly type: "adaptive" | "disabled"
|
|
152
|
+
readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
|
|
153
153
|
} | undefined;
|
|
154
154
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
155
155
|
readonly repetition_penalty?: number | undefined;
|
|
156
156
|
readonly top_k?: number | undefined;
|
|
157
157
|
readonly response_format?: {
|
|
158
|
-
readonly type: "json_object" | "json_schema" | "text"
|
|
158
|
+
readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
|
|
159
159
|
readonly json_schema?: {
|
|
160
160
|
readonly [x: string]: unknown;
|
|
161
161
|
} | undefined;
|
|
@@ -163,7 +163,7 @@ export declare const routes: (Route<{
|
|
|
163
163
|
readonly enable_search?: boolean | undefined;
|
|
164
164
|
readonly search_options?: {
|
|
165
165
|
readonly forced_search?: boolean | undefined;
|
|
166
|
-
readonly search_strategy?: "agent" | "agent_max" | "max" | "turbo" |
|
|
166
|
+
readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
|
|
167
167
|
readonly enable_search_extension?: boolean | undefined;
|
|
168
168
|
} | undefined;
|
|
169
169
|
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
|
|
@@ -314,6 +314,24 @@ export declare const routes: (Route<{
|
|
|
314
314
|
readonly type: "ephemeral";
|
|
315
315
|
readonly ttl?: "1h" | "5m" | undefined;
|
|
316
316
|
} | undefined;
|
|
317
|
+
} | {
|
|
318
|
+
readonly type: "tool_use";
|
|
319
|
+
readonly id: string;
|
|
320
|
+
readonly name: string;
|
|
321
|
+
readonly input: unknown;
|
|
322
|
+
readonly cache_control?: {
|
|
323
|
+
readonly type: "ephemeral";
|
|
324
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
325
|
+
} | undefined;
|
|
326
|
+
} | {
|
|
327
|
+
readonly type: "server_tool_use";
|
|
328
|
+
readonly id: string;
|
|
329
|
+
readonly name: string;
|
|
330
|
+
readonly input: unknown;
|
|
331
|
+
readonly cache_control?: {
|
|
332
|
+
readonly type: "ephemeral";
|
|
333
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
334
|
+
} | undefined;
|
|
317
335
|
} | {
|
|
318
336
|
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
319
337
|
readonly tool_use_id: string;
|
|
@@ -340,24 +358,6 @@ export declare const routes: (Route<{
|
|
|
340
358
|
readonly type: "ephemeral";
|
|
341
359
|
readonly ttl?: "1h" | "5m" | undefined;
|
|
342
360
|
} | undefined;
|
|
343
|
-
} | {
|
|
344
|
-
readonly type: "tool_use";
|
|
345
|
-
readonly id: string;
|
|
346
|
-
readonly name: string;
|
|
347
|
-
readonly input: unknown;
|
|
348
|
-
readonly cache_control?: {
|
|
349
|
-
readonly type: "ephemeral";
|
|
350
|
-
readonly ttl?: "1h" | "5m" | undefined;
|
|
351
|
-
} | undefined;
|
|
352
|
-
} | {
|
|
353
|
-
readonly type: "server_tool_use";
|
|
354
|
-
readonly id: string;
|
|
355
|
-
readonly name: string;
|
|
356
|
-
readonly input: unknown;
|
|
357
|
-
readonly cache_control?: {
|
|
358
|
-
readonly type: "ephemeral";
|
|
359
|
-
readonly ttl?: "1h" | "5m" | undefined;
|
|
360
|
-
} | undefined;
|
|
361
361
|
})[];
|
|
362
362
|
} | {
|
|
363
363
|
readonly role: "system";
|
|
@@ -585,15 +585,15 @@ export declare const routes: (Route<{
|
|
|
585
585
|
} | undefined;
|
|
586
586
|
readonly top_logprobs?: number | undefined;
|
|
587
587
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
588
|
-
readonly service_tier?: import("../
|
|
588
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
589
589
|
readonly prompt_cache_key?: string | undefined;
|
|
590
|
-
readonly include?: readonly import("../
|
|
590
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
591
591
|
readonly reasoning?: {
|
|
592
592
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
593
593
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
594
594
|
} | undefined;
|
|
595
595
|
readonly text?: {
|
|
596
|
-
readonly verbosity?: import("../
|
|
596
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
597
597
|
} | undefined;
|
|
598
598
|
readonly max_output_tokens?: number | undefined;
|
|
599
599
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -616,13 +616,13 @@ export declare const configure: (input: Config) => {
|
|
|
616
616
|
readonly preserveThinking?: boolean | undefined;
|
|
617
617
|
readonly clearThinking?: boolean | undefined;
|
|
618
618
|
readonly thinking?: {
|
|
619
|
-
readonly type: "adaptive" | "disabled"
|
|
619
|
+
readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
|
|
620
620
|
} | undefined;
|
|
621
621
|
readonly toolStream?: boolean | undefined;
|
|
622
622
|
readonly parallelToolCalls?: boolean | undefined;
|
|
623
623
|
readonly repetitionPenalty?: number | undefined;
|
|
624
624
|
readonly responseFormat?: {
|
|
625
|
-
readonly type: "json_object" | "json_schema" | "text"
|
|
625
|
+
readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
|
|
626
626
|
readonly json_schema?: {
|
|
627
627
|
readonly [x: string]: unknown;
|
|
628
628
|
} | undefined;
|
|
@@ -630,7 +630,7 @@ export declare const configure: (input: Config) => {
|
|
|
630
630
|
readonly enableSearch?: boolean | undefined;
|
|
631
631
|
readonly searchOptions?: {
|
|
632
632
|
readonly forced_search?: boolean | undefined;
|
|
633
|
-
readonly search_strategy?: "agent" | "agent_max" | "max" | "turbo" |
|
|
633
|
+
readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
|
|
634
634
|
readonly enable_search_extension?: boolean | undefined;
|
|
635
635
|
} | undefined;
|
|
636
636
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
@@ -641,13 +641,13 @@ export declare const configure: (input: Config) => {
|
|
|
641
641
|
readonly preserveThinking?: boolean | undefined;
|
|
642
642
|
readonly clearThinking?: boolean | undefined;
|
|
643
643
|
readonly thinking?: {
|
|
644
|
-
readonly type: "adaptive" | "disabled"
|
|
644
|
+
readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
|
|
645
645
|
} | undefined;
|
|
646
646
|
readonly toolStream?: boolean | undefined;
|
|
647
647
|
readonly parallelToolCalls?: boolean | undefined;
|
|
648
648
|
readonly repetitionPenalty?: number | undefined;
|
|
649
649
|
readonly responseFormat?: {
|
|
650
|
-
readonly type: "json_object" | "json_schema" | "text"
|
|
650
|
+
readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
|
|
651
651
|
readonly json_schema?: {
|
|
652
652
|
readonly [x: string]: unknown;
|
|
653
653
|
} | undefined;
|
|
@@ -655,7 +655,7 @@ export declare const configure: (input: Config) => {
|
|
|
655
655
|
readonly enableSearch?: boolean | undefined;
|
|
656
656
|
readonly searchOptions?: {
|
|
657
657
|
readonly forced_search?: boolean | undefined;
|
|
658
|
-
readonly search_strategy?: "agent" | "agent_max" | "max" | "turbo" |
|
|
658
|
+
readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
|
|
659
659
|
readonly enable_search_extension?: boolean | undefined;
|
|
660
660
|
} | undefined;
|
|
661
661
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
@@ -189,15 +189,15 @@ export declare const routes: (Route<{
|
|
|
189
189
|
} | undefined;
|
|
190
190
|
readonly top_logprobs?: number | undefined;
|
|
191
191
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
192
|
-
readonly service_tier?: import("../
|
|
192
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
193
193
|
readonly prompt_cache_key?: string | undefined;
|
|
194
|
-
readonly include?: readonly import("../
|
|
194
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
195
195
|
readonly reasoning?: {
|
|
196
196
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
197
197
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
198
198
|
} | undefined;
|
|
199
199
|
readonly text?: {
|
|
200
|
-
readonly verbosity?: import("../
|
|
200
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
201
201
|
} | undefined;
|
|
202
202
|
readonly max_output_tokens?: number | undefined;
|
|
203
203
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -34,13 +34,6 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
34
34
|
readonly messages: readonly ({
|
|
35
35
|
readonly role: "user";
|
|
36
36
|
readonly content: readonly ({
|
|
37
|
-
readonly text: string;
|
|
38
|
-
} | {
|
|
39
|
-
readonly cachePoint: {
|
|
40
|
-
readonly type: "default";
|
|
41
|
-
readonly ttl?: "1h" | "5m" | undefined;
|
|
42
|
-
};
|
|
43
|
-
} | {
|
|
44
37
|
readonly image: {
|
|
45
38
|
readonly format: "gif" | "jpeg" | "png" | "webp";
|
|
46
39
|
readonly source: {
|
|
@@ -55,6 +48,13 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
55
48
|
readonly bytes: string;
|
|
56
49
|
};
|
|
57
50
|
};
|
|
51
|
+
} | {
|
|
52
|
+
readonly text: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly cachePoint: {
|
|
55
|
+
readonly type: "default";
|
|
56
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
57
|
+
};
|
|
58
58
|
} | {
|
|
59
59
|
readonly toolResult: {
|
|
60
60
|
readonly toolUseId: string;
|
|
@@ -151,7 +151,10 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
151
151
|
readonly additionalModelRequestFields?: {
|
|
152
152
|
readonly [x: string]: unknown;
|
|
153
153
|
} | undefined;
|
|
154
|
-
}, import("../route/transport/http.js").HttpPrepared<
|
|
154
|
+
}, import("../route/transport/http.js").HttpPrepared<{
|
|
155
|
+
readonly [x: string]: unknown;
|
|
156
|
+
readonly rawBody: string;
|
|
157
|
+
}>, import("../route/client.js").CompactionOperations | undefined>[];
|
|
155
158
|
export declare const configure: (input?: Config) => {
|
|
156
159
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
157
160
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
@@ -157,15 +157,15 @@ declare const responsesRoute: Route<{
|
|
|
157
157
|
} | undefined;
|
|
158
158
|
readonly top_logprobs?: number | undefined;
|
|
159
159
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
160
|
-
readonly service_tier?: import("../
|
|
160
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
161
161
|
readonly prompt_cache_key?: string | undefined;
|
|
162
|
-
readonly include?: readonly import("../
|
|
162
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
163
163
|
readonly reasoning?: {
|
|
164
164
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
165
165
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
166
166
|
} | undefined;
|
|
167
167
|
readonly text?: {
|
|
168
|
-
readonly verbosity?: import("../
|
|
168
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
169
169
|
} | undefined;
|
|
170
170
|
readonly max_output_tokens?: number | undefined;
|
|
171
171
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -484,15 +484,15 @@ export declare const routes: (Route<{
|
|
|
484
484
|
} | undefined;
|
|
485
485
|
readonly top_logprobs?: number | undefined;
|
|
486
486
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
487
|
-
readonly service_tier?: import("../
|
|
487
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
488
488
|
readonly prompt_cache_key?: string | undefined;
|
|
489
|
-
readonly include?: readonly import("../
|
|
489
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
490
490
|
readonly reasoning?: {
|
|
491
491
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
492
492
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
493
493
|
} | undefined;
|
|
494
494
|
readonly text?: {
|
|
495
|
-
readonly verbosity?: import("../
|
|
495
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
496
496
|
} | undefined;
|
|
497
497
|
readonly max_output_tokens?: number | undefined;
|
|
498
498
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Config, Redacted } from "effect";
|
|
2
2
|
import type { ProviderPackage } from "../provider-package.js";
|
|
3
3
|
import type { AtLeastOne, ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import type { RouteDefaultsInput } from "../route/client.js";
|
|
@@ -163,15 +163,15 @@ export declare const responsesRoute: import("../route/client.js").Route<{
|
|
|
163
163
|
} | undefined;
|
|
164
164
|
readonly top_logprobs?: number | undefined;
|
|
165
165
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
166
|
-
readonly service_tier?: import("../
|
|
166
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
167
167
|
readonly prompt_cache_key?: string | undefined;
|
|
168
|
-
readonly include?: readonly import("../
|
|
168
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
169
169
|
readonly reasoning?: {
|
|
170
170
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
171
171
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
172
172
|
} | undefined;
|
|
173
173
|
readonly text?: {
|
|
174
|
-
readonly verbosity?: import("../
|
|
174
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
175
175
|
} | undefined;
|
|
176
176
|
readonly max_output_tokens?: number | undefined;
|
|
177
177
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -1158,15 +1158,15 @@ export declare const routes: (import("../route/client.js").Route<{
|
|
|
1158
1158
|
} | undefined;
|
|
1159
1159
|
readonly top_logprobs?: number | undefined;
|
|
1160
1160
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1161
|
-
readonly service_tier?: import("../
|
|
1161
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1162
1162
|
readonly prompt_cache_key?: string | undefined;
|
|
1163
|
-
readonly include?: readonly import("../
|
|
1163
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
1164
1164
|
readonly reasoning?: {
|
|
1165
1165
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
1166
1166
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1167
1167
|
} | undefined;
|
|
1168
1168
|
readonly text?: {
|
|
1169
|
-
readonly verbosity?: import("../
|
|
1169
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1170
1170
|
} | undefined;
|
|
1171
1171
|
readonly max_output_tokens?: number | undefined;
|
|
1172
1172
|
readonly max_tool_calls?: number | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
1
|
import { AnthropicMessages, OpenAIChat, OpenAIResponses } from "../protocols/index.js";
|
|
3
2
|
import { Auth } from "../route/auth.js";
|
|
4
3
|
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
4
|
+
import { encodeJson } from "../utils/json.js";
|
|
5
5
|
export const id = ProviderID.make("cloudflare-ai-gateway");
|
|
6
6
|
export const authEnvVars = ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"];
|
|
7
7
|
export const baseURL = (input) => {
|
|
@@ -41,9 +41,7 @@ const credential = (input) => Auth.optional(input.gatewayApiKey ?? ("apiKey" in
|
|
|
41
41
|
.orElse(Auth.config(authEnvVars[0]))
|
|
42
42
|
.orElse(Auth.config(authEnvVars[1]));
|
|
43
43
|
const headers = (input) => ({
|
|
44
|
-
...(input.metadata === undefined
|
|
45
|
-
? {}
|
|
46
|
-
: { "cf-aig-metadata": Schema.encodeSync(Schema.fromJsonString(Schema.Unknown))(input.metadata) }),
|
|
44
|
+
...(input.metadata === undefined ? {} : { "cf-aig-metadata": encodeJson(input.metadata) }),
|
|
47
45
|
...(input.cacheTtl === undefined ? {} : { "cf-aig-cache-ttl": String(input.cacheTtl) }),
|
|
48
46
|
...(input.cacheKey === undefined ? {} : { "cf-aig-cache-key": input.cacheKey }),
|
|
49
47
|
...(input.skipCache === undefined ? {} : { "cf-aig-skip-cache": String(input.skipCache) }),
|
|
@@ -49,7 +49,9 @@ export declare const route: Route<{
|
|
|
49
49
|
readonly function: {
|
|
50
50
|
readonly name: string;
|
|
51
51
|
readonly description?: string | undefined;
|
|
52
|
-
readonly parameters:
|
|
52
|
+
readonly parameters: {
|
|
53
|
+
readonly [x: string]: unknown;
|
|
54
|
+
};
|
|
53
55
|
};
|
|
54
56
|
}[] | undefined;
|
|
55
57
|
readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
|
|
@@ -342,7 +344,9 @@ export declare const routes: (Route<{
|
|
|
342
344
|
readonly function: {
|
|
343
345
|
readonly name: string;
|
|
344
346
|
readonly description?: string | undefined;
|
|
345
|
-
readonly parameters:
|
|
347
|
+
readonly parameters: {
|
|
348
|
+
readonly [x: string]: unknown;
|
|
349
|
+
};
|
|
346
350
|
};
|
|
347
351
|
}[] | undefined;
|
|
348
352
|
readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
|
|
@@ -27,13 +27,13 @@ export declare const routes: Route<{
|
|
|
27
27
|
readonly input: readonly ({
|
|
28
28
|
readonly type: "model_output" | "user_input";
|
|
29
29
|
readonly content: readonly ({
|
|
30
|
+
readonly type: "text";
|
|
31
|
+
readonly text: string;
|
|
32
|
+
} | {
|
|
30
33
|
readonly type: "audio" | "document" | "image" | "video";
|
|
31
34
|
readonly data?: string | undefined;
|
|
32
35
|
readonly uri?: string | undefined;
|
|
33
36
|
readonly mime_type: string;
|
|
34
|
-
} | {
|
|
35
|
-
readonly type: "text";
|
|
36
|
-
readonly text: string;
|
|
37
37
|
})[];
|
|
38
38
|
} | {
|
|
39
39
|
readonly type: "thought";
|
|
@@ -167,24 +167,6 @@ export declare const routes: Route<{
|
|
|
167
167
|
readonly type: "ephemeral";
|
|
168
168
|
readonly ttl?: "1h" | "5m" | undefined;
|
|
169
169
|
} | undefined;
|
|
170
|
-
} | {
|
|
171
|
-
readonly type: "tool_use";
|
|
172
|
-
readonly id: string;
|
|
173
|
-
readonly name: string;
|
|
174
|
-
readonly input: unknown;
|
|
175
|
-
readonly cache_control?: {
|
|
176
|
-
readonly type: "ephemeral";
|
|
177
|
-
readonly ttl?: "1h" | "5m" | undefined;
|
|
178
|
-
} | undefined;
|
|
179
|
-
} | {
|
|
180
|
-
readonly type: "server_tool_use";
|
|
181
|
-
readonly id: string;
|
|
182
|
-
readonly name: string;
|
|
183
|
-
readonly input: unknown;
|
|
184
|
-
readonly cache_control?: {
|
|
185
|
-
readonly type: "ephemeral";
|
|
186
|
-
readonly ttl?: "1h" | "5m" | undefined;
|
|
187
|
-
} | undefined;
|
|
188
170
|
} | {
|
|
189
171
|
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
190
172
|
readonly tool_use_id: string;
|
|
@@ -211,6 +193,24 @@ export declare const routes: Route<{
|
|
|
211
193
|
readonly type: "ephemeral";
|
|
212
194
|
readonly ttl?: "1h" | "5m" | undefined;
|
|
213
195
|
} | undefined;
|
|
196
|
+
} | {
|
|
197
|
+
readonly type: "tool_use";
|
|
198
|
+
readonly id: string;
|
|
199
|
+
readonly name: string;
|
|
200
|
+
readonly input: unknown;
|
|
201
|
+
readonly cache_control?: {
|
|
202
|
+
readonly type: "ephemeral";
|
|
203
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
204
|
+
} | undefined;
|
|
205
|
+
} | {
|
|
206
|
+
readonly type: "server_tool_use";
|
|
207
|
+
readonly id: string;
|
|
208
|
+
readonly name: string;
|
|
209
|
+
readonly input: unknown;
|
|
210
|
+
readonly cache_control?: {
|
|
211
|
+
readonly type: "ephemeral";
|
|
212
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
213
|
+
} | undefined;
|
|
214
214
|
})[];
|
|
215
215
|
} | {
|
|
216
216
|
readonly role: "system";
|
|
@@ -41,9 +41,6 @@ export declare const routes: Route<{
|
|
|
41
41
|
} | {
|
|
42
42
|
readonly role: "assistant";
|
|
43
43
|
readonly content: string | readonly ({
|
|
44
|
-
readonly type: "text";
|
|
45
|
-
readonly text: string;
|
|
46
|
-
} | {
|
|
47
44
|
readonly [x: string]: unknown;
|
|
48
45
|
readonly type: "thinking";
|
|
49
46
|
readonly thinking: readonly {
|
|
@@ -51,6 +48,9 @@ export declare const routes: Route<{
|
|
|
51
48
|
readonly type?: string | undefined;
|
|
52
49
|
readonly text?: string | undefined;
|
|
53
50
|
}[];
|
|
51
|
+
} | {
|
|
52
|
+
readonly type: "text";
|
|
53
|
+
readonly text: string;
|
|
54
54
|
})[];
|
|
55
55
|
readonly tool_calls?: readonly {
|
|
56
56
|
readonly id: string;
|
|
@@ -176,15 +176,15 @@ export declare const routes: Route<{
|
|
|
176
176
|
} | undefined;
|
|
177
177
|
readonly top_logprobs?: number | undefined;
|
|
178
178
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
179
|
-
readonly service_tier?: import("../
|
|
179
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
180
180
|
readonly prompt_cache_key?: string | undefined;
|
|
181
|
-
readonly include?: readonly import("../
|
|
181
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
182
182
|
readonly reasoning?: {
|
|
183
183
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
184
184
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
185
185
|
} | undefined;
|
|
186
186
|
readonly text?: {
|
|
187
|
-
readonly verbosity?: import("../
|
|
187
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
188
188
|
} | undefined;
|
|
189
189
|
readonly max_output_tokens?: number | undefined;
|
|
190
190
|
readonly max_tool_calls?: number | undefined;
|