@opencode/ai 2.0.15 → 2.0.16

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 (168) hide show
  1. package/README.md +286 -2
  2. package/dist/generation.d.ts +36 -22
  3. package/dist/generation.js +53 -24
  4. package/dist/image-client.d.ts +14 -7
  5. package/dist/image-client.js +24 -8
  6. package/dist/image.d.ts +398 -47
  7. package/dist/image.js +47 -45
  8. package/dist/index.d.ts +13 -1
  9. package/dist/index.js +9 -0
  10. package/dist/media-model.d.ts +44 -0
  11. package/dist/media-model.js +49 -0
  12. package/dist/media.d.ts +10 -9
  13. package/dist/media.js +9 -10
  14. package/dist/promise.d.ts +428 -8
  15. package/dist/promise.js +40 -3
  16. package/dist/protocols/alibaba-chat.d.ts +12 -0
  17. package/dist/protocols/alibaba-responses.d.ts +2 -2
  18. package/dist/protocols/anthropic-messages.js +1 -2
  19. package/dist/protocols/assemblyai-transcription.d.ts +40 -0
  20. package/dist/protocols/assemblyai-transcription.js +138 -0
  21. package/dist/protocols/bedrock-converse.js +5 -11
  22. package/dist/protocols/bfl-images.d.ts +32 -0
  23. package/dist/protocols/bfl-images.js +153 -0
  24. package/dist/protocols/cartesia-speech.d.ts +127 -0
  25. package/dist/protocols/cartesia-speech.js +126 -0
  26. package/dist/protocols/deepgram-speech.d.ts +119 -0
  27. package/dist/protocols/deepgram-speech.js +92 -0
  28. package/dist/protocols/deepgram-transcription.d.ts +25 -0
  29. package/dist/protocols/deepgram-transcription.js +129 -0
  30. package/dist/protocols/elevenlabs-speech.d.ts +122 -0
  31. package/dist/protocols/elevenlabs-speech.js +115 -0
  32. package/dist/protocols/fal-images.d.ts +24 -0
  33. package/dist/protocols/fal-images.js +114 -0
  34. package/dist/protocols/fal-video.d.ts +29 -0
  35. package/dist/protocols/fal-video.js +88 -0
  36. package/dist/protocols/gemini.d.ts +9 -9
  37. package/dist/protocols/gemini.js +8 -34
  38. package/dist/protocols/google-images.js +2 -14
  39. package/dist/protocols/google-speech.d.ts +130 -0
  40. package/dist/protocols/google-speech.js +84 -0
  41. package/dist/protocols/google-transcription.d.ts +173 -0
  42. package/dist/protocols/google-transcription.js +138 -0
  43. package/dist/protocols/google-video.d.ts +26 -0
  44. package/dist/protocols/google-video.js +158 -0
  45. package/dist/protocols/meta-images.js +2 -9
  46. package/dist/protocols/meta-responses.d.ts +4 -4
  47. package/dist/protocols/meta-responses.js +1 -1
  48. package/dist/protocols/open-responses.d.ts +6 -6
  49. package/dist/protocols/open-responses.js +1 -2
  50. package/dist/protocols/openai-chat.d.ts +84 -0
  51. package/dist/protocols/openai-chat.js +26 -14
  52. package/dist/protocols/openai-compatible-chat.d.ts +12 -0
  53. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  54. package/dist/protocols/openai-images.d.ts +124 -3
  55. package/dist/protocols/openai-images.js +107 -54
  56. package/dist/protocols/openai-responses.d.ts +15 -15
  57. package/dist/protocols/openai-responses.js +5 -6
  58. package/dist/protocols/openai-speech.d.ts +116 -0
  59. package/dist/protocols/openai-speech.js +98 -0
  60. package/dist/protocols/openai-transcription.d.ts +207 -0
  61. package/dist/protocols/openai-transcription.js +190 -0
  62. package/dist/protocols/replicate-images.d.ts +28 -0
  63. package/dist/protocols/replicate-images.js +133 -0
  64. package/dist/protocols/runway-video.d.ts +38 -0
  65. package/dist/protocols/runway-video.js +146 -0
  66. package/dist/protocols/shared.d.ts +13 -3
  67. package/dist/protocols/shared.js +23 -3
  68. package/dist/protocols/stability-images.d.ts +38 -0
  69. package/dist/protocols/stability-images.js +148 -0
  70. package/dist/protocols/utils/fal-queue.d.ts +28 -0
  71. package/dist/protocols/utils/fal-queue.js +69 -0
  72. package/dist/protocols/utils/gemini-generate-content.d.ts +65 -0
  73. package/dist/protocols/utils/gemini-generate-content.js +65 -0
  74. package/dist/protocols/utils/gemini-json-schema.d.ts +3 -0
  75. package/dist/protocols/utils/gemini-json-schema.js +76 -0
  76. package/dist/protocols/utils/media-input.d.ts +8 -0
  77. package/dist/protocols/utils/media-input.js +18 -0
  78. package/dist/protocols/utils/speech-stream.d.ts +49 -0
  79. package/dist/protocols/utils/speech-stream.js +67 -0
  80. package/dist/protocols/utils/tool-schema.d.ts +2 -2
  81. package/dist/protocols/utils/tool-schema.js +40 -17
  82. package/dist/protocols/xai-images.js +1 -12
  83. package/dist/protocols/xai-responses.d.ts +2 -2
  84. package/dist/protocols/xai-video.d.ts +34 -0
  85. package/dist/protocols/xai-video.js +147 -0
  86. package/dist/protocols/zai-chat.d.ts +13 -1
  87. package/dist/provider-error.js +3 -0
  88. package/dist/providers/alibaba.d.ts +14 -2
  89. package/dist/providers/amazon-bedrock-mantle.d.ts +14 -2
  90. package/dist/providers/assemblyai.d.ts +25 -0
  91. package/dist/providers/assemblyai.js +29 -0
  92. package/dist/providers/azure.d.ts +18 -6
  93. package/dist/providers/baseten.d.ts +24 -0
  94. package/dist/providers/black-forest-labs.d.ts +25 -0
  95. package/dist/providers/black-forest-labs.js +28 -0
  96. package/dist/providers/cartesia.d.ts +24 -0
  97. package/dist/providers/cartesia.js +22 -0
  98. package/dist/providers/cerebras.d.ts +24 -0
  99. package/dist/providers/cloudflare-ai-gateway.d.ts +30 -6
  100. package/dist/providers/cloudflare-workers-ai.d.ts +24 -0
  101. package/dist/providers/deepgram.d.ts +29 -0
  102. package/dist/providers/deepgram.js +31 -0
  103. package/dist/providers/deepinfra.d.ts +24 -0
  104. package/dist/providers/deepseek.d.ts +24 -0
  105. package/dist/providers/elevenlabs.d.ts +24 -0
  106. package/dist/providers/elevenlabs.js +28 -0
  107. package/dist/providers/fal.d.ts +29 -0
  108. package/dist/providers/fal.js +33 -0
  109. package/dist/providers/fireworks.d.ts +24 -0
  110. package/dist/providers/google-vertex-chat.d.ts +12 -0
  111. package/dist/providers/google-vertex-responses.d.ts +2 -2
  112. package/dist/providers/google-vertex.d.ts +3 -3
  113. package/dist/providers/google.d.ts +18 -3
  114. package/dist/providers/google.js +11 -2
  115. package/dist/providers/groq.d.ts +24 -0
  116. package/dist/providers/index.d.ts +9 -0
  117. package/dist/providers/index.js +9 -0
  118. package/dist/providers/meta.d.ts +14 -2
  119. package/dist/providers/minimax.d.ts +14 -2
  120. package/dist/providers/moonshot.d.ts +14 -2
  121. package/dist/providers/moonshot.js +3 -3
  122. package/dist/providers/openai-compatible-responses.d.ts +2 -2
  123. package/dist/providers/openai-compatible.d.ts +12 -0
  124. package/dist/providers/openai.d.ts +25 -3
  125. package/dist/providers/openai.js +10 -1
  126. package/dist/providers/openrouter.d.ts +48 -0
  127. package/dist/providers/replicate.d.ts +25 -0
  128. package/dist/providers/replicate.js +22 -0
  129. package/dist/providers/runway.d.ts +24 -0
  130. package/dist/providers/runway.js +22 -0
  131. package/dist/providers/stability.d.ts +28 -0
  132. package/dist/providers/stability.js +23 -0
  133. package/dist/providers/togetherai.d.ts +24 -0
  134. package/dist/providers/xai.d.ts +17 -0
  135. package/dist/providers/xai.js +5 -2
  136. package/dist/providers/zai-coding-plan.d.ts +15 -3
  137. package/dist/providers/zai.d.ts +13 -1
  138. package/dist/route/auth.d.ts +4 -1
  139. package/dist/route/auth.js +6 -0
  140. package/dist/route/framing.d.ts +5 -1
  141. package/dist/route/framing.js +9 -0
  142. package/dist/route/media-protocol.d.ts +116 -3
  143. package/dist/route/media-protocol.js +60 -4
  144. package/dist/route/media.d.ts +58 -7
  145. package/dist/route/media.js +201 -29
  146. package/dist/schema/events.d.ts +0 -6
  147. package/dist/schema/messages.d.ts +0 -3
  148. package/dist/schema/options.d.ts +4 -3
  149. package/dist/schema/options.js +3 -2
  150. package/dist/speech-client.d.ts +21 -0
  151. package/dist/speech-client.js +25 -0
  152. package/dist/speech.d.ts +1150 -0
  153. package/dist/speech.js +119 -0
  154. package/dist/transcription-client.d.ts +28 -0
  155. package/dist/transcription-client.js +44 -0
  156. package/dist/transcription.d.ts +1504 -0
  157. package/dist/transcription.js +133 -0
  158. package/dist/utils/bytes.d.ts +1 -0
  159. package/dist/utils/bytes.js +10 -0
  160. package/dist/utils/media-type.d.ts +1 -0
  161. package/dist/utils/media-type.js +22 -1
  162. package/dist/video-client.d.ts +28 -0
  163. package/dist/video-client.js +40 -0
  164. package/dist/video.d.ts +1359 -0
  165. package/dist/video.js +119 -0
  166. package/package.json +3 -3
  167. package/dist/protocols/utils/gemini-tool-schema.d.ts +0 -2
  168. package/dist/protocols/utils/gemini-tool-schema.js +0 -103
