@opencode/ai 2.0.22 → 2.0.24
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 +13 -9
- package/dist/protocols/alibaba-chat.d.ts +3 -3
- package/dist/protocols/alibaba-messages.d.ts +3 -0
- package/dist/protocols/alibaba-responses.d.ts +19 -12
- package/dist/protocols/alibaba-responses.js +3 -5
- package/dist/protocols/anthropic-messages.d.ts +3 -0
- package/dist/protocols/anthropic-messages.js +53 -48
- package/dist/protocols/bedrock-converse.js +3 -3
- 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-messages.d.ts +3 -0
- package/dist/protocols/meta-responses.d.ts +34 -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 +424 -103
- package/dist/protocols/open-responses.js +30 -20
- package/dist/protocols/openai-chat.d.ts +401 -5
- package/dist/protocols/openai-chat.js +18 -21
- 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 +90 -223
- package/dist/protocols/openai-responses.js +6 -13
- 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/gateway-protocol.d.ts +17 -0
- package/dist/protocols/utils/gateway-protocol.js +57 -0
- 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.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 +21 -21
- package/dist/protocols/xai-responses.js +2 -8
- package/dist/protocols/zai-chat.d.ts +3 -3
- package/dist/protocols/zai-messages.d.ts +3 -0
- package/dist/provider-error.js +7 -1
- 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 +5 -5
- 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 -0
- 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 +4 -4
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -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 +5 -5
- 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/vercel-ai-gateway/chat.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/chat.js +1 -0
- package/dist/providers/vercel-ai-gateway/messages.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/messages.js +1 -0
- package/dist/providers/vercel-ai-gateway/responses.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/responses.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +91 -9
- package/dist/providers/vercel-ai-gateway.js +161 -21
- 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.js +2 -5
- package/dist/route/framing.js +23 -23
- 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,18 +424,21 @@ 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?: {
|
|
432
|
+
readonly [x: string]: unknown;
|
|
472
433
|
readonly input_tokens?: number | undefined;
|
|
473
434
|
readonly output_tokens?: number | undefined;
|
|
474
435
|
readonly output_tokens_details?: {
|
|
436
|
+
readonly [x: string]: unknown;
|
|
475
437
|
readonly reasoning_tokens?: number | undefined;
|
|
476
438
|
} | null | undefined;
|
|
477
439
|
readonly total_tokens?: number | undefined;
|
|
478
440
|
readonly input_tokens_details?: {
|
|
441
|
+
readonly [x: string]: unknown;
|
|
479
442
|
readonly cached_tokens?: number | undefined;
|
|
480
443
|
readonly cache_write_tokens?: number | undefined;
|
|
481
444
|
} | null | undefined;
|
|
@@ -492,8 +455,8 @@ export declare const protocol: Protocol<{
|
|
|
492
455
|
readonly name?: string | undefined;
|
|
493
456
|
readonly namespace?: string | undefined;
|
|
494
457
|
readonly arguments?: string | undefined;
|
|
495
|
-
readonly encrypted_content?: string | null | undefined;
|
|
496
458
|
readonly call_id?: string | undefined;
|
|
459
|
+
readonly encrypted_content?: string | null | undefined;
|
|
497
460
|
} | null | undefined;
|
|
498
461
|
readonly delta?: string | undefined;
|
|
499
462
|
readonly arguments?: string | undefined;
|
|
@@ -545,6 +508,10 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
545
508
|
readonly reasoning: {
|
|
546
509
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
547
510
|
};
|
|
511
|
+
} | {
|
|
512
|
+
readonly [x: string]: unknown;
|
|
513
|
+
readonly type: string;
|
|
514
|
+
readonly id: string;
|
|
548
515
|
} | {
|
|
549
516
|
readonly type: "reasoning";
|
|
550
517
|
readonly summary: readonly {
|
|
@@ -621,34 +588,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
621
588
|
readonly type: "input_video";
|
|
622
589
|
readonly video_url: string;
|
|
623
590
|
})[];
|
|
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
591
|
})[];
|
|
653
592
|
readonly model: string;
|
|
654
593
|
readonly stream: true;
|
|
@@ -717,9 +656,10 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
717
656
|
readonly top_p?: number | undefined;
|
|
718
657
|
readonly frequency_penalty?: number | undefined;
|
|
719
658
|
readonly presence_penalty?: number | undefined;
|
|
659
|
+
readonly store?: boolean | undefined;
|
|
660
|
+
readonly max_output_tokens?: number | undefined;
|
|
720
661
|
readonly prompt_cache_key?: string | undefined;
|
|
721
662
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
722
|
-
readonly store?: boolean | undefined;
|
|
723
663
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
724
664
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
725
665
|
readonly stream_options?: {
|
|
@@ -727,7 +667,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
727
667
|
} | undefined;
|
|
728
668
|
readonly safety_identifier?: string | undefined;
|
|
729
669
|
readonly top_logprobs?: number | undefined;
|
|
730
|
-
readonly max_output_tokens?: number | undefined;
|
|
731
670
|
readonly max_tool_calls?: number | undefined;
|
|
732
671
|
}, string>;
|
|
733
672
|
export declare const channelTransport: (options: import("./open-responses-channel.js").Options) => import("../route/transport/index.js").Transport<{
|
|
@@ -773,6 +712,10 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
773
712
|
readonly reasoning: {
|
|
774
713
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
775
714
|
};
|
|
715
|
+
} | {
|
|
716
|
+
readonly [x: string]: unknown;
|
|
717
|
+
readonly type: string;
|
|
718
|
+
readonly id: string;
|
|
776
719
|
} | {
|
|
777
720
|
readonly type: "reasoning";
|
|
778
721
|
readonly summary: readonly {
|
|
@@ -849,34 +792,6 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
849
792
|
readonly type: "input_video";
|
|
850
793
|
readonly video_url: string;
|
|
851
794
|
})[];
|
|
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
795
|
})[];
|
|
881
796
|
readonly model: string;
|
|
882
797
|
readonly stream: true;
|
|
@@ -945,9 +860,10 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
945
860
|
readonly top_p?: number | undefined;
|
|
946
861
|
readonly frequency_penalty?: number | undefined;
|
|
947
862
|
readonly presence_penalty?: number | undefined;
|
|
863
|
+
readonly store?: boolean | undefined;
|
|
864
|
+
readonly max_output_tokens?: number | undefined;
|
|
948
865
|
readonly prompt_cache_key?: string | undefined;
|
|
949
866
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
950
|
-
readonly store?: boolean | undefined;
|
|
951
867
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
952
868
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
953
869
|
readonly stream_options?: {
|
|
@@ -955,7 +871,6 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
955
871
|
} | undefined;
|
|
956
872
|
readonly safety_identifier?: string | undefined;
|
|
957
873
|
readonly top_logprobs?: number | undefined;
|
|
958
|
-
readonly max_output_tokens?: number | undefined;
|
|
959
874
|
readonly max_tool_calls?: number | undefined;
|
|
960
875
|
}, import("./open-responses-channel.js").Prepared, string>;
|
|
961
876
|
export declare const transport: import("../route/transport/index.js").Transport<{
|
|
@@ -1001,6 +916,10 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1001
916
|
readonly reasoning: {
|
|
1002
917
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
1003
918
|
};
|
|
919
|
+
} | {
|
|
920
|
+
readonly [x: string]: unknown;
|
|
921
|
+
readonly type: string;
|
|
922
|
+
readonly id: string;
|
|
1004
923
|
} | {
|
|
1005
924
|
readonly type: "reasoning";
|
|
1006
925
|
readonly summary: readonly {
|
|
@@ -1077,34 +996,6 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1077
996
|
readonly type: "input_video";
|
|
1078
997
|
readonly video_url: string;
|
|
1079
998
|
})[];
|
|
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
999
|
})[];
|
|
1109
1000
|
readonly model: string;
|
|
1110
1001
|
readonly stream: true;
|
|
@@ -1173,9 +1064,10 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1173
1064
|
readonly top_p?: number | undefined;
|
|
1174
1065
|
readonly frequency_penalty?: number | undefined;
|
|
1175
1066
|
readonly presence_penalty?: number | undefined;
|
|
1067
|
+
readonly store?: boolean | undefined;
|
|
1068
|
+
readonly max_output_tokens?: number | undefined;
|
|
1176
1069
|
readonly prompt_cache_key?: string | undefined;
|
|
1177
1070
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
1178
|
-
readonly store?: boolean | undefined;
|
|
1179
1071
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
1180
1072
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1181
1073
|
readonly stream_options?: {
|
|
@@ -1183,7 +1075,6 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1183
1075
|
} | undefined;
|
|
1184
1076
|
readonly safety_identifier?: string | undefined;
|
|
1185
1077
|
readonly top_logprobs?: number | undefined;
|
|
1186
|
-
readonly max_output_tokens?: number | undefined;
|
|
1187
1078
|
readonly max_tool_calls?: number | undefined;
|
|
1188
1079
|
}, import("./open-responses-channel.js").Prepared, string>;
|
|
1189
1080
|
export declare const route: Route<{
|
|
@@ -1229,6 +1120,10 @@ export declare const route: Route<{
|
|
|
1229
1120
|
readonly reasoning: {
|
|
1230
1121
|
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
1231
1122
|
};
|
|
1123
|
+
} | {
|
|
1124
|
+
readonly [x: string]: unknown;
|
|
1125
|
+
readonly type: string;
|
|
1126
|
+
readonly id: string;
|
|
1232
1127
|
} | {
|
|
1233
1128
|
readonly type: "reasoning";
|
|
1234
1129
|
readonly summary: readonly {
|
|
@@ -1305,34 +1200,6 @@ export declare const route: Route<{
|
|
|
1305
1200
|
readonly type: "input_video";
|
|
1306
1201
|
readonly video_url: string;
|
|
1307
1202
|
})[];
|
|
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
1203
|
})[];
|
|
1337
1204
|
readonly model: string;
|
|
1338
1205
|
readonly stream: true;
|
|
@@ -1401,9 +1268,10 @@ export declare const route: Route<{
|
|
|
1401
1268
|
readonly top_p?: number | undefined;
|
|
1402
1269
|
readonly frequency_penalty?: number | undefined;
|
|
1403
1270
|
readonly presence_penalty?: number | undefined;
|
|
1271
|
+
readonly store?: boolean | undefined;
|
|
1272
|
+
readonly max_output_tokens?: number | undefined;
|
|
1404
1273
|
readonly prompt_cache_key?: string | undefined;
|
|
1405
1274
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
1406
|
-
readonly store?: boolean | undefined;
|
|
1407
1275
|
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
1408
1276
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1409
1277
|
readonly stream_options?: {
|
|
@@ -1411,7 +1279,6 @@ export declare const route: Route<{
|
|
|
1411
1279
|
} | undefined;
|
|
1412
1280
|
readonly safety_identifier?: string | undefined;
|
|
1413
1281
|
readonly top_logprobs?: number | undefined;
|
|
1414
|
-
readonly max_output_tokens?: number | undefined;
|
|
1415
1282
|
readonly max_tool_calls?: number | undefined;
|
|
1416
1283
|
}, import("./open-responses-channel.js").Prepared, {
|
|
1417
1284
|
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,7 +98,7 @@ 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,
|
|
@@ -132,7 +126,7 @@ const nativeImageTool = (tool) => {
|
|
|
132
126
|
const native = nativeImageToolInput(tool);
|
|
133
127
|
return Schema.is(OpenAIResponsesImageGenerationTool)(native) ? native : undefined;
|
|
134
128
|
};
|
|
135
|
-
const lowerTool = Effect.
|
|
129
|
+
const lowerTool = Effect.fnUntraced(function* (tool) {
|
|
136
130
|
const native = nativeImageToolInput(tool);
|
|
137
131
|
if (native !== undefined) {
|
|
138
132
|
if (Schema.is(OpenAIResponsesImageGenerationTool)(native))
|
|
@@ -143,7 +137,7 @@ const lowerTool = Effect.fn("OpenAIResponses.lowerTool")(function* (tool) {
|
|
|
143
137
|
});
|
|
144
138
|
// Native namespaces hold only function tools, so deeper levels flatten into
|
|
145
139
|
// the leaf names the same way non-native protocols flatten the whole tree.
|
|
146
|
-
const lowerToolEntry = Effect.
|
|
140
|
+
const lowerToolEntry = Effect.fnUntraced(function* (tool) {
|
|
147
141
|
if (tool.type === "tool")
|
|
148
142
|
return yield* lowerTool(tool);
|
|
149
143
|
// OpenAI requires a namespace description; fall back to a generic one so a
|
|
@@ -164,12 +158,11 @@ const lowerToolChoice = (toolChoice, tools) => ProviderShared.matchToolChoice(NA
|
|
|
164
158
|
? { type: "image_generation" }
|
|
165
159
|
: { type: "function", name },
|
|
166
160
|
});
|
|
167
|
-
const decodeBody = ProviderShared.validateWith(Schema.decodeUnknownEffect(OpenAIResponsesBody));
|
|
168
161
|
const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request) {
|
|
169
162
|
const management = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Schema.UndefinedOr(ContextManagement)))(request.providerOptions?.contextManagement);
|
|
170
163
|
const options = OpenResponsesOptions.resolve(request);
|
|
171
164
|
const updates = resolveEffortUpdates(request, options.reasoningEffort);
|
|
172
|
-
return
|
|
165
|
+
return {
|
|
173
166
|
...(yield* OpenResponses.lowerConversation(updates.request, adapter)),
|
|
174
167
|
...OpenResponses.lowerGeneration(request, { ...options, reasoningEffort: updates.effort }),
|
|
175
168
|
context_management: management?.map((edit) => ({ type: edit.type, compact_threshold: edit.compactThreshold })),
|
|
@@ -178,7 +171,7 @@ const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request)
|
|
|
178
171
|
? undefined
|
|
179
172
|
: (OpenResponses.allowedToolChoice(request) ??
|
|
180
173
|
(request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools) : undefined)),
|
|
181
|
-
}
|
|
174
|
+
};
|
|
182
175
|
});
|
|
183
176
|
const checkpointBody = {
|
|
184
177
|
schema: CheckpointBody,
|
|
@@ -198,7 +191,7 @@ const checkpointBody = {
|
|
|
198
191
|
};
|
|
199
192
|
}),
|
|
200
193
|
};
|
|
201
|
-
const hostedToolResult = Effect.
|
|
194
|
+
const hostedToolResult = Effect.fnUntraced(function* (item) {
|
|
202
195
|
const isError = item.error !== undefined && item.error !== null;
|
|
203
196
|
if (item.type === "image_generation_call" && item.result) {
|
|
204
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) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Protocol } from "../../route/protocol.js";
|
|
3
|
+
import { type AIError, type LLMRequest } from "../../schema/index.js";
|
|
4
|
+
interface ParserState<Inner> {
|
|
5
|
+
readonly inner: Inner;
|
|
6
|
+
readonly gateway?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare function gatewayProtocol<Body, Event, State>(protocol: Protocol<Body, string, Event, State>, input: {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly prepare: (request: LLMRequest) => Effect.Effect<{
|
|
11
|
+
readonly request: LLMRequest;
|
|
12
|
+
readonly body: Record<string, unknown>;
|
|
13
|
+
}, AIError>;
|
|
14
|
+
}): Protocol<{
|
|
15
|
+
readonly [x: string]: unknown;
|
|
16
|
+
}, string, Event, ParserState<State>>;
|
|
17
|
+
export {};
|