@opencode/ai 0.0.0-dev-21799 → 0.0.0-dev-21801
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/protocols/alibaba-messages.d.ts +34 -0
- package/dist/protocols/alibaba-responses.d.ts +3 -0
- package/dist/protocols/anthropic-messages.d.ts +102 -0
- package/dist/protocols/anthropic-messages.js +32 -8
- package/dist/protocols/meta-messages.d.ts +34 -0
- package/dist/protocols/meta-messages.js +12 -0
- package/dist/protocols/meta-responses.d.ts +6 -0
- package/dist/protocols/meta-responses.js +29 -1
- package/dist/protocols/open-responses.d.ts +27 -0
- package/dist/protocols/open-responses.js +7 -18
- package/dist/protocols/openai-compatible-responses.d.ts +3 -0
- package/dist/protocols/openai-responses.d.ts +18 -0
- package/dist/protocols/shared.d.ts +1 -1
- package/dist/protocols/shared.js +2 -2
- package/dist/protocols/xai-responses.d.ts +3 -0
- package/dist/protocols/xai-responses.js +9 -0
- package/dist/protocols/zai-messages.d.ts +34 -0
- package/dist/providers/alibaba.d.ts +37 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +37 -0
- package/dist/providers/anthropic-compatible.d.ts +34 -0
- package/dist/providers/anthropic.d.ts +34 -0
- package/dist/providers/azure.d.ts +6 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +74 -0
- package/dist/providers/google-vertex-messages.d.ts +34 -0
- package/dist/providers/google-vertex-responses.d.ts +3 -0
- package/dist/providers/meta.d.ts +37 -0
- package/dist/providers/minimax.d.ts +37 -0
- package/dist/providers/moonshot.d.ts +37 -0
- package/dist/providers/openai-compatible-responses.d.ts +3 -0
- package/dist/providers/openai.d.ts +3 -0
- package/dist/providers/zai-coding-plan.d.ts +37 -0
- package/dist/route/client.js +11 -0
- package/package.json +3 -3
|
@@ -61,6 +61,23 @@ export declare const protocol: Protocol<{
|
|
|
61
61
|
readonly transformations?: {
|
|
62
62
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
63
63
|
} | undefined;
|
|
64
|
+
} | {
|
|
65
|
+
readonly type: "video";
|
|
66
|
+
readonly source: {
|
|
67
|
+
readonly type: "base64";
|
|
68
|
+
readonly media_type: string;
|
|
69
|
+
readonly data: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "url";
|
|
72
|
+
readonly url: string;
|
|
73
|
+
} | {
|
|
74
|
+
readonly type: "file";
|
|
75
|
+
readonly file_id: string;
|
|
76
|
+
};
|
|
77
|
+
readonly cache_control?: {
|
|
78
|
+
readonly type: "ephemeral";
|
|
79
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
80
|
+
} | undefined;
|
|
64
81
|
} | {
|
|
65
82
|
readonly type: "document";
|
|
66
83
|
readonly source: {
|
|
@@ -117,6 +134,23 @@ export declare const protocol: Protocol<{
|
|
|
117
134
|
readonly transformations?: {
|
|
118
135
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
119
136
|
} | undefined;
|
|
137
|
+
} | {
|
|
138
|
+
readonly type: "video";
|
|
139
|
+
readonly source: {
|
|
140
|
+
readonly type: "base64";
|
|
141
|
+
readonly media_type: string;
|
|
142
|
+
readonly data: string;
|
|
143
|
+
} | {
|
|
144
|
+
readonly type: "url";
|
|
145
|
+
readonly url: string;
|
|
146
|
+
} | {
|
|
147
|
+
readonly type: "file";
|
|
148
|
+
readonly file_id: string;
|
|
149
|
+
};
|
|
150
|
+
readonly cache_control?: {
|
|
151
|
+
readonly type: "ephemeral";
|
|
152
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
153
|
+
} | undefined;
|
|
120
154
|
} | {
|
|
121
155
|
readonly type: "document";
|
|
122
156
|
readonly source: {
|
|
@@ -63,6 +63,9 @@ export declare const protocol: Protocol<{
|
|
|
63
63
|
readonly content: readonly ({
|
|
64
64
|
readonly type: "input_text";
|
|
65
65
|
readonly text: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: "input_video";
|
|
68
|
+
readonly video_url: string;
|
|
66
69
|
} | {
|
|
67
70
|
readonly type: "input_image";
|
|
68
71
|
readonly image_url: string;
|
|
@@ -210,6 +210,23 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
|
|
|
210
210
|
readonly citations: Schema.optional<Schema.Struct<{
|
|
211
211
|
readonly enabled: Schema.Boolean;
|
|
212
212
|
}>>;
|
|
213
|
+
}>, Schema.Struct<{
|
|
214
|
+
readonly type: Schema.tag<"video">;
|
|
215
|
+
readonly source: Schema.Union<readonly [Schema.Struct<{
|
|
216
|
+
readonly type: Schema.tag<"base64">;
|
|
217
|
+
readonly media_type: Schema.String;
|
|
218
|
+
readonly data: Schema.String;
|
|
219
|
+
}>, Schema.Struct<{
|
|
220
|
+
readonly type: Schema.tag<"url">;
|
|
221
|
+
readonly url: Schema.String;
|
|
222
|
+
}>, Schema.Struct<{
|
|
223
|
+
readonly type: Schema.tag<"file">;
|
|
224
|
+
readonly file_id: Schema.String;
|
|
225
|
+
}>]>;
|
|
226
|
+
readonly cache_control: Schema.optional<Schema.Struct<{
|
|
227
|
+
readonly type: Schema.tag<"ephemeral">;
|
|
228
|
+
readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
|
|
229
|
+
}>>;
|
|
213
230
|
}>, Schema.Struct<{
|
|
214
231
|
readonly type: Schema.tag<"tool_result">;
|
|
215
232
|
readonly tool_use_id: Schema.String;
|
|
@@ -266,6 +283,23 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
|
|
|
266
283
|
readonly citations: Schema.optional<Schema.Struct<{
|
|
267
284
|
readonly enabled: Schema.Boolean;
|
|
268
285
|
}>>;
|
|
286
|
+
}>, Schema.Struct<{
|
|
287
|
+
readonly type: Schema.tag<"video">;
|
|
288
|
+
readonly source: Schema.Union<readonly [Schema.Struct<{
|
|
289
|
+
readonly type: Schema.tag<"base64">;
|
|
290
|
+
readonly media_type: Schema.String;
|
|
291
|
+
readonly data: Schema.String;
|
|
292
|
+
}>, Schema.Struct<{
|
|
293
|
+
readonly type: Schema.tag<"url">;
|
|
294
|
+
readonly url: Schema.String;
|
|
295
|
+
}>, Schema.Struct<{
|
|
296
|
+
readonly type: Schema.tag<"file">;
|
|
297
|
+
readonly file_id: Schema.String;
|
|
298
|
+
}>]>;
|
|
299
|
+
readonly cache_control: Schema.optional<Schema.Struct<{
|
|
300
|
+
readonly type: Schema.tag<"ephemeral">;
|
|
301
|
+
readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
|
|
302
|
+
}>>;
|
|
269
303
|
}>]>>]>;
|
|
270
304
|
readonly is_error: Schema.optional<Schema.Boolean>;
|
|
271
305
|
readonly cache_control: Schema.optional<Schema.Struct<{
|
|
@@ -457,6 +491,23 @@ export declare const protocol: Protocol<{
|
|
|
457
491
|
readonly transformations?: {
|
|
458
492
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
459
493
|
} | undefined;
|
|
494
|
+
} | {
|
|
495
|
+
readonly type: "video";
|
|
496
|
+
readonly source: {
|
|
497
|
+
readonly type: "base64";
|
|
498
|
+
readonly media_type: string;
|
|
499
|
+
readonly data: string;
|
|
500
|
+
} | {
|
|
501
|
+
readonly type: "url";
|
|
502
|
+
readonly url: string;
|
|
503
|
+
} | {
|
|
504
|
+
readonly type: "file";
|
|
505
|
+
readonly file_id: string;
|
|
506
|
+
};
|
|
507
|
+
readonly cache_control?: {
|
|
508
|
+
readonly type: "ephemeral";
|
|
509
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
510
|
+
} | undefined;
|
|
460
511
|
} | {
|
|
461
512
|
readonly type: "document";
|
|
462
513
|
readonly source: {
|
|
@@ -513,6 +564,23 @@ export declare const protocol: Protocol<{
|
|
|
513
564
|
readonly transformations?: {
|
|
514
565
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
515
566
|
} | undefined;
|
|
567
|
+
} | {
|
|
568
|
+
readonly type: "video";
|
|
569
|
+
readonly source: {
|
|
570
|
+
readonly type: "base64";
|
|
571
|
+
readonly media_type: string;
|
|
572
|
+
readonly data: string;
|
|
573
|
+
} | {
|
|
574
|
+
readonly type: "url";
|
|
575
|
+
readonly url: string;
|
|
576
|
+
} | {
|
|
577
|
+
readonly type: "file";
|
|
578
|
+
readonly file_id: string;
|
|
579
|
+
};
|
|
580
|
+
readonly cache_control?: {
|
|
581
|
+
readonly type: "ephemeral";
|
|
582
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
583
|
+
} | undefined;
|
|
516
584
|
} | {
|
|
517
585
|
readonly type: "document";
|
|
518
586
|
readonly source: {
|
|
@@ -817,6 +885,23 @@ export declare const route: Route<{
|
|
|
817
885
|
readonly transformations?: {
|
|
818
886
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
819
887
|
} | undefined;
|
|
888
|
+
} | {
|
|
889
|
+
readonly type: "video";
|
|
890
|
+
readonly source: {
|
|
891
|
+
readonly type: "base64";
|
|
892
|
+
readonly media_type: string;
|
|
893
|
+
readonly data: string;
|
|
894
|
+
} | {
|
|
895
|
+
readonly type: "url";
|
|
896
|
+
readonly url: string;
|
|
897
|
+
} | {
|
|
898
|
+
readonly type: "file";
|
|
899
|
+
readonly file_id: string;
|
|
900
|
+
};
|
|
901
|
+
readonly cache_control?: {
|
|
902
|
+
readonly type: "ephemeral";
|
|
903
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
904
|
+
} | undefined;
|
|
820
905
|
} | {
|
|
821
906
|
readonly type: "document";
|
|
822
907
|
readonly source: {
|
|
@@ -873,6 +958,23 @@ export declare const route: Route<{
|
|
|
873
958
|
readonly transformations?: {
|
|
874
959
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
875
960
|
} | undefined;
|
|
961
|
+
} | {
|
|
962
|
+
readonly type: "video";
|
|
963
|
+
readonly source: {
|
|
964
|
+
readonly type: "base64";
|
|
965
|
+
readonly media_type: string;
|
|
966
|
+
readonly data: string;
|
|
967
|
+
} | {
|
|
968
|
+
readonly type: "url";
|
|
969
|
+
readonly url: string;
|
|
970
|
+
} | {
|
|
971
|
+
readonly type: "file";
|
|
972
|
+
readonly file_id: string;
|
|
973
|
+
};
|
|
974
|
+
readonly cache_control?: {
|
|
975
|
+
readonly type: "ephemeral";
|
|
976
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
977
|
+
} | undefined;
|
|
876
978
|
} | {
|
|
877
979
|
readonly type: "document";
|
|
878
980
|
readonly source: {
|
|
@@ -81,6 +81,11 @@ const AnthropicImageBlock = Schema.Struct({
|
|
|
81
81
|
cache_control: Schema.optional(AnthropicCacheControl),
|
|
82
82
|
transformations: Schema.optional(AnthropicImageTransformations),
|
|
83
83
|
});
|
|
84
|
+
const AnthropicVideoBlock = Schema.Struct({
|
|
85
|
+
type: Schema.tag("video"),
|
|
86
|
+
source: AnthropicImageSource,
|
|
87
|
+
cache_control: Schema.optional(AnthropicCacheControl),
|
|
88
|
+
});
|
|
84
89
|
// SDK: Base64PDFSource:209 {type:"base64", media_type:"application/pdf", data}, PlainTextSource:2716 {type:"text", media_type:"text/plain", data},
|
|
85
90
|
// SDK: URLPDFSource:3823 {type:"url", url}, FileDocumentSource:2344 {type:"file", file_id}, ContentBlockSource:2266 {type:"content", content}
|
|
86
91
|
// SDK: DocumentBlockParam:2297 {source: 5-way union, cache_control, citations, context, title}
|
|
@@ -157,7 +162,12 @@ const AnthropicServerToolResultBlock = Schema.Struct({
|
|
|
157
162
|
// Anthropic accepts either a plain string or an ordered array of text, image, and
|
|
158
163
|
// document blocks inside `tool_result.content`. The array form keeps media as native
|
|
159
164
|
// model input instead of JSON-stringifying base64 into prompt text.
|
|
160
|
-
const AnthropicToolResultContent = Schema.Union([
|
|
165
|
+
const AnthropicToolResultContent = Schema.Union([
|
|
166
|
+
AnthropicTextBlock,
|
|
167
|
+
AnthropicImageBlock,
|
|
168
|
+
AnthropicDocumentBlock,
|
|
169
|
+
AnthropicVideoBlock,
|
|
170
|
+
]);
|
|
161
171
|
const AnthropicToolResultBlock = Schema.Struct({
|
|
162
172
|
type: Schema.tag("tool_result"),
|
|
163
173
|
tool_use_id: Schema.String,
|
|
@@ -169,6 +179,7 @@ const AnthropicUserBlock = Schema.Union([
|
|
|
169
179
|
AnthropicTextBlock,
|
|
170
180
|
AnthropicImageBlock,
|
|
171
181
|
AnthropicDocumentBlock,
|
|
182
|
+
AnthropicVideoBlock,
|
|
172
183
|
AnthropicToolResultBlock,
|
|
173
184
|
]);
|
|
174
185
|
const AnthropicCompactionBlock = Schema.Struct({
|
|
@@ -539,9 +550,22 @@ const citationsFromMetadata = (metadata) => {
|
|
|
539
550
|
return undefined;
|
|
540
551
|
};
|
|
541
552
|
const isHttpUrl = (value) => /^https?:\/\//i.test(value.trim());
|
|
542
|
-
const lowerMedia = Effect.fnUntraced(function* (part, breakpoints) {
|
|
553
|
+
const lowerMedia = Effect.fnUntraced(function* (part, request, breakpoints) {
|
|
543
554
|
const mime = part.media.mediaType.toLowerCase();
|
|
544
555
|
const cacheControlValue = breakpoints ? cacheControl(breakpoints, part.cache) : undefined;
|
|
556
|
+
if (mime.startsWith("video/")) {
|
|
557
|
+
const inline = part.media.inline();
|
|
558
|
+
const source = inline
|
|
559
|
+
? { type: "base64", media_type: mime, data: inline.base64 }
|
|
560
|
+
: yield* ProviderShared.mediaReference(part.media, request.model.provider, "Messages video").pipe(Effect.map((reference) => reference.type === "ref" && !reference.value.includes("://")
|
|
561
|
+
? { type: "file", file_id: reference.value }
|
|
562
|
+
: { type: "url", url: reference.value }));
|
|
563
|
+
return {
|
|
564
|
+
type: "video",
|
|
565
|
+
source,
|
|
566
|
+
...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }),
|
|
567
|
+
};
|
|
568
|
+
}
|
|
545
569
|
const fileId = fileIdFromMetadata(part.metadata);
|
|
546
570
|
// SDK file sources: FileImageSource:2350 / FileDocumentSource:2344 {type:"file", file_id}
|
|
547
571
|
if (fileId) {
|
|
@@ -644,19 +668,19 @@ const lowerMedia = Effect.fnUntraced(function* (part, breakpoints) {
|
|
|
644
668
|
});
|
|
645
669
|
// Tool results may carry structured text, images, and documents. Keep media as provider-native
|
|
646
670
|
// content instead of JSON-stringifying base64 into a prompt string.
|
|
647
|
-
const lowerToolResultContentItem = Effect.fnUntraced(function* (item) {
|
|
671
|
+
const lowerToolResultContentItem = Effect.fnUntraced(function* (item, request) {
|
|
648
672
|
if (item.type === "text")
|
|
649
673
|
return { type: "text", text: item.text };
|
|
650
|
-
return yield* lowerMedia(ProviderShared.toolFileMedia(item));
|
|
674
|
+
return yield* lowerMedia(ProviderShared.toolFileMedia(item), request);
|
|
651
675
|
});
|
|
652
|
-
const lowerToolResultContent = Effect.fnUntraced(function* (part) {
|
|
676
|
+
const lowerToolResultContent = Effect.fnUntraced(function* (part, request) {
|
|
653
677
|
// Text / json / error results stay as a string for backward compatibility
|
|
654
678
|
// with existing cassettes and provider expectations.
|
|
655
679
|
if (part.result.type !== "content")
|
|
656
680
|
return ProviderShared.toolResultText(part);
|
|
657
681
|
// Preserve the narrowed array element type when compiled through a consumer package.
|
|
658
682
|
const content = part.result.value;
|
|
659
|
-
return yield* Effect.forEach(content, lowerToolResultContentItem);
|
|
683
|
+
return yield* Effect.forEach(content, (item) => lowerToolResultContentItem(item, request));
|
|
660
684
|
});
|
|
661
685
|
const requireThinkingSignature = (request) => {
|
|
662
686
|
if (request.model.compatibility?.requireSignature !== undefined)
|
|
@@ -763,7 +787,7 @@ const lowerMessages = Effect.fnUntraced(function* (request, breakpoints) {
|
|
|
763
787
|
continue;
|
|
764
788
|
}
|
|
765
789
|
if (part.type === "media") {
|
|
766
|
-
content.push(yield* lowerMedia(part, breakpoints));
|
|
790
|
+
content.push(yield* lowerMedia(part, request, breakpoints));
|
|
767
791
|
continue;
|
|
768
792
|
}
|
|
769
793
|
return yield* ProviderShared.unsupportedContent("Anthropic Messages", "user", ["text", "media"]);
|
|
@@ -839,7 +863,7 @@ const lowerMessages = Effect.fnUntraced(function* (request, breakpoints) {
|
|
|
839
863
|
content.push({
|
|
840
864
|
type: "tool_result",
|
|
841
865
|
tool_use_id: scrubToolCallID(part.id),
|
|
842
|
-
content: yield* lowerToolResultContent(part),
|
|
866
|
+
content: yield* lowerToolResultContent(part, request),
|
|
843
867
|
is_error: part.result.type === "error" ? true : undefined,
|
|
844
868
|
cache_control: cacheControl(breakpoints, part.cache),
|
|
845
869
|
});
|
|
@@ -49,6 +49,23 @@ export declare const protocol: Protocol<{
|
|
|
49
49
|
readonly transformations?: {
|
|
50
50
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
51
51
|
} | undefined;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "video";
|
|
54
|
+
readonly source: {
|
|
55
|
+
readonly type: "base64";
|
|
56
|
+
readonly media_type: string;
|
|
57
|
+
readonly data: string;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "url";
|
|
60
|
+
readonly url: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "file";
|
|
63
|
+
readonly file_id: string;
|
|
64
|
+
};
|
|
65
|
+
readonly cache_control?: {
|
|
66
|
+
readonly type: "ephemeral";
|
|
67
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
68
|
+
} | undefined;
|
|
52
69
|
} | {
|
|
53
70
|
readonly type: "document";
|
|
54
71
|
readonly source: {
|
|
@@ -105,6 +122,23 @@ export declare const protocol: Protocol<{
|
|
|
105
122
|
readonly transformations?: {
|
|
106
123
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
107
124
|
} | undefined;
|
|
125
|
+
} | {
|
|
126
|
+
readonly type: "video";
|
|
127
|
+
readonly source: {
|
|
128
|
+
readonly type: "base64";
|
|
129
|
+
readonly media_type: string;
|
|
130
|
+
readonly data: string;
|
|
131
|
+
} | {
|
|
132
|
+
readonly type: "url";
|
|
133
|
+
readonly url: string;
|
|
134
|
+
} | {
|
|
135
|
+
readonly type: "file";
|
|
136
|
+
readonly file_id: string;
|
|
137
|
+
};
|
|
138
|
+
readonly cache_control?: {
|
|
139
|
+
readonly type: "ephemeral";
|
|
140
|
+
readonly ttl?: "1h" | "5m" | undefined;
|
|
141
|
+
} | undefined;
|
|
108
142
|
} | {
|
|
109
143
|
readonly type: "document";
|
|
110
144
|
readonly source: {
|
|
@@ -27,6 +27,18 @@ const fromRequest = Effect.fn("MetaMessages.fromRequest")(function* (request) {
|
|
|
27
27
|
const body = yield* AnthropicMessages.protocol.body.from(projected.request);
|
|
28
28
|
return {
|
|
29
29
|
...body,
|
|
30
|
+
messages: body.messages.map((message) => {
|
|
31
|
+
if (message.role !== "user")
|
|
32
|
+
return message;
|
|
33
|
+
const videos = [];
|
|
34
|
+
const content = message.content.map((block) => {
|
|
35
|
+
if (block.type !== "tool_result" || typeof block.content === "string")
|
|
36
|
+
return block;
|
|
37
|
+
videos.push(...block.content.filter((item) => item.type === "video"));
|
|
38
|
+
return { ...block, content: block.content.filter((item) => item.type !== "video") };
|
|
39
|
+
});
|
|
40
|
+
return videos.length === 0 ? message : { ...message, content: [...content, ...videos] };
|
|
41
|
+
}),
|
|
30
42
|
tools: body.tools === undefined
|
|
31
43
|
? undefined
|
|
32
44
|
: yield* Effect.forEach(body.tools, (tool, index) => Effect.gen(function* () {
|
|
@@ -77,6 +77,9 @@ export declare const protocol: Protocol<{
|
|
|
77
77
|
readonly content: readonly ({
|
|
78
78
|
readonly type: "input_text";
|
|
79
79
|
readonly text: string;
|
|
80
|
+
} | {
|
|
81
|
+
readonly type: "input_video";
|
|
82
|
+
readonly video_url: string;
|
|
80
83
|
} | {
|
|
81
84
|
readonly type: "input_image";
|
|
82
85
|
readonly image_url: string;
|
|
@@ -313,6 +316,9 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
|
|
|
313
316
|
readonly content: readonly ({
|
|
314
317
|
readonly type: "input_text";
|
|
315
318
|
readonly text: string;
|
|
319
|
+
} | {
|
|
320
|
+
readonly type: "input_video";
|
|
321
|
+
readonly video_url: string;
|
|
316
322
|
} | {
|
|
317
323
|
readonly type: "input_image";
|
|
318
324
|
readonly image_url: string;
|
|
@@ -48,7 +48,7 @@ const adapter = {
|
|
|
48
48
|
};
|
|
49
49
|
const fromRequest = Effect.fn("MetaResponses.fromRequest")(function* (request) {
|
|
50
50
|
const key = request.model.route.providerMetadataKey ?? String(request.model.provider);
|
|
51
|
-
|
|
51
|
+
const body = yield* OpenResponses.fromRequestWithAdapter(LLMRequest.update(request, {
|
|
52
52
|
messages: request.messages.map((message) => Message.make({
|
|
53
53
|
...message,
|
|
54
54
|
content: message.content.map((part) => {
|
|
@@ -69,7 +69,35 @@ const fromRequest = Effect.fn("MetaResponses.fromRequest")(function* (request) {
|
|
|
69
69
|
}),
|
|
70
70
|
})),
|
|
71
71
|
}), adapter);
|
|
72
|
+
// Meta cannot see video nested in tool results; attach it after the complete result batch.
|
|
73
|
+
const input = [];
|
|
74
|
+
const videos = [];
|
|
75
|
+
const flushVideos = () => {
|
|
76
|
+
if (videos.length > 0)
|
|
77
|
+
input.push({ type: "message", role: "user", content: videos.splice(0) });
|
|
78
|
+
};
|
|
79
|
+
for (const item of body.input) {
|
|
80
|
+
if (!isFunctionCallOutput(item)) {
|
|
81
|
+
flushVideos();
|
|
82
|
+
input.push(item);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (typeof item.output === "string") {
|
|
86
|
+
input.push(item);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const content = item.output.filter((part) => part.type !== "input_video");
|
|
90
|
+
videos.push(...item.output.filter((part) => part.type === "input_video"));
|
|
91
|
+
input.push({
|
|
92
|
+
...item,
|
|
93
|
+
output: content.length === 0 && item.output.length > 0 ? "Video attached in the following user message." : content,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
flushVideos();
|
|
97
|
+
return { ...body, input };
|
|
72
98
|
});
|
|
99
|
+
// Hosted replay items have an open `type`, so a plain tag check does not narrow the union.
|
|
100
|
+
const isFunctionCallOutput = (item) => item.type === "function_call_output";
|
|
73
101
|
const HOSTED_TOOLS = {
|
|
74
102
|
web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
|
|
75
103
|
image_generation_call: {
|
|
@@ -33,6 +33,9 @@ declare const MediaInput: Schema.Union<readonly [Schema.Struct<{
|
|
|
33
33
|
readonly detail: Schema.optional<Schema.String>;
|
|
34
34
|
readonly file_data: Schema.optional<Schema.String>;
|
|
35
35
|
readonly file_url: Schema.optional<Schema.String>;
|
|
36
|
+
}>, Schema.Struct<{
|
|
37
|
+
readonly type: Schema.tag<"input_video">;
|
|
38
|
+
readonly video_url: Schema.String;
|
|
36
39
|
}>]>;
|
|
37
40
|
export type MediaInput = Schema.Schema.Type<typeof MediaInput>;
|
|
38
41
|
export declare const OpenResponsesOutputText: Schema.Struct<{
|
|
@@ -134,6 +137,9 @@ export declare const InputItem: Schema.Union<readonly [Schema.Struct<{
|
|
|
134
137
|
readonly detail: Schema.optional<Schema.String>;
|
|
135
138
|
readonly file_data: Schema.optional<Schema.String>;
|
|
136
139
|
readonly file_url: Schema.optional<Schema.String>;
|
|
140
|
+
}>, Schema.Struct<{
|
|
141
|
+
readonly type: Schema.tag<"input_video">;
|
|
142
|
+
readonly video_url: Schema.String;
|
|
137
143
|
}>]>]>>;
|
|
138
144
|
readonly id: Schema.optional<Schema.String>;
|
|
139
145
|
readonly status: Schema.optional<Schema.String>;
|
|
@@ -270,6 +276,9 @@ export declare const coreFields: {
|
|
|
270
276
|
readonly detail: Schema.optional<Schema.String>;
|
|
271
277
|
readonly file_data: Schema.optional<Schema.String>;
|
|
272
278
|
readonly file_url: Schema.optional<Schema.String>;
|
|
279
|
+
}>, Schema.Struct<{
|
|
280
|
+
readonly type: Schema.tag<"input_video">;
|
|
281
|
+
readonly video_url: Schema.String;
|
|
273
282
|
}>]>]>>;
|
|
274
283
|
readonly id: Schema.optional<Schema.String>;
|
|
275
284
|
readonly status: Schema.optional<Schema.String>;
|
|
@@ -431,6 +440,9 @@ export declare const OpenResponsesBody: Schema.Struct<{
|
|
|
431
440
|
readonly detail: Schema.optional<Schema.String>;
|
|
432
441
|
readonly file_data: Schema.optional<Schema.String>;
|
|
433
442
|
readonly file_url: Schema.optional<Schema.String>;
|
|
443
|
+
}>, Schema.Struct<{
|
|
444
|
+
readonly type: Schema.tag<"input_video">;
|
|
445
|
+
readonly video_url: Schema.String;
|
|
434
446
|
}>]>]>>;
|
|
435
447
|
readonly id: Schema.optional<Schema.String>;
|
|
436
448
|
readonly status: Schema.optional<Schema.String>;
|
|
@@ -953,6 +965,9 @@ export declare const lowerConversation: (request: LLMRequest<import("../schema/o
|
|
|
953
965
|
readonly content: readonly ({
|
|
954
966
|
readonly type: "input_text";
|
|
955
967
|
readonly text: string;
|
|
968
|
+
} | {
|
|
969
|
+
readonly type: "input_video";
|
|
970
|
+
readonly video_url: string;
|
|
956
971
|
} | {
|
|
957
972
|
readonly type: "input_image";
|
|
958
973
|
readonly image_url: string;
|
|
@@ -1121,6 +1136,9 @@ export declare const fromRequestWithAdapter: (request: LLMRequest<import("../sch
|
|
|
1121
1136
|
readonly content: readonly ({
|
|
1122
1137
|
readonly type: "input_text";
|
|
1123
1138
|
readonly text: string;
|
|
1139
|
+
} | {
|
|
1140
|
+
readonly type: "input_video";
|
|
1141
|
+
readonly video_url: string;
|
|
1124
1142
|
} | {
|
|
1125
1143
|
readonly type: "input_image";
|
|
1126
1144
|
readonly image_url: string;
|
|
@@ -1299,6 +1317,9 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
|
|
|
1299
1317
|
readonly content: readonly ({
|
|
1300
1318
|
readonly type: "input_text";
|
|
1301
1319
|
readonly text: string;
|
|
1320
|
+
} | {
|
|
1321
|
+
readonly type: "input_video";
|
|
1322
|
+
readonly video_url: string;
|
|
1302
1323
|
} | {
|
|
1303
1324
|
readonly type: "input_image";
|
|
1304
1325
|
readonly image_url: string;
|
|
@@ -1712,6 +1733,9 @@ export declare const protocol: Protocol<{
|
|
|
1712
1733
|
readonly content: readonly ({
|
|
1713
1734
|
readonly type: "input_text";
|
|
1714
1735
|
readonly text: string;
|
|
1736
|
+
} | {
|
|
1737
|
+
readonly type: "input_video";
|
|
1738
|
+
readonly video_url: string;
|
|
1715
1739
|
} | {
|
|
1716
1740
|
readonly type: "input_image";
|
|
1717
1741
|
readonly image_url: string;
|
|
@@ -1948,6 +1972,9 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1948
1972
|
readonly content: readonly ({
|
|
1949
1973
|
readonly type: "input_text";
|
|
1950
1974
|
readonly text: string;
|
|
1975
|
+
} | {
|
|
1976
|
+
readonly type: "input_video";
|
|
1977
|
+
readonly video_url: string;
|
|
1951
1978
|
} | {
|
|
1952
1979
|
readonly type: "input_image";
|
|
1953
1980
|
readonly image_url: string;
|
|
@@ -34,7 +34,7 @@ const OpenResponsesInputVideo = Schema.Struct({
|
|
|
34
34
|
type: Schema.tag("input_video"),
|
|
35
35
|
video_url: Schema.String,
|
|
36
36
|
});
|
|
37
|
-
const MediaInput = Schema.Union([OpenResponsesInputImage, OpenResponsesInputFile]);
|
|
37
|
+
const MediaInput = Schema.Union([OpenResponsesInputImage, OpenResponsesInputFile, OpenResponsesInputVideo]);
|
|
38
38
|
const OpenResponsesInputContent = Schema.Union([OpenResponsesInputText, MediaInput]);
|
|
39
39
|
export const OpenResponsesOutputText = Schema.Struct({
|
|
40
40
|
type: Schema.tag("output_text"),
|
|
@@ -341,7 +341,7 @@ const lowerReasoning = (part, providerMetadataKey) => {
|
|
|
341
341
|
};
|
|
342
342
|
const decodeImageDetail = ProviderShared.validateWith(Schema.decodeUnknownEffect(OpenResponsesInputImage.fields.detail));
|
|
343
343
|
const decodeMessageMetadata = ProviderShared.validateWith(Schema.decodeUnknownEffect(MessageMetadata));
|
|
344
|
-
const lowerMedia = Effect.fnUntraced(function* (part, request, adapter
|
|
344
|
+
const lowerMedia = Effect.fnUntraced(function* (part, request, adapter) {
|
|
345
345
|
const media = part.media.inline();
|
|
346
346
|
const providerMedia = adapter.lowerMedia?.({ part, media, request });
|
|
347
347
|
if (providerMedia)
|
|
@@ -352,7 +352,7 @@ const lowerMedia = Effect.fnUntraced(function* (part, request, adapter, target)
|
|
|
352
352
|
const url = ProviderShared.mediaUrl(part.media);
|
|
353
353
|
const location = url ?? (yield* ProviderShared.requireInlineMedia(adapter.name, part.media)).dataUrl;
|
|
354
354
|
if (part.media.kind !== "image") {
|
|
355
|
-
if (
|
|
355
|
+
if (part.media.kind === "video")
|
|
356
356
|
return { type: "input_video", video_url: location };
|
|
357
357
|
return {
|
|
358
358
|
type: "input_file",
|
|
@@ -371,26 +371,15 @@ const lowerUserContent = Effect.fnUntraced(function* (part, request, adapter) {
|
|
|
371
371
|
if (part.type === "text")
|
|
372
372
|
return { type: "input_text", text: part.text };
|
|
373
373
|
if (part.type === "media")
|
|
374
|
-
return yield*
|
|
374
|
+
return yield* lowerMedia(part, request, adapter);
|
|
375
375
|
return yield* ProviderShared.unsupportedContent(adapter.name, "user", ["text", "media"]);
|
|
376
376
|
});
|
|
377
|
-
const lowerMessageMedia = Effect.fnUntraced(function* (part, request, adapter) {
|
|
378
|
-
const lowered = yield* lowerMedia(part, request, adapter, "message");
|
|
379
|
-
if (lowered.type === "input_video")
|
|
380
|
-
return yield* ProviderShared.invalidRequest(`${adapter.name} user messages do not support input_video`);
|
|
381
|
-
return lowered;
|
|
382
|
-
});
|
|
383
377
|
// Tool results may carry structured text, images, and files. Keep media as provider-native
|
|
384
378
|
// content instead of JSON-stringifying base64 into a prompt string.
|
|
385
379
|
const lowerToolResultContentItem = Effect.fnUntraced(function* (item, request, adapter) {
|
|
386
380
|
if (item.type === "text")
|
|
387
381
|
return { type: "input_text", text: item.text };
|
|
388
|
-
return yield* lowerMedia(ProviderShared.toolFileMedia(item), request, adapter
|
|
389
|
-
});
|
|
390
|
-
const lowerHostedToolResultContentItem = Effect.fnUntraced(function* (item, request, adapter) {
|
|
391
|
-
if (item.type === "text")
|
|
392
|
-
return { type: "input_text", text: item.text };
|
|
393
|
-
return yield* lowerMessageMedia(ProviderShared.toolFileMedia(item), request, adapter);
|
|
382
|
+
return yield* lowerMedia(ProviderShared.toolFileMedia(item), request, adapter);
|
|
394
383
|
});
|
|
395
384
|
const lowerToolResultOutput = Effect.fnUntraced(function* (part, request, adapter) {
|
|
396
385
|
// Text/json/error results are encoded as a plain string for backward
|
|
@@ -518,7 +507,7 @@ const lowerMessages = Effect.fnUntraced(function* (request, adapter) {
|
|
|
518
507
|
input.push({
|
|
519
508
|
type: "message",
|
|
520
509
|
role: "user",
|
|
521
|
-
content: yield* Effect.forEach(content, (item) =>
|
|
510
|
+
content: yield* Effect.forEach(content, (item) => lowerToolResultContentItem(item, request, adapter)),
|
|
522
511
|
});
|
|
523
512
|
continue;
|
|
524
513
|
}
|
|
@@ -528,7 +517,7 @@ const lowerMessages = Effect.fnUntraced(function* (request, adapter) {
|
|
|
528
517
|
input.push({
|
|
529
518
|
type: "message",
|
|
530
519
|
role: "user",
|
|
531
|
-
content: [yield*
|
|
520
|
+
content: [yield* lowerMedia(part, request, adapter)],
|
|
532
521
|
});
|
|
533
522
|
continue;
|
|
534
523
|
}
|
|
@@ -57,6 +57,9 @@ export declare const route: Route<{
|
|
|
57
57
|
readonly content: readonly ({
|
|
58
58
|
readonly type: "input_text";
|
|
59
59
|
readonly text: string;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: "input_video";
|
|
62
|
+
readonly video_url: string;
|
|
60
63
|
} | {
|
|
61
64
|
readonly type: "input_image";
|
|
62
65
|
readonly image_url: string;
|
|
@@ -46,6 +46,9 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
46
46
|
readonly detail: Schema.optional<Schema.String>;
|
|
47
47
|
readonly file_data: Schema.optional<Schema.String>;
|
|
48
48
|
readonly file_url: Schema.optional<Schema.String>;
|
|
49
|
+
}>, Schema.Struct<{
|
|
50
|
+
readonly type: Schema.tag<"input_video">;
|
|
51
|
+
readonly video_url: Schema.String;
|
|
49
52
|
}>]>]>>;
|
|
50
53
|
readonly id: Schema.optional<Schema.String>;
|
|
51
54
|
readonly status: Schema.optional<Schema.String>;
|
|
@@ -256,6 +259,9 @@ export declare const protocol: Protocol<{
|
|
|
256
259
|
readonly content: readonly ({
|
|
257
260
|
readonly type: "input_text";
|
|
258
261
|
readonly text: string;
|
|
262
|
+
} | {
|
|
263
|
+
readonly type: "input_video";
|
|
264
|
+
readonly video_url: string;
|
|
259
265
|
} | {
|
|
260
266
|
readonly type: "input_image";
|
|
261
267
|
readonly image_url: string;
|
|
@@ -518,6 +524,9 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
518
524
|
readonly content: readonly ({
|
|
519
525
|
readonly type: "input_text";
|
|
520
526
|
readonly text: string;
|
|
527
|
+
} | {
|
|
528
|
+
readonly type: "input_video";
|
|
529
|
+
readonly video_url: string;
|
|
521
530
|
} | {
|
|
522
531
|
readonly type: "input_image";
|
|
523
532
|
readonly image_url: string;
|
|
@@ -722,6 +731,9 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
722
731
|
readonly content: readonly ({
|
|
723
732
|
readonly type: "input_text";
|
|
724
733
|
readonly text: string;
|
|
734
|
+
} | {
|
|
735
|
+
readonly type: "input_video";
|
|
736
|
+
readonly video_url: string;
|
|
725
737
|
} | {
|
|
726
738
|
readonly type: "input_image";
|
|
727
739
|
readonly image_url: string;
|
|
@@ -926,6 +938,9 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
926
938
|
readonly content: readonly ({
|
|
927
939
|
readonly type: "input_text";
|
|
928
940
|
readonly text: string;
|
|
941
|
+
} | {
|
|
942
|
+
readonly type: "input_video";
|
|
943
|
+
readonly video_url: string;
|
|
929
944
|
} | {
|
|
930
945
|
readonly type: "input_image";
|
|
931
946
|
readonly image_url: string;
|
|
@@ -1130,6 +1145,9 @@ export declare const route: Route<{
|
|
|
1130
1145
|
readonly content: readonly ({
|
|
1131
1146
|
readonly type: "input_text";
|
|
1132
1147
|
readonly text: string;
|
|
1148
|
+
} | {
|
|
1149
|
+
readonly type: "input_video";
|
|
1150
|
+
readonly video_url: string;
|
|
1133
1151
|
} | {
|
|
1134
1152
|
readonly type: "input_image";
|
|
1135
1153
|
readonly image_url: string;
|