@opencode/ai 2.1.2 → 2.1.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 (140) hide show
  1. package/dist/cache-policy.js +6 -5
  2. package/dist/experimental/evaluation.d.ts +7 -6
  3. package/dist/experimental/evaluation.js +3 -11
  4. package/dist/experimental/realtime.d.ts +59 -0
  5. package/dist/experimental/realtime.js +21 -13
  6. package/dist/experimental.d.ts +1 -1
  7. package/dist/generation.js +1 -1
  8. package/dist/image-client.d.ts +11 -9
  9. package/dist/image.d.ts +158 -150
  10. package/dist/image.js +2 -2
  11. package/dist/llm.d.ts +2 -4
  12. package/dist/llm.js +2 -2
  13. package/dist/media-model.d.ts +2 -2
  14. package/dist/media-model.js +1 -1
  15. package/dist/promise.d.ts +121 -121
  16. package/dist/promise.js +3 -5
  17. package/dist/protocols/alibaba-chat.d.ts +18 -18
  18. package/dist/protocols/alibaba-chat.js +3 -3
  19. package/dist/protocols/alibaba-messages.d.ts +12 -12
  20. package/dist/protocols/alibaba-messages.js +1 -1
  21. package/dist/protocols/alibaba-responses.d.ts +38 -38
  22. package/dist/protocols/anthropic-messages.d.ts +40 -44
  23. package/dist/protocols/anthropic-messages.js +13 -15
  24. package/dist/protocols/bedrock-converse.d.ts +36 -85
  25. package/dist/protocols/bedrock-converse.js +6 -6
  26. package/dist/protocols/bedrock-event-stream.d.ts +6 -1
  27. package/dist/protocols/bedrock-event-stream.js +9 -8
  28. package/dist/protocols/cartesia-speech.d.ts +32 -32
  29. package/dist/protocols/cohere-chat.d.ts +13 -10
  30. package/dist/protocols/cohere-chat.js +2 -2
  31. package/dist/protocols/deepgram-speech.d.ts +32 -32
  32. package/dist/protocols/elevenlabs-speech.d.ts +32 -32
  33. package/dist/protocols/gemini.d.ts +46 -36
  34. package/dist/protocols/gemini.js +12 -15
  35. package/dist/protocols/google-interactions.d.ts +14 -13
  36. package/dist/protocols/google-interactions.js +16 -11
  37. package/dist/protocols/google-speech.d.ts +32 -32
  38. package/dist/protocols/google-transcription.d.ts +32 -32
  39. package/dist/protocols/meta-messages.d.ts +23 -23
  40. package/dist/protocols/meta-responses.d.ts +84 -84
  41. package/dist/protocols/mistral-chat.d.ts +81 -78
  42. package/dist/protocols/mistral-chat.js +3 -5
  43. package/dist/protocols/open-responses-channel.js +47 -46
  44. package/dist/protocols/open-responses-continuation.d.ts +8 -2
  45. package/dist/protocols/open-responses-continuation.js +3 -1
  46. package/dist/protocols/open-responses.d.ts +419 -419
  47. package/dist/protocols/open-responses.js +11 -10
  48. package/dist/protocols/openai-chat.d.ts +68 -67
  49. package/dist/protocols/openai-chat.js +7 -8
  50. package/dist/protocols/openai-compatible-chat.d.ts +13 -14
  51. package/dist/protocols/openai-compatible-responses.d.ts +39 -40
  52. package/dist/protocols/openai-images.d.ts +32 -32
  53. package/dist/protocols/openai-responses.d.ts +253 -253
  54. package/dist/protocols/openai-responses.js +1 -1
  55. package/dist/protocols/openai-speech.d.ts +32 -32
  56. package/dist/protocols/openai-transcription.d.ts +32 -32
  57. package/dist/protocols/openai-transcription.js +12 -7
  58. package/dist/protocols/utils/open-responses-options.d.ts +8 -8
  59. package/dist/protocols/utils/open-responses-options.js +4 -6
  60. package/dist/protocols/utils/partial-json-options.d.ts +0 -1
  61. package/dist/protocols/utils/partial-json-options.js +0 -1
  62. package/dist/protocols/utils/partial-json.js +5 -4
  63. package/dist/protocols/utils/tool-schema.d.ts +0 -3
  64. package/dist/protocols/utils/tool-schema.js +0 -4
  65. package/dist/protocols/utils/tool-stream.d.ts +1 -1
  66. package/dist/protocols/venice-chat.d.ts +52 -53
  67. package/dist/protocols/venice-chat.js +6 -5
  68. package/dist/protocols/xai-images.js +3 -4
  69. package/dist/protocols/xai-responses.d.ts +81 -81
  70. package/dist/protocols/zai-chat.d.ts +33 -30
  71. package/dist/protocols/zai-chat.js +8 -3
  72. package/dist/protocols/zai-messages.d.ts +21 -19
  73. package/dist/protocols/zai-messages.js +3 -2
  74. package/dist/provider-error.js +8 -7
  75. package/dist/providers/alibaba.d.ts +74 -74
  76. package/dist/providers/amazon-bedrock-mantle.d.ts +202 -202
  77. package/dist/providers/amazon-bedrock.d.ts +16 -13
  78. package/dist/providers/anthropic-compatible.d.ts +13 -13
  79. package/dist/providers/anthropic.d.ts +13 -13
  80. package/dist/providers/azure.d.ts +112 -112
  81. package/dist/providers/baseten.d.ts +24 -24
  82. package/dist/providers/cerebras.d.ts +24 -24
  83. package/dist/providers/cloudflare-ai-gateway.d.ts +237 -234
  84. package/dist/providers/cloudflare-ai-gateway.js +3 -6
  85. package/dist/providers/cloudflare-workers-ai.d.ts +24 -24
  86. package/dist/providers/cohere.d.ts +78 -74
  87. package/dist/providers/deepinfra.d.ts +24 -24
  88. package/dist/providers/deepseek.d.ts +24 -24
  89. package/dist/providers/digitalocean.d.ts +36 -36
  90. package/dist/providers/fireworks.d.ts +24 -24
  91. package/dist/providers/google-vertex-chat.d.ts +12 -12
  92. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  93. package/dist/providers/google-vertex-messages.d.ts +20 -20
  94. package/dist/providers/google-vertex-mistral.d.ts +14 -14
  95. package/dist/providers/google-vertex-responses.d.ts +38 -38
  96. package/dist/providers/google-vertex.d.ts +17 -17
  97. package/dist/providers/google-vertex.js +2 -2
  98. package/dist/providers/google.d.ts +79 -79
  99. package/dist/providers/groq.d.ts +24 -24
  100. package/dist/providers/meta.d.ts +189 -189
  101. package/dist/providers/minimax.d.ts +202 -202
  102. package/dist/providers/mistral.d.ts +28 -28
  103. package/dist/providers/moonshot.d.ts +202 -202
  104. package/dist/providers/open-responses-options.d.ts +0 -1
  105. package/dist/providers/open-responses-options.js +1 -1
  106. package/dist/providers/openai-compatible-responses.d.ts +38 -38
  107. package/dist/providers/openai-compatible.d.ts +12 -12
  108. package/dist/providers/openai-compatible.js +1 -1
  109. package/dist/providers/openai-options.d.ts +3 -4
  110. package/dist/providers/openai-options.js +0 -1
  111. package/dist/providers/openai.d.ts +103 -103
  112. package/dist/providers/openrouter.d.ts +171 -112
  113. package/dist/providers/openrouter.js +40 -33
  114. package/dist/providers/togetherai.d.ts +24 -24
  115. package/dist/providers/venice.d.ts +195 -20
  116. package/dist/providers/xai.d.ts +12 -12
  117. package/dist/providers/zai-coding-plan.d.ts +152 -72
  118. package/dist/providers/zai.d.ts +84 -19
  119. package/dist/route/auth-options.d.ts +0 -3
  120. package/dist/route/auth.d.ts +0 -2
  121. package/dist/route/auth.js +0 -2
  122. package/dist/route/client.d.ts +0 -218
  123. package/dist/route/client.js +3 -7
  124. package/dist/route/executor-service.js +1 -1
  125. package/dist/route/transport/http.js +5 -8
  126. package/dist/schema/errors.d.ts +1 -1
  127. package/dist/schema/errors.js +1 -1
  128. package/dist/schema/messages.js +4 -7
  129. package/dist/speech-client.d.ts +11 -9
  130. package/dist/speech.d.ts +158 -150
  131. package/dist/speech.js +2 -2
  132. package/dist/transcription-client.d.ts +11 -9
  133. package/dist/transcription.d.ts +158 -150
  134. package/dist/transcription.js +2 -2
  135. package/dist/video-client.d.ts +11 -9
  136. package/dist/video.d.ts +124 -116
  137. package/dist/video.js +2 -2
  138. package/package.json +7 -6
  139. package/dist/protocols/utils/openai-options.d.ts +0 -16
  140. package/dist/protocols/utils/openai-options.js +0 -15
