@opencode/ai 2.2.5 → 2.2.6

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 (264) hide show
  1. package/README.md +133 -69
  2. package/dist/cache-policy.d.ts +1 -1
  3. package/dist/cache-policy.js +16 -4
  4. package/dist/decision-client.d.ts +3 -3
  5. package/dist/decision.d.ts +20 -125
  6. package/dist/decision.js +25 -15
  7. package/dist/effect.d.ts +4 -15
  8. package/dist/effect.js +2 -6
  9. package/dist/effort-updates.d.ts +3 -3
  10. package/dist/effort-updates.js +2 -2
  11. package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
  12. package/dist/experimental/cloudflare-run-extraction.js +4 -1
  13. package/dist/experimental/extraction.d.ts +10 -40
  14. package/dist/experimental/extraction.js +14 -13
  15. package/dist/experimental.d.ts +8 -8
  16. package/dist/experimental.js +4 -4
  17. package/dist/generation.d.ts +0 -2
  18. package/dist/generation.js +2 -2
  19. package/dist/image-client.d.ts +13 -7
  20. package/dist/image-client.js +1 -1
  21. package/dist/image.d.ts +357 -464
  22. package/dist/image.js +17 -15
  23. package/dist/index.d.ts +28 -465
  24. package/dist/index.js +18 -17
  25. package/dist/llm.d.ts +65 -266
  26. package/dist/llm.js +101 -92
  27. package/dist/loop.d.ts +38 -0
  28. package/dist/loop.js +136 -0
  29. package/dist/media-model.d.ts +1 -1
  30. package/dist/media-model.js +8 -6
  31. package/dist/media.d.ts +9 -0
  32. package/dist/media.js +37 -2
  33. package/dist/protocols/alibaba-chat.d.ts +5 -1
  34. package/dist/protocols/alibaba-chat.js +3 -3
  35. package/dist/protocols/alibaba-images.d.ts +2 -2
  36. package/dist/protocols/alibaba-messages.js +3 -3
  37. package/dist/protocols/alibaba-responses.js +8 -20
  38. package/dist/protocols/anthropic-messages.d.ts +1 -1
  39. package/dist/protocols/anthropic-messages.js +54 -173
  40. package/dist/protocols/assemblyai-transcription.d.ts +2 -2
  41. package/dist/protocols/bedrock-converse.js +10 -16
  42. package/dist/protocols/cartesia-speech.d.ts +2 -2
  43. package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
  44. package/dist/protocols/cohere-chat.js +9 -12
  45. package/dist/protocols/deepgram-speech.d.ts +2 -2
  46. package/dist/protocols/deepgram-transcription.d.ts +2 -2
  47. package/dist/protocols/elevenlabs-speech.d.ts +2 -2
  48. package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
  49. package/dist/protocols/gemini.d.ts +3 -0
  50. package/dist/protocols/gemini.js +54 -72
  51. package/dist/protocols/google-images.d.ts +2 -2
  52. package/dist/protocols/google-interactions.d.ts +3 -4
  53. package/dist/protocols/google-interactions.js +44 -30
  54. package/dist/protocols/google-speech.d.ts +2 -2
  55. package/dist/protocols/google-transcription.d.ts +2 -2
  56. package/dist/protocols/google-video.d.ts +2 -2
  57. package/dist/protocols/meta-images.d.ts +2 -2
  58. package/dist/protocols/meta-responses.js +26 -23
  59. package/dist/protocols/minimax-images.d.ts +2 -2
  60. package/dist/protocols/mistral-chat.js +7 -10
  61. package/dist/protocols/open-responses-channel.js +6 -19
  62. package/dist/protocols/open-responses-continuation.d.ts +1 -5
  63. package/dist/protocols/open-responses-continuation.js +1 -3
  64. package/dist/protocols/open-responses.d.ts +1 -21
  65. package/dist/protocols/open-responses.js +10 -15
  66. package/dist/protocols/openai-chat.d.ts +3 -23
  67. package/dist/protocols/openai-chat.js +26 -47
  68. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  69. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  70. package/dist/protocols/openai-compatible-responses.js +1 -1
  71. package/dist/protocols/openai-decisions.js +1 -1
  72. package/dist/protocols/openai-images.d.ts +2 -2
  73. package/dist/protocols/openai-responses.js +10 -29
  74. package/dist/protocols/openai-speech.d.ts +2 -2
  75. package/dist/protocols/openai-transcription.d.ts +2 -2
  76. package/dist/protocols/runway-video.d.ts +2 -2
  77. package/dist/protocols/shared.d.ts +1 -4
  78. package/dist/protocols/shared.js +13 -11
  79. package/dist/protocols/system-one.d.ts +4 -4
  80. package/dist/protocols/utils/bedrock-cache.js +2 -5
  81. package/dist/protocols/utils/bedrock-media.d.ts +0 -3
  82. package/dist/protocols/utils/cache.d.ts +3 -0
  83. package/dist/protocols/utils/cache.js +15 -2
  84. package/dist/protocols/utils/image-sizing.d.ts +1 -1
  85. package/dist/protocols/utils/responses-checkpoint.js +1 -1
  86. package/dist/protocols/utils/responses-compaction.d.ts +1 -1
  87. package/dist/protocols/utils/responses-compaction.js +6 -5
  88. package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
  89. package/dist/protocols/utils/responses-hosted-tools.js +31 -0
  90. package/dist/protocols/utils/tool-stream.d.ts +5 -271
  91. package/dist/protocols/utils/tool-stream.js +3 -13
  92. package/dist/protocols/venice-chat.d.ts +3 -1
  93. package/dist/protocols/venice-chat.js +4 -4
  94. package/dist/protocols/xai-images.d.ts +2 -2
  95. package/dist/protocols/xai-responses.js +5 -25
  96. package/dist/protocols/xai-video.d.ts +2 -2
  97. package/dist/protocols/zai-chat.d.ts +5 -1
  98. package/dist/protocols/zai-chat.js +1 -1
  99. package/dist/protocols/zai-images.d.ts +2 -2
  100. package/dist/protocols/zai-messages.js +3 -3
  101. package/dist/provider-error.d.ts +0 -1
  102. package/dist/provider-error.js +7 -80
  103. package/dist/providers/alibaba.d.ts +67 -4
  104. package/dist/providers/alibaba.js +6 -1
  105. package/dist/providers/amazon-bedrock-mantle.d.ts +6 -3
  106. package/dist/providers/amazon-bedrock-mantle.js +6 -3
  107. package/dist/providers/amazon-bedrock.d.ts +6 -7
  108. package/dist/providers/amazon-bedrock.js +1 -1
  109. package/dist/providers/anthropic-compatible.d.ts +7 -8
  110. package/dist/providers/anthropic-compatible.js +2 -5
  111. package/dist/providers/anthropic.d.ts +8 -9
  112. package/dist/providers/anthropic.js +2 -7
  113. package/dist/providers/assemblyai.d.ts +2 -2
  114. package/dist/providers/assemblyai.js +2 -7
  115. package/dist/providers/azure/messages.d.ts +2 -0
  116. package/dist/providers/azure/messages.js +1 -0
  117. package/dist/providers/azure.d.ts +322 -7
  118. package/dist/providers/azure.js +25 -9
  119. package/dist/providers/baseten.d.ts +5 -5
  120. package/dist/providers/baseten.js +7 -21
  121. package/dist/providers/cartesia.d.ts +1 -1
  122. package/dist/providers/cerebras.d.ts +5 -5
  123. package/dist/providers/cerebras.js +4 -15
  124. package/dist/providers/cloudflare-ai-gateway.d.ts +21 -13
  125. package/dist/providers/cloudflare-ai-gateway.js +28 -40
  126. package/dist/providers/cloudflare-shared.d.ts +9 -0
  127. package/dist/providers/cloudflare-shared.js +25 -0
  128. package/dist/providers/cloudflare-workers-ai.d.ts +4 -4
  129. package/dist/providers/cloudflare-workers-ai.js +4 -20
  130. package/dist/providers/cohere/chat.js +2 -7
  131. package/dist/providers/cohere.d.ts +6 -5
  132. package/dist/providers/cohere.js +7 -13
  133. package/dist/providers/deepgram.d.ts +2 -2
  134. package/dist/providers/deepgram.js +2 -7
  135. package/dist/providers/deepinfra.d.ts +5 -5
  136. package/dist/providers/deepinfra.js +5 -13
  137. package/dist/providers/deepseek.d.ts +5 -5
  138. package/dist/providers/deepseek.js +3 -14
  139. package/dist/providers/digitalocean.d.ts +8 -5
  140. package/dist/providers/digitalocean.js +13 -14
  141. package/dist/providers/elevenlabs.d.ts +2 -2
  142. package/dist/providers/elevenlabs.js +2 -7
  143. package/dist/providers/fireworks.d.ts +5 -5
  144. package/dist/providers/fireworks.js +4 -15
  145. package/dist/providers/google/interactions.d.ts +1 -1
  146. package/dist/providers/google/interactions.js +2 -7
  147. package/dist/providers/google-vertex-chat.d.ts +3 -3
  148. package/dist/providers/google-vertex-chat.js +3 -29
  149. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  150. package/dist/providers/google-vertex-messages.d.ts +3 -3
  151. package/dist/providers/google-vertex-messages.js +3 -29
  152. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  153. package/dist/providers/google-vertex-mistral.js +3 -29
  154. package/dist/providers/google-vertex-responses.d.ts +3 -3
  155. package/dist/providers/google-vertex-responses.js +4 -30
  156. package/dist/providers/google-vertex-shared.d.ts +31 -0
  157. package/dist/providers/google-vertex-shared.js +25 -0
  158. package/dist/providers/google-vertex.d.ts +3 -3
  159. package/dist/providers/google.d.ts +15 -13
  160. package/dist/providers/google.js +9 -19
  161. package/dist/providers/groq.d.ts +5 -5
  162. package/dist/providers/groq.js +4 -15
  163. package/dist/providers/meta.d.ts +5 -5
  164. package/dist/providers/meta.js +10 -23
  165. package/dist/providers/minimax/chat.js +2 -7
  166. package/dist/providers/minimax/responses.js +2 -7
  167. package/dist/providers/minimax.d.ts +5 -5
  168. package/dist/providers/minimax.js +7 -22
  169. package/dist/providers/mistral.d.ts +10 -11
  170. package/dist/providers/mistral.js +3 -14
  171. package/dist/providers/moonshot/messages.js +2 -7
  172. package/dist/providers/moonshot/responses.js +2 -7
  173. package/dist/providers/moonshot.d.ts +5 -5
  174. package/dist/providers/moonshot.js +4 -16
  175. package/dist/providers/openai-compatible-responses.d.ts +6 -7
  176. package/dist/providers/openai-compatible-responses.js +2 -8
  177. package/dist/providers/openai-compatible.d.ts +6 -7
  178. package/dist/providers/openai-compatible.js +4 -10
  179. package/dist/providers/openai.d.ts +4 -4
  180. package/dist/providers/openai.js +3 -3
  181. package/dist/providers/opencode.d.ts +4 -4
  182. package/dist/providers/opencode.js +6 -2
  183. package/dist/providers/openrouter.d.ts +8 -5
  184. package/dist/providers/openrouter.js +16 -24
  185. package/dist/providers/runway.d.ts +1 -1
  186. package/dist/providers/settings.d.ts +40 -0
  187. package/dist/providers/settings.js +19 -0
  188. package/dist/providers/togetherai.d.ts +5 -5
  189. package/dist/providers/togetherai.js +5 -15
  190. package/dist/providers/typesafe-ai.d.ts +4 -4
  191. package/dist/providers/typesafe-ai.js +6 -2
  192. package/dist/providers/venice.d.ts +4 -4
  193. package/dist/providers/venice.js +6 -2
  194. package/dist/providers/vercel-ai-gateway.d.ts +5 -5
  195. package/dist/providers/vercel-ai-gateway.js +15 -28
  196. package/dist/providers/xai.d.ts +4 -4
  197. package/dist/providers/xai.js +4 -12
  198. package/dist/providers/zai-coding-plan/messages.js +2 -7
  199. package/dist/providers/zai-coding-plan/responses.js +2 -7
  200. package/dist/providers/zai-coding-plan.d.ts +5 -5
  201. package/dist/providers/zai-coding-plan.js +8 -15
  202. package/dist/providers/zai.d.ts +5 -5
  203. package/dist/providers/zai.js +10 -22
  204. package/dist/public.d.ts +12 -0
  205. package/dist/public.js +5 -0
  206. package/dist/route/auth-options.d.ts +9 -5
  207. package/dist/route/auth-options.js +10 -7
  208. package/dist/route/client.d.ts +50 -37
  209. package/dist/route/client.js +42 -53
  210. package/dist/route/decision.d.ts +8 -8
  211. package/dist/route/decision.js +3 -3
  212. package/dist/route/executor.d.ts +5 -0
  213. package/dist/route/executor.js +10 -0
  214. package/dist/route/index.d.ts +5 -7
  215. package/dist/route/index.js +1 -1
  216. package/dist/route/media.d.ts +7 -11
  217. package/dist/route/media.js +22 -26
  218. package/dist/route/transport/http.js +6 -5
  219. package/dist/route/transport/websocket.js +7 -1
  220. package/dist/schema/errors.d.ts +16 -17
  221. package/dist/schema/errors.js +63 -12
  222. package/dist/schema/events.d.ts +2563 -2954
  223. package/dist/schema/events.js +54 -109
  224. package/dist/schema/messages.d.ts +194 -137
  225. package/dist/schema/messages.js +66 -83
  226. package/dist/schema/options.d.ts +112 -65
  227. package/dist/schema/options.js +52 -101
  228. package/dist/speech-client.d.ts +7 -7
  229. package/dist/speech.d.ts +306 -316
  230. package/dist/speech.js +16 -14
  231. package/dist/testing.d.ts +31 -175
  232. package/dist/testing.js +60 -5
  233. package/dist/tool-history.d.ts +1 -1
  234. package/dist/tool-history.js +3 -10
  235. package/dist/tool-runtime.d.ts +9 -2
  236. package/dist/tool-runtime.js +17 -31
  237. package/dist/tool.d.ts +39 -43
  238. package/dist/tool.js +16 -26
  239. package/dist/transcription-client.d.ts +7 -7
  240. package/dist/transcription.d.ts +314 -265
  241. package/dist/transcription.js +16 -14
  242. package/dist/utils/provider-codes.d.ts +3 -0
  243. package/dist/utils/provider-codes.js +41 -0
  244. package/dist/video-client.d.ts +7 -7
  245. package/dist/video-client.js +1 -1
  246. package/dist/video.d.ts +269 -287
  247. package/dist/video.js +16 -14
  248. package/package.json +9 -9
  249. package/dist/experimental/testing.d.ts +0 -3
  250. package/dist/experimental/testing.js +0 -3
  251. package/dist/testing/decision.d.ts +0 -16
  252. package/dist/testing/decision.js +0 -20
  253. package/dist/testing/image.d.ts +0 -14
  254. package/dist/testing/image.js +0 -12
  255. package/dist/testing/media.d.ts +0 -18
  256. package/dist/testing/media.js +0 -36
  257. package/dist/testing/script.d.ts +0 -28
  258. package/dist/testing/script.js +0 -60
  259. package/dist/testing/speech.d.ts +0 -14
  260. package/dist/testing/speech.js +0 -12
  261. package/dist/testing/transcription.d.ts +0 -14
  262. package/dist/testing/transcription.js +0 -12
  263. package/dist/testing/video.d.ts +0 -14
  264. package/dist/testing/video.js +0 -12
