@ai-sdk/cohere 2.0.47 → 2.0.49

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @ai-sdk/cohere
2
2
 
3
+ ## 2.0.49
4
+
5
+ ### Patch Changes
6
+
7
+ - 2bde332: fix(cohere): tolerate partial citations and usage in non-streaming responses
8
+
9
+ Cohere citations and usage fields are optional in the API specification, but the
10
+ response schema required `start`, `end`, `text`, every source `document` with
11
+ `text` and `title`, and usage token counts. Responses with untitled documents
12
+ (documents passed without a filename), with tool-sourced citations, or without
13
+ token counts failed with an `AI_TypeValidationError` and discarded the whole
14
+ response.
15
+
16
+ These fields are now validated loosely: citation fields and source `type`/`id`
17
+ are nullish, `document` is a loose object with optional `id`/`text`/`title`, tool
18
+ sources are accepted, and `usage` plus its token counts are nullish. Document
19
+ citations without a title fall back to `"Document"`. Tool-only citations are
20
+ skipped because they have no document to point at; their data stays in the
21
+ response body.
22
+
23
+ `convertCohereUsage` no longer falls back to `billed_units`, which are a
24
+ different measure than `tokens` (e.g. 12 billed vs 507 input tokens in a single
25
+ response) and would go negative when cached tokens are subtracted. A response
26
+ without `tokens` now reports undefined token counts instead of unrelated
27
+ numbers. This usage conversion is shared with streaming.
28
+
29
+ - e51d6ad: fix(cohere): read the response id from v2 chat responses
30
+
31
+ The non-streaming response schema read `generation_id`, which Cohere's v2 chat
32
+ response does not return. As a result, `generateText().response.id` was a locally
33
+ generated fallback instead of the provider's id, while `streamText` returned the
34
+ id from the `message-start` event. `doGenerate` now reads `id` and keeps
35
+ `generation_id` (the v1 field) only for compatibility with proxies and mocks that
36
+ still return it.
37
+
38
+ - 2bde332: fix(cohere): emit `source` stream parts for citations
39
+
40
+ `streamText` did not produce sources for Cohere RAG responses because `citation-start` stream events were ignored, while `generateText` mapped `message.citations` to document sources. Streaming now maps each cited document to the same `source` part as the non-streaming path. Citations that only reference tool output are not emitted as sources, and `citation-start` events without citations are ignored.
41
+
42
+ - Updated dependencies [49c554d]
43
+ - Updated dependencies [b753c03]
44
+ - @ai-sdk/provider-utils@3.0.45
45
+
46
+ ## 2.0.48
47
+
48
+ ### Patch Changes
49
+
50
+ - 0a069bd: fix(cohere): preserve string tool call arguments and safely serialize BigInt and circular structures in tool calls and outputs
51
+ - Updated dependencies [0a069bd]
52
+ - Updated dependencies [0a069bd]
53
+ - Updated dependencies [0a069bd]
54
+ - @ai-sdk/provider-utils@3.0.44
55
+
3
56
  ## 2.0.47
4
57
 
5
58
  ### Patch Changes
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/cohere-chat-language-model.ts
34
34
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
35
- var import_v43 = require("zod/v4");
35
+ var import_v44 = require("zod/v4");
36
36
 
37
37
  // src/cohere-chat-options.ts
38
38
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -68,13 +68,63 @@ var cohereImagePartProviderOptions = (0, import_provider_utils.lazySchema)(
68
68
  )
69
69
  );
70
70
 
