ai 6.0.249 → 6.0.252

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.
@@ -164,7 +164,7 @@ function detectMediaType({
164
164
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
165
165
 
166
166
  // src/version.ts
167
- var VERSION = true ? "6.0.249" : "0.0.0-test";
167
+ var VERSION = true ? "6.0.252" : "0.0.0-test";
168
168
 
169
169
  // src/util/download/download.ts
170
170
  var download = async ({
@@ -144,7 +144,7 @@ import {
144
144
  } from "@ai-sdk/provider-utils";
145
145
 
146
146
  // src/version.ts
147
- var VERSION = true ? "6.0.249" : "0.0.0-test";
147
+ var VERSION = true ? "6.0.252" : "0.0.0-test";
148
148
 
149
149
  // src/util/download/download.ts
150
150
  var download = async ({
@@ -112,6 +112,7 @@ Here are the capabilities of popular models:
112
112
 
113
113
  | Provider | Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
114
114
  | -------------------------------------------------- | ------------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
115
+ | [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4.6` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
115
116
  | [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4.5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
116
117
  | [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-4` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
117
118
  | [xAI Grok](/providers/ai-sdk-providers/xai) | `grok-3` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "6.0.249",
3
+ "version": "6.0.252",
4
4
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -45,9 +45,9 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@opentelemetry/api": "^1.9.0",
48
- "@ai-sdk/gateway": "3.0.169",
48
+ "@ai-sdk/gateway": "3.0.171",
49
49
  "@ai-sdk/provider": "3.0.15",
50
- "@ai-sdk/provider-utils": "4.0.44"
50
+ "@ai-sdk/provider-utils": "4.0.45"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@edge-runtime/vm": "^5.0.0",
@@ -202,6 +202,7 @@ export type ToolLoopAgentSettings<
202
202
  | 'frequencyPenalty'
203
203
  | 'stopSequences'
204
204
  | 'seed'
205
+ | 'timeout'
205
206
  | 'headers'
206
207
  | 'instructions'
207
208
  | 'allowSystemInMessages'
@@ -143,10 +143,12 @@ export class ToolLoopAgent<
143
143
  }: AgentCallParameters<CALL_OPTIONS, TOOLS>): Promise<
144
144
  GenerateTextResult<TOOLS, OUTPUT>
145
145
  > {
146
+ const preparedCall = await this.prepareCall(options);
147
+
146
148
  return generateText({
147
- ...(await this.prepareCall(options)),
149
+ ...preparedCall,
148
150
  abortSignal,
149
- timeout,
151
+ timeout: timeout ?? preparedCall.timeout,
150
152
  onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish),
151
153
  });
152
154
  }
@@ -163,10 +165,12 @@ export class ToolLoopAgent<
163
165
  }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<
164
166
  StreamTextResult<TOOLS, OUTPUT>
165
167
  > {
168
+ const preparedCall = await this.prepareCall(options);
169
+
166
170
  return streamText({
167
- ...(await this.prepareCall(options)),
171
+ ...preparedCall,
168
172
  abortSignal,
169
- timeout,
173
+ timeout: timeout ?? preparedCall.timeout,
170
174
  experimental_transform,
171
175
  onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish),
172
176
  });
@@ -488,6 +488,7 @@ class DefaultStreamObjectResult<
488
488
  }),
489
489
  tracer,
490
490
  endWhenDone: false,
491
+ endOnError: true,
491
492
  fn: async rootSpan => {
492
493
  const standardizedPrompt = await standardizePrompt({
493
494
  system,
@@ -567,6 +568,7 @@ class DefaultStreamObjectResult<
567
568
  }),
568
569
  tracer,
569
570
  endWhenDone: false,
571
+ endOnError: true,
570
572
  fn: async doStreamSpan => ({
571
573
  startTimestampMs: now(),
572
574
  doStreamSpan,
@@ -1760,6 +1760,7 @@ class DefaultStreamTextResult<
1760
1760
  }),
1761
1761
  tracer,
1762
1762
  endWhenDone: false,
1763
+ endOnError: true,
1763
1764
  fn: async doStreamSpan => ({
1764
1765
  startTimestampMs: now(), // get before the call
1765
1766
  doStreamSpan,
@@ -12,12 +12,14 @@ export async function recordSpan<T>({
12
12
  attributes,
13
13
  fn,
14
14
  endWhenDone = true,
15
+ endOnError = endWhenDone,
15
16
  }: {
16
17
  name: string;
17
18
  tracer: Tracer;
18
19
  attributes: Attributes | PromiseLike<Attributes>;
19
20
  fn: (span: Span) => Promise<T>;
20
21
  endWhenDone?: boolean;
22
+ endOnError?: boolean;
21
23
  }) {
22
24
  return tracer.startActiveSpan(
23
25
  name,
@@ -40,8 +42,9 @@ export async function recordSpan<T>({
40
42
  try {
41
43
  recordErrorOnSpan(span, error);
42
44
  } finally {
43
- // always stop the span when there is an error:
44
- span.end();
45
+ if (endOnError) {
46
+ span.end();
47
+ }
45
48
  }
46
49
 
47
50
  throw error;
@@ -77,6 +77,7 @@ class MockSpan implements Span {
77
77
  time?: [number, number];
78
78
  }> = [];
79
79
  status?: SpanStatus;
80
+ endCalls = 0;
80
81
 
81
82
  readonly _spanContext: SpanContext = new MockSpanContext();
82
83
 
@@ -128,6 +129,7 @@ class MockSpan implements Span {
128
129
  return this;
129
130
  }
130
131
  end() {
132
+ this.endCalls++;
131
133
  return this;
132
134
  }
133
135
  isRecording() {
@@ -51,5 +51,5 @@ export type Provider = {
51
51
  *
52
52
  * @throws {NoSuchModelError} If no such model exists.
53
53
  */
54
- rerankingModel(modelId: string): RerankingModel;
54
+ rerankingModel?(modelId: string): RerankingModel;
55
55
  };
package/src/ui/chat.ts CHANGED
@@ -706,7 +706,7 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
706
706
  const response = {
707
707
  state: createStreamingUIMessageState({
708
708
  lastMessage:
709
- trigger === 'regenerate-message'
709
+ trigger === 'resume-stream' || trigger === 'regenerate-message'
710
710
  ? undefined
711
711
  : this.state.snapshot(lastMessage),
712
712
  messageId: this.generateId(),
@@ -846,15 +846,13 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
846
846
  finishReason: activeResponse.state.finishReason,
847
847
  });
848
848
  }
849
- } catch (err) {
850
- console.error(err);
851
- }
849
+ } finally {
850
+ if (this.activeResponse === activeResponse) {
851
+ this.activeResponse = undefined;
852
+ }
852
853
 
853
- if (this.activeResponse === activeResponse) {
854
- this.activeResponse = undefined;
854
+ clearActiveResumeRequest();
855
855
  }
856
-
857
- clearActiveResumeRequest();
858
856
  }
859
857
 
860
858
  // automatically send the message if the sendAutomaticallyWhen function returns true