@ai-sdk/workflow 1.0.50 → 1.0.52
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 +18 -0
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/workflow-agent.ts +16 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/workflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "WorkflowAgent for building AI agents with AI SDK",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"ajv": "^8.20.0",
|
|
30
30
|
"@ai-sdk/provider": "4.0.5",
|
|
31
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
32
|
-
"ai": "7.0.
|
|
31
|
+
"@ai-sdk/provider-utils": "5.0.21",
|
|
32
|
+
"ai": "7.0.52"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "22.19.19",
|
package/src/workflow-agent.ts
CHANGED
|
@@ -2363,6 +2363,10 @@ export class WorkflowAgent<
|
|
|
2363
2363
|
// Emit tool-approval-request chunks for tools that need approval
|
|
2364
2364
|
// so useChat can show the approval UI
|
|
2365
2365
|
if (options.writable) {
|
|
2366
|
+
if (allToolResults.length > 0) {
|
|
2367
|
+
await writeToolResults(options.writable, allToolResults);
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2366
2370
|
const approvalToolCalls = pausedToolCalls.filter((_, i) => {
|
|
2367
2371
|
const tcIndex = nonProviderToolCalls.indexOf(
|
|
2368
2372
|
pausedToolCalls[i],
|
|
@@ -2471,7 +2475,7 @@ export class WorkflowAgent<
|
|
|
2471
2475
|
// UI can transition tool parts to output-available state and
|
|
2472
2476
|
// properly separate multi-step model calls in the message history.
|
|
2473
2477
|
if (options.writable) {
|
|
2474
|
-
await
|
|
2478
|
+
await writeToolResults(
|
|
2475
2479
|
options.writable,
|
|
2476
2480
|
executedToolResults.map(r => ({
|
|
2477
2481
|
toolCallId: r.modelResult.toolCallId,
|
|
@@ -2481,6 +2485,7 @@ export class WorkflowAgent<
|
|
|
2481
2485
|
)?.input,
|
|
2482
2486
|
output: r.rawOutput,
|
|
2483
2487
|
})),
|
|
2488
|
+
true,
|
|
2484
2489
|
);
|
|
2485
2490
|
}
|
|
2486
2491
|
|
|
@@ -2695,7 +2700,7 @@ async function writeApprovalRequests(
|
|
|
2695
2700
|
}
|
|
2696
2701
|
}
|
|
2697
2702
|
|
|
2698
|
-
async function
|
|
2703
|
+
async function writeToolResults(
|
|
2699
2704
|
writable: WritableStream<any>,
|
|
2700
2705
|
results: Array<{
|
|
2701
2706
|
toolCallId: string;
|
|
@@ -2703,6 +2708,7 @@ async function writeToolResultsWithStepBoundary(
|
|
|
2703
2708
|
input: unknown;
|
|
2704
2709
|
output: unknown;
|
|
2705
2710
|
}>,
|
|
2711
|
+
writeStepBoundary = false,
|
|
2706
2712
|
) {
|
|
2707
2713
|
'use step';
|
|
2708
2714
|
const writer = writable.getWriter();
|
|
@@ -2716,12 +2722,14 @@ async function writeToolResultsWithStepBoundary(
|
|
|
2716
2722
|
output: r.output,
|
|
2717
2723
|
});
|
|
2718
2724
|
}
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
+
if (writeStepBoundary) {
|
|
2726
|
+
// Emit step boundaries so the UI message history properly separates
|
|
2727
|
+
// the tool call step from the subsequent text step. This ensures
|
|
2728
|
+
// convertToModelMessages creates separate assistant messages for
|
|
2729
|
+
// tool calls and text responses.
|
|
2730
|
+
await writer.write({ type: 'finish-step' });
|
|
2731
|
+
await writer.write({ type: 'start-step' });
|
|
2732
|
+
}
|
|
2725
2733
|
} finally {
|
|
2726
2734
|
writer.releaseLock();
|
|
2727
2735
|
}
|