package/dist/image.d.ts CHANGED
@@ -1,47 +1,31 @@
1
1
  import { Effect, Schema, Stream } from "effect";
2
+ import { Generation, type AwaitOptions } from "./generation.js";
2
3
  import { Media } from "./media.js";
3
- import { Endpoint } from "./route/endpoint.js";
4
+ import { MediaModel } from "./media-model.js";
4
5
  import { MediaRoute } from "./route/media.js";
5
6
  import type { MediaProtocol } from "./route/media-protocol.js";
6
- import { AIError, HttpOptions, ModelID, ProviderID } from "./schema/index.js";
7
+ import { AIError, HttpOptions } from "./schema/index.js";
7
8
  import { Service } from "./image-client.js";
8
9
  export type ImageOptions = Record<string, unknown>;
9
- export type ImageRoute<Options extends ImageOptions = ImageOptions> = MediaRoute.Route<ImageRequestFor<Options>, ImageResponse>;
10
- export declare class ImageModel<Options extends ImageOptions = ImageOptions> {
11
- protected readonly _Options: (options: Options) => Options;
12
- readonly id: ModelID;
13
- readonly provider: ProviderID;
14
- readonly route: ImageRoute<Options>;
15
- readonly http?: HttpOptions;
16
- constructor(input: ImageModel.Input<Options>);
17
- static make<Options extends ImageOptions = ImageOptions>(input: ImageModel.MakeInput<Options>): ImageModel<Options>;
18
- /** Compose an inline image protocol with its canonical path into a model for one deployment. */
19
- static fromRoute<Options extends ImageOptions = ImageOptions>(route: ImageModel.RouteInput<Options>, input: MediaRoute.ModelInput): ImageModel<Options>;
10
+ export type ImageRoute<Options extends ImageOptions = ImageOptions> = MediaRoute.AnyRoute<ImageRequestFor<Options>, ImageEvent, ImageResponse>;
11
+ export declare class ImageModel<Options extends ImageOptions = ImageOptions> extends MediaModel<ImageRoute<Options>, Options> {
12
+ protected readonly _ImageModel: void;
13
+ static make<Options extends ImageOptions = ImageOptions>(input: MediaModel.Input<ImageRoute<Options>>): ImageModel<Options>;
14
+ /** The number of type arguments selects the kind: `<Options>`, `<Options, Frame, State>`, or `<Options, Token>`. */
15
+ static fromRoute<Options extends ImageOptions>(route: ImageModel.InlineRouteInput<Options>, input: MediaRoute.ModelInput): ImageModel<Options>;
16
+ static fromRoute<Options extends ImageOptions, Frame, State>(route: ImageModel.StreamRouteInput<Options, Frame, State>, input: MediaRoute.ModelInput): ImageModel<Options>;
17
+ static fromRoute<Options extends ImageOptions, Token>(route: ImageModel.QueuedRouteInput<Options, Token>, input: MediaRoute.ModelInput): ImageModel<Options>;
20
18
  }
21
19
  export declare namespace ImageModel {
22
- interface Input<Options extends ImageOptions = ImageOptions> {
23
- readonly id: ModelID;
24
- readonly provider: ProviderID;
25
- readonly route: ImageRoute<Options>;
26
- readonly http?: HttpOptions;
27
- }
28
- interface MakeInput<Options extends ImageOptions = ImageOptions> extends Omit<Input<Options>, "id" | "provider"> {
29
- readonly id: string | ModelID;
30
- readonly provider: string | ProviderID;
31
- }
32
- interface RouteInput<Options extends ImageOptions = ImageOptions> {
33
- readonly id: string;
34
- readonly provider: string | ProviderID;
35
- readonly protocol: MediaProtocol.Inline<ImageRequestFor<Options>, ImageResponse>;
36
- readonly path: Endpoint.EndpointPart<MediaProtocol.Body, ImageRequestFor<Options>>;
37
- /** Canonical base URL; `ModelInput.baseURL` overrides it per deployment. */
38
- readonly baseURL?: string;
39
- }
20
+ type InlineRouteInput<Options extends ImageOptions = ImageOptions> = MediaModel.RouteInput<ImageRequestFor<Options>, MediaProtocol.Inline<ImageRequestFor<Options>, ImageResponse>>;
21
+ type StreamRouteInput<Options extends ImageOptions = ImageOptions, Frame = unknown, State = unknown> = MediaModel.RouteInput<MediaProtocol.Addressed<ImageRequestFor<Options>>, MediaProtocol.Streamed<ImageRequestFor<Options>, ImageEvent, Frame, State>>;
22
+ type QueuedRouteInput<Options extends ImageOptions = ImageOptions, Token = unknown> = MediaModel.RouteInput<ImageRequestFor<Options>, MediaProtocol.Queued<ImageRequestFor<Options>, ImageResponse, Token>>;
23
+ type RouteInput<Options extends ImageOptions = ImageOptions, Frame = unknown, State = unknown, Token = unknown> = MediaModel.AnyRouteInput<ImageRequestFor<Options>, ImageEvent, ImageResponse, Frame, State, Token>;
40
24
  }
41
25
  export declare const ImageModelSchema: Schema.declare<ImageModel<ImageOptions>, ImageModel<ImageOptions>>;
42
26
  export type ImageSize = `${number}x${number}`;
43
27
  export declare const ImageSize: Schema.declare<`${number}x${number}`, `${number}x${number}`>;
44
- export type ImageAspectRatio = `${number}:${number}`;
28
+ export type ImageAspectRatio = Media.AspectRatio;
45
29
  export declare const ImageAspectRatio: Schema.declare<`${number}:${number}`, `${number}:${number}`>;
46
30
  export type ImageFormat = "png" | "jpeg" | "webp" | (string & {});
47
31
  declare const ImageRequest_base: Schema.Class<ImageRequest, Schema.Struct<{
@@ -62,7 +46,6 @@ declare const ImageRequest_base: Schema.Class<ImageRequest, Schema.Struct<{
62
46
  readonly url: Schema.String;
63
47
  readonly mediaType: Schema.optional<Schema.String>;
64
48
  readonly expiresAt: Schema.optional<Schema.Number>;
65
- readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
66
49
  }>, Schema.Struct<{
67
50
  readonly type: Schema.Literal<"ref">;
68
51
  readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
@@ -95,7 +78,6 @@ declare const ImageRequest_base: Schema.Class<ImageRequest, Schema.Struct<{
95
78
  readonly url: Schema.String;
96
79
  readonly mediaType: Schema.optional<Schema.String>;
97
80
  readonly expiresAt: Schema.optional<Schema.Number>;
98
- readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
99
81
  }>, Schema.Struct<{
100
82
  readonly type: Schema.Literal<"ref">;
101
83
  readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
@@ -150,7 +132,6 @@ declare const ImageResponse_base: Schema.Class<ImageResponse, Schema.Struct<{
150
132
  readonly url: Schema.String;
151
133
  readonly mediaType: Schema.optional<Schema.String>;
152
134
  readonly expiresAt: Schema.optional<Schema.Number>;
153
- readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
154
135
  }>, Schema.Struct<{
155
136
  readonly type: Schema.Literal<"ref">;
156
137
  readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
@@ -197,6 +178,42 @@ declare const ImageResponse_base: Schema.Class<ImageResponse, Schema.Struct<{
197
178
  export declare class ImageResponse extends ImageResponse_base {
198
179
  get image(): Media.Asset;
199
180
  }
181
+ /** The `index`-th lower-fidelity preview of an image still generating; the `image` event supersedes it. */
182
+ export declare const ImagePartialEvent: Schema.Struct<{
183
+ readonly type: Schema.tag<"image-partial">;
184
+ readonly index: Schema.Number;
185
+ readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
186
+ readonly source: Schema.Union<readonly [Schema.Struct<{
187
+ readonly type: Schema.Literal<"bytes">;
188
+ readonly data: Schema.Uint8Array;
189
+ readonly mediaType: Schema.String;
190
+ }>, Schema.Struct<{
191
+ readonly type: Schema.Literal<"base64">;
192
+ readonly data: Schema.String;
193
+ readonly mediaType: Schema.String;
194
+ }>, Schema.Struct<{
195
+ readonly type: Schema.Literal<"url">;
196
+ readonly url: Schema.String;
197
+ readonly mediaType: Schema.optional<Schema.String>;
198
+ readonly expiresAt: Schema.optional<Schema.Number>;
199
+ }>, Schema.Struct<{
200
+ readonly type: Schema.Literal<"ref">;
201
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
202
+ readonly id: Schema.String;
203
+ readonly mediaType: Schema.optional<Schema.String>;
204
+ }>]>;
205
+ readonly info: Schema.optional<Schema.Struct<{
206
+ readonly width: Schema.optional<Schema.Number>;
207
+ readonly height: Schema.optional<Schema.Number>;
208
+ readonly durationSeconds: Schema.optional<Schema.Number>;
209
+ readonly sampleRate: Schema.optional<Schema.Number>;
210
+ readonly channels: Schema.optional<Schema.Number>;
211
+ readonly encoding: Schema.optional<Schema.String>;
212
+ readonly format: Schema.optional<Schema.String>;
213
+ }>>;
214
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
215
+ }>, never, never>;
216
+ }>;
200
217
  export declare const ImageOutputEvent: Schema.Struct<{
201
218
  readonly type: Schema.tag<"image">;
202
219
  readonly index: Schema.Number;
@@ -214,7 +231,6 @@ export declare const ImageOutputEvent: Schema.Struct<{
214
231
  readonly url: Schema.String;
215
232
  readonly mediaType: Schema.optional<Schema.String>;
216
233
  readonly expiresAt: Schema.optional<Schema.Number>;
217
- readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
218
234
  }>, Schema.Struct<{
219
235
  readonly type: Schema.Literal<"ref">;
220
236
  readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
@@ -262,6 +278,48 @@ export declare const ImageFinishEvent: Schema.Struct<{
262
278
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
263
279
  }>;
264
280
  declare const imageEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
281
+ readonly type: Schema.tag<"generation-queued">;
282
+ readonly id: Schema.String;
283
+ readonly position: Schema.optional<Schema.Number>;
284
+ }>, Schema.Struct<{
285
+ readonly type: Schema.tag<"generation-progress">;
286
+ readonly id: Schema.String;
287
+ readonly progress: Schema.optional<Schema.Number>;
288
+ }>, Schema.Struct<{
289
+ readonly type: Schema.tag<"image-partial">;
290
+ readonly index: Schema.Number;
291
+ readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
292
+ readonly source: Schema.Union<readonly [Schema.Struct<{
293
+ readonly type: Schema.Literal<"bytes">;
294
+ readonly data: Schema.Uint8Array;
295
+ readonly mediaType: Schema.String;
296
+ }>, Schema.Struct<{
297
+ readonly type: Schema.Literal<"base64">;
298
+ readonly data: Schema.String;
299
+ readonly mediaType: Schema.String;
300
+ }>, Schema.Struct<{
301
+ readonly type: Schema.Literal<"url">;
302
+ readonly url: Schema.String;
303
+ readonly mediaType: Schema.optional<Schema.String>;
304
+ readonly expiresAt: Schema.optional<Schema.Number>;
305
+ }>, Schema.Struct<{
306
+ readonly type: Schema.Literal<"ref">;
307
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
308
+ readonly id: Schema.String;
309
+ readonly mediaType: Schema.optional<Schema.String>;
310
+ }>]>;
311
+ readonly info: Schema.optional<Schema.Struct<{
312
+ readonly width: Schema.optional<Schema.Number>;
313
+ readonly height: Schema.optional<Schema.Number>;
314
+ readonly durationSeconds: Schema.optional<Schema.Number>;
315
+ readonly sampleRate: Schema.optional<Schema.Number>;
316
+ readonly channels: Schema.optional<Schema.Number>;
317
+ readonly encoding: Schema.optional<Schema.String>;
318
+ readonly format: Schema.optional<Schema.String>;
319
+ }>>;
320
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
321
+ }>, never, never>;
322
+ }>, Schema.Struct<{
265
323
  readonly type: Schema.tag<"image">;
266
324
  readonly index: Schema.Number;
267
325
  readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
@@ -278,7 +336,6 @@ declare const imageEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.St
278
336
  readonly url: Schema.String;
279
337
  readonly mediaType: Schema.optional<Schema.String>;
280
338
  readonly expiresAt: Schema.optional<Schema.Number>;
281
- readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
282
339
  }>, Schema.Struct<{
283
340
  readonly type: Schema.Literal<"ref">;
284
341
  readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
@@ -325,6 +382,48 @@ declare const imageEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.St
325
382
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
326
383
  }>]>;
327
384
  export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
385
+ readonly type: Schema.tag<"generation-queued">;
386
+ readonly id: Schema.String;
387
+ readonly position: Schema.optional<Schema.Number>;
388
+ }>, Schema.Struct<{
389
+ readonly type: Schema.tag<"generation-progress">;
390
+ readonly id: Schema.String;
391
+ readonly progress: Schema.optional<Schema.Number>;
392
+ }>, Schema.Struct<{
393
+ readonly type: Schema.tag<"image-partial">;
394
+ readonly index: Schema.Number;
395
+ readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
396
+ readonly source: Schema.Union<readonly [Schema.Struct<{
397
+ readonly type: Schema.Literal<"bytes">;
398
+ readonly data: Schema.Uint8Array;
399
+ readonly mediaType: Schema.String;
400
+ }>, Schema.Struct<{
401
+ readonly type: Schema.Literal<"base64">;
402
+ readonly data: Schema.String;
403
+ readonly mediaType: Schema.String;
404
+ }>, Schema.Struct<{
405
+ readonly type: Schema.Literal<"url">;
406
+ readonly url: Schema.String;
407
+ readonly mediaType: Schema.optional<Schema.String>;
408
+ readonly expiresAt: Schema.optional<Schema.Number>;
409
+ }>, Schema.Struct<{
410
+ readonly type: Schema.Literal<"ref">;
411
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
412
+ readonly id: Schema.String;
413
+ readonly mediaType: Schema.optional<Schema.String>;
414
+ }>]>;
415
+ readonly info: Schema.optional<Schema.Struct<{
416
+ readonly width: Schema.optional<Schema.Number>;
417
+ readonly height: Schema.optional<Schema.Number>;
418
+ readonly durationSeconds: Schema.optional<Schema.Number>;
419
+ readonly sampleRate: Schema.optional<Schema.Number>;
420
+ readonly channels: Schema.optional<Schema.Number>;
421
+ readonly encoding: Schema.optional<Schema.String>;
422
+ readonly format: Schema.optional<Schema.String>;
423
+ }>>;
424
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
425
+ }>, never, never>;
426
+ }>, Schema.Struct<{
328
427
  readonly type: Schema.tag<"image">;
329
428
  readonly index: Schema.Number;
330
429
  readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
@@ -341,7 +440,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
341
440
  readonly url: Schema.String;
342
441
  readonly mediaType: Schema.optional<Schema.String>;
343
442
  readonly expiresAt: Schema.optional<Schema.Number>;
344
- readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
345
443
  }>, Schema.Struct<{
346
444
  readonly type: Schema.Literal<"ref">;
347
445
  readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
@@ -387,8 +485,53 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
387
485
  }>>>;
388
486
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
389
487
  }>]> & {
390
- readonly discriminants: readonly ["image", "finish"];
488
+ readonly discriminants: readonly ["generation-queued", "generation-progress", "image-partial", "image", "finish"];
391
489
  readonly cases: {
490
+ "generation-queued": Schema.Struct<{
491
+ readonly type: Schema.tag<"generation-queued">;
492
+ readonly id: Schema.String;
493
+ readonly position: Schema.optional<Schema.Number>;
494
+ }>;
495
+ "generation-progress": Schema.Struct<{
496
+ readonly type: Schema.tag<"generation-progress">;
497
+ readonly id: Schema.String;
498
+ readonly progress: Schema.optional<Schema.Number>;
499
+ }>;
500
+ "image-partial": Schema.Struct<{
501
+ readonly type: Schema.tag<"image-partial">;
502
+ readonly index: Schema.Number;
503
+ readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
504
+ readonly source: Schema.Union<readonly [Schema.Struct<{
505
+ readonly type: Schema.Literal<"bytes">;
506
+ readonly data: Schema.Uint8Array;
507
+ readonly mediaType: Schema.String;
508
+ }>, Schema.Struct<{
509
+ readonly type: Schema.Literal<"base64">;
510
+ readonly data: Schema.String;
511
+ readonly mediaType: Schema.String;
512
+ }>, Schema.Struct<{
513
+ readonly type: Schema.Literal<"url">;
514
+ readonly url: Schema.String;
515
+ readonly mediaType: Schema.optional<Schema.String>;
516
+ readonly expiresAt: Schema.optional<Schema.Number>;
517
+ }>, Schema.Struct<{
518
+ readonly type: Schema.Literal<"ref">;
519
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
520
+ readonly id: Schema.String;
521
+ readonly mediaType: Schema.optional<Schema.String>;
522
+ }>]>;
523
+ readonly info: Schema.optional<Schema.Struct<{
524
+ readonly width: Schema.optional<Schema.Number>;
525
+ readonly height: Schema.optional<Schema.Number>;
526
+ readonly durationSeconds: Schema.optional<Schema.Number>;
527
+ readonly sampleRate: Schema.optional<Schema.Number>;
528
+ readonly channels: Schema.optional<Schema.Number>;
529
+ readonly encoding: Schema.optional<Schema.String>;
530
+ readonly format: Schema.optional<Schema.String>;
531
+ }>>;
532
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
533
+ }>, never, never>;
534
+ }>;
392
535
  image: Schema.Struct<{
393
536
  readonly type: Schema.tag<"image">;
394
537
  readonly index: Schema.Number;
@@ -406,7 +549,6 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
406
549
  readonly url: Schema.String;
407
550
  readonly mediaType: Schema.optional<Schema.String>;
408
551
  readonly expiresAt: Schema.optional<Schema.Number>;
409
- readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
410
552
  }>, Schema.Struct<{
411
553
  readonly type: Schema.Literal<"ref">;
412
554
  readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
@@ -455,6 +597,18 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
455
597
  }>;
456
598
  };
