@opencode/ai 2.2.7 → 2.3.1

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.
Files changed (158) hide show
  1. package/README.md +164 -99
  2. package/dist/cache-policy.js +4 -2
  3. package/dist/effect.d.ts +11 -8
  4. package/dist/effect.js +2 -1
  5. package/dist/experimental.d.ts +0 -4
  6. package/dist/experimental.js +0 -3
  7. package/dist/generation.d.ts +10 -10
  8. package/dist/generation.js +8 -14
  9. package/dist/image-client.d.ts +56 -59
  10. package/dist/image-client.js +47 -12
  11. package/dist/image.d.ts +36 -95
  12. package/dist/image.js +11 -14
  13. package/dist/index.d.ts +31 -68
  14. package/dist/index.js +54 -30
  15. package/dist/llm.d.ts +4 -1
  16. package/dist/llm.js +10 -1
  17. package/dist/media-client.d.ts +18 -6
  18. package/dist/media-client.js +42 -37
  19. package/dist/media-model.d.ts +2 -0
  20. package/dist/media-model.js +3 -1
  21. package/dist/media.d.ts +26 -4
  22. package/dist/media.js +52 -11
  23. package/dist/protocols/alibaba-messages.d.ts +24 -2
  24. package/dist/protocols/alibaba-responses.d.ts +26 -0
  25. package/dist/protocols/anthropic-messages.d.ts +70 -6
  26. package/dist/protocols/anthropic-messages.js +74 -9
  27. package/dist/protocols/assemblyai-transcription.js +7 -6
  28. package/dist/protocols/cartesia-speech.d.ts +0 -8
  29. package/dist/protocols/deepgram-speech.d.ts +0 -8
  30. package/dist/protocols/elevenlabs-speech.d.ts +0 -8
  31. package/dist/protocols/google-decisions.d.ts +13 -0
  32. package/dist/protocols/google-decisions.js +133 -0
  33. package/dist/protocols/google-interactions-video.d.ts +38 -0
  34. package/dist/protocols/google-interactions-video.js +185 -0
  35. package/dist/protocols/google-interactions.d.ts +14 -1
  36. package/dist/protocols/google-interactions.js +1 -1
  37. package/dist/protocols/google-speech.d.ts +0 -8
  38. package/dist/protocols/google-transcription.d.ts +0 -8
  39. package/dist/protocols/index.d.ts +1 -0
  40. package/dist/protocols/index.js +1 -0
  41. package/dist/protocols/meta-messages.d.ts +24 -2
  42. package/dist/protocols/meta-responses.d.ts +52 -0
  43. package/dist/protocols/minimax-video.d.ts +45 -0
  44. package/dist/protocols/minimax-video.js +290 -0
  45. package/dist/protocols/open-responses.d.ts +250 -24
  46. package/dist/protocols/open-responses.js +40 -24
  47. package/dist/protocols/openai-chat.js +7 -3
  48. package/dist/protocols/openai-compatible-responses.d.ts +26 -0
  49. package/dist/protocols/openai-freeform.d.ts +1 -1
  50. package/dist/protocols/openai-freeform.js +9 -5
  51. package/dist/protocols/openai-images.d.ts +0 -8
  52. package/dist/protocols/openai-responses.d.ts +153 -0
  53. package/dist/protocols/openai-responses.js +68 -7
  54. package/dist/protocols/openai-speech.d.ts +0 -8
  55. package/dist/protocols/openai-transcription.d.ts +0 -8
  56. package/dist/protocols/openrouter-video.d.ts +36 -0
  57. package/dist/protocols/openrouter-video.js +139 -0
  58. package/dist/protocols/seedance-video.d.ts +45 -0
  59. package/dist/protocols/seedance-video.js +217 -0
  60. package/dist/protocols/system-one.d.ts +45 -1
  61. package/dist/protocols/system-one.js +42 -7
  62. package/dist/protocols/utils/gateway-protocol.js +1 -0
  63. package/dist/protocols/utils/responses-compaction.js +8 -4
  64. package/dist/protocols/xai-responses.d.ts +26 -0
  65. package/dist/protocols/xai-video.d.ts +12 -11
  66. package/dist/protocols/xai-video.js +33 -24
  67. package/dist/protocols/zai-messages.d.ts +24 -2
  68. package/dist/provider-error.js +7 -1
  69. package/dist/providers/alibaba.d.ts +50 -2
  70. package/dist/providers/amazon-bedrock-mantle.d.ts +50 -2
  71. package/dist/providers/anthropic-compatible.d.ts +24 -2
  72. package/dist/providers/anthropic.d.ts +24 -2
  73. package/dist/providers/azure.d.ts +76 -2
  74. package/dist/providers/byteplus/videos.d.ts +2 -0
  75. package/dist/providers/byteplus/videos.js +1 -0
  76. package/dist/providers/byteplus.d.ts +26 -0
  77. package/dist/providers/byteplus.js +21 -0
  78. package/dist/providers/cloudflare-ai-gateway.d.ts +100 -4
  79. package/dist/providers/digitalocean.d.ts +26 -0
  80. package/dist/providers/google/decisions.d.ts +2 -0
  81. package/dist/providers/google/decisions.js +1 -0
  82. package/dist/providers/google/videos.d.ts +2 -0
  83. package/dist/providers/google/videos.js +1 -0
  84. package/dist/providers/google-vertex-messages.d.ts +24 -2
  85. package/dist/providers/google-vertex-messages.js +1 -0
  86. package/dist/providers/google-vertex-responses.d.ts +26 -0
  87. package/dist/providers/google.d.ts +11 -4
  88. package/dist/providers/google.js +16 -3
  89. package/dist/providers/index.d.ts +2 -1
  90. package/dist/providers/index.js +2 -1
  91. package/dist/providers/meta.d.ts +50 -2
  92. package/dist/providers/minimax/videos.d.ts +3 -0
  93. package/dist/providers/minimax/videos.js +1 -0
  94. package/dist/providers/minimax.d.ts +56 -3
  95. package/dist/providers/minimax.js +10 -1
  96. package/dist/providers/moonshot.d.ts +50 -2
  97. package/dist/providers/openai-compatible/decisions.d.ts +2 -0
  98. package/dist/providers/openai-compatible/decisions.js +1 -0
  99. package/dist/providers/openai-compatible-responses.d.ts +26 -0
  100. package/dist/providers/openai-compatible.d.ts +2 -0
  101. package/dist/providers/openai-compatible.js +14 -0
  102. package/dist/providers/openai.d.ts +26 -0
  103. package/dist/providers/openrouter/videos.d.ts +2 -0
  104. package/dist/providers/openrouter/videos.js +1 -0
  105. package/dist/providers/openrouter.d.ts +31 -0
  106. package/dist/providers/openrouter.js +8 -0
  107. package/dist/providers/venice.d.ts +26 -0
  108. package/dist/providers/volcengine/videos.d.ts +2 -0
  109. package/dist/providers/volcengine/videos.js +1 -0
  110. package/dist/providers/volcengine.d.ts +26 -0
  111. package/dist/providers/volcengine.js +21 -0
  112. package/dist/providers/xai/videos.d.ts +2 -0
  113. package/dist/providers/xai/videos.js +1 -0
  114. package/dist/providers/xai.d.ts +4 -3
  115. package/dist/providers/xai.js +5 -1
  116. package/dist/providers/zai-coding-plan.d.ts +50 -2
  117. package/dist/public.d.ts +7 -4
  118. package/dist/public.js +2 -1
  119. package/dist/route/client.d.ts +2 -0
  120. package/dist/route/client.js +5 -1
  121. package/dist/route/executor-service.d.ts +20 -1
  122. package/dist/route/executor-service.js +35 -1
  123. package/dist/route/executor.d.ts +11 -2
  124. package/dist/route/executor.js +25 -5
  125. package/dist/route/media-protocol.d.ts +21 -15
  126. package/dist/route/media-protocol.js +11 -4
  127. package/dist/route/media.d.ts +2 -0
  128. package/dist/route/media.js +40 -22
  129. package/dist/route/protocol.d.ts +3 -0
  130. package/dist/route/transport/http.js +1 -1
  131. package/dist/schema/events.d.ts +5 -0
  132. package/dist/schema/messages.d.ts +25 -2
  133. package/dist/schema/messages.js +27 -7
  134. package/dist/schema/options.d.ts +18 -2
  135. package/dist/schema/options.js +1 -0
  136. package/dist/speech-client.d.ts +6 -6
  137. package/dist/speech-client.js +4 -4
  138. package/dist/speech.d.ts +7 -88
  139. package/dist/speech.js +1 -3
  140. package/dist/tool-updates.d.ts +34 -0
  141. package/dist/tool-updates.js +93 -0
  142. package/dist/tool.d.ts +6 -1
  143. package/dist/tool.js +1 -1
  144. package/dist/transcription-client.d.ts +6 -6
  145. package/dist/transcription-client.js +1 -2
  146. package/dist/transcription.d.ts +7 -88
  147. package/dist/transcription.js +1 -3
  148. package/dist/video-client.d.ts +16 -84
  149. package/dist/video-client.js +30 -13
  150. package/dist/video.d.ts +54 -1126
  151. package/dist/video.js +29 -65
  152. package/package.json +59 -7
  153. package/dist/protocols/google-video.d.ts +0 -26
  154. package/dist/protocols/google-video.js +0 -146
  155. package/dist/protocols/runway-video.d.ts +0 -38
  156. package/dist/protocols/runway-video.js +0 -141
  157. package/dist/providers/runway.d.ts +0 -20
  158. package/dist/providers/runway.js +0 -17
