@ai-sdk/workflow 2.0.8 → 2.0.12
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 +39 -0
- package/README.md +25 -0
- package/dist/chunk-UAWBPTDW.js +51 -0
- package/dist/chunk-UAWBPTDW.js.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/video.d.ts +24 -0
- package/dist/video.js +80 -0
- package/dist/video.js.map +1 -0
- package/package.json +12 -7
- package/src/generate-video.ts +120 -0
- package/src/normalize-ui-message-stream.ts +16 -16
- package/src/serializable-schema.ts +12 -4
- package/src/test/serializable-video-model.ts +87 -0
- package/src/test/video-generation-workflow.ts +11 -0
- package/src/video.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @ai-sdk/workflow
|
|
2
2
|
|
|
3
|
+
## 2.0.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [3e125ba]
|
|
8
|
+
- ai@7.0.82
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.32
|
|
10
|
+
|
|
11
|
+
## 2.0.11
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- aed8ff3: Add durable video generation that waits for a Workflow webhook and returns provider video data without downloading hosted URLs.
|
|
16
|
+
- ai@7.0.81
|
|
17
|
+
|
|
18
|
+
## 2.0.10
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- e21bde7: Preserve function tool input examples and provider options across workflow step boundaries.
|
|
23
|
+
- Updated dependencies [a9782e1]
|
|
24
|
+
- Updated dependencies [35841f5]
|
|
25
|
+
- Updated dependencies [d2f3353]
|
|
26
|
+
- Updated dependencies [eed7950]
|
|
27
|
+
- @ai-sdk/provider-utils@5.0.31
|
|
28
|
+
- ai@7.0.80
|
|
29
|
+
|
|
30
|
+
## 2.0.9
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- b251584: Preserve active text and reasoning parts when another merged UI message stream finishes a step, and align workflow stream normalization with the explicit part end chunks.
|
|
35
|
+
- Updated dependencies [b251584]
|
|
36
|
+
- Updated dependencies [591d25b]
|
|
37
|
+
- Updated dependencies [9de0baf]
|
|
38
|
+
- ai@7.0.79
|
|
39
|
+
- @ai-sdk/provider@4.0.8
|
|
40
|
+
- @ai-sdk/provider-utils@5.0.30
|
|
41
|
+
|
|
3
42
|
## 2.0.8
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -42,6 +42,30 @@ console.log('Final messages:', result.messages);
|
|
|
42
42
|
console.log('Steps:', result.steps);
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
### Durable video generation
|
|
46
|
+
|
|
47
|
+
`experimental_generateVideo` starts asynchronous video generation, suspends the
|
|
48
|
+
workflow until a provider webhook arrives, and returns the provider's video
|
|
49
|
+
data without downloading hosted URLs.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { experimental_generateVideo as generateVideo } from '@ai-sdk/workflow/video';
|
|
53
|
+
|
|
54
|
+
export async function videoWorkflow(prompt: string) {
|
|
55
|
+
'use workflow';
|
|
56
|
+
|
|
57
|
+
const result = await generateVideo({
|
|
58
|
+
model: 'klingai/kling-v3.0-t2v',
|
|
59
|
+
prompt,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return result.videos;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The workflow can persist, copy, or process each returned video URL in a
|
|
67
|
+
separate step without serializing the video bytes through the workflow.
|
|
68
|
+
|
|
45
69
|
## Features
|
|
46
70
|
|
|
47
71
|
- **Streaming Support**: Stream responses in real-time
|
|
@@ -52,6 +76,7 @@ console.log('Steps:', result.steps);
|
|
|
52
76
|
- **Step Callbacks**: Hook into each step of the agent loop
|
|
53
77
|
- **Provider-Executed Tools**: Support for provider-executed tools
|
|
54
78
|
- **Abort Support**: Cancel operations with AbortSignal
|
|
79
|
+
- **Durable Video Generation**: Suspend on video webhooks without polling or automatically downloading hosted videos
|
|
55
80
|
|
|
56
81
|
## API
|
|
57
82
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __using = (stack, value, async) => {
|
|
6
|
+
if (value != null) {
|
|
7
|
+
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
|
|
8
|
+
var dispose, inner;
|
|
9
|
+
if (async) dispose = value[__knownSymbol("asyncDispose")];
|
|
10
|
+
if (dispose === void 0) {
|
|
11
|
+
dispose = value[__knownSymbol("dispose")];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") __typeError("Object not disposable");
|
|
15
|
+
if (inner) dispose = function() {
|
|
16
|
+
try {
|
|
17
|
+
inner.call(this);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return Promise.reject(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
stack.push([async, dispose, value]);
|
|
23
|
+
} else if (async) {
|
|
24
|
+
stack.push([async]);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __callDispose = (stack, error, hasError) => {
|
|
29
|
+
var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
|
|
30
|
+
return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
|
|
31
|
+
};
|
|
32
|
+
var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
|
|
33
|
+
var next = (it) => {
|
|
34
|
+
while (it = stack.pop()) {
|
|
35
|
+
try {
|
|
36
|
+
var result = it[1] && it[1].call(it[2]);
|
|
37
|
+
if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
fail(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (hasError) throw error;
|
|
43
|
+
};
|
|
44
|
+
return next();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
__using,
|
|
49
|
+
__callDispose
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=chunk-UAWBPTDW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1188,10 +1188,9 @@ declare class WorkflowChatTransport<UI_MESSAGE extends UIMessage> implements Cha
|
|
|
1188
1188
|
* whole turn. Two properties of the durable streaming model make that error
|
|
1189
1189
|
* reachable:
|
|
1190
1190
|
*
|
|
1191
|
-
* - A workflow run owns a single shared stream
|
|
1192
|
-
*
|
|
1193
|
-
*
|
|
1194
|
-
* `*-start` across a step boundary orphans the rest of that step's content.
|
|
1191
|
+
* - A workflow run owns a single shared stream. Multi-step turns can reuse the
|
|
1192
|
+
* same part id (commonly `"0"`), so a dropped or duplicated `*-start` can
|
|
1193
|
+
* orphan the rest of that part's content.
|
|
1195
1194
|
* - The same stream is read across reconnects, and a stream-producing step can
|
|
1196
1195
|
* run more than once (retry/redelivery, or the concurrent-worker duplication
|
|
1197
1196
|
* tracked in vercel/workflow#2331 and #2039). Either can interleave or
|
|
@@ -1204,11 +1203,12 @@ declare class WorkflowChatTransport<UI_MESSAGE extends UIMessage> implements Cha
|
|
|
1204
1203
|
*
|
|
1205
1204
|
* ## What it does
|
|
1206
1205
|
*
|
|
1207
|
-
* Mirrors the consumer's part-lifetime state machine
|
|
1208
|
-
* -
|
|
1206
|
+
* Mirrors the consumer's explicit-end part-lifetime state machine per part type:
|
|
1207
|
+
* - keeps open parts active across `finish-step`, while allowing ended ids to
|
|
1208
|
+
* be reused by a later step;
|
|
1209
1209
|
* - synthesizes a missing `*-start` when an orphaned `*-delta`/`*-end` arrives;
|
|
1210
1210
|
* - drops a re-delivered `*-start`/`*-delta`/`*-end` for a part already
|
|
1211
|
-
* open or ended
|
|
1211
|
+
* open or ended since the latest step boundary (reconnect/replay overlap).
|
|
1212
1212
|
*
|
|
1213
1213
|
* A well-formed stream passes through unchanged.
|
|
1214
1214
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "./chunk-UAWBPTDW.js";
|
|
2
|
+
|
|
1
3
|
// src/workflow-agent.ts
|
|
2
4
|
import {
|
|
3
5
|
getErrorMessage,
|
|
@@ -102,7 +104,9 @@ function serializeToolSet(tools, {
|
|
|
102
104
|
toolsContext,
|
|
103
105
|
experimental_sandbox: sandbox
|
|
104
106
|
}),
|
|
105
|
-
inputSchema: asSchema(t.inputSchema).jsonSchema
|
|
107
|
+
inputSchema: asSchema(t.inputSchema).jsonSchema,
|
|
108
|
+
inputExamples: t.inputExamples,
|
|
109
|
+
providerOptions: t.providerOptions
|
|
106
110
|
};
|
|
107
111
|
if (t.type === "provider") {
|
|
108
112
|
def.type = "provider";
|
|
@@ -138,7 +142,8 @@ function resolveSerializableTools(tools) {
|
|
|
138
142
|
id: t.id,
|
|
139
143
|
args: (_a = t.args) != null ? _a : {},
|
|
140
144
|
isProviderExecuted: (_b = t.isProviderExecuted) != null ? _b : false,
|
|
141
|
-
inputSchema: jsonSchema(t.inputSchema)
|
|
145
|
+
inputSchema: jsonSchema(t.inputSchema),
|
|
146
|
+
providerOptions: t.providerOptions
|
|
142
147
|
})
|
|
143
148
|
];
|
|
144
149
|
}
|
|
@@ -147,6 +152,8 @@ function resolveSerializableTools(tools) {
|
|
|
147
152
|
name,
|
|
148
153
|
tool({
|
|
149
154
|
description: t.description,
|
|
155
|
+
inputExamples: t.inputExamples,
|
|
156
|
+
providerOptions: t.providerOptions,
|
|
150
157
|
inputSchema: jsonSchema(t.inputSchema, {
|
|
151
158
|
validate: (value) => {
|
|
152
159
|
if (validateFn(value)) {
|
|
@@ -2350,9 +2357,7 @@ async function* normalizeUIMessageStreamParts(source) {
|
|
|
2350
2357
|
yield chunk;
|
|
2351
2358
|
break;
|
|
2352
2359
|
case "finish-step":
|
|
2353
|
-
text.open.clear();
|
|
2354
2360
|
text.ended.clear();
|
|
2355
|
-
reasoning.open.clear();
|
|
2356
2361
|
reasoning.ended.clear();
|
|
2357
2362
|
yield chunk;
|
|
2358
2363
|
break;
|