@opencode/ai 2.0.32 → 2.1.0

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 (149) hide show
  1. package/dist/ai-client.d.ts +2 -2
  2. package/dist/experimental/evaluation-client.d.ts +1 -1
  3. package/dist/experimental/evaluation.d.ts +20 -20
  4. package/dist/experimental/realtime.d.ts +6 -14
  5. package/dist/experimental/realtime.js +28 -3
  6. package/dist/experimental/system-one.d.ts +1 -1
  7. package/dist/image-client.d.ts +8 -8
  8. package/dist/image.d.ts +593 -437
  9. package/dist/llm.d.ts +51 -51
  10. package/dist/media-client.d.ts +1 -1
  11. package/dist/media.d.ts +4 -4
  12. package/dist/promise.d.ts +199 -198
  13. package/dist/protocols/alibaba-chat.d.ts +81 -82
  14. package/dist/protocols/alibaba-chat.js +0 -1
  15. package/dist/protocols/alibaba-messages.d.ts +99 -99
  16. package/dist/protocols/alibaba-responses.d.ts +120 -120
  17. package/dist/protocols/anthropic-messages.d.ts +187 -187
  18. package/dist/protocols/anthropic-messages.js +3 -2
  19. package/dist/protocols/assemblyai-transcription.d.ts +1 -1
  20. package/dist/protocols/bedrock-converse.d.ts +75 -79
  21. package/dist/protocols/bfl-images.d.ts +1 -1
  22. package/dist/protocols/cartesia-speech.d.ts +17 -17
  23. package/dist/protocols/cohere-chat.d.ts +26 -23
  24. package/dist/protocols/cohere-chat.js +22 -1
  25. package/dist/protocols/deepgram-speech.d.ts +17 -17
  26. package/dist/protocols/deepgram-transcription.d.ts +1 -1
  27. package/dist/protocols/elevenlabs-speech.d.ts +17 -17
  28. package/dist/protocols/elevenlabs-transcription.d.ts +1 -1
  29. package/dist/protocols/fal-images.d.ts +1 -1
  30. package/dist/protocols/fal-video.d.ts +1 -1
  31. package/dist/protocols/gemini.d.ts +55 -55
  32. package/dist/protocols/google-images.d.ts +1 -1
  33. package/dist/protocols/google-interactions.d.ts +64 -62
  34. package/dist/protocols/google-interactions.js +19 -1
  35. package/dist/protocols/google-speech.d.ts +17 -17
  36. package/dist/protocols/google-transcription.d.ts +47 -47
  37. package/dist/protocols/google-video.d.ts +1 -1
  38. package/dist/protocols/meta-messages.d.ts +121 -121
  39. package/dist/protocols/meta-responses.d.ts +201 -201
  40. package/dist/protocols/mistral-chat.d.ts +45 -45
  41. package/dist/protocols/open-responses-channel.d.ts +1 -1
  42. package/dist/protocols/open-responses.d.ts +584 -450
  43. package/dist/protocols/open-responses.js +27 -35
  44. package/dist/protocols/openai-chat.d.ts +248 -248
  45. package/dist/protocols/openai-chat.js +11 -42
  46. package/dist/protocols/openai-compatible-chat.d.ts +32 -32
  47. package/dist/protocols/openai-compatible-responses.d.ts +88 -88
  48. package/dist/protocols/openai-images.d.ts +17 -17
  49. package/dist/protocols/openai-responses.d.ts +567 -567
  50. package/dist/protocols/openai-responses.js +1 -1
  51. package/dist/protocols/openai-speech.d.ts +17 -17
  52. package/dist/protocols/openai-transcription.d.ts +47 -47
  53. package/dist/protocols/replicate-images.d.ts +1 -1
  54. package/dist/protocols/runway-video.d.ts +1 -1
  55. package/dist/protocols/shared.d.ts +12 -1
  56. package/dist/protocols/shared.js +17 -1
  57. package/dist/protocols/stability-images.d.ts +2 -2
  58. package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
  59. package/dist/protocols/utils/bedrock-media.d.ts +4 -4
  60. package/dist/protocols/utils/openai-options.d.ts +1 -1
  61. package/dist/protocols/utils/speech-stream.d.ts +1 -1
  62. package/dist/protocols/utils/tool-schema.d.ts +10 -5
  63. package/dist/protocols/utils/tool-stream.d.ts +152 -152
  64. package/dist/protocols/venice-chat.d.ts +109 -110
  65. package/dist/protocols/venice-chat.js +0 -1
  66. package/dist/protocols/xai-images.d.ts +1 -1
  67. package/dist/protocols/xai-responses.d.ts +79 -79
  68. package/dist/protocols/xai-video.d.ts +1 -1
  69. package/dist/protocols/zai-chat.d.ts +77 -78
  70. package/dist/protocols/zai-chat.js +0 -1
  71. package/dist/protocols/zai-images.d.ts +1 -1
  72. package/dist/protocols/zai-messages.d.ts +97 -97
  73. package/dist/providers/alibaba.d.ts +222 -283
  74. package/dist/providers/amazon-bedrock-mantle.d.ts +291 -298
  75. package/dist/providers/amazon-bedrock.d.ts +22 -28
  76. package/dist/providers/anthropic-compatible.d.ts +86 -90
  77. package/dist/providers/anthropic.d.ts +86 -90
  78. package/dist/providers/assemblyai.d.ts +2 -6
  79. package/dist/providers/azure.d.ts +228 -238
  80. package/dist/providers/baseten.d.ts +66 -70
  81. package/dist/providers/black-forest-labs.d.ts +2 -6
  82. package/dist/providers/cartesia.d.ts +2 -6
  83. package/dist/providers/cerebras.d.ts +66 -70
  84. package/dist/providers/cerebras.js +0 -1
  85. package/dist/providers/cloudflare-ai-gateway.d.ts +352 -356
  86. package/dist/providers/cloudflare-workers-ai.d.ts +66 -70
  87. package/dist/providers/cohere.d.ts +122 -132
  88. package/dist/providers/cohere.js +0 -2
  89. package/dist/providers/deepgram.d.ts +2 -7
  90. package/dist/providers/deepinfra.d.ts +66 -70
  91. package/dist/providers/deepinfra.js +0 -1
  92. package/dist/providers/deepseek.d.ts +66 -70
  93. package/dist/providers/deepseek.js +1 -1
  94. package/dist/providers/digitalocean.d.ts +137 -141
  95. package/dist/providers/elevenlabs.d.ts +2 -7
  96. package/dist/providers/fal.d.ts +2 -7
  97. package/dist/providers/fireworks.d.ts +66 -70
  98. package/dist/providers/google-vertex-chat.d.ts +34 -38
  99. package/dist/providers/google-vertex-interactions.d.ts +31 -41
  100. package/dist/providers/google-vertex-messages.d.ts +81 -85
  101. package/dist/providers/google-vertex-mistral.d.ts +23 -27
  102. package/dist/providers/google-vertex-responses.d.ts +90 -94
  103. package/dist/providers/google-vertex.d.ts +26 -30
  104. package/dist/providers/google.d.ts +94 -109
  105. package/dist/providers/groq.d.ts +111 -115
  106. package/dist/providers/groq.js +0 -1
  107. package/dist/providers/meta.d.ts +309 -317
  108. package/dist/providers/meta.js +1 -1
  109. package/dist/providers/minimax.d.ts +296 -303
  110. package/dist/providers/minimax.js +1 -1
  111. package/dist/providers/mistral.d.ts +22 -26
  112. package/dist/providers/moonshot.d.ts +296 -303
  113. package/dist/providers/moonshot.js +0 -1
  114. package/dist/providers/openai-compatible-responses.d.ts +90 -94
  115. package/dist/providers/openai-compatible.d.ts +34 -38
  116. package/dist/providers/openai.d.ts +93 -108
  117. package/dist/providers/opencode.d.ts +2 -8
  118. package/dist/providers/openrouter.d.ts +137 -144
  119. package/dist/providers/replicate.d.ts +2 -6
  120. package/dist/providers/runway.d.ts +2 -6
  121. package/dist/providers/stability.d.ts +2 -7
  122. package/dist/providers/togetherai.d.ts +66 -70
  123. package/dist/providers/togetherai.js +1 -1
  124. package/dist/providers/typesafe-ai.d.ts +2 -8
  125. package/dist/providers/venice.d.ts +58 -63
  126. package/dist/providers/vercel-ai-gateway.d.ts +2 -12
  127. package/dist/providers/xai.d.ts +38 -50
  128. package/dist/providers/zai-coding-plan.d.ts +206 -213
  129. package/dist/providers/zai.d.ts +40 -46
  130. package/dist/route/client.d.ts +51 -51
  131. package/dist/route/media-protocol.d.ts +1 -1
  132. package/dist/route/transport/http.d.ts +1 -1
  133. package/dist/route/transport/websocket.d.ts +8 -8
  134. package/dist/schema/errors.d.ts +19 -19
  135. package/dist/schema/events.d.ts +3090 -3288
  136. package/dist/schema/messages.d.ts +8 -7
  137. package/dist/schema/options.d.ts +2 -1
  138. package/dist/schema/options.js +2 -1
  139. package/dist/speech-client.d.ts +8 -8
  140. package/dist/speech.d.ts +434 -398
  141. package/dist/testing.d.ts +338 -338
  142. package/dist/tool-runtime.d.ts +1 -1
  143. package/dist/transcription-client.d.ts +23 -23
  144. package/dist/transcription.d.ts +562 -646
  145. package/dist/utils/sanitize.d.ts +4 -0
  146. package/dist/utils/sanitize.js +23 -6
  147. package/dist/video-client.d.ts +8 -8
  148. package/dist/video.d.ts +416 -372
  149. package/package.json +6 -6