@@ -1,6 +1,5 @@
1
1
  import { Context } from "effect";
2
2
  import { MediaClient } from "./media-client.js";
3
- import { TranscriptionFinishEvent, } from "./transcription.js";
4
3
  export class TranscriptionClientService extends Context.Service()("@opencode/TranscriptionClient") {
5
4
  }
6
5
  export const Service = TranscriptionClientService;
@@ -8,6 +7,6 @@ export const TranscriptionClient = {
8
7
  Service,
9
8
  ...MediaClient.make(Service, {
10
9
  modality: "transcription",
11
- responseEvents: (response) => [TranscriptionFinishEvent.make({ ...response })],
10
+ responseEvents: (response) => [{ type: "finish", ...response }],
12
11
  }),
13
12
  };
@@ -183,10 +183,6 @@ export declare const TranscriptionFinishEvent: Schema.Struct<{
183
183
  readonly type: Schema.tag<"finish">;
184
184
  }>;
185
185
  declare const transcriptionEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
186
- readonly type: Schema.tag<"generation-queued">;
187
- readonly id: Schema.String;
188
- readonly position: Schema.optional<Schema.Number>;
189
- }>, Schema.Struct<{
190
186
  readonly type: Schema.tag<"generation-progress">;
191
187
  readonly id: Schema.String;
192
188
  readonly progress: Schema.optional<Schema.Number>;
@@ -241,10 +237,6 @@ declare const transcriptionEventTagged: Schema.toTaggedUnion<"type", readonly [S
241
237
  readonly type: Schema.tag<"finish">;
242
238
  }>]>;
