@opencode/ai 2.2.5 → 2.2.7

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 (306) hide show
  1. package/README.md +228 -72
  2. package/dist/ai-client.d.ts +2 -2
  3. package/dist/ai-client.js +2 -1
  4. package/dist/cache-policy.d.ts +1 -1
  5. package/dist/cache-policy.js +16 -4
  6. package/dist/decision-client.d.ts +3 -3
  7. package/dist/decision.d.ts +30 -125
  8. package/dist/decision.js +27 -15
  9. package/dist/effect.d.ts +10 -15
  10. package/dist/effect.js +6 -6
  11. package/dist/effort-updates.d.ts +3 -3
  12. package/dist/effort-updates.js +2 -2
  13. package/dist/embedding-client.d.ts +21 -0
  14. package/dist/embedding-client.js +30 -0
  15. package/dist/embedding.d.ts +111 -0
  16. package/dist/embedding.js +75 -0
  17. package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
  18. package/dist/experimental/cloudflare-run-extraction.js +4 -1
  19. package/dist/experimental/extraction.d.ts +10 -40
  20. package/dist/experimental/extraction.js +14 -13
  21. package/dist/experimental.d.ts +8 -8
  22. package/dist/experimental.js +4 -4
  23. package/dist/generation.d.ts +0 -2
  24. package/dist/generation.js +2 -2
  25. package/dist/image-client.d.ts +13 -7
  26. package/dist/image-client.js +1 -1
  27. package/dist/image.d.ts +357 -465
  28. package/dist/image.js +17 -18
  29. package/dist/index.d.ts +35 -467
  30. package/dist/index.js +23 -17
  31. package/dist/llm.d.ts +65 -266
  32. package/dist/llm.js +101 -92
  33. package/dist/loop.d.ts +38 -0
  34. package/dist/loop.js +136 -0
  35. package/dist/media-model.d.ts +1 -1
  36. package/dist/media-model.js +8 -6
  37. package/dist/media.d.ts +9 -0
  38. package/dist/media.js +37 -2
  39. package/dist/protocols/alibaba-chat.d.ts +9 -1
  40. package/dist/protocols/alibaba-chat.js +3 -3
  41. package/dist/protocols/alibaba-images.d.ts +2 -2
  42. package/dist/protocols/alibaba-messages.js +3 -3
  43. package/dist/protocols/alibaba-responses.js +8 -20
  44. package/dist/protocols/anthropic-messages.d.ts +1 -1
  45. package/dist/protocols/anthropic-messages.js +57 -176
  46. package/dist/protocols/assemblyai-transcription.d.ts +2 -2
  47. package/dist/protocols/bedrock-converse.js +10 -16
  48. package/dist/protocols/cartesia-speech.d.ts +2 -2
  49. package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
  50. package/dist/protocols/cohere-chat.js +9 -12
  51. package/dist/protocols/deepgram-speech.d.ts +2 -2
  52. package/dist/protocols/deepgram-transcription.d.ts +2 -2
  53. package/dist/protocols/elevenlabs-speech.d.ts +2 -2
  54. package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
  55. package/dist/protocols/gemini.d.ts +3 -0
  56. package/dist/protocols/gemini.js +54 -72
  57. package/dist/protocols/google-embed-content.d.ts +34 -0
  58. package/dist/protocols/google-embed-content.js +110 -0
  59. package/dist/protocols/google-images.d.ts +2 -2
  60. package/dist/protocols/google-interactions.d.ts +3 -4
  61. package/dist/protocols/google-interactions.js +44 -30
  62. package/dist/protocols/google-speech.d.ts +2 -2
  63. package/dist/protocols/google-transcription.d.ts +2 -2
  64. package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
  65. package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
  66. package/dist/protocols/google-video.d.ts +2 -2
  67. package/dist/protocols/index.d.ts +3 -0
  68. package/dist/protocols/index.js +3 -0
  69. package/dist/protocols/meta-images.d.ts +2 -2
  70. package/dist/protocols/meta-responses.js +26 -23
  71. package/dist/protocols/minimax-images.d.ts +2 -2
  72. package/dist/protocols/mistral-chat.js +7 -10
  73. package/dist/protocols/open-responses-channel.js +6 -19
  74. package/dist/protocols/open-responses-continuation.d.ts +1 -5
  75. package/dist/protocols/open-responses-continuation.js +1 -3
  76. package/dist/protocols/open-responses.d.ts +2 -22
  77. package/dist/protocols/open-responses.js +41 -23
  78. package/dist/protocols/openai-chat.d.ts +27 -23
  79. package/dist/protocols/openai-chat.js +62 -57
  80. package/dist/protocols/openai-compatible-chat.d.ts +2 -1
  81. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  82. package/dist/protocols/openai-compatible-responses.js +1 -1
  83. package/dist/protocols/openai-decisions.js +15 -2
  84. package/dist/protocols/openai-embeddings.d.ts +16 -0
  85. package/dist/protocols/openai-embeddings.js +76 -0
  86. package/dist/protocols/openai-images.d.ts +2 -2
  87. package/dist/protocols/openai-responses.js +10 -29
  88. package/dist/protocols/openai-speech.d.ts +2 -2
  89. package/dist/protocols/openai-transcription.d.ts +2 -2
  90. package/dist/protocols/runway-video.d.ts +2 -2
  91. package/dist/protocols/shared.d.ts +14 -7
  92. package/dist/protocols/shared.js +40 -15
  93. package/dist/protocols/system-one.d.ts +4 -4
  94. package/dist/protocols/system-one.js +8 -1
  95. package/dist/protocols/utils/bedrock-cache.js +2 -5
  96. package/dist/protocols/utils/bedrock-media.d.ts +0 -3
  97. package/dist/protocols/utils/cache.d.ts +3 -0
  98. package/dist/protocols/utils/cache.js +15 -2
  99. package/dist/protocols/utils/image-sizing.d.ts +1 -1
  100. package/dist/protocols/utils/responses-checkpoint.js +1 -1
  101. package/dist/protocols/utils/responses-compaction.d.ts +1 -1
  102. package/dist/protocols/utils/responses-compaction.js +6 -5
  103. package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
  104. package/dist/protocols/utils/responses-hosted-tools.js +31 -0
  105. package/dist/protocols/utils/tool-stream.d.ts +5 -271
  106. package/dist/protocols/utils/tool-stream.js +3 -13
  107. package/dist/protocols/venice-chat.d.ts +7 -1
  108. package/dist/protocols/venice-chat.js +4 -4
  109. package/dist/protocols/xai-images.d.ts +2 -2
  110. package/dist/protocols/xai-responses.js +5 -25
  111. package/dist/protocols/xai-video.d.ts +2 -2
  112. package/dist/protocols/zai-chat.d.ts +9 -1
  113. package/dist/protocols/zai-chat.js +1 -1
  114. package/dist/protocols/zai-images.d.ts +2 -2
  115. package/dist/protocols/zai-messages.js +3 -3
  116. package/dist/provider-error.d.ts +0 -1
  117. package/dist/provider-error.js +7 -80
  118. package/dist/providers/alibaba/embeddings.d.ts +2 -0
  119. package/dist/providers/alibaba/embeddings.js +1 -0
  120. package/dist/providers/alibaba.d.ts +70 -4
  121. package/dist/providers/alibaba.js +20 -2
  122. package/dist/providers/amazon-bedrock-mantle.d.ts +7 -3
  123. package/dist/providers/amazon-bedrock-mantle.js +6 -3
  124. package/dist/providers/amazon-bedrock.d.ts +6 -7
  125. package/dist/providers/amazon-bedrock.js +1 -1
  126. package/dist/providers/anthropic-compatible.d.ts +7 -8
  127. package/dist/providers/anthropic-compatible.js +2 -5
  128. package/dist/providers/anthropic.d.ts +8 -9
  129. package/dist/providers/anthropic.js +2 -7
  130. package/dist/providers/assemblyai.d.ts +2 -2
  131. package/dist/providers/assemblyai.js +2 -7
  132. package/dist/providers/azure/embeddings.d.ts +2 -0
  133. package/dist/providers/azure/embeddings.js +1 -0
  134. package/dist/providers/azure/messages.d.ts +2 -0
  135. package/dist/providers/azure/messages.js +1 -0
  136. package/dist/providers/azure.d.ts +325 -7
  137. package/dist/providers/azure.js +40 -9
  138. package/dist/providers/baseten.d.ts +7 -5
  139. package/dist/providers/baseten.js +7 -21
  140. package/dist/providers/cartesia.d.ts +1 -1
  141. package/dist/providers/cerebras.d.ts +7 -5
  142. package/dist/providers/cerebras.js +4 -15
  143. package/dist/providers/cloudflare-ai-gateway.d.ts +23 -13
  144. package/dist/providers/cloudflare-ai-gateway.js +28 -40
  145. package/dist/providers/cloudflare-shared.d.ts +9 -0
  146. package/dist/providers/cloudflare-shared.js +25 -0
  147. package/dist/providers/cloudflare-workers-ai.d.ts +6 -4
  148. package/dist/providers/cloudflare-workers-ai.js +4 -20
  149. package/dist/providers/cohere/chat.js +2 -7
  150. package/dist/providers/cohere/embeddings.d.ts +2 -0
  151. package/dist/providers/cohere/embeddings.js +1 -0
  152. package/dist/providers/cohere.d.ts +14 -5
  153. package/dist/providers/cohere.js +23 -13
  154. package/dist/providers/deepgram.d.ts +2 -2
  155. package/dist/providers/deepgram.js +2 -7
  156. package/dist/providers/deepinfra/embeddings.d.ts +2 -0
  157. package/dist/providers/deepinfra/embeddings.js +1 -0
  158. package/dist/providers/deepinfra.d.ts +10 -5
  159. package/dist/providers/deepinfra.js +20 -14
  160. package/dist/providers/deepseek.d.ts +7 -5
  161. package/dist/providers/deepseek.js +3 -14
  162. package/dist/providers/digitalocean/embeddings.d.ts +2 -0
  163. package/dist/providers/digitalocean/embeddings.js +1 -0
  164. package/dist/providers/digitalocean.d.ts +18 -5
  165. package/dist/providers/digitalocean.js +28 -14
  166. package/dist/providers/elevenlabs.d.ts +2 -2
  167. package/dist/providers/elevenlabs.js +2 -7
  168. package/dist/providers/fireworks/embeddings.d.ts +2 -0
  169. package/dist/providers/fireworks/embeddings.js +1 -0
  170. package/dist/providers/fireworks.d.ts +10 -5
  171. package/dist/providers/fireworks.js +17 -14
  172. package/dist/providers/google/embeddings.d.ts +2 -0
  173. package/dist/providers/google/embeddings.js +1 -0
  174. package/dist/providers/google/interactions.d.ts +1 -1
  175. package/dist/providers/google/interactions.js +2 -7
  176. package/dist/providers/google-vertex/embeddings.d.ts +2 -0
  177. package/dist/providers/google-vertex/embeddings.js +1 -0
  178. package/dist/providers/google-vertex-chat.d.ts +4 -3
  179. package/dist/providers/google-vertex-chat.js +3 -29
  180. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  181. package/dist/providers/google-vertex-messages.d.ts +3 -3
  182. package/dist/providers/google-vertex-messages.js +3 -29
  183. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  184. package/dist/providers/google-vertex-mistral.js +3 -29
  185. package/dist/providers/google-vertex-responses.d.ts +3 -3
  186. package/dist/providers/google-vertex-responses.js +4 -30
  187. package/dist/providers/google-vertex-shared.d.ts +31 -0
  188. package/dist/providers/google-vertex-shared.js +25 -0
  189. package/dist/providers/google-vertex.d.ts +10 -3
  190. package/dist/providers/google-vertex.js +52 -0
  191. package/dist/providers/google.d.ts +21 -13
  192. package/dist/providers/google.js +23 -19
  193. package/dist/providers/groq.d.ts +10 -5
  194. package/dist/providers/groq.js +4 -15
  195. package/dist/providers/meta.d.ts +6 -5
  196. package/dist/providers/meta.js +10 -23
  197. package/dist/providers/minimax/chat.js +2 -7
  198. package/dist/providers/minimax/responses.js +2 -7
  199. package/dist/providers/minimax.d.ts +6 -5
  200. package/dist/providers/minimax.js +7 -22
  201. package/dist/providers/mistral.d.ts +10 -11
  202. package/dist/providers/mistral.js +3 -14
  203. package/dist/providers/moonshot/messages.js +2 -7
  204. package/dist/providers/moonshot/responses.js +2 -7
  205. package/dist/providers/moonshot.d.ts +6 -5
  206. package/dist/providers/moonshot.js +4 -16
  207. package/dist/providers/openai/embeddings.d.ts +2 -0
  208. package/dist/providers/openai/embeddings.js +1 -0
  209. package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
  210. package/dist/providers/openai-compatible/embeddings.js +1 -0
  211. package/dist/providers/openai-compatible-responses.d.ts +6 -7
  212. package/dist/providers/openai-compatible-responses.js +2 -8
  213. package/dist/providers/openai-compatible.d.ts +10 -7
  214. package/dist/providers/openai-compatible.js +17 -10
  215. package/dist/providers/openai.d.ts +11 -4
  216. package/dist/providers/openai.js +17 -3
  217. package/dist/providers/opencode.d.ts +4 -4
  218. package/dist/providers/opencode.js +6 -2
  219. package/dist/providers/openrouter/embeddings.d.ts +2 -0
  220. package/dist/providers/openrouter/embeddings.js +1 -0
  221. package/dist/providers/openrouter.d.ts +24 -5
  222. package/dist/providers/openrouter.js +31 -24
  223. package/dist/providers/runway.d.ts +1 -1
  224. package/dist/providers/settings.d.ts +40 -0
  225. package/dist/providers/settings.js +19 -0
  226. package/dist/providers/togetherai.d.ts +7 -5
  227. package/dist/providers/togetherai.js +5 -15
  228. package/dist/providers/typesafe-ai.d.ts +4 -4
  229. package/dist/providers/typesafe-ai.js +6 -2
  230. package/dist/providers/venice.d.ts +5 -4
  231. package/dist/providers/venice.js +6 -2
  232. package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
  233. package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
  234. package/dist/providers/vercel-ai-gateway.d.ts +9 -5
  235. package/dist/providers/vercel-ai-gateway.js +30 -29
  236. package/dist/providers/xai.d.ts +5 -4
  237. package/dist/providers/xai.js +4 -12
  238. package/dist/providers/zai-coding-plan/messages.js +2 -7
  239. package/dist/providers/zai-coding-plan/responses.js +2 -7
  240. package/dist/providers/zai-coding-plan.d.ts +6 -5
  241. package/dist/providers/zai-coding-plan.js +8 -15
  242. package/dist/providers/zai.d.ts +6 -5
  243. package/dist/providers/zai.js +10 -22
  244. package/dist/public.d.ts +14 -0
  245. package/dist/public.js +6 -0
  246. package/dist/route/auth-options.d.ts +9 -5
  247. package/dist/route/auth-options.js +10 -7
  248. package/dist/route/client.d.ts +50 -37
  249. package/dist/route/client.js +42 -53
  250. package/dist/route/decision.d.ts +8 -8
  251. package/dist/route/decision.js +3 -3
  252. package/dist/route/embedding.d.ts +61 -0
  253. package/dist/route/embedding.js +88 -0
  254. package/dist/route/executor.d.ts +5 -0
  255. package/dist/route/executor.js +10 -0
  256. package/dist/route/index.d.ts +5 -7
  257. package/dist/route/index.js +1 -1
  258. package/dist/route/media.d.ts +7 -11
  259. package/dist/route/media.js +22 -26
  260. package/dist/route/transport/http.js +6 -5
  261. package/dist/route/transport/websocket.js +7 -1
  262. package/dist/schema/errors.d.ts +16 -17
  263. package/dist/schema/errors.js +63 -12
  264. package/dist/schema/events.d.ts +2563 -2954
  265. package/dist/schema/events.js +54 -109
  266. package/dist/schema/messages.d.ts +194 -137
  267. package/dist/schema/messages.js +66 -83
  268. package/dist/schema/options.d.ts +112 -65
  269. package/dist/schema/options.js +52 -101
  270. package/dist/speech-client.d.ts +7 -7
  271. package/dist/speech.d.ts +306 -316
  272. package/dist/speech.js +16 -14
  273. package/dist/testing.d.ts +31 -175
  274. package/dist/testing.js +60 -5
  275. package/dist/tool-history.d.ts +1 -1
  276. package/dist/tool-history.js +3 -10
  277. package/dist/tool-runtime.d.ts +9 -2
  278. package/dist/tool-runtime.js +17 -31
  279. package/dist/tool.d.ts +39 -43
  280. package/dist/tool.js +16 -26
  281. package/dist/transcription-client.d.ts +7 -7
  282. package/dist/transcription.d.ts +314 -265
  283. package/dist/transcription.js +16 -14
  284. package/dist/utils/provider-codes.d.ts +3 -0
  285. package/dist/utils/provider-codes.js +41 -0
  286. package/dist/video-client.d.ts +7 -7
  287. package/dist/video-client.js +1 -1
  288. package/dist/video.d.ts +269 -287
  289. package/dist/video.js +16 -14
  290. package/package.json +309 -257
  291. package/dist/experimental/testing.d.ts +0 -3
  292. package/dist/experimental/testing.js +0 -3
  293. package/dist/testing/decision.d.ts +0 -16
  294. package/dist/testing/decision.js +0 -20
  295. package/dist/testing/image.d.ts +0 -14
  296. package/dist/testing/image.js +0 -12
  297. package/dist/testing/media.d.ts +0 -18
  298. package/dist/testing/media.js +0 -36
  299. package/dist/testing/script.d.ts +0 -28
  300. package/dist/testing/script.js +0 -60
  301. package/dist/testing/speech.d.ts +0 -14
  302. package/dist/testing/speech.js +0 -12
  303. package/dist/testing/transcription.d.ts +0 -14
  304. package/dist/testing/transcription.js +0 -12
  305. package/dist/testing/video.d.ts +0 -14
  306. package/dist/testing/video.js +0 -12