package/dist/promise.d.ts CHANGED
@@ -5,7 +5,7 @@ import { type ImageModel, type ImageRequest, type ImageRequestInput } from "./im
5
5
  import { LLM } from "./index.js";
6
6
  import { Media } from "./media.js";
7
7
  import { RequestExecutor } from "./route/executor.js";
8
- import { LanguageModel, LLMRequest } from "./schema/index.js";
8
+ import { LanguageModel, type LLMRequest } from "./schema/index.js";
9
9
  import type { RequestInput } from "./llm.js";
10
10
  import { type SpeechModel, type SpeechRequest, type SpeechRequestInput } from "./speech.js";
11
11
  import { type TranscriptionModel, type TranscriptionRequest, type TranscriptionRequestInput } from "./transcription.js";
@@ -273,14 +273,6 @@ export declare const make: (options?: Options) => {
273
273
  request: typeof import("./image.js").request;
274
274
  generate: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => Promise<import("./image.js").ImageResponse>;
275
275
  stream: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
276
- readonly type: "generation-queued";
277
- readonly id: string;
278
- readonly position?: number | undefined;
279
- } | {
280
- readonly type: "generation-progress";
281
- readonly id: string;
282
- readonly progress?: number | undefined;
283
- } | {
284
276
  readonly type: "image-partial";
285
277
  readonly index: number;
286
278
  readonly image: Media.Asset;
@@ -288,17 +280,17 @@ export declare const make: (options?: Options) => {
288
280
  readonly type: "image";
289
281
  readonly index: number;
290
282
  readonly image: Media.Asset;
283
+ } | {
284
+ readonly type: "generation-queued";
285
+ readonly id: string;
286
+ readonly position?: number | undefined;
287
+ } | {
288
+ readonly type: "generation-progress";
289
+ readonly id: string;
290
+ readonly progress?: number | undefined;
291
291
  } | {
292
292
  readonly type: "finish";
293
293
  readonly usage?: {
294
- readonly type: "tokens";
295
- readonly input?: number | undefined;
296
- readonly output?: number | undefined;
297
- readonly total?: number | undefined;
298
- readonly details?: {
299
- readonly [x: string]: unknown;
300
- } | undefined;
301
- } | {
302
294
  readonly type: "seconds";
303
295
  readonly seconds: number;
304
296
  } | {
@@ -310,6 +302,14 @@ export declare const make: (options?: Options) => {
310
302
  } | {
311
303
  readonly type: "compute";
312
304
  readonly seconds: number;
305
+ } | {
306
+ readonly type: "tokens";
307
+ readonly input?: number | undefined;
308
+ readonly output?: number | undefined;
309
+ readonly total?: number | undefined;
310
+ readonly details?: {
311
+ readonly [x: string]: unknown;
312
+ } | undefined;
313
313
  } | undefined;
314
314
  readonly notices?: readonly {
315
315
  readonly type: "filtered" | "moderated" | "other";
@@ -335,6 +335,10 @@ export declare const make: (options?: Options) => {
335
335
  generate: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
336
336
  resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
337
337
  stream: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
338
+ readonly type: "video";
339
+ readonly index: number;
340
+ readonly video: Media.Asset;
341
+ } | {
338
342
  readonly type: "generation-queued";
339
343
  readonly id: string;
340
344
  readonly position?: number | undefined;
@@ -342,21 +346,9 @@ export declare const make: (options?: Options) => {
342
346
  readonly type: "generation-progress";
343
347
  readonly id: string;
344
348
  readonly progress?: number | undefined;
345
- } | {
346
- readonly type: "video";
347
- readonly index: number;
348
- readonly video: Media.Asset;
349
349
  } | {
350
350
  readonly type: "finish";
351
351
  readonly usage?: {
352
- readonly type: "tokens";
353
- readonly input?: number | undefined;
354
- readonly output?: number | undefined;
355
- readonly total?: number | undefined;
356
- readonly details?: {
357
- readonly [x: string]: unknown;
358
- } | undefined;
359
- } | {
360
352
  readonly type: "seconds";
361
353
  readonly seconds: number;
362
354
  } | {
@@ -368,6 +360,14 @@ export declare const make: (options?: Options) => {
368
360
  } | {
369
361
  readonly type: "compute";
370
362
  readonly seconds: number;
363
+ } | {
364
+ readonly type: "tokens";
365
+ readonly input?: number | undefined;
366
+ readonly output?: number | undefined;
367
+ readonly total?: number | undefined;
368
+ readonly details?: {
369
+ readonly [x: string]: unknown;
370
+ } | undefined;
371
371
  } | undefined;
372
372
  readonly notices?: readonly {
373
373
  readonly type: "filtered" | "moderated" | "other";
@@ -389,14 +389,6 @@ export declare const make: (options?: Options) => {
389
389
  request: typeof import("./speech.js").request;
390
390
  generate: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
391
391
  stream: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => AsyncIterable<{
392
- readonly type: "generation-queued";
393
- readonly id: string;
394
- readonly position?: number | undefined;
395
- } | {
396
- readonly type: "generation-progress";
397
- readonly id: string;
398
- readonly progress?: number | undefined;
399
- } | {
400
392
  readonly type: "audio-delta";
401
393
  readonly chunk: Uint8Array<ArrayBufferLike>;
402
394
  } | {
@@ -406,18 +398,18 @@ export declare const make: (options?: Options) => {
406
398
  readonly startSeconds: number;
407
399
  readonly endSeconds: number;
408
400
  }[];
401
+ } | {
402
+ readonly type: "generation-queued";
403
+ readonly id: string;
404
+ readonly position?: number | undefined;
405
+ } | {
406
+ readonly type: "generation-progress";
407
+ readonly id: string;
408
+ readonly progress?: number | undefined;
409
409
  } | {
410
410
  readonly type: "finish";
411
411
  readonly audio: Media.Asset;
412
412
  readonly usage?: {
413
- readonly type: "tokens";
414
- readonly input?: number | undefined;
415
- readonly output?: number | undefined;
416
- readonly total?: number | undefined;
417
- readonly details?: {
418
- readonly [x: string]: unknown;
419
- } | undefined;
420
- } | {
421
413
  readonly type: "seconds";
422
414
  readonly seconds: number;
423
415
  } | {
@@ -429,6 +421,14 @@ export declare const make: (options?: Options) => {
429
421
  } | {
430
422
  readonly type: "compute";
431
423
  readonly seconds: number;
424
+ } | {
425
+ readonly type: "tokens";
426
+ readonly input?: number | undefined;
427
+ readonly output?: number | undefined;
428
+ readonly total?: number | undefined;
429
+ readonly details?: {
430
+ readonly [x: string]: unknown;
431
+ } | undefined;
432
432
  } | undefined;
433
433
  readonly notices?: readonly {
434
434
  readonly type: "filtered" | "moderated" | "other";
@@ -450,14 +450,6 @@ export declare const make: (options?: Options) => {
450
450
  request: typeof import("./transcription.js").request;
451
451
  generate: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
452
452
  stream: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
453
- readonly type: "generation-queued";
454
- readonly id: string;
455
- readonly position?: number | undefined;
456
- } | {
457
- readonly type: "generation-progress";
458
- readonly id: string;
459
- readonly progress?: number | undefined;
460
- } | {
461
453
  readonly type: "text-delta";
462
454
  readonly delta: string;
463
455
  } | {
@@ -468,6 +460,14 @@ export declare const make: (options?: Options) => {
468
460
  readonly endSeconds: number;
469
461
  readonly speaker?: string | undefined;
470
462
  };
463
+ } | {
464
+ readonly type: "generation-queued";
465
+ readonly id: string;
466
+ readonly position?: number | undefined;
467
+ } | {
468
+ readonly type: "generation-progress";
469
+ readonly id: string;
470
+ readonly progress?: number | undefined;
471
471
  } | {
472
472
  readonly text: string;
473
473
  readonly segments?: readonly {
@@ -486,14 +486,6 @@ export declare const make: (options?: Options) => {
486
486
  readonly language?: string | undefined;
487
487
  readonly durationSeconds?: number | undefined;
488
488
  readonly usage?: {
489
- readonly type: "tokens";
490
- readonly input?: number | undefined;
491
- readonly output?: number | undefined;
492
- readonly total?: number | undefined;
493
- readonly details?: {
494
- readonly [x: string]: unknown;
495
- } | undefined;
496
- } | {
497
489
  readonly type: "seconds";
498
490
  readonly seconds: number;
499
491
  } | {
@@ -505,6 +497,14 @@ export declare const make: (options?: Options) => {
505
497
  } | {
506
498
  readonly type: "compute";
507
499
  readonly seconds: number;
500
+ } | {
501
+ readonly type: "tokens";
502
+ readonly input?: number | undefined;
503
+ readonly output?: number | undefined;
504
+ readonly total?: number | undefined;
505
+ readonly details?: {
506
+ readonly [x: string]: unknown;
507
+ } | undefined;
508
508
  } | undefined;
509
509
  readonly notices?: readonly {
510
510
  readonly type: "filtered" | "moderated" | "other";
@@ -764,14 +764,6 @@ export declare const ai: {
764
764
  request: typeof import("./image.js").request;
765
765
  generate: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => Promise<import("./image.js").ImageResponse>;
766
766
  stream: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
767
- readonly type: "generation-queued";
768
- readonly id: string;
769
- readonly position?: number | undefined;
770
- } | {
771
- readonly type: "generation-progress";
772
- readonly id: string;
773
- readonly progress?: number | undefined;
774
- } | {
775
767
  readonly type: "image-partial";
776
768
  readonly index: number;
777
769
  readonly image: Media.Asset;
@@ -779,17 +771,17 @@ export declare const ai: {
779
771
  readonly type: "image";
780
772
  readonly index: number;
781
773
  readonly image: Media.Asset;
774
+ } | {
775
+ readonly type: "generation-queued";
776
+ readonly id: string;
777
+ readonly position?: number | undefined;
778
+ } | {
779
+ readonly type: "generation-progress";
780
+ readonly id: string;
781
+ readonly progress?: number | undefined;
782
782
  } | {
783
783
  readonly type: "finish";
784
784
  readonly usage?: {
785
- readonly type: "tokens";
786
- readonly input?: number | undefined;
787
- readonly output?: number | undefined;
788
- readonly total?: number | undefined;
789
- readonly details?: {
790
- readonly [x: string]: unknown;
791
- } | undefined;
792
- } | {
793
785
  readonly type: "seconds";
794
786
  readonly seconds: number;
795
787
  } | {
@@ -801,6 +793,14 @@ export declare const ai: {
801
793
  } | {
802
794
  readonly type: "compute";
803
795
  readonly seconds: number;
796
+ } | {
797
+ readonly type: "tokens";
798
+ readonly input?: number | undefined;
799
+ readonly output?: number | undefined;
800
+ readonly total?: number | undefined;
801
+ readonly details?: {
802
+ readonly [x: string]: unknown;
803
+ } | undefined;
804
804
  } | undefined;
805
805
  readonly notices?: readonly {
806
806
  readonly type: "filtered" | "moderated" | "other";
@@ -826,6 +826,10 @@ export declare const ai: {
826
826
  generate: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
827
827
  resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
828
828
  stream: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
829
+ readonly type: "video";
830
+ readonly index: number;
831
+ readonly video: Media.Asset;
832
+ } | {
829
833
  readonly type: "generation-queued";
830
834
  readonly id: string;
831
835
  readonly position?: number | undefined;
@@ -833,21 +837,9 @@ export declare const ai: {
833
837
  readonly type: "generation-progress";
834
838
  readonly id: string;
835
839
  readonly progress?: number | undefined;
836
- } | {
837
- readonly type: "video";
838
- readonly index: number;
839
- readonly video: Media.Asset;
840
840
  } | {
841
841
  readonly type: "finish";
842
842
  readonly usage?: {
843
- readonly type: "tokens";
844
- readonly input?: number | undefined;
845
- readonly output?: number | undefined;
846
- readonly total?: number | undefined;
847
- readonly details?: {
848
- readonly [x: string]: unknown;
849
- } | undefined;
850
- } | {
851
843
  readonly type: "seconds";
852
844
  readonly seconds: number;
853
845
  } | {
@@ -859,6 +851,14 @@ export declare const ai: {
859
851
  } | {
860
852
  readonly type: "compute";
861
853
  readonly seconds: number;
854
+ } | {
855
+ readonly type: "tokens";
856
+ readonly input?: number | undefined;
857
+ readonly output?: number | undefined;
858
+ readonly total?: number | undefined;
859
+ readonly details?: {
860
+ readonly [x: string]: unknown;
861
+ } | undefined;
862
862
  } | undefined;
863
863
  readonly notices?: readonly {
864
864
  readonly type: "filtered" | "moderated" | "other";
@@ -880,14 +880,6 @@ export declare const ai: {
880
880
  request: typeof import("./speech.js").request;
881
881
  generate: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
882
882
  stream: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => AsyncIterable<{
883
- readonly type: "generation-queued";
884
- readonly id: string;
885
- readonly position?: number | undefined;
886
- } | {
887
- readonly type: "generation-progress";
888
- readonly id: string;
889
- readonly progress?: number | undefined;
890
- } | {
891
883
  readonly type: "audio-delta";
892
884
  readonly chunk: Uint8Array<ArrayBufferLike>;
893
885
  } | {
@@ -897,18 +889,18 @@ export declare const ai: {
897
889
  readonly startSeconds: number;
898
890
  readonly endSeconds: number;
899
891
  }[];
892
+ } | {
893
+ readonly type: "generation-queued";
894
+ readonly id: string;
895
+ readonly position?: number | undefined;
896
+ } | {
897
+ readonly type: "generation-progress";
898
+ readonly id: string;
899
+ readonly progress?: number | undefined;
900
900
  } | {
901
901
  readonly type: "finish";
902
902
  readonly audio: Media.Asset;
903
903
  readonly usage?: {
904
- readonly type: "tokens";
905
- readonly input?: number | undefined;
906
- readonly output?: number | undefined;
907
- readonly total?: number | undefined;
908
- readonly details?: {
909
- readonly [x: string]: unknown;
910
- } | undefined;
911
- } | {
912
904
  readonly type: "seconds";
913
905
  readonly seconds: number;
914
906
  } | {
@@ -920,6 +912,14 @@ export declare const ai: {
920
912
  } | {
921
913
  readonly type: "compute";
922
914
  readonly seconds: number;
915
+ } | {
916
+ readonly type: "tokens";
917
+ readonly input?: number | undefined;
918
+ readonly output?: number | undefined;
919
+ readonly total?: number | undefined;
920
+ readonly details?: {
921
+ readonly [x: string]: unknown;
922
+ } | undefined;
923
923
  } | undefined;
924
924
  readonly notices?: readonly {
925
925
  readonly type: "filtered" | "moderated" | "other";
@@ -941,14 +941,6 @@ export declare const ai: {
941
941
  request: typeof import("./transcription.js").request;
942
942
  generate: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
943
943
  stream: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
944
- readonly type: "generation-queued";
945
- readonly id: string;
946
- readonly position?: number | undefined;
947
- } | {
948
- readonly type: "generation-progress";
949
- readonly id: string;
950
- readonly progress?: number | undefined;
951
- } | {
952
944
  readonly type: "text-delta";
953
945
  readonly delta: string;
954
946
  } | {
@@ -959,6 +951,14 @@ export declare const ai: {
959
951
  readonly endSeconds: number;
960
952
  readonly speaker?: string | undefined;
961
953
  };
954
+ } | {
955
+ readonly type: "generation-queued";
956
+ readonly id: string;
957
+ readonly position?: number | undefined;
958
+ } | {
959
+ readonly type: "generation-progress";
960
+ readonly id: string;
961
+ readonly progress?: number | undefined;
962
962
  } | {
963
963
  readonly text: string;
964
964
  readonly segments?: readonly {
@@ -977,14 +977,6 @@ export declare const ai: {
977
977
  readonly language?: string | undefined;
978
978
  readonly durationSeconds?: number | undefined;
979
979
  readonly usage?: {
980
- readonly type: "tokens";
981
- readonly input?: number | undefined;
982
- readonly output?: number | undefined;
983
- readonly total?: number | undefined;
984
- readonly details?: {
985
- readonly [x: string]: unknown;
986
- } | undefined;
987
- } | {
988
980
  readonly type: "seconds";
989
981
  readonly seconds: number;
990
982
  } | {
@@ -996,6 +988,14 @@ export declare const ai: {
996
988
  } | {
997
989
  readonly type: "compute";
998
990
  readonly seconds: number;
991
+ } | {
992
+ readonly type: "tokens";
993
+ readonly input?: number | undefined;
994
+ readonly output?: number | undefined;
995
+ readonly total?: number | undefined;
996
+ readonly details?: {
997
+ readonly [x: string]: unknown;
998
+ } | undefined;
999
999
  } | undefined;
1000
1000
  readonly notices?: readonly {
1001
1001
  readonly type: "filtered" | "moderated" | "other";
package/dist/promise.js CHANGED
@@ -3,9 +3,8 @@ import { AIClient } from "./ai-client.js";
3
3
  import { Image } from "./image.js";
4
4
  import { LLM } from "./index.js";
5
5
  import { Media } from "./media.js";
6
- import { tryRequest } from "./media-model.js";
7
6
  import { RequestExecutor } from "./route/executor.js";
8
- import { AIError, InvalidRequestError, LanguageModel, LLMRequest } from "./schema/index.js";
7
+ import { AIError, InvalidRequestError, LanguageModel } from "./schema/index.js";
9
8
  import { Speech } from "./speech.js";
10
9
  import { Transcription, } from "./transcription.js";
11
10
  import { fileMediaType } from "./utils/media-type.js";
@@ -36,7 +35,6 @@ export const make = (options = {}) => {
36
35
  refresh: (options) => run(generation.refresh(), options).then(handle),
37
36
  cancel: (options) => run(generation.cancel(), options),
38
37
  });
39
- const llmRequest = (input) => input instanceof LLMRequest ? Effect.succeed(input) : tryRequest(() => LLM.request(input));
40
38
  return {
41
39
  run,
42
40
  /** Decoded asset bytes, downloading `url` sources through the executor. */
@@ -65,8 +63,8 @@ export const make = (options = {}) => {
65
63
  },
66
64
  llm: {
67
65
  request: LLM.request,
68
- generate: (input, options) => run(Effect.flatMap(llmRequest(input), LLM.generate), options),
69
- stream: (input, options) => iterate(Stream.unwrap(Effect.map(llmRequest(input), LLM.stream)), options),
66
+ generate: (input, options) => run(LLM.generate(input), options),
67
+ stream: (input, options) => iterate(LLM.stream(input), options),
70
68
  },
71
69
  image: {
72
70
  request: Image.request,
@@ -10,19 +10,19 @@ declare const Options: Schema.Struct<{
10
10
  readonly preserveThinking: Schema.optional<Schema.Boolean>;
11
11
  readonly clearThinking: Schema.optional<Schema.Boolean>;
12
12
  readonly thinking: Schema.optional<Schema.Struct<{
13
- readonly type: Schema.declare<"adaptive" | "disabled" | (string & {}), "adaptive" | "disabled" | (string & {})>;
13
+ readonly type: Schema.declare<import("../schema/options.js").OpenString<"adaptive" | "disabled">, import("../schema/options.js").OpenString<"adaptive" | "disabled">>;
14
14
  }>>;
15
15
  readonly toolStream: Schema.optional<Schema.Boolean>;
16
16
  readonly parallelToolCalls: Schema.optional<Schema.Boolean>;
17
17
  readonly repetitionPenalty: Schema.optional<Schema.Number>;
18
18
  readonly responseFormat: Schema.optional<Schema.Struct<{
19
- readonly type: Schema.declare<"json_object" | "json_schema" | "text" | (string & {}), "json_object" | "json_schema" | "text" | (string & {})>;
19
+ readonly type: Schema.declare<import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">, import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">>;
20
20
  readonly json_schema: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
21
21
  }>>;
22
22
  readonly enableSearch: Schema.optional<Schema.Boolean>;
23
23
  readonly searchOptions: Schema.optional<Schema.Struct<{
24
24
  readonly forced_search: Schema.optional<Schema.Boolean>;
25
- readonly search_strategy: Schema.optional<Schema.declare<"agent" | "agent_max" | "max" | "turbo" | (string & {}), "agent" | "agent_max" | "max" | "turbo" | (string & {})>>;
25
+ readonly search_strategy: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo">, import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo">>>;
26
26
  readonly enable_search_extension: Schema.optional<Schema.Boolean>;
27
27
  }>>;
28
28
  }>;
@@ -38,13 +38,6 @@ export declare const protocol: Protocol<{
38
38
  readonly messages: readonly ({
39
39
  readonly role: "system";
40
40
  readonly content: string | readonly ({
41
- readonly type: "text";
42
- readonly text: string;
43
- readonly cache_control?: {
44
- readonly type: "ephemeral";
45
- readonly ttl?: string | undefined;
46
- } | undefined;
47
- } | {
48
41
  readonly type: "image_url";
49
42
  readonly image_url: {
50
43
  readonly url: string;
@@ -55,17 +48,17 @@ export declare const protocol: Protocol<{
55
48
  readonly filename: string;
56
49
  readonly file_data: string;
57
50
  };
58
- })[];
59
- } | {
60
- readonly role: "user";
61
- readonly content: string | readonly ({
51
+ } | {
62
52
  readonly type: "text";
63
53
  readonly text: string;
64
54
  readonly cache_control?: {
65
55
  readonly type: "ephemeral";
66
56
  readonly ttl?: string | undefined;
67
57
  } | undefined;
68
- } | {
58
+ })[];
59
+ } | {
60
+ readonly role: "user";
61
+ readonly content: string | readonly ({
69
62
  readonly type: "image_url";
70
63
  readonly image_url: {
71
64
  readonly url: string;
@@ -76,6 +69,13 @@ export declare const protocol: Protocol<{
76
69
  readonly filename: string;
77
70
  readonly file_data: string;
78
71
  };
72
+ } | {
73
+ readonly type: "text";
74
+ readonly text: string;
75
+ readonly cache_control?: {
76
+ readonly type: "ephemeral";
77
+ readonly ttl?: string | undefined;
78
+ } | undefined;
79
79
  })[];
80
80
  } | {
81
81
  readonly role: "tool";
@@ -159,13 +159,13 @@ export declare const protocol: Protocol<{
159
159
  readonly preserve_thinking?: boolean | undefined;
160
160
  readonly clear_thinking?: boolean | undefined;
161
161
  readonly thinking?: {
162
- readonly type: "adaptive" | "disabled" | (string & {});
162
+ readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
163
163
  } | undefined;
164
164
  readonly parallel_tool_calls?: boolean | undefined;
165
165
  readonly repetition_penalty?: number | undefined;
166
166
  readonly top_k?: number | undefined;
167
167
  readonly response_format?: {
168
- readonly type: "json_object" | "json_schema" | "text" | (string & {});
168
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
169
169
  readonly json_schema?: {
170
170
  readonly [x: string]: unknown;
171
171
  } | undefined;
@@ -173,7 +173,7 @@ export declare const protocol: Protocol<{
173
173
  readonly enable_search?: boolean | undefined;
174
174
  readonly search_options?: {
175
175
  readonly forced_search?: boolean | undefined;
176
- readonly search_strategy?: "agent" | "agent_max" | "max" | "turbo" | (string & {}) | undefined;
176
+ readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
177
177
  readonly enable_search_extension?: boolean | undefined;
178
178
  } | undefined;
179
179
  }, string, "[DONE]" | {
@@ -11,19 +11,19 @@ const Options = Schema.Struct({
11
11
  preserveThinking: Schema.optional(Schema.Boolean),
12
12
  clearThinking: Schema.optional(Schema.Boolean),
13
13
  thinking: Schema.optional(Schema.Struct({
14
- type: Schema.declare(Schema.is(Schema.String)),
14
+ type: ProviderShared.knownString(),
15
15
  })),
16
16
  toolStream: Schema.optional(Schema.Boolean),
17
17
  parallelToolCalls: Schema.optional(Schema.Boolean),
18
18
  repetitionPenalty: Schema.optional(Schema.Number),
19
19
  responseFormat: Schema.optional(Schema.Struct({
20
- type: Schema.declare(Schema.is(Schema.String)),
20
+ type: ProviderShared.knownString(),
21
21
  json_schema: Schema.optional(JsonObject),
22
22
  })),
23
23
  enableSearch: Schema.optional(Schema.Boolean),
24
24
  searchOptions: Schema.optional(Schema.Struct({
25
25
  forced_search: Schema.optional(Schema.Boolean),
26
- search_strategy: Schema.optional(Schema.declare(Schema.is(Schema.String))),
26
+ search_strategy: Schema.optional(ProviderShared.knownString()),
27
27
  enable_search_extension: Schema.optional(Schema.Boolean),
28
28
  })),
29
29
  });
@@ -5,7 +5,7 @@ import { OpenResponsesOptions } from "./utils/open-responses-options.js";
5
5
  declare const Options: Schema.Struct<{
6
6
  readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
7
7
  readonly thinking: Schema.optional<Schema.Struct<{
8
- readonly type: Schema.declare<"disabled" | "enabled" | (string & {}), "disabled" | "enabled" | (string & {})>;
8
+ readonly type: Schema.declare<import("../schema/options.js").OpenString<"disabled" | "enabled">, import("../schema/options.js").OpenString<"disabled" | "enabled">>;
9
9
  readonly budgetTokens: Schema.optional<Schema.Int>;
10
10
  readonly budget_tokens: Schema.optional<Schema.Int>;
11
11
  }>>;
@@ -153,23 +153,15 @@ export declare const protocol: Protocol<{
153
153
  } | {
154
154
  readonly role: "assistant";
155
155
  readonly content: readonly ({
156
+ readonly type: "compaction";
157
+ readonly content: string | null;
158
+ } | {
156
159
  readonly type: "text";
157
160
  readonly text: string;
158
161
  readonly cache_control?: {
159
162
  readonly type: "ephemeral";
160
163
  readonly ttl?: "1h" | "5m" | undefined;
161
164
  } | undefined;
162
- } | {
163
- readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
164
- readonly tool_use_id: string;
165
- readonly content: unknown;
166
- readonly cache_control?: {
167
- readonly type: "ephemeral";
168
- readonly ttl?: "1h" | "5m" | undefined;
169
- } | undefined;
170
- } | {
171
- readonly type: "compaction";
172
- readonly content: string | null;
173
165
  } | {
174
166
  readonly type: "thinking";
175
167
  readonly thinking: string;
@@ -203,6 +195,14 @@ export declare const protocol: Protocol<{
203
195
  readonly type: "ephemeral";
204
196
  readonly ttl?: "1h" | "5m" | undefined;
205
197
  } | undefined;
198
+ } | {
199
+ readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
200
+ readonly tool_use_id: string;
201
+ readonly content: unknown;
202
+ readonly cache_control?: {
203
+ readonly type: "ephemeral";
204
+ readonly ttl?: "1h" | "5m" | undefined;
205
+ } | undefined;
206
206
  })[];
207
207
  } | {
208
208
  readonly role: "system";
@@ -7,7 +7,7 @@ import { OpenResponsesOptions } from "./utils/open-responses-options.js";
7
7
  const Options = Schema.Struct({
8
8
  effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
9
9
  thinking: Schema.optional(Schema.Struct({
10
- type: Schema.declare(Schema.is(Schema.String)),
10
+ type: ProviderShared.knownString(),
11
11
  budgetTokens: Schema.optional(Schema.Int),
12
12
  budget_tokens: Schema.optional(Schema.Int),
13
13
  })),