ai 7.0.85 → 7.0.86
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 +8 -0
- package/dist/index.js +1 -1
- package/dist/internal/index.d.ts +17 -1
- package/dist/internal/index.js +99 -84
- package/dist/internal/index.js.map +1 -1
- package/docs/03-agents/06-tool-approvals.mdx +6 -3
- package/docs/03-agents/07-workflow-agent.mdx +43 -0
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +4 -0
- package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +25 -0
- package/package.json +2 -2
|
@@ -319,9 +319,12 @@ Every serverless instance that might handle a request needs the same secret, sin
|
|
|
319
319
|
- The secret is never sent to the client or included in the stream
|
|
320
320
|
|
|
321
321
|
<Note>
|
|
322
|
-
`
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
`WorkflowAgent` also supports `experimental_toolApprovalSecret`. It signs in
|
|
323
|
+
a workflow step before writing the durable approval request. Pass an
|
|
324
|
+
environment variable reference, such as
|
|
325
|
+
`{ environmentVariable: 'TOOL_APPROVAL_SECRET' }`, so the raw secret is read
|
|
326
|
+
only inside signing and verification steps. Only the signature is persisted
|
|
327
|
+
and sent to the client.
|
|
325
328
|
</Note>
|
|
326
329
|
|
|
327
330
|
## Related APIs
|
|
@@ -354,6 +354,49 @@ const agent = new WorkflowAgent({
|
|
|
354
354
|
|
|
355
355
|
Because the workflow is durable, the approval request survives process restarts — the user can approve hours later and the agent will resume.
|
|
356
356
|
|
|
357
|
+
### Signed Tool Approvals
|
|
358
|
+
|
|
359
|
+
Client-supplied message history can be modified before it is replayed to the
|
|
360
|
+
workflow. For tools that perform sensitive operations, configure
|
|
361
|
+
`experimental_toolApprovalSecret` to authenticate approval requests:
|
|
362
|
+
|
|
363
|
+
```ts highlight="4"
|
|
364
|
+
const agent = new WorkflowAgent({
|
|
365
|
+
model: 'anthropic/claude-sonnet-4-6',
|
|
366
|
+
experimental_toolApprovalSecret: {
|
|
367
|
+
environmentVariable: 'TOOL_APPROVAL_SECRET',
|
|
368
|
+
},
|
|
369
|
+
tools: {
|
|
370
|
+
bookFlight: tool({
|
|
371
|
+
description: 'Book a flight',
|
|
372
|
+
inputSchema: z.object({ flightId: z.string() }),
|
|
373
|
+
needsApproval: true,
|
|
374
|
+
execute: bookFlightStep,
|
|
375
|
+
}),
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
The agent HMAC-signs the approval ID, tool call ID, tool name, and validated
|
|
381
|
+
input. When approved message history is replayed, a missing or invalid
|
|
382
|
+
signature prevents the tool from executing. The signature is preserved through
|
|
383
|
+
the durable model-call stream, `createModelCallToUIChunkTransform()`,
|
|
384
|
+
`addToolApprovalResponse()`, and `convertToModelMessages()`.
|
|
385
|
+
|
|
386
|
+
Use a high-entropy secret of at least 32 bytes and make the same secret
|
|
387
|
+
available to every worker that can issue or resume an approval. Keep old keys
|
|
388
|
+
available while approvals signed with them are pending; changing the secret
|
|
389
|
+
invalidates those pending approvals.
|
|
390
|
+
|
|
391
|
+
`WorkflowAgent` passes only the environment variable name into signing and
|
|
392
|
+
verification steps. Each step reads the secret from its local environment, and
|
|
393
|
+
the raw value is never included in step arguments, durable stream parts,
|
|
394
|
+
callbacks, or telemetry events. Configure the environment variable on every
|
|
395
|
+
worker, and do not put the secret value in `runtimeContext` or `toolsContext`.
|
|
396
|
+
|
|
397
|
+
You can also provide `experimental_toolApprovalSecret` to `agent.stream()`.
|
|
398
|
+
The stream-level value overrides the constructor default.
|
|
399
|
+
|
|
357
400
|
## Loop Control
|
|
358
401
|
|
|
359
402
|
Control how many steps the agent can take:
|
|
@@ -526,6 +526,10 @@ console.log(preparation.identity);
|
|
|
526
526
|
- `sandboxConfig`: sandbox working-directory and lifecycle hook configuration.
|
|
527
527
|
- `telemetry`, `debug`, and `onLog`: observability and diagnostics.
|
|
528
528
|
|
|
529
|
+
Telemetry reports each turn's resolved model, instructions, and active
|
|
530
|
+
host-defined tools. Skills are adapter context and do not have a corresponding
|
|
531
|
+
AI SDK telemetry field, so they are not included in standard telemetry events.
|
|
532
|
+
|
|
529
533
|
Adapter-specific settings belong on the adapter factory, for example
|
|
530
534
|
`createCodex({ reasoningEffort: 'high' })`.
|
|
531
535
|
|
|
@@ -136,6 +136,13 @@ To see `WorkflowAgent` in action, check out [these examples](#examples).
|
|
|
136
136
|
description:
|
|
137
137
|
'Default sandbox session passed to tool descriptions and execution as `experimental_sandbox`, and exposed to `prepareStep`. Per-stream values override this default.',
|
|
138
138
|
},
|
|
139
|
+
{
|
|
140
|
+
name: 'experimental_toolApprovalSecret',
|
|
141
|
+
type: 'WorkflowToolApprovalSecret',
|
|
142
|
+
isOptional: true,
|
|
143
|
+
description:
|
|
144
|
+
'Workflow-safe reference to the environment variable containing the secret used to HMAC-sign tool approval requests and verify approved message history before tool execution. Only the environment variable name crosses workflow boundaries; the secret is read inside signing and verification steps. Per-stream values override this default.',
|
|
145
|
+
},
|
|
139
146
|
{
|
|
140
147
|
name: 'prepareStep',
|
|
141
148
|
type: 'PrepareStepCallback',
|
|
@@ -559,6 +566,13 @@ const result = await agent.stream({
|
|
|
559
566
|
description:
|
|
560
567
|
'Sandbox session passed to tool descriptions and execution as `experimental_sandbox`, and exposed to `prepareStep`. Overrides the constructor default.',
|
|
561
568
|
},
|
|
569
|
+
{
|
|
570
|
+
name: 'experimental_toolApprovalSecret',
|
|
571
|
+
type: 'WorkflowToolApprovalSecret',
|
|
572
|
+
isOptional: true,
|
|
573
|
+
description:
|
|
574
|
+
'Workflow-safe reference to the environment variable containing the secret used to HMAC-sign tool approval requests and verify approved message history before tool execution. Only the environment variable name crosses workflow boundaries; the secret is read inside signing and verification steps. Overrides the constructor default.',
|
|
575
|
+
},
|
|
562
576
|
{
|
|
563
577
|
name: 'telemetry',
|
|
564
578
|
type: 'TelemetryOptions',
|
|
@@ -922,6 +936,9 @@ import { z } from 'zod';
|
|
|
922
936
|
|
|
923
937
|
const agent = new WorkflowAgent({
|
|
924
938
|
model: 'anthropic/claude-sonnet-4-6',
|
|
939
|
+
experimental_toolApprovalSecret: {
|
|
940
|
+
environmentVariable: 'TOOL_APPROVAL_SECRET',
|
|
941
|
+
},
|
|
925
942
|
tools: {
|
|
926
943
|
bookFlight: tool({
|
|
927
944
|
description: 'Book a flight',
|
|
@@ -936,6 +953,14 @@ const agent = new WorkflowAgent({
|
|
|
936
953
|
});
|
|
937
954
|
```
|
|
938
955
|
|
|
956
|
+
When `experimental_toolApprovalSecret` is configured, each approval request is
|
|
957
|
+
signed over its approval ID, tool call ID, tool name, and validated input.
|
|
958
|
+
Replayed approvals with a missing or invalid signature do not execute the tool.
|
|
959
|
+
The signature is preserved in the durable stream and UI message history, while
|
|
960
|
+
only the environment variable name crosses workflow boundaries. Signing and
|
|
961
|
+
verification steps read the raw secret from their local environment and do not
|
|
962
|
+
serialize it. A stream-level reference overrides the constructor value.
|
|
963
|
+
|
|
939
964
|
### Agent with Lifecycle Callbacks
|
|
940
965
|
|
|
941
966
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.86",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ai-sdk/gateway": "4.0.
|
|
45
|
+
"@ai-sdk/gateway": "4.0.70",
|
|
46
46
|
"@ai-sdk/provider": "4.0.9",
|
|
47
47
|
"@ai-sdk/provider-utils": "5.0.34"
|
|
48
48
|
},
|