@opencode/ai 0.0.0-dev-21799 → 0.0.0-dev-21800

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.
@@ -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: {
@@ -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([AnthropicTextBlock, AnthropicImageBlock, AnthropicDocumentBlock]);
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* () {
@@ -151,7 +151,7 @@ export type MediaReference = {
151
151
  */
152
152
  export declare const mediaReference: (asset: Media.Asset, provider: ProviderID | undefined, label: string) => Effect.Effect<MediaReference, AIError>;
153
153
  /**
154
- * Lift a tool-result file into a `MediaPart`. Tool files carry either a data URL, an `http(s)` URL, or raw base64 in
154
+ * Lift a tool-result file into a `MediaPart`. Tool files carry either a data URL, a URI, or raw base64 in
155
155
  * `uri`; the declared `mime` wins over any data-URL prefix so tool authors control the type the model sees.
156
156
  */
157
157
  export declare const toolFileMedia: (item: Tool.FileContent) => MediaPart;
@@ -186,14 +186,14 @@ export const mediaReference = (asset, provider, label) => {
186
186
  return Effect.fail(invalidRequest(`${label} accepts inline bytes, data URLs, http(s) URLs${accepted}${got}`));
187
187
  };
188
188
  /**
189
- * Lift a tool-result file into a `MediaPart`. Tool files carry either a data URL, an `http(s)` URL, or raw base64 in
189
+ * Lift a tool-result file into a `MediaPart`. Tool files carry either a data URL, a URI, or raw base64 in
190
190
  * `uri`; the declared `mime` wins over any data-URL prefix so tool authors control the type the model sees.
191
191
  */
192
192
  export const toolFileMedia = (item) => {
193
193
  const parsed = Media.parseDataUrl(item.uri);
194
194
  const asset = parsed
195
195
  ? Media.from({ ...parsed.source, mediaType: item.mime })
196
- : /^https?:\/\//.test(item.uri)
196
+ : item.uri.includes("://")
197
197
  ? Media.url(item.uri, { mediaType: item.mime })
198
198
  : Media.base64(item.uri, item.mime);
199
199
  return Message.media(asset, { filename: item.name });
@@ -58,6 +58,23 @@ export declare const protocol: Protocol<{
58
58
  readonly transformations?: {
59
59
  readonly oversized_image?: "downsize" | "error" | undefined;
60
60
  } | undefined;
61
+ } | {
62
+ readonly type: "video";
63
+ readonly source: {
64
+ readonly type: "base64";
65
+ readonly media_type: string;
66
+ readonly data: string;
67
+ } | {
68
+ readonly type: "url";
69
+ readonly url: string;
70
+ } | {
71
+ readonly type: "file";
72
+ readonly file_id: string;
73
+ };
74
+ readonly cache_control?: {
75
+ readonly type: "ephemeral";
76
+ readonly ttl?: "1h" | "5m" | undefined;
77
+ } | undefined;
61
78
  } | {
62
79
  readonly type: "document";
63
80
  readonly source: {
@@ -114,6 +131,23 @@ export declare const protocol: Protocol<{
114
131
  readonly transformations?: {
115
132
  readonly oversized_image?: "downsize" | "error" | undefined;
116
133
  } | undefined;
134
+ } | {
135
+ readonly type: "video";
136
+ readonly source: {
137
+ readonly type: "base64";
138
+ readonly media_type: string;
139
+ readonly data: string;
140
+ } | {
141
+ readonly type: "url";
142
+ readonly url: string;
143
+ } | {
144
+ readonly type: "file";
145
+ readonly file_id: string;
146
+ };
147
+ readonly cache_control?: {
148
+ readonly type: "ephemeral";
149
+ readonly ttl?: "1h" | "5m" | undefined;
150
+ } | undefined;
117
151
  } | {
118
152
  readonly type: "document";
119
153
  readonly source: {
@@ -227,6 +227,23 @@ export declare const routes: (Route<{
227
227
  readonly transformations?: {
228
228
  readonly oversized_image?: "downsize" | "error" | undefined;
229
229
  } | undefined;
230
+ } | {
231
+ readonly type: "video";
232
+ readonly source: {
233
+ readonly type: "base64";
234
+ readonly media_type: string;
235
+ readonly data: string;
236
+ } | {
237
+ readonly type: "url";
238
+ readonly url: string;
239
+ } | {
240
+ readonly type: "file";
241
+ readonly file_id: string;
242
+ };
243
+ readonly cache_control?: {
244
+ readonly type: "ephemeral";
245
+ readonly ttl?: "1h" | "5m" | undefined;
246
+ } | undefined;
230
247
  } | {
231
248
  readonly type: "document";
232
249
  readonly source: {
@@ -283,6 +300,23 @@ export declare const routes: (Route<{
283
300
  readonly transformations?: {
284
301
  readonly oversized_image?: "downsize" | "error" | undefined;
285
302
  } | undefined;
303
+ } | {
304
+ readonly type: "video";
305
+ readonly source: {
306
+ readonly type: "base64";
307
+ readonly media_type: string;
308
+ readonly data: string;
309
+ } | {
310
+ readonly type: "url";
311
+ readonly url: string;
312
+ } | {
313
+ readonly type: "file";
314
+ readonly file_id: string;
315
+ };
316
+ readonly cache_control?: {
317
+ readonly type: "ephemeral";
318
+ readonly ttl?: "1h" | "5m" | undefined;
319
+ } | undefined;
286
320
  } | {
287
321
  readonly type: "document";
288
322
  readonly source: {
@@ -80,6 +80,23 @@ export declare const routes: (Route<{
80
80
  readonly transformations?: {
81
81
  readonly oversized_image?: "downsize" | "error" | undefined;
82
82
  } | undefined;
83
+ } | {
84
+ readonly type: "video";
85
+ readonly source: {
86
+ readonly type: "base64";
87
+ readonly media_type: string;
88
+ readonly data: string;
89
+ } | {
90
+ readonly type: "url";
91
+ readonly url: string;
92
+ } | {
93
+ readonly type: "file";
94
+ readonly file_id: string;
95
+ };
96
+ readonly cache_control?: {
97
+ readonly type: "ephemeral";
98
+ readonly ttl?: "1h" | "5m" | undefined;
99
+ } | undefined;
83
100
  } | {
84
101
  readonly type: "document";
85
102
  readonly source: {
@@ -136,6 +153,23 @@ export declare const routes: (Route<{
136
153
  readonly transformations?: {
137
154
  readonly oversized_image?: "downsize" | "error" | undefined;
138
155
  } | undefined;
156
+ } | {
157
+ readonly type: "video";
158
+ readonly source: {
159
+ readonly type: "base64";
160
+ readonly media_type: string;
161
+ readonly data: string;
162
+ } | {
163
+ readonly type: "url";
164
+ readonly url: string;
165
+ } | {
166
+ readonly type: "file";
167
+ readonly file_id: string;
168
+ };
169
+ readonly cache_control?: {
170
+ readonly type: "ephemeral";
171
+ readonly ttl?: "1h" | "5m" | undefined;
172
+ } | undefined;
139
173
  } | {
140
174
  readonly type: "document";
141
175
  readonly source: {
@@ -72,6 +72,23 @@ export declare const routes: import("../route/client.js").Route<{
72
72
  readonly transformations?: {
73
73
  readonly oversized_image?: "downsize" | "error" | undefined;
74
74
  } | undefined;
75
+ } | {
76
+ readonly type: "video";
77
+ readonly source: {
78
+ readonly type: "base64";
79
+ readonly media_type: string;
80
+ readonly data: string;
81
+ } | {
82
+ readonly type: "url";
83
+ readonly url: string;
84
+ } | {
85
+ readonly type: "file";
86
+ readonly file_id: string;
87
+ };
88
+ readonly cache_control?: {
89
+ readonly type: "ephemeral";
90
+ readonly ttl?: "1h" | "5m" | undefined;
91
+ } | undefined;
75
92
  } | {
76
93
  readonly type: "document";
77
94
  readonly source: {
@@ -128,6 +145,23 @@ export declare const routes: import("../route/client.js").Route<{
128
145
  readonly transformations?: {
129
146
  readonly oversized_image?: "downsize" | "error" | undefined;
130
147
  } | undefined;
148
+ } | {
149
+ readonly type: "video";
150
+ readonly source: {
151
+ readonly type: "base64";
152
+ readonly media_type: string;
153
+ readonly data: string;
154
+ } | {
155
+ readonly type: "url";
156
+ readonly url: string;
157
+ } | {
158
+ readonly type: "file";
159
+ readonly file_id: string;
160
+ };
161
+ readonly cache_control?: {
162
+ readonly type: "ephemeral";
163
+ readonly ttl?: "1h" | "5m" | undefined;
164
+ } | undefined;
131
165
  } | {
132
166
  readonly type: "document";
133
167
  readonly source: {
@@ -57,6 +57,23 @@ export declare const routes: import("../route/client.js").Route<{
57
57
  readonly transformations?: {
58
58
  readonly oversized_image?: "downsize" | "error" | undefined;
59
59
  } | undefined;
60
+ } | {
61
+ readonly type: "video";
62
+ readonly source: {
63
+ readonly type: "base64";
64
+ readonly media_type: string;
65
+ readonly data: string;
66
+ } | {
67
+ readonly type: "url";
68
+ readonly url: string;
69
+ } | {
70
+ readonly type: "file";
71
+ readonly file_id: string;
72
+ };
73
+ readonly cache_control?: {
74
+ readonly type: "ephemeral";
75
+ readonly ttl?: "1h" | "5m" | undefined;
76
+ } | undefined;
60
77
  } | {
61
78
  readonly type: "document";
62
79
  readonly source: {
@@ -113,6 +130,23 @@ export declare const routes: import("../route/client.js").Route<{
113
130
  readonly transformations?: {
114
131
  readonly oversized_image?: "downsize" | "error" | undefined;
115
132
  } | undefined;
133
+ } | {
134
+ readonly type: "video";
135
+ readonly source: {
136
+ readonly type: "base64";
137
+ readonly media_type: string;
138
+ readonly data: string;
139
+ } | {
140
+ readonly type: "url";
141
+ readonly url: string;
142
+ } | {
143
+ readonly type: "file";
144
+ readonly file_id: string;
145
+ };
146
+ readonly cache_control?: {
147
+ readonly type: "ephemeral";
148
+ readonly ttl?: "1h" | "5m" | undefined;
149
+ } | undefined;
116
150
  } | {
117
151
  readonly type: "document";
118
152
  readonly source: {
@@ -286,6 +286,23 @@ export declare const messagesRoute: import("../route/client.js").Route<{
286
286
  readonly transformations?: {
287
287
  readonly oversized_image?: "downsize" | "error" | undefined;
288
288
  } | undefined;
289
+ } | {
290
+ readonly type: "video";
291
+ readonly source: {
292
+ readonly type: "base64";
293
+ readonly media_type: string;
294
+ readonly data: string;
295
+ } | {
296
+ readonly type: "url";
297
+ readonly url: string;
298
+ } | {
299
+ readonly type: "file";
300
+ readonly file_id: string;
301
+ };
302
+ readonly cache_control?: {
303
+ readonly type: "ephemeral";
304
+ readonly ttl?: "1h" | "5m" | undefined;
305
+ } | undefined;
289
306
  } | {
290
307
  readonly type: "document";
291
308
  readonly source: {
@@ -342,6 +359,23 @@ export declare const messagesRoute: import("../route/client.js").Route<{
342
359
  readonly transformations?: {
343
360
  readonly oversized_image?: "downsize" | "error" | undefined;
344
361
  } | undefined;
362
+ } | {
363
+ readonly type: "video";
364
+ readonly source: {
365
+ readonly type: "base64";
366
+ readonly media_type: string;
367
+ readonly data: string;
368
+ } | {
369
+ readonly type: "url";
370
+ readonly url: string;
371
+ } | {
372
+ readonly type: "file";
373
+ readonly file_id: string;
374
+ };
375
+ readonly cache_control?: {
376
+ readonly type: "ephemeral";
377
+ readonly ttl?: "1h" | "5m" | undefined;
378
+ } | undefined;
345
379
  } | {
346
380
  readonly type: "document";
347
381
  readonly source: {
@@ -691,6 +725,23 @@ export declare const routes: (import("../route/client.js").Route<{
691
725
  readonly transformations?: {
692
726
  readonly oversized_image?: "downsize" | "error" | undefined;
693
727
  } | undefined;
728
+ } | {
729
+ readonly type: "video";
730
+ readonly source: {
731
+ readonly type: "base64";
732
+ readonly media_type: string;
733
+ readonly data: string;
734
+ } | {
735
+ readonly type: "url";
736
+ readonly url: string;
737
+ } | {
738
+ readonly type: "file";
739
+ readonly file_id: string;
740
+ };
741
+ readonly cache_control?: {
742
+ readonly type: "ephemeral";
743
+ readonly ttl?: "1h" | "5m" | undefined;
744
+ } | undefined;
694
745
  } | {
695
746
  readonly type: "document";
696
747
  readonly source: {
@@ -747,6 +798,23 @@ export declare const routes: (import("../route/client.js").Route<{
747
798
  readonly transformations?: {
748
799
  readonly oversized_image?: "downsize" | "error" | undefined;
749
800
  } | undefined;
801
+ } | {
802
+ readonly type: "video";
803
+ readonly source: {
804
+ readonly type: "base64";
805
+ readonly media_type: string;
806
+ readonly data: string;
807
+ } | {
808
+ readonly type: "url";
809
+ readonly url: string;
810
+ } | {
811
+ readonly type: "file";
812
+ readonly file_id: string;
813
+ };
814
+ readonly cache_control?: {
815
+ readonly type: "ephemeral";
816
+ readonly ttl?: "1h" | "5m" | undefined;
817
+ } | undefined;
750
818
  } | {
751
819
  readonly type: "document";
752
820
  readonly source: {
@@ -69,6 +69,23 @@ export declare const routes: Route<{
69
69
  readonly transformations?: {
70
70
  readonly oversized_image?: "downsize" | "error" | undefined;
71
71
  } | undefined;
72
+ } | {
73
+ readonly type: "video";
74
+ readonly source: {
75
+ readonly type: "base64";
76
+ readonly media_type: string;
77
+ readonly data: string;
78
+ } | {
79
+ readonly type: "url";
80
+ readonly url: string;
81
+ } | {
82
+ readonly type: "file";
83
+ readonly file_id: string;
84
+ };
85
+ readonly cache_control?: {
86
+ readonly type: "ephemeral";
87
+ readonly ttl?: "1h" | "5m" | undefined;
88
+ } | undefined;
72
89
  } | {
73
90
  readonly type: "document";
74
91
  readonly source: {
@@ -125,6 +142,23 @@ export declare const routes: Route<{
125
142
  readonly transformations?: {
126
143
  readonly oversized_image?: "downsize" | "error" | undefined;
127
144
  } | undefined;
145
+ } | {
146
+ readonly type: "video";
147
+ readonly source: {
148
+ readonly type: "base64";
149
+ readonly media_type: string;
150
+ readonly data: string;
151
+ } | {
152
+ readonly type: "url";
153
+ readonly url: string;
154
+ } | {
155
+ readonly type: "file";
156
+ readonly file_id: string;
157
+ };
158
+ readonly cache_control?: {
159
+ readonly type: "ephemeral";
160
+ readonly ttl?: "1h" | "5m" | undefined;
161
+ } | undefined;
128
162
  } | {
129
163
  readonly type: "document";
130
164
  readonly source: {
@@ -396,6 +396,23 @@ export declare const routes: (Route<{
396
396
  readonly transformations?: {
397
397
  readonly oversized_image?: "downsize" | "error" | undefined;
398
398
  } | undefined;
399
+ } | {
400
+ readonly type: "video";
401
+ readonly source: {
402
+ readonly type: "base64";
403
+ readonly media_type: string;
404
+ readonly data: string;
405
+ } | {
406
+ readonly type: "url";
407
+ readonly url: string;
408
+ } | {
409
+ readonly type: "file";
410
+ readonly file_id: string;
411
+ };
412
+ readonly cache_control?: {
413
+ readonly type: "ephemeral";
414
+ readonly ttl?: "1h" | "5m" | undefined;
415
+ } | undefined;
399
416
  } | {
400
417
  readonly type: "document";
401
418
  readonly source: {
@@ -452,6 +469,23 @@ export declare const routes: (Route<{
452
469
  readonly transformations?: {
453
470
  readonly oversized_image?: "downsize" | "error" | undefined;
454
471
  } | undefined;
472
+ } | {
473
+ readonly type: "video";
474
+ readonly source: {
475
+ readonly type: "base64";
476
+ readonly media_type: string;
477
+ readonly data: string;
478
+ } | {
479
+ readonly type: "url";
480
+ readonly url: string;
481
+ } | {
482
+ readonly type: "file";
483
+ readonly file_id: string;
484
+ };
485
+ readonly cache_control?: {
486
+ readonly type: "ephemeral";
487
+ readonly ttl?: "1h" | "5m" | undefined;
488
+ } | undefined;
455
489
  } | {
456
490
  readonly type: "document";
457
491
  readonly source: {
@@ -83,6 +83,23 @@ export declare const routes: (Route<{
83
83
  readonly transformations?: {
84
84
  readonly oversized_image?: "downsize" | "error" | undefined;
85
85
  } | undefined;
86
+ } | {
87
+ readonly type: "video";
88
+ readonly source: {
89
+ readonly type: "base64";
90
+ readonly media_type: string;
91
+ readonly data: string;
92
+ } | {
93
+ readonly type: "url";
94
+ readonly url: string;
95
+ } | {
96
+ readonly type: "file";
97
+ readonly file_id: string;
98
+ };
99
+ readonly cache_control?: {
100
+ readonly type: "ephemeral";
101
+ readonly ttl?: "1h" | "5m" | undefined;
102
+ } | undefined;
86
103
  } | {
87
104
  readonly type: "document";
88
105
  readonly source: {
@@ -139,6 +156,23 @@ export declare const routes: (Route<{
139
156
  readonly transformations?: {
140
157
  readonly oversized_image?: "downsize" | "error" | undefined;
141
158
  } | undefined;
159
+ } | {
160
+ readonly type: "video";
161
+ readonly source: {
162
+ readonly type: "base64";
163
+ readonly media_type: string;
164
+ readonly data: string;
165
+ } | {
166
+ readonly type: "url";
167
+ readonly url: string;
168
+ } | {
169
+ readonly type: "file";
170
+ readonly file_id: string;
171
+ };
172
+ readonly cache_control?: {
173
+ readonly type: "ephemeral";
174
+ readonly ttl?: "1h" | "5m" | undefined;
175
+ } | undefined;
142
176
  } | {
143
177
  readonly type: "document";
144
178
  readonly source: {
@@ -81,6 +81,23 @@ export declare const routes: (Route<{
81
81
  readonly transformations?: {
82
82
  readonly oversized_image?: "downsize" | "error" | undefined;
83
83
  } | undefined;
84
+ } | {
85
+ readonly type: "video";
86
+ readonly source: {
87
+ readonly type: "base64";
88
+ readonly media_type: string;
89
+ readonly data: string;
90
+ } | {
91
+ readonly type: "url";
92
+ readonly url: string;
93
+ } | {
94
+ readonly type: "file";
95
+ readonly file_id: string;
96
+ };
97
+ readonly cache_control?: {
98
+ readonly type: "ephemeral";
99
+ readonly ttl?: "1h" | "5m" | undefined;
100
+ } | undefined;
84
101
  } | {
85
102
  readonly type: "document";
86
103
  readonly source: {
@@ -137,6 +154,23 @@ export declare const routes: (Route<{
137
154
  readonly transformations?: {
138
155
  readonly oversized_image?: "downsize" | "error" | undefined;
139
156
  } | undefined;
157
+ } | {
158
+ readonly type: "video";
159
+ readonly source: {
160
+ readonly type: "base64";
161
+ readonly media_type: string;
162
+ readonly data: string;
163
+ } | {
164
+ readonly type: "url";
165
+ readonly url: string;
166
+ } | {
167
+ readonly type: "file";
168
+ readonly file_id: string;
169
+ };
170
+ readonly cache_control?: {
171
+ readonly type: "ephemeral";
172
+ readonly ttl?: "1h" | "5m" | undefined;
173
+ } | undefined;
140
174
  } | {
141
175
  readonly type: "document";
142
176
  readonly source: {
@@ -387,6 +387,23 @@ export declare const routes: (Route<{
387
387
  readonly transformations?: {
388
388
  readonly oversized_image?: "downsize" | "error" | undefined;
389
389
  } | undefined;
390
+ } | {
391
+ readonly type: "video";
392
+ readonly source: {
393
+ readonly type: "base64";
394
+ readonly media_type: string;
395
+ readonly data: string;
396
+ } | {
397
+ readonly type: "url";
398
+ readonly url: string;
399
+ } | {
400
+ readonly type: "file";
401
+ readonly file_id: string;
402
+ };
403
+ readonly cache_control?: {
404
+ readonly type: "ephemeral";
405
+ readonly ttl?: "1h" | "5m" | undefined;
406
+ } | undefined;
390
407
  } | {
391
408
  readonly type: "document";
392
409
  readonly source: {
@@ -443,6 +460,23 @@ export declare const routes: (Route<{
443
460
  readonly transformations?: {
444
461
  readonly oversized_image?: "downsize" | "error" | undefined;
445
462
  } | undefined;
463
+ } | {
464
+ readonly type: "video";
465
+ readonly source: {
466
+ readonly type: "base64";
467
+ readonly media_type: string;
468
+ readonly data: string;
469
+ } | {
470
+ readonly type: "url";
471
+ readonly url: string;
472
+ } | {
473
+ readonly type: "file";
474
+ readonly file_id: string;
475
+ };
476
+ readonly cache_control?: {
477
+ readonly type: "ephemeral";
478
+ readonly ttl?: "1h" | "5m" | undefined;
479
+ } | undefined;
446
480
  } | {
447
481
  readonly type: "document";
448
482
  readonly source: {
@@ -216,6 +216,17 @@ const prepareRequest = (request) => {
216
216
  : LLMRequest.update(resolved, { http: mergeHttpOptions(new HttpOptions({ headers }), resolved.http) });
217
217
  };
218
218
  const compile = Effect.fn("LLM.compile")(function* (request, options) {
219
+ const references = request.messages.flatMap((message) => message.content.flatMap((part) => {
220
+ if (part.type === "media") {
221
+ const source = part.media.source;
222
+ return source.type === "url" ? [source.url] : source.type === "ref" ? [source.id] : [];
223
+ }
224
+ if (part.type !== "tool-result" || part.result.type !== "content")
225
+ return [];
226
+ return part.result.value.flatMap((item) => (item.type === "file" ? [item.uri] : []));
227
+ }));
228
+ if (references.some((reference) => /^\s*file:/i.test(reference)))
229
+ return yield* ProviderShared.invalidRequest("Local file references must be read with Media.file(path) before sending");
219
230
  const resolved = prepareRequest(request);
220
231
  const route = resolved.model.route;
221
232
  const body = yield* route.body.from(resolved);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-21799",
3
+ "version": "0.0.0-dev-21800",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "devDependencies": {
36
36
  "@clack/prompts": "1.0.0-alpha.1",
37
37
  "@effect/platform-node": "4.0.1",
38
- "@opencode/http-recorder": "0.0.0-dev-21799",
38
+ "@opencode/http-recorder": "0.0.0-dev-21800",
39
39
  "@tsconfig/bun": "1.0.9",
40
40
  "@types/bun": "1.4.3",
41
41
  "@typescript/native": "npm:typescript@7.1.0-beta",
@@ -45,7 +45,7 @@
45
45
  "@aws-sdk/credential-providers": "3.1057.0",
46
46
  "@smithy/eventstream-codec": "4.2.14",
47
47
  "@smithy/util-utf8": "4.2.2",
48
- "@opencode/schema": "0.0.0-dev-21799",
48
+ "@opencode/schema": "0.0.0-dev-21800",
49
49
  "aws4fetch": "1.0.20",
50
50
  "effect": "4.0.1",
51
51
  "google-auth-library": "10.5.0"