@ai-sdk/workflow 2.0.18 → 2.0.19
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 +11 -0
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/stream-text-iterator.ts +1 -1
- package/src/workflow-agent.ts +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/workflow
|
|
2
2
|
|
|
3
|
+
## 2.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 902ce3b: fix(workflow): respect empty activeTools lists
|
|
8
|
+
- c143af4: fix(workflow): propagate agent abort signals to local tool executions
|
|
9
|
+
- Updated dependencies [5190b67]
|
|
10
|
+
- @ai-sdk/provider@4.0.10
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.35
|
|
12
|
+
- ai@7.0.89
|
|
13
|
+
|
|
3
14
|
## 2.0.18
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
createRestrictedTelemetryDispatcher as createRestrictedTelemetryDispatcher2,
|
|
17
17
|
collectToolApprovals,
|
|
18
18
|
convertToLanguageModelPrompt,
|
|
19
|
+
mergeAbortSignals,
|
|
19
20
|
mergeCallbacks,
|
|
20
21
|
signToolApproval,
|
|
21
22
|
standardizePrompt,
|
|
@@ -511,7 +512,7 @@ async function* streamTextIterator({
|
|
|
511
512
|
toolsContext: currentToolsContext
|
|
512
513
|
}));
|
|
513
514
|
try {
|
|
514
|
-
const effectiveTools = currentActiveTools
|
|
515
|
+
const effectiveTools = currentActiveTools !== void 0 ? (_d = filterActiveTools({
|
|
515
516
|
tools,
|
|
516
517
|
activeTools: currentActiveTools
|
|
517
518
|
})) != null ? _d : tools : tools;
|
|
@@ -941,6 +942,11 @@ var WorkflowAgent = class {
|
|
|
941
942
|
});
|
|
942
943
|
const download = effectiveDownloadFromPrepare;
|
|
943
944
|
const sandbox = (_n = options.experimental_sandbox) != null ? _n : this.experimentalSandbox;
|
|
945
|
+
const effectiveAbortSignal = mergeAbortSignals(
|
|
946
|
+
(_o = options.abortSignal) != null ? _o : effectiveGenerationSettings.abortSignal,
|
|
947
|
+
options.timeout
|
|
948
|
+
);
|
|
949
|
+
const timeoutAt = options.timeout == null ? void 0 : Date.now() + options.timeout;
|
|
944
950
|
const mergedOnToolExecutionStart = mergeCallbacks(
|
|
945
951
|
this.constructorOnToolExecutionStart,
|
|
946
952
|
options.onToolExecutionStart
|
|
@@ -1029,7 +1035,7 @@ var WorkflowAgent = class {
|
|
|
1029
1035
|
invalidToolApprovals[0].error
|
|
1030
1036
|
);
|
|
1031
1037
|
} else if (policyDenied.length > 0) {
|
|
1032
|
-
revalidationReason = (
|
|
1038
|
+
revalidationReason = (_p = policyDenied[0].approvalResponse.reason) != null ? _p : "Tool approval denied";
|
|
1033
1039
|
}
|
|
1034
1040
|
} catch (error) {
|
|
1035
1041
|
revalidationReason = getErrorMessage(error);
|
|
@@ -1134,8 +1140,6 @@ var WorkflowAgent = class {
|
|
|
1134
1140
|
supportedUrls: {},
|
|
1135
1141
|
download
|
|
1136
1142
|
});
|
|
1137
|
-
const effectiveAbortSignal = (_p = options.abortSignal) != null ? _p : effectiveGenerationSettings.abortSignal;
|
|
1138
|
-
const timeoutAt = options.timeout == null ? void 0 : Date.now() + options.timeout;
|
|
1139
1143
|
const mergedGenerationSettings = {
|
|
1140
1144
|
...effectiveGenerationSettings,
|
|
1141
1145
|
...options.maxOutputTokens !== void 0 && {
|
|
@@ -1190,7 +1194,7 @@ var WorkflowAgent = class {
|
|
|
1190
1194
|
);
|
|
1191
1195
|
const effectiveToolChoice = effectiveToolChoiceFromPrepare;
|
|
1192
1196
|
const effectiveActiveTools = effectiveActiveToolsFromPrepare;
|
|
1193
|
-
const effectiveTools = effectiveActiveTools
|
|
1197
|
+
const effectiveTools = effectiveActiveTools !== void 0 ? (_u = filterActiveTools2({
|
|
1194
1198
|
tools: this.tools,
|
|
1195
1199
|
activeTools: effectiveActiveTools
|
|
1196
1200
|
})) != null ? _u : this.tools : this.tools;
|
|
@@ -1272,6 +1276,7 @@ var WorkflowAgent = class {
|
|
|
1272
1276
|
tools,
|
|
1273
1277
|
messages2,
|
|
1274
1278
|
resolvedContext,
|
|
1279
|
+
effectiveAbortSignal,
|
|
1275
1280
|
download,
|
|
1276
1281
|
stepSandbox
|
|
1277
1282
|
);
|
|
@@ -2119,7 +2124,7 @@ function getToolCallbackMessages(messages) {
|
|
|
2119
2124
|
const withoutAssistantToolCall = ((_a = messages.at(-1)) == null ? void 0 : _a.role) === "assistant" ? messages.slice(0, -1) : messages;
|
|
2120
2125
|
return withoutAssistantToolCall;
|
|
2121
2126
|
}
|
|
2122
|
-
async function executeTool(toolCall, tools, messages, context, download, sandbox) {
|
|
2127
|
+
async function executeTool(toolCall, tools, messages, context, abortSignal, download, sandbox) {
|
|
2123
2128
|
const tool2 = tools[toolCall.toolName];
|
|
2124
2129
|
if (!tool2) throw new Error(`Tool "${toolCall.toolName}" not found`);
|
|
2125
2130
|
if (typeof tool2.execute !== "function") {
|
|
@@ -2135,6 +2140,8 @@ async function executeTool(toolCall, tools, messages, context, download, sandbox
|
|
|
2135
2140
|
toolCallId: toolCall.toolCallId,
|
|
2136
2141
|
// Pass the conversation messages to the tool so it has context about the conversation
|
|
2137
2142
|
messages,
|
|
2143
|
+
// Pass the effective agent signal so in-flight tool work can cooperatively cancel
|
|
2144
|
+
abortSignal,
|
|
2138
2145
|
// Pass per-tool context to the tool (resolved from `toolsContext`)
|
|
2139
2146
|
context,
|
|
2140
2147
|
experimental_sandbox: sandbox
|