@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
package/dist/video.d.ts CHANGED
@@ -1,93 +1,31 @@
1
- import { Effect, Schema, Stream } from "effect";
2
- import { Generation, type AwaitOptions } from "./generation.js";
1
+ import { Effect, Schema } from "effect";
2
+ import type { Reason, Status } 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
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<VideoRequest, VideoEvent, VideoResponse>;
9
+ /** Video generation is always a queued job: submit, then read its status and result by the provider's job ID. */
10
+ export type VideoRoute = MediaRoute.QueuedRoute<VideoRequest, VideoResponse>;
10
11
  export declare class VideoModel<Options extends VideoOptions = VideoOptions> extends MediaModel<VideoRoute, Options> {
11
12
  protected readonly _VideoModel: void;
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<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>;
13
+ /** A video route's token is the provider's job ID, so `VideoJob.id` is exactly what `status` and `result` take. */
14
+ static fromRoute<Options extends VideoOptions>(route: MediaModel.QueuedRouteInput<VideoRequest<VideoModel<Options>>, VideoResponse, string>, input: MediaRoute.ModelInput): VideoModel<Options>;
16
15
  }
17
16
  export declare const VideoModelSchema: Schema.declare<VideoModel<{
18
17
  readonly [x: string]: unknown;
19
18
  }>, VideoModel<{
20
19
  readonly [x: string]: unknown;
21
20
  }>>;
22
- export type VideoAspectRatio = Media.AspectRatio;
23
- export declare const VideoAspectRatio: Schema.declare<`${number}:${number}`, `${number}:${number}`>;
21
+ /** A `width:height` ratio, or `auto` to follow the input image. */
22
+ export type VideoAspectRatio = Media.AspectRatio | "auto";
23
+ export declare const VideoAspectRatio: Schema.Union<readonly [Schema.declare<`${number}:${number}`, `${number}:${number}`>, Schema.Literal<"auto">]>;
24
+ /** Common output resolutions; protocols convert them to their provider's spelling and pass other values through. */
24
25
  export type VideoResolution = OpenString<"480p" | "720p" | "1080p" | "4k">;
