@opencode/ai 2.2.4 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/README.md +133 -69
  2. package/dist/cache-policy.d.ts +1 -1
  3. package/dist/cache-policy.js +16 -4
  4. package/dist/decision-client.d.ts +3 -3
  5. package/dist/decision.d.ts +20 -125
  6. package/dist/decision.js +25 -15
  7. package/dist/effect.d.ts +4 -15
  8. package/dist/effect.js +2 -6
  9. package/dist/effort-updates.d.ts +3 -3
  10. package/dist/effort-updates.js +2 -2
  11. package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
  12. package/dist/experimental/cloudflare-run-extraction.js +4 -1
  13. package/dist/experimental/extraction.d.ts +10 -40
  14. package/dist/experimental/extraction.js +14 -13
  15. package/dist/experimental.d.ts +8 -8
  16. package/dist/experimental.js +4 -4
  17. package/dist/generation.d.ts +0 -2
  18. package/dist/generation.js +2 -2
  19. package/dist/image-client.d.ts +13 -7
  20. package/dist/image-client.js +1 -1
  21. package/dist/image.d.ts +357 -464
  22. package/dist/image.js +17 -15
  23. package/dist/index.d.ts +28 -465
  24. package/dist/index.js +18 -17
  25. package/dist/llm.d.ts +65 -266
  26. package/dist/llm.js +101 -92
  27. package/dist/loop.d.ts +38 -0
  28. package/dist/loop.js +136 -0
  29. package/dist/media-model.d.ts +1 -1
  30. package/dist/media-model.js +8 -6
  31. package/dist/media.d.ts +9 -0
  32. package/dist/media.js +37 -2
  33. package/dist/protocols/alibaba-chat.d.ts +5 -1
  34. package/dist/protocols/alibaba-chat.js +3 -3
  35. package/dist/protocols/alibaba-images.d.ts +2 -2
  36. package/dist/protocols/alibaba-messages.js +3 -3
  37. package/dist/protocols/alibaba-responses.js +8 -20
  38. package/dist/protocols/anthropic-messages.d.ts +1 -1
  39. package/dist/protocols/anthropic-messages.js +57 -185
  40. package/dist/protocols/assemblyai-transcription.d.ts +2 -2
  41. package/dist/protocols/bedrock-converse.js +11 -22
  42. package/dist/protocols/cartesia-speech.d.ts +2 -2
  43. package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
  44. package/dist/protocols/cohere-chat.js +9 -12
  45. package/dist/protocols/deepgram-speech.d.ts +2 -2
  46. package/dist/protocols/deepgram-transcription.d.ts +2 -2
  47. package/dist/protocols/elevenlabs-speech.d.ts +2 -2
  48. package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
  49. package/dist/protocols/gemini.d.ts +3 -0
  50. package/dist/protocols/gemini.js +56 -89
  51. package/dist/protocols/google-images.d.ts +2 -2
  52. package/dist/protocols/google-interactions.d.ts +3 -4
  53. package/dist/protocols/google-interactions.js +54 -32
  54. package/dist/protocols/google-speech.d.ts +2 -2
  55. package/dist/protocols/google-transcription.d.ts +2 -2
  56. package/dist/protocols/google-video.d.ts +2 -2
  57. package/dist/protocols/meta-images.d.ts +2 -2
  58. package/dist/protocols/meta-responses.js +26 -23
  59. package/dist/protocols/minimax-images.d.ts +2 -2
  60. package/dist/protocols/mistral-chat.js +14 -20
  61. package/dist/protocols/open-responses-channel.js +6 -19
  62. package/dist/protocols/open-responses-continuation.d.ts +1 -5
  63. package/dist/protocols/open-responses-continuation.js +1 -3
  64. package/dist/protocols/open-responses.d.ts +1 -21
  65. package/dist/protocols/open-responses.js +10 -15
  66. package/dist/protocols/openai-chat.d.ts +3 -23
  67. package/dist/protocols/openai-chat.js +26 -47
  68. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  69. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  70. package/dist/protocols/openai-compatible-responses.js +1 -1
  71. package/dist/protocols/openai-decisions.js +1 -1
  72. package/dist/protocols/openai-images.d.ts +2 -2
  73. package/dist/protocols/openai-responses.js +10 -29
  74. package/dist/protocols/openai-speech.d.ts +2 -2
  75. package/dist/protocols/openai-transcription.d.ts +2 -2
  76. package/dist/protocols/runway-video.d.ts +2 -2
  77. package/dist/protocols/shared.d.ts +1 -4
  78. package/dist/protocols/shared.js +13 -11
  79. package/dist/protocols/system-one.d.ts +4 -4
  80. package/dist/protocols/utils/bedrock-cache.js +2 -5
  81. package/dist/protocols/utils/bedrock-media.d.ts +0 -3
  82. package/dist/protocols/utils/cache.d.ts +3 -0
  83. package/dist/protocols/utils/cache.js +15 -2
  84. package/dist/protocols/utils/image-sizing.d.ts +1 -1
  85. package/dist/protocols/utils/responses-checkpoint.js +1 -1
  86. package/dist/protocols/utils/responses-compaction.d.ts +1 -1
  87. package/dist/protocols/utils/responses-compaction.js +6 -5
  88. package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
  89. package/dist/protocols/utils/responses-hosted-tools.js +31 -0
  90. package/dist/protocols/utils/tool-stream.d.ts +5 -271
  91. package/dist/protocols/utils/tool-stream.js +3 -13
  92. package/dist/protocols/venice-chat.d.ts +3 -1
  93. package/dist/protocols/venice-chat.js +4 -4
  94. package/dist/protocols/xai-images.d.ts +2 -2
  95. package/dist/protocols/xai-responses.js +5 -25
  96. package/dist/protocols/xai-video.d.ts +2 -2
  97. package/dist/protocols/zai-chat.d.ts +5 -1
  98. package/dist/protocols/zai-chat.js +1 -1
  99. package/dist/protocols/zai-images.d.ts +2 -2
  100. package/dist/protocols/zai-messages.js +3 -3
  101. package/dist/provider-error.d.ts +0 -1
  102. package/dist/provider-error.js +9 -80
  103. package/dist/providers/alibaba.d.ts +67 -4
  104. package/dist/providers/alibaba.js +6 -1
  105. package/dist/providers/amazon-bedrock-mantle.d.ts +6 -3
  106. package/dist/providers/amazon-bedrock-mantle.js +6 -3
  107. package/dist/providers/amazon-bedrock.d.ts +6 -7
  108. package/dist/providers/amazon-bedrock.js +1 -1
  109. package/dist/providers/anthropic-compatible.d.ts +7 -8
  110. package/dist/providers/anthropic-compatible.js +2 -5
  111. package/dist/providers/anthropic.d.ts +8 -9
  112. package/dist/providers/anthropic.js +2 -7
  113. package/dist/providers/assemblyai.d.ts +2 -2
  114. package/dist/providers/assemblyai.js +2 -7
  115. package/dist/providers/azure/messages.d.ts +2 -0
  116. package/dist/providers/azure/messages.js +1 -0
  117. package/dist/providers/azure.d.ts +322 -7
  118. package/dist/providers/azure.js +25 -9
  119. package/dist/providers/baseten.d.ts +5 -5
  120. package/dist/providers/baseten.js +7 -21
  121. package/dist/providers/cartesia.d.ts +1 -1
  122. package/dist/providers/cerebras.d.ts +5 -5
  123. package/dist/providers/cerebras.js +4 -15
  124. package/dist/providers/cloudflare-ai-gateway.d.ts +21 -13
  125. package/dist/providers/cloudflare-ai-gateway.js +28 -40
  126. package/dist/providers/cloudflare-shared.d.ts +9 -0
  127. package/dist/providers/cloudflare-shared.js +25 -0
  128. package/dist/providers/cloudflare-workers-ai.d.ts +4 -4
  129. package/dist/providers/cloudflare-workers-ai.js +4 -20
  130. package/dist/providers/cohere/chat.js +2 -7
  131. package/dist/providers/cohere.d.ts +6 -5
  132. package/dist/providers/cohere.js +7 -13
  133. package/dist/providers/deepgram.d.ts +2 -2
  134. package/dist/providers/deepgram.js +2 -7
  135. package/dist/providers/deepinfra.d.ts +5 -5
  136. package/dist/providers/deepinfra.js +5 -13
  137. package/dist/providers/deepseek.d.ts +5 -5
  138. package/dist/providers/deepseek.js +3 -14
  139. package/dist/providers/digitalocean.d.ts +8 -5
  140. package/dist/providers/digitalocean.js +13 -14
  141. package/dist/providers/elevenlabs.d.ts +2 -2
  142. package/dist/providers/elevenlabs.js +2 -7
  143. package/dist/providers/fireworks.d.ts +5 -5
  144. package/dist/providers/fireworks.js +4 -15
  145. package/dist/providers/google/interactions.d.ts +1 -1
  146. package/dist/providers/google/interactions.js +2 -7
  147. package/dist/providers/google-vertex-chat.d.ts +3 -3
  148. package/dist/providers/google-vertex-chat.js +3 -29
  149. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  150. package/dist/providers/google-vertex-messages.d.ts +3 -3
  151. package/dist/providers/google-vertex-messages.js +3 -29
  152. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  153. package/dist/providers/google-vertex-mistral.js +3 -29
  154. package/dist/providers/google-vertex-responses.d.ts +3 -3
  155. package/dist/providers/google-vertex-responses.js +4 -30
  156. package/dist/providers/google-vertex-shared.d.ts +31 -0
  157. package/dist/providers/google-vertex-shared.js +25 -0
  158. package/dist/providers/google-vertex.d.ts +3 -3
  159. package/dist/providers/google.d.ts +15 -13
  160. package/dist/providers/google.js +9 -19
  161. package/dist/providers/groq.d.ts +5 -5
  162. package/dist/providers/groq.js +4 -15
  163. package/dist/providers/meta.d.ts +5 -5
  164. package/dist/providers/meta.js +10 -24
  165. package/dist/providers/minimax/chat.js +2 -7
  166. package/dist/providers/minimax/responses.js +2 -7
  167. package/dist/providers/minimax.d.ts +5 -5
  168. package/dist/providers/minimax.js +11 -23
  169. package/dist/providers/mistral.d.ts +10 -11
  170. package/dist/providers/mistral.js +3 -14
  171. package/dist/providers/moonshot/messages.js +2 -7
  172. package/dist/providers/moonshot/responses.js +2 -7
  173. package/dist/providers/moonshot.d.ts +5 -5
  174. package/dist/providers/moonshot.js +4 -16
  175. package/dist/providers/openai-compatible-responses.d.ts +6 -7
  176. package/dist/providers/openai-compatible-responses.js +2 -8
  177. package/dist/providers/openai-compatible.d.ts +6 -7
  178. package/dist/providers/openai-compatible.js +4 -10
  179. package/dist/providers/openai.d.ts +4 -4
  180. package/dist/providers/openai.js +3 -3
  181. package/dist/providers/opencode.d.ts +4 -4
  182. package/dist/providers/opencode.js +6 -2
  183. package/dist/providers/openrouter.d.ts +8 -5
  184. package/dist/providers/openrouter.js +16 -24
  185. package/dist/providers/runway.d.ts +1 -1
  186. package/dist/providers/settings.d.ts +40 -0
  187. package/dist/providers/settings.js +19 -0
  188. package/dist/providers/togetherai.d.ts +5 -5
  189. package/dist/providers/togetherai.js +5 -15
  190. package/dist/providers/typesafe-ai.d.ts +4 -4
  191. package/dist/providers/typesafe-ai.js +6 -2
  192. package/dist/providers/venice.d.ts +4 -4
  193. package/dist/providers/venice.js +6 -2
  194. package/dist/providers/vercel-ai-gateway.d.ts +5 -5
  195. package/dist/providers/vercel-ai-gateway.js +15 -28
  196. package/dist/providers/xai.d.ts +4 -4
  197. package/dist/providers/xai.js +4 -12
  198. package/dist/providers/zai-coding-plan/messages.js +2 -7
  199. package/dist/providers/zai-coding-plan/responses.js +2 -7
  200. package/dist/providers/zai-coding-plan.d.ts +5 -5
  201. package/dist/providers/zai-coding-plan.js +8 -15
  202. package/dist/providers/zai.d.ts +5 -5
  203. package/dist/providers/zai.js +10 -22
  204. package/dist/public.d.ts +12 -0
  205. package/dist/public.js +5 -0
  206. package/dist/route/auth-options.d.ts +9 -5
  207. package/dist/route/auth-options.js +10 -7
  208. package/dist/route/client.d.ts +50 -37
  209. package/dist/route/client.js +42 -53
  210. package/dist/route/decision.d.ts +8 -8
  211. package/dist/route/decision.js +3 -3
  212. package/dist/route/executor.d.ts +5 -0
  213. package/dist/route/executor.js +10 -0
  214. package/dist/route/index.d.ts +5 -7
  215. package/dist/route/index.js +1 -1
  216. package/dist/route/media.d.ts +7 -11
  217. package/dist/route/media.js +22 -26
  218. package/dist/route/transport/http.js +6 -5
  219. package/dist/route/transport/websocket.js +7 -1
  220. package/dist/schema/errors.d.ts +16 -17
  221. package/dist/schema/errors.js +63 -12
  222. package/dist/schema/events.d.ts +2563 -2954
  223. package/dist/schema/events.js +54 -109
  224. package/dist/schema/messages.d.ts +194 -137
  225. package/dist/schema/messages.js +66 -83
  226. package/dist/schema/options.d.ts +112 -65
  227. package/dist/schema/options.js +52 -101
  228. package/dist/speech-client.d.ts +7 -7
  229. package/dist/speech.d.ts +306 -316
  230. package/dist/speech.js +16 -14
  231. package/dist/testing.d.ts +31 -175
  232. package/dist/testing.js +60 -5
  233. package/dist/tool-history.d.ts +1 -1
  234. package/dist/tool-history.js +3 -10
  235. package/dist/tool-runtime.d.ts +9 -2
  236. package/dist/tool-runtime.js +17 -31
  237. package/dist/tool.d.ts +39 -43
  238. package/dist/tool.js +16 -26
  239. package/dist/transcription-client.d.ts +7 -7
  240. package/dist/transcription.d.ts +314 -265
  241. package/dist/transcription.js +16 -14
  242. package/dist/utils/provider-codes.d.ts +3 -0
  243. package/dist/utils/provider-codes.js +41 -0
  244. package/dist/video-client.d.ts +7 -7
  245. package/dist/video-client.js +1 -1
  246. package/dist/video.d.ts +269 -287
  247. package/dist/video.js +16 -14
  248. package/package.json +9 -9
  249. package/dist/experimental/testing.d.ts +0 -3
  250. package/dist/experimental/testing.js +0 -3
  251. package/dist/testing/decision.d.ts +0 -16
  252. package/dist/testing/decision.js +0 -20
  253. package/dist/testing/image.d.ts +0 -14
  254. package/dist/testing/image.js +0 -12
  255. package/dist/testing/media.d.ts +0 -18
  256. package/dist/testing/media.js +0 -36
  257. package/dist/testing/script.d.ts +0 -28
  258. package/dist/testing/script.js +0 -60
  259. package/dist/testing/speech.d.ts +0 -14
  260. package/dist/testing/speech.js +0 -12
  261. package/dist/testing/transcription.d.ts +0 -14
  262. package/dist/testing/transcription.js +0 -12
  263. package/dist/testing/video.d.ts +0 -14
  264. package/dist/testing/video.js +0 -12