package/dist/image.d.ts CHANGED
@@ -3,16 +3,16 @@ import { Generation, type AwaitOptions } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
6
- import { AIError, HttpOptions, type OpenString } from "./schema/index.js";
6
+ import { AIError, type OpenString, type BaseRequest } from "./schema/index.js";
7
7
  import { Service } from "./image-client.js";
8
8
  export type ImageOptions = MediaModel.Options;
9
- export type ImageRoute = MediaRoute.AnyRoute<ImageRequestFor, ImageEvent, ImageResponse>;
9
+ export type ImageRoute = MediaRoute.AnyRoute<ImageRequest, ImageEvent, ImageResponse>;
10
10
  export declare class ImageModel<Options extends ImageOptions = ImageOptions> extends MediaModel<ImageRoute, Options> {
11
11
  protected readonly _ImageModel: void;
12
12
  /** The number of type arguments selects the kind: `<Options>`, `<Options, Frame, State>`, or `<Options, Token>`. */
13
- static fromRoute<Options extends ImageOptions>(route: MediaModel.InlineRouteInput<ImageRequestFor<Options>, ImageResponse>, input: MediaRoute.ModelInput): ImageModel<Options>;
14
- static fromRoute<Options extends ImageOptions, Frame, State>(route: MediaModel.StreamRouteInput<ImageRequestFor<Options>, ImageEvent, Frame, State>, input: MediaRoute.ModelInput): ImageModel<Options>;
15
- static fromRoute<Options extends ImageOptions, Token>(route: MediaModel.QueuedRouteInput<ImageRequestFor<Options>, ImageResponse, Token>, input: MediaRoute.ModelInput): ImageModel<Options>;
13
+ static fromRoute<Options extends ImageOptions>(route: MediaModel.InlineRouteInput<ImageRequest<ImageModel<Options>>, ImageResponse>, input: MediaRoute.ModelInput): ImageModel<Options>;
14
+ static fromRoute<Options extends ImageOptions, Frame, State>(route: MediaModel.StreamRouteInput<ImageRequest<ImageModel<Options>>, ImageEvent, Frame, State>, input: MediaRoute.ModelInput): ImageModel<Options>;
15
+ static fromRoute<Options extends ImageOptions, Token>(route: MediaModel.QueuedRouteInput<ImageRequest<ImageModel<Options>>, ImageResponse, Token>, input: MediaRoute.ModelInput): ImageModel<Options>;
16
16
  }