25
- /** Pinned frames. Routes that accept only a first frame fail typed when `last` is present. */
26
- export declare const VideoFrames: Schema.Struct<{
27
- readonly first: Schema.optional<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
28
- readonly source: Schema.Union<readonly [Schema.Struct<{
29
- readonly type: Schema.Literal<"bytes">;
30
- readonly data: Schema.Uint8Array;
31
- readonly mediaType: Schema.String;
32
- }>, Schema.Struct<{
33
- readonly type: Schema.Literal<"base64">;
34
- readonly data: Schema.String;
35
- readonly mediaType: Schema.String;
36
- }>, Schema.Struct<{
37
- readonly type: Schema.Literal<"url">;
38
- readonly url: Schema.String;
39
- readonly mediaType: Schema.optional<Schema.String>;
40
- readonly expiresAt: Schema.optional<Schema.Number>;
41
- }>, Schema.Struct<{
42
- readonly type: Schema.Literal<"ref">;
43
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
44
- readonly id: Schema.String;
45
- readonly mediaType: Schema.optional<Schema.String>;
46
- }>]>;
47
- readonly info: Schema.optional<Schema.Struct<{
48
- readonly width: Schema.optional<Schema.Number>;
49
- readonly height: Schema.optional<Schema.Number>;
50
- readonly durationSeconds: Schema.optional<Schema.Number>;
51
- readonly sampleRate: Schema.optional<Schema.Number>;
52
- readonly channels: Schema.optional<Schema.Number>;
53
- readonly encoding: Schema.optional<Schema.String>;
54
- readonly format: Schema.optional<Schema.String>;
55
- }>>;
56
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
57
- }>, never, never>>;
58
- readonly last: Schema.optional<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
59
- readonly source: Schema.Union<readonly [Schema.Struct<{
60
- readonly type: Schema.Literal<"bytes">;
61
- readonly data: Schema.Uint8Array;
62
- readonly mediaType: Schema.String;
63
- }>, Schema.Struct<{
64
- readonly type: Schema.Literal<"base64">;
65
- readonly data: Schema.String;
66
- readonly mediaType: Schema.String;
67
- }>, Schema.Struct<{
68
- readonly type: Schema.Literal<"url">;
69
- readonly url: Schema.String;
70
- readonly mediaType: Schema.optional<Schema.String>;
71
- readonly expiresAt: Schema.optional<Schema.Number>;
72
- }>, Schema.Struct<{
73
- readonly type: Schema.Literal<"ref">;
74
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
75
- readonly id: Schema.String;
76
- readonly mediaType: Schema.optional<Schema.String>;
77
- }>]>;
78
- readonly info: Schema.optional<Schema.Struct<{
79
- readonly width: Schema.optional<Schema.Number>;
80
- readonly height: Schema.optional<Schema.Number>;
81
- readonly durationSeconds: Schema.optional<Schema.Number>;
82
- readonly sampleRate: Schema.optional<Schema.Number>;
83
- readonly channels: Schema.optional<Schema.Number>;
84
- readonly encoding: Schema.optional<Schema.String>;
85
- readonly format: Schema.optional<Schema.String>;
86
- }>>;
87
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
88
- }>, never, never>>;
89
- }>;
90
- export type VideoFrames = Schema.Schema.Type<typeof VideoFrames>;
26
+ /** Output length as an Effect duration string in seconds, such as `"8 seconds"`. */
27
+ export type VideoDuration = `${number} second` | `${number} seconds`;
28
+ export declare const VideoDuration: Schema.declare<VideoDuration, VideoDuration>;
91
29
  declare const VideoRequestSchema: Schema.Struct<{
92
30
  readonly model: Schema.declare<VideoModel<{
93
31
  readonly [x: string]: unknown;
@@ -95,71 +33,11 @@ declare const VideoRequestSchema: Schema.Struct<{
95
33
  readonly [x: string]: unknown;
96
34
  }>>;
97
35
  readonly prompt: Schema.String;
98
- readonly frames: Schema.optional<Schema.Struct<{
99
- readonly first: Schema.optional<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
100
- readonly source: Schema.Union<readonly [Schema.Struct<{
101
- readonly type: Schema.Literal<"bytes">;
102
- readonly data: Schema.Uint8Array;
103
- readonly mediaType: Schema.String;
104
- }>, Schema.Struct<{
105
- readonly type: Schema.Literal<"base64">;
106
- readonly data: Schema.String;
107
- readonly mediaType: Schema.String;
108
- }>, Schema.Struct<{
109
- readonly type: Schema.Literal<"url">;
110
- readonly url: Schema.String;
111
- readonly mediaType: Schema.optional<Schema.String>;
112
- readonly expiresAt: Schema.optional<Schema.Number>;
113
- }>, Schema.Struct<{
114
- readonly type: Schema.Literal<"ref">;
115
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
116
- readonly id: Schema.String;
117
- readonly mediaType: Schema.optional<Schema.String>;
118
- }>]>;
119
- readonly info: Schema.optional<Schema.Struct<{
120
- readonly width: Schema.optional<Schema.Number>;
121
- readonly height: Schema.optional<Schema.Number>;
122
- readonly durationSeconds: Schema.optional<Schema.Number>;
123
- readonly sampleRate: Schema.optional<Schema.Number>;
124
- readonly channels: Schema.optional<Schema.Number>;
125
- readonly encoding: Schema.optional<Schema.String>;
126
- readonly format: Schema.optional<Schema.String>;
127
- }>>;
128
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
129
- }>, never, never>>;
130
- readonly last: Schema.optional<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
131
- readonly source: Schema.Union<readonly [Schema.Struct<{
132
- readonly type: Schema.Literal<"bytes">;
133
- readonly data: Schema.Uint8Array;
134
- readonly mediaType: Schema.String;
135
- }>, Schema.Struct<{
136
- readonly type: Schema.Literal<"base64">;
137
- readonly data: Schema.String;
138
- readonly mediaType: Schema.String;
139
- }>, Schema.Struct<{
140
- readonly type: Schema.Literal<"url">;
141
- readonly url: Schema.String;
142
- readonly mediaType: Schema.optional<Schema.String>;
143
- readonly expiresAt: Schema.optional<Schema.Number>;
144
- }>, Schema.Struct<{
145
- readonly type: Schema.Literal<"ref">;
146
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
147
- readonly id: Schema.String;
148
- readonly mediaType: Schema.optional<Schema.String>;
149
- }>]>;
150
- readonly info: Schema.optional<Schema.Struct<{
151
- readonly width: Schema.optional<Schema.Number>;
152
- readonly height: Schema.optional<Schema.Number>;
153
- readonly durationSeconds: Schema.optional<Schema.Number>;
154
- readonly sampleRate: Schema.optional<Schema.Number>;
155
- readonly channels: Schema.optional<Schema.Number>;
156
- readonly encoding: Schema.optional<Schema.String>;
157
- readonly format: Schema.optional<Schema.String>;
158
- }>>;
159
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
160
- }>, never, never>>;
161
- }>>;
162
- /** Style or subject references that guide the output without pinning a frame. */
36
+ /** Image the video starts on exactly. */
37
+ readonly start: Schema.optional<Schema.brand<Schema.declare<Media.Asset, Media.Asset>, "Media.ImageAsset">>;
38
+ /** Image the video ends on exactly. */
39
+ readonly end: Schema.optional<Schema.brand<Schema.declare<Media.Asset, Media.Asset>, "Media.ImageAsset">>;
40
+ /** Images, videos or audio that guide the subject or style without pinning a frame. */
163
41
  readonly references: Schema.optional<Schema.$Array<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