package/dist/video.d.ts CHANGED
@@ -3,16 +3,16 @@ import { Generation, type AwaitOptions } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
6
- import { AIError, HttpOptions, type OpenString } from "./schema/index.js";
6
+ import { AIError, type OpenString, type BaseRequest } from "./schema/index.js";
7
7
  import { Service } from "./video-client.js";
8
8
  export type VideoOptions = MediaModel.Options;
9
- export type VideoRoute = MediaRoute.AnyRoute<VideoRequestFor, VideoEvent, VideoResponse>;
9
+ export type VideoRoute = MediaRoute.AnyRoute<VideoRequest, VideoEvent, VideoResponse>;
10
10
  export declare class VideoModel<Options extends VideoOptions = VideoOptions> extends MediaModel<VideoRoute, Options> {
11
11
  protected readonly _VideoModel: void;
12
12
  /** The number of type arguments selects the kind: `<Options>`, `<Options, Frame, State>`, or `<Options, Token>`. */
13
- static fromRoute<Options extends VideoOptions>(route: MediaModel.InlineRouteInput<VideoRequestFor<Options>, VideoResponse>, input: MediaRoute.ModelInput): VideoModel<Options>;
14
- static fromRoute<Options extends VideoOptions, Frame, State>(route: MediaModel.StreamRouteInput<VideoRequestFor<Options>, VideoEvent, Frame, State>, input: MediaRoute.ModelInput): VideoModel<Options>;
15
- static fromRoute<Options extends VideoOptions, Token>(route: MediaModel.QueuedRouteInput<VideoRequestFor<Options>, VideoResponse, Token>, input: MediaRoute.ModelInput): VideoModel<Options>;
13
+ static fromRoute<Options extends VideoOptions>(route: MediaModel.InlineRouteInput<VideoRequest<VideoModel<Options>>, VideoResponse>, input: MediaRoute.ModelInput): VideoModel<Options>;
14
+ static fromRoute<Options extends VideoOptions, Frame, State>(route: MediaModel.StreamRouteInput<VideoRequest<VideoModel<Options>>, VideoEvent, Frame, State>, input: MediaRoute.ModelInput): VideoModel<Options>;
15
+ static fromRoute<Options extends VideoOptions, Token>(route: MediaModel.QueuedRouteInput<VideoRequest<VideoModel<Options>>, VideoResponse, Token>, input: MediaRoute.ModelInput): VideoModel<Options>;
16
16
  }