17
17
  export declare const ImageModelSchema: Schema.declare<ImageModel<{
18
18
  readonly [x: string]: unknown;
@@ -23,64 +23,21 @@ export type ImageAspectRatio = Media.AspectRatio;
23
23
  export declare const ImageAspectRatio: Schema.declare<`${number}:${number}`, `${number}:${number}`>;
24
24
  /** Size tier: `1K` is about as many pixels as 1024×1024 at the requested aspect, `2K` as 2048×2048. */
25
25
  export type ImageResolution = OpenString<"1K" | "2K" | "4K">;
26
- declare const ImageRequest_base: Schema.Class<ImageRequest, Schema.Struct<{
27
- readonly model: Schema.declare<ImageModel<{
28
- readonly [x: string]: unknown;
29
- }>, ImageModel<{
30
- readonly [x: string]: unknown;
31
- }>>;
32
- readonly prompt: Schema.String;
26
+ /** A normalized image request, the plain object `ai.image.request(...)` returns. */
27
+ export interface ImageRequest<Model extends ImageModel = ImageModel> extends BaseRequest<Model, ImageModelOptions<Model>> {
28
+ readonly prompt: string;
33
29
  /** Edit sources or style/subject references, in order. */
34
- readonly images: Schema.optional<Schema.$Array<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
35
- readonly source: Schema.Union<readonly [Schema.Struct<{
36
- readonly type: Schema.Literal<"bytes">;
37
- readonly data: Schema.Uint8Array;
38
- readonly mediaType: Schema.String;
39
- }>, Schema.Struct<{
40
- readonly type: Schema.Literal<"base64">;
41
- readonly data: Schema.String;
42
- readonly mediaType: Schema.String;
43
- }>, Schema.Struct<{
44
- readonly type: Schema.Literal<"url">;
45
- readonly url: Schema.String;
46
- readonly mediaType: Schema.optional<Schema.String>;
47
- readonly expiresAt: Schema.optional<Schema.Number>;
48
- }>, Schema.Struct<{
49
- readonly type: Schema.Literal<"ref">;
50
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
51
- readonly id: Schema.String;
52
- readonly mediaType: Schema.optional<Schema.String>;
53
- }>]>;
54
- readonly info: Schema.optional<Schema.Struct<{
55
- readonly width: Schema.optional<Schema.Number>;
56
- readonly height: Schema.optional<Schema.Number>;
57
- readonly durationSeconds: Schema.optional<Schema.Number>;
58
- readonly sampleRate: Schema.optional<Schema.Number>;
59
- readonly channels: Schema.optional<Schema.Number>;
60
- readonly encoding: Schema.optional<Schema.String>;
61
- readonly format: Schema.optional<Schema.String>;
62
- }>>;
63
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
64
- }>, never, never>>>;
65
- readonly n: Schema.optional<Schema.Int>;
66
- readonly aspect: Schema.optional<Schema.declare<`${number}:${number}`, `${number}:${number}`>>;
67
- readonly resolution: Schema.optional<Schema.String>;
68
- readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
69
- readonly http: Schema.optional<typeof HttpOptions>;
70
- }>, {}>;
71
- export declare class ImageRequest extends ImageRequest_base {
72
- protected readonly _ImageRequest: void;
30
+ readonly images?: ReadonlyArray<Media.Asset>;
31
+ readonly n?: number;
32
+ readonly aspect?: ImageAspectRatio;
33
+ readonly resolution?: ImageResolution;
73
34
  }
74
- export type ImageRequestFor<Options extends ImageOptions = ImageOptions> = Omit<ImageRequest, "model" | "providerOptions"> & {
75
- readonly model: ImageModel<Options>;
76
- readonly providerOptions?: Options;
77
- };
78
35
  export type ImageModelOptions<Model> = Model extends ImageModel<infer Options> ? Options : never;
79
- export type ImageRequestInput<Model extends ImageModel = ImageModel> = Omit<ConstructorParameters<typeof ImageRequest>[0], "model" | "providerOptions" | "http" | "resolution"> & {
80
- readonly model: Model;
81
- readonly resolution?: ImageResolution;
36
+ /** Input accepted by `ai.image.request`, `generate`, `stream` and `start`. An `ImageRequest` is also a valid input. */
37
+ export type ImageRequestInput<Model extends ImageModel = ImageModel> = Omit<ImageRequest<Model>, "images" | "providerOptions"> & {
38
+ /** Edit sources or style/subject references, in order: assets or plain data with a detectable type. */
39
+ readonly images?: ReadonlyArray<Media.Input>;
82
40
  readonly providerOptions?: NoInfer<ImageModelOptions<Model>>;
83
- readonly http?: HttpOptions.Input;
84
41
  };
85
42
  declare const ImageResponse_base: Schema.Class<ImageResponse, Schema.Struct<{
86
43
  readonly images: Schema.$Array<Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
@@ -136,7 +93,6 @@ declare const ImageResponse_base: Schema.Class<ImageResponse, Schema.Struct<{
136
93
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
137
94
  }>, {}>;
138
95
  export declare class ImageResponse extends ImageResponse_base {
139
- get image(): Media.Asset;
140
96
  }
141
97
  /** The `index`-th lower-fidelity preview of an image still generating; the `image` event supersedes it. */
142
98
  export declare const ImagePartialEvent: Schema.Struct<{
@@ -688,105 +644,111 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
688
644
  };
689
645
  };
690
646
  readonly match: {
691
- <Cases extends { [M in Schema.Struct<{
692
- readonly type: Schema.tag<"generation-queued">;
693
- readonly id: Schema.String;
694
- readonly position: Schema.optional<Schema.Number>;
695
- }> | Schema.Struct<{
696
- readonly type: Schema.tag<"generation-progress">;
697
- readonly id: Schema.String;
698
- readonly progress: Schema.optional<Schema.Number>;
699
- }> | Schema.Struct<{
700
- readonly type: Schema.tag<"image-partial">;
701
- readonly index: Schema.Number;
702
- readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
703
- readonly source: Schema.Union<readonly [Schema.Struct<{
704
- readonly type: Schema.Literal<"bytes">;
705
- readonly data: Schema.Uint8Array;
706
- readonly mediaType: Schema.String;
707
- }>, Schema.Struct<{
708
- readonly type: Schema.Literal<"base64">;
709
- readonly data: Schema.String;
710
- readonly mediaType: Schema.String;
711
- }>, Schema.Struct<{
712
- readonly type: Schema.Literal<"url">;
713
- readonly url: Schema.String;
714
- readonly mediaType: Schema.optional<Schema.String>;
715
- readonly expiresAt: Schema.optional<Schema.Number>;
647
+ <Handlers extends { [K in "finish" | "generation-progress" | "generation-queued" | "image" | "image-partial"]: (value: {
648
+ readonly finish: Schema.Struct<{
649
+ readonly type: Schema.tag<"finish">;
650
+ readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
651
+ readonly type: Schema.Literal<"tokens">;
652
+ readonly input: Schema.optional<Schema.Number>;
653
+ readonly output: Schema.optional<Schema.Number>;
654
+ readonly total: Schema.optional<Schema.Number>;
655
+ readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
716
656
  }>, Schema.Struct<{
717
- readonly type: Schema.Literal<"ref">;
718
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
719
- readonly id: Schema.String;
720
- readonly mediaType: Schema.optional<Schema.String>;
721
- }>]>;
722
- readonly info: Schema.optional<Schema.Struct<{
723
- readonly width: Schema.optional<Schema.Number>;
724
- readonly height: Schema.optional<Schema.Number>;
725
- readonly durationSeconds: Schema.optional<Schema.Number>;
726
- readonly sampleRate: Schema.optional<Schema.Number>;
727
- readonly channels: Schema.optional<Schema.Number>;
728
- readonly encoding: Schema.optional<Schema.String>;
729
- readonly format: Schema.optional<Schema.String>;
730
- }>>;
731
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
732
- }>, never, never>;
733
- }> | Schema.Struct<{
734
- readonly type: Schema.tag<"image">;
735
- readonly index: Schema.Number;
736
- readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
737
- readonly source: Schema.Union<readonly [Schema.Struct<{
738
- readonly type: Schema.Literal<"bytes">;
739
- readonly data: Schema.Uint8Array;
740
- readonly mediaType: Schema.String;
657
+ readonly type: Schema.Literal<"seconds">;
658
+ readonly seconds: Schema.Number;
741
659
  }>, Schema.Struct<{
742
- readonly type: Schema.Literal<"base64">;
743
- readonly data: Schema.String;
744
- readonly mediaType: Schema.String;
660
+ readonly type: Schema.Literal<"characters">;
661
+ readonly characters: Schema.Number;
745
662
  }>, Schema.Struct<{
746
- readonly type: Schema.Literal<"url">;
747
- readonly url: Schema.String;
748
- readonly mediaType: Schema.optional<Schema.String>;
749
- readonly expiresAt: Schema.optional<Schema.Number>;
663
+ readonly type: Schema.Literal<"credits">;
664
+ readonly credits: Schema.Number;
750
665
  }>, Schema.Struct<{
751
- readonly type: Schema.Literal<"ref">;
752
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
753
- readonly id: Schema.String;
754
- readonly mediaType: Schema.optional<Schema.String>;
755
- }>]>;
756
- readonly info: Schema.optional<Schema.Struct<{
757
- readonly width: Schema.optional<Schema.Number>;
758
- readonly height: Schema.optional<Schema.Number>;
759
- readonly durationSeconds: Schema.optional<Schema.Number>;
760
- readonly sampleRate: Schema.optional<Schema.Number>;
761
- readonly channels: Schema.optional<Schema.Number>;
762
- readonly encoding: Schema.optional<Schema.String>;
763
- readonly format: Schema.optional<Schema.String>;
764
- }>>;
666
+ readonly type: Schema.Literal<"compute">;
667
+ readonly seconds: Schema.Number;
668
+ }>]>>;
765
669
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
766
- }>, never, never>;
767
- }> | Schema.Struct<{
768
- readonly type: Schema.tag<"finish">;
769
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
770
- readonly type: Schema.Literal<"tokens">;
771
- readonly input: Schema.optional<Schema.Number>;
772
- readonly output: Schema.optional<Schema.Number>;
773
- readonly total: Schema.optional<Schema.Number>;
774
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
775
- }>, Schema.Struct<{
776
- readonly type: Schema.Literal<"seconds">;
777
- readonly seconds: Schema.Number;
778
- }>, Schema.Struct<{
779
- readonly type: Schema.Literal<"characters">;
780
- readonly characters: Schema.Number;
781
- }>, Schema.Struct<{
782
- readonly type: Schema.Literal<"credits">;
783
- readonly credits: Schema.Number;
784
- }>, Schema.Struct<{
785
- readonly type: Schema.Literal<"compute">;
786
- readonly seconds: Schema.Number;
787
- }>]>>;
788
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
789
- }> as M["Type"]["type"]]: (value: M["Type"]) => any; }>(value: {
670
+ }>;
671
+ readonly "generation-progress": Schema.Struct<{
672
+ readonly type: Schema.tag<"generation-progress">;
673
+ readonly id: Schema.String;
674
+ readonly progress: Schema.optional<Schema.Number>;
675
+ }>;
676
+ readonly "generation-queued": Schema.Struct<{
677
+ readonly type: Schema.tag<"generation-queued">;
678
+ readonly id: Schema.String;
679
+ readonly position: Schema.optional<Schema.Number>;
680
+ }>;
681
+ readonly image: Schema.Struct<{
682
+ readonly type: Schema.tag<"image">;
683
+ readonly index: Schema.Number;
684
+ readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
685
+ readonly source: Schema.Union<readonly [Schema.Struct<{
686
+ readonly type: Schema.Literal<"bytes">;
687
+ readonly data: Schema.Uint8Array;
688
+ readonly mediaType: Schema.String;
689
+ }>, Schema.Struct<{
690
+ readonly type: Schema.Literal<"base64">;
691
+ readonly data: Schema.String;
692
+ readonly mediaType: Schema.String;
693
+ }>, Schema.Struct<{
694
+ readonly type: Schema.Literal<"url">;
695
+ readonly url: Schema.String;
696
+ readonly mediaType: Schema.optional<Schema.String>;
697
+ readonly expiresAt: Schema.optional<Schema.Number>;
698
+ }>, Schema.Struct<{
699
+ readonly type: Schema.Literal<"ref">;
700
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
701
+ readonly id: Schema.String;
702
+ readonly mediaType: Schema.optional<Schema.String>;
703
+ }>]>;
704
+ readonly info: Schema.optional<Schema.Struct<{
705
+ readonly width: Schema.optional<Schema.Number>;
706
+ readonly height: Schema.optional<Schema.Number>;
707
+ readonly durationSeconds: Schema.optional<Schema.Number>;
708
+ readonly sampleRate: Schema.optional<Schema.Number>;
709
+ readonly channels: Schema.optional<Schema.Number>;
710
+ readonly encoding: Schema.optional<Schema.String>;
711
+ readonly format: Schema.optional<Schema.String>;
712
+ }>>;
713
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
714
+ }>, never, never>;
715
+ }>;
716
+ readonly "image-partial": Schema.Struct<{
717
+ readonly type: Schema.tag<"image-partial">;
718
+ readonly index: Schema.Number;
719
+ readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
720
+ readonly source: Schema.Union<readonly [Schema.Struct<{
721
+ readonly type: Schema.Literal<"bytes">;
722
+ readonly data: Schema.Uint8Array;
723
+ readonly mediaType: Schema.String;
724
+ }>, Schema.Struct<{
725
+ readonly type: Schema.Literal<"base64">;
726
+ readonly data: Schema.String;
727
+ readonly mediaType: Schema.String;
728
+ }>, Schema.Struct<{
729
+ readonly type: Schema.Literal<"url">;
730
+ readonly url: Schema.String;
731
+ readonly mediaType: Schema.optional<Schema.String>;
732
+ readonly expiresAt: Schema.optional<Schema.Number>;
733
+ }>, Schema.Struct<{
734
+ readonly type: Schema.Literal<"ref">;
735
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
736
+ readonly id: Schema.String;
737
+ readonly mediaType: Schema.optional<Schema.String>;
738
+ }>]>;
739
+ readonly info: Schema.optional<Schema.Struct<{
740
+ readonly width: Schema.optional<Schema.Number>;
741
+ readonly height: Schema.optional<Schema.Number>;
742
+ readonly durationSeconds: Schema.optional<Schema.Number>;
743
+ readonly sampleRate: Schema.optional<Schema.Number>;
744
+ readonly channels: Schema.optional<Schema.Number>;
745
+ readonly encoding: Schema.optional<Schema.String>;
746
+ readonly format: Schema.optional<Schema.String>;
747
+ }>>;
748
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
749
+ }>, never, never>;
750
+ }>;
751
+ }[K]["Type"]) => any; }>(value: {
790
752
  readonly type: "image-partial";
791
753
  readonly index: number;
792
754
  readonly image: Media.Asset;
@@ -830,106 +792,112 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
830
792
  readonly [x: string]: unknown;
831
793
  };
832
794
  } | undefined;
