@ai-sdk/workflow 1.0.0-canary.93 → 1.0.1

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 CHANGED
@@ -1,5 +1,179 @@
1
1
  # @ai-sdk/workflow
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ai@7.0.1
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 1949571: feat(ai): make experimental_telemetry stable
14
+ - b3976a2: initial version
15
+
16
+ ### Patch Changes
17
+
18
+ - 19736ee: feat(ai): rename onStepFinish to onStepEnd
19
+ - 382d53b: refactoring: rename context to runtimeContext
20
+ - b567a6c: dependency updates
21
+ - b402b95: `WorkflowAgent` now rejects system messages inside `prompt` or `messages` by default, matching the behavior of `generateText`/`streamText`. Set `allowSystemInMessages: true` to opt in to the previous behavior.
22
+ - eea8d98: refactoring: rename tool execution events
23
+ - 98627e5: feat(ai): remove onChunk event from telemetry
24
+ - ca446f8: feat: flexible tool descriptions
25
+ - 75763b0: agents: tag outgoing requests with an ai-sdk-agent user-agent segment for usage attribution (tool-loop, workflow)
26
+ - 9f0e36c: trigger release for all packages after provenance setup
27
+ - 29d8cf4: feat(ai): rename the core-event types
28
+ - 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
29
+ - a0ca584: fix (workflow): preserve invalid tool calls as errors instead of emitting synthetic success results
30
+ - eba685c: Remove `maxSteps` option from `WorkflowAgent`. Use `stopWhen` with stop conditions like `isStepCount()` instead.
31
+ - 0c4c275: trigger initial canary release
32
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
33
+ - 334ae5d: Update step performance metrics with explicit effective, input, output, and total token throughput fields.
34
+ - b8396f0: trigger initial beta release
35
+ - c3d4019: chore(ai): rename 'TelemetrySettings' to 'TelemetryOptions'
36
+ - 083947b: feat(ai): separate toolsContext from context
37
+ - bae5e2b: fix(security): re-validate tool approvals from client message history before execution
38
+
39
+ The approval-replay path in `generateText`/`streamText` (and `WorkflowAgent.stream`) reconstructed approved tool calls from the client-supplied messages array and executed them without re-validating input against the tool's schema or re-applying the approval policy. A client could forge an assistant message with a pre-approved tool-call part and have the server execute a tool with attacker-chosen arguments.
40
+
41
+ The replay path now validates HMAC signature (when `experimental_toolApprovalSecret` is configured), re-validates tool-call input against the tool's input schema, and re-resolves the approval policy before execution.
42
+
43
+ - d775a57: feat: introduce Instructions type
44
+ - f32c750: refactoring(ai): simplify mergeAbortSignals
45
+ - bf6c17b: Add `id` property to WorkflowAgent for telemetry identification, matching ToolLoopAgent's API surface.
46
+ - 3ca592a: Add `prompt` as an alternative to `messages` in `WorkflowAgent.stream()`, matching the `AgentCallParameters` pattern from ToolLoopAgent.
47
+ - eb49d29: Add constructor-level defaults for `stopWhen`, `activeTools`, `output`, `experimental_repairToolCall`, and `experimental_download` to WorkflowAgent, matching ToolLoopAgent's pattern. Stream-level values override constructor defaults.
48
+ - 0455f24: Enrich WorkflowAgent callback event shapes to align with ToolLoopAgent:
49
+ - Add `stepNumber` to `onToolCallStart` and `onToolCallFinish`
50
+ - Add `steps` (previous step results) to `onStepStart`
51
+ - Adopt discriminated union pattern (`success: true/false`) for `onToolCallFinish`
52
+ - Add `durationMs` to `onToolCallFinish`
53
+ - 43543dc: Add `experimental_sandbox` support to `WorkflowAgent`. The sandbox is passed to tool execution, configurable on the constructor or per stream, and available to `prepareStep` for per-step overrides.
54
+ - 0e462a7: Use `LanguageModel` type for model parameter, aligning with `ToolLoopAgent`. Remove async factory model form. Rename callback types to use `WorkflowAgentOn*` prefix.
55
+ - 39dad72: feat(workflow): add stable telemetry integration support to `WorkflowAgent` and remove legacy telemetry options.
56
+ - 1e4b350: Honor `tool.toModelOutput` in `WorkflowAgent`.
57
+
58
+ `WorkflowAgent` now routes successful local, provider-executed, and approved tool results through each tool's optional `toModelOutput` hook, matching `generateText`, `streamText`, and `ToolLoopAgent`. Previously the hook was ignored and results were always serialized as `text` or `json`.
59
+
60
+ Internally exports the shared tool-result model-output helpers from `ai/internal`, and uses the shared `getErrorMessage` behavior for workflow tool error results.
61
+
62
+ - c3a6524: Add a `stepNumber` option to `doStreamStep` so callers can create `StepResult` objects with the correct step number.
63
+ - 907e002: fix (workflow): forward provider-executed tool approvals to the provider on resume
64
+
65
+ `WorkflowAgent` stripped every `tool-approval-request` and `tool-approval-response` part from the messages when resuming after a tool approval, regardless of whether the tool was locally or provider-executed. For provider-executed tools (e.g. MCP via the OpenAI Responses API) this silently dropped the approval before `convertToLanguageModelPrompt` could forward it, so the provider never learned of the approval and the tool was never executed. Local approvals are still executed and stripped, while provider-executed approvals are now preserved and forwarded to the provider, matching the discriminator core's `streamText` already uses. This is the inverse of the bug fixed in #14289.
66
+
67
+ - 1d56275: feat(workflow): add `runtimeContext` and `toolsContext` to `WorkflowAgent`.
68
+
69
+ `runtimeContext` is shared agent state that flows through `prepareCall`, `prepareStep`, step results, and `onFinish`. `toolsContext` is a per-tool map; each tool receives its own validated entry as `context`, validated against `tool.contextSchema` when defined. The previous `experimental_context` option (and corresponding fields on related callbacks and option types) has been removed — use `runtimeContext` for shared state and `toolsContext` for per-tool values. Context values in `WorkflowAgent` should be serializable because they can cross workflow and step boundaries.
70
+
71
+ - 81e68da: Fix `stepNumber` on telemetry events emitted by `WorkflowAgent.stream` so per-step telemetry integrations (e.g. `@ai-sdk/devtools`) correctly key state per step.
72
+ - 69d7128: fix(workflow): reuse the core tool-approval validation in WorkflowAgent
73
+
74
+ `WorkflowAgent.stream` previously reconstructed approved tool calls with a copy of the core collection logic and validated them inline. Because the logic was duplicated, it could drift from the hardened `generateText`/`streamText` implementation. WorkflowAgent now collects approvals via the shared `collectToolApprovals` and re-validates each one through the shared `validateApprovedToolApprovals` (input-schema re-validation, HMAC signature verification when configured, and approval-policy re-resolution) in addition to its existing `needsApproval` guard, so a client-forged approval cannot execute a tool with unvalidated input. The duplicated collector was removed; `collectToolApprovals` and `validateApprovedToolApprovals` are now exported from `ai/internal`.
75
+
76
+ - fbea042: refactor: replace duplicate `filterTools`/`filterToolSet` with shared `experimental_filterActiveTools` from `ai`
77
+
78
+ ## 1.0.0-beta.107
79
+
80
+ ### Patch Changes
81
+
82
+ - ai@7.0.0-beta.187
83
+
84
+ ## 1.0.0-beta.106
85
+
86
+ ### Patch Changes
87
+
88
+ - ai@7.0.0-beta.186
89
+
90
+ ## 1.0.0-beta.105
91
+
92
+ ### Patch Changes
93
+
94
+ - 75763b0: agents: tag outgoing requests with an ai-sdk-agent user-agent segment for usage attribution (tool-loop, workflow)
95
+ - Updated dependencies [75763b0]
96
+ - ai@7.0.0-beta.185
97
+
98
+ ## 1.0.0-beta.104
99
+
100
+ ### Patch Changes
101
+
102
+ - 43543dc: Add `experimental_sandbox` support to `WorkflowAgent`. The sandbox is passed to tool execution, configurable on the constructor or per stream, and available to `prepareStep` for per-step overrides.
103
+
104
+ ## 1.0.0-beta.103
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [0416e3e]
109
+ - @ai-sdk/provider@4.0.0-beta.20
110
+ - ai@7.0.0-beta.184
111
+ - @ai-sdk/provider-utils@5.0.0-beta.50
112
+
113
+ ## 1.0.0-beta.102
114
+
115
+ ### Patch Changes
116
+
117
+ - ai@7.0.0-beta.183
118
+
119
+ ## 1.0.0-beta.101
120
+
121
+ ### Patch Changes
122
+
123
+ - b402b95: `WorkflowAgent` now rejects system messages inside `prompt` or `messages` by default, matching the behavior of `generateText`/`streamText`. Set `allowSystemInMessages: true` to opt in to the previous behavior.
124
+
125
+ ## 1.0.0-beta.100
126
+
127
+ ### Patch Changes
128
+
129
+ - 907e002: fix (workflow): forward provider-executed tool approvals to the provider on resume
130
+
131
+ `WorkflowAgent` stripped every `tool-approval-request` and `tool-approval-response` part from the messages when resuming after a tool approval, regardless of whether the tool was locally or provider-executed. For provider-executed tools (e.g. MCP via the OpenAI Responses API) this silently dropped the approval before `convertToLanguageModelPrompt` could forward it, so the provider never learned of the approval and the tool was never executed. Local approvals are still executed and stripped, while provider-executed approvals are now preserved and forwarded to the provider, matching the discriminator core's `streamText` already uses. This is the inverse of the bug fixed in #14289.
132
+
133
+ ## 1.0.0-beta.99
134
+
135
+ ### Patch Changes
136
+
137
+ - Updated dependencies [cc6ab90]
138
+ - ai@7.0.0-beta.182
139
+
140
+ ## 1.0.0-beta.98
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies [6a2caf9]
145
+ - ai@7.0.0-beta.181
146
+
147
+ ## 1.0.0-beta.97
148
+
149
+ ### Patch Changes
150
+
151
+ - Updated dependencies [81a284b]
152
+ - ai@7.0.0-beta.180
153
+
154
+ ## 1.0.0-beta.96
155
+
156
+ ### Patch Changes
157
+
158
+ - ai@7.0.0-beta.179
159
+
160
+ ## 1.0.0-beta.95
161
+
162
+ ### Patch Changes
163
+
164
+ - Updated dependencies [b097c52]
165
+ - ai@7.0.0-beta.178
166
+
167
+ ## 1.0.0-beta.94
168
+
169
+ ### Patch Changes
170
+
171
+ - b8396f0: trigger initial beta release
172
+ - Updated dependencies [b8396f0]
173
+ - @ai-sdk/provider-utils@5.0.0-beta.49
174
+ - @ai-sdk/provider@4.0.0-beta.19
175
+ - ai@7.0.0-beta.177
176
+
3
177
  ## 1.0.0-canary.93
