@opencode/ai 2.0.14 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/README.md +399 -56
  2. package/dist/experimental/evaluation-client.d.ts +1 -1
  3. package/dist/experimental/evaluation-client.js +39 -3
  4. package/dist/experimental/evaluation.d.ts +4 -4
  5. package/dist/experimental/evaluation.js +2 -2
  6. package/dist/experimental/system-one.d.ts +3 -3
  7. package/dist/experimental/system-one.js +40 -51
  8. package/dist/generation.d.ts +83 -0
  9. package/dist/generation.js +113 -0
  10. package/dist/image-client.d.ts +16 -7
  11. package/dist/image-client.js +29 -13
  12. package/dist/image.d.ts +1410 -81
  13. package/dist/image.js +97 -67
  14. package/dist/index.d.ts +17 -2
  15. package/dist/index.js +12 -1
  16. package/dist/llm.d.ts +9 -1
  17. package/dist/media-model.d.ts +44 -0
  18. package/dist/media-model.js +49 -0
  19. package/dist/media.d.ts +213 -0
  20. package/dist/media.js +227 -0
  21. package/dist/promise.d.ts +974 -0
  22. package/dist/promise.js +81 -0
  23. package/dist/protocols/alibaba-chat.d.ts +12 -0
  24. package/dist/protocols/alibaba-responses.d.ts +2 -2
  25. package/dist/protocols/anthropic-messages.js +8 -19
  26. package/dist/protocols/assemblyai-transcription.d.ts +40 -0
  27. package/dist/protocols/assemblyai-transcription.js +138 -0
  28. package/dist/protocols/bedrock-converse.d.ts +4 -4
  29. package/dist/protocols/bedrock-converse.js +6 -17
  30. package/dist/protocols/bfl-images.d.ts +32 -0
  31. package/dist/protocols/bfl-images.js +153 -0
  32. package/dist/protocols/cartesia-speech.d.ts +127 -0
  33. package/dist/protocols/cartesia-speech.js +126 -0
  34. package/dist/protocols/deepgram-speech.d.ts +119 -0
  35. package/dist/protocols/deepgram-speech.js +92 -0
  36. package/dist/protocols/deepgram-transcription.d.ts +25 -0
  37. package/dist/protocols/deepgram-transcription.js +129 -0
  38. package/dist/protocols/elevenlabs-speech.d.ts +122 -0
  39. package/dist/protocols/elevenlabs-speech.js +115 -0
  40. package/dist/protocols/fal-images.d.ts +24 -0
  41. package/dist/protocols/fal-images.js +114 -0
  42. package/dist/protocols/fal-video.d.ts +29 -0
  43. package/dist/protocols/fal-video.js +88 -0
  44. package/dist/protocols/gemini.d.ts +30 -9
  45. package/dist/protocols/gemini.js +45 -35
  46. package/dist/protocols/google-images.d.ts +9 -21
  47. package/dist/protocols/google-images.js +158 -133
  48. package/dist/protocols/google-speech.d.ts +130 -0
  49. package/dist/protocols/google-speech.js +84 -0
  50. package/dist/protocols/google-transcription.d.ts +173 -0
  51. package/dist/protocols/google-transcription.js +138 -0
  52. package/dist/protocols/google-video.d.ts +26 -0
  53. package/dist/protocols/google-video.js +158 -0
  54. package/dist/protocols/meta-images.d.ts +7 -12
  55. package/dist/protocols/meta-images.js +85 -66
  56. package/dist/protocols/meta-responses.d.ts +4 -4
  57. package/dist/protocols/meta-responses.js +1 -1
  58. package/dist/protocols/mistral-chat.js +7 -6
  59. package/dist/protocols/open-responses.d.ts +17 -9
  60. package/dist/protocols/open-responses.js +24 -14
  61. package/dist/protocols/openai-chat.d.ts +118 -1
  62. package/dist/protocols/openai-chat.js +125 -44
  63. package/dist/protocols/openai-compatible-chat.d.ts +12 -0
  64. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  65. package/dist/protocols/openai-images.d.ts +128 -18
  66. package/dist/protocols/openai-images.js +177 -154
  67. package/dist/protocols/openai-responses.d.ts +15 -15
  68. package/dist/protocols/openai-responses.js +5 -6
  69. package/dist/protocols/openai-speech.d.ts +116 -0
  70. package/dist/protocols/openai-speech.js +98 -0
  71. package/dist/protocols/openai-transcription.d.ts +207 -0
  72. package/dist/protocols/openai-transcription.js +190 -0
  73. package/dist/protocols/replicate-images.d.ts +28 -0
  74. package/dist/protocols/replicate-images.js +133 -0
  75. package/dist/protocols/runway-video.d.ts +38 -0
  76. package/dist/protocols/runway-video.js +146 -0
  77. package/dist/protocols/shared.d.ts +27 -17
  78. package/dist/protocols/shared.js +52 -35
  79. package/dist/protocols/stability-images.d.ts +38 -0
  80. package/dist/protocols/stability-images.js +148 -0
  81. package/dist/protocols/utils/bedrock-media.d.ts +2 -3
  82. package/dist/protocols/utils/bedrock-media.js +4 -4
  83. package/dist/protocols/utils/fal-queue.d.ts +28 -0
  84. package/dist/protocols/utils/fal-queue.js +69 -0
  85. package/dist/protocols/utils/gemini-generate-content.d.ts +65 -0
  86. package/dist/protocols/utils/gemini-generate-content.js +65 -0
  87. package/dist/protocols/utils/gemini-json-schema.d.ts +3 -0
  88. package/dist/protocols/utils/gemini-json-schema.js +76 -0
  89. package/dist/protocols/utils/media-input.d.ts +18 -0
  90. package/dist/protocols/utils/media-input.js +35 -0
  91. package/dist/protocols/utils/responses-compaction.js +6 -5
  92. package/dist/protocols/utils/speech-stream.d.ts +49 -0
  93. package/dist/protocols/utils/speech-stream.js +67 -0
  94. package/dist/protocols/utils/tool-schema.d.ts +2 -2
  95. package/dist/protocols/utils/tool-schema.js +40 -17
  96. package/dist/protocols/utils/tool-stream.d.ts +27 -3
  97. package/dist/protocols/xai-images.d.ts +9 -15
  98. package/dist/protocols/xai-images.js +75 -84
  99. package/dist/protocols/xai-responses.d.ts +2 -2
  100. package/dist/protocols/xai-video.d.ts +34 -0
  101. package/dist/protocols/xai-video.js +147 -0
  102. package/dist/protocols/zai-chat.d.ts +13 -1
  103. package/dist/protocols/zai-images.d.ts +9 -13
  104. package/dist/protocols/zai-images.js +59 -57
  105. package/dist/provider-error.js +3 -0
  106. package/dist/providers/alibaba.d.ts +14 -2
  107. package/dist/providers/amazon-bedrock-mantle.d.ts +14 -2
  108. package/dist/providers/amazon-bedrock.d.ts +2 -2
  109. package/dist/providers/assemblyai.d.ts +25 -0
  110. package/dist/providers/assemblyai.js +29 -0
  111. package/dist/providers/azure.d.ts +18 -6
  112. package/dist/providers/baseten.d.ts +24 -0
  113. package/dist/providers/black-forest-labs.d.ts +25 -0
  114. package/dist/providers/black-forest-labs.js +28 -0
  115. package/dist/providers/cartesia.d.ts +24 -0
  116. package/dist/providers/cartesia.js +22 -0
  117. package/dist/providers/cerebras.d.ts +24 -0
  118. package/dist/providers/cerebras.js +6 -1
  119. package/dist/providers/cloudflare-ai-gateway.d.ts +30 -6
  120. package/dist/providers/cloudflare-workers-ai.d.ts +24 -0
  121. package/dist/providers/deepgram.d.ts +29 -0
  122. package/dist/providers/deepgram.js +31 -0
  123. package/dist/providers/deepinfra.d.ts +24 -0
  124. package/dist/providers/deepinfra.js +6 -1
  125. package/dist/providers/deepseek.d.ts +24 -0
  126. package/dist/providers/elevenlabs.d.ts +24 -0
  127. package/dist/providers/elevenlabs.js +28 -0
  128. package/dist/providers/fal.d.ts +29 -0
  129. package/dist/providers/fal.js +33 -0
  130. package/dist/providers/fireworks.d.ts +24 -0
  131. package/dist/providers/google-vertex-chat.d.ts +12 -0
  132. package/dist/providers/google-vertex-responses.d.ts +2 -2
  133. package/dist/providers/google-vertex.d.ts +10 -3
  134. package/dist/providers/google.d.ts +25 -3
  135. package/dist/providers/google.js +11 -2
  136. package/dist/providers/groq.d.ts +24 -0
  137. package/dist/providers/index.d.ts +10 -0
  138. package/dist/providers/index.js +10 -0
  139. package/dist/providers/meta.d.ts +14 -2
  140. package/dist/providers/minimax.d.ts +14 -2
  141. package/dist/providers/moonshot.d.ts +14 -2
  142. package/dist/providers/moonshot.js +3 -3
  143. package/dist/providers/openai-compatible-responses.d.ts +2 -2
  144. package/dist/providers/openai-compatible.d.ts +12 -0
  145. package/dist/providers/openai.d.ts +25 -3
  146. package/dist/providers/openai.js +10 -1
  147. package/dist/providers/openrouter.d.ts +67 -0
  148. package/dist/providers/openrouter.js +13 -1
  149. package/dist/providers/replicate.d.ts +25 -0
  150. package/dist/providers/replicate.js +22 -0
  151. package/dist/providers/runway.d.ts +24 -0
  152. package/dist/providers/runway.js +22 -0
  153. package/dist/providers/stability.d.ts +28 -0
  154. package/dist/providers/stability.js +23 -0
  155. package/dist/providers/togetherai.d.ts +24 -0
  156. package/dist/providers/vercel-ai-gateway.d.ts +41 -0
  157. package/dist/providers/vercel-ai-gateway.js +85 -0
  158. package/dist/providers/xai.d.ts +17 -0
  159. package/dist/providers/xai.js +5 -2
  160. package/dist/providers/zai-coding-plan.d.ts +15 -3
  161. package/dist/providers/zai.d.ts +13 -1
  162. package/dist/route/auth.d.ts +4 -1
  163. package/dist/route/auth.js +6 -0
  164. package/dist/route/client.d.ts +9 -1
  165. package/dist/route/endpoint.d.ts +10 -10
  166. package/dist/route/executor-service.d.ts +12 -0
  167. package/dist/route/executor-service.js +3 -0
  168. package/dist/route/executor.d.ts +4 -9
  169. package/dist/route/executor.js +3 -3
  170. package/dist/route/framing.d.ts +5 -1
  171. package/dist/route/framing.js +9 -0
  172. package/dist/route/index.d.ts +2 -0
  173. package/dist/route/index.js +2 -0
  174. package/dist/route/media-protocol.d.ts +158 -0
  175. package/dist/route/media-protocol.js +96 -0
  176. package/dist/route/media.d.ts +97 -0
  177. package/dist/route/media.js +236 -0
  178. package/dist/schema/errors.d.ts +13 -3
  179. package/dist/schema/errors.js +7 -0
  180. package/dist/schema/events.d.ts +557 -40
  181. package/dist/schema/events.js +35 -2
  182. package/dist/schema/messages.d.ts +95 -8
  183. package/dist/schema/messages.js +8 -6
  184. package/dist/schema/options.d.ts +6 -3
  185. package/dist/schema/options.js +6 -2
  186. package/dist/speech-client.d.ts +21 -0
  187. package/dist/speech-client.js +25 -0
  188. package/dist/speech.d.ts +1150 -0
  189. package/dist/speech.js +119 -0
  190. package/dist/testing.d.ts +72 -8
  191. package/dist/transcription-client.d.ts +28 -0
  192. package/dist/transcription-client.js +44 -0
  193. package/dist/transcription.d.ts +1504 -0
  194. package/dist/transcription.js +133 -0
  195. package/dist/utils/bytes.d.ts +1 -0
  196. package/dist/utils/bytes.js +10 -0
  197. package/dist/utils/media-type.d.ts +7 -0
  198. package/dist/utils/media-type.js +70 -0
  199. package/dist/utils/sanitize.js +3 -1
  200. package/dist/video-client.d.ts +28 -0
  201. package/dist/video-client.js +40 -0
  202. package/dist/video.d.ts +1359 -0
  203. package/dist/video.js +119 -0
  204. package/package.json +7 -3
  205. package/dist/protocols/utils/gemini-tool-schema.d.ts +0 -2
  206. package/dist/protocols/utils/gemini-tool-schema.js +0 -103
  207. package/dist/protocols/utils/image-input.d.ts +0 -21
  208. package/dist/protocols/utils/image-input.js +0 -20
