@opencode-ai/ai 0.0.0-beta-17639 → 0.0.0-beta-17728
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 +17 -6
- package/dist/cache-policy.js +3 -5
- package/dist/protocols/anthropic-messages.d.ts +26 -28
- package/dist/protocols/anthropic-messages.js +5 -5
- package/dist/protocols/gemini.d.ts +5 -9
- package/dist/protocols/gemini.js +5 -4
- package/dist/protocols/open-responses.d.ts +176 -38
- package/dist/protocols/open-responses.js +108 -33
- package/dist/protocols/openai-chat.d.ts +17 -15
- package/dist/protocols/openai-chat.js +8 -2
- package/dist/protocols/openai-compatible-chat.d.ts +3 -3
- package/dist/protocols/openai-compatible-responses.d.ts +27 -5
- package/dist/protocols/openai-responses.d.ts +151 -33
- package/dist/protocols/openai-responses.js +4 -2
- package/dist/protocols/shared.d.ts +8 -14
- package/dist/protocols/shared.js +8 -14
- package/dist/protocols/utils/bedrock-cache.js +3 -4
- package/dist/protocols/utils/cache.js +3 -6
- package/dist/protocols/utils/open-responses-options.d.ts +46 -15
- package/dist/protocols/utils/open-responses-options.js +38 -25
- package/dist/protocols/utils/openai-options.d.ts +7 -5
- package/dist/protocols/utils/openai-options.js +3 -3
- package/dist/provider-package.d.ts +0 -5
- package/dist/providers/amazon-bedrock-mantle.d.ts +43 -19
- package/dist/providers/amazon-bedrock-mantle.js +0 -1
- package/dist/providers/amazon-bedrock.d.ts +3 -9
- package/dist/providers/amazon-bedrock.js +0 -1
- package/dist/providers/anthropic-compatible.d.ts +11 -11
- package/dist/providers/anthropic-compatible.js +0 -1
- package/dist/providers/anthropic.d.ts +12 -12
- package/dist/providers/anthropic.js +0 -1
- package/dist/providers/azure.d.ts +40 -16
- package/dist/providers/azure.js +0 -1
- package/dist/providers/cloudflare.d.ts +11 -11
- package/dist/providers/google-vertex-chat.d.ts +5 -5
- package/dist/providers/google-vertex-chat.js +0 -1
- package/dist/providers/google-vertex-messages.d.ts +11 -11
- package/dist/providers/google-vertex-messages.js +0 -1
- package/dist/providers/google-vertex-responses.d.ts +29 -7
- package/dist/providers/google-vertex-responses.js +1 -2
- package/dist/providers/google-vertex.d.ts +5 -7
- package/dist/providers/google-vertex.js +1 -2
- package/dist/providers/google.d.ts +4 -4
- package/dist/providers/google.js +0 -1
- package/dist/providers/open-responses-options.d.ts +3 -14
- package/dist/providers/openai-compatible-responses.d.ts +29 -7
- package/dist/providers/openai-compatible-responses.js +0 -1
- package/dist/providers/openai-compatible.d.ts +13 -12
- package/dist/providers/openai-compatible.js +1 -1
- package/dist/providers/openai-options.d.ts +2 -4
- package/dist/providers/openai-options.js +3 -3
- package/dist/providers/openai.d.ts +44 -20
- package/dist/providers/openai.js +0 -1
- package/dist/providers/openrouter.d.ts +16 -17
- package/dist/providers/openrouter.js +1 -2
- package/dist/providers/xai.d.ts +46 -24
- package/dist/providers/xai.js +1 -2
- package/dist/route/client.d.ts +2 -6
- package/dist/route/client.js +1 -2
- package/dist/route/framing.d.ts +2 -2
- package/dist/route/protocol.d.ts +1 -2
- package/dist/route/protocol.js +1 -2
- package/dist/schema/errors.js +2 -1
- package/dist/schema/events.d.ts +5 -3
- package/dist/schema/events.js +5 -2
- package/dist/schema/ids.d.ts +0 -13
- package/dist/schema/ids.js +0 -9
- package/dist/schema/messages.d.ts +7 -7
- package/dist/schema/messages.js +5 -2
- package/dist/schema/options.d.ts +6 -22
- package/dist/schema/options.js +6 -30
- package/package.json +5 -5
|
@@ -8,6 +8,8 @@ export declare const PATH = "/responses";
|
|
|
8
8
|
declare const OpenAIResponsesBody: Schema.Struct<{
|
|
9
9
|
readonly stream: Schema.Literal<true>;
|
|
10
10
|
readonly input: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
11
|
+
readonly type: Schema.tag<"message">;
|
|
12
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
11
13
|
readonly role: Schema.tag<"assistant">;
|
|
12
14
|
readonly content: Schema.$Array<Schema.Struct<{
|
|
13
15
|
readonly type: Schema.tag<"output_text">;
|
|
@@ -35,6 +37,8 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
35
37
|
readonly mime_type: Schema.optional<Schema.String>;
|
|
36
38
|
}>]>]>>;
|
|
37
39
|
}>, Schema.Struct<{
|
|
40
|
+
readonly type: Schema.tag<"message">;
|
|
41
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
38
42
|
readonly role: Schema.tag<"assistant">;
|
|
39
43
|
readonly content: Schema.$Array<Schema.Struct<{
|
|
40
44
|
readonly type: Schema.tag<"output_text">;
|
|
@@ -54,6 +58,7 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
54
58
|
readonly id: Schema.String;
|
|
55
59
|
}>, Schema.Struct<{
|
|
56
60
|
readonly type: Schema.tag<"function_call">;
|
|
61
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
57
62
|
readonly call_id: Schema.String;
|
|
58
63
|
readonly name: Schema.String;
|
|
59
64
|
readonly arguments: Schema.String;
|
|
@@ -93,26 +98,43 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
93
98
|
readonly tool_choice: Schema.optional<Schema.Union<readonly [Schema.Union<readonly [Schema.Literals<readonly ["auto", "none", "required"]>, Schema.Struct<{
|
|
94
99
|
readonly type: Schema.tag<"function">;
|
|
95
100
|
readonly name: Schema.String;
|
|
101
|
+
}>, Schema.Struct<{
|
|
102
|
+
readonly type: Schema.tag<"allowed_tools">;
|
|
103
|
+
readonly mode: Schema.Literals<readonly ["auto", "none", "required"]>;
|
|
104
|
+
readonly tools: Schema.$Array<Schema.Struct<{
|
|
105
|
+
readonly type: Schema.tag<"function">;
|
|
106
|
+
readonly name: Schema.String;
|
|
107
|
+
}>>;
|
|
96
108
|
}>]>, Schema.Struct<{
|
|
97
109
|
readonly type: Schema.tag<"image_generation">;
|
|
98
110
|
}>]>>;
|
|
99
111
|
readonly model: Schema.String;
|
|
100
112
|
readonly instructions: Schema.optional<Schema.String>;
|
|
101
113
|
readonly store: Schema.optional<Schema.Boolean>;
|
|
114
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
115
|
+
readonly safety_identifier: Schema.optional<Schema.String>;
|
|
116
|
+
readonly stream_options: Schema.optional<Schema.Struct<{
|
|
117
|
+
readonly include_obfuscation: Schema.optional<Schema.Boolean>;
|
|
118
|
+
}>>;
|
|
119
|
+
readonly top_logprobs: Schema.optional<Schema.Int>;
|
|
102
120
|
readonly truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
|
|
103
121
|
readonly service_tier: Schema.optional<Schema.Literals<readonly ["auto", "default", "flex", "priority"]>>;
|
|
104
122
|
readonly prompt_cache_key: Schema.optional<Schema.String>;
|
|
105
|
-
readonly include: Schema.optional<Schema.$Array<Schema.
|
|
123
|
+
readonly include: Schema.optional<Schema.$Array<Schema.declare<import("./utils/open-responses-options.js").ResponseIncludable, import("./utils/open-responses-options.js").ResponseIncludable>>>;
|
|
106
124
|
readonly reasoning: Schema.optional<Schema.Struct<{
|
|
107
|
-
readonly effort: Schema.optional<Schema.
|
|
125
|
+
readonly effort: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ReasoningEffort, import("./utils/open-responses-options.js").ReasoningEffort>>;
|
|
108
126
|
readonly summary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
|
|
109
127
|
}>>;
|
|
110
128
|
readonly text: Schema.optional<Schema.Struct<{
|
|
111
|
-
readonly verbosity: Schema.optional<Schema.
|
|
129
|
+
readonly verbosity: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").TextVerbosity, import("./utils/open-responses-options.js").TextVerbosity>>;
|
|
112
130
|
}>>;
|
|
113
131
|
readonly max_output_tokens: Schema.optional<Schema.Number>;
|
|
132
|
+
readonly max_tool_calls: Schema.optional<Schema.Int>;
|
|
133
|
+
readonly parallel_tool_calls: Schema.optional<Schema.Boolean>;
|
|
114
134
|
readonly temperature: Schema.optional<Schema.Number>;
|
|
115
135
|
readonly top_p: Schema.optional<Schema.Number>;
|
|
136
|
+
readonly presence_penalty: Schema.optional<Schema.Number>;
|
|
137
|
+
readonly frequency_penalty: Schema.optional<Schema.Number>;
|
|
116
138
|
}>;
|
|
117
139
|
export type OpenAIResponsesBody = Schema.Schema.Type<typeof OpenAIResponsesBody>;
|
|
118
140
|
export declare const protocol: Protocol<{
|
|
@@ -148,17 +170,20 @@ export declare const protocol: Protocol<{
|
|
|
148
170
|
readonly text: string;
|
|
149
171
|
})[];
|
|
150
172
|
} | {
|
|
173
|
+
readonly type: "message";
|
|
151
174
|
readonly content: readonly {
|
|
152
175
|
readonly type: "output_text";
|
|
153
176
|
readonly text: string;
|
|
154
177
|
}[];
|
|
155
178
|
readonly role: "assistant";
|
|
179
|
+
readonly id?: string | undefined;
|
|
156
180
|
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
157
181
|
} | {
|
|
158
182
|
readonly type: "function_call";
|
|
159
|
-
readonly call_id: string;
|
|
160
183
|
readonly name: string;
|
|
161
184
|
readonly arguments: string;
|
|
185
|
+
readonly call_id: string;
|
|
186
|
+
readonly id?: string | undefined;
|
|
162
187
|
} | {
|
|
163
188
|
readonly type: "function_call_output";
|
|
164
189
|
readonly call_id: string;
|
|
@@ -175,19 +200,24 @@ export declare const protocol: Protocol<{
|
|
|
175
200
|
readonly text: string;
|
|
176
201
|
})[];
|
|
177
202
|
} | {
|
|
203
|
+
readonly type: "message";
|
|
178
204
|
readonly content: readonly {
|
|
179
205
|
readonly type: "output_text";
|
|
180
206
|
readonly text: string;
|
|
181
207
|
}[];
|
|
182
208
|
readonly role: "assistant";
|
|
209
|
+
readonly id?: string | undefined;
|
|
183
210
|
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
184
211
|
})[];
|
|
185
212
|
readonly model: string;
|
|
186
213
|
readonly stream: true;
|
|
214
|
+
readonly metadata?: {
|
|
215
|
+
readonly [x: string]: string;
|
|
216
|
+
} | undefined;
|
|
187
217
|
readonly instructions?: string | undefined;
|
|
188
218
|
readonly reasoning?: {
|
|
189
219
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
190
|
-
readonly effort?:
|
|
220
|
+
readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
191
221
|
} | undefined;
|
|
192
222
|
readonly tools?: readonly ({
|
|
193
223
|
readonly type: "function";
|
|
@@ -202,43 +232,59 @@ export declare const protocol: Protocol<{
|
|
|
202
232
|
readonly size?: string | undefined;
|
|
203
233
|
readonly action?: "generate" | "auto" | "edit" | undefined;
|
|
204
234
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
205
|
-
readonly quality?: "
|
|
235
|
+
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
206
236
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
207
237
|
readonly output_compression?: number | undefined;
|
|
208
238
|
readonly input_fidelity?: "low" | "high" | undefined;
|
|
209
239
|
readonly partial_images?: number | undefined;
|
|
210
240
|
})[] | undefined;
|
|
211
241
|
readonly text?: {
|
|
212
|
-
readonly verbosity?: "
|
|
242
|
+
readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
|
|
213
243
|
} | undefined;
|
|
214
244
|
readonly temperature?: number | undefined;
|
|
215
|
-
readonly tool_choice?: "required" | "
|
|
245
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
216
246
|
readonly type: "function";
|
|
217
247
|
readonly name: string;
|
|
248
|
+
} | {
|
|
249
|
+
readonly type: "allowed_tools";
|
|
250
|
+
readonly mode: "required" | "auto" | "none";
|
|
251
|
+
readonly tools: readonly {
|
|
252
|
+
readonly type: "function";
|
|
253
|
+
readonly name: string;
|
|
254
|
+
}[];
|
|
218
255
|
} | {
|
|
219
256
|
readonly type: "image_generation";
|
|
220
257
|
} | undefined;
|
|
221
258
|
readonly top_p?: number | undefined;
|
|
222
|
-
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
|
|
223
259
|
readonly store?: boolean | undefined;
|
|
260
|
+
readonly include?: readonly import("./utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
224
261
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
262
|
+
readonly stream_options?: {
|
|
263
|
+
readonly include_obfuscation?: boolean | undefined;
|
|
264
|
+
} | undefined;
|
|
225
265
|
readonly prompt_cache_key?: string | undefined;
|
|
266
|
+
readonly frequency_penalty?: number | undefined;
|
|
267
|
+
readonly presence_penalty?: number | undefined;
|
|
268
|
+
readonly safety_identifier?: string | undefined;
|
|
269
|
+
readonly top_logprobs?: number | undefined;
|
|
226
270
|
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
|
|
227
271
|
readonly max_output_tokens?: number | undefined;
|
|
272
|
+
readonly max_tool_calls?: number | undefined;
|
|
273
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
228
274
|
}, string, {
|
|
229
275
|
readonly [x: string]: unknown;
|
|
230
276
|
readonly type: string;
|
|
277
|
+
readonly status?: unknown;
|
|
278
|
+
readonly code?: string | null | undefined;
|
|
279
|
+
readonly message?: string | undefined;
|
|
280
|
+
readonly headers?: unknown;
|
|
281
|
+
readonly text?: string | undefined;
|
|
231
282
|
readonly error?: {
|
|
232
283
|
readonly type?: string | null | undefined;
|
|
233
284
|
readonly code?: string | null | undefined;
|
|
234
285
|
readonly message?: string | null | undefined;
|
|
235
286
|
readonly param?: string | null | undefined;
|
|
236
287
|
} | null | undefined;
|
|
237
|
-
readonly status?: unknown;
|
|
238
|
-
readonly code?: string | null | undefined;
|
|
239
|
-
readonly message?: string | undefined;
|
|
240
|
-
readonly headers?: unknown;
|
|
241
|
-
readonly text?: string | undefined;
|
|
242
288
|
readonly item?: {
|
|
243
289
|
readonly [x: string]: unknown;
|
|
244
290
|
readonly type: string;
|
|
@@ -251,13 +297,13 @@ export declare const protocol: Protocol<{
|
|
|
251
297
|
readonly delta?: string | undefined;
|
|
252
298
|
readonly response?: {
|
|
253
299
|
readonly [x: string]: unknown;
|
|
300
|
+
readonly id?: string | undefined;
|
|
254
301
|
readonly error?: {
|
|
255
302
|
readonly type?: string | null | undefined;
|
|
256
303
|
readonly code?: string | null | undefined;
|
|
257
304
|
readonly message?: string | null | undefined;
|
|
258
305
|
readonly param?: string | null | undefined;
|
|
259
306
|
} | null | undefined;
|
|
260
|
-
readonly id?: string | undefined;
|
|
261
307
|
readonly usage?: {
|
|
262
308
|
readonly input_tokens?: number | undefined;
|
|
263
309
|
readonly output_tokens?: number | undefined;
|
|
@@ -313,17 +359,20 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
313
359
|
readonly text: string;
|
|
314
360
|
})[];
|
|
315
361
|
} | {
|
|
362
|
+
readonly type: "message";
|
|
316
363
|
readonly content: readonly {
|
|
317
364
|
readonly type: "output_text";
|
|
318
365
|
readonly text: string;
|
|
319
366
|
}[];
|
|
320
367
|
readonly role: "assistant";
|
|
368
|
+
readonly id?: string | undefined;
|
|
321
369
|
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
322
370
|
} | {
|
|
323
371
|
readonly type: "function_call";
|
|
324
|
-
readonly call_id: string;
|
|
325
372
|
readonly name: string;
|
|
326
373
|
readonly arguments: string;
|
|
374
|
+
readonly call_id: string;
|
|
375
|
+
readonly id?: string | undefined;
|
|
327
376
|
} | {
|
|
328
377
|
readonly type: "function_call_output";
|
|
329
378
|
readonly call_id: string;
|
|
@@ -340,19 +389,24 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
340
389
|
readonly text: string;
|
|
341
390
|
})[];
|
|
342
391
|
} | {
|
|
392
|
+
readonly type: "message";
|
|
343
393
|
readonly content: readonly {
|
|
344
394
|
readonly type: "output_text";
|
|
345
395
|
readonly text: string;
|
|
346
396
|
}[];
|
|
347
397
|
readonly role: "assistant";
|
|
398
|
+
readonly id?: string | undefined;
|
|
348
399
|
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
349
400
|
})[];
|
|
350
401
|
readonly model: string;
|
|
351
402
|
readonly stream: true;
|
|
403
|
+
readonly metadata?: {
|
|
404
|
+
readonly [x: string]: string;
|
|
405
|
+
} | undefined;
|
|
352
406
|
readonly instructions?: string | undefined;
|
|
353
407
|
readonly reasoning?: {
|
|
354
408
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
355
|
-
readonly effort?:
|
|
409
|
+
readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
356
410
|
} | undefined;
|
|
357
411
|
readonly tools?: readonly ({
|
|
358
412
|
readonly type: "function";
|
|
@@ -367,29 +421,45 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
367
421
|
readonly size?: string | undefined;
|
|
368
422
|
readonly action?: "generate" | "auto" | "edit" | undefined;
|
|
369
423
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
370
|
-
readonly quality?: "
|
|
424
|
+
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
371
425
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
372
426
|
readonly output_compression?: number | undefined;
|
|
373
427
|
readonly input_fidelity?: "low" | "high" | undefined;
|
|
374
428
|
readonly partial_images?: number | undefined;
|
|
375
429
|
})[] | undefined;
|
|
376
430
|
readonly text?: {
|
|
377
|
-
readonly verbosity?: "
|
|
431
|
+
readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
|
|
378
432
|
} | undefined;
|
|
379
433
|
readonly temperature?: number | undefined;
|
|
380
|
-
readonly tool_choice?: "required" | "
|
|
434
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
381
435
|
readonly type: "function";
|
|
382
436
|
readonly name: string;
|
|
437
|
+
} | {
|
|
438
|
+
readonly type: "allowed_tools";
|
|
439
|
+
readonly mode: "required" | "auto" | "none";
|
|
440
|
+
readonly tools: readonly {
|
|
441
|
+
readonly type: "function";
|
|
442
|
+
readonly name: string;
|
|
443
|
+
}[];
|
|
383
444
|
} | {
|
|
384
445
|
readonly type: "image_generation";
|
|
385
446
|
} | undefined;
|
|
386
447
|
readonly top_p?: number | undefined;
|
|
387
|
-
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
|
|
388
448
|
readonly store?: boolean | undefined;
|
|
449
|
+
readonly include?: readonly import("./utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
389
450
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
451
|
+
readonly stream_options?: {
|
|
452
|
+
readonly include_obfuscation?: boolean | undefined;
|
|
453
|
+
} | undefined;
|
|
390
454
|
readonly prompt_cache_key?: string | undefined;
|
|
455
|
+
readonly frequency_penalty?: number | undefined;
|
|
456
|
+
readonly presence_penalty?: number | undefined;
|
|
457
|
+
readonly safety_identifier?: string | undefined;
|
|
458
|
+
readonly top_logprobs?: number | undefined;
|
|
391
459
|
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
|
|
392
460
|
readonly max_output_tokens?: number | undefined;
|
|
461
|
+
readonly max_tool_calls?: number | undefined;
|
|
462
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
393
463
|
}, string>;
|
|
394
464
|
export declare const transport: import("../route/transport/index.js").Transport<{
|
|
395
465
|
readonly input: readonly ({
|
|
@@ -424,17 +494,20 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
424
494
|
readonly text: string;
|
|
425
495
|
})[];
|
|
426
496
|
} | {
|
|
497
|
+
readonly type: "message";
|
|
427
498
|
readonly content: readonly {
|
|
428
499
|
readonly type: "output_text";
|
|
429
500
|
readonly text: string;
|
|
430
501
|
}[];
|
|
431
502
|
readonly role: "assistant";
|
|
503
|
+
readonly id?: string | undefined;
|
|
432
504
|
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
433
505
|
} | {
|
|
434
506
|
readonly type: "function_call";
|
|
435
|
-
readonly call_id: string;
|
|
436
507
|
readonly name: string;
|
|
437
508
|
readonly arguments: string;
|
|
509
|
+
readonly call_id: string;
|
|
510
|
+
readonly id?: string | undefined;
|
|
438
511
|
} | {
|
|
439
512
|
readonly type: "function_call_output";
|
|
440
513
|
readonly call_id: string;
|
|
@@ -451,19 +524,24 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
451
524
|
readonly text: string;
|
|
452
525
|
})[];
|
|
453
526
|
} | {
|
|
527
|
+
readonly type: "message";
|
|
454
528
|
readonly content: readonly {
|
|
455
529
|
readonly type: "output_text";
|
|
456
530
|
readonly text: string;
|
|
457
531
|
}[];
|
|
458
532
|
readonly role: "assistant";
|
|
533
|
+
readonly id?: string | undefined;
|
|
459
534
|
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
460
535
|
})[];
|
|
461
536
|
readonly model: string;
|
|
462
537
|
readonly stream: true;
|
|
538
|
+
readonly metadata?: {
|
|
539
|
+
readonly [x: string]: string;
|
|
540
|
+
} | undefined;
|
|
463
541
|
readonly instructions?: string | undefined;
|
|
464
542
|
readonly reasoning?: {
|
|
465
543
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
466
|
-
readonly effort?:
|
|
544
|
+
readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
467
545
|
} | undefined;
|
|
468
546
|
readonly tools?: readonly ({
|
|
469
547
|
readonly type: "function";
|
|
@@ -478,29 +556,45 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
478
556
|
readonly size?: string | undefined;
|
|
479
557
|
readonly action?: "generate" | "auto" | "edit" | undefined;
|
|
480
558
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
481
|
-
readonly quality?: "
|
|
559
|
+
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
482
560
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
483
561
|
readonly output_compression?: number | undefined;
|
|
484
562
|
readonly input_fidelity?: "low" | "high" | undefined;
|
|
485
563
|
readonly partial_images?: number | undefined;
|
|
486
564
|
})[] | undefined;
|
|
487
565
|
readonly text?: {
|
|
488
|
-
readonly verbosity?: "
|
|
566
|
+
readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
|
|
489
567
|
} | undefined;
|
|
490
568
|
readonly temperature?: number | undefined;
|
|
491
|
-
readonly tool_choice?: "required" | "
|
|
569
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
492
570
|
readonly type: "function";
|
|
493
571
|
readonly name: string;
|
|
572
|
+
} | {
|
|
573
|
+
readonly type: "allowed_tools";
|
|
574
|
+
readonly mode: "required" | "auto" | "none";
|
|
575
|
+
readonly tools: readonly {
|
|
576
|
+
readonly type: "function";
|
|
577
|
+
readonly name: string;
|
|
578
|
+
}[];
|
|
494
579
|
} | {
|
|
495
580
|
readonly type: "image_generation";
|
|
496
581
|
} | undefined;
|
|
497
582
|
readonly top_p?: number | undefined;
|
|
498
|
-
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
|
|
499
583
|
readonly store?: boolean | undefined;
|
|
584
|
+
readonly include?: readonly import("./utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
500
585
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
586
|
+
readonly stream_options?: {
|
|
587
|
+
readonly include_obfuscation?: boolean | undefined;
|
|
588
|
+
} | undefined;
|
|
501
589
|
readonly prompt_cache_key?: string | undefined;
|
|
590
|
+
readonly frequency_penalty?: number | undefined;
|
|
591
|
+
readonly presence_penalty?: number | undefined;
|
|
592
|
+
readonly safety_identifier?: string | undefined;
|
|
593
|
+
readonly top_logprobs?: number | undefined;
|
|
502
594
|
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
|
|
503
595
|
readonly max_output_tokens?: number | undefined;
|
|
596
|
+
readonly max_tool_calls?: number | undefined;
|
|
597
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
504
598
|
}, import("./open-responses-channel.js").Prepared, string>;
|
|
505
599
|
export declare const route: Route<{
|
|
506
600
|
readonly input: readonly ({
|
|
@@ -535,17 +629,20 @@ export declare const route: Route<{
|
|
|
535
629
|
readonly text: string;
|
|
536
630
|
})[];
|
|
537
631
|
} | {
|
|
632
|
+
readonly type: "message";
|
|
538
633
|
readonly content: readonly {
|
|
539
634
|
readonly type: "output_text";
|
|
540
635
|
readonly text: string;
|
|
541
636
|
}[];
|
|
542
637
|
readonly role: "assistant";
|
|
638
|
+
readonly id?: string | undefined;
|
|
543
639
|
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
544
640
|
} | {
|
|
545
641
|
readonly type: "function_call";
|
|
546
|
-
readonly call_id: string;
|
|
547
642
|
readonly name: string;
|
|
548
643
|
readonly arguments: string;
|
|
644
|
+
readonly call_id: string;
|
|
645
|
+
readonly id?: string | undefined;
|
|
549
646
|
} | {
|
|
550
647
|
readonly type: "function_call_output";
|
|
551
648
|
readonly call_id: string;
|
|
@@ -562,19 +659,24 @@ export declare const route: Route<{
|
|
|
562
659
|
readonly text: string;
|
|
563
660
|
})[];
|
|
564
661
|
} | {
|
|
662
|
+
readonly type: "message";
|
|
565
663
|
readonly content: readonly {
|
|
566
664
|
readonly type: "output_text";
|
|
567
665
|
readonly text: string;
|
|
568
666
|
}[];
|
|
569
667
|
readonly role: "assistant";
|
|
668
|
+
readonly id?: string | undefined;
|
|
570
669
|
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
571
670
|
})[];
|
|
572
671
|
readonly model: string;
|
|
573
672
|
readonly stream: true;
|
|
673
|
+
readonly metadata?: {
|
|
674
|
+
readonly [x: string]: string;
|
|
675
|
+
} | undefined;
|
|
574
676
|
readonly instructions?: string | undefined;
|
|
575
677
|
readonly reasoning?: {
|
|
576
678
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
577
|
-
readonly effort?:
|
|
679
|
+
readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
578
680
|
} | undefined;
|
|
579
681
|
readonly tools?: readonly ({
|
|
580
682
|
readonly type: "function";
|
|
@@ -589,28 +691,44 @@ export declare const route: Route<{
|
|
|
589
691
|
readonly size?: string | undefined;
|
|
590
692
|
readonly action?: "generate" | "auto" | "edit" | undefined;
|
|
591
693
|
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
592
|
-
readonly quality?: "
|
|
694
|
+
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
593
695
|
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
594
696
|
readonly output_compression?: number | undefined;
|
|
595
697
|
readonly input_fidelity?: "low" | "high" | undefined;
|
|
596
698
|
readonly partial_images?: number | undefined;
|
|
597
699
|
})[] | undefined;
|
|
598
700
|
readonly text?: {
|
|
599
|
-
readonly verbosity?: "
|
|
701
|
+
readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
|
|
600
702
|
} | undefined;
|
|
601
703
|
readonly temperature?: number | undefined;
|
|
602
|
-
readonly tool_choice?: "required" | "
|
|
704
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
603
705
|
readonly type: "function";
|
|
604
706
|
readonly name: string;
|
|
707
|
+
} | {
|
|
708
|
+
readonly type: "allowed_tools";
|
|
709
|
+
readonly mode: "required" | "auto" | "none";
|
|
710
|
+
readonly tools: readonly {
|
|
711
|
+
readonly type: "function";
|
|
712
|
+
readonly name: string;
|
|
713
|
+
}[];
|
|
605
714
|
} | {
|
|
606
715
|
readonly type: "image_generation";
|
|
607
716
|
} | undefined;
|
|
608
717
|
readonly top_p?: number | undefined;
|
|
609
|
-
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
|
|
610
718
|
readonly store?: boolean | undefined;
|
|
719
|
+
readonly include?: readonly import("./utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
611
720
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
721
|
+
readonly stream_options?: {
|
|
722
|
+
readonly include_obfuscation?: boolean | undefined;
|
|
723
|
+
} | undefined;
|
|
612
724
|
readonly prompt_cache_key?: string | undefined;
|
|
725
|
+
readonly frequency_penalty?: number | undefined;
|
|
726
|
+
readonly presence_penalty?: number | undefined;
|
|
727
|
+
readonly safety_identifier?: string | undefined;
|
|
728
|
+
readonly top_logprobs?: number | undefined;
|
|
613
729
|
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
|
|
614
730
|
readonly max_output_tokens?: number | undefined;
|
|
731
|
+
readonly max_tool_calls?: number | undefined;
|
|
732
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
615
733
|
}, import("./open-responses-channel.js").Prepared>;
|
|
616
734
|
export * as OpenAIResponses from "./openai-responses.js";
|
|
@@ -37,6 +37,8 @@ const OpenAIResponsesToolChoice = Schema.Union([
|
|
|
37
37
|
]);
|
|
38
38
|
const OpenAIResponsesInputItem = Schema.Union([
|
|
39
39
|
Schema.Struct({
|
|
40
|
+
type: Schema.tag("message"),
|
|
41
|
+
id: Schema.optionalKey(Schema.String),
|
|
40
42
|
role: Schema.tag("assistant"),
|
|
41
43
|
content: Schema.Array(Schema.Struct({ type: Schema.tag("output_text"), text: Schema.String })),
|
|
42
44
|
phase: Schema.optionalKey(Schema.NullOr(OpenResponses.MessagePhase)),
|
|
@@ -101,7 +103,7 @@ const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request)
|
|
|
101
103
|
tools: request.tools.length === 0
|
|
102
104
|
? undefined
|
|
103
105
|
: yield* Effect.forEach(request.tools, (tool) => lowerTool(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility))),
|
|
104
|
-
tool_choice: request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools) : undefined,
|
|
106
|
+
tool_choice: body.tool_choice ?? (request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools) : undefined),
|
|
105
107
|
};
|
|
106
108
|
});
|
|
107
109
|
const HOSTED_TOOLS = {
|
|
@@ -203,6 +205,6 @@ export const route = Route.make({
|
|
|
203
205
|
endpoint,
|
|
204
206
|
auth,
|
|
205
207
|
transport,
|
|
206
|
-
defaults: { providerOptions: {
|
|
208
|
+
defaults: { providerOptions: { store: false } },
|
|
207
209
|
});
|
|
208
210
|
export * as OpenAIResponses from "./openai-responses.js";
|
|
@@ -26,12 +26,10 @@ export interface ToolAccumulator {
|
|
|
26
26
|
* when at least one is defined. Returns `undefined` when neither input nor
|
|
27
27
|
* output is known so routes don't publish a misleading `0`.
|
|
28
28
|
*
|
|
29
|
-
* Under the
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* Anthropic-style providers (which don't surface a total) still get a
|
|
34
|
-
* sensible aggregate on the input + output axes.
|
|
29
|
+
* Under the inclusive `AI.Usage` contract, `inputTokens` includes cached input
|
|
30
|
+
* and `outputTokens` includes reasoning. Protocol mappers normalize those
|
|
31
|
+
* inclusive values before calling this helper. The provider-supplied total is
|
|
32
|
+
* the source of truth when present; otherwise their sum is the canonical total.
|
|
35
33
|
*/
|
|
36
34
|
export declare const totalTokens: (inputTokens: number | undefined, outputTokens: number | undefined, total: number | undefined) => number | undefined;
|
|
37
35
|
/**
|
|
@@ -43,7 +41,7 @@ export declare const totalTokens: (inputTokens: number | undefined, outputTokens
|
|
|
43
41
|
*
|
|
44
42
|
* If `total` is `undefined`, returns `undefined` (we don't fabricate
|
|
45
43
|
* counts). If `subtrahend` is `undefined`, returns `total` unchanged. The
|
|
46
|
-
* provider-native breakdown stays available on `Usage.
|
|
44
|
+
* provider-native breakdown stays available on `Usage.providerMetadata` for debugging.
|
|
47
45
|
*/
|
|
48
46
|
export declare const subtractTokens: (total: number | undefined, subtrahend: number | undefined) => number | undefined;
|
|
49
47
|
/**
|
|
@@ -117,19 +115,15 @@ export declare const toolResultText: (part: ToolResultPart) => string;
|
|
|
117
115
|
export declare const errorText: (error: unknown) => string;
|
|
118
116
|
/**
|
|
119
117
|
* `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
|
|
120
|
-
* decoder, and drops empty / `[DONE]` keep-alive events so the
|
|
121
|
-
*
|
|
118
|
+
* decoder, and drops empty / `[DONE]` keep-alive events so the protocol event
|
|
119
|
+
* schema sees one JSON string per element. The SSE channel emits a
|
|
122
120
|
* `Retry` control event on its error channel; we drop it here (we don't
|
|
123
121
|
* implement client-driven retries). Decoder failures become provider output
|
|
124
122
|
* errors so the public error channel stays `AIError`.
|
|
125
123
|
*/
|
|
126
124
|
export declare const sseFraming: (bytes: Stream.Stream<Uint8Array, AIError>) => Stream.Stream<string, AIError>;
|
|
127
125
|
/**
|
|
128
|
-
* Canonical invalid-request constructor
|
|
129
|
-
* (message) => invalidRequest(message)` aliases out of every
|
|
130
|
-
* route so the error constructor lives in one place. If we ever extend
|
|
131
|
-
* `InvalidRequestReason` with route context or trace metadata, the change
|
|
132
|
-
* lands here.
|
|
126
|
+
* Canonical invalid-request constructor shared by protocol lowering.
|
|
133
127
|
*/
|
|
134
128
|
export declare const invalidRequest: (message: string) => AIError;
|
|
135
129
|
export declare const matchToolChoice: <Auto, None, Required, Tool>(route: string, toolChoice: NonNullable<LLMRequest["toolChoice"]>, cases: {
|
package/dist/protocols/shared.js
CHANGED
|
@@ -19,12 +19,10 @@ export const optionalNull = (schema) => Schema.optional(Schema.NullOr(schema));
|
|
|
19
19
|
* when at least one is defined. Returns `undefined` when neither input nor
|
|
20
20
|
* output is known so routes don't publish a misleading `0`.
|
|
21
21
|
*
|
|
22
|
-
* Under the
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Anthropic-style providers (which don't surface a total) still get a
|
|
27
|
-
* sensible aggregate on the input + output axes.
|
|
22
|
+
* Under the inclusive `AI.Usage` contract, `inputTokens` includes cached input
|
|
23
|
+
* and `outputTokens` includes reasoning. Protocol mappers normalize those
|
|
24
|
+
* inclusive values before calling this helper. The provider-supplied total is
|
|
25
|
+
* the source of truth when present; otherwise their sum is the canonical total.
|
|
28
26
|
*/
|
|
29
27
|
export const totalTokens = (inputTokens, outputTokens, total) => {
|
|
30
28
|
if (total !== undefined)
|
|
@@ -42,7 +40,7 @@ export const totalTokens = (inputTokens, outputTokens, total) => {
|
|
|
42
40
|
*
|
|
43
41
|
* If `total` is `undefined`, returns `undefined` (we don't fabricate
|
|
44
42
|
* counts). If `subtrahend` is `undefined`, returns `total` unchanged. The
|
|
45
|
-
* provider-native breakdown stays available on `Usage.
|
|
43
|
+
* provider-native breakdown stays available on `Usage.providerMetadata` for debugging.
|
|
46
44
|
*/
|
|
47
45
|
export const subtractTokens = (total, subtrahend) => {
|
|
48
46
|
if (total === undefined)
|
|
@@ -151,19 +149,15 @@ export const errorText = (error) => {
|
|
|
151
149
|
};
|
|
152
150
|
/**
|
|
153
151
|
* `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
|
|
154
|
-
* decoder, and drops empty / `[DONE]` keep-alive events so the
|
|
155
|
-
*
|
|
152
|
+
* decoder, and drops empty / `[DONE]` keep-alive events so the protocol event
|
|
153
|
+
* schema sees one JSON string per element. The SSE channel emits a
|
|
156
154
|
* `Retry` control event on its error channel; we drop it here (we don't
|
|
157
155
|
* implement client-driven retries). Decoder failures become provider output
|
|
158
156
|
* errors so the public error channel stays `AIError`.
|
|
159
157
|
*/
|
|
160
158
|
export const sseFraming = (bytes) => bytes.pipe(Stream.decodeText(), Stream.pipeThroughChannel(Sse.decode()), Stream.catchTag("Retry", () => Stream.empty), Stream.catchTag("SseError", (error) => Stream.fail(eventError("sse", error.message))), Stream.filter((event) => event.data.length > 0 && event.data !== "[DONE]"), Stream.map((event) => event.data));
|
|
161
159
|
/**
|
|
162
|
-
* Canonical invalid-request constructor
|
|
163
|
-
* (message) => invalidRequest(message)` aliases out of every
|
|
164
|
-
* route so the error constructor lives in one place. If we ever extend
|
|
165
|
-
* `InvalidRequestReason` with route context or trace metadata, the change
|
|
166
|
-
* lands here.
|
|
160
|
+
* Canonical invalid-request constructor shared by protocol lowering.
|
|
167
161
|
*/
|
|
168
162
|
export const invalidRequest = (message) => new AIError({
|
|
169
163
|
module: "ProviderShared",
|
|
@@ -2,16 +2,15 @@ import { Schema } from "effect";
|
|
|
2
2
|
import { newBreakpoints, ttlBucket } from "./cache.js";
|
|
3
3
|
// Bedrock cache markers are positional: emit a `cachePoint` block immediately
|
|
4
4
|
// after the content the caller wants treated as a cacheable prefix. Bedrock
|
|
5
|
-
// accepts optional `ttl: "5m" | "1h"` on cachePoint
|
|
5
|
+
// accepts optional `ttl: "5m" | "1h"` on cachePoint.
|
|
6
6
|
export const CachePointBlock = Schema.Struct({
|
|
7
7
|
cachePoint: Schema.Struct({
|
|
8
8
|
type: Schema.tag("default"),
|
|
9
9
|
ttl: Schema.optional(Schema.Literals(["5m", "1h"])),
|
|
10
10
|
}),
|
|
11
11
|
});
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// budget is respected across `system`, `messages`, and `tools`.
|
|
12
|
+
// Callers pass a shared counter through every `block()` call site so the
|
|
13
|
+
// four-breakpoint budget is respected across `system`, `messages`, and `tools`.
|
|
15
14
|
export const BEDROCK_BREAKPOINT_CAP = 4;
|
|
16
15
|
export const breakpoints = () => newBreakpoints(BEDROCK_BREAKPOINT_CAP);
|
|
17
16
|
const DEFAULT_5M = { cachePoint: { type: "default" } };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// Shared
|
|
2
|
-
// both enforce a 4-breakpoint cap per request and accept the same `5m`/`1h`
|
|
3
|
-
// TTL buckets, so the counter and TTL mapping live here.
|
|
1
|
+
// Shared counter and TTL mapping for provider cache-marker lowering.
|
|
4
2
|
export const newBreakpoints = (cap) => ({ remaining: cap, dropped: 0 });
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// an hour as 5m.
|
|
3
|
+
// Requests of at least one hour use the explicit `"1h"` bucket; shorter
|
|
4
|
+
// requests omit the wire TTL and use the provider default.
|
|
8
5
|
export const ttlBucket = (ttlSeconds) => ttlSeconds !== undefined && ttlSeconds >= 3600 ? "1h" : undefined;
|