@opencode/ai 2.2.2 → 2.2.4

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 (52) hide show
  1. package/README.md +159 -144
  2. package/dist/decision.d.ts +0 -1
  3. package/dist/effect.d.ts +47 -17
  4. package/dist/effect.js +25 -13
  5. package/dist/experimental/testing.d.ts +3 -0
  6. package/dist/experimental/testing.js +3 -0
  7. package/dist/experimental.d.ts +12 -0
  8. package/dist/experimental.js +9 -0
  9. package/dist/index.d.ts +637 -1323
  10. package/dist/index.js +60 -56
  11. package/dist/llm.d.ts +4 -3
  12. package/dist/llm.js +21 -29
  13. package/dist/protocols/alibaba-responses.d.ts +2 -2
  14. package/dist/protocols/assemblyai-transcription.js +3 -3
  15. package/dist/protocols/meta-responses.d.ts +4 -4
  16. package/dist/protocols/open-responses.d.ts +18 -18
  17. package/dist/protocols/open-responses.js +4 -2
  18. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  19. package/dist/protocols/openai-responses.d.ts +12 -12
  20. package/dist/protocols/runway-video.js +2 -2
  21. package/dist/protocols/xai-responses.d.ts +2 -2
  22. package/dist/protocols/xai-responses.js +1 -1
  23. package/dist/protocols/xai-video.js +2 -2
  24. package/dist/providers/alibaba.d.ts +2 -2
  25. package/dist/providers/amazon-bedrock-mantle.d.ts +2 -2
  26. package/dist/providers/azure.d.ts +4 -4
  27. package/dist/providers/cloudflare-ai-gateway.d.ts +4 -4
  28. package/dist/providers/digitalocean.d.ts +2 -2
  29. package/dist/providers/google-vertex-responses.d.ts +2 -2
  30. package/dist/providers/meta.d.ts +2 -2
  31. package/dist/providers/minimax.d.ts +2 -2
  32. package/dist/providers/moonshot.d.ts +2 -2
  33. package/dist/providers/openai-compatible-responses.d.ts +2 -2
  34. package/dist/providers/openai.d.ts +2 -2
  35. package/dist/providers/openrouter/responses.d.ts +1 -2
  36. package/dist/providers/openrouter.d.ts +36 -23
  37. package/dist/providers/openrouter.js +29 -10
  38. package/dist/providers/venice.d.ts +2 -2
  39. package/dist/providers/zai-coding-plan.d.ts +2 -2
  40. package/dist/route/client.d.ts +3 -2
  41. package/dist/route/client.js +6 -9
  42. package/dist/route/media-protocol.d.ts +2 -3
  43. package/dist/route/media-protocol.js +2 -6
  44. package/dist/schema/errors.d.ts +6 -0
  45. package/dist/schema/errors.js +8 -0
  46. package/dist/schema/events.d.ts +2 -0
  47. package/dist/schema/events.js +4 -0
  48. package/dist/testing.d.ts +1 -4
  49. package/dist/testing.js +4 -12
  50. package/dist/tool.d.ts +40 -73
  51. package/dist/tool.js +27 -18
  52. package/package.json +7 -3
package/dist/index.d.ts CHANGED
@@ -3,15 +3,15 @@ import { AIClient } from "./ai-client.js";
3
3
  import { type DecisionModel, type DecisionQuestions, type DecisionRequestInput } from "./decision.js";
4
4
  import type { AwaitOptions, Event, Snapshot } from "./generation.js";
5
5
  import { type ImageModel, type ImageRequest, type ImageRequestInput } from "./image.js";
6
- import { LLM } from "./effect.js";
6
+ import { LLM } from "./llm.js";
7
7
  import { Media } from "./media.js";
8
- import { type CheckpointRequest, type CompactionRequest, type EndpointCompactOptions, type TriggerCompactOptions } from "./route/client.js";
8
+ import { type CheckpointRequest, type CompactionRequest, type EndpointCompactOptions, type StreamOptions, type TriggerCompactOptions } from "./route/client.js";
9
9
  import { RequestExecutor } from "./route/executor.js";
10
10
  import { LanguageModel, type CompactionCheckpointResponse, type CompactionResponse, type LLMRequest } from "./schema/index.js";
11
11
  import type { GenerateObjectDynamicOptions, GenerateObjectOptions, GenerateObjectResponse, LoopInput, RequestInput } from "./llm.js";
12
12
  import { type SpeechModel, type SpeechRequest, type SpeechRequestInput } from "./speech.js";
13
13
  import { type TranscriptionModel, type TranscriptionRequest, type TranscriptionRequestInput } from "./transcription.js";
14
- import { Tool, type FreeformOption, type ToolExecuteContext, type ToolSchema } from "./tool.js";
14
+ import type { NoExecute, ToolExecuteContext, ToolOptions, ToolSchema } from "./tool.js";
15
15
  import { type VideoModel, type VideoRequest, type VideoRequestInput } from "./video.js";
16
16
  /**
17
17
  * Promise-first entrypoint for scripts and non-Effect callers. One `ManagedRuntime` hosts the LLM, image, video, speech,
@@ -33,6 +33,8 @@ export type Services = AIClient.Services;
33
33
  * new handle rather than updating this one.
34
34
  */