package/dist/speech.d.ts CHANGED
@@ -2,16 +2,16 @@ import { Effect, Schema, Stream } from "effect";
2
2
  import { Media } from "./media.js";
3
3
  import { MediaModel } from "./media-model.js";
4
4
  import { MediaRoute } from "./route/media.js";
5
- import { AIError, HttpOptions, type OpenString } from "./schema/index.js";
5
+ import { AIError, type OpenString, type BaseRequest } from "./schema/index.js";
6
6
  import { Service } from "./speech-client.js";
7
7
  export type SpeechOptions = MediaModel.Options;
8
- export type SpeechRoute = MediaRoute.AnyRoute<SpeechRequestFor, SpeechEvent, SpeechResponse>;
8
+ export type SpeechRoute = MediaRoute.AnyRoute<SpeechRequest, SpeechEvent, SpeechResponse>;
9
9
  export declare class SpeechModel<Options extends SpeechOptions = SpeechOptions> extends MediaModel<SpeechRoute, Options> {
10
10
  protected readonly _SpeechModel: void;
11
11
  /** The number of type arguments selects the kind: `<Options>`, `<Options, Frame, State>`, or `<Options, Token>`. */
12
- static fromRoute<Options extends SpeechOptions>(route: MediaModel.InlineRouteInput<SpeechRequestFor<Options>, SpeechResponse>, input: MediaRoute.ModelInput): SpeechModel<Options>;
13
- static fromRoute<Options extends SpeechOptions, Frame, State>(route: MediaModel.StreamRouteInput<SpeechRequestFor<Options>, SpeechEvent, Frame, State>, input: MediaRoute.ModelInput): SpeechModel<Options>;
14
- static fromRoute<Options extends SpeechOptions, Token>(route: MediaModel.QueuedRouteInput<SpeechRequestFor<Options>, SpeechResponse, Token>, input: MediaRoute.ModelInput): SpeechModel<Options>;
12
+ static fromRoute<Options extends SpeechOptions>(route: MediaModel.InlineRouteInput<SpeechRequest<SpeechModel<Options>>, SpeechResponse>, input: MediaRoute.ModelInput): SpeechModel<Options>;
13
+ static fromRoute<Options extends SpeechOptions, Frame, State>(route: MediaModel.StreamRouteInput<SpeechRequest<SpeechModel<Options>>, SpeechEvent, Frame, State>, input: MediaRoute.ModelInput): SpeechModel<Options>;
14
+ static fromRoute<Options extends SpeechOptions, Token>(route: MediaModel.QueuedRouteInput<SpeechRequest<SpeechModel<Options>>, SpeechResponse, Token>, input: MediaRoute.ModelInput): SpeechModel<Options>;
15
15
  }