457
599
  readonly isAnyOf: <const Keys>(keys: readonly Keys[]) => (value: {
600
+ readonly id: string;
601
+ readonly type: "generation-queued";
602
+ readonly position?: number | undefined;
603
+ } | {
604
+ readonly id: string;
605
+ readonly type: "generation-progress";
606
+ readonly progress?: number | undefined;
607
+ } | {
608
+ readonly type: "image-partial";
609
+ readonly index: number;
610
+ readonly image: Media.Asset;
611
+ } | {
458
612
  readonly type: "image";
459
613
  readonly index: number;
460
614
  readonly image: Media.Asset;
@@ -496,6 +650,24 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
496
650
  } | undefined;
497
651
  }[] | undefined;
498
652
  }) => value is Extract<{
653
+ readonly id: string;
654
+ readonly type: "generation-queued";
655
+ readonly position?: number | undefined;
656
+ }, {
657
+ readonly type: Keys;
658
+ }> | Extract<{
659
+ readonly id: string;
660
+ readonly type: "generation-progress";
661
+ readonly progress?: number | undefined;
662
+ }, {
663
+ readonly type: Keys;
664
+ }> | Extract<{
665
+ readonly type: "image-partial";
666
+ readonly index: number;
667
+ readonly image: Media.Asset;
668
+ }, {
669
+ readonly type: Keys;
670
+ }> | Extract<{
499
671
  readonly type: "image";
500
672
  readonly index: number;
501
673
  readonly image: Media.Asset;
@@ -542,6 +714,21 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
542
714
  readonly type: Keys;
543
715
  }>;