@@ -9,7 +9,7 @@ import { Protocol } from "../route/protocol.js";
9
9
  import { Headers } from "effect/http";
10
10
  import { HttpTransport } from "../route/transport/index.js";
11
11
  import { AIError, HttpOptions, LLMRequest, LLMEvent, mergeJsonRecords, Usage, } from "../schema/index.js";
12
- import { JsonObject, knownString, optionalArray, optionalNull, ProviderShared } from "./shared.js";
12
+ import { JsonObject, knownString, optionalArray, optionalNull, ProviderShared, withUntypedFrames } from "./shared.js";
13
13
  import { classifyProviderFailure } from "../provider-error.js";
14
14
  import { effortUpdate, resolveEffortUpdates } from "../effort-updates.js";
15
15
  import * as Cache from "./utils/cache.js";
@@ -362,7 +362,7 @@ const AnthropicStreamDelta = Schema.StructWithRest(Schema.Struct({
362
362
  stop_details: optionalNull(Schema.StructWithRest(Schema.Struct({ category: optionalNull(Schema.String), explanation: optionalNull(Schema.String) }), [JsonObject])),
363
363
  }), [JsonObject]);
364
364
  const decodeAnthropicStreamDelta = Schema.decodeUnknownOption(AnthropicStreamDelta);