4
178
 
5
179
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LanguageModelV4, SharedV4ProviderOptions, LanguageModelV4CallOptions, LanguageModelV4Prompt, LanguageModelV4StreamPart } from '@ai-sdk/provider';
2
2
  import { Context, HasRequiredKey, InferToolSetContext } from '@ai-sdk/provider-utils';
3
- import { ToolSet, LanguageModel, Instructions, ToolChoice, TelemetryOptions as TelemetryOptions$1, StopCondition, ActiveTools, LanguageModelResponseMetadata, LanguageModelUsage, FinishReason, ToolCallRepairFunction, StepResult, GenerateTextOnStepEndCallback, ModelMessage, Experimental_LanguageModelStreamPart, UIMessage, UIMessageChunk, ChatTransport, PrepareSendMessagesRequest, PrepareReconnectToStreamRequest, ChatRequestOptions } from 'ai';
3
+ import { ToolSet, LanguageModel, Instructions, ToolChoice, TelemetryOptions as TelemetryOptions$1, StopCondition, ActiveTools, LanguageModelResponseMetadata, LanguageModelUsage, FinishReason, ToolCallRepairFunction, Experimental_SandboxSession, StepResult, GenerateTextOnStepEndCallback, ModelMessage, Experimental_LanguageModelStreamPart, UIMessage, UIMessageChunk, ChatTransport, PrepareSendMessagesRequest, PrepareReconnectToStreamRequest, ChatRequestOptions } from 'ai';
4
4
  export { Experimental_LanguageModelStreamPart as ModelCallStreamPart, Output, ToolCallRepairFunction } from 'ai';
