@opencode/ai 2.0.21 → 2.0.23
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 +61 -1
- package/dist/cache-policy.js +10 -2
- package/dist/llm.d.ts +4 -0
- package/dist/promise.d.ts +8 -0
- package/dist/protocols/alibaba-chat.d.ts +7 -3
- package/dist/protocols/alibaba-chat.js +2 -1
- package/dist/protocols/alibaba-responses.d.ts +16 -12
- package/dist/protocols/alibaba-responses.js +3 -5
- package/dist/protocols/anthropic-messages.js +58 -51
- package/dist/protocols/bedrock-converse.js +33 -4
- package/dist/protocols/cartesia-speech.js +3 -3
- package/dist/protocols/cohere-chat.d.ts +178 -0
- package/dist/protocols/cohere-chat.js +299 -0
- package/dist/protocols/elevenlabs-speech.js +3 -3
- package/dist/protocols/gemini.d.ts +2 -2
- package/dist/protocols/gemini.js +3 -3
- package/dist/protocols/google-interactions.d.ts +236 -0
- package/dist/protocols/google-interactions.js +478 -0
- package/dist/protocols/google-speech.js +1 -1
- package/dist/protocols/google-transcription.js +1 -1
- package/dist/protocols/index.d.ts +2 -0
- package/dist/protocols/index.js +2 -0
- package/dist/protocols/meta-responses.d.ts +31 -58
- package/dist/protocols/meta-responses.js +8 -27
- package/dist/protocols/mistral-chat.d.ts +24 -9
- package/dist/protocols/mistral-chat.js +22 -10
- package/dist/protocols/open-responses.d.ts +410 -91
- package/dist/protocols/open-responses.js +25 -15
- package/dist/protocols/openai-chat.d.ts +409 -5
- package/dist/protocols/openai-chat.js +27 -26
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +16 -4
- package/dist/protocols/openai-images.js +2 -2
- package/dist/protocols/openai-responses.d.ts +87 -223
- package/dist/protocols/openai-responses.js +10 -16
- package/dist/protocols/openai-speech.js +1 -1
- package/dist/protocols/openai-transcription.js +1 -1
- package/dist/protocols/shared.js +2 -2
- package/dist/protocols/stability-images.js +1 -1
- package/dist/protocols/utils/bedrock-media.js +2 -2
- package/dist/protocols/utils/cache.d.ts +5 -0
- package/dist/protocols/utils/cache.js +9 -1
- package/dist/protocols/utils/responses-checkpoint.js +2 -2
- package/dist/protocols/utils/responses-hosted-tools.js +1 -1
- package/dist/protocols/utils/tool-stream.d.ts +12 -0
- package/dist/protocols/utils/tool-stream.js +15 -7
- package/dist/protocols/venice-chat.d.ts +280 -0
- package/dist/protocols/venice-chat.js +283 -0
- package/dist/protocols/xai-responses.d.ts +18 -21
- package/dist/protocols/xai-responses.js +2 -8
- package/dist/protocols/zai-chat.d.ts +7 -3
- package/dist/protocols/zai-chat.js +6 -3
- package/dist/provider-error.js +27 -7
- package/dist/providers/alibaba.d.ts +17 -13
- package/dist/providers/amazon-bedrock/mantle/messages.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/messages.js +1 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +301 -9
- package/dist/providers/amazon-bedrock-mantle.js +28 -3
- package/dist/providers/azure.d.ts +13 -61
- package/dist/providers/baseten.d.ts +2 -2
- package/dist/providers/cerebras.d.ts +2 -2
- package/dist/providers/cloudflare-ai-gateway.d.ts +14 -62
- package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
- package/dist/providers/cohere/chat.d.ts +4 -0
- package/dist/providers/cohere/chat.js +8 -0
- package/dist/providers/cohere.d.ts +395 -0
- package/dist/providers/cohere.js +48 -0
- package/dist/providers/deepinfra.d.ts +2 -2
- package/dist/providers/deepseek.d.ts +2 -2
- package/dist/providers/digitalocean.d.ts +469 -0
- package/dist/providers/digitalocean.js +53 -0
- package/dist/providers/fireworks.d.ts +2 -2
- package/dist/providers/google/interactions.d.ts +7 -0
- package/dist/providers/google/interactions.js +8 -0
- package/dist/providers/google-vertex-chat.d.ts +1 -1
- package/dist/providers/google-vertex-messages.js +1 -1
- package/dist/providers/google-vertex-responses.d.ts +16 -4
- package/dist/providers/google-vertex.d.ts +1 -1
- package/dist/providers/google.d.ts +95 -4
- package/dist/providers/google.js +8 -1
- package/dist/providers/groq.d.ts +8 -4
- package/dist/providers/groq.js +1 -1
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.js +3 -0
- package/dist/providers/meta.d.ts +15 -28
- package/dist/providers/minimax.d.ts +17 -5
- package/dist/providers/mistral.d.ts +10 -4
- package/dist/providers/moonshot.d.ts +17 -5
- package/dist/providers/openai-compatible-responses.d.ts +16 -4
- package/dist/providers/openai-compatible.d.ts +1 -1
- package/dist/providers/openai-options.d.ts +1 -1
- package/dist/providers/openai.d.ts +7 -31
- package/dist/providers/openrouter.d.ts +9 -5
- package/dist/providers/openrouter.js +1 -13
- package/dist/providers/togetherai.d.ts +2 -2
- package/dist/providers/venice.d.ts +183 -0
- package/dist/providers/venice.js +38 -0
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/zai-coding-plan.d.ts +17 -5
- package/dist/providers/zai.d.ts +1 -1
- package/dist/route/client.d.ts +4 -0
- package/dist/route/client.js +2 -5
- package/dist/route/executor.js +13 -6
- package/dist/route/framing.js +23 -23
- package/dist/route/transport/http.d.ts +2 -1
- package/dist/route/transport/http.js +28 -6
- package/dist/schema/events.d.ts +176 -0
- package/dist/schema/events.js +4 -0
- package/dist/schema/options.d.ts +11 -0
- package/dist/schema/options.js +15 -2
- package/dist/testing.d.ts +32 -0
- package/dist/tool-history.js +17 -3
- package/package.json +3 -3
|
@@ -13,10 +13,61 @@ export declare const ContextManagement: Schema.$Array<Schema.Struct<{
|
|
|
13
13
|
export type ContextManagement = typeof ContextManagement.Type;
|
|
14
14
|
declare const OpenAIResponsesBody: Schema.Struct<{
|
|
15
15
|
readonly stream: Schema.Literal<true>;
|
|
16
|
-
readonly
|
|
16
|
+
readonly tools: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
17
|
+
readonly type: Schema.tag<"function">;
|
|
18
|
+
readonly name: Schema.String;
|
|
19
|
+
readonly description: Schema.String;
|
|
20
|
+
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
21
|
+
readonly strict: Schema.optional<Schema.Boolean>;
|
|
22
|
+
}>, Schema.Struct<{
|
|
23
|
+
readonly type: Schema.tag<"namespace">;
|
|
24
|
+
readonly name: Schema.String;
|
|
25
|
+
readonly description: Schema.String;
|
|
26
|
+
readonly tools: Schema.$Array<Schema.Struct<{
|
|
27
|
+
readonly type: Schema.tag<"function">;
|
|
28
|
+
readonly name: Schema.String;
|
|
29
|
+
readonly description: Schema.String;
|
|
30
|
+
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
31
|
+
readonly strict: Schema.optional<Schema.Boolean>;
|
|
32
|
+
}>>;
|
|
33
|
+
}>, Schema.Struct<{
|
|
34
|
+
readonly type: Schema.tag<"image_generation">;
|
|
35
|
+
readonly action: Schema.optional<Schema.Literals<readonly ["auto", "generate", "edit"]>>;
|
|
36
|
+
readonly background: Schema.optional<Schema.Literals<readonly ["auto", "opaque", "transparent"]>>;
|
|
37
|
+
readonly input_fidelity: Schema.optional<Schema.Literals<readonly ["low", "high"]>>;
|
|
38
|
+
readonly output_compression: Schema.optional<Schema.Int>;
|
|
39
|
+
readonly output_format: Schema.optional<Schema.Literals<readonly ["png", "jpeg", "webp"]>>;
|
|
40
|
+
readonly partial_images: Schema.optional<Schema.Int>;
|
|
41
|
+
readonly quality: Schema.optional<Schema.Literals<readonly ["auto", "low", "medium", "high"]>>;
|
|
42
|
+
readonly size: Schema.optional<Schema.String>;
|
|
43
|
+
}>]>>>;
|
|
44
|
+
readonly tool_choice: Schema.optional<Schema.Union<readonly [Schema.Union<readonly [Schema.Literals<readonly ["auto", "none", "required"]>, Schema.Struct<{
|
|
45
|
+
readonly type: Schema.tag<"function">;
|
|
46
|
+
readonly name: Schema.String;
|
|
47
|
+
}>, Schema.Struct<{
|
|
48
|
+
readonly type: Schema.tag<"allowed_tools">;
|
|
49
|
+
readonly mode: Schema.Literals<readonly ["auto", "none", "required"]>;
|
|
50
|
+
readonly tools: Schema.$Array<Schema.Struct<{
|
|
51
|
+
readonly type: Schema.tag<"function">;
|
|
52
|
+
readonly name: Schema.String;
|
|
53
|
+
}>>;
|
|
54
|
+
}>]>, Schema.Struct<{
|
|
55
|
+
readonly type: Schema.tag<"image_generation">;
|
|
56
|
+
}>]>>;
|
|
57
|
+
readonly context_management: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
58
|
+
readonly type: Schema.Literal<"compaction">;
|
|
59
|
+
readonly compact_threshold: Schema.optional<Schema.Int>;
|
|
60
|
+
}>>>;
|
|
61
|
+
readonly model: Schema.String;
|
|
62
|
+
readonly input: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
17
63
|
readonly type: Schema.Literal<"compaction">;
|
|
18
64
|
readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
19
65
|
readonly encrypted_content: Schema.String;
|
|
66
|
+
}>, Schema.Struct<{
|
|
67
|
+
readonly type: Schema.Literal<"configuration_update">;
|
|
68
|
+
readonly reasoning: Schema.Struct<{
|
|
69
|
+
readonly effort: Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>;
|
|
70
|
+
}>;
|
|
20
71
|
}>, Schema.Struct<{
|
|
21
72
|
readonly type: Schema.tag<"message">;
|
|
22
73
|
readonly role: Schema.tag<"system">;
|
|
@@ -116,77 +167,10 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
116
167
|
readonly arguments: Schema.optional<Schema.String>;
|
|
117
168
|
readonly output: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
118
169
|
readonly error: Schema.optional<Schema.Unknown>;
|
|
119
|
-
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>]
|
|
120
|
-
readonly type: Schema.
|
|
170
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>]>, Schema.StructWithRest<Schema.Struct<{
|
|
171
|
+
readonly type: Schema.String;
|
|
121
172
|
readonly id: Schema.String;
|
|
122
|
-
|
|
123
|
-
readonly call_id: Schema.optional<Schema.String>;
|
|
124
|
-
readonly action: Schema.optional<Schema.NullOr<Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
125
|
-
readonly pending_safety_checks: Schema.optional<Schema.$Array<Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
126
|
-
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.StructWithRest<Schema.Struct<{
|
|
127
|
-
readonly type: Schema.tag<"web_search_preview_call">;
|
|
128
|
-
readonly id: Schema.String;
|
|
129
|
-
readonly status: Schema.optional<Schema.String>;
|
|
130
|
-
readonly action: Schema.optional<Schema.NullOr<Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
131
|
-
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.StructWithRest<Schema.Struct<{
|
|
132
|
-
readonly type: Schema.tag<"image_generation_call">;
|
|
133
|
-
readonly id: Schema.String;
|
|
134
|
-
readonly status: Schema.optional<Schema.String>;
|
|
135
|
-
readonly result: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
136
|
-
readonly output_format: Schema.optional<Schema.Literals<readonly ["png", "jpeg", "webp"]>>;
|
|
137
|
-
readonly revised_prompt: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
138
|
-
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>]>, Schema.Struct<{
|
|
139
|
-
readonly type: Schema.Literal<"configuration_update">;
|
|
140
|
-
readonly reasoning: Schema.Struct<{
|
|
141
|
-
readonly effort: Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>;
|
|
142
|
-
}>;
|
|
143
|
-
}>]>>;
|
|
144
|
-
readonly tools: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
145
|
-
readonly type: Schema.tag<"function">;
|
|
146
|
-
readonly name: Schema.String;
|
|
147
|
-
readonly description: Schema.String;
|
|
148
|
-
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
149
|
-
readonly strict: Schema.optional<Schema.Boolean>;
|
|
150
|
-
}>, Schema.Struct<{
|
|
151
|
-
readonly type: Schema.tag<"namespace">;
|
|
152
|
-
readonly name: Schema.String;
|
|
153
|
-
readonly description: Schema.String;
|
|
154
|
-
readonly tools: Schema.$Array<Schema.Struct<{
|
|
155
|
-
readonly type: Schema.tag<"function">;
|
|
156
|
-
readonly name: Schema.String;
|
|
157
|
-
readonly description: Schema.String;
|
|
158
|
-
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
159
|
-
readonly strict: Schema.optional<Schema.Boolean>;
|
|
160
|
-
}>>;
|
|
161
|
-
}>, Schema.Struct<{
|
|
162
|
-
readonly type: Schema.tag<"image_generation">;
|
|
163
|
-
readonly action: Schema.optional<Schema.Literals<readonly ["auto", "generate", "edit"]>>;
|
|
164
|
-
readonly background: Schema.optional<Schema.Literals<readonly ["auto", "opaque", "transparent"]>>;
|
|
165
|
-
readonly input_fidelity: Schema.optional<Schema.Literals<readonly ["low", "high"]>>;
|
|
166
|
-
readonly output_compression: Schema.optional<Schema.Int>;
|
|
167
|
-
readonly output_format: Schema.optional<Schema.Literals<readonly ["png", "jpeg", "webp"]>>;
|
|
168
|
-
readonly partial_images: Schema.optional<Schema.Int>;
|
|
169
|
-
readonly quality: Schema.optional<Schema.Literals<readonly ["auto", "low", "medium", "high"]>>;
|
|
170
|
-
readonly size: Schema.optional<Schema.String>;
|
|
171
|
-
}>]>>>;
|
|
172
|
-
readonly tool_choice: Schema.optional<Schema.Union<readonly [Schema.Union<readonly [Schema.Literals<readonly ["auto", "none", "required"]>, Schema.Struct<{
|
|
173
|
-
readonly type: Schema.tag<"function">;
|
|
174
|
-
readonly name: Schema.String;
|
|
175
|
-
}>, Schema.Struct<{
|
|
176
|
-
readonly type: Schema.tag<"allowed_tools">;
|
|
177
|
-
readonly mode: Schema.Literals<readonly ["auto", "none", "required"]>;
|
|
178
|
-
readonly tools: Schema.$Array<Schema.Struct<{
|
|
179
|
-
readonly type: Schema.tag<"function">;
|
|
180
|
-
readonly name: Schema.String;
|
|
181
|
-
}>>;
|
|
182
|
-
}>]>, Schema.Struct<{
|
|
183
|
-
readonly type: Schema.tag<"image_generation">;
|
|
184
|
-
}>]>>;
|
|
185
|
-
readonly context_management: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
186
|
-
readonly type: Schema.Literal<"compaction">;
|
|
187
|
-
readonly compact_threshold: Schema.optional<Schema.Int>;
|
|
188
|
-
}>>>;
|
|
189
|
-
readonly model: Schema.String;
|
|
173
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>]>>;
|
|
190
174
|
readonly instructions: Schema.optional<Schema.String>;
|
|
191
175
|
readonly store: Schema.optional<Schema.Boolean>;
|
|
192
176
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
@@ -262,6 +246,10 @@ export declare const protocol: Protocol<{
|
|
|
262
246
|
readonly reasoning: {
|
|
263
247
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
264
248
|
};
|
|
249
|
+
} | {
|
|
250
|
+
readonly [x: string]: unknown;
|
|
251
|
+
readonly type: string;
|
|
252
|
+
readonly id: string;
|
|
265
253
|
} | {
|
|
266
254
|
readonly type: "reasoning";
|
|
267
255
|
readonly summary: readonly {
|
|
@@ -338,34 +326,6 @@ export declare const protocol: Protocol<{
|
|
|
338
326
|
readonly type: "input_video";
|
|
339
327
|
readonly video_url: string;
|
|
340
328
|
})[];
|
|
341
|
-
} | {
|
|
342
|
-
readonly [x: string]: unknown;
|
|
343
|
-
readonly id: string;
|
|
344
|
-
readonly type: "computer_call";
|
|
345
|
-
readonly status?: string | undefined;
|
|
346
|
-
readonly action?: {
|
|
347
|
-
readonly [x: string]: unknown;
|
|
348
|
-
} | null | undefined;
|
|
349
|
-
readonly call_id?: string | undefined;
|
|
350
|
-
readonly pending_safety_checks?: readonly {
|
|
351
|
-
readonly [x: string]: unknown;
|
|
352
|
-
}[] | undefined;
|
|
353
|
-
} | {
|
|
354
|
-
readonly [x: string]: unknown;
|
|
355
|
-
readonly id: string;
|
|
356
|
-
readonly type: "web_search_preview_call";
|
|
357
|
-
readonly status?: string | undefined;
|
|
358
|
-
readonly action?: {
|
|
359
|
-
readonly [x: string]: unknown;
|
|
360
|
-
} | null | undefined;
|
|
361
|
-
} | {
|
|
362
|
-
readonly [x: string]: unknown;
|
|
363
|
-
readonly id: string;
|
|
364
|
-
readonly type: "image_generation_call";
|
|
365
|
-
readonly status?: string | undefined;
|
|
366
|
-
readonly result?: string | null | undefined;
|
|
367
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
368
|
-
readonly revised_prompt?: string | null | undefined;
|
|
369
329
|
})[];
|
|
370
330
|
readonly model: string;
|
|
371
331
|
readonly stream: true;
|
|
@@ -434,9 +394,10 @@ export declare const protocol: Protocol<{
|
|
|
434
394
|
readonly top_p?: number | undefined;
|
|
435
395
|
readonly frequency_penalty?: number | undefined;
|
|
436
396
|
readonly presence_penalty?: number | undefined;
|
|
397
|
+
readonly store?: boolean | undefined;
|
|
398
|
+
readonly max_output_tokens?: number | undefined;
|
|
437
399
|
readonly prompt_cache_key?: string | undefined;
|
|
438
400
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
439
|
-
readonly store?: boolean | undefined;
|
|
440
401
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
441
402
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
442
403
|
readonly stream_options?: {
|
|
@@ -444,7 +405,6 @@ export declare const protocol: Protocol<{
|
|
|
444
405
|
} | undefined;
|
|
445
406
|
readonly safety_identifier?: string | undefined;
|
|
446
407
|
readonly top_logprobs?: number | undefined;
|
|
447
|
-
readonly max_output_tokens?: number | undefined;
|
|
448
408
|
readonly max_tool_calls?: number | undefined;
|
|
449
409
|
}, string, {
|
|
450
410
|
readonly [x: string]: unknown;
|
|
@@ -464,8 +424,8 @@ export declare const protocol: Protocol<{
|
|
|
464
424
|
readonly name?: string | undefined;
|
|
465
425
|
readonly namespace?: string | undefined;
|
|
466
426
|
readonly arguments?: string | undefined;
|
|
467
|
-
readonly encrypted_content?: string | null | undefined;
|
|
468
427
|
readonly call_id?: string | undefined;
|
|
428
|
+
readonly encrypted_content?: string | null | undefined;
|
|
469
429
|
}[] | undefined;
|
|
470
430
|
readonly error?: unknown;
|
|
471
431
|
readonly usage?: {
|
|
@@ -492,8 +452,8 @@ export declare const protocol: Protocol<{
|
|
|
492
452
|
readonly name?: string | undefined;
|
|
493
453
|
readonly namespace?: string | undefined;
|
|
494
454
|
readonly arguments?: string | undefined;
|
|
495
|
-
readonly encrypted_content?: string | null | undefined;
|
|
496
455
|
readonly call_id?: string | undefined;
|
|
456
|
+
readonly encrypted_content?: string | null | undefined;
|
|
497
457
|
} | null | undefined;
|
|
498
458
|
readonly delta?: string | undefined;
|
|
499
459
|
readonly arguments?: string | undefined;
|
|
@@ -545,6 +505,10 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
545
505
|
readonly reasoning: {
|
|
546
506
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
547
507
|
};
|
|
508
|
+
} | {
|
|
509
|
+
readonly [x: string]: unknown;
|
|
510
|
+
readonly type: string;
|
|
511
|
+
readonly id: string;
|
|
548
512
|
} | {
|
|
549
513
|
readonly type: "reasoning";
|
|
550
514
|
readonly summary: readonly {
|
|
@@ -621,34 +585,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
621
585
|
readonly type: "input_video";
|
|
622
586
|
readonly video_url: string;
|
|
623
587
|
})[];
|
|
624
|
-
} | {
|
|
625
|
-
readonly [x: string]: unknown;
|
|
626
|
-
readonly id: string;
|
|
627
|
-
readonly type: "computer_call";
|
|
628
|
-
readonly status?: string | undefined;
|
|
629
|
-
readonly action?: {
|
|
630
|
-
readonly [x: string]: unknown;
|
|
631
|
-
} | null | undefined;
|
|
632
|
-
readonly call_id?: string | undefined;
|
|
633
|
-
readonly pending_safety_checks?: readonly {
|
|
634
|
-
readonly [x: string]: unknown;
|
|
635
|
-
}[] | undefined;
|
|
636
|
-
} | {
|
|
637
|
-
readonly [x: string]: unknown;
|
|
638
|
-
readonly id: string;
|
|
639
|
-
readonly type: "web_search_preview_call";
|
|
640
|
-
readonly status?: string | undefined;
|
|
641
|
-
readonly action?: {
|
|
642
|
-
readonly [x: string]: unknown;
|
|
643
|
-
} | null | undefined;
|
|
644
|
-
} | {
|
|
645
|
-
readonly [x: string]: unknown;
|
|
646
|
-
readonly id: string;
|
|
647
|
-
readonly type: "image_generation_call";
|
|
648
|
-
readonly status?: string | undefined;
|
|
649
|
-
readonly result?: string | null | undefined;
|
|
650
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
651
|
-
readonly revised_prompt?: string | null | undefined;
|
|
652
588
|
})[];
|
|
653
589
|
readonly model: string;
|
|
654
590
|
readonly stream: true;
|
|
@@ -717,9 +653,10 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
717
653
|
readonly top_p?: number | undefined;
|
|
718
654
|
readonly frequency_penalty?: number | undefined;
|
|
719
655
|
readonly presence_penalty?: number | undefined;
|
|
656
|
+
readonly store?: boolean | undefined;
|
|
657
|
+
readonly max_output_tokens?: number | undefined;
|
|
720
658
|
readonly prompt_cache_key?: string | undefined;
|
|
721
659
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
722
|
-
readonly store?: boolean | undefined;
|
|
723
660
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
724
661
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
725
662
|
readonly stream_options?: {
|
|
@@ -727,7 +664,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
727
664
|
} | undefined;
|
|
728
665
|
readonly safety_identifier?: string | undefined;
|
|
729
666
|
readonly top_logprobs?: number | undefined;
|
|
730
|
-
readonly max_output_tokens?: number | undefined;
|
|
731
667
|
readonly max_tool_calls?: number | undefined;
|
|
732
668
|
}, string>;
|
|
733
669
|
export declare const channelTransport: (options: import("./open-responses-channel.js").Options) => import("../route/transport/index.js").Transport<{
|
|
@@ -773,6 +709,10 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
773
709
|
readonly reasoning: {
|
|
774
710
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
775
711
|
};
|
|
712
|
+
} | {
|
|
713
|
+
readonly [x: string]: unknown;
|
|
714
|
+
readonly type: string;
|
|
715
|
+
readonly id: string;
|
|
776
716
|
} | {
|
|
777
717
|
readonly type: "reasoning";
|
|
778
718
|
readonly summary: readonly {
|
|
@@ -849,34 +789,6 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
849
789
|
readonly type: "input_video";
|
|
850
790
|
readonly video_url: string;
|
|
851
791
|
})[];
|
|
852
|
-
} | {
|
|
853
|
-
readonly [x: string]: unknown;
|
|
854
|
-
readonly id: string;
|
|
855
|
-
readonly type: "computer_call";
|
|
856
|
-
readonly status?: string | undefined;
|
|
857
|
-
readonly action?: {
|
|
858
|
-
readonly [x: string]: unknown;
|
|
859
|
-
} | null | undefined;
|
|
860
|
-
readonly call_id?: string | undefined;
|
|
861
|
-
readonly pending_safety_checks?: readonly {
|
|
862
|
-
readonly [x: string]: unknown;
|
|
863
|
-
}[] | undefined;
|
|
864
|
-
} | {
|
|
865
|
-
readonly [x: string]: unknown;
|
|
866
|
-
readonly id: string;
|
|
867
|
-
readonly type: "web_search_preview_call";
|
|
868
|
-
readonly status?: string | undefined;
|
|
869
|
-
readonly action?: {
|
|
870
|
-
readonly [x: string]: unknown;
|
|
871
|
-
} | null | undefined;
|
|
872
|
-
} | {
|
|
873
|
-
readonly [x: string]: unknown;
|
|
874
|
-
readonly id: string;
|
|
875
|
-
readonly type: "image_generation_call";
|
|
876
|
-
readonly status?: string | undefined;
|
|
877
|
-
readonly result?: string | null | undefined;
|
|
878
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
879
|
-
readonly revised_prompt?: string | null | undefined;
|
|
880
792
|
})[];
|
|
881
793
|
readonly model: string;
|
|
882
794
|
readonly stream: true;
|
|
@@ -945,9 +857,10 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
945
857
|
readonly top_p?: number | undefined;
|
|
946
858
|
readonly frequency_penalty?: number | undefined;
|
|
947
859
|
readonly presence_penalty?: number | undefined;
|
|
860
|
+
readonly store?: boolean | undefined;
|
|
861
|
+
readonly max_output_tokens?: number | undefined;
|
|
948
862
|
readonly prompt_cache_key?: string | undefined;
|
|
949
863
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
950
|
-
readonly store?: boolean | undefined;
|
|
951
864
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
952
865
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
953
866
|
readonly stream_options?: {
|
|
@@ -955,7 +868,6 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
955
868
|
} | undefined;
|
|
956
869
|
readonly safety_identifier?: string | undefined;
|
|
957
870
|
readonly top_logprobs?: number | undefined;
|
|
958
|
-
readonly max_output_tokens?: number | undefined;
|
|
959
871
|
readonly max_tool_calls?: number | undefined;
|
|
960
872
|
}, import("./open-responses-channel.js").Prepared, string>;
|
|
961
873
|
export declare const transport: import("../route/transport/index.js").Transport<{
|
|
@@ -1001,6 +913,10 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1001
913
|
readonly reasoning: {
|
|
1002
914
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
1003
915
|
};
|
|
916
|
+
} | {
|
|
917
|
+
readonly [x: string]: unknown;
|
|
918
|
+
readonly type: string;
|
|
919
|
+
readonly id: string;
|
|
1004
920
|
} | {
|
|
1005
921
|
readonly type: "reasoning";
|
|
1006
922
|
readonly summary: readonly {
|
|
@@ -1077,34 +993,6 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1077
993
|
readonly type: "input_video";
|
|
1078
994
|
readonly video_url: string;
|
|
1079
995
|
})[];
|
|
1080
|
-
} | {
|
|
1081
|
-
readonly [x: string]: unknown;
|
|
1082
|
-
readonly id: string;
|
|
1083
|
-
readonly type: "computer_call";
|
|
1084
|
-
readonly status?: string | undefined;
|
|
1085
|
-
readonly action?: {
|
|
1086
|
-
readonly [x: string]: unknown;
|
|
1087
|
-
} | null | undefined;
|
|
1088
|
-
readonly call_id?: string | undefined;
|
|
1089
|
-
readonly pending_safety_checks?: readonly {
|
|
1090
|
-
readonly [x: string]: unknown;
|
|
1091
|
-
}[] | undefined;
|
|
1092
|
-
} | {
|
|
1093
|
-
readonly [x: string]: unknown;
|
|
1094
|
-
readonly id: string;
|
|
1095
|
-
readonly type: "web_search_preview_call";
|
|
1096
|
-
readonly status?: string | undefined;
|
|
1097
|
-
readonly action?: {
|
|
1098
|
-
readonly [x: string]: unknown;
|
|
1099
|
-
} | null | undefined;
|
|
1100
|
-
} | {
|
|
1101
|
-
readonly [x: string]: unknown;
|
|
1102
|
-
readonly id: string;
|
|
1103
|
-
readonly type: "image_generation_call";
|
|
1104
|
-
readonly status?: string | undefined;
|
|
1105
|
-
readonly result?: string | null | undefined;
|
|
1106
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
1107
|
-
readonly revised_prompt?: string | null | undefined;
|
|
1108
996
|
})[];
|
|
1109
997
|
readonly model: string;
|
|
1110
998
|
readonly stream: true;
|
|
@@ -1173,9 +1061,10 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1173
1061
|
readonly top_p?: number | undefined;
|
|
1174
1062
|
readonly frequency_penalty?: number | undefined;
|
|
1175
1063
|
readonly presence_penalty?: number | undefined;
|
|
1064
|
+
readonly store?: boolean | undefined;
|
|
1065
|
+
readonly max_output_tokens?: number | undefined;
|
|
1176
1066
|
readonly prompt_cache_key?: string | undefined;
|
|
1177
1067
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
1178
|
-
readonly store?: boolean | undefined;
|
|
1179
1068
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
1180
1069
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1181
1070
|
readonly stream_options?: {
|
|
@@ -1183,7 +1072,6 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1183
1072
|
} | undefined;
|
|
1184
1073
|
readonly safety_identifier?: string | undefined;
|
|
1185
1074
|
readonly top_logprobs?: number | undefined;
|
|
1186
|
-
readonly max_output_tokens?: number | undefined;
|
|
1187
1075
|
readonly max_tool_calls?: number | undefined;
|
|
1188
1076
|
}, import("./open-responses-channel.js").Prepared, string>;
|
|
1189
1077
|
export declare const route: Route<{
|
|
@@ -1229,6 +1117,10 @@ export declare const route: Route<{
|
|
|
1229
1117
|
readonly reasoning: {
|
|
1230
1118
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
1231
1119
|
};
|
|
1120
|
+
} | {
|
|
1121
|
+
readonly [x: string]: unknown;
|
|
1122
|
+
readonly type: string;
|
|
1123
|
+
readonly id: string;
|
|
1232
1124
|
} | {
|
|
1233
1125
|
readonly type: "reasoning";
|
|
1234
1126
|
readonly summary: readonly {
|
|
@@ -1305,34 +1197,6 @@ export declare const route: Route<{
|
|
|
1305
1197
|
readonly type: "input_video";
|
|
1306
1198
|
readonly video_url: string;
|
|
1307
1199
|
})[];
|
|
1308
|
-
} | {
|
|
1309
|
-
readonly [x: string]: unknown;
|
|
1310
|
-
readonly id: string;
|
|
1311
|
-
readonly type: "computer_call";
|
|
1312
|
-
readonly status?: string | undefined;
|
|
1313
|
-
readonly action?: {
|
|
1314
|
-
readonly [x: string]: unknown;
|
|
1315
|
-
} | null | undefined;
|
|
1316
|
-
readonly call_id?: string | undefined;
|
|
1317
|
-
readonly pending_safety_checks?: readonly {
|
|
1318
|
-
readonly [x: string]: unknown;
|
|
1319
|
-
}[] | undefined;
|
|
1320
|
-
} | {
|
|
1321
|
-
readonly [x: string]: unknown;
|
|
1322
|
-
readonly id: string;
|
|
1323
|
-
readonly type: "web_search_preview_call";
|
|
1324
|
-
readonly status?: string | undefined;
|
|
1325
|
-
readonly action?: {
|
|
1326
|
-
readonly [x: string]: unknown;
|
|
1327
|
-
} | null | undefined;
|
|
1328
|
-
} | {
|
|
1329
|
-
readonly [x: string]: unknown;
|
|
1330
|
-
readonly id: string;
|
|
1331
|
-
readonly type: "image_generation_call";
|
|
1332
|
-
readonly status?: string | undefined;
|
|
1333
|
-
readonly result?: string | null | undefined;
|
|
1334
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
1335
|
-
readonly revised_prompt?: string | null | undefined;
|
|
1336
1200
|
})[];
|
|
1337
1201
|
readonly model: string;
|
|
1338
1202
|
readonly stream: true;
|
|
@@ -1401,9 +1265,10 @@ export declare const route: Route<{
|
|
|
1401
1265
|
readonly top_p?: number | undefined;
|
|
1402
1266
|
readonly frequency_penalty?: number | undefined;
|
|
1403
1267
|
readonly presence_penalty?: number | undefined;
|
|
1268
|
+
readonly store?: boolean | undefined;
|
|
1269
|
+
readonly max_output_tokens?: number | undefined;
|
|
1404
1270
|
readonly prompt_cache_key?: string | undefined;
|
|
1405
1271
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
1406
|
-
readonly store?: boolean | undefined;
|
|
1407
1272
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
1408
1273
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1409
1274
|
readonly stream_options?: {
|
|
@@ -1411,7 +1276,6 @@ export declare const route: Route<{
|
|
|
1411
1276
|
} | undefined;
|
|
1412
1277
|
readonly safety_identifier?: string | undefined;
|
|
1413
1278
|
readonly top_logprobs?: number | undefined;
|
|
1414
|
-
readonly max_output_tokens?: number | undefined;
|
|
1415
1279
|
readonly max_tool_calls?: number | undefined;
|
|
1416
1280
|
}, import("./open-responses-channel.js").Prepared, {
|
|
1417
1281
|
endpoint: import("../route/client.js").CompactOperation;
|
|
@@ -81,14 +81,8 @@ const OpenAIResponsesToolChoice = Schema.Union([
|
|
|
81
81
|
OpenResponses.ToolChoice,
|
|
82
82
|
Schema.Struct({ type: Schema.tag("image_generation") }),
|
|
83
83
|
]);
|
|
84
|
-
const OpenAIResponsesInputItem = Schema.Union([
|
|
85
|
-
OpenResponses.InputItem,
|
|
86
|
-
OpenAIResponsesHostedToolItem,
|
|
87
|
-
OpenResponses.ConfigurationUpdate,
|
|
88
|
-
]);
|
|
89
84
|
const OpenAIResponsesCoreFields = {
|
|
90
85
|
...OpenResponses.coreFields,
|
|
91
|
-
input: Schema.Array(OpenAIResponsesInputItem),
|
|
92
86
|
tools: optionalArray(OpenAIResponsesTools),
|
|
93
87
|
tool_choice: Schema.optional(OpenAIResponsesToolChoice),
|
|
94
88
|
context_management: Schema.optional(Schema.Array(Schema.Struct({
|
|
@@ -104,15 +98,15 @@ const OpenAIResponsesBody = Schema.Struct({
|
|
|
104
98
|
export const CompactionTrigger = Schema.Struct({ type: Schema.Literal("compaction_trigger") });
|
|
105
99
|
const CheckpointBody = Schema.Struct({
|
|
106
100
|
...OpenAIResponsesBody.fields,
|
|
107
|
-
input: Schema.Array(Schema.Union([
|
|
101
|
+
input: Schema.Array(Schema.Union([OpenResponses.InputItem, CompactionTrigger])),
|
|
108
102
|
});
|
|
109
103
|
const adapter = {
|
|
110
104
|
id: ADAPTER,
|
|
111
105
|
name: NAME,
|
|
112
106
|
restoreHostedToolItem: (item) => (Schema.is(OpenAIResponsesHostedToolItem)(item) ? item : undefined),
|
|
113
107
|
};
|
|
114
|
-
// GPT-6
|
|
115
|
-
//
|
|
108
|
+
// GPT-6 and later default to `configuration_update` support, except in `reasoning.mode: "pro"`
|
|
109
|
+
// or alongside automatic `context_management` compaction.
|
|
116
110
|
const supportsEffortUpdates = (request) => {
|
|
117
111
|
if (request.providerOptions?.contextManagement !== undefined)
|
|
118
112
|
return false;
|
|
@@ -121,7 +115,8 @@ const supportsEffortUpdates = (request) => {
|
|
|
121
115
|
const override = request.model.compatibility?.supportsEffortUpdates;
|
|
122
116
|
if (override !== undefined)
|
|
123
117
|
return override;
|
|
124
|
-
|
|
118
|
+
const match = /(?:^|\/)gpt-(\d+)(?:\.\d+)?(?:-|$)/i.exec(request.model.id);
|
|
119
|
+
return match !== null && Number(match[1]) >= 6;
|
|
125
120
|
};
|
|
126
121
|
const nativeImageToolInput = (tool) => {
|
|
127
122
|
const native = tool.native?.openai;
|
|
@@ -131,7 +126,7 @@ const nativeImageTool = (tool) => {
|
|
|
131
126
|
const native = nativeImageToolInput(tool);
|
|
132
127
|
return Schema.is(OpenAIResponsesImageGenerationTool)(native) ? native : undefined;
|
|
133
128
|
};
|
|
134
|
-
const lowerTool = Effect.
|
|
129
|
+
const lowerTool = Effect.fnUntraced(function* (tool) {
|
|
135
130
|
const native = nativeImageToolInput(tool);
|
|
136
131
|
if (native !== undefined) {
|
|
137
132
|
if (Schema.is(OpenAIResponsesImageGenerationTool)(native))
|
|
@@ -142,7 +137,7 @@ const lowerTool = Effect.fn("OpenAIResponses.lowerTool")(function* (tool) {
|
|
|
142
137
|
});
|
|
143
138
|
// Native namespaces hold only function tools, so deeper levels flatten into
|
|
144
139
|
// the leaf names the same way non-native protocols flatten the whole tree.
|
|
145
|
-
const lowerToolEntry = Effect.
|
|
140
|
+
const lowerToolEntry = Effect.fnUntraced(function* (tool) {
|
|
146
141
|
if (tool.type === "tool")
|
|
147
142
|
return yield* lowerTool(tool);
|
|
148
143
|
// OpenAI requires a namespace description; fall back to a generic one so a
|
|
@@ -163,12 +158,11 @@ const lowerToolChoice = (toolChoice, tools) => ProviderShared.matchToolChoice(NA
|
|
|
163
158
|
? { type: "image_generation" }
|
|
164
159
|
: { type: "function", name },
|
|
165
160
|
});
|
|
166
|
-
const decodeBody = ProviderShared.validateWith(Schema.decodeUnknownEffect(OpenAIResponsesBody));
|
|
167
161
|
const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request) {
|
|
168
162
|
const management = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Schema.UndefinedOr(ContextManagement)))(request.providerOptions?.contextManagement);
|
|
169
163
|
const options = OpenResponsesOptions.resolve(request);
|
|
170
164
|
const updates = resolveEffortUpdates(request, options.reasoningEffort);
|
|
171
|
-
return
|
|
165
|
+
return {
|
|
172
166
|
...(yield* OpenResponses.lowerConversation(updates.request, adapter)),
|
|
173
167
|
...OpenResponses.lowerGeneration(request, { ...options, reasoningEffort: updates.effort }),
|
|
174
168
|
context_management: management?.map((edit) => ({ type: edit.type, compact_threshold: edit.compactThreshold })),
|
|
@@ -177,7 +171,7 @@ const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request)
|
|
|
177
171
|
? undefined
|
|
178
172
|
: (OpenResponses.allowedToolChoice(request) ??
|
|
179
173
|
(request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools) : undefined)),
|
|
180
|
-
}
|
|
174
|
+
};
|
|
181
175
|
});
|
|
182
176
|
const checkpointBody = {
|
|
183
177
|
schema: CheckpointBody,
|
|
@@ -197,7 +191,7 @@ const checkpointBody = {
|
|
|
197
191
|
};
|
|
198
192
|
}),
|
|
199
193
|
};
|
|
200
|
-
const hostedToolResult = Effect.
|
|
194
|
+
const hostedToolResult = Effect.fnUntraced(function* (item) {
|
|
201
195
|
const isError = item.error !== undefined && item.error !== null;
|
|
202
196
|
if (item.type === "image_generation_call" && item.result) {
|
|
203
197
|
yield* Effect.fromResult(Encoding.decodeBase64(item.result)).pipe(Effect.mapError((cause) => ProviderShared.eventError(ADAPTER, "OpenAI Responses returned invalid image base64", undefined, cause)));
|
|
@@ -51,7 +51,7 @@ const fromRequest = Effect.fn("OpenAISpeech.fromRequest")(function* (request) {
|
|
|
51
51
|
// 6. Stream parsing
|
|
52
52
|
// ---------------------------------------------------------------------------
|
|
53
53
|
const isSse = (body) => body.type === "json" && body.value.stream_format === "sse";
|
|
54
|
-
const onEvent = Effect.
|
|
54
|
+
const onEvent = Effect.fnUntraced(function* (state, frame) {
|
|
55
55
|
const event = yield* decodeEvent(frame);
|
|
56
56
|
if (event.type === "speech.audio.delta")
|
|
57
57
|
return SpeechStream.delta(state, event.audio);
|
|
@@ -131,7 +131,7 @@ const segment = (value) => ({
|
|
|
131
131
|
endSeconds: value.end,
|
|
132
132
|
speaker: value.speaker,
|
|
133
133
|
});
|
|
134
|
-
const onEvent = Effect.
|
|
134
|
+
const onEvent = Effect.fnUntraced(function* (state, frame) {
|
|
135
135
|
if (!EVENT_TYPES.has((yield* decodeEventType(frame)).type))
|
|
136
136
|
return [state, []];
|
|
137
137
|
const event = yield* decodeEvent(frame);
|
package/dist/protocols/shared.js
CHANGED
|
@@ -108,7 +108,7 @@ export const wrapSystemUpdate = (parts) => `<system-update>\n${escapeSystemUpdat
|
|
|
108
108
|
* raw retrieved, tool, or web content into privileged updates: keep untrusted
|
|
109
109
|
* data in ordinary user/tool messages instead.
|
|
110
110
|
*/
|
|
111
|
-
export const systemUpdateText = Effect.
|
|
111
|
+
export const systemUpdateText = Effect.fnUntraced(function* (route, message) {
|
|
112
112
|
const content = [];
|
|
113
113
|
for (const part of message.content) {
|
|
114
114
|
if (!supportsContent(part, ["text"]))
|
|
@@ -118,7 +118,7 @@ export const systemUpdateText = Effect.fn("ProviderShared.systemUpdateText")(fun
|
|
|
118
118
|
return content;
|
|
119
119
|
});
|
|
120
120
|
/** Lower an unsupported privileged update into visible, in-order user text. */
|
|
121
|
-
export const wrappedSystemUpdate = Effect.
|
|
121
|
+
export const wrappedSystemUpdate = Effect.fnUntraced(function* (route, message) {
|
|
122
122
|
const content = yield* systemUpdateText(route, message);
|
|
123
123
|
return { type: "text", text: wrapSystemUpdate(content), cache: content.at(-1)?.cache };
|
|
124
124
|
});
|
|
@@ -30,7 +30,7 @@ const Started = Schema.Struct({ id: Schema.String });
|
|
|
30
30
|
/** `sd3.5-*` ids share the `sd3` endpoint and select the model with a form field. */
|
|
31
31
|
const endpoint = (model) => (model.startsWith("sd3") ? "sd3" : model);
|
|
32
32
|
const RESERVED_FORM_FIELDS = new Set(["image", "prompt", "mode", "model"]);
|
|
33
|
-
const form = Effect.
|
|
33
|
+
const form = Effect.fnUntraced(function* (identity, fields, native, source) {
|
|
34
34
|
if ((source?.length ?? 0) > 1)
|
|
35
35
|
return yield* identity.unsupported("media.images", `${identity.name} takes one source image`);
|
|
36
36
|
const body = new FormData();
|
|
@@ -61,7 +61,7 @@ function documentName(filename, names) {
|
|
|
61
61
|
names.add(name);
|
|
62
62
|
return name;
|
|
63
63
|
}
|
|
64
|
-
const mediaBase64 = Effect.
|
|
64
|
+
const mediaBase64 = Effect.fnUntraced(function* (part) {
|
|
65
65
|
const media = yield* ProviderShared.requireInlineMedia("Bedrock Converse", part.media);
|
|
66
66
|
const bytes = yield* Effect.fromResult(Encoding.decodeBase64(media.base64)).pipe(Effect.mapError((cause) => ProviderShared.invalidRequest("Bedrock Converse media data must be valid base64", cause)));
|
|
67
67
|
return Encoding.encodeBase64(bytes);
|
|
@@ -71,7 +71,7 @@ const mediaBase64 = Effect.fn("BedrockMedia.mediaBase64")(function* (part) {
|
|
|
71
71
|
// document block. Image MIME types not in `IMAGE_FORMATS` (e.g. `image/svg+xml`)
|
|
72
72
|
// get an image-specific error so the caller knows it's a format-support issue,
|
|
73
73
|
// not a kind-detection issue.
|
|
74
|
-
export const lower = Effect.
|
|
74
|
+
export const lower = Effect.fnUntraced(function* (part, documentNames) {
|
|
75
75
|
const mime = part.media.mediaType.toLowerCase();
|
|
76
76
|
const imageFormat = IMAGE_FORMATS[mime];
|
|
77
77
|
if (imageFormat) {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import type { CacheHint } from "../../schema/index.js";
|
|
1
2
|
export interface Breakpoints {
|
|
2
3
|
remaining: number;
|
|
3
4
|
dropped: number;
|
|
4
5
|
}
|
|
5
6
|
export declare const newBreakpoints: (cap: number) => Breakpoints;
|
|
6
7
|
export declare const ttlBucket: (ttlSeconds: number | undefined) => "1h" | undefined;
|
|
8
|
+
export declare const cacheControl: () => (cache: CacheHint | undefined) => {
|
|
9
|
+
type: "ephemeral";
|
|
10
|
+
ttl: "1h" | undefined;
|
|
11
|
+
} | undefined;
|