164
42
  readonly source: Schema.Union<readonly [Schema.Struct<{
165
43
  readonly type: Schema.Literal<"bytes">;
@@ -191,57 +69,40 @@ declare const VideoRequestSchema: Schema.Struct<{
191
69
  }>>;
192
70
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
193
71
  }>, never, never>>>;
194
- /** Source video for edit or extension routes. */
195
- readonly video: Schema.optional<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
196
- readonly source: Schema.Union<readonly [Schema.Struct<{
197
- readonly type: Schema.Literal<"bytes">;
198
- readonly data: Schema.Uint8Array;
199
- readonly mediaType: Schema.String;
200
- }>, Schema.Struct<{
201
- readonly type: Schema.Literal<"base64">;
202
- readonly data: Schema.String;
203
- readonly mediaType: Schema.String;
204
- }>, Schema.Struct<{
205
- readonly type: Schema.Literal<"url">;
206
- readonly url: Schema.String;
207
- readonly mediaType: Schema.optional<Schema.String>;
208
- readonly expiresAt: Schema.optional<Schema.Number>;
209
- }>, Schema.Struct<{
210
- readonly type: Schema.Literal<"ref">;
211
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
212
- readonly id: Schema.String;
213
- readonly mediaType: Schema.optional<Schema.String>;
214
- }>]>;
215
- readonly info: Schema.optional<Schema.Struct<{
216
- readonly width: Schema.optional<Schema.Number>;
217
- readonly height: Schema.optional<Schema.Number>;
218
- readonly durationSeconds: Schema.optional<Schema.Number>;
219
- readonly sampleRate: Schema.optional<Schema.Number>;
220
- readonly channels: Schema.optional<Schema.Number>;
221
- readonly encoding: Schema.optional<Schema.String>;
222
- readonly format: Schema.optional<Schema.String>;
223
- }>>;
224
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
225
- }>, never, never>>;
226
- readonly durationSeconds: Schema.optional<Schema.Number>;
227
- readonly aspect: Schema.optional<Schema.declare<`${number}:${number}`, `${number}:${number}`>>;
72
+ readonly duration: Schema.optional<Schema.declare<VideoDuration, VideoDuration>>;
73
+ readonly aspect: Schema.optional<Schema.Union<readonly [Schema.declare<`${number}:${number}`, `${number}:${number}`>, Schema.Literal<"auto">]>>;
228
74
  readonly resolution: Schema.optional<Schema.String>;
229
- /** Whether to generate an audio track; routes whose audio is always on fail typed on `false`. */
230
- readonly audio: Schema.optional<Schema.Boolean>;
231
- readonly n: Schema.optional<Schema.Int>;
232
- readonly seed: Schema.optional<Schema.Number>;
233
- readonly negativePrompt: Schema.optional<Schema.String>;
75
+ /** Whether the video has a generated soundtrack; unset leaves the model's default. */
76
+ readonly sound: Schema.optional<Schema.Boolean>;
234
77
  readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
235
78
  }>;
236
- /** A normalized video request, the plain object `Video.request(...)` returns. */
79
+ /** A normalized video request, the plain object `ai.video.request(...)` returns. */
237
80
  export type VideoRequest<Model extends VideoModel = VideoModel> = Omit<typeof VideoRequestSchema.Type, "model" | "providerOptions" | "resolution"> & BaseRequest<Model, VideoModelOptions<Model>> & {
238
81
  readonly resolution?: VideoResolution;
239
82
  };
240
83
  export type VideoModelOptions<Model> = Model extends VideoModel<infer Options> ? Options : never;
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"> & {
84
+ /** Input accepted by `ai.video.request` and `ai.video.start`; a `VideoRequest` is also a valid input. */
85
+ export type VideoRequestInput<Model extends VideoModel = VideoModel> = Omit<VideoRequest<Model>, "start" | "end" | "references" | "providerOptions"> & {
86
+ /** An image: `Media.image(...)`, or a URL, data URL, base64 string or bytes, which must not be a known non-image. */
87
+ readonly start?: Media.ImageAsset | Media.Data;
88
+ readonly end?: Media.ImageAsset | Media.Data;
89
+ readonly references?: ReadonlyArray<Media.Input>;
243
90
  readonly providerOptions?: NoInfer<VideoModelOptions<Model>>;
244
91
  };