5
5
 
6
6
  /**
@@ -193,6 +193,10 @@ interface PrepareStepInfo<TTools extends ToolSet = ToolSet, TRuntimeContext exte
193
193
  * `prepareStep` to update it for the current and subsequent steps.
194
194
  */
195
195
  toolsContext: InferToolSetContext<TTools>;
196
+ /**
197
+ * The sandbox environment that the step is operating in.
198
+ */
199
+ experimental_sandbox?: Experimental_SandboxSession;
196
200
  }
197
201
  /**
198
202
  * Return type from the prepareStep callback.
@@ -231,6 +235,10 @@ interface PrepareStepResult<TTools extends ToolSet = ToolSet, TRuntimeContext ex
231
235
  * Returning a value replaces the agent's tools context.
232
236
  */
233
237
  toolsContext?: InferToolSetContext<TTools>;
238
+ /**
239
+ * Override the sandbox environment for this step.
240
+ */
241
+ experimental_sandbox?: Experimental_SandboxSession;
234
242
  }
235
243
  /**
236
244
  * Callback function called before each step in the agent loop.
@@ -354,6 +362,13 @@ type WorkflowAgentOptions<TTools extends ToolSet = ToolSet, TRuntimeContext exte
354
362
  * Per-stream `experimental_download` values passed to `stream()` override this default.
355
363
  */