243
239
  export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
244
- readonly type: Schema.tag<"generation-queued">;
245
- readonly id: Schema.String;
246
- readonly position: Schema.optional<Schema.Number>;
247
- }>, Schema.Struct<{
248
240
  readonly type: Schema.tag<"generation-progress">;
249
241
  readonly id: Schema.String;
250
242
  readonly progress: Schema.optional<Schema.Number>;
@@ -299,7 +291,7 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
299
291
  readonly type: Schema.tag<"finish">;
300
292
  }>]> & {
301
293
  readonly tag: "type";
302
- readonly discriminants: readonly ["generation-queued", "generation-progress", "text-delta", "segment", "finish"];
294
+ readonly discriminants: readonly ["generation-progress", "text-delta", "segment", "finish"];
303
295
  readonly cases: {
304
296
  finish: Schema.Struct<{
305
297
  readonly text: Schema.String;
@@ -345,11 +337,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
345
337
  readonly id: Schema.String;
346
338
  readonly progress: Schema.optional<Schema.Number>;
347
339
  }>;
348
- "generation-queued": Schema.Struct<{
349
- readonly type: Schema.tag<"generation-queued">;
350
- readonly id: Schema.String;
351
- readonly position: Schema.optional<Schema.Number>;
352
- }>;
353
340
  segment: Schema.Struct<{
354
341
  readonly type: Schema.tag<"segment">;
355
342
  readonly segment: Schema.Struct<{
@@ -375,10 +362,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
375
362
  readonly endSeconds: number;
376
363
  readonly speaker?: string | undefined;
377
364
  };
378
- } | {
379
- readonly type: "generation-queued";
380
- readonly id: string;
381
- readonly position?: number | undefined;
382
365
  } | {
383
366
  readonly type: "generation-progress";
384
367
  readonly id: string;
@@ -442,12 +425,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
442
425
  };
443
426
  }, {
444
427
  readonly type: Keys;
445
- }> | Extract<{
446
- readonly type: "generation-queued";
447
- readonly id: string;
448
- readonly position?: number | undefined;
449
- }, {
450
- readonly type: Keys;
451
428
  }> | Extract<{
452
429
  readonly type: "generation-progress";
453
430
  readonly id: string;
@@ -552,11 +529,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
552
529
  readonly id: string;
553
530
  readonly progress?: number | undefined;
554
531
  };
555
- "generation-queued": (u: unknown) => u is {
556
- readonly type: "generation-queued";
557
- readonly id: string;
558
- readonly position?: number | undefined;
559
- };
560
532
  segment: (u: unknown) => u is {
561
533
  readonly type: "segment";
562
534
  readonly segment: {
@@ -572,7 +544,7 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
572
544
  };
573
545
  };
574
546
  readonly match: {
575
- <Handlers extends { [K in "finish" | "generation-progress" | "generation-queued" | "segment" | "text-delta"]: (value: {
547
+ <Handlers extends { [K in "finish" | "generation-progress" | "segment" | "text-delta"]: (value: {
576
548
  readonly finish: Schema.Struct<{
577
549
  readonly text: Schema.String;
578
550
  readonly segments: Schema.optional<Schema.$Array<Schema.Struct<{
@@ -617,11 +589,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
617
589
  readonly id: Schema.String;
618
590
  readonly progress: Schema.optional<Schema.Number>;
619
591
  }>;
620
- readonly "generation-queued": Schema.Struct<{
621
- readonly type: Schema.tag<"generation-queued">;
622
- readonly id: Schema.String;
623
- readonly position: Schema.optional<Schema.Number>;
624
- }>;
625
592
  readonly segment: Schema.Struct<{
626
593
  readonly type: Schema.tag<"segment">;
627
594
  readonly segment: Schema.Struct<{
@@ -646,10 +613,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
646
613
  readonly endSeconds: number;
647
614
  readonly speaker?: string | undefined;
648
615
  };
649
- } | {
650
- readonly type: "generation-queued";
651
- readonly id: string;
652
- readonly position?: number | undefined;
653
616
  } | {
654
617
  readonly type: "generation-progress";
655
618
  readonly id: string;
@@ -698,8 +661,8 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
698
661
  };
699
662
  } | undefined;
700
663
  readonly type: "finish";
701
- }, cases: Handlers): import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "generation-queued" | "segment" | "text-delta"]>>;
702
- <Handlers extends { [K in "finish" | "generation-progress" | "generation-queued" | "segment" | "text-delta"]: (value: {
664
+ }, cases: Handlers): import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "segment" | "text-delta"]>>;
665
+ <Handlers extends { [K in "finish" | "generation-progress" | "segment" | "text-delta"]: (value: {
703
666
  readonly finish: Schema.Struct<{
704
667
  readonly text: Schema.String;
705
668
  readonly segments: Schema.optional<Schema.$Array<Schema.Struct<{
@@ -744,11 +707,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
744
707
  readonly id: Schema.String;
745
708
  readonly progress: Schema.optional<Schema.Number>;
746
709
  }>;
747
- readonly "generation-queued": Schema.Struct<{
748
- readonly type: Schema.tag<"generation-queued">;
749
- readonly id: Schema.String;
750
- readonly position: Schema.optional<Schema.Number>;
751
- }>;
752
710
  readonly segment: Schema.Struct<{
753
711
  readonly type: Schema.tag<"segment">;
754
712
  readonly segment: Schema.Struct<{
@@ -773,10 +731,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
773
731
  readonly endSeconds: number;
774
732
  readonly speaker?: string | undefined;
775
733
  };
776
- } | {
777
- readonly type: "generation-queued";
778
- readonly id: string;
779
- readonly position?: number | undefined;
780
734
  } | {
781
735
  readonly type: "generation-progress";
782
736
  readonly id: string;
@@ -825,7 +779,7 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
825
779
  };
826
780
  } | undefined;
827
781
  readonly type: "finish";
828
- }) => import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "generation-queued" | "segment" | "text-delta"]>>;
782
+ }) => import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "segment" | "text-delta"]>>;
829
783
  };
830
784
  readonly matchOrElse: {
831
785
  <Handlers, OrElse>(value: {
@@ -839,10 +793,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
839
793
  readonly endSeconds: number;
840
794
  readonly speaker?: string | undefined;
841
795
  };
842
- } | {
843
- readonly type: "generation-queued";
844
- readonly id: string;
845
- readonly position?: number | undefined;
846
796
  } | {
847
797
  readonly type: "generation-progress";
848
798
  readonly id: string;
@@ -942,11 +892,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
942
892
  readonly id: string;
943
893
  readonly progress?: number | undefined;
944
894
  }) => any) | undefined;