16
16
  export declare const SpeechModelSchema: Schema.declare<SpeechModel<{
17
17
  readonly [x: string]: unknown;
@@ -31,7 +31,7 @@ export declare const SpeechTimestamp: Schema.Struct<{
31
31
  readonly endSeconds: Schema.Number;
32
32
  }>;
33
33
  export type SpeechTimestamp = Schema.Schema.Type<typeof SpeechTimestamp>;
34
- declare const SpeechRequest_base: Schema.Class<SpeechRequest, Schema.Struct<{
34
+ declare const SpeechRequestSchema: Schema.Struct<{
35
35
  readonly model: Schema.declare<SpeechModel<{
36
36
  readonly [x: string]: unknown;
37
37
  }>, SpeechModel<{
@@ -47,21 +47,15 @@ declare const SpeechRequest_base: Schema.Class<SpeechRequest, Schema.Struct<{
47
47
  readonly instructions: Schema.optional<Schema.String>;
48
48
  readonly timestamps: Schema.optional<Schema.Boolean>;
49
49
  readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
50
- readonly http: Schema.optional<typeof HttpOptions>;
51
- }>, {}>;
52
- export declare class SpeechRequest extends SpeechRequest_base {
53
- protected readonly _SpeechRequest: void;
54
- }
55
- export type SpeechRequestFor<Options extends SpeechOptions = SpeechOptions> = Omit<SpeechRequest, "model" | "providerOptions"> & {
56
- readonly model: SpeechModel<Options>;
57
- readonly providerOptions?: Options;
50
+ }>;
51
+ /** A normalized speech request, the plain object `Speech.request(...)` returns. */
52
+ export type SpeechRequest<Model extends SpeechModel = SpeechModel> = Omit<typeof SpeechRequestSchema.Type, "model" | "providerOptions" | "format"> & BaseRequest<Model, SpeechModelOptions<Model>> & {
53
+ readonly format?: SpeechFormat;
58
54
  };
59
55
  export type SpeechModelOptions<Model> = Model extends SpeechModel<infer Options> ? Options : never;
60
- export type SpeechRequestInput<Model extends SpeechModel = SpeechModel> = Omit<ConstructorParameters<typeof SpeechRequest>[0], "model" | "providerOptions" | "http" | "format"> & {
61
- readonly model: Model;
62
- readonly format?: SpeechFormat;
56
+ /** Input accepted by `Speech.request` and the calls; a `SpeechRequest` is also a valid input. */
57
+ export type SpeechRequestInput<Model extends SpeechModel = SpeechModel> = Omit<SpeechRequest<Model>, "providerOptions"> & {
63
58
  readonly providerOptions?: NoInfer<SpeechModelOptions<Model>>;
64
- readonly http?: HttpOptions.Input;
65
59
  };
66
60
  declare const SpeechResponse_base: Schema.Class<SpeechResponse, Schema.Struct<{
67
61
  /** The complete audio. Headerless PCM carries `info.encoding`, `info.sampleRate`, and `info.channels`. */
@@ -575,78 +569,84 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
575
569
  };
576
570
  };
577
571
  readonly match: {
578
- <Cases extends { [M in Schema.Struct<{
579
- readonly type: Schema.tag<"generation-queued">;
580
- readonly id: Schema.String;
581
- readonly position: Schema.optional<Schema.Number>;
582
- }> | Schema.Struct<{
583
- readonly type: Schema.tag<"generation-progress">;
584
- readonly id: Schema.String;
585
- readonly progress: Schema.optional<Schema.Number>;
586
- }> | Schema.Struct<{
587
- readonly type: Schema.tag<"audio-delta">;
588
- readonly chunk: Schema.Uint8Array;
589
- }> | Schema.Struct<{
590
- readonly type: Schema.tag<"timestamps">;
591
- readonly items: Schema.$Array<Schema.Struct<{
592
- readonly text: Schema.String;
593
- readonly startSeconds: Schema.Number;
594
- readonly endSeconds: Schema.Number;
595
- }>>;
596
- }> | Schema.Struct<{
597
- readonly type: Schema.tag<"finish">;
598
- readonly audio: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
599
- readonly source: Schema.Union<readonly [Schema.Struct<{
600
- readonly type: Schema.Literal<"bytes">;
601
- readonly data: Schema.Uint8Array;
602
- readonly mediaType: Schema.String;
572
+ <Handlers extends { [K in "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"]: (value: {
573
+ readonly "audio-delta": Schema.Struct<{
574
+ readonly type: Schema.tag<"audio-delta">;
575
+ readonly chunk: Schema.Uint8Array;
576
+ }>;
577
+ readonly finish: Schema.Struct<{
578
+ readonly type: Schema.tag<"finish">;
579
+ readonly audio: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
580
+ readonly source: Schema.Union<readonly [Schema.Struct<{
581
+ readonly type: Schema.Literal<"bytes">;
582
+ readonly data: Schema.Uint8Array;
583
+ readonly mediaType: Schema.String;
584
+ }>, Schema.Struct<{
585
+ readonly type: Schema.Literal<"base64">;
586
+ readonly data: Schema.String;
587
+ readonly mediaType: Schema.String;
588
+ }>, Schema.Struct<{
589
+ readonly type: Schema.Literal<"url">;
590
+ readonly url: Schema.String;
591
+ readonly mediaType: Schema.optional<Schema.String>;
592
+ readonly expiresAt: Schema.optional<Schema.Number>;
593
+ }>, Schema.Struct<{
594
+ readonly type: Schema.Literal<"ref">;
595
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
596
+ readonly id: Schema.String;
597
+ readonly mediaType: Schema.optional<Schema.String>;
598
+ }>]>;
599
+ readonly info: Schema.optional<Schema.Struct<{
600
+ readonly width: Schema.optional<Schema.Number>;
601
+ readonly height: Schema.optional<Schema.Number>;
602
+ readonly durationSeconds: Schema.optional<Schema.Number>;
603
+ readonly sampleRate: Schema.optional<Schema.Number>;
604
+ readonly channels: Schema.optional<Schema.Number>;
605
+ readonly encoding: Schema.optional<Schema.String>;
606
+ readonly format: Schema.optional<Schema.String>;
607
+ }>>;
608
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
609
+ }>, never, never>;
610
+ readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
611
+ readonly type: Schema.Literal<"tokens">;
612
+ readonly input: Schema.optional<Schema.Number>;
613
+ readonly output: Schema.optional<Schema.Number>;
614
+ readonly total: Schema.optional<Schema.Number>;
615
+ readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
603
616
  }>, Schema.Struct<{
604
- readonly type: Schema.Literal<"base64">;
605
- readonly data: Schema.String;
606
- readonly mediaType: Schema.String;
617
+ readonly type: Schema.Literal<"seconds">;
618
+ readonly seconds: Schema.Number;
607
619
  }>, Schema.Struct<{
608
- readonly type: Schema.Literal<"url">;
609
- readonly url: Schema.String;
610
- readonly mediaType: Schema.optional<Schema.String>;
611
- readonly expiresAt: Schema.optional<Schema.Number>;
620
+ readonly type: Schema.Literal<"characters">;
621
+ readonly characters: Schema.Number;
612
622
  }>, Schema.Struct<{
613
- readonly type: Schema.Literal<"ref">;
614
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
615
- readonly id: Schema.String;
616
- readonly mediaType: Schema.optional<Schema.String>;
617
- }>]>;
618
- readonly info: Schema.optional<Schema.Struct<{
619
- readonly width: Schema.optional<Schema.Number>;
620
- readonly height: Schema.optional<Schema.Number>;
621
- readonly durationSeconds: Schema.optional<Schema.Number>;
622
- readonly sampleRate: Schema.optional<Schema.Number>;
623
- readonly channels: Schema.optional<Schema.Number>;
624
- readonly encoding: Schema.optional<Schema.String>;
625
- readonly format: Schema.optional<Schema.String>;
626
- }>>;
623
+ readonly type: Schema.Literal<"credits">;
624
+ readonly credits: Schema.Number;
625
+ }>, Schema.Struct<{
626
+ readonly type: Schema.Literal<"compute">;
627
+ readonly seconds: Schema.Number;
628
+ }>]>>;
627
629
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
628
- }>, never, never>;
629
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
630
- readonly type: Schema.Literal<"tokens">;
631
- readonly input: Schema.optional<Schema.Number>;
632
- readonly output: Schema.optional<Schema.Number>;
633
- readonly total: Schema.optional<Schema.Number>;
634
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
635
- }>, Schema.Struct<{
636
- readonly type: Schema.Literal<"seconds">;
637
- readonly seconds: Schema.Number;
638
- }>, Schema.Struct<{
639
- readonly type: Schema.Literal<"characters">;
640
- readonly characters: Schema.Number;
641
- }>, Schema.Struct<{
642
- readonly type: Schema.Literal<"credits">;
643
- readonly credits: Schema.Number;
644
- }>, Schema.Struct<{
645
- readonly type: Schema.Literal<"compute">;
646
- readonly seconds: Schema.Number;
647
- }>]>>;
648
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
649
- }> as M["Type"]["type"]]: (value: M["Type"]) => any; }>(value: {
630
+ }>;
631
+ readonly "generation-progress": Schema.Struct<{
632
+ readonly type: Schema.tag<"generation-progress">;
633
+ readonly id: Schema.String;
634
+ readonly progress: Schema.optional<Schema.Number>;
635
+ }>;
636
+ readonly "generation-queued": Schema.Struct<{
637
+ readonly type: Schema.tag<"generation-queued">;
638
+ readonly id: Schema.String;
639
+ readonly position: Schema.optional<Schema.Number>;
640
+ }>;
641
+ readonly timestamps: Schema.Struct<{
642
+ readonly type: Schema.tag<"timestamps">;
643
+ readonly items: Schema.$Array<Schema.Struct<{
644
+ readonly text: Schema.String;
645
+ readonly startSeconds: Schema.Number;
646
+ readonly endSeconds: Schema.Number;
647
+ }>>;
648
+ }>;
649
+ }[K]["Type"]) => any; }>(value: {
650
650
  readonly type: "audio-delta";
651
651
  readonly chunk: Uint8Array<ArrayBufferLike>;
652
652
  } | {
@@ -693,79 +693,85 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
693
693
  readonly [x: string]: unknown;
694
694
  };
695
695
  } | undefined;
696
- }, cases: Cases): Cases[keyof Cases] extends (value: any) => infer R ? import("effect/Unify").Unify<R> : never;
697
- <Cases extends { [M in Schema.Struct<{
698
- readonly type: Schema.tag<"generation-queued">;
699
- readonly id: Schema.String;
700
- readonly position: Schema.optional<Schema.Number>;
701
- }> | Schema.Struct<{
702
- readonly type: Schema.tag<"generation-progress">;
703
- readonly id: Schema.String;
704
- readonly progress: Schema.optional<Schema.Number>;
705
- }> | Schema.Struct<{
706
- readonly type: Schema.tag<"audio-delta">;
707
- readonly chunk: Schema.Uint8Array;
708
- }> | Schema.Struct<{
709
- readonly type: Schema.tag<"timestamps">;
710
- readonly items: Schema.$Array<Schema.Struct<{
711
- readonly text: Schema.String;
712
- readonly startSeconds: Schema.Number;
713
- readonly endSeconds: Schema.Number;
714
- }>>;
715
- }> | Schema.Struct<{
716
- readonly type: Schema.tag<"finish">;
717
- readonly audio: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
718
- readonly source: Schema.Union<readonly [Schema.Struct<{
719
- readonly type: Schema.Literal<"bytes">;
720
- readonly data: Schema.Uint8Array;
721
- readonly mediaType: Schema.String;
696
+ }, cases: Handlers): import("effect/Unify").Unify<ReturnType<Handlers["audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"]>>;
697
+ <Handlers extends { [K in "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"]: (value: {
698
+ readonly "audio-delta": Schema.Struct<{
699
+ readonly type: Schema.tag<"audio-delta">;
700
+ readonly chunk: Schema.Uint8Array;
701
+ }>;
702
+ readonly finish: Schema.Struct<{
703
+ readonly type: Schema.tag<"finish">;
704
+ readonly audio: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
705
+ readonly source: Schema.Union<readonly [Schema.Struct<{
706
+ readonly type: Schema.Literal<"bytes">;
707
+ readonly data: Schema.Uint8Array;
708
+ readonly mediaType: Schema.String;
709
+ }>, Schema.Struct<{
710
+ readonly type: Schema.Literal<"base64">;
711
+ readonly data: Schema.String;
712
+ readonly mediaType: Schema.String;
713
+ }>, Schema.Struct<{
714
+ readonly type: Schema.Literal<"url">;
715
+ readonly url: Schema.String;
716
+ readonly mediaType: Schema.optional<Schema.String>;
717
+ readonly expiresAt: Schema.optional<Schema.Number>;
718
+ }>, Schema.Struct<{
719
+ readonly type: Schema.Literal<"ref">;
720
+ readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
721
+ readonly id: Schema.String;
722
+ readonly mediaType: Schema.optional<Schema.String>;
723
+ }>]>;
724
+ readonly info: Schema.optional<Schema.Struct<{
725
+ readonly width: Schema.optional<Schema.Number>;
726
+ readonly height: Schema.optional<Schema.Number>;
727
+ readonly durationSeconds: Schema.optional<Schema.Number>;
728
+ readonly sampleRate: Schema.optional<Schema.Number>;
729
+ readonly channels: Schema.optional<Schema.Number>;
730
+ readonly encoding: Schema.optional<Schema.String>;
731
+ readonly format: Schema.optional<Schema.String>;
732
+ }>>;
733
+ readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
734
+ }>, never, never>;
735
+ readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
736
+ readonly type: Schema.Literal<"tokens">;
737
+ readonly input: Schema.optional<Schema.Number>;
738
+ readonly output: Schema.optional<Schema.Number>;
739
+ readonly total: Schema.optional<Schema.Number>;
740
+ readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
722
741
  }>, Schema.Struct<{
723
- readonly type: Schema.Literal<"base64">;
724
- readonly data: Schema.String;
725
- readonly mediaType: Schema.String;
742
+ readonly type: Schema.Literal<"seconds">;
743
+ readonly seconds: Schema.Number;
726
744
  }>, Schema.Struct<{
727
- readonly type: Schema.Literal<"url">;
728
- readonly url: Schema.String;
729
- readonly mediaType: Schema.optional<Schema.String>;
730
- readonly expiresAt: Schema.optional<Schema.Number>;
745
+ readonly type: Schema.Literal<"characters">;
746
+ readonly characters: Schema.Number;
731
747
  }>, Schema.Struct<{
732
- readonly type: Schema.Literal<"ref">;
733
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
734
- readonly id: Schema.String;
735
- readonly mediaType: Schema.optional<Schema.String>;
736
- }>]>;
737
- readonly info: Schema.optional<Schema.Struct<{
738
- readonly width: Schema.optional<Schema.Number>;
739
- readonly height: Schema.optional<Schema.Number>;
740
- readonly durationSeconds: Schema.optional<Schema.Number>;
741
- readonly sampleRate: Schema.optional<Schema.Number>;
742
- readonly channels: Schema.optional<Schema.Number>;
743
- readonly encoding: Schema.optional<Schema.String>;
744
- readonly format: Schema.optional<Schema.String>;
745
- }>>;
748
+ readonly type: Schema.Literal<"credits">;
749
+ readonly credits: Schema.Number;
750
+ }>, Schema.Struct<{
751
+ readonly type: Schema.Literal<"compute">;
752
+ readonly seconds: Schema.Number;
753
+ }>]>>;
746
754
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
747
- }>, never, never>;
748
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
749
- readonly type: Schema.Literal<"tokens">;
750
- readonly input: Schema.optional<Schema.Number>;
751
- readonly output: Schema.optional<Schema.Number>;
752
- readonly total: Schema.optional<Schema.Number>;
753
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
754
- }>, Schema.Struct<{
755
- readonly type: Schema.Literal<"seconds">;
756
- readonly seconds: Schema.Number;
757
- }>, Schema.Struct<{
758
- readonly type: Schema.Literal<"characters">;
759
- readonly characters: Schema.Number;
760
- }>, Schema.Struct<{
761
- readonly type: Schema.Literal<"credits">;
762
- readonly credits: Schema.Number;
763
- }>, Schema.Struct<{
764
- readonly type: Schema.Literal<"compute">;
765
- readonly seconds: Schema.Number;
766
- }>]>>;
767
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
768
- }> as M["Type"]["type"]]: (value: M["Type"]) => any; }>(cases: Cases): (value: {
755
+ }>;
756
+ readonly "generation-progress": Schema.Struct<{
757
+ readonly type: Schema.tag<"generation-progress">;
758
+ readonly id: Schema.String;
759
+ readonly progress: Schema.optional<Schema.Number>;
760
+ }>;
761
+ readonly "generation-queued": Schema.Struct<{
762
+ readonly type: Schema.tag<"generation-queued">;
763
+ readonly id: Schema.String;
764
+ readonly position: Schema.optional<Schema.Number>;
765
+ }>;
766
+ readonly timestamps: Schema.Struct<{
767
+ readonly type: Schema.tag<"timestamps">;
768
+ readonly items: Schema.$Array<Schema.Struct<{
769
+ readonly text: Schema.String;
770
+ readonly startSeconds: Schema.Number;
771
+ readonly endSeconds: Schema.Number;
772
+ }>>;
773
+ }>;
774
+ }[K]["Type"]) => any; }>(cases: Handlers): (value: {
769
775
  readonly type: "audio-delta";
770
776
  readonly chunk: Uint8Array<ArrayBufferLike>;
771
777
  } | {
@@ -812,81 +818,10 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
812
818
  readonly [x: string]: unknown;
813
819
  };
814
820
  } | undefined;
