@opencode/ai 0.0.0-dev-21800 → 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.
@@ -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;
@@ -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
- return yield* OpenResponses.fromRequestWithAdapter(LLMRequest.update(request, {
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, target) {
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 (target === "tool-result" && part.media.kind === "video")
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* lowerMessageMedia(part, request, adapter);
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, "tool-result");
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) => lowerHostedToolResultContentItem(item, request, adapter)),
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* lowerMessageMedia(part, request, adapter)],
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;
@@ -53,6 +53,9 @@ export declare const protocol: Protocol<{
53
53
  readonly content: readonly ({
54
54
  readonly type: "input_text";
55
55
  readonly text: string;
56
+ } | {
57
+ readonly type: "input_video";
58
+ readonly video_url: string;
56
59
  } | {
57
60
  readonly type: "input_image";
58
61
  readonly image_url: string;
@@ -24,6 +24,15 @@ const XAIResponsesHostedToolItem = Schema.Union([
24
24
  const adapter = {
25
25
  id: ADAPTER,
26
26
  name: NAME,
27
+ lowerMedia: ({ part, media }) => {
28
+ if (part.media.kind !== "video")
29
+ return undefined;
30
+ const filename = part.filename ?? "file";
31
+ const url = ProviderShared.mediaUrl(part.media);
32
+ if (url)
33
+ return { type: "input_file", filename, file_url: url };
34
+ return media && { type: "input_file", filename, file_data: media.dataUrl };
35
+ },
27
36
  restoreHostedToolItem: (item) => (Schema.is(XAIResponsesHostedToolItem)(item) ? item : undefined),
28
37
  };
29
38
  const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
@@ -524,6 +524,9 @@ export declare const routes: (Route<{
524
524
  readonly content: readonly ({
525
525
  readonly type: "input_text";
526
526
  readonly text: string;
527
+ } | {
528
+ readonly type: "input_video";
529
+ readonly video_url: string;
527
530
  } | {
528
531
  readonly type: "input_image";
529
532
  readonly image_url: string;
@@ -520,6 +520,9 @@ export declare const routes: (Route<{
520
520
  readonly content: readonly ({
521
521
  readonly type: "input_text";
522
522
  readonly text: string;
523
+ } | {
524
+ readonly type: "input_video";
525
+ readonly video_url: string;
523
526
  } | {
524
527
  readonly type: "input_image";
525
528
  readonly image_url: string;
@@ -74,6 +74,9 @@ declare const responsesRoute: Route<{
74
74
  readonly content: readonly ({
75
75
  readonly type: "input_text";
76
76
  readonly text: string;
77
+ } | {
78
+ readonly type: "input_video";
79
+ readonly video_url: string;
77
80
  } | {
78
81
  readonly type: "input_image";
79
82
  readonly image_url: string;
@@ -411,6 +414,9 @@ export declare const routes: (Route<{
411
414
  readonly content: readonly ({
412
415
  readonly type: "input_text";
413
416
  readonly text: string;
417
+ } | {
418
+ readonly type: "input_video";
419
+ readonly video_url: string;
414
420
  } | {
415
421
  readonly type: "input_image";
416
422
  readonly image_url: string;
@@ -82,6 +82,9 @@ export declare const responsesRoute: import("../route/client.js").Route<{
82
82
  readonly content: readonly ({
83
83
  readonly type: "input_text";
84
84
  readonly text: string;
85
+ } | {
86
+ readonly type: "input_video";
87
+ readonly video_url: string;
85
88
  } | {
86
89
  readonly type: "input_image";
87
90
  readonly image_url: string;
@@ -1165,6 +1168,9 @@ export declare const routes: (import("../route/client.js").Route<{
1165
1168
  readonly content: readonly ({
1166
1169
  readonly type: "input_text";
1167
1170
  readonly text: string;
1171
+ } | {
1172
+ readonly type: "input_video";
1173
+ readonly video_url: string;
1168
1174
  } | {
1169
1175
  readonly type: "input_image";
1170
1176
  readonly image_url: string;
@@ -70,6 +70,9 @@ export declare const routes: Route<{
70
70
  readonly content: readonly ({
71
71
  readonly type: "input_text";
72
72
  readonly text: string;
73
+ } | {
74
+ readonly type: "input_video";
75
+ readonly video_url: string;
73
76
  } | {
74
77
  readonly type: "input_image";
75
78
  readonly image_url: string;
@@ -222,6 +222,9 @@ export declare const routes: (Route<{
222
222
  readonly content: readonly ({
223
223
  readonly type: "input_text";
224
224
  readonly text: string;
225
+ } | {
226
+ readonly type: "input_video";
227
+ readonly video_url: string;
225
228
  } | {
226
229
  readonly type: "input_image";
227
230
  readonly image_url: string;
@@ -392,6 +392,9 @@ export declare const routes: (Route<{
392
392
  readonly content: readonly ({
393
393
  readonly type: "input_text";
394
394
  readonly text: string;
395
+ } | {
396
+ readonly type: "input_video";
397
+ readonly video_url: string;
395
398
  } | {
396
399
  readonly type: "input_image";
397
400
  readonly image_url: string;
@@ -390,6 +390,9 @@ export declare const routes: (Route<{
390
390
  readonly content: readonly ({
391
391
  readonly type: "input_text";
392
392
  readonly text: string;
393
+ } | {
394
+ readonly type: "input_video";
395
+ readonly video_url: string;
393
396
  } | {
394
397
  readonly type: "input_image";
395
398
  readonly image_url: string;
@@ -68,6 +68,9 @@ export declare const routes: import("../route/client.js").Route<{
68
68
  readonly content: readonly ({
69
69
  readonly type: "input_text";
70
70
  readonly text: string;
71
+ } | {
72
+ readonly type: "input_video";
73
+ readonly video_url: string;
71
74
  } | {
72
75
  readonly type: "input_image";
73
76
  readonly image_url: string;
@@ -195,6 +195,9 @@ export declare const routes: (Route<{
195
195
  readonly content: readonly ({
196
196
  readonly type: "input_text";
197
197
  readonly text: string;
198
+ } | {
199
+ readonly type: "input_video";
200
+ readonly video_url: string;
198
201
  } | {
199
202
  readonly type: "input_image";
200
203
  readonly image_url: string;
@@ -72,6 +72,9 @@ export declare const routes: (Route<{
72
72
  readonly content: readonly ({
73
73
  readonly type: "input_text";
74
74
  readonly text: string;
75
+ } | {
76
+ readonly type: "input_video";
77
+ readonly video_url: string;
75
78
  } | {
76
79
  readonly type: "input_image";
77
80
  readonly image_url: string;
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-21800",
3
+ "version": "0.0.0-dev-21801",
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-21800",
38
+ "@opencode/http-recorder": "0.0.0-dev-21801",
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-21800",
48
+ "@opencode/schema": "0.0.0-dev-21801",
49
49
  "aws4fetch": "1.0.20",
50
50
  "effect": "4.0.1",
51
51
  "google-auth-library": "10.5.0"