17
17
  export declare const VideoModelSchema: Schema.declare<VideoModel<{
18
18
  readonly [x: string]: unknown;
@@ -88,7 +88,7 @@ export declare const VideoFrames: Schema.Struct<{
88
88
  }>, never, never>>;
89
89
  }>;
90
90
  export type VideoFrames = Schema.Schema.Type<typeof VideoFrames>;
91
- declare const VideoRequest_base: Schema.Class<VideoRequest, Schema.Struct<{
91
+ declare const VideoRequestSchema: Schema.Struct<{
92
92
  readonly model: Schema.declare<VideoModel<{
93
93
  readonly [x: string]: unknown;
94
94
  }>, VideoModel<{
@@ -232,21 +232,15 @@ declare const VideoRequest_base: Schema.Class<VideoRequest, Schema.Struct<{
232
232
  readonly seed: Schema.optional<Schema.Number>;
233
233
  readonly negativePrompt: Schema.optional<Schema.String>;
234
234
  readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
235
- readonly http: Schema.optional<typeof HttpOptions>;
236
- }>, {}>;
237
- export declare class VideoRequest extends VideoRequest_base {
238
- protected readonly _VideoRequest: void;
239
- }
240
- export type VideoRequestFor<Options extends VideoOptions = VideoOptions> = Omit<VideoRequest, "model" | "providerOptions"> & {
241
- readonly model: VideoModel<Options>;
242
- readonly providerOptions?: Options;
235
+ }>;
236
+ /** A normalized video request, the plain object `Video.request(...)` returns. */
237
+ export type VideoRequest<Model extends VideoModel = VideoModel> = Omit<typeof VideoRequestSchema.Type, "model" | "providerOptions" | "resolution"> & BaseRequest<Model, VideoModelOptions<Model>> & {
238
+ readonly resolution?: VideoResolution;
243
239
  };
244
240
  export type VideoModelOptions<Model> = Model extends VideoModel<infer Options> ? Options : never;
245
- export type VideoRequestInput<Model extends VideoModel = VideoModel> = Omit<ConstructorParameters<typeof VideoRequest>[0], "model" | "providerOptions" | "http" | "resolution"> & {
246
- readonly model: Model;
247
- readonly resolution?: VideoResolution;
241
+ /** Input accepted by `Video.request` and the calls; a `VideoRequest` is also a valid input. */
242
+ export type VideoRequestInput<Model extends VideoModel = VideoModel> = Omit<VideoRequest<Model>, "providerOptions"> & {
248
243
  readonly providerOptions?: NoInfer<VideoModelOptions<Model>>;
249
- readonly http?: HttpOptions.Input;
250
244
  };
251
245
  declare const VideoResponse_base: Schema.Class<VideoResponse, Schema.Struct<{
252
246
  readonly videos: Schema.$Array<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
@@ -700,71 +694,76 @@ export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
700
694
  };
701
695
  };
702
696
  readonly match: {
703
- <Cases extends { [M in Schema.Struct<{
704
- readonly type: Schema.tag<"generation-queued">;
705
- readonly id: Schema.String;
706
- readonly position: Schema.optional<Schema.Number>;
707
- }> | Schema.Struct<{
708
- readonly type: Schema.tag<"generation-progress">;
709
- readonly id: Schema.String;
710
- readonly progress: Schema.optional<Schema.Number>;
711
- }> | Schema.Struct<{
712
- readonly type: Schema.tag<"video">;
713
- readonly index: Schema.Number;
714
- readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
715
- readonly source: Schema.Union<readonly [Schema.Struct<{
716
- readonly type: Schema.Literal<"bytes">;
717
- readonly data: Schema.Uint8Array;
718
- readonly mediaType: Schema.String;
697
+ <Handlers extends { [K in "finish" | "generation-progress" | "generation-queued" | "video"]: (value: {
698
+ readonly finish: Schema.Struct<{
699
+ readonly type: Schema.tag<"finish">;
700
+ readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
701
+ readonly type: Schema.Literal<"tokens">;
702
+ readonly input: Schema.optional<Schema.Number>;
703
+ readonly output: Schema.optional<Schema.Number>;
704
+ readonly total: Schema.optional<Schema.Number>;
705
+ readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
719
706
  }>, Schema.Struct<{
720
- readonly type: Schema.Literal<"base64">;
721
- readonly data: Schema.String;
722
- readonly mediaType: Schema.String;
707
+ readonly type: Schema.Literal<"seconds">;
708
+ readonly seconds: Schema.Number;
723
709
  }>, Schema.Struct<{
724
- readonly type: Schema.Literal<"url">;
725
- readonly url: Schema.String;
726
- readonly mediaType: Schema.optional<Schema.String>;
727
- readonly expiresAt: Schema.optional<Schema.Number>;
710
+ readonly type: Schema.Literal<"characters">;
711
+ readonly characters: Schema.Number;
728
712
  }>, Schema.Struct<{
729
- readonly type: Schema.Literal<"ref">;
730
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
731
- readonly id: Schema.String;
732
- readonly mediaType: Schema.optional<Schema.String>;
733
- }>]>;
734
- readonly info: Schema.optional<Schema.Struct<{
735
- readonly width: Schema.optional<Schema.Number>;
736
- readonly height: Schema.optional<Schema.Number>;
737
- readonly durationSeconds: Schema.optional<Schema.Number>;
738
- readonly sampleRate: Schema.optional<Schema.Number>;
739
- readonly channels: Schema.optional<Schema.Number>;
740
- readonly encoding: Schema.optional<Schema.String>;
741
- readonly format: Schema.optional<Schema.String>;
742
- }>>;
713
+ readonly type: Schema.Literal<"credits">;
714
+ readonly credits: Schema.Number;
715
+ }>, Schema.Struct<{
716
+ readonly type: Schema.Literal<"compute">;
717
+ readonly seconds: Schema.Number;
718
+ }>]>>;
743
719
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
744
- }>, never, never>;
745
- }> | Schema.Struct<{
746
- readonly type: Schema.tag<"finish">;
747
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
748
- readonly type: Schema.Literal<"tokens">;
749
- readonly input: Schema.optional<Schema.Number>;
750
- readonly output: Schema.optional<Schema.Number>;
751
- readonly total: Schema.optional<Schema.Number>;
752
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
753
- }>, Schema.Struct<{
754
- readonly type: Schema.Literal<"seconds">;
755
- readonly seconds: Schema.Number;
756
- }>, Schema.Struct<{
757
- readonly type: Schema.Literal<"characters">;
758
- readonly characters: Schema.Number;
759
- }>, Schema.Struct<{
760
- readonly type: Schema.Literal<"credits">;
761
- readonly credits: Schema.Number;
762
- }>, Schema.Struct<{
763
- readonly type: Schema.Literal<"compute">;
764
- readonly seconds: Schema.Number;
765
- }>]>>;
766
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
767
- }> as M["Type"]["type"]]: (value: M["Type"]) => any; }>(value: {
720
+ }>;
721
+ readonly "generation-progress": Schema.Struct<{
722
+ readonly type: Schema.tag<"generation-progress">;
723
+ readonly id: Schema.String;
724
+ readonly progress: Schema.optional<Schema.Number>;
725
+ }>;
726
+ readonly "generation-queued": Schema.Struct<{
727
+ readonly type: Schema.tag<"generation-queued">;
728
+ readonly id: Schema.String;
729
+ readonly position: Schema.optional<Schema.Number>;
730
+ }>;
731
+ readonly video: Schema.Struct<{
732
+ readonly type: Schema.tag<"video">;
733
+ readonly index: Schema.Number;
734
+ readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
735
+ readonly source: Schema.Union<readonly [Schema.Struct<{
736
+ readonly type: Schema.Literal<"bytes">;
737
+ readonly data: Schema.Uint8Array;
738
+ readonly mediaType: Schema.String;
739
+ }>, Schema.Struct<{
740
+ readonly type: Schema.Literal<"base64">;
741
+ readonly data: Schema.String;
742
+ readonly mediaType: Schema.String;
743
+ }>, Schema.Struct<{
744
+ readonly type: Schema.Literal<"url">;
745
+ readonly url: Schema.String;
746
+ readonly mediaType: Schema.optional<Schema.String>;
747
+ readonly expiresAt: Schema.optional<Schema.Number>;
748
+ }>, Schema.Struct<{
749
+ readonly type: Schema.Literal<"ref">;
750
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
751
+ readonly id: Schema.String;
752
+ readonly mediaType: Schema.optional<Schema.String>;
753
+ }>]>;
754
+ readonly info: Schema.optional<Schema.Struct<{
755
+ readonly width: Schema.optional<Schema.Number>;
756
+ readonly height: Schema.optional<Schema.Number>;
757
+ readonly durationSeconds: Schema.optional<Schema.Number>;
758
+ readonly sampleRate: Schema.optional<Schema.Number>;
759
+ readonly channels: Schema.optional<Schema.Number>;
760
+ readonly encoding: Schema.optional<Schema.String>;
761
+ readonly format: Schema.optional<Schema.String>;
762
+ }>>;
763
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
764
+ }>, never, never>;
765
+ }>;
766
+ }[K]["Type"]) => any; }>(value: {
768
767
  readonly type: "video";
769
768
  readonly index: number;
770
769
  readonly video: Media.Asset;
@@ -804,72 +803,77 @@ export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
804
803
  readonly [x: string]: unknown;
805
804
  };
806
805
  } | undefined;