833
- }, cases: Cases): Cases[keyof Cases] extends (value: any) => infer R ? import("effect/Unify").Unify<R> : never;
834
- <Cases extends { [M in Schema.Struct<{
835
- readonly type: Schema.tag<"generation-queued">;
836
- readonly id: Schema.String;
837
- readonly position: Schema.optional<Schema.Number>;
838
- }> | Schema.Struct<{
839
- readonly type: Schema.tag<"generation-progress">;
840
- readonly id: Schema.String;
841
- readonly progress: Schema.optional<Schema.Number>;
842
- }> | Schema.Struct<{
843
- readonly type: Schema.tag<"image-partial">;
844
- readonly index: Schema.Number;
845
- readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
846
- readonly source: Schema.Union<readonly [Schema.Struct<{
847
- readonly type: Schema.Literal<"bytes">;
848
- readonly data: Schema.Uint8Array;
849
- readonly mediaType: Schema.String;
795
+ }, cases: Handlers): import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "generation-queued" | "image" | "image-partial"]>>;
796
+ <Handlers extends { [K in "finish" | "generation-progress" | "generation-queued" | "image" | "image-partial"]: (value: {
797
+ readonly finish: Schema.Struct<{
798
+ readonly type: Schema.tag<"finish">;
799
+ readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
800
+ readonly type: Schema.Literal<"tokens">;
801
+ readonly input: Schema.optional<Schema.Number>;
802
+ readonly output: Schema.optional<Schema.Number>;
803
+ readonly total: Schema.optional<Schema.Number>;
804
+ readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
850
805
  }>, Schema.Struct<{
851
- readonly type: Schema.Literal<"base64">;
852
- readonly data: Schema.String;
853
- readonly mediaType: Schema.String;
854
- }>, Schema.Struct<{
855
- readonly type: Schema.Literal<"url">;
856
- readonly url: Schema.String;
857
- readonly mediaType: Schema.optional<Schema.String>;
858
- readonly expiresAt: Schema.optional<Schema.Number>;
859
- }>, Schema.Struct<{
860
- readonly type: Schema.Literal<"ref">;
861
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
862
- readonly id: Schema.String;
863
- readonly mediaType: Schema.optional<Schema.String>;
864
- }>]>;
865
- readonly info: Schema.optional<Schema.Struct<{
866
- readonly width: Schema.optional<Schema.Number>;
867
- readonly height: Schema.optional<Schema.Number>;
868
- readonly durationSeconds: Schema.optional<Schema.Number>;
869
- readonly sampleRate: Schema.optional<Schema.Number>;
870
- readonly channels: Schema.optional<Schema.Number>;
871
- readonly encoding: Schema.optional<Schema.String>;
872
- readonly format: Schema.optional<Schema.String>;
873
- }>>;
874
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
875
- }>, never, never>;
876
- }> | Schema.Struct<{
877
- readonly type: Schema.tag<"image">;
878
- readonly index: Schema.Number;
879
- readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
880
- readonly source: Schema.Union<readonly [Schema.Struct<{
881
- readonly type: Schema.Literal<"bytes">;
882
- readonly data: Schema.Uint8Array;
883
- readonly mediaType: Schema.String;
806
+ readonly type: Schema.Literal<"seconds">;
807
+ readonly seconds: Schema.Number;
884
808
  }>, Schema.Struct<{
885
- readonly type: Schema.Literal<"base64">;
886
- readonly data: Schema.String;
887
- readonly mediaType: Schema.String;
809
+ readonly type: Schema.Literal<"characters">;
810
+ readonly characters: Schema.Number;
888
811
  }>, Schema.Struct<{
889
- readonly type: Schema.Literal<"url">;
890
- readonly url: Schema.String;
891
- readonly mediaType: Schema.optional<Schema.String>;
892
- readonly expiresAt: Schema.optional<Schema.Number>;
812
+ readonly type: Schema.Literal<"credits">;
813
+ readonly credits: Schema.Number;
893
814
  }>, Schema.Struct<{
894
- readonly type: Schema.Literal<"ref">;
895
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
896
- readonly id: Schema.String;
897
- readonly mediaType: Schema.optional<Schema.String>;
898
- }>]>;
899
- readonly info: Schema.optional<Schema.Struct<{
900
- readonly width: Schema.optional<Schema.Number>;
901
- readonly height: Schema.optional<Schema.Number>;
902
- readonly durationSeconds: Schema.optional<Schema.Number>;
903
- readonly sampleRate: Schema.optional<Schema.Number>;
904
- readonly channels: Schema.optional<Schema.Number>;
905
- readonly encoding: Schema.optional<Schema.String>;
906
- readonly format: Schema.optional<Schema.String>;
907
- }>>;
815
+ readonly type: Schema.Literal<"compute">;
816
+ readonly seconds: Schema.Number;
817
+ }>]>>;
908
818
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
909
- }>, never, never>;
910
- }> | Schema.Struct<{
911
- readonly type: Schema.tag<"finish">;
912
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
913
- readonly type: Schema.Literal<"tokens">;
914
- readonly input: Schema.optional<Schema.Number>;
915
- readonly output: Schema.optional<Schema.Number>;
916
- readonly total: Schema.optional<Schema.Number>;
917
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
918
- }>, Schema.Struct<{
919
- readonly type: Schema.Literal<"seconds">;
920
- readonly seconds: Schema.Number;
921
- }>, Schema.Struct<{
922
- readonly type: Schema.Literal<"characters">;
923
- readonly characters: Schema.Number;
924
- }>, Schema.Struct<{
925
- readonly type: Schema.Literal<"credits">;
926
- readonly credits: Schema.Number;
927
- }>, Schema.Struct<{
928
- readonly type: Schema.Literal<"compute">;
929
- readonly seconds: Schema.Number;
930
- }>]>>;
931
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
932
- }> as M["Type"]["type"]]: (value: M["Type"]) => any; }>(cases: Cases): (value: {
819
+ }>;
820
+ readonly "generation-progress": Schema.Struct<{
821
+ readonly type: Schema.tag<"generation-progress">;
822
+ readonly id: Schema.String;
823
+ readonly progress: Schema.optional<Schema.Number>;
824
+ }>;
825
+ readonly "generation-queued": Schema.Struct<{
826
+ readonly type: Schema.tag<"generation-queued">;
827
+ readonly id: Schema.String;
828
+ readonly position: Schema.optional<Schema.Number>;
829
+ }>;
830
+ readonly image: Schema.Struct<{
831
+ readonly type: Schema.tag<"image">;
832
+ readonly index: Schema.Number;
833
+ readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
834
+ readonly source: Schema.Union<readonly [Schema.Struct<{
835
+ readonly type: Schema.Literal<"bytes">;
836
+ readonly data: Schema.Uint8Array;
837
+ readonly mediaType: Schema.String;
838
+ }>, Schema.Struct<{
839
+ readonly type: Schema.Literal<"base64">;
840
+ readonly data: Schema.String;
841
+ readonly mediaType: Schema.String;
842
+ }>, Schema.Struct<{
843
+ readonly type: Schema.Literal<"url">;
844
+ readonly url: Schema.String;
845
+ readonly mediaType: Schema.optional<Schema.String>;
846
+ readonly expiresAt: Schema.optional<Schema.Number>;
847
+ }>, Schema.Struct<{
848
+ readonly type: Schema.Literal<"ref">;
849
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
850
+ readonly id: Schema.String;
851
+ readonly mediaType: Schema.optional<Schema.String>;
852
+ }>]>;
853
+ readonly info: Schema.optional<Schema.Struct<{
854
+ readonly width: Schema.optional<Schema.Number>;
855
+ readonly height: Schema.optional<Schema.Number>;
856
+ readonly durationSeconds: Schema.optional<Schema.Number>;
857
+ readonly sampleRate: Schema.optional<Schema.Number>;
858
+ readonly channels: Schema.optional<Schema.Number>;
859
+ readonly encoding: Schema.optional<Schema.String>;
860
+ readonly format: Schema.optional<Schema.String>;
861
+ }>>;
862
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
863
+ }>, never, never>;
864
+ }>;
865
+ readonly "image-partial": Schema.Struct<{
866
+ readonly type: Schema.tag<"image-partial">;
867
+ readonly index: Schema.Number;
868
+ readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
869
+ readonly source: Schema.Union<readonly [Schema.Struct<{
870
+ readonly type: Schema.Literal<"bytes">;
871
+ readonly data: Schema.Uint8Array;
872
+ readonly mediaType: Schema.String;
873
+ }>, Schema.Struct<{
874
+ readonly type: Schema.Literal<"base64">;
875
+ readonly data: Schema.String;
876
+ readonly mediaType: Schema.String;
877
+ }>, Schema.Struct<{
878
+ readonly type: Schema.Literal<"url">;
879
+ readonly url: Schema.String;
880
+ readonly mediaType: Schema.optional<Schema.String>;
881
+ readonly expiresAt: Schema.optional<Schema.Number>;
882
+ }>, Schema.Struct<{
883
+ readonly type: Schema.Literal<"ref">;
884
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
885
+ readonly id: Schema.String;
886
+ readonly mediaType: Schema.optional<Schema.String>;
887
+ }>]>;
888
+ readonly info: Schema.optional<Schema.Struct<{
889
+ readonly width: Schema.optional<Schema.Number>;
890
+ readonly height: Schema.optional<Schema.Number>;
891
+ readonly durationSeconds: Schema.optional<Schema.Number>;
892
+ readonly sampleRate: Schema.optional<Schema.Number>;
893
+ readonly channels: Schema.optional<Schema.Number>;
894
+ readonly encoding: Schema.optional<Schema.String>;
895
+ readonly format: Schema.optional<Schema.String>;
896
+ }>>;
897
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
898
+ }>, never, never>;
899
+ }>;
900
+ }[K]["Type"]) => any; }>(cases: Handlers): (value: {
933
901
  readonly type: "image-partial";
934
902
  readonly index: number;
935
903
  readonly image: Media.Asset;
@@ -973,108 +941,10 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
973
941
  readonly [x: string]: unknown;
974
942
  };
975
943
  } | undefined;