544
716
  readonly guards: {
717
+ "generation-queued": (u: unknown) => u is {
718
+ readonly id: string;
719
+ readonly type: "generation-queued";
720
+ readonly position?: number | undefined;
721
+ };
722
+ "generation-progress": (u: unknown) => u is {
723
+ readonly id: string;
724
+ readonly type: "generation-progress";
725
+ readonly progress?: number | undefined;
726
+ };
727
+ "image-partial": (u: unknown) => u is {
728
+ readonly type: "image-partial";
729
+ readonly index: number;
730
+ readonly image: Media.Asset;
731
+ };
545
732
  image: (u: unknown) => u is {
546
733
  readonly type: "image";
547
734
  readonly index: number;
@@ -588,6 +775,21 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
588
775
  };
589
776
  readonly match: {
590
777
  <Cases extends {
778
+ "generation-queued": (value: {
779
+ readonly id: string;
780
+ readonly type: "generation-queued";
781
+ readonly position?: number | undefined;
782
+ }) => any;
783
+ "generation-progress": (value: {
784
+ readonly id: string;
785
+ readonly type: "generation-progress";
786
+ readonly progress?: number | undefined;
787
+ }) => any;
788
+ "image-partial": (value: {
789
+ readonly type: "image-partial";
790
+ readonly index: number;
791
+ readonly image: Media.Asset;
792
+ }) => any;
591
793
  image: (value: {
592
794
  readonly type: "image";
593
795
  readonly index: number;
@@ -632,6 +834,18 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
632
834
  }[] | undefined;
633
835
  }) => any;
634
836
  }>(value: {
837
+ readonly id: string;
838
+ readonly type: "generation-queued";
839
+ readonly position?: number | undefined;
840
+ } | {
841
+ readonly id: string;
842
+ readonly type: "generation-progress";
843
+ readonly progress?: number | undefined;
844
+ } | {
845
+ readonly type: "image-partial";
846
+ readonly index: number;
847
+ readonly image: Media.Asset;
848
+ } | {
635
849
  readonly type: "image";
636
850
  readonly index: number;
637
851
  readonly image: Media.Asset;
@@ -674,6 +888,21 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
674
888
  }[] | undefined;
675
889
  }, cases: Cases): Cases[keyof Cases] extends (value: any) => infer R ? import("effect/Unify").Unify<R> : never;