945
- readonly "generation-queued"?: ((value: {
946
- readonly type: "generation-queued";
947
- readonly id: string;
948
- readonly position?: number | undefined;
949
- }) => any) | undefined;
950
895
  readonly segment?: ((value: {
951
896
  readonly type: "segment";
952
897
  readonly segment: {
@@ -960,7 +905,7 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
960
905
  readonly type: "text-delta";
961
906
  readonly delta: string;
962
907
  }) => any) | undefined;
963
- } & (Exclude<keyof Handlers, "finish" | "generation-progress" | "generation-queued" | "segment" | "text-delta"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
908
+ } & (Exclude<keyof Handlers, "finish" | "generation-progress" | "segment" | "text-delta"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
964
909
  readonly type: "text-delta";
965
910
  readonly delta: string;
966
911
  }, {
@@ -975,12 +920,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
975
920
  };
976
921
  }, {
977
922
  readonly type: keyof Handlers;
978
- }> | Exclude<{
979
- readonly type: "generation-queued";
980
- readonly id: string;
981
- readonly position?: number | undefined;
982
- }, {
983
- readonly type: keyof Handlers;
984
923
  }> | Exclude<{
985
924
  readonly type: "generation-progress";
986
925
  readonly id: string;
@@ -1085,11 +1024,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
1085
1024
  readonly id: string;
1086
1025
  readonly progress?: number | undefined;
1087
1026
  }) => any) | undefined;
