@opencode/ai 0.0.0-dev-1297 → 0.0.0-dev-1299

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 (43) hide show
  1. package/README.md +27 -3
  2. package/dist/generation.d.ts +10 -10
  3. package/dist/generation.js +8 -14
  4. package/dist/image-client.d.ts +5 -1
  5. package/dist/image-client.js +1 -1
  6. package/dist/image.d.ts +10 -89
  7. package/dist/image.js +2 -9
  8. package/dist/index.d.ts +13 -18
  9. package/dist/index.js +17 -15
  10. package/dist/media-client.d.ts +5 -1
  11. package/dist/media.d.ts +9 -1
  12. package/dist/media.js +14 -7
  13. package/dist/protocols/assemblyai-transcription.js +7 -6
  14. package/dist/protocols/cartesia-speech.d.ts +0 -8
  15. package/dist/protocols/deepgram-speech.d.ts +0 -8
  16. package/dist/protocols/elevenlabs-speech.d.ts +0 -8
  17. package/dist/protocols/google-interactions-video.js +3 -3
  18. package/dist/protocols/google-speech.d.ts +0 -8
  19. package/dist/protocols/google-transcription.d.ts +0 -8
  20. package/dist/protocols/minimax-video.js +11 -11
  21. package/dist/protocols/openai-images.d.ts +0 -8
  22. package/dist/protocols/openai-speech.d.ts +0 -8
  23. package/dist/protocols/openai-transcription.d.ts +0 -8
  24. package/dist/protocols/openrouter-video.js +7 -7
  25. package/dist/protocols/seedance-video.js +5 -5
  26. package/dist/protocols/xai-video.js +6 -3
  27. package/dist/public.d.ts +2 -1
  28. package/dist/route/executor-service.d.ts +14 -1
  29. package/dist/route/executor-service.js +28 -1
  30. package/dist/route/executor.d.ts +5 -2
  31. package/dist/route/executor.js +20 -5
  32. package/dist/route/media-protocol.d.ts +12 -7
  33. package/dist/route/media-protocol.js +11 -4
  34. package/dist/route/media.js +12 -3
  35. package/dist/speech-client.d.ts +5 -5
  36. package/dist/speech.d.ts +7 -88
  37. package/dist/speech.js +1 -3
  38. package/dist/transcription-client.d.ts +5 -5
  39. package/dist/transcription.d.ts +7 -88
  40. package/dist/transcription.js +1 -3
  41. package/dist/video-client.js +1 -1
  42. package/dist/video.d.ts +3 -1
  43. package/package.json +3 -3
@@ -2,8 +2,8 @@ import { Cause, Effect, Layer, Option, Schema, Stream } from "effect";
2
2
  import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, } from "effect/http";
3
3
  import { HttpContext, HttpRateLimitDetails, AIError, TransportError } from "../schema/index.js";
4
4
  import { classifyProviderFailure, providerErrorMessage } from "../provider-error.js";
5
- import { CurrentTls, headerDetails, responseHttp, Service, } from "./executor-service.js";
6
- export { CurrentTls, responseHttp, Service } from "./executor-service.js";
5
+ import { composeMiddleware, CurrentMiddleware, CurrentTls, headerDetails, responseHttp, Service, } from "./executor-service.js";
6
+ export { composeMiddleware, CurrentMiddleware, CurrentTls, responseHttp, Service, withMiddleware, } from "./executor-service.js";
7
7
  const normalizedHeaders = (headers) => Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]));
8
8
  const clampRetryAfterMs = (millis) => Math.min(Number.MAX_SAFE_INTEGER, Math.max(0, Math.ceil(millis)));
9
9
  const retryAfterMs = (headers) => {
@@ -182,7 +182,12 @@ export const layer = Layer.effect(Service, Effect.gen(function* () {
182
182
  return yield* statusError(response);
183
183
  });
184
184
  return Service.of({
185
- execute: executeOnce,
185
+ // Scoped middleware runs outside per-call middleware. It is cleared while the request runs, so a request a
186
+ // middleware makes itself isn't wrapped again.
187
+ execute: (request, next) => Effect.gen(function* () {
188
+ const middleware = composeMiddleware(yield* CurrentMiddleware, next);
189
+ return yield* executeOnce(request, middleware).pipe(Effect.provideService(CurrentMiddleware, undefined));
190
+ }),
186
191
  });
187
192
  }));