71
+ // src/cohere-citations.ts
72
+ var import_v42 = require("zod/v4");
73
+ var cohereCitationSchema = import_v42.z.object({
74
+ start: import_v42.z.number().nullish(),
75
+ end: import_v42.z.number().nullish(),
76
+ text: import_v42.z.string().nullish(),
77
+ sources: import_v42.z.array(
78
+ import_v42.z.object({
79
+ type: import_v42.z.string().nullish(),
80
+ id: import_v42.z.string().nullish(),
81
+ // Documents are arbitrary objects; only the fields the provider maps
82
+ // are typed, everything else is passed through as provider metadata.
83
+ document: import_v42.z.looseObject({
84
+ id: import_v42.z.string().nullish(),
85
+ text: import_v42.z.string().nullish(),
86
+ title: import_v42.z.string().nullish()
87
+ }).nullish(),
88
+ tool_output: import_v42.z.looseObject({}).nullish()
89
+ })
90
+ ).nullish(),
91
+ type: import_v42.z.string().nullish()
92
+ });
93
+ function mapCohereCitationToSource(citation, generateId3) {
94
+ var _a, _b;
95
+ const document = (_b = (_a = citation.sources) == null ? void 0 : _a.find(
96
+ (source) => source.document != null
97
+ )) == null ? void 0 : _b.document;
98
+ if (document == null) {
99
+ return void 0;
100
+ }
101
+ return {
102
+ type: "source",
103
+ sourceType: "document",
104
+ id: generateId3(),
105
+ mediaType: "text/plain",
106
+ title: document.title || "Document",
107
+ providerMetadata: {
108
+ cohere: {
109
+ ...citation.start != null && { start: citation.start },
110
+ ...citation.end != null && { end: citation.end },
111
+ ...citation.text != null && { text: citation.text },
112
+ ...citation.sources != null && {
113
+ sources: citation.sources
114
+ },
115
+ ...citation.type != null && { citationType: citation.type }
116
+ }
117
+ }
118
+ };
119
+ }
120
+
71
121
  // src/cohere-error.ts