807
- }, cases: Cases): Cases[keyof Cases] extends (value: any) => infer R ? import("effect/Unify").Unify<R> : never;
808
- <Cases extends { [M in Schema.Struct<{
809
- readonly type: Schema.tag<"generation-queued">;
810
- readonly id: Schema.String;
811
- readonly position: Schema.optional<Schema.Number>;
812
- }> | Schema.Struct<{
813
- readonly type: Schema.tag<"generation-progress">;
814
- readonly id: Schema.String;
815
- readonly progress: Schema.optional<Schema.Number>;
816
- }> | Schema.Struct<{
817
- readonly type: Schema.tag<"video">;
818
- readonly index: Schema.Number;
819
- readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
820
- readonly source: Schema.Union<readonly [Schema.Struct<{
821
- readonly type: Schema.Literal<"bytes">;
822
- readonly data: Schema.Uint8Array;
823
- readonly mediaType: Schema.String;
806
+ }, cases: Handlers): import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "generation-queued" | "video"]>>;
807
+ <Handlers extends { [K in "finish" | "generation-progress" | "generation-queued" | "video"]: (value: {
808
+ readonly finish: Schema.Struct<{
809
+ readonly type: Schema.tag<"finish">;
810
+ readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
811
+ readonly type: Schema.Literal<"tokens">;
812
+ readonly input: Schema.optional<Schema.Number>;
813
+ readonly output: Schema.optional<Schema.Number>;
814
+ readonly total: Schema.optional<Schema.Number>;
815
+ readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
824
816
  }>, Schema.Struct<{
825
- readonly type: Schema.Literal<"base64">;
826
- readonly data: Schema.String;
827
- readonly mediaType: Schema.String;
817
+ readonly type: Schema.Literal<"seconds">;
818
+ readonly seconds: Schema.Number;
828
819
  }>, Schema.Struct<{
829
- readonly type: Schema.Literal<"url">;
830
- readonly url: Schema.String;
831
- readonly mediaType: Schema.optional<Schema.String>;
832
- readonly expiresAt: Schema.optional<Schema.Number>;
820
+ readonly type: Schema.Literal<"characters">;
821
+ readonly characters: Schema.Number;
833
822
  }>, Schema.Struct<{
834
- readonly type: Schema.Literal<"ref">;
835
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
836
- readonly id: Schema.String;
837
- readonly mediaType: Schema.optional<Schema.String>;
838
- }>]>;
839
- readonly info: Schema.optional<Schema.Struct<{
840
- readonly width: Schema.optional<Schema.Number>;
841
- readonly height: Schema.optional<Schema.Number>;
842
- readonly durationSeconds: Schema.optional<Schema.Number>;
843
- readonly sampleRate: Schema.optional<Schema.Number>;
844
- readonly channels: Schema.optional<Schema.Number>;
845
- readonly encoding: Schema.optional<Schema.String>;
846
- readonly format: Schema.optional<Schema.String>;
847
- }>>;
823
+ readonly type: Schema.Literal<"credits">;
824
+ readonly credits: Schema.Number;
825
+ }>, Schema.Struct<{
826
+ readonly type: Schema.Literal<"compute">;
827
+ readonly seconds: Schema.Number;
828
+ }>]>>;
848
829
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
849
- }>, never, never>;
850
- }> | Schema.Struct<{
851
- readonly type: Schema.tag<"finish">;
852
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
853
- readonly type: Schema.Literal<"tokens">;
854
- readonly input: Schema.optional<Schema.Number>;
855
- readonly output: Schema.optional<Schema.Number>;
856
- readonly total: Schema.optional<Schema.Number>;
857
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
858
- }>, Schema.Struct<{
859
- readonly type: Schema.Literal<"seconds">;
860
- readonly seconds: Schema.Number;
861
- }>, Schema.Struct<{
862
- readonly type: Schema.Literal<"characters">;
863
- readonly characters: Schema.Number;
864
- }>, Schema.Struct<{
865
- readonly type: Schema.Literal<"credits">;
866
- readonly credits: Schema.Number;
867
- }>, Schema.Struct<{
868
- readonly type: Schema.Literal<"compute">;
869
- readonly seconds: Schema.Number;
870
- }>]>>;
871
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
872
- }> as M["Type"]["type"]]: (value: M["Type"]) => any; }>(cases: Cases): (value: {
830
+ }>;
831
+ readonly "generation-progress": Schema.Struct<{
832
+ readonly type: Schema.tag<"generation-progress">;
833
+ readonly id: Schema.String;
834
+ readonly progress: Schema.optional<Schema.Number>;
835
+ }>;
836
+ readonly "generation-queued": Schema.Struct<{
837
+ readonly type: Schema.tag<"generation-queued">;
838
+ readonly id: Schema.String;
839
+ readonly position: Schema.optional<Schema.Number>;
840
+ }>;
841
+ readonly video: Schema.Struct<{
842
+ readonly type: Schema.tag<"video">;
843
+ readonly index: Schema.Number;
844
+ readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
845
+ readonly source: Schema.Union<readonly [Schema.Struct<{
846
+ readonly type: Schema.Literal<"bytes">;
847
+ readonly data: Schema.Uint8Array;
848
+ readonly mediaType: Schema.String;
849
+ }>, Schema.Struct<{
850
+ readonly type: Schema.Literal<"base64">;
851
+ readonly data: Schema.String;
852
+ readonly mediaType: Schema.String;
853
+ }>, Schema.Struct<{
854
+ readonly type: Schema.Literal<"url">;
855
+ readonly url: Schema.String;
856
+ readonly mediaType: Schema.optional<Schema.String>;
857
+ readonly expiresAt: Schema.optional<Schema.Number>;
858
+ }>, Schema.Struct<{
859
+ readonly type: Schema.Literal<"ref">;
860
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
861
+ readonly id: Schema.String;
862
+ readonly mediaType: Schema.optional<Schema.String>;
863
+ }>]>;
864
+ readonly info: Schema.optional<Schema.Struct<{
865
+ readonly width: Schema.optional<Schema.Number>;
866
+ readonly height: Schema.optional<Schema.Number>;
867
+ readonly durationSeconds: Schema.optional<Schema.Number>;
868
+ readonly sampleRate: Schema.optional<Schema.Number>;
869
+ readonly channels: Schema.optional<Schema.Number>;
870
+ readonly encoding: Schema.optional<Schema.String>;
871
+ readonly format: Schema.optional<Schema.String>;
872
+ }>>;
873
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
874
+ }>, never, never>;
875
+ }>;
876
+ }[K]["Type"]) => any; }>(cases: Handlers): (value: {
873
877
  readonly type: "video";
874
878
  readonly index: number;
875
879
  readonly video: Media.Asset;
@@ -909,74 +913,10 @@ export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
909
913
  readonly [x: string]: unknown;
910
914
  };
911
915
  } | undefined;