815
- }) => Cases[keyof Cases] extends (value: any) => infer R ? import("effect/Unify").Unify<R> : never;
821
+ }) => import("effect/Unify").Unify<ReturnType<Handlers["audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"]>>;
816
822
  };
817
823
  readonly matchOrElse: {
818
- <Cases extends { [M in Schema.Struct<{
819
- readonly type: Schema.tag<"generation-queued">;
820
- readonly id: Schema.String;
821
- readonly position: Schema.optional<Schema.Number>;
822
- }> | Schema.Struct<{
823
- readonly type: Schema.tag<"generation-progress">;
824
- readonly id: Schema.String;
825
- readonly progress: Schema.optional<Schema.Number>;
826
- }> | Schema.Struct<{
827
- readonly type: Schema.tag<"audio-delta">;
828
- readonly chunk: Schema.Uint8Array;
829
- }> | Schema.Struct<{
830
- readonly type: Schema.tag<"timestamps">;
831
- readonly items: Schema.$Array<Schema.Struct<{
832
- readonly text: Schema.String;
833
- readonly startSeconds: Schema.Number;
834
- readonly endSeconds: Schema.Number;
835
- }>>;
836
- }> | Schema.Struct<{
837
- readonly type: Schema.tag<"finish">;
838
- readonly audio: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
839
- readonly source: Schema.Union<readonly [Schema.Struct<{
840
- readonly type: Schema.Literal<"bytes">;
841
- readonly data: Schema.Uint8Array;
842
- readonly mediaType: Schema.String;
843
- }>, Schema.Struct<{
844
- readonly type: Schema.Literal<"base64">;
845
- readonly data: Schema.String;
846
- readonly mediaType: Schema.String;
847
- }>, Schema.Struct<{
848
- readonly type: Schema.Literal<"url">;
849
- readonly url: Schema.String;
850
- readonly mediaType: Schema.optional<Schema.String>;
851
- readonly expiresAt: Schema.optional<Schema.Number>;
852
- }>, Schema.Struct<{
853
- readonly type: Schema.Literal<"ref">;
854
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
855
- readonly id: Schema.String;
856
- readonly mediaType: Schema.optional<Schema.String>;
857
- }>]>;
858
- readonly info: Schema.optional<Schema.Struct<{
859
- readonly width: Schema.optional<Schema.Number>;
860
- readonly height: Schema.optional<Schema.Number>;
861
- readonly durationSeconds: Schema.optional<Schema.Number>;
862
- readonly sampleRate: Schema.optional<Schema.Number>;
863
- readonly channels: Schema.optional<Schema.Number>;
864
- readonly encoding: Schema.optional<Schema.String>;
865
- readonly format: Schema.optional<Schema.String>;
866
- }>>;
867
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
868
- }>, never, never>;
869
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
870
- readonly type: Schema.Literal<"tokens">;
871
- readonly input: Schema.optional<Schema.Number>;
872
- readonly output: Schema.optional<Schema.Number>;
873
- readonly total: Schema.optional<Schema.Number>;
874
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
875
- }>, Schema.Struct<{
876
- readonly type: Schema.Literal<"seconds">;
877
- readonly seconds: Schema.Number;
878
- }>, Schema.Struct<{
879
- readonly type: Schema.Literal<"characters">;
880
- readonly characters: Schema.Number;
881
- }>, Schema.Struct<{
882
- readonly type: Schema.Literal<"credits">;
883
- readonly credits: Schema.Number;
884
- }>, Schema.Struct<{
885
- readonly type: Schema.Literal<"compute">;
886
- readonly seconds: Schema.Number;
887
- }>]>>;
888
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
889
- }> as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps">]: never; }, OrElse extends (value: Exclude<{
824
+ <Handlers, OrElse>(value: {
890
825
  readonly type: "audio-delta";
891
826
  readonly chunk: Uint8Array<ArrayBufferLike>;
892
827
  } | {
@@ -933,25 +868,86 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
933
868
  readonly [x: string]: unknown;
934
869
  };
935
870
  } | undefined;