package/dist/speech.js ADDED
@@ -0,0 +1,119 @@
1
+ import { Effect, Schema, Stream } from "effect";
2
+ import { Media } from "./media.js";
3
+ import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
4
+ import { MediaRoute } from "./route/media.js";
5
+ import { AIError, HttpOptions, MediaUsage, ProviderMetadata } from "./schema/index.js";
6
+ import { SpeechClient, Service } from "./speech-client.js";
7
+ export class SpeechModel extends MediaModel {
8
+ static make(input) {
9
+ return new SpeechModel(input);
10
+ }
11
+ /** Compose a streaming speech protocol with its canonical path into a model for one deployment. */
12
+ static fromRoute(route, input) {
13
+ return new SpeechModel({
14
+ id: input.id,
15
+ provider: route.provider,
16
+ http: input.http,
17
+ route: composeRoute((composition) => MediaRoute.stream({ ...composition, collect: collectResponse }), route, input),
18
+ });
19
+ }
20
+ }
21
+ export const SpeechModelSchema = Schema.declare((value) => value instanceof SpeechModel, {
22
+ expected: "Speech.Model",
23
+ });
24
+ // ---------------------------------------------------------------------------
25
+ // Request
26
+ // ---------------------------------------------------------------------------
27
+ /** Provider-native: a name on OpenAI and Gemini, a voice id on ElevenLabs and Cartesia; `{ id }` is an OpenAI custom voice. */
28
+ export const SpeechVoice = Schema.Union([Schema.String, Schema.Struct({ id: Schema.String })]).annotate({
29
+ identifier: "Speech.Voice",
30
+ });
31
+ /** Granularity is provider-native: characters on ElevenLabs, words on Cartesia. */
32
+ export const SpeechTimestamp = Schema.Struct({
33
+ text: Schema.String,
34
+ startSeconds: Schema.Number,
35
+ endSeconds: Schema.Number,
36
+ }).annotate({ identifier: "Speech.Timestamp" });
37
+ export class SpeechRequest extends Schema.Class("Speech.Request")({
38
+ model: SpeechModelSchema,
39
+ text: Schema.String,
40
+ voice: Schema.optional(SpeechVoice),
41
+ format: Schema.optional(Schema.String),
42
+ speed: Schema.optional(Schema.Number),
43
+ language: Schema.optional(Schema.String),
44
+ instructions: Schema.optional(Schema.String),
45
+ timestamps: Schema.optional(Schema.Boolean),
46
+ providerOptions: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
47
+ http: Schema.optional(HttpOptions),
48
+ }) {
49
+ }
50
+ // ---------------------------------------------------------------------------
51
+ // Response and events
52
+ // ---------------------------------------------------------------------------
53
+ export class SpeechResponse extends Schema.Class("Speech.Response")({
54
+ /** The complete audio. Headerless PCM carries `info.encoding`, `info.sampleRate`, and `info.channels`. */
55
+ audio: Media.AssetSchema,
56
+ timestamps: Schema.optional(Schema.Array(SpeechTimestamp)),
57
+ usage: Schema.optional(MediaUsage),
58
+ notices: Schema.optional(Schema.Array(Media.Notice)),
59
+ providerMetadata: Schema.optional(ProviderMetadata),
60
+ }) {
61
+ }
62
+ export const SpeechAudioDeltaEvent = Schema.Struct({
63
+ type: Schema.tag("audio-delta"),
64
+ chunk: Schema.Uint8Array,
65
+ }).annotate({ identifier: "Speech.Event.AudioDelta" });
66
+ export const SpeechTimestampsEvent = Schema.Struct({
67
+ type: Schema.tag("timestamps"),
68
+ items: Schema.Array(SpeechTimestamp),
69
+ }).annotate({ identifier: "Speech.Event.Timestamps" });
70
+ /** `audio` is every `audio-delta` chunk concatenated, so the route holds the whole clip in memory until `finish`. */
71
+ export const SpeechFinishEvent = Schema.Struct({
72
+ type: Schema.tag("finish"),
73
+ audio: Media.AssetSchema,
74
+ usage: Schema.optional(MediaUsage),
75
+ notices: Schema.optional(Schema.Array(Media.Notice)),
76
+ providerMetadata: Schema.optional(ProviderMetadata),
77
+ }).annotate({ identifier: "Speech.Event.Finish" });
78
+ const speechEventTagged = Schema.Union([SpeechAudioDeltaEvent, SpeechTimestampsEvent, SpeechFinishEvent]).pipe(Schema.toTaggedUnion("type"));
79
+ export const SpeechEvent = Object.assign(speechEventTagged, {
80
+ is: {
81
+ audioDelta: speechEventTagged.guards["audio-delta"],
82
+ timestamps: speechEventTagged.guards.timestamps,
83
+ finish: speechEventTagged.guards.finish,
84
+ },
85
+ });
86
+ const collectResponse = (events) => {
87
+ const finish = events.find(SpeechEvent.is.finish);
88
+ // Every speech protocol's `finish` emits the terminal event or fails, so a completed stream always has one.
89
+ if (finish === undefined)
90
+ return Effect.die(new Error("The speech stream completed without a finish event"));
91
+ const timestamps = events.filter(SpeechEvent.is.timestamps).flatMap((event) => event.items);
92
+ return Effect.succeed(new SpeechResponse({
93
+ audio: finish.audio,
94
+ timestamps: timestamps.length === 0 ? undefined : timestamps,
95
+ usage: finish.usage,
96
+ notices: finish.notices,
97
+ providerMetadata: finish.providerMetadata,
98
+ }));
99
+ };
100
+ export function request(input) {
101
+ if (input instanceof SpeechRequest)
102
+ return input;
103
+ return new SpeechRequest({
104
+ ...input,
105
+ http: input.http === undefined ? undefined : HttpOptions.make(input.http),
106
+ });
107
+ }
108
+ const requestEffect = (input) => tryRequest(() => request(input));
109
+ export function generate(input) {
110
+ return requestEffect(input).pipe(Effect.flatMap((request) => SpeechClient.generate(request)));
111
+ }
112
+ export function stream(input) {
113
+ return Stream.unwrap(requestEffect(input).pipe(Effect.map((request) => SpeechClient.stream(request))));
114
+ }
115
+ export const Speech = {
116
+ request,
117
+ generate,
118
+ stream,
119
+ };
package/dist/testing.d.ts CHANGED
@@ -215,6 +215,14 @@ export declare const complete: (options: {
215
215
  };
216
216
  } | undefined;