676
890
  <Cases extends {
891
+ "generation-queued": (value: {
892
+ readonly id: string;
893
+ readonly type: "generation-queued";
894
+ readonly position?: number | undefined;
895
+ }) => any;
896
+ "generation-progress": (value: {
897
+ readonly id: string;
898
+ readonly type: "generation-progress";
899
+ readonly progress?: number | undefined;
900
+ }) => any;
901
+ "image-partial": (value: {
902
+ readonly type: "image-partial";
903
+ readonly index: number;
904
+ readonly image: Media.Asset;
905
+ }) => any;
677
906
  image: (value: {
678
907
  readonly type: "image";
679
908
  readonly index: number;
@@ -718,6 +947,18 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
718
947
  }[] | undefined;
719
948
  }) => any;
720
949
  }>(cases: Cases): (value: {
950
+ readonly id: string;
951
+ readonly type: "generation-queued";
952
+ readonly position?: number | undefined;
953
+ } | {
954
+ readonly id: string;
955
+ readonly type: "generation-progress";
956
+ readonly progress?: number | undefined;
957
+ } | {
958
+ readonly type: "image-partial";
959
+ readonly index: number;
960
+ readonly image: Media.Asset;
961
+ } | {
721
962
  readonly type: "image";
722
963
  readonly index: number;
723
964
  readonly image: Media.Asset;
@@ -762,6 +1003,21 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
762
1003
  };
763
1004
  readonly matchOrElse: {
764
1005
  <Cases extends {
1006
+ "generation-queued"?: ((value: {
1007
+ readonly id: string;
1008
+ readonly type: "generation-queued";
1009
+ readonly position?: number | undefined;
1010
+ }) => any) | undefined;
1011
+ "generation-progress"?: ((value: {
1012
+ readonly id: string;
1013
+ readonly type: "generation-progress";
1014
+ readonly progress?: number | undefined;
1015
+ }) => any) | undefined;
1016
+ "image-partial"?: ((value: {
1017
+ readonly type: "image-partial";
1018
+ readonly index: number;
1019
+ readonly image: Media.Asset;
1020
+ }) => any) | undefined;
765
1021
  image?: ((value: {
766
1022
  readonly type: "image";
767
1023
  readonly index: number;
@@ -805,7 +1061,25 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
805
1061
  } | undefined;
806
1062
  }[] | undefined;
807
1063
  }) => any) | undefined;
808
- } & { [K in Exclude<keyof Cases, "image" | "finish">]: never; }, OrElse extends (value: Exclude<{
1064
+ } & { [K in Exclude<keyof Cases, "image" | "finish" | "generation-queued" | "generation-progress" | "image-partial">]: never; }, OrElse extends (value: Exclude<{
1065
+ readonly id: string;
1066
+ readonly type: "generation-queued";
1067
+ readonly position?: number | undefined;
1068
+ }, {
1069
+ readonly type: keyof Cases;
1070
+ }> | Exclude<{
1071
+ readonly id: string;
1072
+ readonly type: "generation-progress";
1073
+ readonly progress?: number | undefined;
1074
+ }, {
1075
+ readonly type: keyof Cases;
1076
+ }> | Exclude<{
1077
+ readonly type: "image-partial";
1078
+ readonly index: number;
1079
+ readonly image: Media.Asset;
1080
+ }, {
1081
+ readonly type: keyof Cases;
1082
+ }> | Exclude<{
809
1083
  readonly type: "image";
810
1084
  readonly index: number;
811
1085
  readonly image: Media.Asset;
@@ -851,6 +1125,18 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
851
1125
  }, {
852
1126
  readonly type: keyof Cases;
853
1127
  }>) => any>(value: {
1128
+ readonly id: string;
1129
+ readonly type: "generation-queued";
1130
+ readonly position?: number | undefined;
1131
+ } | {
1132
+ readonly id: string;
1133
+ readonly type: "generation-progress";
1134
+ readonly progress?: number | undefined;
1135
+ } | {
1136
+ readonly type: "image-partial";
1137
+ readonly index: number;
1138
+ readonly image: Media.Asset;
1139
+ } | {
854
1140
  readonly type: "image";
855
1141
  readonly index: number;
856
1142
  readonly image: Media.Asset;
@@ -893,6 +1179,21 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
893
1179
  }[] | undefined;
894
1180
  }, cases: Cases, orElse: OrElse): import("effect/Unify").Unify<{ [K_1 in keyof Cases]-?: NonNullable<Cases[K_1]> extends (...args: Array<any>) => infer R ? R : never; }[keyof Cases] | ReturnType<OrElse>>;