976
- }) => Cases[keyof Cases] extends (value: any) => infer R ? import("effect/Unify").Unify<R> : never;
944
+ }) => import("effect/Unify").Unify<ReturnType<Handlers["finish" | "generation-progress" | "generation-queued" | "image" | "image-partial"]>>;
977
945
  };
978
946
  readonly matchOrElse: {
979
- <Cases extends { [M in Schema.Struct<{
980
- readonly type: Schema.tag<"generation-queued">;
981
- readonly id: Schema.String;
982
- readonly position: Schema.optional<Schema.Number>;
983
- }> | Schema.Struct<{
984
- readonly type: Schema.tag<"generation-progress">;
985
- readonly id: Schema.String;
986
- readonly progress: Schema.optional<Schema.Number>;
987
- }> | Schema.Struct<{
988
- readonly type: Schema.tag<"image-partial">;
989
- readonly index: Schema.Number;
990
- readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
991
- readonly source: Schema.Union<readonly [Schema.Struct<{
992
- readonly type: Schema.Literal<"bytes">;
993
- readonly data: Schema.Uint8Array;
994
- readonly mediaType: Schema.String;
995
- }>, Schema.Struct<{
996
- readonly type: Schema.Literal<"base64">;
997
- readonly data: Schema.String;
998
- readonly mediaType: Schema.String;
999
- }>, Schema.Struct<{
1000
- readonly type: Schema.Literal<"url">;
1001
- readonly url: Schema.String;
1002
- readonly mediaType: Schema.optional<Schema.String>;
1003
- readonly expiresAt: Schema.optional<Schema.Number>;
1004
- }>, Schema.Struct<{
1005
- readonly type: Schema.Literal<"ref">;
1006
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
1007
- readonly id: Schema.String;
1008
- readonly mediaType: Schema.optional<Schema.String>;
1009
- }>]>;
1010
- readonly info: Schema.optional<Schema.Struct<{
1011
- readonly width: Schema.optional<Schema.Number>;
1012
- readonly height: Schema.optional<Schema.Number>;
1013
- readonly durationSeconds: Schema.optional<Schema.Number>;
1014
- readonly sampleRate: Schema.optional<Schema.Number>;
1015
- readonly channels: Schema.optional<Schema.Number>;
1016
- readonly encoding: Schema.optional<Schema.String>;
1017
- readonly format: Schema.optional<Schema.String>;
1018
- }>>;
1019
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1020
- }>, never, never>;
1021
- }> | Schema.Struct<{
1022
- readonly type: Schema.tag<"image">;
1023
- readonly index: Schema.Number;
1024
- readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
1025
- readonly source: Schema.Union<readonly [Schema.Struct<{
1026
- readonly type: Schema.Literal<"bytes">;
1027
- readonly data: Schema.Uint8Array;
1028
- readonly mediaType: Schema.String;
1029
- }>, Schema.Struct<{
1030
- readonly type: Schema.Literal<"base64">;
1031
- readonly data: Schema.String;
1032
- readonly mediaType: Schema.String;
1033
- }>, Schema.Struct<{
1034
- readonly type: Schema.Literal<"url">;
1035
- readonly url: Schema.String;
1036
- readonly mediaType: Schema.optional<Schema.String>;
1037
- readonly expiresAt: Schema.optional<Schema.Number>;
1038
- }>, Schema.Struct<{
1039
- readonly type: Schema.Literal<"ref">;
1040
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
1041
- readonly id: Schema.String;
1042
- readonly mediaType: Schema.optional<Schema.String>;
1043
- }>]>;
1044
- readonly info: Schema.optional<Schema.Struct<{
1045
- readonly width: Schema.optional<Schema.Number>;
1046
- readonly height: Schema.optional<Schema.Number>;
1047
- readonly durationSeconds: Schema.optional<Schema.Number>;
1048
- readonly sampleRate: Schema.optional<Schema.Number>;
1049
- readonly channels: Schema.optional<Schema.Number>;
1050
- readonly encoding: Schema.optional<Schema.String>;
1051
- readonly format: Schema.optional<Schema.String>;
1052
- }>>;
1053
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1054
- }>, never, never>;
1055
- }> | Schema.Struct<{
1056
- readonly type: Schema.tag<"finish">;
1057
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
1058
- readonly type: Schema.Literal<"tokens">;
1059
- readonly input: Schema.optional<Schema.Number>;
1060
- readonly output: Schema.optional<Schema.Number>;
1061
- readonly total: Schema.optional<Schema.Number>;
1062
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
1063
- }>, Schema.Struct<{
1064
- readonly type: Schema.Literal<"seconds">;
1065
- readonly seconds: Schema.Number;
1066
- }>, Schema.Struct<{
1067
- readonly type: Schema.Literal<"characters">;
1068
- readonly characters: Schema.Number;
1069
- }>, Schema.Struct<{
1070
- readonly type: Schema.Literal<"credits">;
1071
- readonly credits: Schema.Number;
1072
- }>, Schema.Struct<{
1073
- readonly type: Schema.Literal<"compute">;
1074
- readonly seconds: Schema.Number;
1075
- }>]>>;
1076
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1077
- }> as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "finish" | "generation-progress" | "generation-queued" | "image" | "image-partial">]: never; }, OrElse extends (value: Exclude<{
947
+ <Handlers, OrElse>(value: {
1078
948
  readonly type: "image-partial";
1079
949
  readonly index: number;
1080
950
  readonly image: Media.Asset;
@@ -1118,23 +988,81 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
1118
988
  readonly [x: string]: unknown;
1119
989
  };
1120
990
  } | undefined;
1121
- }, { readonly [K in "type"]: keyof Cases; }>) => any>(value: {
991
+ }, cases: Handlers & {
992
+ readonly finish?: ((value: {
993
+ readonly type: "finish";
994
+ readonly usage?: {
995
+ readonly type: "seconds";
996
+ readonly seconds: number;
997
+ } | {
998
+ readonly type: "characters";
999
+ readonly characters: number;
1000
+ } | {
1001
+ readonly type: "credits";
1002
+ readonly credits: number;
1003
+ } | {
1004
+ readonly type: "compute";
1005
+ readonly seconds: number;
1006
+ } | {
1007
+ readonly type: "tokens";
1008
+ readonly input?: number | undefined;
1009
+ readonly output?: number | undefined;
1010
+ readonly total?: number | undefined;
1011
+ readonly details?: {
1012
+ readonly [x: string]: unknown;
1013
+ } | undefined;
1014
+ } | undefined;
1015
+ readonly providerMetadata?: {
1016
+ readonly [x: string]: {
1017
+ readonly [x: string]: unknown;
1018
+ };
1019
+ } | undefined;
1020
+ }) => any) | undefined;
1021
+ readonly "generation-progress"?: ((value: {
1022
+ readonly type: "generation-progress";
1023
+ readonly id: string;
1024
+ readonly progress?: number | undefined;
1025
+ }) => any) | undefined;
1026
+ readonly "generation-queued"?: ((value: {
1027
+ readonly type: "generation-queued";
1028
+ readonly id: string;
1029
+ readonly position?: number | undefined;
1030
+ }) => any) | undefined;
1031
+ readonly image?: ((value: {
1032
+ readonly type: "image";
1033
+ readonly index: number;
1034
+ readonly image: Media.Asset;
1035
+ }) => any) | undefined;
1036
+ readonly "image-partial"?: ((value: {
1037
+ readonly type: "image-partial";
1038
+ readonly index: number;
1039
+ readonly image: Media.Asset;
1040
+ }) => any) | undefined;
1041
+ } & (Exclude<keyof Handlers, "finish" | "generation-progress" | "generation-queued" | "image" | "image-partial"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
1122
1042
  readonly type: "image-partial";
1123
1043
  readonly index: number;
1124
1044
  readonly image: Media.Asset;
1125
- } | {
1045
+ }, {
1046
+ readonly type: keyof Handlers;
1047
+ }> | Exclude<{
1126
1048
  readonly type: "image";
1127
1049
  readonly index: number;
1128
1050
  readonly image: Media.Asset;
1129
- } | {
1051
+ }, {
1052
+ readonly type: keyof Handlers;
1053
+ }> | Exclude<{
1130
1054
  readonly type: "generation-queued";
1131
1055
  readonly id: string;
1132
1056
  readonly position?: number | undefined;
1133
- } | {
1057
+ }, {
1058
+ readonly type: keyof Handlers;
1059
+ }> | Exclude<{
1134
1060
  readonly type: "generation-progress";
1135
1061
  readonly id: string;
1136
1062
  readonly progress?: number | undefined;
1137
- } | {
1063
+ }, {
1064
+ readonly type: keyof Handlers;
1065
+ }> | Exclude<{
1138
1066
  readonly type: "finish";
1139
1067
  readonly usage?: {
1140
1068
  readonly type: "seconds";
@@ -1162,122 +1090,84 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
1162
1090
  readonly [x: string]: unknown;
1163
1091
  };
1164
1092
  } | undefined;
1165
- }, cases: Cases, orElse: OrElse): import("effect/Unify").Unify<{ [K in keyof Cases]-?: NonNullable<Cases[K]> extends (...args: Array<any>) => infer R ? R : never; }[keyof Cases] | ReturnType<OrElse>>;
1166
- <Cases extends { [M in Schema.Struct<{
1167
- readonly type: Schema.tag<"generation-queued">;
1168
- readonly id: Schema.String;
1169
- readonly position: Schema.optional<Schema.Number>;
1170
- }> | Schema.Struct<{
1171
- readonly type: Schema.tag<"generation-progress">;
1172
- readonly id: Schema.String;
1173
- readonly progress: Schema.optional<Schema.Number>;
1174
- }> | Schema.Struct<{
1175
- readonly type: Schema.tag<"image-partial">;
1176
- readonly index: Schema.Number;
1177
- readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
1178
- readonly source: Schema.Union<readonly [Schema.Struct<{
1179
- readonly type: Schema.Literal<"bytes">;
1180
- readonly data: Schema.Uint8Array;
1181
- readonly mediaType: Schema.String;
1182
- }>, Schema.Struct<{
1183
- readonly type: Schema.Literal<"base64">;
1184
- readonly data: Schema.String;
1185
- readonly mediaType: Schema.String;
1186
- }>, Schema.Struct<{
1187
- readonly type: Schema.Literal<"url">;
1188
- readonly url: Schema.String;
1189
- readonly mediaType: Schema.optional<Schema.String>;
1190
- readonly expiresAt: Schema.optional<Schema.Number>;
1191
- }>, Schema.Struct<{
1192
- readonly type: Schema.Literal<"ref">;
1193
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
1194
- readonly id: Schema.String;
1195
- readonly mediaType: Schema.optional<Schema.String>;
1196
- }>]>;
1197
- readonly info: Schema.optional<Schema.Struct<{
1198
- readonly width: Schema.optional<Schema.Number>;
1199
- readonly height: Schema.optional<Schema.Number>;
1200
- readonly durationSeconds: Schema.optional<Schema.Number>;
1201
- readonly sampleRate: Schema.optional<Schema.Number>;
1202
- readonly channels: Schema.optional<Schema.Number>;
1203
- readonly encoding: Schema.optional<Schema.String>;
1204
- readonly format: Schema.optional<Schema.String>;
1205
- }>>;
1206
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1207
- }>, never, never>;
1208
- }> | Schema.Struct<{
1209
- readonly type: Schema.tag<"image">;
1210
- readonly index: Schema.Number;
1211
- readonly image: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
1212
- readonly source: Schema.Union<readonly [Schema.Struct<{
1213
- readonly type: Schema.Literal<"bytes">;
1214
- readonly data: Schema.Uint8Array;
1215
- readonly mediaType: Schema.String;
1216
- }>, Schema.Struct<{
1217
- readonly type: Schema.Literal<"base64">;
1218
- readonly data: Schema.String;
1219
- readonly mediaType: Schema.String;
1220
- }>, Schema.Struct<{
1221
- readonly type: Schema.Literal<"url">;
1222
- readonly url: Schema.String;
1223
- readonly mediaType: Schema.optional<Schema.String>;
1224
- readonly expiresAt: Schema.optional<Schema.Number>;
1225
- }>, Schema.Struct<{
1226
- readonly type: Schema.Literal<"ref">;
1227
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
1228
- readonly id: Schema.String;
1229
- readonly mediaType: Schema.optional<Schema.String>;
1230
- }>]>;
1231
- readonly info: Schema.optional<Schema.Struct<{
1232
- readonly width: Schema.optional<Schema.Number>;
1233
- readonly height: Schema.optional<Schema.Number>;
1234
- readonly durationSeconds: Schema.optional<Schema.Number>;
1235
- readonly sampleRate: Schema.optional<Schema.Number>;
1236
- readonly channels: Schema.optional<Schema.Number>;
1237
- readonly encoding: Schema.optional<Schema.String>;
1238
- readonly format: Schema.optional<Schema.String>;
1239
- }>>;
1240
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1241
- }>, never, never>;
1242
- }> | Schema.Struct<{
1243
- readonly type: Schema.tag<"finish">;
1244
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
1245
- readonly type: Schema.Literal<"tokens">;
1246
- readonly input: Schema.optional<Schema.Number>;
1247
- readonly output: Schema.optional<Schema.Number>;
1248
- readonly total: Schema.optional<Schema.Number>;
1249
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
1250
- }>, Schema.Struct<{
1251
- readonly type: Schema.Literal<"seconds">;
1252
- readonly seconds: Schema.Number;
1253
- }>, Schema.Struct<{
1254
- readonly type: Schema.Literal<"characters">;
1255
- readonly characters: Schema.Number;
1256
- }>, Schema.Struct<{
1257
- readonly type: Schema.Literal<"credits">;
1258
- readonly credits: Schema.Number;
1259
- }>, Schema.Struct<{
1260
- readonly type: Schema.Literal<"compute">;
1261
- readonly seconds: Schema.Number;
1262
- }>]>>;
1263
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1264
- }> as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "finish" | "generation-progress" | "generation-queued" | "image" | "image-partial">]: never; }, OrElse extends (value: Exclude<{
1093
+ }, {
1094
+ readonly type: keyof Handlers;
1095
+ }>) => 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)>;
1096
+ <Handlers, OrElse>(cases: Handlers & {
1097
+ readonly finish?: ((value: {
1098
+ readonly type: "finish";
1099
+ readonly usage?: {
1100
+ readonly type: "seconds";
1101
+ readonly seconds: number;
1102
+ } | {
1103
+ readonly type: "characters";
1104
+ readonly characters: number;
1105
+ } | {
1106
+ readonly type: "credits";
1107
+ readonly credits: number;
1108
+ } | {
1109
+ readonly type: "compute";
1110
+ readonly seconds: number;
1111
+ } | {
1112
+ readonly type: "tokens";
1113
+ readonly input?: number | undefined;
1114
+ readonly output?: number | undefined;
1115
+ readonly total?: number | undefined;
1116
+ readonly details?: {
1117
+ readonly [x: string]: unknown;
1118
+ } | undefined;
1119
+ } | undefined;
1120
+ readonly providerMetadata?: {
1121
+ readonly [x: string]: {
1122
+ readonly [x: string]: unknown;
1123
+ };
1124
+ } | undefined;
1125
+ }) => any) | undefined;
1126
+ readonly "generation-progress"?: ((value: {
1127
+ readonly type: "generation-progress";
1128
+ readonly id: string;
1129
+ readonly progress?: number | undefined;
1130
+ }) => any) | undefined;
1131
+ readonly "generation-queued"?: ((value: {
1132
+ readonly type: "generation-queued";
1133
+ readonly id: string;
1134
+ readonly position?: number | undefined;
1135
+ }) => any) | undefined;
1136
+ readonly image?: ((value: {
1137
+ readonly type: "image";
1138
+ readonly index: number;
1139
+ readonly image: Media.Asset;
1140
+ }) => any) | undefined;
1141
+ readonly "image-partial"?: ((value: {
1142
+ readonly type: "image-partial";
1143
+ readonly index: number;
1144
+ readonly image: Media.Asset;
1145
+ }) => any) | undefined;
1146
+ } & (Exclude<keyof Handlers, "finish" | "generation-progress" | "generation-queued" | "image" | "image-partial"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
1265
1147
  readonly type: "image-partial";
1266
1148
  readonly index: number;
1267
1149
  readonly image: Media.Asset;
1268
- } | {
1150
+ }, {
1151
+ readonly type: keyof Handlers;
1152
+ }> | Exclude<{
1269
1153
  readonly type: "image";
1270
1154
  readonly index: number;
1271
1155
  readonly image: Media.Asset;
1272
- } | {
1156
+ }, {
1157
+ readonly type: keyof Handlers;
1158
+ }> | Exclude<{
1273
1159
  readonly type: "generation-queued";
1274
1160
  readonly id: string;
1275
1161
  readonly position?: number | undefined;
1276
- } | {
1162
+ }, {
1163
+ readonly type: keyof Handlers;
1164
+ }> | Exclude<{
1277
1165
  readonly type: "generation-progress";
1278
1166
  readonly id: string;
1279
1167
  readonly progress?: number | undefined;
1280
- } | {
1168
+ }, {
1169
+ readonly type: keyof Handlers;
1170
+ }> | Exclude<{
1281
1171
  readonly type: "finish";
1282
1172
  readonly usage?: {
1283
1173
  readonly type: "seconds";
@@ -1305,7 +1195,9 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
1305
1195
  readonly [x: string]: unknown;
1306
1196
  };
1307
1197
  } | undefined;
1308
- }, { readonly [K in "type"]: keyof Cases; }>) => any>(cases: Cases, orElse: OrElse): (value: {
1198
+ }, {
1199
+ readonly type: keyof Handlers;
1200
+ }>) => any)): (value: {
1309
1201
  readonly type: "image-partial";
1310
1202
  readonly index: number;
1311
1203
  readonly image: Media.Asset;
@@ -1349,7 +1241,7 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
1349
1241
  readonly [x: string]: unknown;
1350
1242
  };
1351
1243
  } | undefined;