92
+ /** Seconds in a request's `duration`, for protocols that send a number. */
93
+ export declare const seconds: (duration: VideoDuration) => number;
94
+ /** A submitted generation. Store `id` with the model to read the job later, from any process. */
95
+ export interface VideoJob {
96
+ /** The provider's job ID. */
97
+ readonly id: string;
98
+ }
99
+ export interface VideoStatus {
100
+ readonly status: Status;
101
+ /** Set when `status` is `error`. */
102
+ readonly reason?: Reason;
103
+ /** 0..1, only when the provider reports progress. */
104
+ readonly progress?: number;
105
+ }
245
106
  declare const VideoResponse_base: Schema.Class<VideoResponse, Schema.Struct<{
246
107
  readonly videos: Schema.$Array<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
247
108
  readonly source: Schema.Union<readonly [Schema.Struct<{
@@ -298,954 +159,21 @@ declare const VideoResponse_base: Schema.Class<VideoResponse, Schema.Struct<{
298
159
  export declare class VideoResponse extends VideoResponse_base {
299
160
  get video(): Media.Asset;
300
161
  }
301
- export declare const VideoOutputEvent: Schema.Struct<{
302
- readonly type: Schema.tag<"video">;
303
- readonly index: Schema.Number;
304
- readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
305
- readonly source: Schema.Union<readonly [Schema.Struct<{
306
- readonly type: Schema.Literal<"bytes">;
307
- readonly data: Schema.Uint8Array;
308
- readonly mediaType: Schema.String;
309
- }>, Schema.Struct<{
310
- readonly type: Schema.Literal<"base64">;
311
- readonly data: Schema.String;
312
- readonly mediaType: Schema.String;
313
- }>, Schema.Struct<{
314
- readonly type: Schema.Literal<"url">;
315
- readonly url: Schema.String;
316
- readonly mediaType: Schema.optional<Schema.String>;
317
- readonly expiresAt: Schema.optional<Schema.Number>;
318
- }>, Schema.Struct<{
319
- readonly type: Schema.Literal<"ref">;
320
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
321
- readonly id: Schema.String;
322
- readonly mediaType: Schema.optional<Schema.String>;
323
- }>]>;
324
- readonly info: Schema.optional<Schema.Struct<{
325
- readonly width: Schema.optional<Schema.Number>;
326
- readonly height: Schema.optional<Schema.Number>;
327
- readonly durationSeconds: Schema.optional<Schema.Number>;
328
- readonly sampleRate: Schema.optional<Schema.Number>;
329
- readonly channels: Schema.optional<Schema.Number>;
330
- readonly encoding: Schema.optional<Schema.String>;
331
- readonly format: Schema.optional<Schema.String>;
332
- }>>;
333
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
334
- }>, never, never>;
335
- }>;
336
- export declare const VideoFinishEvent: Schema.Struct<{
337
- readonly type: Schema.tag<"finish">;
338
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
339
- readonly type: Schema.Literal<"tokens">;
340
- readonly input: Schema.optional<Schema.Number>;
341
- readonly output: Schema.optional<Schema.Number>;
342
- readonly total: Schema.optional<Schema.Number>;
343
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
344
- }>, Schema.Struct<{
345
- readonly type: Schema.Literal<"seconds">;
346
- readonly seconds: Schema.Number;
347
- }>, Schema.Struct<{
348
- readonly type: Schema.Literal<"characters">;
349
- readonly characters: Schema.Number;
350
- }>, Schema.Struct<{
351
- readonly type: Schema.Literal<"credits">;
352
- readonly credits: Schema.Number;
353
- }>, Schema.Struct<{
354
- readonly type: Schema.Literal<"compute">;
355
- readonly seconds: Schema.Number;
356
- }>]>>;
357
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
358
- }>;
359
- declare const videoEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
360
- readonly type: Schema.tag<"generation-queued">;
361
- readonly id: Schema.String;
362
- readonly position: Schema.optional<Schema.Number>;
363
- }>, Schema.Struct<{
364
- readonly type: Schema.tag<"generation-progress">;
365
- readonly id: Schema.String;
366
- readonly progress: Schema.optional<Schema.Number>;
367
- }>, Schema.Struct<{
368
- readonly type: Schema.tag<"video">;
369
- readonly index: Schema.Number;
370
- readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
371
- readonly source: Schema.Union<readonly [Schema.Struct<{
372
- readonly type: Schema.Literal<"bytes">;
373
- readonly data: Schema.Uint8Array;
374
- readonly mediaType: Schema.String;
375
- }>, Schema.Struct<{
376
- readonly type: Schema.Literal<"base64">;
377
- readonly data: Schema.String;
378
- readonly mediaType: Schema.String;
379
- }>, Schema.Struct<{
380
- readonly type: Schema.Literal<"url">;
381
- readonly url: Schema.String;
382
- readonly mediaType: Schema.optional<Schema.String>;
383
- readonly expiresAt: Schema.optional<Schema.Number>;
384
- }>, Schema.Struct<{
385
- readonly type: Schema.Literal<"ref">;
386
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
387
- readonly id: Schema.String;
388
- readonly mediaType: Schema.optional<Schema.String>;
389
- }>]>;
390
- readonly info: Schema.optional<Schema.Struct<{
391
- readonly width: Schema.optional<Schema.Number>;
392
- readonly height: Schema.optional<Schema.Number>;
393
- readonly durationSeconds: Schema.optional<Schema.Number>;
394
- readonly sampleRate: Schema.optional<Schema.Number>;
395
- readonly channels: Schema.optional<Schema.Number>;
396
- readonly encoding: Schema.optional<Schema.String>;
397
- readonly format: Schema.optional<Schema.String>;
398
- }>>;
399
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
400
- }>, never, never>;
401
- }>, Schema.Struct<{
402
- readonly type: Schema.tag<"finish">;
403
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
404
- readonly type: Schema.Literal<"tokens">;
405
- readonly input: Schema.optional<Schema.Number>;
406
- readonly output: Schema.optional<Schema.Number>;
407
- readonly total: Schema.optional<Schema.Number>;
408
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
409
- }>, Schema.Struct<{
410
- readonly type: Schema.Literal<"seconds">;
411
- readonly seconds: Schema.Number;
412
- }>, Schema.Struct<{
413
- readonly type: Schema.Literal<"characters">;
414
- readonly characters: Schema.Number;
415
- }>, Schema.Struct<{
416
- readonly type: Schema.Literal<"credits">;
417
- readonly credits: Schema.Number;
418
- }>, Schema.Struct<{
419
- readonly type: Schema.Literal<"compute">;
420
- readonly seconds: Schema.Number;
421
- }>]>>;
422
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
423
- }>]>;
424
- export declare const VideoEvent: Schema.Union<readonly [Schema.Struct<{
425
- readonly type: Schema.tag<"generation-queued">;
426
- readonly id: Schema.String;
427
- readonly position: Schema.optional<Schema.Number>;
428
- }>, Schema.Struct<{
429
- readonly type: Schema.tag<"generation-progress">;
430
- readonly id: Schema.String;
431
- readonly progress: Schema.optional<Schema.Number>;
432
- }>, Schema.Struct<{
433
- readonly type: Schema.tag<"video">;
434
- readonly index: Schema.Number;
435
- readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
436
- readonly source: Schema.Union<readonly [Schema.Struct<{
437
- readonly type: Schema.Literal<"bytes">;
438
- readonly data: Schema.Uint8Array;
439
- readonly mediaType: Schema.String;
440
- }>, Schema.Struct<{
441
- readonly type: Schema.Literal<"base64">;
442
- readonly data: Schema.String;
443
- readonly mediaType: Schema.String;
444
- }>, Schema.Struct<{
445
- readonly type: Schema.Literal<"url">;
446
- readonly url: Schema.String;
447
- readonly mediaType: Schema.optional<Schema.String>;
448
- readonly expiresAt: Schema.optional<Schema.Number>;
449
- }>, Schema.Struct<{
450
- readonly type: Schema.Literal<"ref">;
451
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
452
- readonly id: Schema.String;
453
- readonly mediaType: Schema.optional<Schema.String>;
454
- }>]>;
455
- readonly info: Schema.optional<Schema.Struct<{
456
- readonly width: Schema.optional<Schema.Number>;
457
- readonly height: Schema.optional<Schema.Number>;
458
- readonly durationSeconds: Schema.optional<Schema.Number>;
459
- readonly sampleRate: Schema.optional<Schema.Number>;
460
- readonly channels: Schema.optional<Schema.Number>;
461
- readonly encoding: Schema.optional<Schema.String>;
462
- readonly format: Schema.optional<Schema.String>;
463
- }>>;
464
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
465
- }>, never, never>;
466
- }>, Schema.Struct<{
467
- readonly type: Schema.tag<"finish">;
468
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
469
- readonly type: Schema.Literal<"tokens">;
470
- readonly input: Schema.optional<Schema.Number>;
471
- readonly output: Schema.optional<Schema.Number>;
472
- readonly total: Schema.optional<Schema.Number>;
473
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
474
- }>, Schema.Struct<{
475
- readonly type: Schema.Literal<"seconds">;
476
- readonly seconds: Schema.Number;
477
- }>, Schema.Struct<{
478
- readonly type: Schema.Literal<"characters">;
479
- readonly characters: Schema.Number;
480
- }>, Schema.Struct<{
481
- readonly type: Schema.Literal<"credits">;
482
- readonly credits: Schema.Number;
483
- }>, Schema.Struct<{
484
- readonly type: Schema.Literal<"compute">;
485
- readonly seconds: Schema.Number;
486
- }>]>>;
487
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
488
- }>]> & {
489
- readonly tag: "type";
490
- readonly discriminants: readonly ["generation-queued", "generation-progress", "video", "finish"];
491
- readonly cases: {
492
- finish: Schema.Struct<{
493
- readonly type: Schema.tag<"finish">;
494
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
495
- readonly type: Schema.Literal<"tokens">;
496
- readonly input: Schema.optional<Schema.Number>;
497
- readonly output: Schema.optional<Schema.Number>;
498
- readonly total: Schema.optional<Schema.Number>;
499
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
500
- }>, Schema.Struct<{
501
- readonly type: Schema.Literal<"seconds">;
502
- readonly seconds: Schema.Number;
503
- }>, Schema.Struct<{
504
- readonly type: Schema.Literal<"characters">;
505
- readonly characters: Schema.Number;
506
- }>, Schema.Struct<{
507
- readonly type: Schema.Literal<"credits">;
508
- readonly credits: Schema.Number;
509
- }>, Schema.Struct<{
510
- readonly type: Schema.Literal<"compute">;
511
- readonly seconds: Schema.Number;
512
- }>]>>;
513
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
514
- }>;
515
- "generation-progress": Schema.Struct<{
516
- readonly type: Schema.tag<"generation-progress">;
517
- readonly id: Schema.String;
518
- readonly progress: Schema.optional<Schema.Number>;
519
- }>;
520
- "generation-queued": Schema.Struct<{
521
- readonly type: Schema.tag<"generation-queued">;
522
- readonly id: Schema.String;
523
- readonly position: Schema.optional<Schema.Number>;
524
- }>;
525
- video: Schema.Struct<{
526
- readonly type: Schema.tag<"video">;
527
- readonly index: Schema.Number;
528
- readonly video: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
529
- readonly source: Schema.Union<readonly [Schema.Struct<{
530
- readonly type: Schema.Literal<"bytes">;
531
- readonly data: Schema.Uint8Array;
532
- readonly mediaType: Schema.String;
533
- }>, Schema.Struct<{
534
- readonly type: Schema.Literal<"base64">;
535
- readonly data: Schema.String;
536
- readonly mediaType: Schema.String;
537
- }>, Schema.Struct<{
538
- readonly type: Schema.Literal<"url">;
539
- readonly url: Schema.String;
540
- readonly mediaType: Schema.optional<Schema.String>;
541
- readonly expiresAt: Schema.optional<Schema.Number>;
542
- }>, Schema.Struct<{
543
- readonly type: Schema.Literal<"ref">;
544
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
545
- readonly id: Schema.String;
546
- readonly mediaType: Schema.optional<Schema.String>;
547
- }>]>;
548
- readonly info: Schema.optional<Schema.Struct<{
549
- readonly width: Schema.optional<Schema.Number>;
550
- readonly height: Schema.optional<Schema.Number>;
551
- readonly durationSeconds: Schema.optional<Schema.Number>;
552
- readonly sampleRate: Schema.optional<Schema.Number>;
553
- readonly channels: Schema.optional<Schema.Number>;
554
- readonly encoding: Schema.optional<Schema.String>;
555
- readonly format: Schema.optional<Schema.String>;
556
- }>>;
557
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
558
- }>, never, never>;
559
- }>;
560
- };
561
- readonly isAnyOf: <const Keys>(keys: readonly Keys[]) => (value: {
562
- readonly type: "video";
563
- readonly index: number;
564
- readonly video: Media.Asset;
565
- } | {
566
- readonly type: "generation-queued";
567
- readonly id: string;
568
- readonly position?: number | undefined;
569
- } | {
570
- readonly type: "generation-progress";
571
- readonly id: string;
572
- readonly progress?: number | undefined;
573
- } | {
574
- readonly type: "finish";
575
- readonly usage?: {
576
- readonly type: "seconds";
577
- readonly seconds: number;
578
- } | {
579
- readonly type: "characters";
580
- readonly characters: number;
581
- } | {
582
- readonly type: "credits";
583
- readonly credits: number;
584
- } | {
585
- readonly type: "compute";
586
- readonly seconds: number;
587
- } | {
588
- readonly type: "tokens";
589
- readonly input?: number | undefined;
590
- readonly output?: number | undefined;
591
- readonly total?: number | undefined;
592
- readonly details?: {
593
- readonly [x: string]: unknown;
594
- } | undefined;
595
- } | undefined;
596
- readonly providerMetadata?: {
597
- readonly [x: string]: {
598
- readonly [x: string]: unknown;
599
- };
600
- } | undefined;
601
- }) => value is Extract<{
602
- readonly type: "video";
603
- readonly index: number;
604
- readonly video: Media.Asset;
605
- }, {
606
- readonly type: Keys;
607
- }> | Extract<{
608
- readonly type: "generation-queued";
609
- readonly id: string;
610
- readonly position?: number | undefined;
611
- }, {
612
- readonly type: Keys;
613
- }> | Extract<{
614
- readonly type: "generation-progress";
615
- readonly id: string;
616
- readonly progress?: number | undefined;
617
- }, {
618
- readonly type: Keys;
619
- }> | Extract<{
620
- readonly type: "finish";
621
- readonly usage?: {
622
- readonly type: "seconds";
623
- readonly seconds: number;
624
- } | {
625
- readonly type: "characters";
626
- readonly characters: number;
627
- } | {
628
- readonly type: "credits";
629
- readonly credits: number;
630
- } | {
631
- readonly type: "compute";
632
- readonly seconds: number;
633
- } | {
634
- readonly type: "tokens";
635
- readonly input?: number | undefined;
636
- readonly output?: number | undefined;
637
- readonly total?: number | undefined;
638
- readonly details?: {
639
- readonly [x: string]: unknown;
640
- } | undefined;
641
- } | undefined;
642
- readonly providerMetadata?: {
643
- readonly [x: string]: {
644
- readonly [x: string]: unknown;
645
- };
646
- } | undefined;
647
- }, {
648
- readonly type: Keys;
649
- }>;
650
- readonly guards: {
651
- finish: (u: unknown) => u is {
652
- readonly type: "finish";
653
- readonly usage?: {
654
- readonly type: "seconds";
655
- readonly seconds: number;
656
- } | {
657
- readonly type: "characters";
658
- readonly characters: number;
659
- } | {
660
- readonly type: "credits";
661
- readonly credits: number;
662
- } | {
663
- readonly type: "compute";
664
- readonly seconds: number;
665
- } | {
666
- readonly type: "tokens";
667
- readonly input?: number | undefined;
668
- readonly output?: number | undefined;
669
- readonly total?: number | undefined;
670
- readonly details?: {
671
- readonly [x: string]: unknown;
672
- } | undefined;
673
- } | undefined;
674
- readonly providerMetadata?: {
675
- readonly [x: string]: {
676
- readonly [x: string]: unknown;
677
- };
678
- } | undefined;
679
- };
680
- "generation-progress": (u: unknown) => u is {
681
- readonly type: "generation-progress";
682
- readonly id: string;
683
- readonly progress?: number | undefined;
684
- };
685
- "generation-queued": (u: unknown) => u is {
686
- readonly type: "generation-queued";
687
- readonly id: string;
688
- readonly position?: number | undefined;
689
- };
690
- video: (u: unknown) => u is {
691
- readonly type: "video";
692
- readonly index: number;
693
- readonly video: Media.Asset;
694
- };
695
- };
696
- readonly match: {
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>>;
706
- }>, Schema.Struct<{
707
- readonly type: Schema.Literal<"seconds">;
708
- readonly seconds: Schema.Number;
709
- }>, Schema.Struct<{
710
- readonly type: Schema.Literal<"characters">;
711
- readonly characters: Schema.Number;
712
- }>, Schema.Struct<{
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
- }>]>>;
719
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
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: {
767
- readonly type: "video";
768
- readonly index: number;
769
- readonly video: Media.Asset;
770
- } | {
771
- readonly type: "generation-queued";
772
- readonly id: string;
773
- readonly position?: number | undefined;
774
- } | {
775
- readonly type: "generation-progress";
776
- readonly id: string;
777
- readonly progress?: number | undefined;
778
- } | {
779
- readonly type: "finish";
780
- readonly usage?: {
781
- readonly type: "seconds";
782
- readonly seconds: number;
783
- } | {
784
- readonly type: "characters";
785
- readonly characters: number;
786
- } | {
787
- readonly type: "credits";
788
- readonly credits: number;
789
- } | {
790
- readonly type: "compute";
791
- readonly seconds: number;
792
- } | {
793
- readonly type: "tokens";
794
- readonly input?: number | undefined;
795
- readonly output?: number | undefined;
796
- readonly total?: number | undefined;
797
- readonly details?: {
798
- readonly [x: string]: unknown;
799
- } | undefined;
800
- } | undefined;
801
- readonly providerMetadata?: {
802
- readonly [x: string]: {
803
- readonly [x: string]: unknown;
804
- };
805
- } | undefined;
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>>;
816
- }>, Schema.Struct<{
817
- readonly type: Schema.Literal<"seconds">;
818
- readonly seconds: Schema.Number;
819
- }>, Schema.Struct<{
820
- readonly type: Schema.Literal<"characters">;
821
- readonly characters: Schema.Number;
822
- }>, Schema.Struct<{
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
- }>]>>;
829
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
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: {
877
- readonly type: "video";
878
- readonly index: number;
879
- readonly video: Media.Asset;
880
- } | {
881
- readonly type: "generation-queued";
882
- readonly id: string;
883
- readonly position?: number | undefined;
884
- } | {
885
- readonly type: "generation-progress";
886
- readonly id: string;
887
- readonly progress?: number | undefined;
888
- } | {
889
- readonly type: "finish";
890
- readonly usage?: {
891
- readonly type: "seconds";
892
- readonly seconds: number;
893
- } | {
894
- readonly type: "characters";
895
- readonly characters: number;
896
- } | {
897
- readonly type: "credits";
898
- readonly credits: number;
899
- } | {
900
- readonly type: "compute";
901
- readonly seconds: number;
902
- } | {
903
- readonly type: "tokens";
904
- readonly input?: number | undefined;
905
- readonly output?: number | undefined;
906
- readonly total?: number | undefined;
907
- readonly details?: {
908
- readonly [x: string]: unknown;
909
- } | undefined;
910
- } | undefined;
911
- readonly providerMetadata?: {
912
- readonly [x: string]: {
913
- readonly [x: string]: unknown;
914
- };
915
- } | undefined;
916
- }) => import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "generation-queued" | "video"]>>;
917
- };
918
- readonly matchOrElse: {
919
- <Handlers, OrElse>(value: {
920
- readonly type: "video";
921
- readonly index: number;
922
- readonly video: Media.Asset;
923
- } | {
924
- readonly type: "generation-queued";
925
- readonly id: string;
926
- readonly position?: number | undefined;
927
- } | {
928
- readonly type: "generation-progress";
929
- readonly id: string;
930
- readonly progress?: number | undefined;
931
- } | {
932
- readonly type: "finish";
933
- readonly usage?: {
934
- readonly type: "seconds";
935
- readonly seconds: number;
936
- } | {
937
- readonly type: "characters";
938
- readonly characters: number;
939
- } | {
940
- readonly type: "credits";
941
- readonly credits: number;
942
- } | {
943
- readonly type: "compute";
944
- readonly seconds: number;
945
- } | {
946
- readonly type: "tokens";
947
- readonly input?: number | undefined;
948
- readonly output?: number | undefined;
949
- readonly total?: number | undefined;
950
- readonly details?: {
951
- readonly [x: string]: unknown;
952
- } | undefined;
953
- } | undefined;
954
- readonly providerMetadata?: {
955
- readonly [x: string]: {
956
- readonly [x: string]: unknown;
957
- };
958
- } | undefined;
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<{
1005
- readonly type: "video";
1006
- readonly index: number;
1007
- readonly video: Media.Asset;
1008
- }, {
1009
- readonly type: keyof Handlers;
1010
- }> | Exclude<{
1011
- readonly type: "generation-queued";
1012
- readonly id: string;
1013
- readonly position?: number | undefined;
1014
- }, {
1015
- readonly type: keyof Handlers;
1016
- }> | Exclude<{
1017
- readonly type: "generation-progress";
1018
- readonly id: string;
1019
- readonly progress?: number | undefined;
1020
- }, {
1021
- readonly type: keyof Handlers;
1022
- }> | Exclude<{
1023
- readonly type: "finish";
1024
- readonly usage?: {
1025
- readonly type: "seconds";
1026
- readonly seconds: number;
1027
- } | {
1028
- readonly type: "characters";
1029
- readonly characters: number;
1030
- } | {
1031
- readonly type: "credits";
1032
- readonly credits: number;
1033
- } | {
1034
- readonly type: "compute";
1035
- readonly seconds: number;
1036
- } | {
1037
- readonly type: "tokens";
1038
- readonly input?: number | undefined;
1039
- readonly output?: number | undefined;
1040
- readonly total?: number | undefined;
1041
- readonly details?: {
1042
- readonly [x: string]: unknown;
1043
- } | undefined;
1044
- } | undefined;
1045
- readonly providerMetadata?: {
1046
- readonly [x: string]: {
1047
- readonly [x: string]: unknown;
1048
- };
1049
- } | undefined;
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<{
1099
- readonly type: "video";
1100
- readonly index: number;
1101
- readonly video: Media.Asset;
1102
- }, {
1103
- readonly type: keyof Handlers;
1104
- }> | Exclude<{
1105
- readonly type: "generation-queued";
1106
- readonly id: string;
1107
- readonly position?: number | undefined;
1108
- }, {
1109
- readonly type: keyof Handlers;
1110
- }> | Exclude<{
1111
- readonly type: "generation-progress";
1112
- readonly id: string;
1113
- readonly progress?: number | undefined;
1114
- }, {
1115
- readonly type: keyof Handlers;
1116
- }> | Exclude<{
1117
- readonly type: "finish";
1118
- readonly usage?: {
1119
- readonly type: "seconds";
1120
- readonly seconds: number;
1121
- } | {
1122
- readonly type: "characters";
1123
- readonly characters: number;
1124
- } | {
1125
- readonly type: "credits";
1126
- readonly credits: number;
1127
- } | {
1128
- readonly type: "compute";
1129
- readonly seconds: number;
1130
- } | {
1131
- readonly type: "tokens";
1132
- readonly input?: number | undefined;
1133
- readonly output?: number | undefined;
1134
- readonly total?: number | undefined;
1135
- readonly details?: {
1136
- readonly [x: string]: unknown;
1137
- } | undefined;
1138
- } | undefined;
1139
- readonly providerMetadata?: {
1140
- readonly [x: string]: {
1141
- readonly [x: string]: unknown;
1142
- };
1143
- } | undefined;
1144
- }, {
1145
- readonly type: keyof Handlers;
1146
- }>) => any)): (value: {
1147
- readonly type: "video";
1148
- readonly index: number;
1149
- readonly video: Media.Asset;
1150
- } | {
1151
- readonly type: "generation-queued";
1152
- readonly id: string;
1153
- readonly position?: number | undefined;
1154
- } | {
1155
- readonly type: "generation-progress";
1156
- readonly id: string;
1157
- readonly progress?: number | undefined;
1158
- } | {
1159
- readonly type: "finish";
1160
- readonly usage?: {
1161
- readonly type: "seconds";
1162
- readonly seconds: number;
1163
- } | {
1164
- readonly type: "characters";
1165
- readonly characters: number;
1166
- } | {
1167
- readonly type: "credits";
1168
- readonly credits: number;
1169
- } | {
1170
- readonly type: "compute";
1171
- readonly seconds: number;
1172
- } | {
1173
- readonly type: "tokens";
1174
- readonly input?: number | undefined;
1175
- readonly output?: number | undefined;
1176
- readonly total?: number | undefined;
1177
- readonly details?: {
1178
- readonly [x: string]: unknown;
1179
- } | undefined;
1180
- } | undefined;
1181
- readonly providerMetadata?: {
1182
- readonly [x: string]: {
1183
- readonly [x: string]: unknown;
1184
- };
1185
- } | undefined;
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)>;
1187
- };
1188
- } & {
1189
- is: {
1190
- generationQueued: (u: unknown) => u is {
1191
- readonly type: "generation-queued";
1192
- readonly id: string;
1193
- readonly position?: number | undefined;
1194
- };
1195
- generationProgress: (u: unknown) => u is {
1196
- readonly type: "generation-progress";
1197
- readonly id: string;
1198
- readonly progress?: number | undefined;
1199
- };
1200
- video: (u: unknown) => u is {
1201
- readonly type: "video";
1202
- readonly index: number;
1203
- readonly video: Media.Asset;
1204
- };
1205
- finish: (u: unknown) => u is {
1206
- readonly type: "finish";
1207
- readonly usage?: {
1208
- readonly type: "seconds";
1209
- readonly seconds: number;
1210
- } | {
1211
- readonly type: "characters";
1212
- readonly characters: number;
1213
- } | {
1214
- readonly type: "credits";
1215
- readonly credits: number;
1216
- } | {
1217
- readonly type: "compute";
1218
- readonly seconds: number;
1219
- } | {
1220
- readonly type: "tokens";
1221
- readonly input?: number | undefined;
1222
- readonly output?: number | undefined;
1223
- readonly total?: number | undefined;
1224
- readonly details?: {
1225
- readonly [x: string]: unknown;
1226
- } | undefined;
1227
- } | undefined;
1228
- readonly providerMetadata?: {
1229
- readonly [x: string]: {
1230
- readonly [x: string]: unknown;
1231
- };
1232
- } | undefined;
1233
- };
1234
- };
1235
- };
1236
- export type VideoEvent = Schema.Schema.Type<typeof videoEventTagged>;
1237
162
  /** Normalize video request input into a plain `VideoRequest`. */