1088
- readonly "generation-queued"?: ((value: {
1089
- readonly type: "generation-queued";
1090
- readonly id: string;
1091
- readonly position?: number | undefined;
1092
- }) => any) | undefined;
1093
1027
  readonly segment?: ((value: {
1094
1028
  readonly type: "segment";
1095
1029
  readonly segment: {
@@ -1103,7 +1037,7 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
1103
1037
  readonly type: "text-delta";
1104
1038
  readonly delta: string;
1105
1039
  }) => any) | undefined;
1106
- } & (Exclude<keyof Handlers, "finish" | "generation-progress" | "generation-queued" | "segment" | "text-delta"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
1040
+ } & (Exclude<keyof Handlers, "finish" | "generation-progress" | "segment" | "text-delta"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
1107
1041
  readonly type: "text-delta";
1108
1042
  readonly delta: string;
1109
1043
  }, {
@@ -1118,12 +1052,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
1118
1052
  };
1119
1053
  }, {
1120
1054
  readonly type: keyof Handlers;
1121
- }> | Exclude<{
1122
- readonly type: "generation-queued";
1123
- readonly id: string;
1124
- readonly position?: number | undefined;
1125
- }, {
1126
- readonly type: keyof Handlers;
1127
1055
  }> | Exclude<{
1128
1056
  readonly type: "generation-progress";
1129
1057
  readonly id: string;
@@ -1187,10 +1115,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
1187
1115
  readonly endSeconds: number;
1188
1116
  readonly speaker?: string | undefined;
1189
1117
  };
