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.
- package/CHANGELOG.md +26 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/package.json +3 -3
- package/src/agent/tool-loop-agent-settings.ts +1 -0
- package/src/agent/tool-loop-agent.ts +8 -4
- package/src/generate-object/stream-object.ts +2 -0
- package/src/generate-text/stream-text.ts +1 -0
- package/src/telemetry/record-span.ts +5 -2
- package/src/test/mock-tracer.ts +2 -0
- package/src/types/provider.ts +1 -1
- package/src/ui/chat.ts +6 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.252
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2f96d3f: Allow providers without reranking model support to satisfy the `Provider` type.
|
|
8
|
+
- afb1965: Propagate errors thrown by the Chat `onFinish` callback to the initiating request.
|
|
9
|
+
- Updated dependencies [18b0965]
|
|
10
|
+
- Updated dependencies [451d2c3]
|
|
11
|
+
- @ai-sdk/gateway@3.0.171
|
|
12
|
+
|
|
13
|
+
## 6.0.251
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- d13c2e9: Respect ToolLoopAgent timeouts configured in agent settings.
|
|
18
|
+
|
|
19
|
+
## 6.0.250
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- a077695: Prevent streaming telemetry spans from ending twice when model calls fail.
|
|
24
|
+
- 7ce3b8c: Prevent `resumeStream` from copying the previous assistant message into the resumed response.
|
|
25
|
+
- Updated dependencies [b2a4d5a]
|
|
26
|
+
- @ai-sdk/provider-utils@4.0.45
|
|
27
|
+
- @ai-sdk/gateway@3.0.170
|
|
28
|
+
|
|
3
29
|
## 6.0.249
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -205,7 +205,7 @@ type Provider = {
|
|
|
205
205
|
*
|
|
206
206
|
* @throws {NoSuchModelError} If no such model exists.
|
|
207
207
|
*/
|
|
208
|
-
rerankingModel(modelId: string): RerankingModel;
|
|
208
|
+
rerankingModel?(modelId: string): RerankingModel;
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
/**
|
|
@@ -3357,7 +3357,7 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUT
|
|
|
3357
3357
|
* }),
|
|
3358
3358
|
* ```
|
|
3359
3359
|
*/
|
|
3360
|
-
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
|
|
3360
|
+
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'timeout' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
|
|
3361
3361
|
};
|
|
3362
3362
|
|
|
3363
3363
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -205,7 +205,7 @@ type Provider = {
|
|
|
205
205
|
*
|
|
206
206
|
* @throws {NoSuchModelError} If no such model exists.
|
|
207
207
|
*/
|
|
208
|
-
rerankingModel(modelId: string): RerankingModel;
|
|
208
|
+
rerankingModel?(modelId: string): RerankingModel;
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
/**
|
|
@@ -3357,7 +3357,7 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUT
|
|
|
3357
3357
|
* }),
|
|
3358
3358
|
* ```
|
|
3359
3359
|
*/
|
|
3360
|
-
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
|
|
3360
|
+
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'timeout' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
|
|
3361
3361
|
};
|
|
3362
3362
|
|
|
3363
3363
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1304,7 +1304,7 @@ function detectMediaType({
|
|
|
1304
1304
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1305
1305
|
|
|
1306
1306
|
// src/version.ts
|
|
1307
|
-
var VERSION = true ? "6.0.
|
|
1307
|
+
var VERSION = true ? "6.0.252" : "0.0.0-test";
|
|
1308
1308
|
|
|
1309
1309
|
// src/util/download/download.ts
|
|
1310
1310
|
var download = async ({
|
|
@@ -2532,7 +2532,8 @@ async function recordSpan({
|
|
|
2532
2532
|
tracer,
|
|
2533
2533
|
attributes,
|
|
2534
2534
|
fn,
|
|
2535
|
-
endWhenDone = true
|
|
2535
|
+
endWhenDone = true,
|
|
2536
|
+
endOnError = endWhenDone
|
|
2536
2537
|
}) {
|
|
2537
2538
|
return tracer.startActiveSpan(
|
|
2538
2539
|
name22,
|
|
@@ -2549,7 +2550,9 @@ async function recordSpan({
|
|
|
2549
2550
|
try {
|
|
2550
2551
|
recordErrorOnSpan(span, error);
|
|
2551
2552
|
} finally {
|
|
2552
|
-
|
|
2553
|
+
if (endOnError) {
|
|
2554
|
+
span.end();
|
|
2555
|
+
}
|
|
2553
2556
|
}
|
|
2554
2557
|
throw error;
|
|
2555
2558
|
}
|
|
@@ -7901,6 +7904,7 @@ var DefaultStreamTextResult = class {
|
|
|
7901
7904
|
}),
|
|
7902
7905
|
tracer,
|
|
7903
7906
|
endWhenDone: false,
|
|
7907
|
+
endOnError: true,
|
|
7904
7908
|
fn: async (doStreamSpan2) => ({
|
|
7905
7909
|
startTimestampMs: now2(),
|
|
7906
7910
|
// get before the call
|
|
@@ -8906,10 +8910,11 @@ var ToolLoopAgent = class {
|
|
|
8906
8910
|
onStepFinish,
|
|
8907
8911
|
...options
|
|
8908
8912
|
}) {
|
|
8913
|
+
const preparedCall = await this.prepareCall(options);
|
|
8909
8914
|
return generateText({
|
|
8910
|
-
...
|
|
8915
|
+
...preparedCall,
|
|
8911
8916
|
abortSignal,
|
|
8912
|
-
timeout,
|
|
8917
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
8913
8918
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
8914
8919
|
});
|
|
8915
8920
|
}
|
|
@@ -8923,10 +8928,11 @@ var ToolLoopAgent = class {
|
|
|
8923
8928
|
onStepFinish,
|
|
8924
8929
|
...options
|
|
8925
8930
|
}) {
|
|
8931
|
+
const preparedCall = await this.prepareCall(options);
|
|
8926
8932
|
return streamText({
|
|
8927
|
-
...
|
|
8933
|
+
...preparedCall,
|
|
8928
8934
|
abortSignal,
|
|
8929
|
-
timeout,
|
|
8935
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
8930
8936
|
experimental_transform,
|
|
8931
8937
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
8932
8938
|
});
|
|
@@ -11399,6 +11405,7 @@ var DefaultStreamObjectResult = class {
|
|
|
11399
11405
|
}),
|
|
11400
11406
|
tracer,
|
|
11401
11407
|
endWhenDone: false,
|
|
11408
|
+
endOnError: true,
|
|
11402
11409
|
fn: async (rootSpan) => {
|
|
11403
11410
|
const standardizedPrompt = await standardizePrompt({
|
|
11404
11411
|
system,
|
|
@@ -11470,6 +11477,7 @@ var DefaultStreamObjectResult = class {
|
|
|
11470
11477
|
}),
|
|
11471
11478
|
tracer,
|
|
11472
11479
|
endWhenDone: false,
|
|
11480
|
+
endOnError: true,
|
|
11473
11481
|
fn: async (doStreamSpan2) => ({
|
|
11474
11482
|
startTimestampMs: now2(),
|
|
11475
11483
|
doStreamSpan: doStreamSpan2,
|
|
@@ -14041,7 +14049,7 @@ var AbstractChat = class {
|
|
|
14041
14049
|
try {
|
|
14042
14050
|
const response = {
|
|
14043
14051
|
state: createStreamingUIMessageState({
|
|
14044
|
-
lastMessage: trigger === "regenerate-message" ? void 0 : this.state.snapshot(lastMessage),
|
|
14052
|
+
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? void 0 : this.state.snapshot(lastMessage),
|
|
14045
14053
|
messageId: this.generateId()
|
|
14046
14054
|
}),
|
|
14047
14055
|
abortController
|
|
@@ -14150,13 +14158,12 @@ var AbstractChat = class {
|
|
|
14150
14158
|
finishReason: activeResponse.state.finishReason
|
|
14151
14159
|
});
|
|
14152
14160
|
}
|
|
14153
|
-
}
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14161
|
+
} finally {
|
|
14162
|
+
if (this.activeResponse === activeResponse) {
|
|
14163
|
+
this.activeResponse = void 0;
|
|
14164
|
+
}
|
|
14165
|
+
clearActiveResumeRequest();
|
|
14158
14166
|
}
|
|
14159
|
-
clearActiveResumeRequest();
|
|
14160
14167
|
}
|
|
14161
14168
|
if (!isError && await this.shouldSendAutomatically()) {
|
|
14162
14169
|
await this.makeRequest({
|