ai 3.4.11 → 3.4.13
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 +12 -0
- package/dist/index.d.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 3.4.13
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- fc39158: fix (ai/core): add abortSignal to tool helper function
|
8
|
+
|
9
|
+
## 3.4.12
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- a23da5b: feat (ai/core): forward abort signal to tools
|
14
|
+
|
3
15
|
## 3.4.11
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -1233,16 +1233,25 @@ interface CoreTool<PARAMETERS extends Parameters = any, RESULT = any> {
|
|
1233
1233
|
/**
|
1234
1234
|
An async function that is called with the arguments from the tool call and produces a result.
|
1235
1235
|
If not provided, the tool will not be executed automatically.
|
1236
|
+
|
1237
|
+
@args is the input of the tool call.
|
1238
|
+
@options.abortSignal is a signal that can be used to abort the tool call.
|
1236
1239
|
*/
|
1237
|
-
execute?: (args: inferParameters<PARAMETERS
|
1240
|
+
execute?: (args: inferParameters<PARAMETERS>, options: {
|
1241
|
+
abortSignal?: AbortSignal;
|
1242
|
+
}) => PromiseLike<RESULT>;
|
1238
1243
|
}
|
1239
1244
|
/**
|
1240
1245
|
Helper function for inferring the execute args of a tool.
|
1241
1246
|
*/
|
1242
1247
|
declare function tool<PARAMETERS extends Parameters, RESULT>(tool: CoreTool<PARAMETERS, RESULT> & {
|
1243
|
-
execute: (args: inferParameters<PARAMETERS
|
1248
|
+
execute: (args: inferParameters<PARAMETERS>, options: {
|
1249
|
+
abortSignal?: AbortSignal;
|
1250
|
+
}) => PromiseLike<RESULT>;
|
1244
1251
|
}): CoreTool<PARAMETERS, RESULT> & {
|
1245
|
-
execute: (args: inferParameters<PARAMETERS
|
1252
|
+
execute: (args: inferParameters<PARAMETERS>, options: {
|
1253
|
+
abortSignal?: AbortSignal;
|
1254
|
+
}) => PromiseLike<RESULT>;
|
1246
1255
|
};
|
1247
1256
|
declare function tool<PARAMETERS extends Parameters, RESULT>(tool: CoreTool<PARAMETERS, RESULT> & {
|
1248
1257
|
execute?: undefined;
|
package/dist/index.d.ts
CHANGED
@@ -1233,16 +1233,25 @@ interface CoreTool<PARAMETERS extends Parameters = any, RESULT = any> {
|
|
1233
1233
|
/**
|
1234
1234
|
An async function that is called with the arguments from the tool call and produces a result.
|
1235
1235
|
If not provided, the tool will not be executed automatically.
|
1236
|
+
|
1237
|
+
@args is the input of the tool call.
|
1238
|
+
@options.abortSignal is a signal that can be used to abort the tool call.
|
1236
1239
|
*/
|
1237
|
-
execute?: (args: inferParameters<PARAMETERS
|
1240
|
+
execute?: (args: inferParameters<PARAMETERS>, options: {
|
1241
|
+
abortSignal?: AbortSignal;
|
1242
|
+
}) => PromiseLike<RESULT>;
|
1238
1243
|
}
|
1239
1244
|
/**
|
1240
1245
|
Helper function for inferring the execute args of a tool.
|
1241
1246
|
*/
|
1242
1247
|
declare function tool<PARAMETERS extends Parameters, RESULT>(tool: CoreTool<PARAMETERS, RESULT> & {
|
1243
|
-
execute: (args: inferParameters<PARAMETERS
|
1248
|
+
execute: (args: inferParameters<PARAMETERS>, options: {
|
1249
|
+
abortSignal?: AbortSignal;
|
1250
|
+
}) => PromiseLike<RESULT>;
|
1244
1251
|
}): CoreTool<PARAMETERS, RESULT> & {
|
1245
|
-
execute: (args: inferParameters<PARAMETERS
|
1252
|
+
execute: (args: inferParameters<PARAMETERS>, options: {
|
1253
|
+
abortSignal?: AbortSignal;
|
1254
|
+
}) => PromiseLike<RESULT>;
|
1246
1255
|
};
|
1247
1256
|
declare function tool<PARAMETERS extends Parameters, RESULT>(tool: CoreTool<PARAMETERS, RESULT> & {
|
1248
1257
|
execute?: undefined;
|
package/dist/index.js
CHANGED
@@ -3337,7 +3337,8 @@ async function generateText({
|
|
3337
3337
|
toolCalls: currentToolCalls,
|
3338
3338
|
tools,
|
3339
3339
|
tracer,
|
3340
|
-
telemetry
|
3340
|
+
telemetry,
|
3341
|
+
abortSignal
|
3341
3342
|
});
|
3342
3343
|
const currentUsage = calculateLanguageModelUsage(
|
3343
3344
|
currentModelResponse.usage
|
@@ -3467,7 +3468,8 @@ async function executeTools({
|
|
3467
3468
|
toolCalls,
|
3468
3469
|
tools,
|
3469
3470
|
tracer,
|
3470
|
-
telemetry
|
3471
|
+
telemetry,
|
3472
|
+
abortSignal
|
3471
3473
|
}) {
|
3472
3474
|
const toolResults = await Promise.all(
|
3473
3475
|
toolCalls.map(async (toolCall) => {
|
@@ -3493,7 +3495,7 @@ async function executeTools({
|
|
3493
3495
|
}),
|
3494
3496
|
tracer,
|
3495
3497
|
fn: async (span) => {
|
3496
|
-
const result2 = await tool2.execute(toolCall.args);
|
3498
|
+
const result2 = await tool2.execute(toolCall.args, { abortSignal });
|
3497
3499
|
try {
|
3498
3500
|
span.setAttributes(
|
3499
3501
|
selectTelemetryAttributes({
|
@@ -3703,7 +3705,8 @@ function runToolsTransformation({
|
|
3703
3705
|
generatorStream,
|
3704
3706
|
toolCallStreaming,
|
3705
3707
|
tracer,
|
3706
|
-
telemetry
|
3708
|
+
telemetry,
|
3709
|
+
abortSignal
|
3707
3710
|
}) {
|
3708
3711
|
let canClose = false;
|
3709
3712
|
const outstandingToolCalls = /* @__PURE__ */ new Set();
|
@@ -3789,7 +3792,7 @@ function runToolsTransformation({
|
|
3789
3792
|
}
|
3790
3793
|
}),
|
3791
3794
|
tracer,
|
3792
|
-
fn: async (span) => tool2.execute(toolCall.args).then(
|
3795
|
+
fn: async (span) => tool2.execute(toolCall.args, { abortSignal }).then(
|
3793
3796
|
(result) => {
|
3794
3797
|
toolResultsStreamController.enqueue({
|
3795
3798
|
...toolCall,
|
@@ -4010,7 +4013,8 @@ async function streamText({
|
|
4010
4013
|
generatorStream: stream2,
|
4011
4014
|
toolCallStreaming,
|
4012
4015
|
tracer,
|
4013
|
-
telemetry
|
4016
|
+
telemetry,
|
4017
|
+
abortSignal
|
4014
4018
|
}),
|
4015
4019
|
warnings: warnings2,
|
4016
4020
|
rawResponse: rawResponse2
|