936
- }, { readonly [K in "type"]: keyof Cases; }>) => any>(value: {
871
+ }, cases: Handlers & {
872
+ readonly "audio-delta"?: ((value: {
873
+ readonly type: "audio-delta";
874
+ readonly chunk: Uint8Array<ArrayBufferLike>;
875
+ }) => any) | undefined;
876
+ readonly finish?: ((value: {
877
+ readonly type: "finish";
878
+ readonly audio: Media.Asset;
879
+ readonly usage?: {
880
+ readonly type: "seconds";
881
+ readonly seconds: number;
882
+ } | {
883
+ readonly type: "characters";
884
+ readonly characters: number;
885
+ } | {
886
+ readonly type: "credits";
887
+ readonly credits: number;
888
+ } | {
889
+ readonly type: "compute";
890
+ readonly seconds: number;
891
+ } | {
892
+ readonly type: "tokens";
893
+ readonly input?: number | undefined;
894
+ readonly output?: number | undefined;
895
+ readonly total?: number | undefined;
896
+ readonly details?: {
897
+ readonly [x: string]: unknown;
898
+ } | undefined;
899
+ } | undefined;
900
+ readonly providerMetadata?: {
901
+ readonly [x: string]: {
902
+ readonly [x: string]: unknown;
903
+ };
904
+ } | undefined;
905
+ }) => any) | undefined;
906
+ readonly "generation-progress"?: ((value: {
907
+ readonly type: "generation-progress";
908
+ readonly id: string;
909
+ readonly progress?: number | undefined;
910
+ }) => any) | undefined;
911
+ readonly "generation-queued"?: ((value: {
912
+ readonly type: "generation-queued";
913
+ readonly id: string;
914
+ readonly position?: number | undefined;
915
+ }) => any) | undefined;
916
+ readonly timestamps?: ((value: {
917
+ readonly type: "timestamps";
918
+ readonly items: readonly {
919
+ readonly text: string;
920
+ readonly startSeconds: number;
921
+ readonly endSeconds: number;
922
+ }[];
923
+ }) => any) | undefined;
924
+ } & (Exclude<keyof Handlers, "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
937
925
  readonly type: "audio-delta";
938
926
  readonly chunk: Uint8Array<ArrayBufferLike>;
939
- } | {
927
+ }, {
928
+ readonly type: keyof Handlers;
929
+ }> | Exclude<{
940
930
  readonly type: "timestamps";
941
931
  readonly items: readonly {
942
932
  readonly text: string;
943
933
  readonly startSeconds: number;
944
934
  readonly endSeconds: number;
945
935
  }[];
946
- } | {
936
+ }, {
937
+ readonly type: keyof Handlers;
938
+ }> | Exclude<{
947
939
  readonly type: "generation-queued";
948
940
  readonly id: string;
949
941
  readonly position?: number | undefined;
950
- } | {
942
+ }, {
943
+ readonly type: keyof Handlers;
944
+ }> | Exclude<{
951
945
  readonly type: "generation-progress";
952
946
  readonly id: string;
953
947
  readonly progress?: number | undefined;
954
- } | {
948
+ }, {
949
+ readonly type: keyof Handlers;
950
+ }> | Exclude<{
955
951
  readonly type: "finish";
956
952
  readonly audio: Media.Asset;
957
953
  readonly usage?: {
@@ -980,97 +976,89 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
980
976
  readonly [x: string]: unknown;
981
977
  };
982
978
  } | undefined;
983
- }, 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>>;
984
- <Cases extends { [M in Schema.Struct<{
985
- readonly type: Schema.tag<"generation-queued">;
986
- readonly id: Schema.String;
987
- readonly position: Schema.optional<Schema.Number>;
988
- }> | Schema.Struct<{
989
- readonly type: Schema.tag<"generation-progress">;
990
- readonly id: Schema.String;
991
- readonly progress: Schema.optional<Schema.Number>;
992
- }> | Schema.Struct<{
993
- readonly type: Schema.tag<"audio-delta">;
994
- readonly chunk: Schema.Uint8Array;
995
- }> | Schema.Struct<{
996
- readonly type: Schema.tag<"timestamps">;
997
- readonly items: Schema.$Array<Schema.Struct<{
998
- readonly text: Schema.String;
999
- readonly startSeconds: Schema.Number;
1000
- readonly endSeconds: Schema.Number;
1001
- }>>;
1002
- }> | Schema.Struct<{
1003
- readonly type: Schema.tag<"finish">;
1004
- readonly audio: Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
1005
- readonly source: Schema.Union<readonly [Schema.Struct<{
1006
- readonly type: Schema.Literal<"bytes">;
1007
- readonly data: Schema.Uint8Array;
1008
- readonly mediaType: Schema.String;
1009
- }>, Schema.Struct<{
1010
- readonly type: Schema.Literal<"base64">;
1011
- readonly data: Schema.String;
1012
- readonly mediaType: Schema.String;
1013
- }>, Schema.Struct<{
1014
- readonly type: Schema.Literal<"url">;
1015
- readonly url: Schema.String;
1016
- readonly mediaType: Schema.optional<Schema.String>;
1017
- readonly expiresAt: Schema.optional<Schema.Number>;
1018
- }>, Schema.Struct<{
1019
- readonly type: Schema.Literal<"ref">;
1020
- readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
1021
- readonly id: Schema.String;
1022
- readonly mediaType: Schema.optional<Schema.String>;
1023
- }>]>;
1024
- readonly info: Schema.optional<Schema.Struct<{
1025
- readonly width: Schema.optional<Schema.Number>;
1026
- readonly height: Schema.optional<Schema.Number>;
1027
- readonly durationSeconds: Schema.optional<Schema.Number>;
1028
- readonly sampleRate: Schema.optional<Schema.Number>;
1029
- readonly channels: Schema.optional<Schema.Number>;
1030
- readonly encoding: Schema.optional<Schema.String>;
1031
- readonly format: Schema.optional<Schema.String>;
1032
- }>>;
1033
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1034
- }>, never, never>;
1035
- readonly usage: Schema.optional<Schema.Union<readonly [Schema.Struct<{
1036
- readonly type: Schema.Literal<"tokens">;
1037
- readonly input: Schema.optional<Schema.Number>;
1038
- readonly output: Schema.optional<Schema.Number>;
1039
- readonly total: Schema.optional<Schema.Number>;
1040
- readonly details: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
1041
- }>, Schema.Struct<{
1042
- readonly type: Schema.Literal<"seconds">;
1043
- readonly seconds: Schema.Number;
1044
- }>, Schema.Struct<{
1045
- readonly type: Schema.Literal<"characters">;
1046
- readonly characters: Schema.Number;
1047
- }>, Schema.Struct<{
1048
- readonly type: Schema.Literal<"credits">;
1049
- readonly credits: Schema.Number;
1050
- }>, Schema.Struct<{
1051
- readonly type: Schema.Literal<"compute">;
1052
- readonly seconds: Schema.Number;
1053
- }>]>>;
1054
- readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
1055
- }> as M["Type"]["type"]]+?: (value: M["Type"]) => any; } & { [K in Exclude<keyof Cases, "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps">]: never; }, OrElse extends (value: Exclude<{
979
+ }, {
980
+ readonly type: keyof Handlers;
981
+ }>) => 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)>;
982
+ <Handlers, OrElse>(cases: Handlers & {
983
+ readonly "audio-delta"?: ((value: {
984
+ readonly type: "audio-delta";
985
+ readonly chunk: Uint8Array<ArrayBufferLike>;
986
+ }) => any) | undefined;
987
+ readonly finish?: ((value: {
988
+ readonly type: "finish";
989
+ readonly audio: Media.Asset;
990
+ readonly usage?: {
991
+ readonly type: "seconds";
992
+ readonly seconds: number;
993
+ } | {
994
+ readonly type: "characters";
995
+ readonly characters: number;
996
+ } | {
997
+ readonly type: "credits";
998
+ readonly credits: number;
999
+ } | {
1000
+ readonly type: "compute";
1001
+ readonly seconds: number;
1002
+ } | {
1003
+ readonly type: "tokens";
1004
+ readonly input?: number | undefined;
1005
+ readonly output?: number | undefined;
1006
+ readonly total?: number | undefined;
1007
+ readonly details?: {
1008
+ readonly [x: string]: unknown;
1009
+ } | undefined;
1010
+ } | undefined;
1011
+ readonly providerMetadata?: {
1012
+ readonly [x: string]: {
1013
+ readonly [x: string]: unknown;
1014
+ };
1015
+ } | undefined;
1016
+ }) => any) | undefined;
1017
+ readonly "generation-progress"?: ((value: {
1018
+ readonly type: "generation-progress";
1019
+ readonly id: string;
1020
+ readonly progress?: number | undefined;
1021
+ }) => any) | undefined;
1022
+ readonly "generation-queued"?: ((value: {
1023
+ readonly type: "generation-queued";
1024
+ readonly id: string;
1025
+ readonly position?: number | undefined;
1026
+ }) => any) | undefined;
1027
+ readonly timestamps?: ((value: {
1028
+ readonly type: "timestamps";
1029
+ readonly items: readonly {
1030
+ readonly text: string;
1031
+ readonly startSeconds: number;
1032
+ readonly endSeconds: number;
1033
+ }[];
1034
+ }) => any) | undefined;
1035
+ } & (Exclude<keyof Handlers, "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
1056
1036
  readonly type: "audio-delta";
1057
1037
  readonly chunk: Uint8Array<ArrayBufferLike>;
1058
- } | {
1038
+ }, {
1039
+ readonly type: keyof Handlers;
1040
+ }> | Exclude<{
1059
1041
  readonly type: "timestamps";
1060
1042
  readonly items: readonly {
1061
1043
  readonly text: string;
1062
1044
  readonly startSeconds: number;
1063
1045
  readonly endSeconds: number;
1064
1046
  }[];
1065
- } | {
1047
+ }, {
1048
+ readonly type: keyof Handlers;
1049
+ }> | Exclude<{
1066
1050
  readonly type: "generation-queued";
1067
1051
  readonly id: string;
1068
1052
  readonly position?: number | undefined;
1069
- } | {
1053
+ }, {
1054
+ readonly type: keyof Handlers;
1055
+ }> | Exclude<{
1070
1056
  readonly type: "generation-progress";
1071
1057
  readonly id: string;
1072
1058
  readonly progress?: number | undefined;
1073
- } | {
1059
+ }, {
1060
+ readonly type: keyof Handlers;
1061
+ }> | Exclude<{
1074
1062
  readonly type: "finish";
1075
1063
  readonly audio: Media.Asset;
1076
1064
  readonly usage?: {
@@ -1099,7 +1087,9 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
1099
1087
  readonly [x: string]: unknown;
1100
1088
  };
1101
1089
  } | undefined;
1102
- }, { readonly [K in "type"]: keyof Cases; }>) => any>(cases: Cases, orElse: OrElse): (value: {
1090
+ }, {
1091
+ readonly type: keyof Handlers;
1092
+ }>) => any)): (value: {
1103
1093
  readonly type: "audio-delta";
1104
1094
  readonly chunk: Uint8Array<ArrayBufferLike>;
1105
1095
  } | {
@@ -1146,7 +1136,7 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
1146
1136
  readonly [x: string]: unknown;
1147
1137
  };
1148
1138
  } | undefined;