912
- }) => Cases[keyof Cases] extends (value: any) => infer R ? import("effect/Unify").Unify<R> : never;
916
+ }) => import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "generation-queued" | "video"]>>;
913
917
  };
914
918
  readonly matchOrElse: {
915
- <Cases extends { [M in Schema.Struct<{
916
- readonly type: Schema.tag<"generation-queued">;
917
- readonly id: Schema.String;
918
- readonly position: Schema.optional<Schema.Number>;
919
- }> | Schema.Struct<{
920
- readonly type: Schema.tag<"generation-progress">;
921
- readonly id: Schema.String;
922
- readonly progress: Schema.optional<Schema.Number>;
923
- }> | Schema.Struct<{
924
- readonly type: Schema.tag<"video">;
925
- readonly index: Schema.Number;
926
- readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
927
- readonly source: Schema.Union<readonly [Schema.Struct<{
928
- readonly type: Schema.Literal<"bytes">;
929
- readonly data: Schema.Uint8Array;
930
- readonly mediaType: Schema.String;
931
- }>, Schema.Struct<{
932
- readonly type: Schema.Literal<"base64">;
933
- readonly data: Schema.String;
934
- readonly mediaType: Schema.String;
935
- }>, Schema.Struct<{
936
- readonly type: Schema.Literal<"url">;
937
- readonly url: Schema.String;
938
- readonly mediaType: Schema.optional<Schema.String>;
939
- readonly expiresAt: Schema.optional<Schema.Number>;
940
- }>, Schema.Struct<{
941
- readonly type: Schema.Literal<"ref">;
942
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
943
- readonly id: Schema.String;
944
- readonly mediaType: Schema.optional<Schema.String>;
945
- }>]>;
946
- readonly info: Schema.optional<Schema.Struct<{
947
- readonly width: Schema.optional<Schema.Number>;
948
- readonly height: Schema.optional<Schema.Number>;
949
- readonly durationSeconds: Schema.optional<Schema.Number>;
950
- readonly sampleRate: Schema.optional<Schema.Number>;
951
- readonly channels: Schema.optional<Schema.Number>;
952
- readonly encoding: Schema.optional<Schema.String>;
953
- readonly format: Schema.optional<Schema.String>;
954
- }>>;
955
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
956
- }>, never, never>;
957
- }> | Schema.Struct<{
958
- readonly type: Schema.tag<"finish">;
959
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
960
- readonly type: Schema.Literal<"tokens">;
961
- readonly input: Schema.optional<Schema.Number>;
962
- readonly output: Schema.optional<Schema.Number>;
963
- readonly total: Schema.optional<Schema.Number>;
964
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
965
- }>, Schema.Struct<{
966
- readonly type: Schema.Literal<"seconds">;
967
- readonly seconds: Schema.Number;
968
- }>, Schema.Struct<{
969
- readonly type: Schema.Literal<"characters">;
970
- readonly characters: Schema.Number;
971
- }>, Schema.Struct<{
972
- readonly type: Schema.Literal<"credits">;
973
- readonly credits: Schema.Number;
974
- }>, Schema.Struct<{
975
- readonly type: Schema.Literal<"compute">;
976
- readonly seconds: Schema.Number;
977
- }>]>>;
978
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
979
- }> as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "finish" | "generation-progress" | "generation-queued" | "video">]: never; }, OrElse extends (value: Exclude<{
919
+ <Handlers, OrElse>(value: {
980
920
  readonly type: "video";
981
921
  readonly index: number;
982
922
  readonly video: Media.Asset;
@@ -1016,19 +956,70 @@ export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
1016
956
  readonly [x: string]: unknown;
1017
957
  };
1018
958
  } | undefined;
1019
- }, { readonly [K in "type"]: keyof Cases; }>) => any>(value: {
959
+ }, cases: Handlers & {
960
+ readonly finish?: ((value: {
961
+ readonly type: "finish";
962
+ readonly usage?: {
963
+ readonly type: "seconds";
964
+ readonly seconds: number;
965
+ } | {
966
+ readonly type: "characters";
967
+ readonly characters: number;
968
+ } | {
969
+ readonly type: "credits";
970
+ readonly credits: number;
971
+ } | {
972
+ readonly type: "compute";
973
+ readonly seconds: number;
974
+ } | {
975
+ readonly type: "tokens";
976
+ readonly input?: number | undefined;
977
+ readonly output?: number | undefined;
978
+ readonly total?: number | undefined;
979
+ readonly details?: {
980
+ readonly [x: string]: unknown;
981
+ } | undefined;
982
+ } | undefined;
983
+ readonly providerMetadata?: {
984
+ readonly [x: string]: {
985
+ readonly [x: string]: unknown;
986
+ };
987
+ } | undefined;
988
+ }) => any) | undefined;
989
+ readonly "generation-progress"?: ((value: {
990
+ readonly type: "generation-progress";
991
+ readonly id: string;
992
+ readonly progress?: number | undefined;
993
+ }) => any) | undefined;
994
+ readonly "generation-queued"?: ((value: {
995
+ readonly type: "generation-queued";
996
+ readonly id: string;
997
+ readonly position?: number | undefined;
998
+ }) => any) | undefined;
999
+ readonly video?: ((value: {
1000
+ readonly type: "video";
1001
+ readonly index: number;
1002
+ readonly video: Media.Asset;
1003
+ }) => any) | undefined;
1004
+ } & (Exclude<keyof Handlers, "finish" | "generation-progress" | "generation-queued" | "video"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
1020
1005
  readonly type: "video";
1021
1006
  readonly index: number;
1022
1007
  readonly video: Media.Asset;
1023
- } | {
1008
+ }, {
1009
+ readonly type: keyof Handlers;
1010
+ }> | Exclude<{
1024
1011
  readonly type: "generation-queued";
1025
1012
  readonly id: string;
1026
1013
  readonly position?: number | undefined;
1027
- } | {
1014
+ }, {
1015
+ readonly type: keyof Handlers;
1016
+ }> | Exclude<{
1028
1017
  readonly type: "generation-progress";
1029
1018
  readonly id: string;
1030
1019
  readonly progress?: number | undefined;
1031
- } | {
1020
+ }, {
1021
+ readonly type: keyof Handlers;
1022
+ }> | Exclude<{
1032
1023
  readonly type: "finish";
1033
1024
  readonly usage?: {
1034
1025
  readonly type: "seconds";
@@ -1056,84 +1047,73 @@ export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
1056
1047
  readonly [x: string]: unknown;
1057
1048
  };
1058
1049
  } | undefined;
1059
- }, cases: Cases, orElse: OrElse): import("effect/Unify").Unify<{ [K in keyof Cases]-?: NonNullable<Cases[K]> extends (...args: Array<any>) => infer R ? R : never; }[keyof Cases] | ReturnType<OrElse>>;
1060
- <Cases extends { [M in Schema.Struct<{
1061
- readonly type: Schema.tag<"generation-queued">;
1062
- readonly id: Schema.String;
1063
- readonly position: Schema.optional<Schema.Number>;
1064
- }> | Schema.Struct<{
1065
- readonly type: Schema.tag<"generation-progress">;
1066
- readonly id: Schema.String;
1067
- readonly progress: Schema.optional<Schema.Number>;
1068
- }> | Schema.Struct<{
1069
- readonly type: Schema.tag<"video">;
1070
- readonly index: Schema.Number;
1071
- readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
1072
- readonly source: Schema.Union<readonly [Schema.Struct<{
1073
- readonly type: Schema.Literal<"bytes">;
1074
- readonly data: Schema.Uint8Array;
1075
- readonly mediaType: Schema.String;
1076
- }>, Schema.Struct<{
1077
- readonly type: Schema.Literal<"base64">;
1078
- readonly data: Schema.String;
1079
- readonly mediaType: Schema.String;
1080
- }>, Schema.Struct<{
1081
- readonly type: Schema.Literal<"url">;
1082
- readonly url: Schema.String;
1083
- readonly mediaType: Schema.optional<Schema.String>;
1084
- readonly expiresAt: Schema.optional<Schema.Number>;
1085
- }>, Schema.Struct<{
1086
- readonly type: Schema.Literal<"ref">;
1087
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
1088
- readonly id: Schema.String;
1089
- readonly mediaType: Schema.optional<Schema.String>;
1090
- }>]>;
1091
- readonly info: Schema.optional<Schema.Struct<{
1092
- readonly width: Schema.optional<Schema.Number>;
1093
- readonly height: Schema.optional<Schema.Number>;
1094
- readonly durationSeconds: Schema.optional<Schema.Number>;
1095
- readonly sampleRate: Schema.optional<Schema.Number>;
1096
- readonly channels: Schema.optional<Schema.Number>;
1097
- readonly encoding: Schema.optional<Schema.String>;
1098
- readonly format: Schema.optional<Schema.String>;
1099
- }>>;
1100
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1101
- }>, never, never>;
1102
- }> | Schema.Struct<{
1103
- readonly type: Schema.tag<"finish">;
1104
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
1105
- readonly type: Schema.Literal<"tokens">;
1106
- readonly input: Schema.optional<Schema.Number>;
1107
- readonly output: Schema.optional<Schema.Number>;
1108
- readonly total: Schema.optional<Schema.Number>;
1109
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
1110
- }>, Schema.Struct<{
1111
- readonly type: Schema.Literal<"seconds">;
1112
- readonly seconds: Schema.Number;
1113
- }>, Schema.Struct<{
1114
- readonly type: Schema.Literal<"characters">;
1115
- readonly characters: Schema.Number;
1116
- }>, Schema.Struct<{
1117
- readonly type: Schema.Literal<"credits">;
1118
- readonly credits: Schema.Number;
1119
- }>, Schema.Struct<{
1120
- readonly type: Schema.Literal<"compute">;
1121
- readonly seconds: Schema.Number;
1122
- }>]>>;
1123
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1124
- }> as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "finish" | "generation-progress" | "generation-queued" | "video">]: never; }, OrElse extends (value: Exclude<{
1050
+ }, {
1051
+ readonly type: keyof Handlers;
1052
+ }>) => any)): import("effect/Unify").Unify<{ [K in keyof Handlers]-?: NonNullable<Handlers[K]> extends (...args: Array<any>) => infer R ? R : never; }[keyof Handlers] | (OrElse extends (...args: Array<any>) => infer R ? R : never)>;
1053
+ <Handlers, OrElse>(cases: Handlers & {
1054
+ readonly finish?: ((value: {
1055
+ readonly type: "finish";
1056
+ readonly usage?: {
1057
+ readonly type: "seconds";
1058
+ readonly seconds: number;
1059
+ } | {
1060
+ readonly type: "characters";
1061
+ readonly characters: number;
1062
+ } | {
1063
+ readonly type: "credits";
1064
+ readonly credits: number;
1065
+ } | {
1066
+ readonly type: "compute";
1067
+ readonly seconds: number;
1068
+ } | {
1069
+ readonly type: "tokens";
1070
+ readonly input?: number | undefined;
1071
+ readonly output?: number | undefined;
1072
+ readonly total?: number | undefined;
1073
+ readonly details?: {
1074
+ readonly [x: string]: unknown;
1075
+ } | undefined;
1076
+ } | undefined;
1077
+ readonly providerMetadata?: {
1078
+ readonly [x: string]: {
1079
+ readonly [x: string]: unknown;
1080
+ };
1081
+ } | undefined;
1082
+ }) => any) | undefined;
1083
+ readonly "generation-progress"?: ((value: {
1084
+ readonly type: "generation-progress";
1085
+ readonly id: string;
1086
+ readonly progress?: number | undefined;
1087
+ }) => 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
+ readonly video?: ((value: {
1094
+ readonly type: "video";
1095
+ readonly index: number;
1096
+ readonly video: Media.Asset;
1097
+ }) => any) | undefined;
1098
+ } & (Exclude<keyof Handlers, "finish" | "generation-progress" | "generation-queued" | "video"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
1125
1099
  readonly type: "video";
1126
1100
  readonly index: number;
1127
1101
  readonly video: Media.Asset;
1128
- } | {
1102
+ }, {
1103
+ readonly type: keyof Handlers;
1104
+ }> | Exclude<{
1129
1105
  readonly type: "generation-queued";
1130
1106
  readonly id: string;
1131
1107
  readonly position?: number | undefined;
1132
- } | {
1108
+ }, {
1109
+ readonly type: keyof Handlers;
1110
+ }> | Exclude<{
1133
1111
  readonly type: "generation-progress";
1134
1112
  readonly id: string;
1135
1113
  readonly progress?: number | undefined;
1136
- } | {
1114
+ }, {
1115
+ readonly type: keyof Handlers;
1116
+ }> | Exclude<{
1137
1117
  readonly type: "finish";
1138
1118
  readonly usage?: {
1139
1119
  readonly type: "seconds";
@@ -1161,7 +1141,9 @@ export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
1161
1141
  readonly [x: string]: unknown;
1162
1142
  };
1163
1143
  } | undefined;
1164
- }, { readonly [K in "type"]: keyof Cases; }>) => any>(cases: Cases, orElse: OrElse): (value: {
1144
+ }, {
1145
+ readonly type: keyof Handlers;
1146
+ }>) => any)): (value: {
1165
1147
  readonly type: "video";
1166
1148
  readonly index: number;
1167
1149
  readonly video: Media.Asset;
@@ -1201,7 +1183,7 @@ export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
1201
1183
  readonly [x: string]: unknown;
1202
1184
  };
1203
1185
  } | undefined;