356
364
  experimental_download?: DownloadFunction;
365
+ /**
366
+ * Default sandbox environment passed through to tool execution as
367
+ * `experimental_sandbox`.
368
+ *
369
+ * Per-stream `experimental_sandbox` values passed to `stream()` override this default.
370
+ */
371
+ experimental_sandbox?: Experimental_SandboxSession;
357
372
  /**
358
373
  * Default callback function called before each step in the agent loop.
359
374
  * Use this to modify settings, manage context, or inject messages dynamically
@@ -404,6 +419,15 @@ type WorkflowAgentOptions<TTools extends ToolSet = ToolSet, TRuntimeContext exte
404
419
  * model, tools, instructions, or other settings based on runtime context.
405
420
  */
406
421
  prepareCall?: PrepareCallCallback<TTools, TRuntimeContext>;
422
+ /**
423
+ * Whether to allow system messages inside the `prompt` or `messages` fields.
424
+ * When `false` (the default), system messages in `prompt` or `messages` are
425
+ * rejected to prevent prompt-injection attacks. Set to `true` only when you
426
+ * intentionally interleave system messages with user messages.
427
+ *
428
+ * @default false
429
+ */
430
+ allowSystemInMessages?: boolean;
407
431
  };
408
432
  /**
409
433
  * Callback that is called when the LLM response and all request tool executions are finished.
@@ -694,6 +718,11 @@ type WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, TRuntimeContex
694
718
  * By default, files are downloaded if the model does not support the URL for the given media type.
695
719
  */
696
720
  experimental_download?: DownloadFunction;
721
+ /**
722
+ * Sandbox environment passed through to tool execution as
723
+ * `experimental_sandbox`. Overrides the constructor-level value if provided.
724
+ */
725
+ experimental_sandbox?: Experimental_SandboxSession;
697
726
  /**
698
727
  * Callback function to be called after each step completes.
699
728
  */
@@ -896,7 +925,9 @@ declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet, TRuntimeContex
896
925
  private output?;
897
926
  private experimentalRepairToolCall?;
898
927
  private experimentalDownload?;
928
+ private experimentalSandbox?;
899
929
  private prepareStep?;
930
+ private allowSystemInMessages;
900
931
  private constructorOnStepEnd?;
901
932
  private constructorOnEnd?;
902
933
  private constructorOnStart?;