365
- const AnthropicEvent = Schema.StructWithRest(Schema.Struct({
365
+ const TypedAnthropicEvent = Schema.StructWithRest(Schema.Struct({
366
366
  type: Schema.String,
367
367
  index: Schema.optional(Schema.Number),
368
368
  message: Schema.optional(Schema.StructWithRest(Schema.Struct({ usage: Schema.optional(AnthropicUsage) }), [JsonObject])),
@@ -375,6 +375,7 @@ const AnthropicEvent = Schema.StructWithRest(Schema.Struct({
375
375
  // the parser can fall back to whichever field is populated.
376
376
  error: Schema.optional(Schema.StructWithRest(Schema.Struct({ type: Schema.optional(Schema.String), message: Schema.optional(Schema.String) }), [JsonObject])),
377
377
  }), [JsonObject]);
378
+ const AnthropicEvent = withUntypedFrames(TypedAnthropicEvent);
378
379
  const invalid = ProviderShared.invalidRequest;
379
380
  // =============================================================================
380
381
  // Request Lowering
@@ -37,5 +37,5 @@ export declare const AssemblyAITranscription: {
37
37
  readonly protocol: MediaProtocol.Queued<Request, TranscriptionResponse, {
38
38
  readonly transcriptID: string;
39
39
  }>;
40
- readonly model: (input: MediaRoute.ModelInput) => TranscriptionModel<AssemblyAITranscriptionOptions>;
40
+ readonly model: typeof model;
41
41
  };
@@ -133,21 +133,12 @@ declare const Options: Schema.Struct<{
133
133
  }>>;
134
134
  }>;
135
135
  export type OptionsInput = typeof Options.Type;
136
- interface ParserState {
137
- readonly providerMetadataKey: string;
138
- readonly tools: ToolStream.State<number>;
139
- readonly finishReason: FinishReasonDetails | undefined;
140
- readonly usage: Usage | undefined;
141
- readonly hasToolCalls: boolean;
142
- readonly lifecycle: Lifecycle.State;
143
- readonly reasoningSignatures: Readonly<Record<number, string>>;
144
- readonly reasoningRedactedContent: Readonly<Record<number, Uint8Array[]>>;
145
- }
146
136
  /**
147
137
  * The Bedrock Converse protocol — request body construction, body schema, and
148
138
  * the streaming-event state machine.
149
139
  */
150
140
  export declare const protocol: Protocol<{
141
+ readonly modelId: string;
151
142
  readonly messages: readonly ({
152
143
  readonly role: "user";
153
144
  readonly content: readonly ({
@@ -155,35 +146,21 @@ export declare const protocol: Protocol<{
155
146
  readonly type: "default";
156
147
  readonly ttl?: "1h" | "5m" | undefined;
157
148
  };
158
- } | {
159
- readonly image: {
160
- readonly format: "png" | "jpeg" | "gif" | "webp";
161
- readonly source: {
162
- readonly bytes: string;
163
- };
164
- };
165
- } | {
166
- readonly document: {
167
- readonly format: "pdf" | "txt" | "md" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html";
168
- readonly name: string;
169
- readonly source: {
170
- readonly bytes: string;
171
- };
172
- };
173
149
  } | {
174
150
  readonly text: string;
175
151
  } | {
176
152
  readonly toolResult: {
153
+ readonly toolUseId: string;
177
154
  readonly content: readonly ({
178
155
  readonly image: {
179
- readonly format: "png" | "jpeg" | "gif" | "webp";
156
+ readonly format: "gif" | "jpeg" | "png" | "webp";
180
157
  readonly source: {
181
158
  readonly bytes: string;
182
159
  };
183
160
  };
184
161
  } | {
185
162
  readonly document: {
186
- readonly format: "pdf" | "txt" | "md" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html";
163
+ readonly format: "csv" | "doc" | "docx" | "html" | "md" | "pdf" | "txt" | "xls" | "xlsx";
187
164
  readonly name: string;
188
165
  readonly source: {
189
166
  readonly bytes: string;
@@ -194,9 +171,23 @@ export declare const protocol: Protocol<{
194
171
  } | {
195
172
  readonly json: unknown;
196
173
  })[];
197
- readonly toolUseId: string;
198
174
  readonly status?: "error" | "success" | undefined;
199
175
  };
176
+ } | {
177
+ readonly image: {
178
+ readonly format: "gif" | "jpeg" | "png" | "webp";
179
+ readonly source: {
180
+ readonly bytes: string;
181
+ };
182
+ };
183
+ } | {
184
+ readonly document: {
185
+ readonly format: "csv" | "doc" | "docx" | "html" | "md" | "pdf" | "txt" | "xls" | "xlsx";
186
+ readonly name: string;
187
+ readonly source: {
188
+ readonly bytes: string;
189
+ };
190
+ };
200
191
  })[];
201
192
  } | {
202
193
  readonly role: "assistant";
@@ -224,7 +215,6 @@ export declare const protocol: Protocol<{
224
215
  };
225
216
  })[];
226
217
  })[];
227
- readonly modelId: string;
228
218
  readonly system?: readonly ({
229
219
  readonly cachePoint: {
230
220
  readonly type: "default";
@@ -234,8 +224,8 @@ export declare const protocol: Protocol<{
234
224
  readonly text: string;
235
225
  })[] | undefined;
236
226
  readonly inferenceConfig?: {
237
- readonly temperature?: number | undefined;
238
227
  readonly maxTokens?: number | undefined;
228
+ readonly temperature?: number | undefined;
239
229
  readonly topP?: number | undefined;
240
230
  readonly stopSequences?: readonly string[] | undefined;
241
231
  } | undefined;
@@ -248,12 +238,12 @@ export declare const protocol: Protocol<{
248
238
  } | {
249
239
  readonly toolSpec: {
250
240
  readonly name: string;
241
+ readonly description?: string | undefined;
251
242
  readonly inputSchema: {
252
243
  readonly json: {
253
244
  readonly [x: string]: unknown;
254
245
  };
255
246
  };
256
- readonly description?: string | undefined;
257
247
  };
258
248
  })[];
259
249
  readonly toolChoice?: {
@@ -270,24 +260,6 @@ export declare const protocol: Protocol<{
270
260
  readonly [x: string]: unknown;
271
261
  } | undefined;
272
262
  }, {
273
- readonly metadata?: {
274
- readonly usage?: {
275
- readonly inputTokens?: number | undefined;
276
- readonly outputTokens?: number | undefined;
277
- readonly cacheReadInputTokens?: number | undefined;
278
- readonly cacheWriteInputTokens?: number | undefined;
279
- readonly totalTokens?: number | undefined;
280
- } | undefined;
281
- readonly metrics?: unknown;
282
- } | undefined;
283
- readonly exception?: {
284
- readonly type: string;
285
- readonly details: {
286
- readonly message?: string | undefined;
287
- readonly originalMessage?: string | undefined;
288
- readonly originalStatusCode?: number | undefined;
289
- };
290
- } | undefined;
291
263
  readonly messageStart?: {
292
264
  readonly role: string;
293
265
  } | undefined;
@@ -308,10 +280,10 @@ export declare const protocol: Protocol<{
308
280
  readonly input: string;
309
281
  } | undefined;
310
282
  readonly reasoningContent?: {
311
- readonly data?: string | undefined;
312
283
  readonly text?: string | undefined;
313
284
  readonly signature?: string | undefined;
314
285
  readonly redactedContent?: string | undefined;
286
+ readonly data?: string | undefined;
315
287
  } | undefined;
316
288
  } | undefined;
317
289
  } | undefined;
@@ -322,14 +294,13 @@ export declare const protocol: Protocol<{
322
294
  readonly stopReason: string;
323
295
  readonly additionalModelResponseFields?: unknown;
324
296
  } | undefined;
325
- }, {
326
297
  readonly metadata?: {
327
298
  readonly usage?: {
328
299
  readonly inputTokens?: number | undefined;
329
300
  readonly outputTokens?: number | undefined;
301
+ readonly totalTokens?: number | undefined;
330
302
  readonly cacheReadInputTokens?: number | undefined;
331
303
  readonly cacheWriteInputTokens?: number | undefined;
332
- readonly totalTokens?: number | undefined;
333
304
  } | undefined;
334
305
  readonly metrics?: unknown;
335
306
  } | undefined;
@@ -341,6 +312,7 @@ export declare const protocol: Protocol<{
341
312
  readonly originalStatusCode?: number | undefined;
342
313
  };
343
314
  } | undefined;
315
+ }, {
344
316
  readonly messageStart?: {
345
317
  readonly role: string;
346
318
  } | undefined;
@@ -361,10 +333,10 @@ export declare const protocol: Protocol<{
361
333
  readonly input: string;
362
334
  } | undefined;
363
335
  readonly reasoningContent?: {
364
- readonly data?: string | undefined;
365
336
  readonly text?: string | undefined;
366
337
  readonly signature?: string | undefined;
367
338
  readonly redactedContent?: string | undefined;
339
+ readonly data?: string | undefined;
368
340
  } | undefined;
369
341
  } | undefined;
370
342
  } | undefined;
@@ -375,8 +347,36 @@ export declare const protocol: Protocol<{
375
347
  readonly stopReason: string;
376
348
  readonly additionalModelResponseFields?: unknown;
377
349
  } | undefined;
378
- }, ParserState>;
350
+ readonly metadata?: {
351
+ readonly usage?: {
352
+ readonly inputTokens?: number | undefined;
353
+ readonly outputTokens?: number | undefined;
354
+ readonly totalTokens?: number | undefined;
355
+ readonly cacheReadInputTokens?: number | undefined;
356
+ readonly cacheWriteInputTokens?: number | undefined;
357
+ } | undefined;
358
+ readonly metrics?: unknown;
359
+ } | undefined;
360
+ readonly exception?: {
361
+ readonly type: string;
362
+ readonly details: {
363
+ readonly message?: string | undefined;
364
+ readonly originalMessage?: string | undefined;
365
+ readonly originalStatusCode?: number | undefined;
366
+ };
367
+ } | undefined;
368
+ }, {
369
+ readonly providerMetadataKey: string;
370
+ readonly tools: ToolStream.State<number>;
371
+ readonly finishReason: FinishReasonDetails | undefined;
372
+ readonly usage: Usage | undefined;
373
+ readonly hasToolCalls: boolean;
374
+ readonly reasoningSignatures: Readonly<Record<number, string>>;
375
+ readonly reasoningRedactedContent: Readonly<Record<number, Uint8Array[]>>;
376
+ readonly lifecycle: Lifecycle.State;
377
+ }>;
379
378
  export declare const route: Route<{
379
+ readonly modelId: string;
380
380
  readonly messages: readonly ({
381
381
  readonly role: "user";
382
382
  readonly content: readonly ({
@@ -384,35 +384,21 @@ export declare const route: Route<{
384
384
  readonly type: "default";
385
385
  readonly ttl?: "1h" | "5m" | undefined;
386
386
  };
387
- } | {
388
- readonly image: {
389
- readonly format: "png" | "jpeg" | "gif" | "webp";
390
- readonly source: {
391
- readonly bytes: string;
392
- };
393
- };
394
- } | {
395
- readonly document: {
396
- readonly format: "pdf" | "txt" | "md" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html";
397
- readonly name: string;
398
- readonly source: {
399
- readonly bytes: string;
400
- };
401
- };
402
387
  } | {
403
388
  readonly text: string;
404
389
  } | {
405
390
  readonly toolResult: {
391
+ readonly toolUseId: string;
406
392
  readonly content: readonly ({
407
393
  readonly image: {
408
- readonly format: "png" | "jpeg" | "gif" | "webp";
394
+ readonly format: "gif" | "jpeg" | "png" | "webp";
409
395
  readonly source: {
410
396
  readonly bytes: string;
411
397
  };
412
398
  };
413
399
  } | {
414
400
  readonly document: {
415
- readonly format: "pdf" | "txt" | "md" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html";
401
+ readonly format: "csv" | "doc" | "docx" | "html" | "md" | "pdf" | "txt" | "xls" | "xlsx";
416
402
  readonly name: string;
417
403
  readonly source: {
418
404
  readonly bytes: string;
@@ -423,9 +409,23 @@ export declare const route: Route<{
423
409
  } | {
424
410
  readonly json: unknown;
425
411
  })[];
426
- readonly toolUseId: string;
427
412
  readonly status?: "error" | "success" | undefined;
428
413
  };
414
+ } | {
415
+ readonly image: {
416
+ readonly format: "gif" | "jpeg" | "png" | "webp";
417
+ readonly source: {
418
+ readonly bytes: string;
419
+ };
420
+ };
421
+ } | {
422
+ readonly document: {
423
+ readonly format: "csv" | "doc" | "docx" | "html" | "md" | "pdf" | "txt" | "xls" | "xlsx";
424
+ readonly name: string;
425
+ readonly source: {
426
+ readonly bytes: string;
427
+ };
428
+ };
429
429
  })[];
430
430
  } | {
431
431
  readonly role: "assistant";
@@ -453,7 +453,6 @@ export declare const route: Route<{
453
453
  };
454
454
  })[];
455
455
  })[];
456
- readonly modelId: string;
457
456
  readonly system?: readonly ({
458
457
  readonly cachePoint: {
459
458
  readonly type: "default";
@@ -463,8 +462,8 @@ export declare const route: Route<{
463
462
  readonly text: string;
464
463
  })[] | undefined;
465
464
  readonly inferenceConfig?: {
466
- readonly temperature?: number | undefined;
467
465
  readonly maxTokens?: number | undefined;
466
+ readonly temperature?: number | undefined;
468
467
  readonly topP?: number | undefined;
469
468
  readonly stopSequences?: readonly string[] | undefined;
470
469
  } | undefined;
@@ -477,12 +476,12 @@ export declare const route: Route<{
477
476
  } | {
478
477
  readonly toolSpec: {
479
478
  readonly name: string;
479
+ readonly description?: string | undefined;
480
480
  readonly inputSchema: {
481
481
  readonly json: {
482
482
  readonly [x: string]: unknown;
483
483
  };
484
484
  };
485
- readonly description?: string | undefined;
486
485
  };
487
486
  })[];
488
487
  readonly toolChoice?: {
@@ -499,8 +498,5 @@ export declare const route: Route<{
499
498
  readonly [x: string]: unknown;
500
499
  } | undefined;
501
500
  }, import("../route/transport/http.js").HttpPrepared<object>, import("../route/client.js").CompactionOperations | undefined>;
502
- export declare const sigV4Auth: (source: BedrockAuth.CredentialSource | undefined, options?: {
503
- readonly service?: string;
504
- readonly name?: string;
505
- }) => import("../route.js").AuthShape;
501
+ export declare const sigV4Auth: typeof BedrockAuth.sigV4;
506
502
  export * as BedrockConverse from "./bedrock-converse.js";
@@ -34,5 +34,5 @@ export declare const BlackForestLabsImages: {
34
34
  readonly pollingURL: string;
35
35
  readonly cost?: number | undefined;
36
36
  }>;
37
- readonly model: (input: MediaRoute.ModelInput) => ImageModel<BlackForestLabsImageOptions>;
37
+ readonly model: typeof model;
38
38
  };
@@ -23,12 +23,12 @@ interface State extends SpeechStream.Audio {
23
23
  readonly done: boolean;
24
24
  }
25
25
  export declare const protocol: MediaProtocol.Streamed<Request, {
26
- readonly id: string;
27
26
  readonly type: "generation-queued";
27
+ readonly id: string;
28
28
  readonly position?: number | undefined;
29
29
  } | {
30
- readonly id: string;
31
30
  readonly type: "generation-progress";
31
+ readonly id: string;
32
32
  readonly progress?: number | undefined;
33
33
  } | {
34
34
  readonly type: "audio-delta";
@@ -43,11 +43,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
43
43
  } | {
44
44
  readonly type: "finish";
45
45
  readonly audio: import("../media.js").Asset;
46
- readonly providerMetadata?: {
47
- readonly [x: string]: {
48
- readonly [x: string]: unknown;
49
- };
50
- } | undefined;
51
46
  readonly usage?: {
52
47
  readonly type: "tokens";
53
48
  readonly input?: number | undefined;
@@ -70,7 +65,7 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
70
65
  readonly seconds: number;
71
66
  } | undefined;
72
67
  readonly notices?: readonly {
73
- readonly type: "other" | "moderated" | "filtered";
68
+ readonly type: "filtered" | "moderated" | "other";
74
69
  readonly message: string;
75
70
  readonly providerMetadata?: {
76
71
  readonly [x: string]: {
@@ -78,16 +73,21 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
78
73
  };
79
74
  } | undefined;
80
75
  }[] | undefined;
76
+ readonly providerMetadata?: {
77
+ readonly [x: string]: {
78
+ readonly [x: string]: unknown;
79
+ };
80
+ } | undefined;
81
81
  }, string | Uint8Array<ArrayBufferLike>, State>;
82
82
  export declare const model: (input: MediaRoute.ModelInput) => SpeechModel<CartesiaSpeechOptions>;
83
83
  export declare const CartesiaSpeech: {
84
84
  readonly protocol: MediaProtocol.Streamed<Request, {
85
- readonly id: string;
86
85
  readonly type: "generation-queued";
86
+ readonly id: string;
87
87
  readonly position?: number | undefined;
88
88
  } | {
89
- readonly id: string;
90
89
  readonly type: "generation-progress";
90
+ readonly id: string;
91
91
  readonly progress?: number | undefined;
92
92
  } | {
93
93
  readonly type: "audio-delta";
@@ -102,11 +102,6 @@ export declare const CartesiaSpeech: {
102
102
  } | {
103
103
  readonly type: "finish";
104
104
  readonly audio: import("../media.js").Asset;
105
- readonly providerMetadata?: {
106
- readonly [x: string]: {
107
- readonly [x: string]: unknown;
108
- };
109
- } | undefined;
110
105
  readonly usage?: {
111
106
  readonly type: "tokens";
112
107
  readonly input?: number | undefined;
@@ -129,7 +124,7 @@ export declare const CartesiaSpeech: {
129
124
  readonly seconds: number;
130
125
  } | undefined;
131
126
  readonly notices?: readonly {
132
- readonly type: "other" | "moderated" | "filtered";
127
+ readonly type: "filtered" | "moderated" | "other";
133
128
  readonly message: string;
134
129
  readonly providerMetadata?: {
135
130
  readonly [x: string]: {
@@ -137,7 +132,12 @@ export declare const CartesiaSpeech: {
137
132
  };
138
133
  } | undefined;
139
134
  }[] | undefined;
135
+ readonly providerMetadata?: {
136
+ readonly [x: string]: {
137
+ readonly [x: string]: unknown;
138
+ };
139
+ } | undefined;
140
140
  }, string | Uint8Array<ArrayBufferLike>, State>;
141
- readonly model: (input: MediaRoute.ModelInput) => SpeechModel<CartesiaSpeechOptions>;
141
+ readonly model: typeof model;
142
142
  };
143
143
  export {};
@@ -11,10 +11,15 @@ declare const Options: Schema.Struct<{
11
11
  }>>;
12
12
  }>;
13
13
  export type ProviderOptionsInput = Schema.Schema.Type<typeof Options>;
14
+ type State = {
15
+ readonly lifecycle: Lifecycle.State;
16
+ readonly tools: ToolStream.State<number>;
17
+ readonly finished: boolean;
18
+ };
14
19
  export declare const protocol: Protocol<{
15
20
  readonly model: string;
16
21
  readonly messages: readonly {
17
- readonly role: "tool" | "system" | "user" | "assistant";
22
+ readonly role: "assistant" | "system" | "tool" | "user";
18
23
  readonly content?: string | readonly ({
19
24
  readonly type: "text";
20
25
  readonly text: string;
@@ -39,31 +44,31 @@ export declare const protocol: Protocol<{
39
44
  readonly tool_plan?: string | undefined;
40
45
  }[];
41
46
  readonly stream: true;
42
- readonly max_tokens?: number | undefined;
43
- readonly temperature?: number | undefined;
44
47
  readonly tools?: readonly {
45
48
  readonly type: "function";
46
49
  readonly function: {
47
50
  readonly name: string;
48
- readonly parameters: unknown;
49
51
  readonly description?: string | undefined;
52
+ readonly parameters: unknown;
50
53
  };
51
54
  }[] | undefined;
52
- readonly seed?: number | undefined;
55
+ readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
53
56
  readonly thinking?: {
54
57
  readonly type: string;
55
58
  readonly token_budget?: number | undefined;
56
59
  } | undefined;
57
- readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
58
- readonly stop_sequences?: readonly string[] | undefined;
60
+ readonly max_tokens?: number | undefined;
61
+ readonly temperature?: number | undefined;
59
62
  readonly p?: number | undefined;
60
63
  readonly k?: number | undefined;
64
+ readonly seed?: number | undefined;
65
+ readonly stop_sequences?: readonly string[] | undefined;
61
66
  readonly frequency_penalty?: number | undefined;
62
67
  readonly presence_penalty?: number | undefined;
63
68
  }, string, {
64
69
  readonly type: "message-start";
65
70
  } | {
66
- readonly type: "content-start" | "content-delta";
71
+ readonly type: "content-delta" | "content-start";
67
72
  readonly index: number;
68
73
  readonly delta: {
69
74
  readonly message: {
@@ -84,16 +89,16 @@ export declare const protocol: Protocol<{
84
89
  };
85
90
  };
86
91
  } | {
87
- readonly type: "tool-call-start" | "tool-call-delta";
92
+ readonly type: "tool-call-delta" | "tool-call-start";
88
93
  readonly index: number;
89
94
  readonly delta: {
90
95
  readonly message: {
91
96
  readonly tool_calls: {
97
+ readonly id?: string | undefined;
92
98
  readonly function: {
93
99
  readonly name?: string | undefined;
94
100
  readonly arguments?: string | undefined;
95
101
  };
96
- readonly id?: string | undefined;
97
102
  };
98
103
  };
99
104
  };
@@ -119,16 +124,14 @@ export declare const protocol: Protocol<{
119
124
  } | undefined;
120
125
  };
121
126
  } | {
122
- readonly type: "citation-start" | "citation-end";
123
- }, {
124
- readonly tools: Partial<Record<number, ToolStream.PendingTool>>;
125
- readonly lifecycle: Lifecycle.State;
126
- readonly finished: boolean;
127
- }>;
127
+ readonly type: "citation-end" | "citation-start";
128
+ } | {
129
+ readonly type: "unknown";
130
+ }, State>;
128
131
  export declare const route: Route<{
129
132
  readonly model: string;
130
133
  readonly messages: readonly {
131
- readonly role: "tool" | "system" | "user" | "assistant";
134
+ readonly role: "assistant" | "system" | "tool" | "user";
132
135
  readonly content?: string | readonly ({
133
136
  readonly type: "text";
134
137
  readonly text: string;
@@ -153,25 +156,25 @@ export declare const route: Route<{
153
156
  readonly tool_plan?: string | undefined;
154
157
  }[];
155
158
  readonly stream: true;
156
- readonly max_tokens?: number | undefined;
157
- readonly temperature?: number | undefined;
158
159
  readonly tools?: readonly {
159
160
  readonly type: "function";
160
161
  readonly function: {
161
162
  readonly name: string;
162
- readonly parameters: unknown;
163
163
  readonly description?: string | undefined;
164
+ readonly parameters: unknown;
164
165
  };
165
166
  }[] | undefined;
166
- readonly seed?: number | undefined;
167
+ readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
167
168
  readonly thinking?: {
168
169
  readonly type: string;
169
170
  readonly token_budget?: number | undefined;
170
171
  } | undefined;
171
- readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
172
- readonly stop_sequences?: readonly string[] | undefined;
172
+ readonly max_tokens?: number | undefined;
173
+ readonly temperature?: number | undefined;
173
174
  readonly p?: number | undefined;
174
175
  readonly k?: number | undefined;
176
+ readonly seed?: number | undefined;
177
+ readonly stop_sequences?: readonly string[] | undefined;
175
178
  readonly frequency_penalty?: number | undefined;
176
179
  readonly presence_penalty?: number | undefined;
177
180
  }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
@@ -1,4 +1,4 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect, Schema, SchemaGetter } from "effect";
2
2
  import { Route } from "../route/client.js";
3
3
  import { Endpoint } from "../route/endpoint.js";
4
4
  import { Framing } from "../route/framing.js";
@@ -65,6 +65,26 @@ const NativeUsage = Schema.Struct({
65
65
  billed_units: Schema.optional(TokenCounts),
66
66
  cached_tokens: Schema.optional(Schema.Number),
67
67
  });
68
+ const KNOWN_EVENT_TYPES = new Set([
69
+ "message-start",
70
+ "content-start",
71
+ "content-delta",
72
+ "content-end",
73
+ "tool-plan-delta",
74
+ "tool-call-start",
75
+ "tool-call-delta",
76
+ "tool-call-end",
77
+ "message-end",
78
+ "citation-start",
79
+ "citation-end",
80
+ ]);
81
+ // Cohere may add stream event types. Unknown types are ignored, while a malformed known type still fails decoding.
82
+ const UnknownEvent = Schema.Struct({
83
+ type: Schema.String.check(Schema.makeFilter((type) => !KNOWN_EVENT_TYPES.has(type))),
84
+ }).pipe(Schema.decodeTo(Schema.Struct({ type: Schema.Literal("unknown") }), {
85
+ decode: SchemaGetter.transform(() => ({ type: "unknown" })),
86
+ encode: SchemaGetter.forbidden(() => "Unknown Cohere stream events are decode-only"),
87
+ }));
68
88
  const Event = Schema.Union([
69
89
  Schema.Struct({ type: Schema.Literal("message-start") }),
70
90
  Schema.Struct({
@@ -100,6 +120,7 @@ const Event = Schema.Union([
100
120
  }),
101
121
  // Citation output is outside this basic chat surface.
102
122
  Schema.Struct({ type: Schema.Literals(["citation-start", "citation-end"]) }),
123
+ UnknownEvent,
103
124
  ]);
104
125
  const TOOL_CHOICE = { auto: undefined, none: "NONE", required: "REQUIRED", tool: "REQUIRED" };
105
126
  const fromRequest = Effect.fn("CohereChat.fromRequest")(function* (request) {