1204
- }) => import("effect/Unify").Unify<{ [K in keyof Cases]-?: NonNullable<Cases[K]> extends (...args: Array<any>) => infer R ? R : never; }[keyof Cases] | ReturnType<OrElse>>;
1186
+ }) => import("effect/Unify").Unify<{ [K in keyof Handlers]-?: NonNullable<Handlers[K]> extends (...args: Array<any>) => infer R ? R : never; }[keyof Handlers] | (OrElse extends (...args: Array<any>) => infer R ? R : never)>;
1205
1187
  };
1206
1188
  } & {
1207
1189
  is: {
@@ -1252,13 +1234,13 @@ export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
1252
1234
  };
1253
1235
  };
1254
1236
  export type VideoEvent = Schema.Schema.Type<typeof videoEventTagged>;
1255
- export declare function request<const Model extends VideoModel>(input: VideoRequestInput<Model>): VideoRequestFor<VideoModelOptions<Model>>;
1256
- export declare function request(input: VideoRequest): VideoRequest;
1257
- export declare function start<const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>): Effect.Effect<Generation<VideoResponse>, AIError, Service>;
1258
- export declare function generate<const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: AwaitOptions): Effect.Effect<VideoResponse, AIError, Service>;
1237
+ /** Normalize video request input into a plain `VideoRequest`. */
1238
+ export declare const request: <const Model extends VideoModel>(input: VideoRequestInput<Model>) => VideoRequest<Model>;
1239
+ export declare function start<const Model extends VideoModel>(input: VideoRequestInput<Model>): Effect.Effect<Generation<VideoResponse>, AIError, Service>;
1240
+ export declare function generate<const Model extends VideoModel>(input: VideoRequestInput<Model>, options?: AwaitOptions): Effect.Effect<VideoResponse, AIError, Service>;
1259
1241
  /** Rebuild a generation handle from a persisted `Generation.token`, refreshing its status once. */
1260
1242
  export declare const resume: (model: VideoModel, token: unknown) => Effect.Effect<Generation<VideoResponse>, AIError, Service>;
1261
- export declare function stream<const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: AwaitOptions): Stream.Stream<VideoEvent, AIError, Service>;
1243
+ export declare function stream<const Model extends VideoModel>(input: VideoRequestInput<Model>, options?: AwaitOptions): Stream.Stream<VideoEvent, AIError, Service>;
1262
1244
  export declare const Video: {
1263
1245
  readonly request: typeof request;
1264
1246
  readonly start: typeof start;