1238
163
  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>;
1241
- /** Rebuild a generation handle from a persisted `Generation.token`, refreshing its status once. */
1242
- export declare const resume: (model: VideoModel, token: unknown) => Effect.Effect<Generation<VideoResponse>, AIError, Service>;
1243
- export declare function stream<const Model extends VideoModel>(input: VideoRequestInput<Model>, options?: AwaitOptions): Stream.Stream<VideoEvent, AIError, Service>;
164
+ /** Submit a generation and return at once; nothing polls. */
165
+ export declare function start<const Model extends VideoModel>(input: VideoRequestInput<Model>): Effect.Effect<VideoJob, AIError, Service>;
166
+ /** One status read for a job ID. */
167
+ export declare const status: (model: VideoModel, id: string) => Effect.Effect<VideoStatus, AIError, Service>;
168
+ /** The finished videos; fails while the job is still running, or with the provider's reason when it failed. */
169
+ export declare const result: (model: VideoModel, id: string) => Effect.Effect<VideoResponse, AIError, Service>;
170
+ /** Ask the provider to stop the job; fails with `UnsupportedOperation` when the provider has no cancel call. */
171
+ export declare const cancel: (model: VideoModel, id: string) => Effect.Effect<void, AIError, Service>;
1244
172
  export declare const Video: {
1245
173
  readonly request: typeof request;
1246
174
  readonly start: typeof start;
1247
- readonly generate: typeof generate;
1248
- readonly resume: typeof resume;
1249
- readonly stream: typeof stream;
175
+ readonly status: typeof status;
176
+ readonly result: typeof result;
177
+ readonly cancel: typeof cancel;
1250
178
  };
1251
179
  export {};