188
193
  export const fetchLayer = layer.pipe(Layer.provide(FetchHttpClient.layer));
@@ -201,11 +206,21 @@ export const withFetch = (fetch, middleware) => {
201
206
  const send = (request) => HttpClient.execute(request).pipe(Effect.provide(FetchHttpClient.layer), Effect.provideService(FetchHttpClient.Fetch, fetch));
202
207
  return middleware === undefined ? send : (request) => middleware(request, send);
203
208
  };
204
- /** Run `fn` on every request: it sees the raw response before status classification, inside middleware already on `executor`, and outside per-call middleware. */
209
+ /**
210
+ * Run `fn` on every request: it sees the raw response before status classification, inside middleware already on
211
+ * `executor`, and outside per-call and scoped ({@link withMiddleware}) middleware.
212
+ */
205
213
  export const middleware = (fn, executor = fetchLayer) => Layer.effect(Service, Effect.gen(function* () {
206
214
  const inner = yield* Service;
207
215
  return Service.of({
208
- execute: (request, next) => inner.execute(request, next === undefined ? fn : (input, handler) => fn(input, (forwarded) => next(forwarded, handler))),
216
+ // Scoped middleware sits where per-call middleware does, inside `fn`; it is read here and cleared so the
217
+ // executors below don't apply it again.
218
+ execute: (request, next) => Effect.gen(function* () {
219
+ const scoped = composeMiddleware(yield* CurrentMiddleware, next);
220
+ return yield* inner
221
+ .execute(request, composeMiddleware(fn, scoped))
222
+ .pipe(Effect.provideService(CurrentMiddleware, undefined));
223
+ }),
209
224
  });
210
225
  })).pipe(Layer.provide(executor));
211
226
  export * as RequestExecutor from "./executor.js";
@@ -1,6 +1,6 @@
1
1
  import { Duration, Effect, Schema, type Stream } from "effect";
2
2
  import { HttpClientResponse } from "effect/http";
3
- import type { Snapshot, Status } from "../generation.js";
3
+ import type { Reason, Snapshot } from "../generation.js";
4
4
  import { Media } from "../media.js";
5
5
  import type { AuthInput } from "./auth.js";
6
6
  import { AIError, AuthenticationError, type HttpContext, InvalidRequestError, ProviderID, ProviderInternalError, RateLimitError } from "../schema/index.js";