35
35
  export type GenerationHandle<Response> = Snapshot & {
36
+ readonly snapshot: Snapshot;
37
+ readonly terminal: boolean;
36
38
  /** Serializable JSON; pass it back to `resume` from another process. */
37
39
  readonly token: unknown;
38
40
  readonly await: (options?: AwaitOptions & RunOptions) => Promise<Response>;
@@ -54,1171 +56,462 @@ export declare const make: <R = never>(options?: Options<R>) => {
54
56
  file: (path: string, options?: Media.AssetOptions & RunOptions) => Promise<Media.Asset>;
55
57
  /** Write an asset's bytes like `Media.write`, downloading `url` sources through the executor. */
56
58
  write: (asset: Media.Asset, path: string, options?: RunOptions) => Promise<void>;
57
- llm: {
58
- request: typeof LLM.request;
59
- generate: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: RunOptions) => Promise<import("./effect.js").LLMResponse>;
60
- stream: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: RunOptions) => AsyncIterable<{
61
- readonly type: "step-start";
62
- readonly index: number;
63
- } | {
64
- readonly type: "raw";
65
- readonly data: unknown;
66
- } | {
67
- readonly type: "text-start";
68
- readonly id: string;
69
- readonly providerMetadata?: {
70
- readonly [x: string]: {
71
- readonly [x: string]: unknown;
72
- };
73
- } | undefined;
74
- } | {
75
- readonly type: "text-delta";
76
- readonly id: string;
77
- readonly text: string;
78
- readonly providerMetadata?: {
79
- readonly [x: string]: {
80
- readonly [x: string]: unknown;
81
- };
82
- } | undefined;
83
- } | {
84
- readonly type: "text-end";
85
- readonly id: string;
86
- readonly text?: string | undefined;
87
- readonly providerMetadata?: {
88
- readonly [x: string]: {
89
- readonly [x: string]: unknown;
90
- };
91
- } | undefined;
92
- } | {
93
- readonly type: "reasoning-start";
94
- readonly id: string;
95
- readonly providerMetadata?: {
96
- readonly [x: string]: {
97
- readonly [x: string]: unknown;
98
- };
99
- } | undefined;
100
- } | {
101
- readonly type: "reasoning-delta";
102
- readonly id: string;
103
- readonly text: string;
104
- readonly providerMetadata?: {
105
- readonly [x: string]: {
106
- readonly [x: string]: unknown;
107
- };
108
- } | undefined;
109
- } | {
110
- readonly type: "reasoning-end";
111
- readonly id: string;
112
- readonly text?: string | undefined;
113
- readonly providerMetadata?: {
114
- readonly [x: string]: {
115
- readonly [x: string]: unknown;
116
- };
117
- } | undefined;
118
- } | {
119
- readonly type: "tool-input-start";
120
- readonly id: string;
121
- readonly name: string;
122
- readonly namespace?: string | undefined;
123
- readonly providerExecuted?: boolean | undefined;
124
- readonly providerMetadata?: {
125
- readonly [x: string]: {
126
- readonly [x: string]: unknown;
127
- };
128
- } | undefined;
129
- } | {
130
- readonly type: "tool-input-delta";
131
- readonly id: string;
132
- readonly name: string;
133
- readonly namespace?: string | undefined;
134
- readonly text: string;
135
- readonly input?: unknown;
136
- } | {
137
- readonly type: "tool-input-end";
138
- readonly id: string;
139
- readonly name: string;
140
- readonly namespace?: string | undefined;
141
- readonly providerMetadata?: {
142
- readonly [x: string]: {
143
- readonly [x: string]: unknown;
144
- };
145
- } | undefined;
146
- } | {
147
- readonly type: "tool-input-error";
148
- readonly id: string;
149
- readonly name: string;
150
- readonly namespace?: string | undefined;
151
- readonly raw: string;
152
- } | {
153
- readonly type: "tool-call";
154
- readonly id: string;
155
- readonly name: string;
156
- readonly namespace?: string | undefined;
157
- readonly input: unknown;
158
- readonly providerExecuted?: boolean | undefined;
159
- readonly providerMetadata?: {
160
- readonly [x: string]: {
161
- readonly [x: string]: unknown;
162
- };
163
- } | undefined;
164
- } | {
165
- readonly type: "tool-result";
166
- readonly id: string;
167
- readonly name: string;
168
- readonly namespace?: string | undefined;
169
- readonly result: {
170
- readonly type: "json";
171
- readonly value: unknown;
172
- } | {
173
- readonly type: "text";
174
- readonly value: unknown;
175
- } | {
176
- readonly type: "error";
177
- readonly value: unknown;
178
- } | {
179
- readonly type: "content";
180
- readonly value: readonly ({
181
- readonly type: "text";
182
- readonly text: string;
183
- } | {
184
- readonly type: "file";
185
- readonly uri: string;
186
- readonly mime: string;
187
- readonly name?: string | undefined;
188
- })[];
189
- };
190
- readonly output?: {
191
- readonly structured: unknown;
192
- readonly content: readonly ({
193
- readonly type: "text";
194
- readonly text: string;
195
- } | {
196
- readonly type: "file";
197
- readonly uri: string;
198
- readonly mime: string;
199
- readonly name?: string | undefined;
200
- })[];
201
- } | undefined;
202
- readonly providerExecuted?: boolean | undefined;
203
- readonly providerMetadata?: {
204
- readonly [x: string]: {
205
- readonly [x: string]: unknown;
206
- };
207
- } | undefined;
208
- } | {
209
- readonly type: "tool-error";
210
- readonly id: string;
211
- readonly name: string;
212
- readonly namespace?: string | undefined;
213
- readonly message: string;
214
- readonly error?: unknown;
215
- readonly providerMetadata?: {
216
- readonly [x: string]: {
217
- readonly [x: string]: unknown;
218
- };
219
- } | undefined;
220
- } | {
221
- readonly type: "step-finish";
222
- readonly index: number;
223
- readonly reason: {
224
- readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
225
- readonly raw?: string | undefined;
226
- readonly category?: string | undefined;
227
- readonly explanation?: string | undefined;
228
- };
229
- readonly usage?: import("./effect.js").Usage | undefined;
230
- readonly providerMetadata?: {
231
- readonly [x: string]: {
232
- readonly [x: string]: unknown;
233
- };
234
- } | undefined;
235
- } | {
236
- readonly type: "finish";
237
- readonly reason: {
238
- readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
239
- readonly raw?: string | undefined;
240
- readonly category?: string | undefined;
241
- readonly explanation?: string | undefined;
242
- };
243
- readonly usage?: import("./effect.js").Usage | undefined;
244
- readonly providerMetadata?: {
245
- readonly [x: string]: {
246
- readonly [x: string]: unknown;
247
- };
248
- } | undefined;
249
- } | {
250
- readonly type: "media";
251
- readonly media: Media.Asset;
252
- readonly providerMetadata?: {
253
- readonly [x: string]: {
254
- readonly [x: string]: unknown;
255
- };
256
- } | undefined;
257
- } | {
258
- readonly type: "provider-error";
259
- readonly message: string;
260
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
261
- readonly providerMetadata?: {
262
- readonly [x: string]: {
263
- readonly [x: string]: unknown;
264
- };
265
- } | undefined;
266
- } | ({
267
- readonly type: "compaction";
268
- readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
269
- readonly id?: string | undefined;
270
- readonly encrypted?: string | undefined;
271
- readonly text?: string | null | undefined;
272
- } & ({
273
- readonly encrypted: string;
274
- readonly text?: never;
275
- } | {
276
- readonly text: string | null;
277
- readonly encrypted?: never;
278
- }))>;
279
- /** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
280
- loop: <const Model extends LanguageModel>(input: LoopInput<Model>, options?: RunOptions) => AsyncIterable<{
281
- readonly type: "step-start";
282
- readonly index: number;
283
- } | {
284
- readonly type: "raw";
285
- readonly data: unknown;
286
- } | {
287
- readonly type: "text-start";
288
- readonly id: string;
289
- readonly providerMetadata?: {
290
- readonly [x: string]: {
291
- readonly [x: string]: unknown;
292
- };
293
- } | undefined;
294
- } | {
295
- readonly type: "text-delta";
296
- readonly id: string;
297
- readonly text: string;
298
- readonly providerMetadata?: {
299
- readonly [x: string]: {
300
- readonly [x: string]: unknown;
301
- };
302
- } | undefined;
303
- } | {
304
- readonly type: "text-end";
305
- readonly id: string;
306
- readonly text?: string | undefined;
307
- readonly providerMetadata?: {
308
- readonly [x: string]: {
309
- readonly [x: string]: unknown;
310
- };
311
- } | undefined;
312
- } | {
313
- readonly type: "reasoning-start";
314
- readonly id: string;
315
- readonly providerMetadata?: {
316
- readonly [x: string]: {
317
- readonly [x: string]: unknown;
318
- };
319
- } | undefined;
320
- } | {
321
- readonly type: "reasoning-delta";
322
- readonly id: string;
323
- readonly text: string;
324
- readonly providerMetadata?: {
325
- readonly [x: string]: {
326
- readonly [x: string]: unknown;
327
- };
328
- } | undefined;
329
- } | {
330
- readonly type: "reasoning-end";
331
- readonly id: string;
332
- readonly text?: string | undefined;
333
- readonly providerMetadata?: {
334
- readonly [x: string]: {
335
- readonly [x: string]: unknown;
336
- };
337
- } | undefined;
338
- } | {
339
- readonly type: "tool-input-start";
340
- readonly id: string;
341
- readonly name: string;
342
- readonly namespace?: string | undefined;
343
- readonly providerExecuted?: boolean | undefined;
344
- readonly providerMetadata?: {
345
- readonly [x: string]: {
346
- readonly [x: string]: unknown;
347
- };
348
- } | undefined;
349
- } | {
350
- readonly type: "tool-input-delta";
351
- readonly id: string;
352
- readonly name: string;
353
- readonly namespace?: string | undefined;
354
- readonly text: string;
355
- readonly input?: unknown;
356
- } | {
357
- readonly type: "tool-input-end";
358
- readonly id: string;
359
- readonly name: string;
360
- readonly namespace?: string | undefined;
361
- readonly providerMetadata?: {
362
- readonly [x: string]: {
363
- readonly [x: string]: unknown;
364
- };
365
- } | undefined;
366
- } | {
367
- readonly type: "tool-input-error";
368
- readonly id: string;
369
- readonly name: string;
370
- readonly namespace?: string | undefined;
371
- readonly raw: string;
372
- } | {
373
- readonly type: "tool-call";
374
- readonly id: string;
375
- readonly name: string;
376
- readonly namespace?: string | undefined;
377
- readonly input: unknown;
378
- readonly providerExecuted?: boolean | undefined;
379
- readonly providerMetadata?: {
380
- readonly [x: string]: {
381
- readonly [x: string]: unknown;
382
- };
383
- } | undefined;
384
- } | {
385
- readonly type: "tool-result";
386
- readonly id: string;
387
- readonly name: string;
388
- readonly namespace?: string | undefined;
389
- readonly result: {
390
- readonly type: "json";
391
- readonly value: unknown;
392
- } | {
393
- readonly type: "text";
394
- readonly value: unknown;
395
- } | {
396
- readonly type: "error";
397
- readonly value: unknown;
398
- } | {
399
- readonly type: "content";
400
- readonly value: readonly ({
401
- readonly type: "text";
402
- readonly text: string;
403
- } | {
404
- readonly type: "file";
405
- readonly uri: string;
406
- readonly mime: string;
407
- readonly name?: string | undefined;
408
- })[];
409
- };
410
- readonly output?: {
411
- readonly structured: unknown;
412
- readonly content: readonly ({
413
- readonly type: "text";
414
- readonly text: string;
415
- } | {
416
- readonly type: "file";
417
- readonly uri: string;
418
- readonly mime: string;
419
- readonly name?: string | undefined;
420
- })[];
421
- } | undefined;
422
- readonly providerExecuted?: boolean | undefined;
423
- readonly providerMetadata?: {
424
- readonly [x: string]: {
425
- readonly [x: string]: unknown;
426
- };
427
- } | undefined;
428
- } | {
429
- readonly type: "tool-error";
430
- readonly id: string;
431
- readonly name: string;
432
- readonly namespace?: string | undefined;
433
- readonly message: string;
434
- readonly error?: unknown;
435
- readonly providerMetadata?: {
436
- readonly [x: string]: {
437
- readonly [x: string]: unknown;
438
- };
439
- } | undefined;
440
- } | {
441
- readonly type: "step-finish";
442
- readonly index: number;
443
- readonly reason: {
444
- readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
445
- readonly raw?: string | undefined;
446
- readonly category?: string | undefined;
447
- readonly explanation?: string | undefined;
448
- };
449
- readonly usage?: import("./effect.js").Usage | undefined;
450
- readonly providerMetadata?: {
451
- readonly [x: string]: {
452
- readonly [x: string]: unknown;
453
- };
454
- } | undefined;
455
- } | {
456
- readonly type: "finish";
457
- readonly reason: {
458
- readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
459
- readonly raw?: string | undefined;
460
- readonly category?: string | undefined;
461
- readonly explanation?: string | undefined;
462
- };
463
- readonly usage?: import("./effect.js").Usage | undefined;
464
- readonly providerMetadata?: {
465
- readonly [x: string]: {
466
- readonly [x: string]: unknown;
467
- };
468
- } | undefined;
469
- } | {
470
- readonly type: "media";
471
- readonly media: Media.Asset;
472
- readonly providerMetadata?: {
473
- readonly [x: string]: {
474
- readonly [x: string]: unknown;
475
- };
476
- } | undefined;
477
- } | {
478
- readonly type: "provider-error";
479
- readonly message: string;
480
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
481
- readonly providerMetadata?: {
482
- readonly [x: string]: {
483
- readonly [x: string]: unknown;
484
- };
485
- } | undefined;
486
- } | ({
487
- readonly type: "compaction";
488
- readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
489
- readonly id?: string | undefined;
490
- readonly encrypted?: string | undefined;
491
- readonly text?: string | null | undefined;
492
- } & ({
493
- readonly encrypted: string;
494
- readonly text?: never;
495
- } | {
496
- readonly text: string | null;
497
- readonly encrypted?: never;
498
- }))>;
499
- /** Decode the model's output against `schema` (or `jsonSchema`, unvalidated) like `LLM.generateObject`. */
500
- generateObject: {
501
- <const Model extends LanguageModel, S extends ToolSchema<any>>(input: GenerateObjectOptions<S, Model>, options?: RunOptions): Promise<GenerateObjectResponse<Schema.Schema.Type<S>>>;
502
- <const Model extends LanguageModel>(input: GenerateObjectDynamicOptions<Model>, options?: RunOptions): Promise<GenerateObjectResponse<unknown>>;
503
- };
504
- /** Compact a Responses request like `LLMClient.compact`: a replacement window, or a checkpoint with `mechanism: "trigger"`. */
505
- compact: {
506
- (request: CheckpointRequest, options: TriggerCompactOptions & RunOptions): Promise<CompactionCheckpointResponse>;
507
- (request: CompactionRequest, options?: EndpointCompactOptions & RunOptions): Promise<CompactionResponse>;
508
- };
509
- };
510
- image: {
511
- request: typeof import("./image.js").request;
512
- generate: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => Promise<import("./image.js").ImageResponse>;
513
- stream: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
514
- readonly type: "image-partial";
515
- readonly index: number;
516
- readonly image: Media.Asset;
517
- } | {
518
- readonly type: "image";
519
- readonly index: number;
520
- readonly image: Media.Asset;
521
- } | {
522
- readonly type: "generation-queued";
523
- readonly id: string;
524
- readonly position?: number | undefined;
525
- } | {
526
- readonly type: "generation-progress";
527
- readonly id: string;
528
- readonly progress?: number | undefined;
529
- } | {
530
- readonly type: "finish";
531
- readonly usage?: {
532
- readonly type: "seconds";
533
- readonly seconds: number;
534
- } | {
535
- readonly type: "characters";
536
- readonly characters: number;
537
- } | {
538
- readonly type: "credits";
539
- readonly credits: number;
540
- } | {
541
- readonly type: "compute";
542
- readonly seconds: number;
543
- } | {
544
- readonly type: "tokens";
545
- readonly input?: number | undefined;
546
- readonly output?: number | undefined;
547
- readonly total?: number | undefined;
548
- readonly details?: {
549
- readonly [x: string]: unknown;
550
- } | undefined;
551
- } | undefined;
552
- readonly providerMetadata?: {
553
- readonly [x: string]: {
554
- readonly [x: string]: unknown;
555
- };
556
- } | undefined;
557
- }>;
558
- start: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
559
- resume: (model: ImageModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
560
- };
561
- video: {
562
- request: typeof import("./video.js").request;
563
- start: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
564
- generate: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
565
- resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
566
- stream: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
567
- readonly type: "video";
568
- readonly index: number;
569
- readonly video: Media.Asset;
570
- } | {
571
- readonly type: "generation-queued";
572
- readonly id: string;
573
- readonly position?: number | undefined;
574
- } | {
575
- readonly type: "generation-progress";
576
- readonly id: string;
577
- readonly progress?: number | undefined;
578
- } | {
579
- readonly type: "finish";
580
- readonly usage?: {
581
- readonly type: "seconds";
582
- readonly seconds: number;
583
- } | {
584
- readonly type: "characters";
585
- readonly characters: number;
586
- } | {
587
- readonly type: "credits";
588
- readonly credits: number;
589
- } | {
590
- readonly type: "compute";
591
- readonly seconds: number;
592
- } | {
593
- readonly type: "tokens";
594
- readonly input?: number | undefined;
595
- readonly output?: number | undefined;
596
- readonly total?: number | undefined;
597
- readonly details?: {
598
- readonly [x: string]: unknown;
599
- } | undefined;
600
- } | undefined;
601
- readonly providerMetadata?: {
602
- readonly [x: string]: {
603
- readonly [x: string]: unknown;
604
- };
605
- } | undefined;
606
- }>;
607
- };
608
- speech: {
609
- request: typeof import("./speech.js").request;
610
- generate: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
611
- stream: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => AsyncIterable<{
612
- readonly type: "audio-delta";
613
- readonly chunk: Uint8Array<ArrayBufferLike>;
614
- } | {
615
- readonly type: "timestamps";
616
- readonly items: readonly {
617
- readonly text: string;
618
- readonly startSeconds: number;
619
- readonly endSeconds: number;
620
- }[];
621
- } | {
622
- readonly type: "generation-queued";
623
- readonly id: string;
624
- readonly position?: number | undefined;
625
- } | {
626
- readonly type: "generation-progress";
627
- readonly id: string;
628
- readonly progress?: number | undefined;
629
- } | {
630
- readonly type: "finish";
631
- readonly audio: Media.Asset;
632
- readonly usage?: {
633
- readonly type: "seconds";
634
- readonly seconds: number;
635
- } | {
636
- readonly type: "characters";
637
- readonly characters: number;
638
- } | {
639
- readonly type: "credits";
640
- readonly credits: number;
641
- } | {
642
- readonly type: "compute";
643
- readonly seconds: number;
644
- } | {
645
- readonly type: "tokens";
646
- readonly input?: number | undefined;
647
- readonly output?: number | undefined;
648
- readonly total?: number | undefined;
649
- readonly details?: {
650
- readonly [x: string]: unknown;
651
- } | undefined;
652
- } | undefined;
653
- readonly providerMetadata?: {
654
- readonly [x: string]: {
655
- readonly [x: string]: unknown;
656
- };
657
- } | undefined;
658
- }>;
659
- };
660
- transcription: {
661
- request: typeof import("./transcription.js").request;
662
- generate: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
663
- stream: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
664
- readonly type: "text-delta";
665
- readonly delta: string;
666
- } | {
667
- readonly type: "segment";
668
- readonly segment: {
669
- readonly text: string;
670
- readonly startSeconds: number;
671
- readonly endSeconds: number;
672
- readonly speaker?: string | undefined;
673
- };
674
- } | {
675
- readonly type: "generation-queued";
676
- readonly id: string;
677
- readonly position?: number | undefined;
678
- } | {
679
- readonly type: "generation-progress";
680
- readonly id: string;
681
- readonly progress?: number | undefined;
682
- } | {
683
- readonly text: string;
684
- readonly segments?: readonly {
685
- readonly text: string;
686
- readonly startSeconds: number;
687
- readonly endSeconds: number;
688
- readonly speaker?: string | undefined;
689
- }[] | undefined;
690
- readonly words?: readonly {
691
- readonly text: string;
692
- readonly startSeconds: number;
693
- readonly endSeconds: number;
694
- readonly speaker?: string | undefined;
695
- readonly confidence?: number | undefined;
696
- }[] | undefined;
697
- readonly language?: string | undefined;
698
- readonly durationSeconds?: number | undefined;
699
- readonly usage?: {
700
- readonly type: "seconds";
701
- readonly seconds: number;
702
- } | {
703
- readonly type: "characters";
704
- readonly characters: number;
705
- } | {
706
- readonly type: "credits";
707
- readonly credits: number;
708
- } | {
709
- readonly type: "compute";
710
- readonly seconds: number;
711
- } | {
712
- readonly type: "tokens";
713
- readonly input?: number | undefined;
714
- readonly output?: number | undefined;
715
- readonly total?: number | undefined;
716
- readonly details?: {
717
- readonly [x: string]: unknown;
718
- } | undefined;
719
- } | undefined;
720
- readonly providerMetadata?: {
721
- readonly [x: string]: {
722
- readonly [x: string]: unknown;
723
- };
724
- } | undefined;
725
- readonly type: "finish";
726
- }>;
727
- start: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
728
- resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
729
- };
730
- decision: {
731
- request: typeof import("./decision.js").request;
732
- generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
733
- };
734
- dispose: () => Promise<void>;
735
- };
736
- export type Client<R = never> = ReturnType<typeof make<R>>;
737
- /**
738
- * Promise counterpart of `Tool.make` for `ai.llm.loop`. A throw or rejection becomes the error result the model sees, the
739
- * returned value is sent unvalidated (`undefined` as `null`), and `signal` aborts when the loop is interrupted.
740
- */
741
- export declare const tool: <Parameters extends ToolSchema<any>>(config: {
742
- readonly description: string;
743
- readonly parameters: Parameters;
744
- readonly freeform?: FreeformOption<Parameters>;
745
- readonly execute: (params: Schema.Schema.Type<Parameters>, context: Partial<ToolExecuteContext> & {
746
- readonly signal: AbortSignal;
747
- }) => unknown;
748
- }) => Tool.ExecutableTool<Parameters, Schema.Unknown>;
749
- /** Default client over `RequestExecutor.fetchLayer` for scripts; the runtime builds its layer on first use. */
750
- export declare const ai: {
751
- run: <A, E>(effect: Effect.Effect<A, E, import("./image-client.js").ImageClientService | import("./effect.js").LLMClientService | RequestExecutor.RequestExecutorService | import("./decision-client.js").Service | import("./speech-client.js").SpeechClientService | import("./transcription-client.js").TranscriptionClientService | import("./video-client.js").VideoClientService>, options?: RunOptions) => Promise<A>;
752
- /** Decoded asset bytes, downloading `url` sources through the executor. */
753
- bytes: (asset: Media.Asset, options?: RunOptions) => Promise<Uint8Array<ArrayBufferLike>>;
754
- base64: (asset: Media.Asset, options?: RunOptions) => Promise<string>;
755
- /** Pull a `url` asset into owned bytes before the provider URL expires. */
756
- materialize: (asset: Media.Asset, options?: RunOptions) => Promise<Media.Asset>;
757
- /** Read a file into an asset like `Media.file`: sniffed media type, then the extension's. */
758
- file: (path: string, options?: Media.AssetOptions & RunOptions) => Promise<Media.Asset>;
759
- /** Write an asset's bytes like `Media.write`, downloading `url` sources through the executor. */
760
- write: (asset: Media.Asset, path: string, options?: RunOptions) => Promise<void>;
761
- llm: {
762
- request: typeof LLM.request;
763
- generate: <const Model extends LanguageModel>(input: LLMRequest<LanguageModel<{
764
- readonly [x: string]: unknown;
765
- }, import("./route/client.js").CompactionOperations | undefined>> | RequestInput<Model>, options?: RunOptions) => Promise<import("./effect.js").LLMResponse>;
766
- stream: <const Model extends LanguageModel>(input: LLMRequest<LanguageModel<{
767
- readonly [x: string]: unknown;
768
- }, import("./route/client.js").CompactionOperations | undefined>> | RequestInput<Model>, options?: RunOptions) => AsyncIterable<{
769
- readonly type: "step-start";
770
- readonly index: number;
771
- } | {
772
- readonly type: "raw";
773
- readonly data: unknown;
774
- } | {
775
- readonly type: "text-start";
776
- readonly id: string;
777
- readonly providerMetadata?: {
778
- readonly [x: string]: {
779
- readonly [x: string]: unknown;
780
- };
781
- } | undefined;
782
- } | {
783
- readonly type: "text-delta";
784
- readonly id: string;
785
- readonly text: string;
786
- readonly providerMetadata?: {
787
- readonly [x: string]: {
788
- readonly [x: string]: unknown;
789
- };
790
- } | undefined;
791
- } | {
792
- readonly type: "text-end";
793
- readonly id: string;
794
- readonly text?: string | undefined;
795
- readonly providerMetadata?: {
796
- readonly [x: string]: {
797
- readonly [x: string]: unknown;
798
- };
799
- } | undefined;
800
- } | {
801
- readonly type: "reasoning-start";
802
- readonly id: string;
803
- readonly providerMetadata?: {
804
- readonly [x: string]: {
805
- readonly [x: string]: unknown;
806
- };
807
- } | undefined;
808
- } | {
809
- readonly type: "reasoning-delta";
810
- readonly id: string;
811
- readonly text: string;
812
- readonly providerMetadata?: {
813
- readonly [x: string]: {
814
- readonly [x: string]: unknown;
815
- };
816
- } | undefined;
817
- } | {
818
- readonly type: "reasoning-end";
819
- readonly id: string;
820
- readonly text?: string | undefined;
821
- readonly providerMetadata?: {
822
- readonly [x: string]: {
823
- readonly [x: string]: unknown;
824
- };
825
- } | undefined;
826
- } | {
827
- readonly type: "tool-input-start";
828
- readonly id: string;
829
- readonly name: string;
830
- readonly namespace?: string | undefined;
831
- readonly providerExecuted?: boolean | undefined;
832
- readonly providerMetadata?: {
833
- readonly [x: string]: {
834
- readonly [x: string]: unknown;
835
- };
836
- } | undefined;
837
- } | {
838
- readonly type: "tool-input-delta";
839
- readonly id: string;
840
- readonly name: string;
841
- readonly namespace?: string | undefined;
842
- readonly text: string;
843
- readonly input?: unknown;
844
- } | {
845
- readonly type: "tool-input-end";
846
- readonly id: string;
847
- readonly name: string;
848
- readonly namespace?: string | undefined;
849
- readonly providerMetadata?: {
850
- readonly [x: string]: {
851
- readonly [x: string]: unknown;
852
- };
853
- } | undefined;
854
- } | {
855
- readonly type: "tool-input-error";
856
- readonly id: string;
857
- readonly name: string;
858
- readonly namespace?: string | undefined;
859
- readonly raw: string;
860
- } | {
861
- readonly type: "tool-call";
862
- readonly id: string;
863
- readonly name: string;
864
- readonly namespace?: string | undefined;
865
- readonly input: unknown;
866
- readonly providerExecuted?: boolean | undefined;
867
- readonly providerMetadata?: {
868
- readonly [x: string]: {
869
- readonly [x: string]: unknown;
870
- };
871
- } | undefined;
872
- } | {
873
- readonly type: "tool-result";
874
- readonly id: string;
875
- readonly name: string;
876
- readonly namespace?: string | undefined;
877
- readonly result: {
878
- readonly type: "json";
879
- readonly value: unknown;
880
- } | {
881
- readonly type: "text";
882
- readonly value: unknown;
883
- } | {
884
- readonly type: "error";
885
- readonly value: unknown;
886
- } | {
887
- readonly type: "content";
888
- readonly value: readonly ({
889
- readonly type: "text";
890
- readonly text: string;
891
- } | {
892
- readonly type: "file";
893
- readonly uri: string;
894
- readonly mime: string;
895
- readonly name?: string | undefined;
896
- })[];
897
- };
898
- readonly output?: {
899
- readonly structured: unknown;
900
- readonly content: readonly ({
901
- readonly type: "text";
902
- readonly text: string;
903
- } | {
904
- readonly type: "file";
905
- readonly uri: string;
906
- readonly mime: string;
907
- readonly name?: string | undefined;
908
- })[];
909
- } | undefined;
910
- readonly providerExecuted?: boolean | undefined;
911
- readonly providerMetadata?: {
912
- readonly [x: string]: {
913
- readonly [x: string]: unknown;
914
- };
915
- } | undefined;
916
- } | {
917
- readonly type: "tool-error";
918
- readonly id: string;
919
- readonly name: string;
920
- readonly namespace?: string | undefined;
921
- readonly message: string;
922
- readonly error?: unknown;
923
- readonly providerMetadata?: {
924
- readonly [x: string]: {
925
- readonly [x: string]: unknown;
926
- };
927
- } | undefined;
928
- } | {
929
- readonly type: "step-finish";
930
- readonly index: number;
931
- readonly reason: {
932
- readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
933
- readonly raw?: string | undefined;
934
- readonly category?: string | undefined;
935
- readonly explanation?: string | undefined;
936
- };
937
- readonly usage?: import("./effect.js").Usage | undefined;
938
- readonly providerMetadata?: {
939
- readonly [x: string]: {
940
- readonly [x: string]: unknown;
941
- };
942
- } | undefined;
943
- } | {
944
- readonly type: "finish";
945
- readonly reason: {
946
- readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
947
- readonly raw?: string | undefined;
948
- readonly category?: string | undefined;
949
- readonly explanation?: string | undefined;
950
- };
951
- readonly usage?: import("./effect.js").Usage | undefined;
952
- readonly providerMetadata?: {
953
- readonly [x: string]: {
954
- readonly [x: string]: unknown;
955
- };
956
- } | undefined;
957
- } | {
958
- readonly type: "media";
959
- readonly media: Media.Asset;
960
- readonly providerMetadata?: {
961
- readonly [x: string]: {
962
- readonly [x: string]: unknown;
963
- };
964
- } | undefined;
965
- } | {
966
- readonly type: "provider-error";
967
- readonly message: string;
968
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
969
- readonly providerMetadata?: {
970
- readonly [x: string]: {
971
- readonly [x: string]: unknown;
972
- };
973
- } | undefined;
974
- } | ({
975
- readonly type: "compaction";
976
- readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
977
- readonly id?: string | undefined;
978
- readonly encrypted?: string | undefined;
979
- readonly text?: string | null | undefined;
980
- } & ({
981
- readonly encrypted: string;
982
- readonly text?: never;
983
- } | {
984
- readonly text: string | null;
985
- readonly encrypted?: never;
986
- }))>;
987
- /** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
988
- loop: <const Model extends LanguageModel>(input: LoopInput<Model>, options?: RunOptions) => AsyncIterable<{
989
- readonly type: "step-start";
990
- readonly index: number;
991
- } | {
992
- readonly type: "raw";
993
- readonly data: unknown;
994
- } | {
995
- readonly type: "text-start";
996
- readonly id: string;
997
- readonly providerMetadata?: {
998
- readonly [x: string]: {
999
- readonly [x: string]: unknown;
1000
- };
1001
- } | undefined;
1002
- } | {
1003
- readonly type: "text-delta";
1004
- readonly id: string;
1005
- readonly text: string;
1006
- readonly providerMetadata?: {
1007
- readonly [x: string]: {
1008
- readonly [x: string]: unknown;
1009
- };
1010
- } | undefined;
1011
- } | {
1012
- readonly type: "text-end";
1013
- readonly id: string;
1014
- readonly text?: string | undefined;
1015
- readonly providerMetadata?: {
1016
- readonly [x: string]: {
1017
- readonly [x: string]: unknown;
1018
- };
1019
- } | undefined;
1020
- } | {
1021
- readonly type: "reasoning-start";
1022
- readonly id: string;
1023
- readonly providerMetadata?: {
1024
- readonly [x: string]: {
1025
- readonly [x: string]: unknown;
1026
- };
1027
- } | undefined;
1028
- } | {
1029
- readonly type: "reasoning-delta";
1030
- readonly id: string;
1031
- readonly text: string;
1032
- readonly providerMetadata?: {
1033
- readonly [x: string]: {
1034
- readonly [x: string]: unknown;
1035
- };
1036
- } | undefined;
1037
- } | {
1038
- readonly type: "reasoning-end";
1039
- readonly id: string;
1040
- readonly text?: string | undefined;
1041
- readonly providerMetadata?: {
1042
- readonly [x: string]: {
1043
- readonly [x: string]: unknown;
1044
- };
1045
- } | undefined;
1046
- } | {
1047
- readonly type: "tool-input-start";
1048
- readonly id: string;
1049
- readonly name: string;
1050
- readonly namespace?: string | undefined;
1051
- readonly providerExecuted?: boolean | undefined;
1052
- readonly providerMetadata?: {
1053
- readonly [x: string]: {
1054
- readonly [x: string]: unknown;
1055
- };
1056
- } | undefined;
1057
- } | {
1058
- readonly type: "tool-input-delta";
1059
- readonly id: string;
1060
- readonly name: string;
1061
- readonly namespace?: string | undefined;
1062
- readonly text: string;
1063
- readonly input?: unknown;
1064
- } | {
1065
- readonly type: "tool-input-end";
1066
- readonly id: string;
1067
- readonly name: string;
1068
- readonly namespace?: string | undefined;
1069
- readonly providerMetadata?: {
1070
- readonly [x: string]: {
1071
- readonly [x: string]: unknown;
1072
- };
1073
- } | undefined;
1074
- } | {
1075
- readonly type: "tool-input-error";
1076
- readonly id: string;
1077
- readonly name: string;
1078
- readonly namespace?: string | undefined;
1079
- readonly raw: string;
1080
- } | {
1081
- readonly type: "tool-call";
1082
- readonly id: string;
1083
- readonly name: string;
1084
- readonly namespace?: string | undefined;
1085
- readonly input: unknown;
1086
- readonly providerExecuted?: boolean | undefined;
1087
- readonly providerMetadata?: {
1088
- readonly [x: string]: {
1089
- readonly [x: string]: unknown;
1090
- };
1091
- } | undefined;
1092
- } | {
1093
- readonly type: "tool-result";
1094
- readonly id: string;
1095
- readonly name: string;
1096
- readonly namespace?: string | undefined;
1097
- readonly result: {
1098
- readonly type: "json";
1099
- readonly value: unknown;
1100
- } | {
59
+ request: typeof LLM.request;
60
+ generate: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: StreamOptions & RunOptions) => Promise<import("./index.js").LLMResponse>;
61
+ stream: <const Model extends LanguageModel>(input: RequestInput<Model> | LLMRequest, options?: StreamOptions & RunOptions) => AsyncIterable<{
62
+ readonly type: "step-start";
63
+ readonly index: number;
64
+ } | {
65
+ readonly type: "raw";
66
+ readonly data: unknown;
67
+ } | {
68
+ readonly type: "text-start";
69
+ readonly id: string;
70
+ readonly providerMetadata?: {
71
+ readonly [x: string]: {
72
+ readonly [x: string]: unknown;
73
+ };
74
+ } | undefined;
75
+ } | {
76
+ readonly type: "text-delta";
77
+ readonly id: string;
78
+ readonly text: string;
79
+ readonly providerMetadata?: {
80
+ readonly [x: string]: {
81
+ readonly [x: string]: unknown;
82
+ };
83
+ } | undefined;
84
+ } | {
85
+ readonly type: "text-end";
86
+ readonly id: string;
87
+ readonly text?: string | undefined;
88
+ readonly providerMetadata?: {
89
+ readonly [x: string]: {
90
+ readonly [x: string]: unknown;
91
+ };
92
+ } | undefined;
93
+ } | {
94
+ readonly type: "reasoning-start";
95
+ readonly id: string;
96
+ readonly providerMetadata?: {
97
+ readonly [x: string]: {
98
+ readonly [x: string]: unknown;
99
+ };
100
+ } | undefined;
101
+ } | {
102
+ readonly type: "reasoning-delta";
103
+ readonly id: string;
104
+ readonly text: string;
105
+ readonly providerMetadata?: {
106
+ readonly [x: string]: {
107
+ readonly [x: string]: unknown;
108
+ };
109
+ } | undefined;
110
+ } | {
111
+ readonly type: "reasoning-end";
112
+ readonly id: string;
113
+ readonly text?: string | undefined;
114
+ readonly providerMetadata?: {
115
+ readonly [x: string]: {
116
+ readonly [x: string]: unknown;
117
+ };
118
+ } | undefined;
119
+ } | {
120
+ readonly type: "tool-input-start";
121
+ readonly id: string;
122
+ readonly name: string;
123
+ readonly namespace?: string | undefined;
124
+ readonly providerExecuted?: boolean | undefined;
125
+ readonly providerMetadata?: {
126
+ readonly [x: string]: {
127
+ readonly [x: string]: unknown;
128
+ };
129
+ } | undefined;
130
+ } | {
131
+ readonly type: "tool-input-delta";
132
+ readonly id: string;
133
+ readonly name: string;
134
+ readonly namespace?: string | undefined;
135
+ readonly text: string;
136
+ readonly input?: unknown;
137
+ } | {
138
+ readonly type: "tool-input-end";
139
+ readonly id: string;
140
+ readonly name: string;
141
+ readonly namespace?: string | undefined;
142
+ readonly providerMetadata?: {
143
+ readonly [x: string]: {
144
+ readonly [x: string]: unknown;
145
+ };
146
+ } | undefined;
147
+ } | {
148
+ readonly type: "tool-input-error";
149
+ readonly id: string;
150
+ readonly name: string;
151
+ readonly namespace?: string | undefined;
152
+ readonly raw: string;
153
+ } | {
154
+ readonly type: "tool-call";
155
+ readonly id: string;
156
+ readonly name: string;
157
+ readonly namespace?: string | undefined;
158
+ readonly input: unknown;
159
+ readonly providerExecuted?: boolean | undefined;
160
+ readonly providerMetadata?: {
161
+ readonly [x: string]: {
162
+ readonly [x: string]: unknown;
163
+ };
164
+ } | undefined;
165
+ } | {
166
+ readonly type: "tool-result";
167
+ readonly id: string;
168
+ readonly name: string;
169
+ readonly namespace?: string | undefined;
170
+ readonly result: {
171
+ readonly type: "json";
172
+ readonly value: unknown;
173
+ } | {
174
+ readonly type: "text";
175
+ readonly value: unknown;
176
+ } | {
177
+ readonly type: "error";
178
+ readonly value: unknown;
179
+ } | {
180
+ readonly type: "content";
181
+ readonly value: readonly ({
1101
182
  readonly type: "text";
1102
- readonly value: unknown;
183
+ readonly text: string;
1103
184
  } | {
1104
- readonly type: "error";
1105
- readonly value: unknown;
185
+ readonly type: "file";
186
+ readonly uri: string;
187
+ readonly mime: string;
188
+ readonly name?: string | undefined;
189
+ })[];
190
+ };
191
+ readonly output?: {
192
+ readonly structured: unknown;
193
+ readonly content: readonly ({
194
+ readonly type: "text";
195
+ readonly text: string;
1106
196
  } | {
1107
- readonly type: "content";
1108
- readonly value: readonly ({
1109
- readonly type: "text";
1110
- readonly text: string;
1111
- } | {
1112
- readonly type: "file";
1113
- readonly uri: string;
1114
- readonly mime: string;
1115
- readonly name?: string | undefined;
1116
- })[];
197
+ readonly type: "file";
198
+ readonly uri: string;
199
+ readonly mime: string;
200
+ readonly name?: string | undefined;
201
+ })[];
202
+ } | undefined;
203
+ readonly providerExecuted?: boolean | undefined;
204
+ readonly providerMetadata?: {
205
+ readonly [x: string]: {
206
+ readonly [x: string]: unknown;
1117
207
  };
1118
- readonly output?: {
1119
- readonly structured: unknown;
1120
- readonly content: readonly ({
1121
- readonly type: "text";
1122
- readonly text: string;
1123
- } | {
1124
- readonly type: "file";
1125
- readonly uri: string;
1126
- readonly mime: string;
1127
- readonly name?: string | undefined;
1128
- })[];
1129
- } | undefined;
1130
- readonly providerExecuted?: boolean | undefined;
1131
- readonly providerMetadata?: {
1132
- readonly [x: string]: {
1133
- readonly [x: string]: unknown;
1134
- };
1135
- } | undefined;
1136
- } | {
1137
- readonly type: "tool-error";
1138
- readonly id: string;
1139
- readonly name: string;
1140
- readonly namespace?: string | undefined;
1141
- readonly message: string;
1142
- readonly error?: unknown;
1143
- readonly providerMetadata?: {
1144
- readonly [x: string]: {
1145
- readonly [x: string]: unknown;
1146
- };
1147
- } | undefined;
1148
- } | {
1149
- readonly type: "step-finish";
1150
- readonly index: number;
1151
- readonly reason: {
1152
- readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
1153
- readonly raw?: string | undefined;
1154
- readonly category?: string | undefined;
1155
- readonly explanation?: string | undefined;
208
+ } | undefined;
209
+ } | {
210
+ readonly type: "tool-error";
211
+ readonly id: string;
212
+ readonly name: string;
213
+ readonly namespace?: string | undefined;
214
+ readonly message: string;
215
+ readonly error?: unknown;
216
+ readonly providerMetadata?: {
217
+ readonly [x: string]: {
218
+ readonly [x: string]: unknown;
1156
219
  };
1157
- readonly usage?: import("./effect.js").Usage | undefined;
1158
- readonly providerMetadata?: {
1159
- readonly [x: string]: {
1160
- readonly [x: string]: unknown;
1161
- };
1162
- } | undefined;
1163
- } | {
1164
- readonly type: "finish";
1165
- readonly reason: {
1166
- readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
1167
- readonly raw?: string | undefined;
1168
- readonly category?: string | undefined;
1169
- readonly explanation?: string | undefined;
220
+ } | undefined;
221
+ } | {
222
+ readonly type: "step-finish";
223
+ readonly index: number;
224
+ readonly reason: {
225
+ readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
226
+ readonly raw?: string | undefined;
227
+ readonly category?: string | undefined;
228
+ readonly explanation?: string | undefined;
229
+ };
230
+ readonly usage?: import("./index.js").Usage | undefined;
231
+ readonly providerMetadata?: {
232
+ readonly [x: string]: {
233
+ readonly [x: string]: unknown;
1170
234
  };
1171
- readonly usage?: import("./effect.js").Usage | undefined;
1172
- readonly providerMetadata?: {
1173
- readonly [x: string]: {
1174
- readonly [x: string]: unknown;
1175
- };
1176
- } | undefined;
1177
- } | {
1178
- readonly type: "media";
1179
- readonly media: Media.Asset;
1180
- readonly providerMetadata?: {
1181
- readonly [x: string]: {
1182
- readonly [x: string]: unknown;
1183
- };
1184
- } | undefined;
1185
- } | {
1186
- readonly type: "provider-error";
1187
- readonly message: string;
1188
- readonly classification?: "context-overflow" | "payload-too-large" | undefined;
1189
- readonly providerMetadata?: {
1190
- readonly [x: string]: {
1191
- readonly [x: string]: unknown;
1192
- };
1193
- } | undefined;
1194
- } | ({
1195
- readonly type: "compaction";
1196
- readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
1197
- readonly id?: string | undefined;
1198
- readonly encrypted?: string | undefined;
1199
- readonly text?: string | null | undefined;
1200
- } & ({
1201
- readonly encrypted: string;
1202
- readonly text?: never;
1203
- } | {
1204
- readonly text: string | null;
1205
- readonly encrypted?: never;
1206
- }))>;
1207
- /** Decode the model's output against `schema` (or `jsonSchema`, unvalidated) like `LLM.generateObject`. */
1208
- generateObject: {
1209
- <const Model extends LanguageModel, S extends ToolSchema<any>>(input: GenerateObjectOptions<S, Model>, options?: RunOptions): Promise<GenerateObjectResponse<Schema.Schema.Type<S>>>;
1210
- <const Model extends LanguageModel>(input: GenerateObjectDynamicOptions<Model>, options?: RunOptions): Promise<GenerateObjectResponse<unknown>>;
235
+ } | undefined;
236
+ } | {
237
+ readonly type: "finish";
238
+ readonly reason: {
239
+ readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
240
+ readonly raw?: string | undefined;
241
+ readonly category?: string | undefined;
242
+ readonly explanation?: string | undefined;
243
+ };
244
+ readonly usage?: import("./index.js").Usage | undefined;
245
+ readonly providerMetadata?: {
246
+ readonly [x: string]: {
247
+ readonly [x: string]: unknown;
248
+ };
249
+ } | undefined;
250
+ } | {
251
+ readonly type: "media";
252
+ readonly media: Media.Asset;
253
+ readonly providerMetadata?: {
254
+ readonly [x: string]: {
255
+ readonly [x: string]: unknown;
256
+ };
257
+ } | undefined;
258
+ } | {
259
+ readonly type: "provider-error";
260
+ readonly message: string;
261
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
262
+ readonly providerMetadata?: {
263
+ readonly [x: string]: {
264
+ readonly [x: string]: unknown;
265
+ };
266
+ } | undefined;
267
+ } | ({
268
+ readonly type: "compaction";
269
+ readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
270
+ readonly id?: string | undefined;
271
+ readonly encrypted?: string | undefined;
272
+ readonly text?: string | null | undefined;
273
+ } & ({
274
+ readonly encrypted: string;
275
+ readonly text?: never;
276
+ } | {
277
+ readonly text: string | null;
278
+ readonly encrypted?: never;
279
+ }))>;
280
+ /** Stream model calls, running their tool calls, until the model stops calling tools or `until` is true. */
281
+ loop: <const Model extends LanguageModel>(input: LoopInput<Model>, options?: StreamOptions & RunOptions) => AsyncIterable<{
282
+ readonly type: "step-start";
283
+ readonly index: number;
284
+ } | {
285
+ readonly type: "raw";
286
+ readonly data: unknown;
287
+ } | {
288
+ readonly type: "text-start";
289
+ readonly id: string;
290
+ readonly providerMetadata?: {
291
+ readonly [x: string]: {
292
+ readonly [x: string]: unknown;
293
+ };
294
+ } | undefined;
295
+ } | {
296
+ readonly type: "text-delta";
297
+ readonly id: string;
298
+ readonly text: string;
299
+ readonly providerMetadata?: {
300
+ readonly [x: string]: {
301
+ readonly [x: string]: unknown;
302
+ };
303
+ } | undefined;
304
+ } | {
305
+ readonly type: "text-end";
306
+ readonly id: string;
307
+ readonly text?: string | undefined;
308
+ readonly providerMetadata?: {
309
+ readonly [x: string]: {
310
+ readonly [x: string]: unknown;
311
+ };
312
+ } | undefined;
313
+ } | {
314
+ readonly type: "reasoning-start";
315
+ readonly id: string;
316
+ readonly providerMetadata?: {
317
+ readonly [x: string]: {
318
+ readonly [x: string]: unknown;
319
+ };
320
+ } | undefined;
321
+ } | {
322
+ readonly type: "reasoning-delta";
323
+ readonly id: string;
324
+ readonly text: string;
325
+ readonly providerMetadata?: {
326
+ readonly [x: string]: {
327
+ readonly [x: string]: unknown;
328
+ };
329
+ } | undefined;
330
+ } | {
331
+ readonly type: "reasoning-end";
332
+ readonly id: string;
333
+ readonly text?: string | undefined;
334
+ readonly providerMetadata?: {
335
+ readonly [x: string]: {
336
+ readonly [x: string]: unknown;
337
+ };
338
+ } | undefined;
339
+ } | {
340
+ readonly type: "tool-input-start";
341
+ readonly id: string;
342
+ readonly name: string;
343
+ readonly namespace?: string | undefined;
344
+ readonly providerExecuted?: boolean | undefined;
345
+ readonly providerMetadata?: {
346
+ readonly [x: string]: {
347
+ readonly [x: string]: unknown;
348
+ };
349
+ } | undefined;
350
+ } | {
351
+ readonly type: "tool-input-delta";
352
+ readonly id: string;
353
+ readonly name: string;
354
+ readonly namespace?: string | undefined;
355
+ readonly text: string;
356
+ readonly input?: unknown;
357
+ } | {
358
+ readonly type: "tool-input-end";
359
+ readonly id: string;
360
+ readonly name: string;
361
+ readonly namespace?: string | undefined;
362
+ readonly providerMetadata?: {
363
+ readonly [x: string]: {
364
+ readonly [x: string]: unknown;
365
+ };
366
+ } | undefined;
367
+ } | {
368
+ readonly type: "tool-input-error";
369
+ readonly id: string;
370
+ readonly name: string;
371
+ readonly namespace?: string | undefined;
372
+ readonly raw: string;
373
+ } | {
374
+ readonly type: "tool-call";
375
+ readonly id: string;
376
+ readonly name: string;
377
+ readonly namespace?: string | undefined;
378
+ readonly input: unknown;
379
+ readonly providerExecuted?: boolean | undefined;
380
+ readonly providerMetadata?: {
381
+ readonly [x: string]: {
382
+ readonly [x: string]: unknown;
383
+ };
384
+ } | undefined;
385
+ } | {
386
+ readonly type: "tool-result";
387
+ readonly id: string;
388
+ readonly name: string;
389
+ readonly namespace?: string | undefined;
390
+ readonly result: {
391
+ readonly type: "json";
392
+ readonly value: unknown;
393
+ } | {
394
+ readonly type: "text";
395
+ readonly value: unknown;
396
+ } | {
397
+ readonly type: "error";
398
+ readonly value: unknown;
399
+ } | {
400
+ readonly type: "content";
401
+ readonly value: readonly ({
402
+ readonly type: "text";
403
+ readonly text: string;
404
+ } | {
405
+ readonly type: "file";
406
+ readonly uri: string;
407
+ readonly mime: string;
408
+ readonly name?: string | undefined;
409
+ })[];
1211
410
  };
1212
- /** Compact a Responses request like `LLMClient.compact`: a replacement window, or a checkpoint with `mechanism: "trigger"`. */
1213
- compact: {
1214
- (request: CheckpointRequest, options: TriggerCompactOptions & RunOptions): Promise<CompactionCheckpointResponse>;
1215
- (request: CompactionRequest, options?: EndpointCompactOptions & RunOptions): Promise<CompactionResponse>;
411
+ readonly output?: {
412
+ readonly structured: unknown;
413
+ readonly content: readonly ({
414
+ readonly type: "text";
415
+ readonly text: string;
416
+ } | {
417
+ readonly type: "file";
418
+ readonly uri: string;
419
+ readonly mime: string;
420
+ readonly name?: string | undefined;
421
+ })[];
422
+ } | undefined;
423
+ readonly providerExecuted?: boolean | undefined;
424
+ readonly providerMetadata?: {
425
+ readonly [x: string]: {
426
+ readonly [x: string]: unknown;
427
+ };
428
+ } | undefined;
429
+ } | {
430
+ readonly type: "tool-error";
431
+ readonly id: string;
432
+ readonly name: string;
433
+ readonly namespace?: string | undefined;
434
+ readonly message: string;
435
+ readonly error?: unknown;
436
+ readonly providerMetadata?: {
437
+ readonly [x: string]: {
438
+ readonly [x: string]: unknown;
439
+ };
440
+ } | undefined;
441
+ } | {
442
+ readonly type: "step-finish";
443
+ readonly index: number;
444
+ readonly reason: {
445
+ readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
446
+ readonly raw?: string | undefined;
447
+ readonly category?: string | undefined;
448
+ readonly explanation?: string | undefined;
449
+ };
450
+ readonly usage?: import("./index.js").Usage | undefined;
451
+ readonly providerMetadata?: {
452
+ readonly [x: string]: {
453
+ readonly [x: string]: unknown;
454
+ };
455
+ } | undefined;
456
+ } | {
457
+ readonly type: "finish";
458
+ readonly reason: {
459
+ readonly normalized: "content-filter" | "error" | "length" | "stop" | "tool-calls" | "unknown";
460
+ readonly raw?: string | undefined;
461
+ readonly category?: string | undefined;
462
+ readonly explanation?: string | undefined;
1216
463
  };
464
+ readonly usage?: import("./index.js").Usage | undefined;
465
+ readonly providerMetadata?: {
466
+ readonly [x: string]: {
467
+ readonly [x: string]: unknown;
468
+ };
469
+ } | undefined;
470
+ } | {
471
+ readonly type: "media";
472
+ readonly media: Media.Asset;
473
+ readonly providerMetadata?: {
474
+ readonly [x: string]: {
475
+ readonly [x: string]: unknown;
476
+ };
477
+ } | undefined;
478
+ } | {
479
+ readonly type: "provider-error";
480
+ readonly message: string;
481
+ readonly classification?: "context-overflow" | "payload-too-large" | undefined;
482
+ readonly providerMetadata?: {
483
+ readonly [x: string]: {
484
+ readonly [x: string]: unknown;
485
+ };
486
+ } | undefined;
487
+ } | ({
488
+ readonly type: "compaction";
489
+ readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
490
+ readonly id?: string | undefined;
491
+ readonly encrypted?: string | undefined;
492
+ readonly text?: string | null | undefined;
493
+ } & ({
494
+ readonly encrypted: string;
495
+ readonly text?: never;
496
+ } | {
497
+ readonly text: string | null;
498
+ readonly encrypted?: never;
499
+ }))>;
500
+ /** Decode the model's output against `schema` (or `jsonSchema`, unvalidated). */
501
+ generateObject: {
502
+ <const Model extends LanguageModel, S extends ToolSchema<any>>(input: GenerateObjectOptions<S, Model>, options?: RunOptions): Promise<GenerateObjectResponse<Schema.Schema.Type<S>>>;
503
+ <const Model extends LanguageModel>(input: GenerateObjectDynamicOptions<Model>, options?: RunOptions): Promise<GenerateObjectResponse<unknown>>;
1217
504
  };
505
+ /** Compact a Responses request: a replacement window, or a checkpoint with `mechanism: "trigger"`. */
506
+ compact: {
507
+ (request: CheckpointRequest, options: TriggerCompactOptions & RunOptions): Promise<CompactionCheckpointResponse>;
508
+ (request: CompactionRequest, options?: EndpointCompactOptions & RunOptions): Promise<CompactionResponse>;
509
+ };
510
+ canCompact: typeof LLM.canCompact;
1218
511
  image: {
1219
512
  request: typeof import("./image.js").request;
1220
- generate: <const Model extends ImageModel>(input: ImageRequest | ImageRequestInput<Model>, options?: AwaitOptions & RunOptions) => Promise<import("./image.js").ImageResponse>;
1221
- stream: <const Model extends ImageModel>(input: ImageRequest | ImageRequestInput<Model>, options?: AwaitOptions & RunOptions) => AsyncIterable<{
513
+ generate: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => Promise<import("./image.js").ImageResponse>;
514
+ stream: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
1222
515
  readonly type: "image-partial";
1223
516
  readonly index: number;
1224
517
  readonly image: Media.Asset;
@@ -1263,182 +556,203 @@ export declare const ai: {
1263
556
  };
1264
557
  } | undefined;
1265
558
  }>;
1266
- start: <const Model extends ImageModel>(input: ImageRequest | ImageRequestInput<Model>, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
559
+ start: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
1267
560
  resume: (model: ImageModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
1268
561
  };
1269
- video: {
1270
- request: typeof import("./video.js").request;
1271
- start: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
1272
- generate: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
1273
- resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
1274
- stream: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: AwaitOptions & RunOptions) => AsyncIterable<{
1275
- readonly type: "video";
1276
- readonly index: number;
1277
- readonly video: Media.Asset;
1278
- } | {
1279
- readonly type: "generation-queued";
1280
- readonly id: string;
1281
- readonly position?: number | undefined;
1282
- } | {
1283
- readonly type: "generation-progress";
1284
- readonly id: string;
1285
- readonly progress?: number | undefined;
1286
- } | {
1287
- readonly type: "finish";
1288
- readonly usage?: {
1289
- readonly type: "seconds";
1290
- readonly seconds: number;
1291
- } | {
1292
- readonly type: "characters";
1293
- readonly characters: number;
1294
- } | {
1295
- readonly type: "credits";
1296
- readonly credits: number;
1297
- } | {
1298
- readonly type: "compute";
1299
- readonly seconds: number;
1300
- } | {
1301
- readonly type: "tokens";
1302
- readonly input?: number | undefined;
1303
- readonly output?: number | undefined;
1304
- readonly total?: number | undefined;
1305
- readonly details?: {
1306
- readonly [x: string]: unknown;
1307
- } | undefined;
1308
- } | undefined;
1309
- readonly providerMetadata?: {
1310
- readonly [x: string]: {
1311
- readonly [x: string]: unknown;
1312
- };
1313
- } | undefined;
1314
- }>;
562
+ decision: {
563
+ request: typeof import("./decision.js").request;
564
+ generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
1315
565
  };
1316
- speech: {
1317
- request: typeof import("./speech.js").request;
1318
- generate: <const Model extends SpeechModel>(input: SpeechRequest | SpeechRequestInput<Model>, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
1319
- stream: <const Model extends SpeechModel>(input: SpeechRequest | SpeechRequestInput<Model>, options?: RunOptions) => AsyncIterable<{
1320
- readonly type: "audio-delta";
1321
- readonly chunk: Uint8Array<ArrayBufferLike>;
1322
- } | {
1323
- readonly type: "timestamps";
1324
- readonly items: readonly {
1325
- readonly text: string;
1326
- readonly startSeconds: number;
1327
- readonly endSeconds: number;
1328
- }[];
1329
- } | {
1330
- readonly type: "generation-queued";
1331
- readonly id: string;
1332
- readonly position?: number | undefined;
1333
- } | {
1334
- readonly type: "generation-progress";
1335
- readonly id: string;
1336
- readonly progress?: number | undefined;
1337
- } | {
1338
- readonly type: "finish";
1339
- readonly audio: Media.Asset;
1340
- readonly usage?: {
1341
- readonly type: "seconds";
1342
- readonly seconds: number;
1343
- } | {
1344
- readonly type: "characters";
1345
- readonly characters: number;
1346
- } | {
1347
- readonly type: "credits";
1348
- readonly credits: number;
1349
- } | {
1350
- readonly type: "compute";
1351
- readonly seconds: number;
1352
- } | {
1353
- readonly type: "tokens";
1354
- readonly input?: number | undefined;
1355
- readonly output?: number | undefined;
1356
- readonly total?: number | undefined;
1357
- readonly details?: {
1358
- readonly [x: string]: unknown;
566
+ /** Experimental: may change without compatibility guarantees. */
567
+ experimental: {
568
+ speech: {
569
+ request: typeof import("./speech.js").request;
570
+ generate: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
571
+ stream: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => AsyncIterable<{
572
+ readonly type: "audio-delta";
573
+ readonly chunk: Uint8Array<ArrayBufferLike>;
574
+ } | {
575
+ readonly type: "timestamps";
576
+ readonly items: readonly {
577
+ readonly text: string;
578
+ readonly startSeconds: number;
579
+ readonly endSeconds: number;
580
+ }[];
581
+ } | {
582
+ readonly type: "generation-queued";
583
+ readonly id: string;
584
+ readonly position?: number | undefined;
585
+ } | {
586
+ readonly type: "generation-progress";
587
+ readonly id: string;
588
+ readonly progress?: number | undefined;
589
+ } | {
590
+ readonly type: "finish";
591
+ readonly audio: Media.Asset;
592
+ readonly usage?: {
593
+ readonly type: "seconds";
594
+ readonly seconds: number;
595
+ } | {
596
+ readonly type: "characters";
597
+ readonly characters: number;
598
+ } | {
599
+ readonly type: "credits";
600
+ readonly credits: number;
601
+ } | {
602
+ readonly type: "compute";
603
+ readonly seconds: number;
604
+ } | {
605
+ readonly type: "tokens";
606
+ readonly input?: number | undefined;
607
+ readonly output?: number | undefined;
608
+ readonly total?: number | undefined;
609
+ readonly details?: {
610
+ readonly [x: string]: unknown;
611
+ } | undefined;
1359
612
  } | undefined;
1360
- } | undefined;
1361
- readonly providerMetadata?: {
1362
- readonly [x: string]: {
1363
- readonly [x: string]: unknown;
613
+ readonly providerMetadata?: {
614
+ readonly [x: string]: {
615
+ readonly [x: string]: unknown;
616
+ };
617
+ } | undefined;
618
+ }>;
619
+ };
620
+ transcription: {
621
+ request: typeof import("./transcription.js").request;
622
+ generate: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
623
+ stream: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
624
+ readonly type: "text-delta";
625
+ readonly delta: string;
626
+ } | {
627
+ readonly type: "segment";
628
+ readonly segment: {
629
+ readonly text: string;
630
+ readonly startSeconds: number;
631
+ readonly endSeconds: number;
632
+ readonly speaker?: string | undefined;
1364
633
  };
1365
- } | undefined;
1366
- }>;
1367
- };
1368
- transcription: {
1369
- request: typeof import("./transcription.js").request;
1370
- generate: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
1371
- stream: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: AwaitOptions & RunOptions) => AsyncIterable<{
1372
- readonly type: "text-delta";
1373
- readonly delta: string;
1374
- } | {
1375
- readonly type: "segment";
1376
- readonly segment: {
1377
- readonly text: string;
1378
- readonly startSeconds: number;
1379
- readonly endSeconds: number;
1380
- readonly speaker?: string | undefined;
1381
- };
1382
- } | {
1383
- readonly type: "generation-queued";
1384
- readonly id: string;
1385
- readonly position?: number | undefined;
1386
- } | {
1387
- readonly type: "generation-progress";
1388
- readonly id: string;
1389
- readonly progress?: number | undefined;
1390
- } | {
1391
- readonly text: string;
1392
- readonly segments?: readonly {
1393
- readonly text: string;
1394
- readonly startSeconds: number;
1395
- readonly endSeconds: number;
1396
- readonly speaker?: string | undefined;
1397
- }[] | undefined;
1398
- readonly words?: readonly {
1399
- readonly text: string;
1400
- readonly startSeconds: number;
1401
- readonly endSeconds: number;
1402
- readonly speaker?: string | undefined;
1403
- readonly confidence?: number | undefined;
1404
- }[] | undefined;
1405
- readonly language?: string | undefined;
1406
- readonly durationSeconds?: number | undefined;
1407
- readonly usage?: {
1408
- readonly type: "seconds";
1409
- readonly seconds: number;
1410
- } | {
1411
- readonly type: "characters";
1412
- readonly characters: number;
1413
634
  } | {
1414
- readonly type: "credits";
1415
- readonly credits: number;
635
+ readonly type: "generation-queued";
636
+ readonly id: string;
637
+ readonly position?: number | undefined;
1416
638
  } | {
1417
- readonly type: "compute";
1418
- readonly seconds: number;
639
+ readonly type: "generation-progress";
640
+ readonly id: string;
641
+ readonly progress?: number | undefined;
1419
642
  } | {
1420
- readonly type: "tokens";
1421
- readonly input?: number | undefined;
1422
- readonly output?: number | undefined;
1423
- readonly total?: number | undefined;
1424
- readonly details?: {
1425
- readonly [x: string]: unknown;
643
+ readonly text: string;
644
+ readonly segments?: readonly {
645
+ readonly text: string;
646
+ readonly startSeconds: number;
647
+ readonly endSeconds: number;
648
+ readonly speaker?: string | undefined;
649
+ }[] | undefined;
650
+ readonly words?: readonly {
651
+ readonly text: string;
652
+ readonly startSeconds: number;
653
+ readonly endSeconds: number;
654
+ readonly speaker?: string | undefined;
655
+ readonly confidence?: number | undefined;
656
+ }[] | undefined;
657
+ readonly language?: string | undefined;
658
+ readonly durationSeconds?: number | undefined;
659
+ readonly usage?: {
660
+ readonly type: "seconds";
661
+ readonly seconds: number;
662
+ } | {
663
+ readonly type: "characters";
664
+ readonly characters: number;
665
+ } | {
666
+ readonly type: "credits";
667
+ readonly credits: number;
668
+ } | {
669
+ readonly type: "compute";
670
+ readonly seconds: number;
671
+ } | {
672
+ readonly type: "tokens";
673
+ readonly input?: number | undefined;
674
+ readonly output?: number | undefined;
675
+ readonly total?: number | undefined;
676
+ readonly details?: {
677
+ readonly [x: string]: unknown;
678
+ } | undefined;
1426
679
  } | undefined;
1427
- } | undefined;
1428
- readonly providerMetadata?: {
1429
- readonly [x: string]: {
1430
- readonly [x: string]: unknown;
1431
- };
1432
- } | undefined;
1433
- readonly type: "finish";
1434
- }>;
1435
- start: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
1436
- resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
1437
- };
1438
- decision: {
1439
- request: typeof import("./decision.js").request;
1440
- generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
680
+ readonly providerMetadata?: {
681
+ readonly [x: string]: {
682
+ readonly [x: string]: unknown;
683
+ };
684
+ } | undefined;
685
+ readonly type: "finish";
686
+ }>;
687
+ start: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
688
+ resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
689
+ };
690
+ video: {
691
+ request: typeof import("./video.js").request;
692
+ start: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
693
+ generate: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
694
+ resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
695
+ stream: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
696
+ readonly type: "video";
697
+ readonly index: number;
698
+ readonly video: Media.Asset;
699
+ } | {
700
+ readonly type: "generation-queued";
701
+ readonly id: string;
702
+ readonly position?: number | undefined;
703
+ } | {
704
+ readonly type: "generation-progress";
705
+ readonly id: string;
706
+ readonly progress?: number | undefined;
707
+ } | {
708
+ readonly type: "finish";
709
+ readonly usage?: {
710
+ readonly type: "seconds";
711
+ readonly seconds: number;
712
+ } | {
713
+ readonly type: "characters";
714
+ readonly characters: number;
715
+ } | {
716
+ readonly type: "credits";
717
+ readonly credits: number;
718
+ } | {
719
+ readonly type: "compute";
720
+ readonly seconds: number;
721
+ } | {
722
+ readonly type: "tokens";
723
+ readonly input?: number | undefined;
724
+ readonly output?: number | undefined;
725
+ readonly total?: number | undefined;
726
+ readonly details?: {
727
+ readonly [x: string]: unknown;
728
+ } | undefined;
729
+ } | undefined;
730
+ readonly providerMetadata?: {
731
+ readonly [x: string]: {
732
+ readonly [x: string]: unknown;
733
+ };
734
+ } | undefined;
735
+ }>;
736
+ };
1441
737
  };
1442
738
  dispose: () => Promise<void>;
1443
739
  };
740
+ export type Client<R = never> = ReturnType<typeof make<R>>;
741
+ /** `tool` from `@opencode/ai/effect`, with an `execute` that returns a value or a Promise and throws to fail. */
742
+ export declare const tool: <Parameters extends ToolSchema<any> = typeof Schema.Unknown, Success extends ToolSchema<any> = typeof Schema.Unknown, Result extends Schema.Schema.Type<Success> | PromiseLike<Schema.Schema.Type<Success>> | NoExecute = NoExecute>(config: ToolOptions<Parameters, Success, (params: Schema.Schema.Type<Parameters>, context: Partial<ToolExecuteContext> & {
743
+ signal: AbortSignal;
744
+ }) => Result>) => 0 extends 1 & Result ? import("./tool.js").ExecutableTool<Parameters, Success> : [Result, NoExecute] extends [NoExecute, Result] ? import("./tool.js").Tool<Parameters, Success> : import("./tool.js").ExecutableTool<Parameters, Success>;
745
+ /** Default client over `RequestExecutor.fetchLayer`; the runtime builds its layer on first use and holds nothing to dispose. */
746
+ export declare const ai: Omit<Client, "dispose">;
1444
747
  export * as AI from "./index.js";
748
+ export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
749
+ export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, LLMRequest, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, ToolError, FinishReasonDetails, StepFinish, Finish, MediaEvent, ProviderErrorEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, NoRouteError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
750
+ export type { GenerationOptionsFields, GenerationOptionsInput, LanguageModelInput, LanguageModelProviderOptions, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, UsageInput, } from "./schema/index.js";
751
+ export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageRequest, ImageResponse } from "./image.js";
752
+ export type { ImageModelOptions, ImageOptions, ImageRequestFor, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
753
+ export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionRequest, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
754
+ export type { AnswerFor, AnswersFor, DecisionInput, DecisionModelOptions, DecisionOptions, DecisionQuestions, DecisionRequestFor, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
755
+ export { Media } from "./media.js";
756
+ export type { AwaitOptions as GenerationAwaitOptions, Event as GenerationEvent, Poll, Route as GenerationRoute, Snapshot as GenerationSnapshot, Status as GenerationStatus, } from "./generation.js";
757
+ export type { ExecutableTool, Tool, ToolExecute, ToolExecuteContext, ToolModelOutputInput, ToolOptions, Tools, ToolSchema, ToolToModelOutput, } from "./tool.js";
758
+ export type { LLM } from "./llm.js";