72
122
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
73
- var import_v42 = require("zod/v4");
123
+ var import_v43 = require("zod/v4");
74
124
  var cohereErrorDataSchema = (0, import_provider_utils2.lazySchema)(
75
125
  () => (0, import_provider_utils2.zodSchema)(
76
- import_v42.z.object({
77
- message: import_v42.z.string()
126
+ import_v43.z.object({
127
+ message: import_v43.z.string()
78
128
  })
79
129
  )
80
130
  );
@@ -86,6 +136,17 @@ var cohereFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
86
136
  // src/convert-to-cohere-chat-prompt.ts
87
137
  var import_provider = require("@ai-sdk/provider");
88
138
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
139
+ function serializeCohereToolCallArguments(input) {
140
+ if (typeof input === "string") {
141
+ try {
142
+ (0, import_provider_utils3.secureJsonParse)(input);
143
+ return input;
144
+ } catch (e) {
145
+ return JSON.stringify(input);
146
+ }
147
+ }
148
+ return (0, import_provider_utils3.stringifyWithBigIntAndCycles)(input);
149
+ }
89
150
  async function convertToCohereChatPrompt(prompt) {
90
151
  var _a, _b;
91
152
  const messages = [];
@@ -178,7 +239,7 @@ async function convertToCohereChatPrompt(prompt) {
178
239
  type: "function",
179
240
  function: {
180
241
  name: part.toolName,
181
- arguments: JSON.stringify(part.input)
242
+ arguments: serializeCohereToolCallArguments(part.input)
182
243
  }
183
244
  });
184
245
  break;
@@ -206,7 +267,7 @@ async function convertToCohereChatPrompt(prompt) {
206
267
  case "content":
207
268
  case "json":
208
269
  case "error-json":
209
- contentValue = JSON.stringify(output.value);
270
+ contentValue = (0, import_provider_utils3.stringifyWithBigIntAndCycles)(output.value);
210
271
  break;
211
272
  }
212
273
  return {
@@ -386,7 +447,7 @@ var CohereChatLanguageModel = class {
386
447
  };
387
448
  }
388
449
  async doGenerate(options) {
389
- var _a, _b, _c, _d, _e, _f;
450
+ var _a, _b, _c, _d, _e;
390
451
  const { args, warnings } = await this.getArgs(options);
391
452
  const {
392
453
  responseHeaders,
@@ -415,24 +476,15 @@ var CohereChatLanguageModel = class {
415
476
  }
416
477
  }
417
478
  for (const citation of (_b = response.message.citations) != null ? _b : []) {
418
- content.push({
419
- type: "source",
420
- sourceType: "document",
421
- id: this.config.generateId(),
422
- mediaType: "text/plain",
423
- title: ((_d = (_c = citation.sources[0]) == null ? void 0 : _c.document) == null ? void 0 : _d.title) || "Document",
424
- providerMetadata: {
425
- cohere: {
426
- start: citation.start,
427
- end: citation.end,
428
- text: citation.text,
429
- sources: citation.sources,
430
- ...citation.type && { citationType: citation.type }
431
- }
432
- }
433
- });
479
+ const source = mapCohereCitationToSource(
480
+ citation,
481
+ () => this.config.generateId()
482
+ );
483
+ if (source != null) {
484
+ content.push(source);
485
+ }
434
486
  }
435
- for (const toolCall of (_e = response.message.tool_calls) != null ? _e : []) {
487
+ for (const toolCall of (_c = response.message.tool_calls) != null ? _c : []) {
436
488
  content.push({
437
489
  type: "tool-call",
438
490
  toolCallId: toolCall.id,
@@ -445,15 +497,13 @@ var CohereChatLanguageModel = class {
445
497
  return {
446
498
  content,
447
499
  finishReason: mapCohereFinishReason(response.finish_reason),
448
- usage: {
449
- inputTokens: response.usage.tokens.input_tokens,
450
- outputTokens: response.usage.tokens.output_tokens,
451
- totalTokens: response.usage.tokens.input_tokens + response.usage.tokens.output_tokens
452
- },
500
+ usage: convertCohereUsage(response.usage),
453
501
  request: { body: args },
454
502
  response: {
455
503
  // TODO timestamp, model id
456
- id: (_f = response.generation_id) != null ? _f : void 0,
504
+ // Cohere v2 returns `id`; `generation_id` is the v1 field, kept only
505
+ // for compatibility with proxies/mocks that still return it.
506
+ id: (_e = (_d = response.id) != null ? _d : response.generation_id) != null ? _e : void 0,
457
507
  headers: responseHeaders,
458
508
  body: rawResponse
459
509
  },
@@ -474,13 +524,10 @@ var CohereChatLanguageModel = class {
474
524
  fetch: this.config.fetch
475
525
  });
476
526
  let finishReason = "unknown";
477
- const usage = {
478
- inputTokens: void 0,
479
- outputTokens: void 0,
480
- totalTokens: void 0
481
- };
527
+ let rawUsage = void 0;
482
528
  let pendingToolCall = null;
483
529
  let isActiveReasoning = false;
530
+ const generateId3 = this.config.generateId;
484
531
  return {
485
532
  stream: response.pipeThrough(
486
533
  new TransformStream({
@@ -488,7 +535,7 @@ var CohereChatLanguageModel = class {
488
535
  controller.enqueue({ type: "stream-start", warnings });
489
536
  },
490
537
  transform(chunk, controller) {
491
- var _a, _b;
538
+ var _a, _b, _c, _d, _e;
492
539
  if (options.includeRawChunks) {
493
540
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
494
541
  }
@@ -546,6 +593,22 @@ var CohereChatLanguageModel = class {
546
593
  });
547
594
  return;
548
595
  }
596
+ case "citation-start": {
597
+ const citations = (_b = (_a = value.delta) == null ? void 0 : _a.message) == null ? void 0 : _b.citations;
598
+ if (citations == null) {
599
+ return;
600
+ }
601
+ for (const citation of Array.isArray(citations) ? citations : [citations]) {
602
+ const source = mapCohereCitationToSource(
603
+ citation,
604
+ generateId3
605
+ );
606
+ if (source != null) {
607
+ controller.enqueue(source);
608
+ }
609
+ }
610
+ return;
611
+ }
549
612
  case "tool-call-start": {
550
613
  const toolId = value.delta.message.tool_calls.id;
551
614
  const toolName = value.delta.message.tool_calls.function.name;
@@ -593,7 +656,7 @@ var CohereChatLanguageModel = class {
593
656
  toolCallId: pendingToolCall.id,
594
657
  toolName: pendingToolCall.name,
595
658
  input: JSON.stringify(
596
- JSON.parse(((_a = pendingToolCall.arguments) == null ? void 0 : _a.trim()) || "{}")
659
+ JSON.parse(((_c = pendingToolCall.arguments) == null ? void 0 : _c.trim()) || "{}")
597
660
  )
598
661
  });
599
662
  pendingToolCall.hasFinished = true;
@@ -604,16 +667,13 @@ var CohereChatLanguageModel = class {
604
667
  case "message-start": {
605
668
  controller.enqueue({
606
669
  type: "response-metadata",
607
- id: (_b = value.id) != null ? _b : void 0
670
+ id: (_d = value.id) != null ? _d : void 0
608
671
  });
609
672
  return;
610
673
  }
611
674
  case "message-end": {
612
675
  finishReason = mapCohereFinishReason(value.delta.finish_reason);
613
- const tokens = value.delta.usage.tokens;
614
- usage.inputTokens = tokens.input_tokens;
615
- usage.outputTokens = tokens.output_tokens;
616
- usage.totalTokens = tokens.input_tokens + tokens.output_tokens;
676
+ rawUsage = (_e = value.delta.usage) != null ? _e : void 0;
617
677
  return;
618
678
  }
619
679
  default: {
@@ -624,7 +684,7 @@ var CohereChatLanguageModel = class {
624
684
  controller.enqueue({
625
685
  type: "finish",
626
686
  finishReason,
627
- usage
687
+ usage: convertCohereUsage(rawUsage)
628
688
  });
629
689
  }
630
690
  })
@@ -634,151 +694,148 @@ var CohereChatLanguageModel = class {
634
694
  };
635
695
  }
636
696
  };
697
+ var cohereUsageSchema = () => import_v44.z.looseObject({
698
+ billed_units: import_v44.z.looseObject({
699
+ input_tokens: import_v44.z.number().nullish(),
700
+ output_tokens: import_v44.z.number().nullish()
701
+ }).nullish(),
702
+ tokens: import_v44.z.looseObject({
703
+ input_tokens: import_v44.z.number().nullish(),
704
+ output_tokens: import_v44.z.number().nullish()
705
+ }).nullish()
706
+ });
707
+ function convertCohereUsage(usage) {
708
+ var _a, _b, _c, _d;
709
+ const inputTokens = (_b = (_a = usage == null ? void 0 : usage.tokens) == null ? void 0 : _a.input_tokens) != null ? _b : void 0;
710
+ const outputTokens = (_d = (_c = usage == null ? void 0 : usage.tokens) == null ? void 0 : _c.output_tokens) != null ? _d : void 0;
711
+ return {
712
+ inputTokens,
713
+ outputTokens,
714
+ totalTokens: inputTokens != null && outputTokens != null ? inputTokens + outputTokens : void 0
715
+ };
716
+ }
637
717
  var cohereChatResponseSchema = (0, import_provider_utils4.lazySchema)(
638
718
  () => (0, import_provider_utils4.zodSchema)(
639
- import_v43.z.object({
640
- generation_id: import_v43.z.string().nullish(),
641
- message: import_v43.z.object({
642
- role: import_v43.z.string(),
643
- content: import_v43.z.array(
644
- import_v43.z.union([
645
- import_v43.z.object({
646
- type: import_v43.z.literal("text"),
647
- text: import_v43.z.string()
719
+ import_v44.z.object({
720
+ id: import_v44.z.string().nullish(),
721
+ generation_id: import_v44.z.string().nullish(),
722
+ message: import_v44.z.object({
723
+ role: import_v44.z.string(),
724
+ content: import_v44.z.array(
725
+ import_v44.z.union([
726
+ import_v44.z.object({
727
+ type: import_v44.z.literal("text"),
728
+ text: import_v44.z.string()
648
729
  }),
649
- import_v43.z.object({
650
- type: import_v43.z.literal("thinking"),
651
- thinking: import_v43.z.string()
730
+ import_v44.z.object({
731
+ type: import_v44.z.literal("thinking"),
732
+ thinking: import_v44.z.string()
652
733
  })
653
734
  ])
654
735
  ).nullish(),
655
- tool_plan: import_v43.z.string().nullish(),
656
- tool_calls: import_v43.z.array(
657
- import_v43.z.object({
658
- id: import_v43.z.string(),
659
- type: import_v43.z.literal("function"),
660
- function: import_v43.z.object({
661
- name: import_v43.z.string(),
662
- arguments: import_v43.z.string()
736
+ tool_plan: import_v44.z.string().nullish(),
737
+ tool_calls: import_v44.z.array(
738
+ import_v44.z.object({
739
+ id: import_v44.z.string(),
740
+ type: import_v44.z.literal("function"),
741
+ function: import_v44.z.object({
742
+ name: import_v44.z.string(),
743
+ arguments: import_v44.z.string()
663
744
  })
664
745
  })
665
746
  ).nullish(),
666
- citations: import_v43.z.array(
667
- import_v43.z.object({
668
- start: import_v43.z.number(),
669
- end: import_v43.z.number(),
670
- text: import_v43.z.string(),
671
- sources: import_v43.z.array(
672
- import_v43.z.object({
673
- type: import_v43.z.string().optional(),
674
- id: import_v43.z.string().optional(),
675
- document: import_v43.z.object({
676
- id: import_v43.z.string().optional(),
677
- text: import_v43.z.string(),
678
- title: import_v43.z.string()
679
- })
680
- })
681
- ),
682
- type: import_v43.z.string().optional()
683
- })
684
- ).nullish()
747
+ citations: import_v44.z.array(cohereCitationSchema).nullish()
685
748
  }),
686
- finish_reason: import_v43.z.string(),
687
- usage: import_v43.z.object({
688
- billed_units: import_v43.z.object({
689
- input_tokens: import_v43.z.number(),
690
- output_tokens: import_v43.z.number()
691
- }),
692
- tokens: import_v43.z.object({
693
- input_tokens: import_v43.z.number(),
694
- output_tokens: import_v43.z.number()
695
- })
696
- })
749
+ finish_reason: import_v44.z.string(),
750
+ usage: cohereUsageSchema().nullish()
697
751
  })
698
752
  )
699
753
  );
700
754
  var cohereChatChunkSchema = (0, import_provider_utils4.lazySchema)(
701
755
  () => (0, import_provider_utils4.zodSchema)(
702
- import_v43.z.discriminatedUnion("type", [
703
- import_v43.z.object({
704
- type: import_v43.z.literal("citation-start")
756
+ import_v44.z.discriminatedUnion("type", [
757
+ // `citation-start` events can arrive without citations, and a single
758
+ // citation may be sent instead of an array.
759
+ import_v44.z.object({
760
+ type: import_v44.z.literal("citation-start"),
761
+ index: import_v44.z.number().nullish(),
762
+ delta: import_v44.z.object({
763
+ message: import_v44.z.object({
764
+ citations: import_v44.z.union([cohereCitationSchema, import_v44.z.array(cohereCitationSchema)]).nullish()
765
+ }).nullish()
766
+ }).nullish()
705
767
  }),
706
- import_v43.z.object({
707
- type: import_v43.z.literal("citation-end")
768
+ import_v44.z.object({
769
+ type: import_v44.z.literal("citation-end")
708
770
  }),
709
- import_v43.z.object({
710
- type: import_v43.z.literal("content-start"),
711
- index: import_v43.z.number(),
712
- delta: import_v43.z.object({
713
- message: import_v43.z.object({
714
- content: import_v43.z.union([
715
- import_v43.z.object({
716
- type: import_v43.z.literal("text"),
717
- text: import_v43.z.string()
771
+ import_v44.z.object({
772
+ type: import_v44.z.literal("content-start"),
773
+ index: import_v44.z.number(),
774
+ delta: import_v44.z.object({
775
+ message: import_v44.z.object({
776
+ content: import_v44.z.union([
777
+ import_v44.z.object({
778
+ type: import_v44.z.literal("text"),
779
+ text: import_v44.z.string()
718
780
  }),
719
- import_v43.z.object({
720
- type: import_v43.z.literal("thinking"),
721
- thinking: import_v43.z.string()
781
+ import_v44.z.object({
782
+ type: import_v44.z.literal("thinking"),
783
+ thinking: import_v44.z.string()
722
784
  })
723
785
  ])
724
786
  })
725
787
  })
726
788
  }),
727
- import_v43.z.object({
728
- type: import_v43.z.literal("content-delta"),
729
- index: import_v43.z.number(),
730
- delta: import_v43.z.object({
731
- message: import_v43.z.object({
732
- content: import_v43.z.union([
733
- import_v43.z.object({
734
- text: import_v43.z.string()
789
+ import_v44.z.object({
790
+ type: import_v44.z.literal("content-delta"),
791
+ index: import_v44.z.number(),
792
+ delta: import_v44.z.object({
793
+ message: import_v44.z.object({
794
+ content: import_v44.z.union([
795
+ import_v44.z.object({
796
+ text: import_v44.z.string()
735
797
  }),
736
- import_v43.z.object({
737
- thinking: import_v43.z.string()
798
+ import_v44.z.object({
799
+ thinking: import_v44.z.string()
738
800
  })
739
801
  ])
740
802
  })
741
803
  })
742
804
  }),
743
- import_v43.z.object({
744
- type: import_v43.z.literal("content-end"),
745
- index: import_v43.z.number()
805
+ import_v44.z.object({
806
+ type: import_v44.z.literal("content-end"),
807
+ index: import_v44.z.number()
746
808
  }),
747
- import_v43.z.object({
748
- type: import_v43.z.literal("message-start"),
749
- id: import_v43.z.string().nullish()
809
+ import_v44.z.object({
810
+ type: import_v44.z.literal("message-start"),
811
+ id: import_v44.z.string().nullish()
750
812
  }),
751
- import_v43.z.object({
752
- type: import_v43.z.literal("message-end"),
753
- delta: import_v43.z.object({
754
- finish_reason: import_v43.z.string(),
755
- usage: import_v43.z.object({
756
- tokens: import_v43.z.object({
757
- input_tokens: import_v43.z.number(),
758
- output_tokens: import_v43.z.number()
759
- })
760
- })
813
+ import_v44.z.object({
814
+ type: import_v44.z.literal("message-end"),
815
+ delta: import_v44.z.object({
816
+ finish_reason: import_v44.z.string(),
817
+ usage: cohereUsageSchema().nullish()
761
818
  })
762
819
  }),
763
820
  // https://docs.cohere.com/v2/docs/streaming#tool-use-stream-events-for-tool-calling
764
- import_v43.z.object({
765
- type: import_v43.z.literal("tool-plan-delta"),
766
- delta: import_v43.z.object({
767
- message: import_v43.z.object({
768
- tool_plan: import_v43.z.string()
821
+ import_v44.z.object({
822
+ type: import_v44.z.literal("tool-plan-delta"),
823
+ delta: import_v44.z.object({
824
+ message: import_v44.z.object({
825
+ tool_plan: import_v44.z.string()
769
826
  })
770
827
  })
771
828
  }),
772
- import_v43.z.object({
773
- type: import_v43.z.literal("tool-call-start"),
774
- delta: import_v43.z.object({
775
- message: import_v43.z.object({
776
- tool_calls: import_v43.z.object({
777
- id: import_v43.z.string(),
778
- type: import_v43.z.literal("function"),
779
- function: import_v43.z.object({
780
- name: import_v43.z.string(),
781
- arguments: import_v43.z.string()
829
+ import_v44.z.object({
830
+ type: import_v44.z.literal("tool-call-start"),
831
+ delta: import_v44.z.object({
832
+ message: import_v44.z.object({
833
+ tool_calls: import_v44.z.object({
834
+ id: import_v44.z.string(),
835
+ type: import_v44.z.literal("function"),
836
+ function: import_v44.z.object({
837
+ name: import_v44.z.string(),
838
+ arguments: import_v44.z.string()
782
839
  })
783
840
  })
784
841
  })
@@ -787,20 +844,20 @@ var cohereChatChunkSchema = (0, import_provider_utils4.lazySchema)(
787
844
  // A single tool call's `arguments` stream in chunks and must be accumulated
788
845
  // in a string and so the full tool object info can only be parsed once we see
789
846
  // `tool-call-end`.
790
- import_v43.z.object({
791
- type: import_v43.z.literal("tool-call-delta"),
792
- delta: import_v43.z.object({
793
- message: import_v43.z.object({
794
- tool_calls: import_v43.z.object({
795
- function: import_v43.z.object({
796
- arguments: import_v43.z.string()
847
+ import_v44.z.object({
848
+ type: import_v44.z.literal("tool-call-delta"),
849
+ delta: import_v44.z.object({
850
+ message: import_v44.z.object({
851
+ tool_calls: import_v44.z.object({
852
+ function: import_v44.z.object({
853
+ arguments: import_v44.z.string()
797
854
  })
798
855
  })
799
856
  })
800
857
  })
801
858
  }),
802
- import_v43.z.object({
803
- type: import_v43.z.literal("tool-call-end")
859
+ import_v44.z.object({
860
+ type: import_v44.z.literal("tool-call-end")
804
861
  })
805
862
  ])
806
863
  )
@@ -809,14 +866,14 @@ var cohereChatChunkSchema = (0, import_provider_utils4.lazySchema)(
809
866
  // src/cohere-embedding-model.ts
810
867
  var import_provider3 = require("@ai-sdk/provider");
811
868
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
812
- var import_v45 = require("zod/v4");
869
+ var import_v46 = require("zod/v4");
813
870
 
814
871
  // src/cohere-embedding-options.ts
815
872
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
816
- var import_v44 = require("zod/v4");
873
+ var import_v45 = require("zod/v4");
817
874
  var cohereEmbeddingOptions = (0, import_provider_utils5.lazySchema)(
818
875
  () => (0, import_provider_utils5.zodSchema)(
819
- import_v44.z.object({
876
+ import_v45.z.object({
820
877
  /**
821
878
  * Specifies the type of input passed to the model. Default is `search_query`.
822
879
  *
@@ -825,7 +882,7 @@ var cohereEmbeddingOptions = (0, import_provider_utils5.lazySchema)(
825
882
  * - "classification": Used for embeddings passed through a text classifier.
826
883
  * - "clustering": Used for embeddings run through a clustering algorithm.
827
884
  */
828
- inputType: import_v44.z.enum([
885
+ inputType: import_v45.z.enum([
829
886
  "search_document",
830
887
  "search_query",
831
888
  "classification",
@@ -839,7 +896,7 @@ var cohereEmbeddingOptions = (0, import_provider_utils5.lazySchema)(
839
896
  * - "START": Will discard the start of the input until the remaining input is exactly the maximum input token length for the model.
840
897
  * - "END": Will discard the end of the input until the remaining input is exactly the maximum input token length for the model.
841
898
  */
842
- truncate: import_v44.z.enum(["NONE", "START", "END"]).optional()
899
+ truncate: import_v45.z.enum(["NONE", "START", "END"]).optional()
843
900
  })
844
901
  )
845
902
  );
@@ -909,13 +966,13 @@ var CohereEmbeddingModel = class {
909
966
  };
910
967
  var cohereTextEmbeddingResponseSchema = (0, import_provider_utils6.lazySchema)(
911
968
  () => (0, import_provider_utils6.zodSchema)(
912
- import_v45.z.object({
913
- embeddings: import_v45.z.object({
914
- float: import_v45.z.array(import_v45.z.array(import_v45.z.number()))
969
+ import_v46.z.object({
970
+ embeddings: import_v46.z.object({
971
+ float: import_v46.z.array(import_v46.z.array(import_v46.z.number()))
915
972
  }),
916
- meta: import_v45.z.object({
917
- billed_units: import_v45.z.object({
918
- input_tokens: import_v45.z.number()
973
+ meta: import_v46.z.object({
974
+ billed_units: import_v46.z.object({
975
+ input_tokens: import_v46.z.number()
919
976
  })
920
977
  })
921
978
  })
@@ -923,7 +980,7 @@ var cohereTextEmbeddingResponseSchema = (0, import_provider_utils6.lazySchema)(
923
980
  );
924
981
 
925
982
  // src/version.ts
926
- var VERSION = true ? "2.0.47" : "0.0.0-test";
983
+ var VERSION = true ? "2.0.49" : "0.0.0-test";
927
984
 
928
985
  // src/cohere-provider.ts
929
986
  function createCohere(options = {}) {