@@ -54,10 +54,11 @@ export interface Started<Token> {
54
54
  export interface PollContext<Token> {
55
55
  readonly token: Token;
56
56
  /**
57
- * The headers an authenticated GET of `url` would send (deployment headers plus auth), for result URLs that need
58
- * the API key to download. URLs on another origin than the route's base URL get no headers.
57
+ * What an authenticated download of `url` needs, for result URLs that only download with the API key: the headers a
58
+ * GET would send (deployment headers plus auth) and the caller's scoped middleware. Spread it into `Media.url`. URLs
59
+ * on another origin than the route's base URL get neither, so credentials and hooks never leave the provider's host.
59
60
  */
60
- readonly headers: (url: string) => Effect.Effect<Record<string, string>, AIError>;
61
+ readonly credentials: (url: string) => Effect.Effect<Pick<Media.AssetOptions, "headers" | "middleware">, AIError>;
61
62
  /**
62
63
  * A further GET with the same auth and headers, retried like the poll itself, for providers whose result needs a
63
64
  * second lookup (MiniMax v1 answers with a file id that resolves to a download URL).
@@ -148,7 +149,7 @@ export declare const identity: (input: {
148
149
  body: string;
149
150
  http: HttpContext;
150
151
  invalid: (message: string, cause?: unknown) => AIError;
151
- ended: (status: Exclude<Status, "queued" | "running" | "completed">, message: string, failure?: Failure) => AIError;
152
+ ended: (reason: Reason, message: string, failure?: Failure) => AIError;
152
153
  pending: (id: string) => AIError;
153
154
  contentPolicy: (message: string) => AIError;
154
155
  }, AIError, never>;
@@ -157,7 +158,7 @@ export declare const identity: (input: {
157
158
  body: string;
158
159
  http: HttpContext;
159
160
  invalid: (message: string, cause?: unknown) => AIError;
160
- ended: (status: Exclude<Status, "queued" | "running" | "completed">, message: string, failure?: Failure) => AIError;
161
+ ended: (reason: Reason, message: string, failure?: Failure) => AIError;
161
162
  pending: (id: string) => AIError;
162
163
  contentPolicy: (message: string) => AIError;
163
164
  value: A;
@@ -172,8 +173,12 @@ export declare const identity: (input: {
172
173
  unsupported: (operation: string, message: string) => AIError;
173
174
  };
174
175
  export type Identity = ReturnType<typeof identity>;
176
+ /** A provider status in package terms: still running, completed, or the reason it ended in `error`. */
177
+ export type State = "running" | "completed" | Reason;
175
178
  /** Map a provider status string through the protocol's table; unknown values keep the generation running. */
176
- export declare const status: (table: Readonly<Record<string, Status>>, raw: string) => Status;
179
+ export declare const state: (table: Readonly<Record<string, State>>, raw: string) => State;
180
+ /** The snapshot `status` and `reason` for a provider status string. */
181
+ export declare const status: (table: Readonly<Record<string, State>>, raw: string) => Pick<Snapshot, "status" | "reason">;
177
182
  /** Map a provider error code through the protocol's table; missing or unmapped codes are `ProviderInternal`. */
178
183
  export declare const failure: (table: Readonly<Record<string, Failure>>, code: string | number | undefined) => Failure;
179
184
  /** A `url` asset whose provider-declared retention window starts now. */
@@ -42,7 +42,7 @@ export const identity = (input) => {
42
42
  });
43
43
  /**
44
44
  * Read a text body while retaining the original payload and HTTP context on every downstream error. `invalid` is a
45
- * malformed provider document; `ended` is a generation that reached a terminal status without output (`failed`
45
+ * malformed provider document; `ended` is a generation that ended in `error` without output (reason `failed`
46
46
  * carries the provider's classification, defaulting to `ProviderInternal`; `cancelled`/`expired` mean the result
47
47
  * will never exist); `pending` is a `result()` read before the generation finished, which is caller misuse;
48
48
  * `contentPolicy` is a moderated result.
@@ -54,8 +54,8 @@ export const identity = (input) => {
54
54
  body,
55
55
  http,
56
56
  invalid: (message, cause) => new AIError({ reason: new InvalidProviderOutputError({ route: input.id, message, body, http, cause }) }),
57
- ended: (status, message, failure = "ProviderInternal") => new AIError({
58
- reason: status === "failed"
57
+ ended: (reason, message, failure = "ProviderInternal") => new AIError({
58
+ reason: reason === "failed"
59
59
  ? new FAILURES[failure]({ message, body, http })
60
60
  : new InvalidRequestError({ message, body, http }),
61
61
  }),
@@ -110,7 +110,14 @@ export const identity = (input) => {
110
110
  };
111
111
  };
112
112
  /** Map a provider status string through the protocol's table; unknown values keep the generation running. */
113
- export const status = (table, raw) => Object.hasOwn(table, raw) ? table[raw] : "running";
113
+ export const state = (table, raw) => Object.hasOwn(table, raw) ? table[raw] : "running";
114
+ /** The snapshot `status` and `reason` for a provider status string. */
115
+ export const status = (table, raw) => {
116
+ const mapped = state(table, raw);
117
+ if (mapped === "running" || mapped === "completed")
118
+ return { status: mapped };
119
+ return { status: "error", reason: mapped };
120
+ };
114
121
  /** Map a provider error code through the protocol's table; missing or unmapped codes are `ProviderInternal`. */
115
122
  export const failure = (table, code) => code !== undefined && Object.hasOwn(table, code) ? table[code] : "ProviderInternal";
116
123
  /** A `url` asset whose provider-declared retention window starts now. */
@@ -58,7 +58,16 @@ export const queued = (input) => {
58
58
  // Only the GET exchange retries: a decoded terminal failure (`output.ended`) can be a `ProviderInternal` too, and
59
59
  // re-reading it would spin until the caller's deadline.
60
60
  const get = (path) => transport.call("GET", path, exchange, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.map((sent) => sent.response));
61
- const poll = (operation) => get(operation.path(token)).pipe(Effect.flatMap((response) => operation.decode(response, { token, get, headers: (url) => transport.headers(url, exchange) })));
61
+ const poll = (operation) => get(operation.path(token)).pipe(Effect.flatMap((response) => operation.decode(response, {
62
+ token,
63
+ get,
64
+ credentials: (url) => Effect.gen(function* () {
65
+ const headers = yield* transport.headers(url, exchange);
66
+ if (headers === undefined)
67
+ return {};
68
+ return { headers, middleware: yield* RequestExecutor.CurrentMiddleware };
69
+ }),
70
+ })));
62
71
  const status = poll(protocol.status);
63
72
  const cancel = protocol.cancel;
64
73
  return {
@@ -167,7 +176,7 @@ const makeTransport = (input) => {
167
176
  }),
168
177
  /**
169
178
  * The headers a follow-up GET of `url` sends, for result URLs that only download with the same credentials. A URL
170
- * on another origin than the route's base URL gets none, so credentials never leave the provider's host.
179
+ * on another origin than the route's base URL gets undefined, so credentials never leave the provider's host.
171
180
  */
172
181
  headers: (url, exchange) => URL.canParse(url) && new URL(url).origin === baseURL("").origin
173
182
  ? authorize({
@@ -177,7 +186,7 @@ const makeTransport = (input) => {
177
186
  body: "",
178
187
  headers: Headers.fromInput(exchange.headers),
179
188
  }).pipe(Effect.map((headers) => ({ ...headers })))
180
- : Effect.succeed({}),
189
+ : Effect.succeed(undefined),
181
190
  /** Bodiless follow-up call (status, result, cancel) with the same auth and headers as `submit`. */
182
191
  call: (method, path, exchange, execute) => {
183
192
  // Provider-issued absolute URLs are used as-is; everything else resolves against the base.
@@ -18,10 +18,6 @@ export declare const SpeechClient: {
18
18
  readonly startSeconds: number;
19
19
  readonly endSeconds: number;
20
20
  }[];
21
- } | {
22
- readonly type: "generation-queued";
23
- readonly id: string;
24
- readonly position?: number | undefined;
25
21
  } | {
26
22
  readonly type: "generation-progress";
27
23
  readonly id: string;
@@ -68,6 +64,10 @@ export declare const SpeechClient: {
68
64
  readonly startSeconds: number;
69
65
  readonly endSeconds: number;
70
66
  }[];
67
+ } | {
68
+ readonly type: "generation-progress";
69
+ readonly id: string;
70
+ readonly progress?: number | undefined;
71
71
  } | {
72
72
  readonly type: "finish";
73
73
  readonly audio: import("./media.js").Asset;
@@ -97,7 +97,7 @@ export declare const SpeechClient: {
97
97
  readonly [x: string]: unknown;
98
98
  };
99
99
  } | undefined;
100
- } | import("./generation.js").Observation, import("./public.js").AIError, SpeechClientService>;
100
+ }, import("./public.js").AIError, SpeechClientService>;
101
101
  readonly start: (request: SpeechRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<SpeechResponse>, import("./public.js").AIError, SpeechClientService>;
102
102
  readonly resume: (model: import("./speech.js").SpeechModel<{
103
103
  readonly [x: string]: unknown;
package/dist/speech.d.ts CHANGED
@@ -186,10 +186,6 @@ export declare const SpeechFinishEvent: Schema.Struct<{
186
186
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
187
187
  }>;
188
188
  declare const speechEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
189
- readonly type: Schema.tag<"generation-queued">;
190
- readonly id: Schema.String;
191
- readonly position: Schema.optional<Schema.Number>;
192
- }>, Schema.Struct<{
193
189
  readonly type: Schema.tag<"generation-progress">;
194
190
  readonly id: Schema.String;
195
191
  readonly progress: Schema.optional<Schema.Number>;
@@ -258,10 +254,6 @@ declare const speechEventTagged: Schema.toTaggedUnion<"type", readonly [Schema.S
258
254
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
259
255
  }>]>;
260
256
  export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
261
- readonly type: Schema.tag<"generation-queued">;
262
- readonly id: Schema.String;
263
- readonly position: Schema.optional<Schema.Number>;
264
- }>, Schema.Struct<{
265
257
  readonly type: Schema.tag<"generation-progress">;
266
258
  readonly id: Schema.String;
267
259
  readonly progress: Schema.optional<Schema.Number>;
@@ -330,7 +322,7 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
330
322
  readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
331
323
  }>]> & {
332
324
  readonly tag: "type";
333
- readonly discriminants: readonly ["generation-queued", "generation-progress", "audio-delta", "timestamps", "finish"];
325
+ readonly discriminants: readonly ["generation-progress", "audio-delta", "timestamps", "finish"];
334
326
  readonly cases: {
335
327
  "audio-delta": Schema.Struct<{
336
328
  readonly type: Schema.tag<"audio-delta">;
@@ -395,11 +387,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
395
387
  readonly id: Schema.String;
396
388
  readonly progress: Schema.optional<Schema.Number>;
397
389
  }>;
398
- "generation-queued": Schema.Struct<{
399
- readonly type: Schema.tag<"generation-queued">;
400
- readonly id: Schema.String;
401
- readonly position: Schema.optional<Schema.Number>;
402
- }>;
403
390
  timestamps: Schema.Struct<{
404
391
  readonly type: Schema.tag<"timestamps">;
405
392
  readonly items: Schema.$Array<Schema.Struct<{
@@ -419,10 +406,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
419
406
  readonly startSeconds: number;
420
407
  readonly endSeconds: number;
421
408
  }[];
422
- } | {
423
- readonly type: "generation-queued";
424
- readonly id: string;
425
- readonly position?: number | undefined;
426
409
  } | {
427
410
  readonly type: "generation-progress";
428
411
  readonly id: string;
@@ -470,12 +453,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
470
453
  }[];
471
454
  }, {
472
455
  readonly type: Keys;
473
- }> | Extract<{
474
- readonly type: "generation-queued";
475
- readonly id: string;
476
- readonly position?: number | undefined;
477
- }, {
478
- readonly type: Keys;
479
456
  }> | Extract<{
480
457
  readonly type: "generation-progress";
481
458
  readonly id: string;
@@ -554,11 +531,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
554
531
  readonly id: string;
555
532
  readonly progress?: number | undefined;
556
533
  };
557
- "generation-queued": (u: unknown) => u is {
558
- readonly type: "generation-queued";
559
- readonly id: string;
560
- readonly position?: number | undefined;
561
- };
562
534
  timestamps: (u: unknown) => u is {
563
535
  readonly type: "timestamps";
564
536
  readonly items: readonly {
@@ -569,7 +541,7 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
569
541
  };
570
542
  };
571
543
  readonly match: {
572
- <Handlers extends { [K in "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"]: (value: {
544
+ <Handlers extends { [K in "audio-delta" | "finish" | "generation-progress" | "timestamps"]: (value: {
573
545
  readonly "audio-delta": Schema.Struct<{
574
546
  readonly type: Schema.tag<"audio-delta">;
575
547
  readonly chunk: Schema.Uint8Array;
@@ -633,11 +605,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
633
605
  readonly id: Schema.String;
634
606
  readonly progress: Schema.optional<Schema.Number>;
635
607
  }>;
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
608
  readonly timestamps: Schema.Struct<{
642
609
  readonly type: Schema.tag<"timestamps">;
643
610
  readonly items: Schema.$Array<Schema.Struct<{
@@ -656,10 +623,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
656
623
  readonly startSeconds: number;
657
624
  readonly endSeconds: number;
658
625
  }[];
659
- } | {
660
- readonly type: "generation-queued";
661
- readonly id: string;
662
- readonly position?: number | undefined;
663
626
  } | {
664
627
  readonly type: "generation-progress";
665
628
  readonly id: string;
@@ -693,8 +656,8 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
693
656
  readonly [x: string]: unknown;
694
657
  };
695
658
  } | undefined;
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: {
659
+ }, cases: Handlers): import("effect/Unify").Unify<ReturnType<Handlers["audio-delta" | "finish" | "generation-progress" | "timestamps"]>>;
660
+ <Handlers extends { [K in "audio-delta" | "finish" | "generation-progress" | "timestamps"]: (value: {
698
661
  readonly "audio-delta": Schema.Struct<{
699
662
  readonly type: Schema.tag<"audio-delta">;
700
663
  readonly chunk: Schema.Uint8Array;
@@ -758,11 +721,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
758
721
  readonly id: Schema.String;
759
722
  readonly progress: Schema.optional<Schema.Number>;
760
723
  }>;
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
724
  readonly timestamps: Schema.Struct<{
767
725
  readonly type: Schema.tag<"timestamps">;
768
726
  readonly items: Schema.$Array<Schema.Struct<{
@@ -781,10 +739,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
781
739
  readonly startSeconds: number;
782
740
  readonly endSeconds: number;
783
741
  }[];
784
- } | {
785
- readonly type: "generation-queued";
786
- readonly id: string;
787
- readonly position?: number | undefined;
788
742
  } | {
789
743
  readonly type: "generation-progress";
790
744
  readonly id: string;
@@ -818,7 +772,7 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
818
772
  readonly [x: string]: unknown;
819
773
  };
820
774
  } | undefined;
821
- }) => import("effect/Unify").Unify<ReturnType<Handlers["audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"]>>;
775
+ }) => import("effect/Unify").Unify<ReturnType<Handlers["audio-delta" | "finish" | "generation-progress" | "timestamps"]>>;
822
776
  };
823
777
  readonly matchOrElse: {
824
778
  <Handlers, OrElse>(value: {
@@ -831,10 +785,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
831
785
  readonly startSeconds: number;
832
786
  readonly endSeconds: number;
833
787
  }[];
834
- } | {
835
- readonly type: "generation-queued";
836
- readonly id: string;
837
- readonly position?: number | undefined;
838
788
  } | {
839
789
  readonly type: "generation-progress";
840
790
  readonly id: string;
@@ -908,11 +858,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
908
858
  readonly id: string;
909
859
  readonly progress?: number | undefined;
910
860
  }) => 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
861
  readonly timestamps?: ((value: {
917
862
  readonly type: "timestamps";
918
863
  readonly items: readonly {
@@ -921,7 +866,7 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
921
866
  readonly endSeconds: number;
922
867
  }[];
923
868
  }) => any) | undefined;
924
- } & (Exclude<keyof Handlers, "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
869
+ } & (Exclude<keyof Handlers, "audio-delta" | "finish" | "generation-progress" | "timestamps"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
925
870
  readonly type: "audio-delta";
926
871
  readonly chunk: Uint8Array<ArrayBufferLike>;
927
872
  }, {
@@ -935,12 +880,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
935
880
  }[];
936
881
  }, {
937
882
  readonly type: keyof Handlers;
938
- }> | Exclude<{
939
- readonly type: "generation-queued";
940
- readonly id: string;
941
- readonly position?: number | undefined;
942
- }, {
943
- readonly type: keyof Handlers;
944
883
  }> | Exclude<{
945
884
  readonly type: "generation-progress";
946
885
  readonly id: string;
@@ -1019,11 +958,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
1019
958
  readonly id: string;
1020
959
  readonly progress?: number | undefined;
1021
960
  }) => 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
961
  readonly timestamps?: ((value: {
1028
962
  readonly type: "timestamps";
1029
963
  readonly items: readonly {
@@ -1032,7 +966,7 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
1032
966
  readonly endSeconds: number;
1033
967
  }[];
1034
968
  }) => any) | undefined;
1035
- } & (Exclude<keyof Handlers, "audio-delta" | "finish" | "generation-progress" | "generation-queued" | "timestamps"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
969
+ } & (Exclude<keyof Handlers, "audio-delta" | "finish" | "generation-progress" | "timestamps"> extends never ? unknown : never), orElse: OrElse & ((value: Exclude<{
1036
970
  readonly type: "audio-delta";
1037
971
  readonly chunk: Uint8Array<ArrayBufferLike>;
1038
972
  }, {
@@ -1046,12 +980,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
1046
980
  }[];
1047
981
  }, {
1048
982
  readonly type: keyof Handlers;
1049
- }> | Exclude<{
1050
- readonly type: "generation-queued";
1051
- readonly id: string;
1052
- readonly position?: number | undefined;
1053
- }, {
1054
- readonly type: keyof Handlers;
1055
983
  }> | Exclude<{
1056
984
  readonly type: "generation-progress";
1057
985
  readonly id: string;
@@ -1099,10 +1027,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
1099
1027
  readonly startSeconds: number;
1100
1028
  readonly endSeconds: number;
1101
1029
  }[];
1102
- } | {
1103
- readonly type: "generation-queued";
1104
- readonly id: string;
1105
- readonly position?: number | undefined;
1106
1030
  } | {
1107
1031
  readonly type: "generation-progress";
1108
1032
  readonly id: string;
@@ -1140,11 +1064,6 @@ export declare const SpeechEvent: Schema.Union<readonly [Schema.Struct<{
1140
1064
  };
1141
1065
  } & {
1142
1066
  is: {
1143
- generationQueued: (u: unknown) => u is {
1144
- readonly type: "generation-queued";
1145
- readonly id: string;
1146
- readonly position?: number | undefined;
1147
- };
1148
1067
  generationProgress: (u: unknown) => u is {
1149
1068
  readonly type: "generation-progress";
1150
1069
  readonly id: string;
package/dist/speech.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Effect, Schema, Stream } from "effect";
2
- import { ProgressEvent, QueuedEvent } from "./generation.js";
2
+ import { ProgressEvent } from "./generation.js";
3
3
  import { Media } from "./media.js";
4
4
  import { MediaModel, composeRoute, tryRequest } from "./media-model.js";
5
5
  import { MediaRoute } from "./route/media.js";
@@ -70,7 +70,6 @@ export const SpeechFinishEvent = Schema.Struct({
70
70
  providerMetadata: Schema.optional(ProviderMetadata),
71
71
  }).annotate({ identifier: "Speech.Event.Finish" });
72
72
  const speechEventTagged = Schema.Union([
73
- QueuedEvent,
74
73
  ProgressEvent,
75
74
  SpeechAudioDeltaEvent,
76
75
  SpeechTimestampsEvent,
@@ -78,7 +77,6 @@ const speechEventTagged = Schema.Union([
78
77
  ]).pipe(Schema.toTaggedUnion("type"));
79
78
  export const SpeechEvent = Object.assign(speechEventTagged, {
80
79
  is: {
81
- generationQueued: speechEventTagged.guards["generation-queued"],
82
80
  generationProgress: speechEventTagged.guards["generation-progress"],
83
81
  audioDelta: speechEventTagged.guards["audio-delta"],
84
82
  timestamps: speechEventTagged.guards.timestamps,
@@ -19,10 +19,6 @@ export declare const TranscriptionClient: {
19
19
  readonly endSeconds: number;
20
20
  readonly speaker?: string | undefined;
21
21
  };
22
- } | {
23
- readonly type: "generation-queued";
24
- readonly id: string;
25
- readonly position?: number | undefined;
26
22
  } | {
27
23
  readonly type: "generation-progress";
28
24
  readonly id: string;
@@ -85,6 +81,10 @@ export declare const TranscriptionClient: {
85
81
  readonly endSeconds: number;
86
82
  readonly speaker?: string | undefined;
87
83
  };
84
+ } | {
85
+ readonly type: "generation-progress";
86
+ readonly id: string;
87
+ readonly progress?: number | undefined;
88
88
  } | {
89
89
  readonly text: string;
90
90
  readonly segments?: readonly {
@@ -129,7 +129,7 @@ export declare const TranscriptionClient: {
129
129
  };
130
130
  } | undefined;
131
131
  readonly type: "finish";
132
- } | import("./generation.js").Observation, import("./public.js").AIError, TranscriptionClientService>;
132
+ }, import("./public.js").AIError, TranscriptionClientService>;
133
133
  readonly start: (request: TranscriptionRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./public.js").AIError, TranscriptionClientService>;
134
134
  readonly resume: (model: import("./transcription.js").TranscriptionModel<{
135
135
  readonly [x: string]: unknown;