1352
- }) => import("effect/Unify").Unify<{ [K in keyof Cases]-?: NonNullable<Cases[K]> extends (...args: Array<any>) => infer R ? R : never; }[keyof Cases] | ReturnType<OrElse>>;
1244
+ }) => 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)>;
1353
1245
  };
1354
1246
  } & {
1355
1247
  is: {
@@ -1405,12 +1297,12 @@ export declare const ImageEvent: Schema.Union<readonly [Schema.Struct<{
1405
1297
  };
1406
1298
  };
1407
1299
  export type ImageEvent = Schema.Schema.Type<typeof imageEventTagged>;
1408
- export declare function request<const Model extends ImageModel>(input: ImageRequestInput<Model>): ImageRequestFor<ImageModelOptions<Model>>;
1409
- export declare function request(input: ImageRequest): ImageRequest;
1410
- export declare function generate<const Model extends ImageModel>(input: ImageRequest | ImageRequestInput<Model>, options?: AwaitOptions): Effect.Effect<ImageResponse, AIError, Service>;
1411
- export declare function stream<const Model extends ImageModel>(input: ImageRequest | ImageRequestInput<Model>, options?: AwaitOptions): Stream.Stream<ImageEvent, AIError, Service>;
1300
+ /** Normalize image request input into a plain `ImageRequest`. */
1301
+ export declare const request: <const Model extends ImageModel>(input: ImageRequestInput<Model>) => ImageRequest<Model>;
1302
+ export declare function generate<const Model extends ImageModel>(input: ImageRequestInput<Model>, options?: AwaitOptions): Effect.Effect<ImageResponse, AIError, Service>;
1303
+ export declare function stream<const Model extends ImageModel>(input: ImageRequestInput<Model>, options?: AwaitOptions): Stream.Stream<ImageEvent, AIError, Service>;
1412
1304
  /** Inline and streaming routes fail with `UnsupportedOperation`. */
1413
- export declare function start<const Model extends ImageModel>(input: ImageRequest | ImageRequestInput<Model>): Effect.Effect<Generation<ImageResponse>, AIError, Service>;
1305
+ export declare function start<const Model extends ImageModel>(input: ImageRequestInput<Model>): Effect.Effect<Generation<ImageResponse>, AIError, Service>;
1414
1306
  export declare const resume: (model: ImageModel, token: unknown) => Effect.Effect<Generation<ImageResponse>, AIError, Service>;
1415
1307
  export declare const Image: {
1416
1308
  readonly request: typeof request;