1149
- }) => import("effect/Unify").Unify<{ [K in keyof Cases]-?: NonNullable<Cases[K]> extends (...args: Array<any>) => infer R ? R : never; }[keyof Cases] | ReturnType<OrElse>>;
1139
+ }) => 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)>;
1150
1140
  };
1151
1141
  } & {
1152
1142
  is: {
@@ -1205,10 +1195,10 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
1205
1195
  };
1206
1196
  };
1207
1197
  export type SpeechEvent = Schema.Schema.Type<typeof speechEventTagged>;
1208
- export declare function request<const Model extends SpeechModel>(input: SpeechRequestInput<Model>): SpeechRequestFor<SpeechModelOptions<Model>>;
1209
- export declare function request(input: SpeechRequest): SpeechRequest;
1210
- export declare function generate<const Model extends SpeechModel>(input: SpeechRequest | SpeechRequestInput<Model>): Effect.Effect<SpeechResponse, AIError, Service>;
1211
- export declare function stream<const Model extends SpeechModel>(input: SpeechRequest | SpeechRequestInput<Model>): Stream.Stream<SpeechEvent, AIError, Service>;
1198
+ /** Normalize speech request input into a plain `SpeechRequest`. */
1199
+ export declare const request: <const Model extends SpeechModel>(input: SpeechRequestInput<Model>) => SpeechRequest<Model>;
1200
+ export declare function generate<const Model extends SpeechModel>(input: SpeechRequestInput<Model>): Effect.Effect<SpeechResponse, AIError, Service>;
1201
+ export declare function stream<const Model extends SpeechModel>(input: SpeechRequestInput<Model>): Stream.Stream<SpeechEvent, AIError, Service>;
1212
1202
  export declare const Speech: {
1213
1203
  readonly request: typeof request;
1214
1204
  readonly generate: typeof generate;