895
1181
  <Cases extends {
1182
+ "generation-queued"?: ((value: {
1183
+ readonly id: string;
1184
+ readonly type: "generation-queued";
1185
+ readonly position?: number | undefined;
1186
+ }) => any) | undefined;
1187
+ "generation-progress"?: ((value: {
1188
+ readonly id: string;
1189
+ readonly type: "generation-progress";
1190
+ readonly progress?: number | undefined;
1191
+ }) => any) | undefined;
1192
+ "image-partial"?: ((value: {
1193
+ readonly type: "image-partial";
1194
+ readonly index: number;
1195
+ readonly image: Media.Asset;
1196
+ }) => any) | undefined;
896
1197
  image?: ((value: {
897
1198
  readonly type: "image";
898
1199
  readonly index: number;
@@ -936,7 +1237,25 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
936
1237
  } | undefined;
937
1238
  }[] | undefined;
938
1239
  }) => any) | undefined;
939
- } & { [K in Exclude<keyof Cases, "image" | "finish">]: never; }, OrElse extends (value: Exclude<{
1240
+ } & { [K in Exclude<keyof Cases, "image" | "finish" | "generation-queued" | "generation-progress" | "image-partial">]: never; }, OrElse extends (value: Exclude<{
1241
+ readonly id: string;
1242
+ readonly type: "generation-queued";
1243
+ readonly position?: number | undefined;
1244
+ }, {
1245
+ readonly type: keyof Cases;
1246
+ }> | Exclude<{
1247
+ readonly id: string;
1248
+ readonly type: "generation-progress";
1249
+ readonly progress?: number | undefined;
1250
+ }, {
1251
+ readonly type: keyof Cases;
1252
+ }> | Exclude<{
1253
+ readonly type: "image-partial";
1254
+ readonly index: number;
1255
+ readonly image: Media.Asset;
1256
+ }, {
1257
+ readonly type: keyof Cases;
1258
+ }> | Exclude<{
940
1259
  readonly type: "image";
941
1260
  readonly index: number;
942
1261
  readonly image: Media.Asset;
@@ -982,6 +1301,18 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
982
1301
  }, {
983
1302
  readonly type: keyof Cases;
984
1303
  }>) => any>(cases: Cases, orElse: OrElse): (value: {
1304
+ readonly id: string;
1305
+ readonly type: "generation-queued";
1306
+ readonly position?: number | undefined;
1307
+ } | {
1308
+ readonly id: string;
1309
+ readonly type: "generation-progress";
1310
+ readonly progress?: number | undefined;
1311
+ } | {
1312
+ readonly type: "image-partial";
1313
+ readonly index: number;
1314
+ readonly image: Media.Asset;
1315
+ } | {
985
1316
  readonly type: "image";
986
1317
  readonly index: number;
987
1318
  readonly image: Media.Asset;
@@ -1026,6 +1357,21 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
1026
1357
  };
1027
1358
  } & {
1028
1359
  is: {
1360
+ generationQueued: (u: unknown) => u is {
1361
+ readonly id: string;
1362
+ readonly type: "generation-queued";
1363
+ readonly position?: number | undefined;
1364
+ };
1365
+ generationProgress: (u: unknown) => u is {
1366
+ readonly id: string;
1367
+ readonly type: "generation-progress";
1368
+ readonly progress?: number | undefined;
1369
+ };
1370
+ imagePartial: (u: unknown) => u is {
1371
+ readonly type: "image-partial";
1372
+ readonly index: number;
1373
+ readonly image: Media.Asset;
1374
+ };
1029
1375
  image: (u: unknown) => u is {
1030
1376
  readonly type: "image";
1031
1377
  readonly index: number;
@@ -1072,17 +1418,22 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
1072
1418
  };
1073
1419
  };
1074
1420
  export type ImageEvent = Schema.Schema.Type<typeof imageEventTagged>;
1075
- /** Inline routes produce every image at once; expand the response into the streaming event shape. */
1076
1421
  export declare const responseEvents: (response: ImageResponse) => ReadonlyArray<ImageEvent>;
1077
1422
  export declare function request<const Model extends ImageModel>(input: ImageRequestInput<Model>): ImageRequestFor<ImageModelOptions<Model>>;
1078
1423
  export declare function request(input: ImageRequest): ImageRequest;
1079
- export declare function generate<const Model extends ImageModel>(input: ImageRequestInput<Model>): Effect.Effect<ImageResponse, AIError, Service>;
1080
- export declare function generate(input: ImageRequest): Effect.Effect<ImageResponse, AIError, Service>;
1081
- export declare function stream<const Model extends ImageModel>(input: ImageRequestInput<Model>): Stream.Stream<ImageEvent, AIError, Service>;
1082
- export declare function stream(input: ImageRequest): Stream.Stream<ImageEvent, AIError, Service>;
1424
+ export declare function generate<const Model extends ImageModel>(input: ImageRequestInput<Model>, options?: AwaitOptions): Effect.Effect<ImageResponse, AIError, Service>;
1425
+ export declare function generate(input: ImageRequest, options?: AwaitOptions): Effect.Effect<ImageResponse, AIError, Service>;
1426
+ export declare function stream<const Model extends ImageModel>(input: ImageRequestInput<Model>, options?: AwaitOptions): Stream.Stream<ImageEvent, AIError, Service>;
1427
+ export declare function stream(input: ImageRequest, options?: AwaitOptions): Stream.Stream<ImageEvent, AIError, Service>;
1428
+ /** Inline and streaming routes fail with `UnsupportedOperation`. */
1429
+ export declare function start<const Model extends ImageModel>(input: ImageRequestInput<Model>): Effect.Effect<Generation<ImageResponse>, AIError, Service>;
1430
+ export declare function start(input: ImageRequest): Effect.Effect<Generation<ImageResponse>, AIError, Service>;
1431
+ export declare const resume: <Options extends ImageOptions>(model: ImageModel<Options>, token: unknown) => Effect.Effect<Generation<ImageResponse>, AIError, Service>;
1083
1432
  export declare const Image: {
1084
1433
  readonly request: typeof request;
1085
1434
  readonly generate: typeof generate;
1086
1435
  readonly stream: typeof stream;
1436
+ readonly start: typeof start;
1437
+ readonly resume: <Options extends ImageOptions>(model: ImageModel<Options>, token: unknown) => Effect.Effect<Generation<ImageResponse>, AIError, Service>;
1087
1438
  };
1088
1439
  export {};