@opencode/ai 2.0.19 → 2.0.21
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 +21 -3
- package/dist/llm.d.ts +1 -1
- package/dist/promise.d.ts +2 -2
- package/dist/protocols/alibaba-chat.d.ts +16 -10
- package/dist/protocols/alibaba-responses.d.ts +14 -14
- package/dist/protocols/anthropic-messages.js +2 -15
- package/dist/protocols/bedrock-converse.d.ts +1 -1
- package/dist/protocols/bedrock-converse.js +38 -12
- package/dist/protocols/meta-messages.d.ts +5 -1
- package/dist/protocols/meta-messages.js +11 -4
- package/dist/protocols/meta-responses.d.ts +16 -16
- package/dist/protocols/mistral-chat.d.ts +6 -0
- package/dist/protocols/mistral-chat.js +8 -5
- package/dist/protocols/open-responses.d.ts +31 -31
- package/dist/protocols/openai-chat.d.ts +114 -71
- package/dist/protocols/openai-chat.js +31 -32
- package/dist/protocols/openai-compatible-chat.d.ts +16 -10
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-responses.d.ts +22 -22
- package/dist/protocols/utils/claude-model.d.ts +8 -0
- package/dist/protocols/utils/claude-model.js +15 -0
- package/dist/protocols/utils/tool-stream.d.ts +3 -3
- package/dist/protocols/xai-responses.d.ts +14 -14
- package/dist/protocols/zai-chat.d.ts +16 -10
- package/dist/provider-error.d.ts +1 -0
- package/dist/provider-error.js +23 -1
- package/dist/providers/alibaba.d.ts +18 -12
- package/dist/providers/amazon-bedrock-mantle.d.ts +18 -12
- package/dist/providers/azure.d.ts +20 -14
- package/dist/providers/baseten.d.ts +32 -20
- package/dist/providers/cerebras.d.ts +32 -20
- package/dist/providers/cloudflare-ai-gateway.d.ts +36 -24
- package/dist/providers/cloudflare-ai-gateway.js +43 -35
- package/dist/providers/cloudflare-workers-ai.d.ts +32 -20
- package/dist/providers/deepinfra.d.ts +32 -20
- package/dist/providers/deepseek.d.ts +32 -20
- package/dist/providers/fireworks.d.ts +32 -20
- package/dist/providers/google-vertex-chat.d.ts +16 -10
- package/dist/providers/google-vertex-responses.d.ts +2 -2
- package/dist/providers/groq.d.ts +32 -20
- package/dist/providers/meta.d.ts +23 -13
- package/dist/providers/minimax.d.ts +18 -12
- package/dist/providers/moonshot.d.ts +18 -12
- package/dist/providers/openai-compatible-responses.d.ts +2 -2
- package/dist/providers/openai-compatible.d.ts +16 -10
- package/dist/providers/openai.d.ts +18 -12
- package/dist/providers/openrouter.d.ts +64 -40
- package/dist/providers/togetherai.d.ts +32 -20
- package/dist/providers/xai.d.ts +16 -10
- package/dist/providers/zai-coding-plan.d.ts +18 -12
- package/dist/providers/zai.d.ts +16 -10
- package/dist/route/client.d.ts +1 -1
- package/dist/route/executor.js +12 -8
- package/dist/schema/events.d.ts +30 -30
- package/dist/testing.d.ts +8 -8
- package/package.json +3 -3
|
@@ -291,8 +291,8 @@ export declare const protocol: Protocol<{
|
|
|
291
291
|
} | {
|
|
292
292
|
readonly type: "input_file";
|
|
293
293
|
readonly filename: string;
|
|
294
|
-
readonly file_data?: string | undefined;
|
|
295
294
|
readonly detail?: string | undefined;
|
|
295
|
+
readonly file_data?: string | undefined;
|
|
296
296
|
readonly file_url?: string | undefined;
|
|
297
297
|
} | {
|
|
298
298
|
readonly type: "input_text";
|
|
@@ -328,8 +328,8 @@ export declare const protocol: Protocol<{
|
|
|
328
328
|
} | {
|
|
329
329
|
readonly type: "input_file";
|
|
330
330
|
readonly filename: string;
|
|
331
|
-
readonly file_data?: string | undefined;
|
|
332
331
|
readonly detail?: string | undefined;
|
|
332
|
+
readonly file_data?: string | undefined;
|
|
333
333
|
readonly file_url?: string | undefined;
|
|
334
334
|
} | {
|
|
335
335
|
readonly type: "input_text";
|
|
@@ -450,21 +450,10 @@ export declare const protocol: Protocol<{
|
|
|
450
450
|
readonly [x: string]: unknown;
|
|
451
451
|
readonly type: string;
|
|
452
452
|
readonly status?: unknown;
|
|
453
|
-
readonly code?: unknown;
|
|
454
453
|
readonly message?: unknown;
|
|
454
|
+
readonly code?: unknown;
|
|
455
455
|
readonly text?: string | undefined;
|
|
456
456
|
readonly error?: unknown;
|
|
457
|
-
readonly item?: {
|
|
458
|
-
readonly [x: string]: unknown;
|
|
459
|
-
readonly type: string;
|
|
460
|
-
readonly id?: string | undefined;
|
|
461
|
-
readonly name?: string | undefined;
|
|
462
|
-
readonly namespace?: string | undefined;
|
|
463
|
-
readonly arguments?: string | undefined;
|
|
464
|
-
readonly encrypted_content?: string | null | undefined;
|
|
465
|
-
readonly call_id?: string | undefined;
|
|
466
|
-
} | null | undefined;
|
|
467
|
-
readonly delta?: string | undefined;
|
|
468
457
|
readonly response?: {
|
|
469
458
|
readonly [x: string]: unknown;
|
|
470
459
|
readonly id?: string | undefined;
|
|
@@ -496,6 +485,17 @@ export declare const protocol: Protocol<{
|
|
|
496
485
|
readonly reason?: string | undefined;
|
|
497
486
|
} | null | undefined;
|
|
498
487
|
} | undefined;
|
|
488
|
+
readonly item?: {
|
|
489
|
+
readonly [x: string]: unknown;
|
|
490
|
+
readonly type: string;
|
|
491
|
+
readonly id?: string | undefined;
|
|
492
|
+
readonly name?: string | undefined;
|
|
493
|
+
readonly namespace?: string | undefined;
|
|
494
|
+
readonly arguments?: string | undefined;
|
|
495
|
+
readonly encrypted_content?: string | null | undefined;
|
|
496
|
+
readonly call_id?: string | undefined;
|
|
497
|
+
} | null | undefined;
|
|
498
|
+
readonly delta?: string | undefined;
|
|
499
499
|
readonly arguments?: string | undefined;
|
|
500
500
|
readonly item_id?: string | undefined;
|
|
501
501
|
readonly output_index?: number | undefined;
|
|
@@ -574,8 +574,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
574
574
|
} | {
|
|
575
575
|
readonly type: "input_file";
|
|
576
576
|
readonly filename: string;
|
|
577
|
-
readonly file_data?: string | undefined;
|
|
578
577
|
readonly detail?: string | undefined;
|
|
578
|
+
readonly file_data?: string | undefined;
|
|
579
579
|
readonly file_url?: string | undefined;
|
|
580
580
|
} | {
|
|
581
581
|
readonly type: "input_text";
|
|
@@ -611,8 +611,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
611
611
|
} | {
|
|
612
612
|
readonly type: "input_file";
|
|
613
613
|
readonly filename: string;
|
|
614
|
-
readonly file_data?: string | undefined;
|
|
615
614
|
readonly detail?: string | undefined;
|
|
615
|
+
readonly file_data?: string | undefined;
|
|
616
616
|
readonly file_url?: string | undefined;
|
|
617
617
|
} | {
|
|
618
618
|
readonly type: "input_text";
|
|
@@ -802,8 +802,8 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
802
802
|
} | {
|
|
803
803
|
readonly type: "input_file";
|
|
804
804
|
readonly filename: string;
|
|
805
|
-
readonly file_data?: string | undefined;
|
|
806
805
|
readonly detail?: string | undefined;
|
|
806
|
+
readonly file_data?: string | undefined;
|
|
807
807
|
readonly file_url?: string | undefined;
|
|
808
808
|
} | {
|
|
809
809
|
readonly type: "input_text";
|
|
@@ -839,8 +839,8 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
839
839
|
} | {
|
|
840
840
|
readonly type: "input_file";
|
|
841
841
|
readonly filename: string;
|
|
842
|
-
readonly file_data?: string | undefined;
|
|
843
842
|
readonly detail?: string | undefined;
|
|
843
|
+
readonly file_data?: string | undefined;
|
|
844
844
|
readonly file_url?: string | undefined;
|
|
845
845
|
} | {
|
|
846
846
|
readonly type: "input_text";
|
|
@@ -1030,8 +1030,8 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1030
1030
|
} | {
|
|
1031
1031
|
readonly type: "input_file";
|
|
1032
1032
|
readonly filename: string;
|
|
1033
|
-
readonly file_data?: string | undefined;
|
|
1034
1033
|
readonly detail?: string | undefined;
|
|
1034
|
+
readonly file_data?: string | undefined;
|
|
1035
1035
|
readonly file_url?: string | undefined;
|
|
1036
1036
|
} | {
|
|
1037
1037
|
readonly type: "input_text";
|
|
@@ -1067,8 +1067,8 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1067
1067
|
} | {
|
|
1068
1068
|
readonly type: "input_file";
|
|
1069
1069
|
readonly filename: string;
|
|
1070
|
-
readonly file_data?: string | undefined;
|
|
1071
1070
|
readonly detail?: string | undefined;
|
|
1071
|
+
readonly file_data?: string | undefined;
|
|
1072
1072
|
readonly file_url?: string | undefined;
|
|
1073
1073
|
} | {
|
|
1074
1074
|
readonly type: "input_text";
|
|
@@ -1258,8 +1258,8 @@ export declare const route: Route<{
|
|
|
1258
1258
|
} | {
|
|
1259
1259
|
readonly type: "input_file";
|
|
1260
1260
|
readonly filename: string;
|
|
1261
|
-
readonly file_data?: string | undefined;
|
|
1262
1261
|
readonly detail?: string | undefined;
|
|
1262
|
+
readonly file_data?: string | undefined;
|
|
1263
1263
|
readonly file_url?: string | undefined;
|
|
1264
1264
|
} | {
|
|
1265
1265
|
readonly type: "input_text";
|
|
@@ -1295,8 +1295,8 @@ export declare const route: Route<{
|
|
|
1295
1295
|
} | {
|
|
1296
1296
|
readonly type: "input_file";
|
|
1297
1297
|
readonly filename: string;
|
|
1298
|
-
readonly file_data?: string | undefined;
|
|
1299
1298
|
readonly detail?: string | undefined;
|
|
1299
|
+
readonly file_data?: string | undefined;
|
|
1300
1300
|
readonly file_url?: string | undefined;
|
|
1301
1301
|
} | {
|
|
1302
1302
|
readonly type: "input_text";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LLMRequest } from "../../schema/index.js";
|
|
2
|
+
export declare const THINKING_BINDING_BETA = "thinking-binding-controls-2026-08-01";
|
|
3
|
+
export declare const claudeVersion: (id: string) => {
|
|
4
|
+
family: string;
|
|
5
|
+
major: number;
|
|
6
|
+
minor: number;
|
|
7
|
+
} | undefined;
|
|
8
|
+
export declare const supportsThinkingBlockBinding: (model: LLMRequest["model"]) => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const THINKING_BINDING_BETA = "thinking-binding-controls-2026-08-01";
|
|
2
|
+
// Accept gateway namespaces and Vertex suffixes without treating a snapshot date as a minor version.
|
|
3
|
+
export const claudeVersion = (id) => {
|
|
4
|
+
const match = /(?:^|[./])claude-(?<family>[a-z]+)-(?<major>\d+)(?:[.-](?<minor>\d{1,2}))?(?:$|[-:@])/.exec(id.toLowerCase())?.groups;
|
|
5
|
+
if (!match)
|
|
6
|
+
return undefined;
|
|
7
|
+
return { family: match.family, major: Number(match.major), minor: Number(match.minor ?? 0) };
|
|
8
|
+
};
|
|
9
|
+
export const supportsThinkingBlockBinding = (model) => {
|
|
10
|
+
const override = model.compatibility?.supportsThinkingBlockBinding;
|
|
11
|
+
if (override !== undefined)
|
|
12
|
+
return override;
|
|
13
|
+
const version = claudeVersion(model.id);
|
|
14
|
+
return version !== undefined && (version.major > 5 || (version.major === 5 && version.minor >= 1));
|
|
15
|
+
};
|
|
@@ -236,8 +236,8 @@ export declare const finish: <K extends StreamKey>(route: string, tools: State<K
|
|
|
236
236
|
} | {
|
|
237
237
|
readonly id: string;
|
|
238
238
|
readonly type: "tool-error";
|
|
239
|
-
readonly name: string;
|
|
240
239
|
readonly message: string;
|
|
240
|
+
readonly name: string;
|
|
241
241
|
readonly error?: unknown;
|
|
242
242
|
readonly providerMetadata?: {
|
|
243
243
|
readonly [x: string]: {
|
|
@@ -459,8 +459,8 @@ export declare const finishWithInput: <K extends StreamKey>(route: string, tools
|
|
|
459
459
|
} | {
|
|
460
460
|
readonly id: string;
|
|
461
461
|
readonly type: "tool-error";
|
|
462
|
-
readonly name: string;
|
|
463
462
|
readonly message: string;
|
|
463
|
+
readonly name: string;
|
|
464
464
|
readonly error?: unknown;
|
|
465
465
|
readonly providerMetadata?: {
|
|
466
466
|
readonly [x: string]: {
|
|
@@ -679,8 +679,8 @@ export declare const finishAll: <K extends StreamKey>(route: string, tools: Stat
|
|
|
679
679
|
} | {
|
|
680
680
|
readonly id: string;
|
|
681
681
|
readonly type: "tool-error";
|
|
682
|
-
readonly name: string;
|
|
683
682
|
readonly message: string;
|
|
683
|
+
readonly name: string;
|
|
684
684
|
readonly error?: unknown;
|
|
685
685
|
readonly providerMetadata?: {
|
|
686
686
|
readonly [x: string]: {
|
|
@@ -67,8 +67,8 @@ export declare const protocol: Protocol<{
|
|
|
67
67
|
} | {
|
|
68
68
|
readonly type: "input_file";
|
|
69
69
|
readonly filename: string;
|
|
70
|
-
readonly file_data?: string | undefined;
|
|
71
70
|
readonly detail?: string | undefined;
|
|
71
|
+
readonly file_data?: string | undefined;
|
|
72
72
|
readonly file_url?: string | undefined;
|
|
73
73
|
} | {
|
|
74
74
|
readonly type: "input_text";
|
|
@@ -104,8 +104,8 @@ export declare const protocol: Protocol<{
|
|
|
104
104
|
} | {
|
|
105
105
|
readonly type: "input_file";
|
|
106
106
|
readonly filename: string;
|
|
107
|
-
readonly file_data?: string | undefined;
|
|
108
107
|
readonly detail?: string | undefined;
|
|
108
|
+
readonly file_data?: string | undefined;
|
|
109
109
|
readonly file_url?: string | undefined;
|
|
110
110
|
} | {
|
|
111
111
|
readonly type: "input_text";
|
|
@@ -184,21 +184,10 @@ export declare const protocol: Protocol<{
|
|
|
184
184
|
readonly [x: string]: unknown;
|
|
185
185
|
readonly type: string;
|
|
186
186
|
readonly status?: unknown;
|
|
187
|
-
readonly code?: unknown;
|
|
188
187
|
readonly message?: unknown;
|
|
188
|
+
readonly code?: unknown;
|
|
189
189
|
readonly text?: string | undefined;
|
|
190
190
|
readonly error?: unknown;
|
|
191
|
-
readonly item?: {
|
|
192
|
-
readonly [x: string]: unknown;
|
|
193
|
-
readonly type: string;
|
|
194
|
-
readonly id?: string | undefined;
|
|
195
|
-
readonly name?: string | undefined;
|
|
196
|
-
readonly namespace?: string | undefined;
|
|
197
|
-
readonly arguments?: string | undefined;
|
|
198
|
-
readonly encrypted_content?: string | null | undefined;
|
|
199
|
-
readonly call_id?: string | undefined;
|
|
200
|
-
} | null | undefined;
|
|
201
|
-
readonly delta?: string | undefined;
|
|
202
191
|
readonly response?: {
|
|
203
192
|
readonly [x: string]: unknown;
|
|
204
193
|
readonly id?: string | undefined;
|
|
@@ -230,6 +219,17 @@ export declare const protocol: Protocol<{
|
|
|
230
219
|
readonly reason?: string | undefined;
|
|
231
220
|
} | null | undefined;
|
|
232
221
|
} | undefined;
|
|
222
|
+
readonly item?: {
|
|
223
|
+
readonly [x: string]: unknown;
|
|
224
|
+
readonly type: string;
|
|
225
|
+
readonly id?: string | undefined;
|
|
226
|
+
readonly name?: string | undefined;
|
|
227
|
+
readonly namespace?: string | undefined;
|
|
228
|
+
readonly arguments?: string | undefined;
|
|
229
|
+
readonly encrypted_content?: string | null | undefined;
|
|
230
|
+
readonly call_id?: string | undefined;
|
|
231
|
+
} | null | undefined;
|
|
232
|
+
readonly delta?: string | undefined;
|
|
233
233
|
readonly arguments?: string | undefined;
|
|
234
234
|
readonly item_id?: string | undefined;
|
|
235
235
|
readonly output_index?: number | undefined;
|
|
@@ -69,15 +69,18 @@ export declare const protocol: Protocol<{
|
|
|
69
69
|
})[];
|
|
70
70
|
} | {
|
|
71
71
|
readonly [x: string]: unknown;
|
|
72
|
-
readonly content: string |
|
|
72
|
+
readonly content: string | readonly {
|
|
73
|
+
readonly type: "text";
|
|
74
|
+
readonly text: string;
|
|
75
|
+
readonly cache_control?: {
|
|
76
|
+
readonly type: "ephemeral";
|
|
77
|
+
readonly ttl?: string | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
}[] | null;
|
|
73
80
|
readonly role: "assistant";
|
|
74
81
|
readonly reasoning?: string | undefined;
|
|
75
82
|
readonly reasoning_content?: string | undefined;
|
|
76
83
|
readonly reasoning_text?: string | undefined;
|
|
77
|
-
readonly cache_control?: {
|
|
78
|
-
readonly type: "ephemeral";
|
|
79
|
-
readonly ttl?: string | undefined;
|
|
80
|
-
} | undefined;
|
|
81
84
|
readonly tool_calls?: readonly {
|
|
82
85
|
readonly function: {
|
|
83
86
|
readonly name: string;
|
|
@@ -93,13 +96,16 @@ export declare const protocol: Protocol<{
|
|
|
93
96
|
}[] | undefined;
|
|
94
97
|
readonly reasoning_details?: unknown;
|
|
95
98
|
} | {
|
|
96
|
-
readonly content: string;
|
|
97
99
|
readonly role: "tool";
|
|
98
100
|
readonly tool_call_id: string;
|
|
99
|
-
readonly
|
|
100
|
-
readonly type: "
|
|
101
|
-
readonly
|
|
102
|
-
|
|
101
|
+
readonly content: string | readonly {
|
|
102
|
+
readonly type: "text";
|
|
103
|
+
readonly text: string;
|
|
104
|
+
readonly cache_control?: {
|
|
105
|
+
readonly type: "ephemeral";
|
|
106
|
+
readonly ttl?: string | undefined;
|
|
107
|
+
} | undefined;
|
|
108
|
+
}[];
|
|
103
109
|
})[];
|
|
104
110
|
readonly stream: true;
|
|
105
111
|
readonly max_completion_tokens?: number | undefined;
|
package/dist/provider-error.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const isContextOverflowFailure: (failure: unknown) => boolean;
|
|
|
7
7
|
* not deliver an accepted write, and unrecognized failures. Callers decide which calls are safe to repeat.
|
|
8
8
|
*/
|
|
9
9
|
export declare const isRetryable: (error: AIError) => boolean;
|
|
10
|
+
export declare const providerErrorMessage: (body: string) => string | undefined;
|
|
10
11
|
export interface ProviderFailure {
|
|
11
12
|
readonly message: string;
|
|
12
13
|
readonly status?: number | undefined;
|
package/dist/provider-error.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Option, Schema } from "effect";
|
|
1
|
+
import { Option, Schema, SchemaGetter } from "effect";
|
|
2
2
|
import { AuthenticationError, ContentPolicyError, InvalidRequestError, AIError, ProviderErrorEvent, ProviderInternalError, QuotaExceededError, RateLimitError, UnknownProviderError, } from "./schema/index.js";
|
|
3
3
|
const patterns = [
|
|
4
4
|
/prompt is too long/i,
|
|
5
5
|
/input is too long for requested model/i,
|
|
6
|
+
// Cloudflare Workers AI reports this as HTTP 413.
|
|
7
|
+
/exceeded this model context window limit/i,
|
|
6
8
|
/exceeds the context window/i,
|
|
7
9
|
/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,
|
|
8
10
|
/input token count.*exceeds the maximum/i,
|
|
11
|
+
// Amazon Nova on Bedrock reports this as a mid-stream validationException.
|
|
12
|
+
/number of input tokens exceeds maximum length/i,
|
|
9
13
|
/tokens in request more than max tokens allowed/i,
|
|
10
14
|
/maximum prompt length is \d+/i,
|
|
11
15
|
/reduce the length of the messages/i,
|
|
@@ -130,6 +134,24 @@ const QUOTA_TEXT = /insufficient[-_\s]?quota|quota[-_\s]?exceeded|budget exceede
|
|
|
130
134
|
// under `invalid_request_error`.
|
|
131
135
|
const CONTENT_POLICY_TEXT = /violating our usage policy|blocked by content filtering policy|content[-_\s]?policy|rejected as a result of our safety system/i;
|
|
132
136
|
const SERVER_ERROR_TEXT = /\b(?:try again|(?:please |you can )?retry (?:the |this |your )?request|try (?:the |this |your )?request again|(?:currently |temporarily )?at capacity|overloaded|temporarily unavailable|service[-_\s]?unavailable|(?:server|internal)[-_\s]?error|server (?:is )?busy|provider returned (?:an )?error|resource[-_\s]?exhausted|upstream (?:connect|connection|request)|request buffer limit while retrying upstream)\b/i;
|
|
137
|
+
const Message = Schema.String.check(Schema.isPattern(/\S/));
|
|
138
|
+
const messageAt = (fields, message) => Schema.Struct(fields).pipe(Schema.decodeTo(Schema.String, {
|
|
139
|
+
decode: SchemaGetter.transform(message),
|
|
140
|
+
encode: SchemaGetter.forbidden(() => "Provider error messages are decode-only"),
|
|
141
|
+
}));
|
|
142
|
+
// Common error body layouts that carry a human-readable message, in priority order.
|
|
143
|
+
// Provider-specific layouts belong in their protocol.
|
|
144
|
+
const decodeMessage = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Union([
|
|
145
|
+
messageAt({ error: Schema.Struct({ message: Message }) }, (body) => body.error.message),
|
|
146
|
+
messageAt({ error: Message }, (body) => body.error),
|
|
147
|
+
messageAt({ message: Message }, (body) => body.message),
|
|
148
|
+
// AWS services
|
|
149
|
+
messageAt({ Message: Message }, (body) => body.Message),
|
|
150
|
+
// RFC 9457 problem details
|
|
151
|
+
messageAt({ detail: Message }, (body) => body.detail),
|
|
152
|
+
messageAt({ errors: Schema.NonEmptyArray(Schema.Struct({ message: Message })) }, (body) => body.errors[0].message),
|
|
153
|
+
])));
|
|
154
|
+
export const providerErrorMessage = (body) => Option.getOrUndefined(decodeMessage(body));
|
|
133
155
|
// Classification records affirmative evidence about a failure. Deterministic
|
|
134
156
|
// failures need positive identification (a 4xx status, quota/auth/policy
|
|
135
157
|
// signals); anything unrecognized stays UnknownProvider, which the session
|
|
@@ -69,15 +69,18 @@ export declare const routes: (Route<{
|
|
|
69
69
|
})[];
|
|
70
70
|
} | {
|
|
71
71
|
readonly [x: string]: unknown;
|
|
72
|
-
readonly content: string |
|
|
72
|
+
readonly content: string | readonly {
|
|
73
|
+
readonly type: "text";
|
|
74
|
+
readonly text: string;
|
|
75
|
+
readonly cache_control?: {
|
|
76
|
+
readonly type: "ephemeral";
|
|
77
|
+
readonly ttl?: string | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
}[] | null;
|
|
73
80
|
readonly role: "assistant";
|
|
74
81
|
readonly reasoning?: string | undefined;
|
|
75
82
|
readonly reasoning_content?: string | undefined;
|
|
76
83
|
readonly reasoning_text?: string | undefined;
|
|
77
|
-
readonly cache_control?: {
|
|
78
|
-
readonly type: "ephemeral";
|
|
79
|
-
readonly ttl?: string | undefined;
|
|
80
|
-
} | undefined;
|
|
81
84
|
readonly tool_calls?: readonly {
|
|
82
85
|
readonly function: {
|
|
83
86
|
readonly name: string;
|
|
@@ -93,13 +96,16 @@ export declare const routes: (Route<{
|
|
|
93
96
|
}[] | undefined;
|
|
94
97
|
readonly reasoning_details?: unknown;
|
|
95
98
|
} | {
|
|
96
|
-
readonly content: string;
|
|
97
99
|
readonly role: "tool";
|
|
98
100
|
readonly tool_call_id: string;
|
|
99
|
-
readonly
|
|
100
|
-
readonly type: "
|
|
101
|
-
readonly
|
|
102
|
-
|
|
101
|
+
readonly content: string | readonly {
|
|
102
|
+
readonly type: "text";
|
|
103
|
+
readonly text: string;
|
|
104
|
+
readonly cache_control?: {
|
|
105
|
+
readonly type: "ephemeral";
|
|
106
|
+
readonly ttl?: string | undefined;
|
|
107
|
+
} | undefined;
|
|
108
|
+
}[];
|
|
103
109
|
})[];
|
|
104
110
|
readonly stream: true;
|
|
105
111
|
readonly max_completion_tokens?: number | undefined;
|
|
@@ -487,8 +493,8 @@ export declare const routes: (Route<{
|
|
|
487
493
|
} | {
|
|
488
494
|
readonly type: "input_file";
|
|
489
495
|
readonly filename: string;
|
|
490
|
-
readonly file_data?: string | undefined;
|
|
491
496
|
readonly detail?: string | undefined;
|
|
497
|
+
readonly file_data?: string | undefined;
|
|
492
498
|
readonly file_url?: string | undefined;
|
|
493
499
|
} | {
|
|
494
500
|
readonly type: "input_text";
|
|
@@ -524,8 +530,8 @@ export declare const routes: (Route<{
|
|
|
524
530
|
} | {
|
|
525
531
|
readonly type: "input_file";
|
|
526
532
|
readonly filename: string;
|
|
527
|
-
readonly file_data?: string | undefined;
|
|
528
533
|
readonly detail?: string | undefined;
|
|
534
|
+
readonly file_data?: string | undefined;
|
|
529
535
|
readonly file_url?: string | undefined;
|
|
530
536
|
} | {
|
|
531
537
|
readonly type: "input_text";
|
|
@@ -72,15 +72,18 @@ export declare const routes: (Route<{
|
|
|
72
72
|
})[];
|
|
73
73
|
} | {
|
|
74
74
|
readonly [x: string]: unknown;
|
|
75
|
-
readonly content: string |
|
|
75
|
+
readonly content: string | readonly {
|
|
76
|
+
readonly type: "text";
|
|
77
|
+
readonly text: string;
|
|
78
|
+
readonly cache_control?: {
|
|
79
|
+
readonly type: "ephemeral";
|
|
80
|
+
readonly ttl?: string | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
}[] | null;
|
|
76
83
|
readonly role: "assistant";
|
|
77
84
|
readonly reasoning?: string | undefined;
|
|
78
85
|
readonly reasoning_content?: string | undefined;
|
|
79
86
|
readonly reasoning_text?: string | undefined;
|
|
80
|
-
readonly cache_control?: {
|
|
81
|
-
readonly type: "ephemeral";
|
|
82
|
-
readonly ttl?: string | undefined;
|
|
83
|
-
} | undefined;
|
|
84
87
|
readonly tool_calls?: readonly {
|
|
85
88
|
readonly function: {
|
|
86
89
|
readonly name: string;
|
|
@@ -96,13 +99,16 @@ export declare const routes: (Route<{
|
|
|
96
99
|
}[] | undefined;
|
|
97
100
|
readonly reasoning_details?: unknown;
|
|
98
101
|
} | {
|
|
99
|
-
readonly content: string;
|
|
100
102
|
readonly role: "tool";
|
|
101
103
|
readonly tool_call_id: string;
|
|
102
|
-
readonly
|
|
103
|
-
readonly type: "
|
|
104
|
-
readonly
|
|
105
|
-
|
|
104
|
+
readonly content: string | readonly {
|
|
105
|
+
readonly type: "text";
|
|
106
|
+
readonly text: string;
|
|
107
|
+
readonly cache_control?: {
|
|
108
|
+
readonly type: "ephemeral";
|
|
109
|
+
readonly ttl?: string | undefined;
|
|
110
|
+
} | undefined;
|
|
111
|
+
}[];
|
|
106
112
|
})[];
|
|
107
113
|
readonly stream: true;
|
|
108
114
|
readonly max_completion_tokens?: number | undefined;
|
|
@@ -208,8 +214,8 @@ export declare const routes: (Route<{
|
|
|
208
214
|
} | {
|
|
209
215
|
readonly type: "input_file";
|
|
210
216
|
readonly filename: string;
|
|
211
|
-
readonly file_data?: string | undefined;
|
|
212
217
|
readonly detail?: string | undefined;
|
|
218
|
+
readonly file_data?: string | undefined;
|
|
213
219
|
readonly file_url?: string | undefined;
|
|
214
220
|
} | {
|
|
215
221
|
readonly type: "input_text";
|
|
@@ -245,8 +251,8 @@ export declare const routes: (Route<{
|
|
|
245
251
|
} | {
|
|
246
252
|
readonly type: "input_file";
|
|
247
253
|
readonly filename: string;
|
|
248
|
-
readonly file_data?: string | undefined;
|
|
249
254
|
readonly detail?: string | undefined;
|
|
255
|
+
readonly file_data?: string | undefined;
|
|
250
256
|
readonly file_url?: string | undefined;
|
|
251
257
|
} | {
|
|
252
258
|
readonly type: "input_text";
|
|
@@ -93,8 +93,8 @@ declare const responsesRoute: Route<{
|
|
|
93
93
|
} | {
|
|
94
94
|
readonly type: "input_file";
|
|
95
95
|
readonly filename: string;
|
|
96
|
-
readonly file_data?: string | undefined;
|
|
97
96
|
readonly detail?: string | undefined;
|
|
97
|
+
readonly file_data?: string | undefined;
|
|
98
98
|
readonly file_url?: string | undefined;
|
|
99
99
|
} | {
|
|
100
100
|
readonly type: "input_text";
|
|
@@ -130,8 +130,8 @@ declare const responsesRoute: Route<{
|
|
|
130
130
|
} | {
|
|
131
131
|
readonly type: "input_file";
|
|
132
132
|
readonly filename: string;
|
|
133
|
-
readonly file_data?: string | undefined;
|
|
134
133
|
readonly detail?: string | undefined;
|
|
134
|
+
readonly file_data?: string | undefined;
|
|
135
135
|
readonly file_url?: string | undefined;
|
|
136
136
|
} | {
|
|
137
137
|
readonly type: "input_text";
|
|
@@ -297,15 +297,18 @@ export declare const routes: (Route<{
|
|
|
297
297
|
})[];
|
|
298
298
|
} | {
|
|
299
299
|
readonly [x: string]: unknown;
|
|
300
|
-
readonly content: string |
|
|
300
|
+
readonly content: string | readonly {
|
|
301
|
+
readonly type: "text";
|
|
302
|
+
readonly text: string;
|
|
303
|
+
readonly cache_control?: {
|
|
304
|
+
readonly type: "ephemeral";
|
|
305
|
+
readonly ttl?: string | undefined;
|
|
306
|
+
} | undefined;
|
|
307
|
+
}[] | null;
|
|
301
308
|
readonly role: "assistant";
|
|
302
309
|
readonly reasoning?: string | undefined;
|
|
303
310
|
readonly reasoning_content?: string | undefined;
|
|
304
311
|
readonly reasoning_text?: string | undefined;
|
|
305
|
-
readonly cache_control?: {
|
|
306
|
-
readonly type: "ephemeral";
|
|
307
|
-
readonly ttl?: string | undefined;
|
|
308
|
-
} | undefined;
|
|
309
312
|
readonly tool_calls?: readonly {
|
|
310
313
|
readonly function: {
|
|
311
314
|
readonly name: string;
|
|
@@ -321,13 +324,16 @@ export declare const routes: (Route<{
|
|
|
321
324
|
}[] | undefined;
|
|
322
325
|
readonly reasoning_details?: unknown;
|
|
323
326
|
} | {
|
|
324
|
-
readonly content: string;
|
|
325
327
|
readonly role: "tool";
|
|
326
328
|
readonly tool_call_id: string;
|
|
327
|
-
readonly
|
|
328
|
-
readonly type: "
|
|
329
|
-
readonly
|
|
330
|
-
|
|
329
|
+
readonly content: string | readonly {
|
|
330
|
+
readonly type: "text";
|
|
331
|
+
readonly text: string;
|
|
332
|
+
readonly cache_control?: {
|
|
333
|
+
readonly type: "ephemeral";
|
|
334
|
+
readonly ttl?: string | undefined;
|
|
335
|
+
} | undefined;
|
|
336
|
+
}[];
|
|
331
337
|
})[];
|
|
332
338
|
readonly stream: true;
|
|
333
339
|
readonly max_completion_tokens?: number | undefined;
|
|
@@ -438,8 +444,8 @@ export declare const routes: (Route<{
|
|
|
438
444
|
} | {
|
|
439
445
|
readonly type: "input_file";
|
|
440
446
|
readonly filename: string;
|
|
441
|
-
readonly file_data?: string | undefined;
|
|
442
447
|
readonly detail?: string | undefined;
|
|
448
|
+
readonly file_data?: string | undefined;
|
|
443
449
|
readonly file_url?: string | undefined;
|
|
444
450
|
} | {
|
|
445
451
|
readonly type: "input_text";
|
|
@@ -475,8 +481,8 @@ export declare const routes: (Route<{
|
|
|
475
481
|
} | {
|
|
476
482
|
readonly type: "input_file";
|
|
477
483
|
readonly filename: string;
|
|
478
|
-
readonly file_data?: string | undefined;
|
|
479
484
|
readonly detail?: string | undefined;
|
|
485
|
+
readonly file_data?: string | undefined;
|
|
480
486
|
readonly file_url?: string | undefined;
|
|
481
487
|
} | {
|
|
482
488
|
readonly type: "input_text";
|
|
@@ -58,15 +58,18 @@ export declare const route: Route<{
|
|
|
58
58
|
})[];
|
|
59
59
|
} | {
|
|
60
60
|
readonly [x: string]: unknown;
|
|
61
|
-
readonly content: string |
|
|
61
|
+
readonly content: string | readonly {
|
|
62
|
+
readonly type: "text";
|
|
63
|
+
readonly text: string;
|
|
64
|
+
readonly cache_control?: {
|
|
65
|
+
readonly type: "ephemeral";
|
|
66
|
+
readonly ttl?: string | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
}[] | null;
|
|
62
69
|
readonly role: "assistant";
|
|
63
70
|
readonly reasoning?: string | undefined;
|
|
64
71
|
readonly reasoning_content?: string | undefined;
|
|
65
72
|
readonly reasoning_text?: string | undefined;
|
|
66
|
-
readonly cache_control?: {
|
|
67
|
-
readonly type: "ephemeral";
|
|
68
|
-
readonly ttl?: string | undefined;
|
|
69
|
-
} | undefined;
|
|
70
73
|
readonly tool_calls?: readonly {
|
|
71
74
|
readonly function: {
|
|
72
75
|
readonly name: string;
|
|
@@ -82,13 +85,16 @@ export declare const route: Route<{
|
|
|
82
85
|
}[] | undefined;
|
|
83
86
|
readonly reasoning_details?: unknown;
|
|
84
87
|
} | {
|
|
85
|
-
readonly content: string;
|
|
86
88
|
readonly role: "tool";
|
|
87
89
|
readonly tool_call_id: string;
|
|
88
|
-
readonly
|
|
89
|
-
readonly type: "
|
|
90
|
-
readonly
|
|
91
|
-
|
|
90
|
+
readonly content: string | readonly {
|
|
91
|
+
readonly type: "text";
|
|
92
|
+
readonly text: string;
|
|
93
|
+
readonly cache_control?: {
|
|
94
|
+
readonly type: "ephemeral";
|
|
95
|
+
readonly ttl?: string | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
}[];
|
|
92
98
|
})[];
|
|
93
99
|
readonly stream: true;
|
|
94
100
|
readonly max_completion_tokens?: number | undefined;
|
|
@@ -174,15 +180,18 @@ export declare const routes: Route<{
|
|
|
174
180
|
})[];
|
|
175
181
|
} | {
|
|
176
182
|
readonly [x: string]: unknown;
|
|
177
|
-
readonly content: string |
|
|
183
|
+
readonly content: string | readonly {
|
|
184
|
+
readonly type: "text";
|
|
185
|
+
readonly text: string;
|
|
186
|
+
readonly cache_control?: {
|
|
187
|
+
readonly type: "ephemeral";
|
|
188
|
+
readonly ttl?: string | undefined;
|
|
189
|
+
} | undefined;
|
|
190
|
+
}[] | null;
|
|
178
191
|
readonly role: "assistant";
|
|
179
192
|
readonly reasoning?: string | undefined;
|
|
180
193
|
readonly reasoning_content?: string | undefined;
|
|
181
194
|
readonly reasoning_text?: string | undefined;
|
|
182
|
-
readonly cache_control?: {
|
|
183
|
-
readonly type: "ephemeral";
|
|
184
|
-
readonly ttl?: string | undefined;
|
|
185
|
-
} | undefined;
|
|
186
195
|
readonly tool_calls?: readonly {
|
|
187
196
|
readonly function: {
|
|
188
197
|
readonly name: string;
|
|
@@ -198,13 +207,16 @@ export declare const routes: Route<{
|
|
|
198
207
|
}[] | undefined;
|
|
199
208
|
readonly reasoning_details?: unknown;
|
|
200
209
|
} | {
|
|
201
|
-
readonly content: string;
|
|
202
210
|
readonly role: "tool";
|
|
203
211
|
readonly tool_call_id: string;
|
|
204
|
-
readonly
|
|
205
|
-
readonly type: "
|
|
206
|
-
readonly
|
|
207
|
-
|
|
212
|
+
readonly content: string | readonly {
|
|
213
|
+
readonly type: "text";
|
|
214
|
+
readonly text: string;
|
|
215
|
+
readonly cache_control?: {
|
|
216
|
+
readonly type: "ephemeral";
|
|
217
|
+
readonly ttl?: string | undefined;
|
|
218
|
+
} | undefined;
|
|
219
|
+
}[];
|
|
208
220
|
})[];
|
|
209
221
|
readonly stream: true;
|
|
210
222
|
readonly max_completion_tokens?: number | undefined;
|