@ai-sdk/workflow 0.0.0-bf6e4b15-20260402200305
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 +52 -0
- package/LICENSE +13 -0
- package/README.md +62 -0
- package/dist/index.d.mts +739 -0
- package/dist/index.mjs +1261 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +77 -0
- package/src/do-stream-step.ts +329 -0
- package/src/index.ts +37 -0
- package/src/providers/mock-function-wrapper.ts +11 -0
- package/src/providers/mock.ts +123 -0
- package/src/serializable-schema.ts +81 -0
- package/src/stream-iterator.ts +46 -0
- package/src/stream-text-iterator.ts +444 -0
- package/src/telemetry.ts +199 -0
- package/src/test/agent-e2e-workflows.ts +507 -0
- package/src/test/calculate-workflow.ts +19 -0
- package/src/to-ui-message-chunk.ts +214 -0
- package/src/types.ts +11 -0
- package/src/workflow-agent.ts +1647 -0
- package/src/workflow-chat-transport.ts +359 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @ai-sdk/workflow
|
|
2
|
+
|
|
3
|
+
## 0.0.0-bf6e4b15-20260402200305
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0746eb5: initial version
|
|
8
|
+
- Updated dependencies [b56301c]
|
|
9
|
+
- Updated dependencies [986c6fd]
|
|
10
|
+
- Updated dependencies [5ceed7d]
|
|
11
|
+
- Updated dependencies [ff9ce30]
|
|
12
|
+
- Updated dependencies [99bf941]
|
|
13
|
+
- Updated dependencies [6a3793e]
|
|
14
|
+
- Updated dependencies [31ee822]
|
|
15
|
+
- Updated dependencies [531251e]
|
|
16
|
+
- Updated dependencies [9b47dea]
|
|
17
|
+
- Updated dependencies [877bf12]
|
|
18
|
+
- Updated dependencies [5d0f18e]
|
|
19
|
+
- Updated dependencies [80d4dde]
|
|
20
|
+
- Updated dependencies [1f509d4]
|
|
21
|
+
- Updated dependencies [5c2a5a2]
|
|
22
|
+
- Updated dependencies [caf1b6f]
|
|
23
|
+
- Updated dependencies [f7d4f01]
|
|
24
|
+
- Updated dependencies [776b617]
|
|
25
|
+
- Updated dependencies [2e17091]
|
|
26
|
+
- Updated dependencies [210ed3d]
|
|
27
|
+
- Updated dependencies [a3fd75b]
|
|
28
|
+
- Updated dependencies [1fe058b]
|
|
29
|
+
- Updated dependencies [5c4d910]
|
|
30
|
+
- Updated dependencies [34fd051]
|
|
31
|
+
- Updated dependencies [3debdb7]
|
|
32
|
+
- Updated dependencies [493295c]
|
|
33
|
+
- Updated dependencies [c26ca8d]
|
|
34
|
+
- Updated dependencies [118b953]
|
|
35
|
+
- Updated dependencies [ebd4da2]
|
|
36
|
+
- Updated dependencies [bc67b4f]
|
|
37
|
+
- Updated dependencies [f0b0b20]
|
|
38
|
+
- Updated dependencies [3887c70]
|
|
39
|
+
- Updated dependencies [989d3d2]
|
|
40
|
+
- Updated dependencies [61753c3]
|
|
41
|
+
- Updated dependencies [6abd098]
|
|
42
|
+
- Updated dependencies [4b46062]
|
|
43
|
+
- Updated dependencies [8359612]
|
|
44
|
+
- Updated dependencies [e79e644]
|
|
45
|
+
- Updated dependencies [b3c9f6a]
|
|
46
|
+
- Updated dependencies [b9cf502]
|
|
47
|
+
- Updated dependencies [f4cfccd]
|
|
48
|
+
- Updated dependencies [5b8c58f]
|
|
49
|
+
- Updated dependencies [f5a6f89]
|
|
50
|
+
- ai@0.0.0-bf6e4b15-20260402200305
|
|
51
|
+
- @ai-sdk/provider-utils@0.0.0-bf6e4b15-20260402200305
|
|
52
|
+
- @ai-sdk/provider@0.0.0-bf6e4b15-20260402200305
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @ai-sdk/workflow
|
|
2
|
+
|
|
3
|
+
WorkflowAgent is a class for building durable AI agents that can maintain state across workflow steps, call tools, and handle interruptions gracefully.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ai-sdk/workflow ai
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { WorkflowAgent } from '@ai-sdk/workflow';
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
|
|
17
|
+
const agent = new WorkflowAgent({
|
|
18
|
+
model: 'anthropic/claude-opus',
|
|
19
|
+
tools: {
|
|
20
|
+
getWeather: {
|
|
21
|
+
description: 'Get weather for a location',
|
|
22
|
+
inputSchema: z.object({ location: z.string() }),
|
|
23
|
+
execute: async ({ location }) => {
|
|
24
|
+
// Fetch weather data
|
|
25
|
+
return { temperature: 72, condition: 'sunny' };
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
system: 'You are a helpful weather assistant.',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const result = await agent.stream({
|
|
33
|
+
messages: [{ role: 'user', content: 'What is the weather in SF?' }],
|
|
34
|
+
writable: new WritableStream({
|
|
35
|
+
write(chunk) {
|
|
36
|
+
console.log('Chunk:', chunk);
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log('Final messages:', result.messages);
|
|
42
|
+
console.log('Steps:', result.steps);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- **Streaming Support**: Stream responses in real-time
|
|
48
|
+
- **Tool Calling**: Execute tools dynamically during conversation
|
|
49
|
+
- **Context Management**: Pass context between steps
|
|
50
|
+
- **Error Handling**: Robust error handling with callbacks
|
|
51
|
+
- **Structured Output**: Parse structured outputs from LLM responses
|
|
52
|
+
- **Step Callbacks**: Hook into each step of the agent loop
|
|
53
|
+
- **Provider-Executed Tools**: Support for provider-executed tools
|
|
54
|
+
- **Abort Support**: Cancel operations with AbortSignal
|
|
55
|
+
|
|
56
|
+
## API
|
|
57
|
+
|
|
58
|
+
See the [AI SDK documentation](https://ai-sdk.dev/docs) for full API details.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
Apache-2.0
|