1190
- } | {
1191
- readonly type: "generation-queued";
1192
- readonly id: string;
1193
- readonly position?: number | undefined;
1194
1118
  } | {
1195
1119
  readonly type: "generation-progress";
1196
1120
  readonly id: string;
@@ -1243,11 +1167,6 @@ export declare const TranscriptionEvent: Schema.Union<readonly [Schema.Struct<{
1243
1167
  };
1244
1168
  } & {
1245
1169
  is: {
1246
- generationQueued: (u: unknown) => u is {
1247
- readonly type: "generation-queued";
1248
- readonly id: string;
1249
- readonly position?: number | undefined;
1250
- };
1251
1170
  generationProgress: (u: unknown) => u is {
1252
1171
  readonly type: "generation-progress";
1253
1172
  readonly id: string;
@@ -1,5 +1,5 @@
1
1
  import { Effect, Schema, Stream } from "effect";
2
- import { Generation, ProgressEvent, QueuedEvent } from "./generation.js";
2
+ import { Generation, ProgressEvent } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
@@ -74,7 +74,6 @@ export const TranscriptionFinishEvent = Schema.Struct({
74
74
  ...transcriptFields,
75
75
  }).annotate({ identifier: "Transcription.Event.Finish" });
76
76
  const transcriptionEventTagged = Schema.Union([
77
- QueuedEvent,
78
77
  ProgressEvent,
79
78
  TranscriptionTextDeltaEvent,
80
79
  TranscriptionSegmentEvent,
@@ -82,7 +81,6 @@ const transcriptionEventTagged = Schema.Union([
82
81
  ]).pipe(Schema.toTaggedUnion("type"));
83
82
  export const TranscriptionEvent = Object.assign(transcriptionEventTagged, {
84
83
  is: {
85
- generationQueued: transcriptionEventTagged.guards["generation-queued"],
86
84
  generationProgress: transcriptionEventTagged.guards["generation-progress"],
87
85
  textDelta: transcriptionEventTagged.guards["text-delta"],
88
86
  segment: transcriptionEventTagged.guards.segment,
@@ -1,93 +1,25 @@
1
- import { Context } from "effect";
2
- import { MediaClient } from "./media-client.js";
3
- import { type VideoEvent, type VideoRequest, type VideoResponse } from "./video.js";
4
- export type Interface = MediaClient.Interface<VideoRequest, VideoEvent, VideoResponse>;
1
+ import { Context, Effect, Layer } from "effect";
2
+ import { RequestExecutor } from "./route/executor.js";
3
+ import { AIError } from "./schema/index.js";
4
+ import type { VideoJob, VideoModel, VideoRequest, VideoResponse, VideoStatus } from "./video.js";
5
+ export interface Interface {
6
+ readonly start: (request: VideoRequest) => Effect.Effect<VideoJob, AIError>;
7
+ readonly status: (model: VideoModel, id: string) => Effect.Effect<VideoStatus, AIError>;
8
+ readonly result: (model: VideoModel, id: string) => Effect.Effect<VideoResponse, AIError>;
9
+ readonly cancel: (model: VideoModel, id: string) => Effect.Effect<void, AIError>;
10
+ }
5
11
  declare const VideoClientService_base: Context.ServiceClass<VideoClientService, "@opencode/VideoClient", Interface>;
6
12
  export declare class VideoClientService extends VideoClientService_base {
7
13
  }
8
14
  export declare const Service: typeof VideoClientService;
9
15
  export type Service = VideoClientService;
16
+ export declare const layer: Layer.Layer<VideoClientService, never, RequestExecutor.RequestExecutorService>;
10
17
  export declare const VideoClient: {
11
- readonly responseEvents: (response: VideoResponse) => readonly ({
12
- readonly type: "video";
13
- readonly index: number;
14
- readonly video: import("./media.js").Asset;
15
- } | {
16
- readonly type: "generation-queued";
17
- readonly id: string;
18
- readonly position?: number | undefined;
19
- } | {
20
- readonly type: "generation-progress";
21
- readonly id: string;
22
- readonly progress?: number | undefined;
23
- } | {
24
- readonly type: "finish";
25
- readonly usage?: {
26
- readonly type: "seconds";
27
- readonly seconds: number;
28
- } | {
29
- readonly type: "characters";
30
- readonly characters: number;
31
- } | {
32
- readonly type: "credits";
33
- readonly credits: number;
34
- } | {
35
- readonly type: "compute";
36
- readonly seconds: number;
37
- } | {
38
- readonly type: "tokens";
39
- readonly input?: number | undefined;
40
- readonly output?: number | undefined;
41
- readonly total?: number | undefined;
42
- readonly details?: {
43
- readonly [x: string]: unknown;
44
- } | undefined;
45
- } | undefined;
46
- readonly providerMetadata?: {
47
- readonly [x: string]: {
48
- readonly [x: string]: unknown;
49
- };
50
- } | undefined;
51
- })[];
52
- readonly layer: import("effect/Layer").Layer<VideoClientService, never, import("./route.js").RequestExecutorService>;
53
- readonly generate: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<VideoResponse, import("./public.js").AIError, VideoClientService>;
54
- readonly stream: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
55
- readonly type: "video";
56
- readonly index: number;
57
- readonly video: import("./media.js").Asset;
58
- } | {
59
- readonly type: "finish";
60
- readonly usage?: {
61
- readonly type: "seconds";
62
- readonly seconds: number;
63
- } | {
64
- readonly type: "characters";
65
- readonly characters: number;
66
- } | {
67
- readonly type: "credits";
68
- readonly credits: number;
69
- } | {
70
- readonly type: "compute";
71
- readonly seconds: number;
72
- } | {
73
- readonly type: "tokens";
74
- readonly input?: number | undefined;
75
- readonly output?: number | undefined;
76
- readonly total?: number | undefined;
77
- readonly details?: {
78
- readonly [x: string]: unknown;
79
- } | undefined;
80
- } | undefined;
81
- readonly providerMetadata?: {
82
- readonly [x: string]: {
83
- readonly [x: string]: unknown;
84
- };
85
- } | undefined;
86
- } | import("./generation.js").Observation, import("./public.js").AIError, VideoClientService>;
87
- readonly start: (request: VideoRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./public.js").AIError, VideoClientService>;
88
- readonly resume: (model: import("./video.js").VideoModel<{
89
- readonly [x: string]: unknown;
90
- }>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./public.js").AIError, VideoClientService>;
91
18
  readonly Service: typeof VideoClientService;
19
+ readonly layer: Layer.Layer<VideoClientService, never, RequestExecutor.RequestExecutorService>;
20
+ readonly start: (request: VideoRequest) => Effect.Effect<VideoJob, AIError, VideoClientService>;
21
+ readonly status: (model: VideoModel, id: string) => Effect.Effect<VideoStatus, AIError, VideoClientService>;
22
+ readonly result: (model: VideoModel, id: string) => Effect.Effect<VideoResponse, AIError, VideoClientService>;
23
+ readonly cancel: (model: VideoModel, id: string) => Effect.Effect<void, AIError, VideoClientService>;
92
24
  };
93
25
  export {};
@@ -1,19 +1,36 @@
1
- import { Context } from "effect";
2
- import { MediaClient } from "./media-client.js";
3
- import { VideoOutputEvent, VideoFinishEvent } from "./video.js";
1
+ import { Context, Effect, Layer, Schema } from "effect";
2
+ import { RequestExecutor } from "./route/executor.js";
3
+ import { AIError, UnsupportedOperationError } from "./schema/index.js";
4
4
  export class VideoClientService extends Context.Service()("@opencode/VideoClient") {
5
5
  }
6
6
  export const Service = VideoClientService;
7
+ // A video route whose token isn't a string is a programmer defect, not a provider error.
8
+ const decodeID = (token) => Schema.decodeUnknownEffect(Schema.String)(token).pipe(Effect.orDie);
9
+ export const layer = Layer.effect(Service, Effect.gen(function* () {
10
+ const executor = yield* RequestExecutor.Service;
11
+ const attach = (model, id) => model.route.attach(model, id, executor.execute);
12
+ return Service.of({
13
+ start: (request) => request.model.route.start(request, executor.execute).pipe(
14
+ // The token, not the snapshot id, is what `status` and `result` decode; `VideoModel.fromRoute` makes it a string.
15
+ Effect.flatMap((generation) => decodeID(generation.token)), Effect.map((id) => ({ id }))),
16
+ status: (model, id) => attach(model, id).pipe(Effect.flatMap((route) => route.status), Effect.map((snapshot) => ({ status: snapshot.status, reason: snapshot.reason, progress: snapshot.progress }))),
17
+ result: (model, id) => attach(model, id).pipe(Effect.flatMap((route) => route.result)),
18
+ cancel: (model, id) => attach(model, id).pipe(Effect.flatMap((route) => route.cancel ??
19
+ Effect.fail(new AIError({
20
+ reason: new UnsupportedOperationError({
21
+ operation: "video.cancel",
22
+ provider: model.provider,
23
+ route: model.route.id,
24
+ message: `${model.provider}/${model.route.id} has no way to cancel a video generation`,
25
+ }),
26
+ })))),
27
+ });
28
+ }));
7
29
  export const VideoClient = {
8
30
  Service,
9
- ...MediaClient.make(Service, {
10
- modality: "video",
11
- responseEvents: (response) => [
12
- ...response.videos.map((video, index) => VideoOutputEvent.make({ index, video })),
13
- VideoFinishEvent.make({
14
- usage: response.usage,
15
- providerMetadata: response.providerMetadata,
16
- }),
17
- ],
18
- }),
31
+ layer,
32
+ start: (request) => Service.use((client) => client.start(request)),
33
+ status: (model, id) => Service.use((client) => client.status(model, id)),
34
+ result: (model, id) => Service.use((client) => client.result(model, id)),
35
+ cancel: (model, id) => Service.use((client) => client.cancel(model, id)),
19
36
  };