217
217
  readonly namespace?: string | undefined;
218
+ } | {
219
+ readonly type: "media";
220
+ readonly media: import("./media.js").Asset;
221
+ readonly providerMetadata?: {
222
+ readonly [x: string]: {
223
+ readonly [x: string]: unknown;
224
+ };
225
+ } | undefined;
218
226
  } | {
219
227
  readonly type: "step-finish";
220
228
  readonly reason: {
@@ -243,12 +251,12 @@ export declare const complete: (options: {
243
251
  } | {
244
252
  readonly type: "provider-error";
245
253
  readonly message: string;
254
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
246
255
  readonly providerMetadata?: {
247
256
  readonly [x: string]: {
248
257
  readonly [x: string]: unknown;
249
258
  };
250
259
  } | undefined;
251
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
252
260
  })[];
253
261
  export declare const stop: (...events: readonly LLMEvent[]) => (({
254
262
  readonly type: "compaction";
@@ -419,6 +427,14 @@ export declare const stop: (...events: readonly LLMEvent[]) => (({
419
427
  };
420
428
  } | undefined;
421
429
  readonly namespace?: string | undefined;
430
+ } | {
431
+ readonly type: "media";
432
+ readonly media: import("./media.js").Asset;
433
+ readonly providerMetadata?: {
434
+ readonly [x: string]: {
435
+ readonly [x: string]: unknown;
436
+ };
437
+ } | undefined;
422
438
  } | {
423
439
  readonly type: "step-finish";
424
440
  readonly reason: {
@@ -447,12 +463,12 @@ export declare const stop: (...events: readonly LLMEvent[]) => (({
447
463
  } | {
448
464
  readonly type: "provider-error";
449
465
  readonly message: string;
466
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
450
467
  readonly providerMetadata?: {
451
468
  readonly [x: string]: {
452
469
  readonly [x: string]: unknown;
453
470
  };
454
471
  } | undefined;
455
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
456
472
  })[];
457
473
  export declare const toolCalls: (...events: readonly LLMEvent[]) => (({
458
474
  readonly type: "compaction";
@@ -623,6 +639,14 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => (({
623
639
  };
624
640
  } | undefined;
625
641
  readonly namespace?: string | undefined;
642
+ } | {
643
+ readonly type: "media";
644
+ readonly media: import("./media.js").Asset;
645
+ readonly providerMetadata?: {
646
+ readonly [x: string]: {
647
+ readonly [x: string]: unknown;
648
+ };
649
+ } | undefined;
626
650
  } | {
627
651
  readonly type: "step-finish";
628
652
  readonly reason: {
@@ -651,12 +675,12 @@ export declare const toolCalls: (...events: readonly LLMEvent[]) => (({
651
675
  } | {
652
676
  readonly type: "provider-error";
653
677
  readonly message: string;
678
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
654
679
  readonly providerMetadata?: {
655
680
  readonly [x: string]: {
656
681
  readonly [x: string]: unknown;
657
682
  };
658
683
  } | undefined;
659
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
660
684
  })[];
661
685
  export declare const text: (value: string, id: string) => (({
662
686
  readonly type: "compaction";
@@ -827,6 +851,14 @@ export declare const text: (value: string, id: string) => (({
827
851
  };
828
852
  } | undefined;
829
853
  readonly namespace?: string | undefined;
854
+ } | {
855
+ readonly type: "media";
856
+ readonly media: import("./media.js").Asset;
857
+ readonly providerMetadata?: {
858
+ readonly [x: string]: {
859
+ readonly [x: string]: unknown;
860
+ };
861
+ } | undefined;
830
862
  } | {
831
863
  readonly type: "step-finish";
832
864
  readonly reason: {
@@ -855,12 +887,12 @@ export declare const text: (value: string, id: string) => (({
855
887
  } | {
856
888
  readonly type: "provider-error";
857
889
  readonly message: string;
890
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
858
891
  readonly providerMetadata?: {
859
892
  readonly [x: string]: {
860
893
  readonly [x: string]: unknown;
861
894
  };
862
895
  } | undefined;
863
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
864
896
  })[];
865
897
  export declare const textWithUsage: (value: string, id: string, inputTokens: number) => (({
866
898
  readonly type: "compaction";
@@ -1031,6 +1063,14 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: num
1031
1063
  };
1032
1064
  } | undefined;
1033
1065
  readonly namespace?: string | undefined;
1066
+ } | {
1067
+ readonly type: "media";
1068
+ readonly media: import("./media.js").Asset;
1069
+ readonly providerMetadata?: {
1070
+ readonly [x: string]: {
1071
+ readonly [x: string]: unknown;
1072
+ };
1073
+ } | undefined;
1034
1074
  } | {
1035
1075
  readonly type: "step-finish";
1036
1076
  readonly reason: {
@@ -1059,12 +1099,12 @@ export declare const textWithUsage: (value: string, id: string, inputTokens: num
1059
1099
  } | {
1060
1100
  readonly type: "provider-error";
1061
1101
  readonly message: string;
1102
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1062
1103
  readonly providerMetadata?: {
1063
1104
  readonly [x: string]: {
1064
1105
  readonly [x: string]: unknown;
1065
1106
  };
1066
1107
  } | undefined;
1067
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1068
1108
  })[];
1069
1109
  export declare const tool: (id: string, name: string, input: unknown) => (({
1070
1110
  readonly type: "compaction";
@@ -1235,6 +1275,14 @@ export declare const tool: (id: string, name: string, input: unknown) => (({
1235
1275
  };
1236
1276
  } | undefined;
1237
1277
  readonly namespace?: string | undefined;
1278
+ } | {
1279
+ readonly type: "media";
1280
+ readonly media: import("./media.js").Asset;
1281
+ readonly providerMetadata?: {
1282
+ readonly [x: string]: {
1283
+ readonly [x: string]: unknown;
1284
+ };
1285
+ } | undefined;
1238
1286
  } | {
1239
1287
  readonly type: "step-finish";
1240
1288
  readonly reason: {
@@ -1263,12 +1311,12 @@ export declare const tool: (id: string, name: string, input: unknown) => (({
1263
1311
  } | {
1264
1312
  readonly type: "provider-error";
1265
1313
  readonly message: string;
1314
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1266
1315
  readonly providerMetadata?: {
1267
1316
  readonly [x: string]: {
1268
1317
  readonly [x: string]: unknown;
1269
1318
  };
1270
1319
  } | undefined;
1271
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1272
1320
  })[];
1273
1321
  export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[]) => Stream.Stream<({
1274
1322
  readonly type: "compaction";
@@ -1439,6 +1487,14 @@ export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[])
1439
1487
  };
1440
1488
  } | undefined;
1441
1489
  readonly namespace?: string | undefined;
1490
+ } | {
1491
+ readonly type: "media";
1492
+ readonly media: import("./media.js").Asset;
1493
+ readonly providerMetadata?: {
1494
+ readonly [x: string]: {
1495
+ readonly [x: string]: unknown;
1496
+ };
1497
+ } | undefined;
1442
1498
  } | {
1443
1499
  readonly type: "step-finish";
1444
1500
  readonly reason: {
@@ -1467,12 +1523,12 @@ export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[])
1467
1523
  } | {
1468
1524
  readonly type: "provider-error";
1469
1525
  readonly message: string;
1526
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1470
1527
  readonly providerMetadata?: {
1471
1528
  readonly [x: string]: {
1472
1529
  readonly [x: string]: unknown;
1473
1530
  };
1474
1531
  } | undefined;
1475
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1476
1532
  }, AIError, never>;
1477
1533
  export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Stream<({
1478
1534
  readonly type: "compaction";
@@ -1643,6 +1699,14 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
1643
1699
  };
1644
1700
  } | undefined;
1645
1701
  readonly namespace?: string | undefined;
1702
+ } | {
1703
+ readonly type: "media";
1704
+ readonly media: import("./media.js").Asset;
1705
+ readonly providerMetadata?: {
1706
+ readonly [x: string]: {
1707
+ readonly [x: string]: unknown;
1708
+ };
1709
+ } | undefined;
1646
1710
  } | {
1647
1711
  readonly type: "step-finish";
1648
1712
  readonly reason: {
@@ -1671,12 +1735,12 @@ export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Strea
1671
1735
  } | {
1672
1736
  readonly type: "provider-error";
1673
1737
  readonly message: string;
1738
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1674
1739
  readonly providerMetadata?: {
1675
1740
  readonly [x: string]: {
1676
1741
  readonly [x: string]: unknown;
1677
1742
  };
1678
1743
  } | undefined;
1679
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1680
1744
  }, never, never>;
1681
1745
  /** Provides one shared implementation under the normal client and test-control tags. */
1682
1746
  export declare const testLayer: (options?: LayerOptions) => Layer.Layer<import("./route/client.js").Service | Test, never, never>;
@@ -0,0 +1,28 @@
1
+ import { Context, Effect, Layer, Stream } from "effect";
2
+ import type { AwaitOptions, Generation } from "./generation.js";
3
+ import { RequestExecutor } from "./route/executor.js";
4
+ import type { AIError } from "./schema/index.js";
5
+ import { type TranscriptionEvent, type TranscriptionModel, type TranscriptionOptions, type TranscriptionRequestFor, type TranscriptionResponse } from "./transcription.js";
6
+ export interface Interface {
7
+ readonly generate: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Effect.Effect<TranscriptionResponse, AIError>;
8
+ readonly stream: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Stream.Stream<TranscriptionEvent, AIError>;
9
+ readonly start: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>) => Effect.Effect<Generation<TranscriptionResponse>, AIError>;
10
+ readonly resume: <Options extends TranscriptionOptions>(model: TranscriptionModel<Options>, token: unknown) => Effect.Effect<Generation<TranscriptionResponse>, AIError>;
11
+ }
12
+ declare const Service_base: Context.ServiceClass<Service, "@opencode/TranscriptionClient", Interface>;
13
+ export declare class Service extends Service_base {
14
+ }
15
+ export declare const generate: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Effect.Effect<TranscriptionResponse, AIError, Service>;
16
+ export declare const stream: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Stream.Stream<TranscriptionEvent, AIError, Service>;
17
+ export declare const start: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
18
+ export declare const resume: <Options extends TranscriptionOptions>(model: TranscriptionModel<Options>, token: unknown) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
19
+ export declare const layer: Layer.Layer<Service, never, RequestExecutor.Service>;
20
+ export declare const TranscriptionClient: {
21
+ readonly Service: typeof Service;
22
+ readonly layer: Layer.Layer<Service, never, RequestExecutor.Service>;
23
+ readonly generate: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Effect.Effect<TranscriptionResponse, AIError, Service>;
24
+ readonly stream: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>, options?: AwaitOptions) => Stream.Stream<TranscriptionEvent, AIError, Service>;
25
+ readonly start: <Options extends TranscriptionOptions>(request: TranscriptionRequestFor<Options>) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
26
+ readonly resume: <Options extends TranscriptionOptions>(model: TranscriptionModel<Options>, token: unknown) => Effect.Effect<Generation<TranscriptionResponse>, AIError, Service>;
27
+ };
28
+ export {};
@@ -0,0 +1,44 @@
1
+ import { Context, Effect, Layer, Stream } from "effect";
2
+ import { RequestExecutor } from "./route/executor.js";
3
+ import { MediaRoute } from "./route/media.js";
4
+ import { responseEvents, } from "./transcription.js";
5
+ export class Service extends Context.Service()("@opencode/TranscriptionClient") {
6
+ }
7
+ export const generate = (request, options) => Effect.gen(function* () {
8
+ const client = yield* Service;
9
+ return yield* client.generate(request, options);
10
+ });
11
+ export const stream = (request, options) => Stream.unwrap(Effect.gen(function* () {
12
+ const client = yield* Service;
13
+ return client.stream(request, options);
14
+ }));
15
+ export const start = (request) => Effect.gen(function* () {
16
+ const client = yield* Service;
17
+ return yield* client.start(request);
18
+ });
19
+ export const resume = (model, token) => Effect.gen(function* () {
20
+ const client = yield* Service;
21
+ return yield* client.resume(model, token);
22
+ });
23
+ export const layer = Layer.effect(Service, Effect.gen(function* () {
24
+ const executor = yield* RequestExecutor.Service;
25
+ const dispatch = MediaRoute.dispatch({
26
+ modality: "transcription",
27
+ execute: executor.execute,
28
+ responseEvents,
29
+ });
30
+ return Service.of({
31
+ start: (request) => dispatch.start(request.model.route, request),
32
+ resume: (model, token) => dispatch.resume(model.route, model, token),
33
+ generate: (request, options) => dispatch.generate(request.model.route, request, options),
34
+ stream: (request, options) => dispatch.stream(request.model.route, request, options),
35
+ });
36
+ }));
37
+ export const TranscriptionClient = {
38
+ Service,
39
+ layer,
40
+ generate,
41
+ stream,
42
+ start,
43
+ resume,
44
+ };