ai 6.0.201 → 6.0.203
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 +41 -0
- package/dist/index.d.mts +61 -15
- package/dist/index.d.ts +61 -15
- package/dist/index.js +853 -592
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +695 -430
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +10 -12
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +11 -13
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-ai-sdk-core/16-mcp-tools.mdx +32 -0
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +20 -2
- package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +1 -1
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-approval-signature-error.mdx +31 -0
- package/package.json +3 -3
- package/src/error/index.ts +1 -0
- package/src/error/invalid-tool-approval-signature-error.ts +35 -0
- package/src/generate-text/generate-text.ts +48 -6
- package/src/generate-text/run-tools-transformation.ts +14 -1
- package/src/generate-text/stream-text.ts +47 -11
- package/src/generate-text/to-response-messages.ts +1 -0
- package/src/generate-text/tool-approval-request-output.ts +5 -0
- package/src/generate-text/tool-approval-signature.ts +125 -0
- package/src/generate-text/validate-tool-approvals.ts +124 -0
- package/src/middleware/extract-json-middleware.ts +2 -1
- package/src/middleware/extract-reasoning-middleware.ts +2 -1
- package/src/ui/convert-to-model-messages.ts +3 -0
- package/src/ui/process-ui-message-stream.ts +6 -1
- package/src/ui/ui-messages.ts +10 -0
- package/src/ui/validate-ui-messages.ts +10 -0
- package/src/ui-message-stream/create-ui-message-stream.ts +2 -3
- package/src/ui-message-stream/ui-message-chunks.ts +2 -0
- package/src/util/download/download.ts +11 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.203
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f42aa79: fix: harden download URL SSRF guard against hostname and redirect bypasses
|
|
8
|
+
|
|
9
|
+
`validateDownloadUrl` and the file download helpers (`downloadBlob`, `download`) could be bypassed in several ways when handling untrusted URLs:
|
|
10
|
+
|
|
11
|
+
- A fully-qualified hostname with a trailing dot (e.g. `localhost.`, `myhost.local.`) skipped the localhost/`.local` blocklist.
|
|
12
|
+
- IPv6 addresses that embed an IPv4 address in their last 32 bits — IPv4-compatible (`::127.0.0.1`), IPv4-translated (`::ffff:0:127.0.0.1`), and NAT64 (`64:ff9b::127.0.0.1`, including the `64:ff9b:1::/48` local-use prefix) — were not decoded and checked against the private IPv4 ranges.
|
|
13
|
+
- Redirects were validated only _after_ `fetch` had already followed them, so the request to a redirect target (e.g. an internal/metadata address) had already been issued before the check ran.
|
|
14
|
+
- Several reserved/internal address ranges were not blocked: CGNAT (`100.64.0.0/10`, used by some cloud providers for internal traffic), benchmarking (`198.18.0.0/15`), IETF protocol assignments (`192.0.0.0/24`), the reserved `240.0.0.0/4` block (including the `255.255.255.255` broadcast address), and IPv6 site-local (`fec0::/10`) and multicast (`ff00::/8`).
|
|
15
|
+
|
|
16
|
+
The validator now strips trailing dots before the hostname checks and fully expands IPv6 addresses to detect embedded private IPv4 targets. The download helpers now follow redirects manually (`redirect: 'manual'`), re-validating each hop before requesting it, so an unsafe redirect target is never fetched. When a redirect cannot be inspected because the runtime returns an opaque response, the helpers fail closed (reject the redirect) on the server; only in a real browser — where SSRF is not reachable (fetch is constrained by CORS and cannot reach a server's internal network or cloud-metadata endpoints) — is the redirect followed natively so legitimate redirected downloads keep working.
|
|
17
|
+
|
|
18
|
+
- 5291f7e: Harden stream text processing and middleware against prototype pollution from stream part IDs.
|
|
19
|
+
- b4b575a: fix: redact server error details from UI message streams by default
|
|
20
|
+
|
|
21
|
+
`streamText(...).toUIMessageStream()` and `createUIMessageStream` defaulted their `onError` callback to `getErrorMessage`, which serializes the raw error (`error.toString()` / `JSON.stringify(error)`) into the client-facing `{ type: 'error', errorText }` chunk — and also into `tool-output-error` parts. The documented default was `() => 'An error occurred.'`, so applications relying on the documented behavior were unknowingly streaming server exception details (internal hostnames, paths, provider request data, validation inputs) to end users.
|
|
22
|
+
|
|
23
|
+
The default `onError` now returns the documented generic `'An error occurred.'`. Raw error details are only emitted when the developer explicitly supplies an `onError` handler. This also redacts `tool-output-error` and invalid-tool-input error text by default; pass an `onError` to surface richer messages.
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [bfa5864]
|
|
26
|
+
- Updated dependencies [f42aa79]
|
|
27
|
+
- @ai-sdk/provider-utils@4.0.29
|
|
28
|
+
- @ai-sdk/gateway@3.0.129
|
|
29
|
+
|
|
30
|
+
## 6.0.202
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 942f2f8: fix(security): re-validate tool approvals from client message history before execution
|
|
35
|
+
|
|
36
|
+
The approval-replay path in `generateText`/`streamText` reconstructed approved tool calls from the client-supplied messages array and executed them without re-validating input against the tool's schema or re-checking that the tool actually requires approval. 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.
|
|
37
|
+
|
|
38
|
+
The replay path now verifies the HMAC signature (when `experimental_toolApprovalSecret` is configured), re-validates tool-call input against the tool's input schema, and re-resolves whether the tool requires approval before execution.
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [942f2f8]
|
|
41
|
+
- @ai-sdk/provider-utils@4.0.28
|
|
42
|
+
- @ai-sdk/gateway@3.0.128
|
|
43
|
+
|
|
3
44
|
## 6.0.201
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -732,6 +732,10 @@ type ToolApprovalRequestOutput<TOOLS extends ToolSet> = {
|
|
|
732
732
|
* Tool call that the approval request is for.
|
|
733
733
|
*/
|
|
734
734
|
toolCall: TypedToolCall<TOOLS>;
|
|
735
|
+
/**
|
|
736
|
+
* HMAC-SHA256 signature binding this approval request to its tool call.
|
|
737
|
+
*/
|
|
738
|
+
signature?: string;
|
|
735
739
|
};
|
|
736
740
|
|
|
737
741
|
type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
|
|
@@ -1165,9 +1169,9 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
1165
1169
|
readonly output: InferCompleteOutput<OUTPUT>;
|
|
1166
1170
|
}
|
|
1167
1171
|
|
|
1168
|
-
declare const symbol$
|
|
1172
|
+
declare const symbol$k: unique symbol;
|
|
1169
1173
|
declare class InvalidToolInputError extends AISDKError {
|
|
1170
|
-
private readonly [symbol$
|
|
1174
|
+
private readonly [symbol$k];
|
|
1171
1175
|
readonly toolName: string;
|
|
1172
1176
|
readonly toolInput: string;
|
|
1173
1177
|
constructor({ toolInput, toolName, cause, message, }: {
|
|
@@ -1179,9 +1183,9 @@ declare class InvalidToolInputError extends AISDKError {
|
|
|
1179
1183
|
static isInstance(error: unknown): error is InvalidToolInputError;
|
|
1180
1184
|
}
|
|
1181
1185
|
|
|
1182
|
-
declare const symbol$
|
|
1186
|
+
declare const symbol$j: unique symbol;
|
|
1183
1187
|
declare class NoSuchToolError extends AISDKError {
|
|
1184
|
-
private readonly [symbol$
|
|
1188
|
+
private readonly [symbol$j];
|
|
1185
1189
|
readonly toolName: string;
|
|
1186
1190
|
readonly availableTools: string[] | undefined;
|
|
1187
1191
|
constructor({ toolName, availableTools, message, }: {
|
|
@@ -1345,7 +1349,7 @@ type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent
|
|
|
1345
1349
|
* @returns
|
|
1346
1350
|
* A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
1347
1351
|
*/
|
|
1348
|
-
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1352
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_toolApprovalSecret, experimental_include: include, _internal: { generateId }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1349
1353
|
/**
|
|
1350
1354
|
* The language model to use.
|
|
1351
1355
|
*/
|
|
@@ -1446,6 +1450,14 @@ declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Out
|
|
|
1446
1450
|
* @default undefined
|
|
1447
1451
|
*/
|
|
1448
1452
|
experimental_context?: unknown;
|
|
1453
|
+
/**
|
|
1454
|
+
* Secret for HMAC-signing tool approval requests. When set, the server
|
|
1455
|
+
* signs each approval request at issuance and verifies the signature when
|
|
1456
|
+
* the approval is replayed, preventing client-forged approvals.
|
|
1457
|
+
*
|
|
1458
|
+
* Experimental (can break in patch releases).
|
|
1459
|
+
*/
|
|
1460
|
+
experimental_toolApprovalSecret?: string | Uint8Array;
|
|
1449
1461
|
/**
|
|
1450
1462
|
* Settings for controlling what data is included in step results.
|
|
1451
1463
|
* Disabling inclusion can help reduce memory usage when processing
|
|
@@ -1731,6 +1743,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1731
1743
|
id: string;
|
|
1732
1744
|
approved?: never;
|
|
1733
1745
|
reason?: never;
|
|
1746
|
+
signature?: string;
|
|
1734
1747
|
};
|
|
1735
1748
|
} | {
|
|
1736
1749
|
state: 'approval-responded';
|
|
@@ -1742,6 +1755,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1742
1755
|
id: string;
|
|
1743
1756
|
approved: boolean;
|
|
1744
1757
|
reason?: string;
|
|
1758
|
+
signature?: string;
|
|
1745
1759
|
};
|
|
1746
1760
|
} | {
|
|
1747
1761
|
state: 'output-available';
|
|
@@ -1755,6 +1769,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1755
1769
|
id: string;
|
|
1756
1770
|
approved: true;
|
|
1757
1771
|
reason?: string;
|
|
1772
|
+
signature?: string;
|
|
1758
1773
|
};
|
|
1759
1774
|
} | {
|
|
1760
1775
|
state: 'output-error';
|
|
@@ -1768,6 +1783,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1768
1783
|
id: string;
|
|
1769
1784
|
approved: true;
|
|
1770
1785
|
reason?: string;
|
|
1786
|
+
signature?: string;
|
|
1771
1787
|
};
|
|
1772
1788
|
} | {
|
|
1773
1789
|
state: 'output-denied';
|
|
@@ -1779,6 +1795,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1779
1795
|
id: string;
|
|
1780
1796
|
approved: false;
|
|
1781
1797
|
reason?: string;
|
|
1798
|
+
signature?: string;
|
|
1782
1799
|
};
|
|
1783
1800
|
});
|
|
1784
1801
|
type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
|
|
@@ -1826,6 +1843,7 @@ type DynamicToolUIPart = {
|
|
|
1826
1843
|
id: string;
|
|
1827
1844
|
approved?: never;
|
|
1828
1845
|
reason?: never;
|
|
1846
|
+
signature?: string;
|
|
1829
1847
|
};
|
|
1830
1848
|
} | {
|
|
1831
1849
|
state: 'approval-responded';
|
|
@@ -1837,6 +1855,7 @@ type DynamicToolUIPart = {
|
|
|
1837
1855
|
id: string;
|
|
1838
1856
|
approved: boolean;
|
|
1839
1857
|
reason?: string;
|
|
1858
|
+
signature?: string;
|
|
1840
1859
|
};
|
|
1841
1860
|
} | {
|
|
1842
1861
|
state: 'output-available';
|
|
@@ -1850,6 +1869,7 @@ type DynamicToolUIPart = {
|
|
|
1850
1869
|
id: string;
|
|
1851
1870
|
approved: true;
|
|
1852
1871
|
reason?: string;
|
|
1872
|
+
signature?: string;
|
|
1853
1873
|
};
|
|
1854
1874
|
} | {
|
|
1855
1875
|
state: 'output-error';
|
|
@@ -1862,6 +1882,7 @@ type DynamicToolUIPart = {
|
|
|
1862
1882
|
id: string;
|
|
1863
1883
|
approved: true;
|
|
1864
1884
|
reason?: string;
|
|
1885
|
+
signature?: string;
|
|
1865
1886
|
};
|
|
1866
1887
|
} | {
|
|
1867
1888
|
state: 'output-denied';
|
|
@@ -1873,6 +1894,7 @@ type DynamicToolUIPart = {
|
|
|
1873
1894
|
id: string;
|
|
1874
1895
|
approved: false;
|
|
1875
1896
|
reason?: string;
|
|
1897
|
+
signature?: string;
|
|
1876
1898
|
};
|
|
1877
1899
|
});
|
|
1878
1900
|
/**
|
|
@@ -1989,6 +2011,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1989
2011
|
type: "tool-approval-request";
|
|
1990
2012
|
approvalId: string;
|
|
1991
2013
|
toolCallId: string;
|
|
2014
|
+
signature?: string | undefined;
|
|
1992
2015
|
} | {
|
|
1993
2016
|
type: "tool-output-available";
|
|
1994
2017
|
toolCallId: string;
|
|
@@ -2126,6 +2149,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
2126
2149
|
type: 'tool-approval-request';
|
|
2127
2150
|
approvalId: string;
|
|
2128
2151
|
toolCallId: string;
|
|
2152
|
+
signature?: string;
|
|
2129
2153
|
} | {
|
|
2130
2154
|
type: 'tool-output-available';
|
|
2131
2155
|
toolCallId: string;
|
|
@@ -2732,7 +2756,7 @@ type StreamTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (even
|
|
|
2732
2756
|
* @returns
|
|
2733
2757
|
* A result object for accessing different stream types and additional information.
|
|
2734
2758
|
*/
|
|
2735
|
-
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2759
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_toolApprovalSecret, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2736
2760
|
/**
|
|
2737
2761
|
* The language model to use.
|
|
2738
2762
|
*/
|
|
@@ -2865,6 +2889,14 @@ declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Outpu
|
|
|
2865
2889
|
* @default undefined
|
|
2866
2890
|
*/
|
|
2867
2891
|
experimental_context?: unknown;
|
|
2892
|
+
/**
|
|
2893
|
+
* Secret for HMAC-signing tool approval requests. When set, the server
|
|
2894
|
+
* signs each approval request at issuance and verifies the signature when
|
|
2895
|
+
* the approval is replayed, preventing client-forged approvals.
|
|
2896
|
+
*
|
|
2897
|
+
* Experimental (can break in patch releases).
|
|
2898
|
+
*/
|
|
2899
|
+
experimental_toolApprovalSecret?: string | Uint8Array;
|
|
2868
2900
|
/**
|
|
2869
2901
|
* Settings for controlling what data is included in step results.
|
|
2870
2902
|
* Disabling inclusion can help reduce memory usage when processing
|
|
@@ -4264,7 +4296,7 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
|
4264
4296
|
* Creates a UI message stream that can be used to send messages to the client.
|
|
4265
4297
|
*
|
|
4266
4298
|
* @param options.execute - A function that is called with a writer to write UI message chunks to the stream.
|
|
4267
|
-
* @param options.onError - A function that extracts an error message from an error. Defaults to `
|
|
4299
|
+
* @param options.onError - A function that extracts an error message from an error. Defaults to `() => 'An error occurred.'` so server-side error details are not leaked to the client; supply your own to surface richer messages.
|
|
4268
4300
|
* @param options.originalMessages - The original messages. If provided, persistence mode is assumed
|
|
4269
4301
|
* and a message ID is provided for the response message.
|
|
4270
4302
|
* @param options.onStepFinish - A callback that is called when each step finishes. Useful for persisting intermediate messages.
|
|
@@ -4273,7 +4305,8 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
|
4273
4305
|
*
|
|
4274
4306
|
* @returns A `ReadableStream` of UI message chunks.
|
|
4275
4307
|
*/
|
|
4276
|
-
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError,
|
|
4308
|
+
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, // prevent leaking server error details to the client by default
|
|
4309
|
+
originalMessages, onStepFinish, onFinish, generateId, }: {
|
|
4277
4310
|
execute: (options: {
|
|
4278
4311
|
writer: UIMessageStreamWriter<UI_MESSAGE>;
|
|
4279
4312
|
}) => Promise<void> | void;
|
|
@@ -4608,9 +4641,9 @@ declare function embedMany({ model: modelArg, values, maxParallelCalls, maxRetri
|
|
|
4608
4641
|
maxParallelCalls?: number;
|
|
4609
4642
|
}): Promise<EmbedManyResult>;
|
|
4610
4643
|
|
|
4611
|
-
declare const symbol$
|
|
4644
|
+
declare const symbol$i: unique symbol;
|
|
4612
4645
|
declare class InvalidArgumentError extends AISDKError {
|
|
4613
|
-
private readonly [symbol$
|
|
4646
|
+
private readonly [symbol$i];
|
|
4614
4647
|
readonly parameter: string;
|
|
4615
4648
|
readonly value: unknown;
|
|
4616
4649
|
constructor({ parameter, value, message, }: {
|
|
@@ -4697,9 +4730,9 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
|
|
4697
4730
|
rawValue: unknown;
|
|
4698
4731
|
};
|
|
4699
4732
|
|
|
4700
|
-
declare const symbol$
|
|
4733
|
+
declare const symbol$h: unique symbol;
|
|
4701
4734
|
declare class InvalidStreamPartError extends AISDKError {
|
|
4702
|
-
private readonly [symbol$
|
|
4735
|
+
private readonly [symbol$h];
|
|
4703
4736
|
readonly chunk: SingleRequestTextStreamPart<any>;
|
|
4704
4737
|
constructor({ chunk, message, }: {
|
|
4705
4738
|
chunk: SingleRequestTextStreamPart<any>;
|
|
@@ -4708,9 +4741,9 @@ declare class InvalidStreamPartError extends AISDKError {
|
|
|
4708
4741
|
static isInstance(error: unknown): error is InvalidStreamPartError;
|
|
4709
4742
|
}
|
|
4710
4743
|
|
|
4711
|
-
declare const symbol$
|
|
4744
|
+
declare const symbol$g: unique symbol;
|
|
4712
4745
|
declare class InvalidToolApprovalError extends AISDKError {
|
|
4713
|
-
private readonly [symbol$
|
|
4746
|
+
private readonly [symbol$g];
|
|
4714
4747
|
readonly approvalId: string;
|
|
4715
4748
|
constructor({ approvalId }: {
|
|
4716
4749
|
approvalId: string;
|
|
@@ -4718,6 +4751,19 @@ declare class InvalidToolApprovalError extends AISDKError {
|
|
|
4718
4751
|
static isInstance(error: unknown): error is InvalidToolApprovalError;
|
|
4719
4752
|
}
|
|
4720
4753
|
|
|
4754
|
+
declare const symbol$f: unique symbol;
|
|
4755
|
+
declare class InvalidToolApprovalSignatureError extends AISDKError {
|
|
4756
|
+
private readonly [symbol$f];
|
|
4757
|
+
readonly approvalId: string;
|
|
4758
|
+
readonly toolCallId: string;
|
|
4759
|
+
constructor({ approvalId, toolCallId, reason, }: {
|
|
4760
|
+
approvalId: string;
|
|
4761
|
+
toolCallId: string;
|
|
4762
|
+
reason: string;
|
|
4763
|
+
});
|
|
4764
|
+
static isInstance(error: unknown): error is InvalidToolApprovalSignatureError;
|
|
4765
|
+
}
|
|
4766
|
+
|
|
4721
4767
|
declare const symbol$e: unique symbol;
|
|
4722
4768
|
declare class ToolCallNotFoundForApprovalError extends AISDKError {
|
|
4723
4769
|
private readonly [symbol$e];
|
|
@@ -6440,4 +6486,4 @@ declare function bindTelemetryIntegration(integration: TelemetryIntegration): Te
|
|
|
6440
6486
|
*/
|
|
6441
6487
|
declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
|
|
6442
6488
|
|
|
6443
|
-
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|
|
6489
|
+
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -732,6 +732,10 @@ type ToolApprovalRequestOutput<TOOLS extends ToolSet> = {
|
|
|
732
732
|
* Tool call that the approval request is for.
|
|
733
733
|
*/
|
|
734
734
|
toolCall: TypedToolCall<TOOLS>;
|
|
735
|
+
/**
|
|
736
|
+
* HMAC-SHA256 signature binding this approval request to its tool call.
|
|
737
|
+
*/
|
|
738
|
+
signature?: string;
|
|
735
739
|
};
|
|
736
740
|
|
|
737
741
|
type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
|
|
@@ -1165,9 +1169,9 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
1165
1169
|
readonly output: InferCompleteOutput<OUTPUT>;
|
|
1166
1170
|
}
|
|
1167
1171
|
|
|
1168
|
-
declare const symbol$
|
|
1172
|
+
declare const symbol$k: unique symbol;
|
|
1169
1173
|
declare class InvalidToolInputError extends AISDKError {
|
|
1170
|
-
private readonly [symbol$
|
|
1174
|
+
private readonly [symbol$k];
|
|
1171
1175
|
readonly toolName: string;
|
|
1172
1176
|
readonly toolInput: string;
|
|
1173
1177
|
constructor({ toolInput, toolName, cause, message, }: {
|
|
@@ -1179,9 +1183,9 @@ declare class InvalidToolInputError extends AISDKError {
|
|
|
1179
1183
|
static isInstance(error: unknown): error is InvalidToolInputError;
|
|
1180
1184
|
}
|
|
1181
1185
|
|
|
1182
|
-
declare const symbol$
|
|
1186
|
+
declare const symbol$j: unique symbol;
|
|
1183
1187
|
declare class NoSuchToolError extends AISDKError {
|
|
1184
|
-
private readonly [symbol$
|
|
1188
|
+
private readonly [symbol$j];
|
|
1185
1189
|
readonly toolName: string;
|
|
1186
1190
|
readonly availableTools: string[] | undefined;
|
|
1187
1191
|
constructor({ toolName, availableTools, message, }: {
|
|
@@ -1345,7 +1349,7 @@ type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent
|
|
|
1345
1349
|
* @returns
|
|
1346
1350
|
* A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
1347
1351
|
*/
|
|
1348
|
-
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1352
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_toolApprovalSecret, experimental_include: include, _internal: { generateId }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1349
1353
|
/**
|
|
1350
1354
|
* The language model to use.
|
|
1351
1355
|
*/
|
|
@@ -1446,6 +1450,14 @@ declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = Out
|
|
|
1446
1450
|
* @default undefined
|
|
1447
1451
|
*/
|
|
1448
1452
|
experimental_context?: unknown;
|
|
1453
|
+
/**
|
|
1454
|
+
* Secret for HMAC-signing tool approval requests. When set, the server
|
|
1455
|
+
* signs each approval request at issuance and verifies the signature when
|
|
1456
|
+
* the approval is replayed, preventing client-forged approvals.
|
|
1457
|
+
*
|
|
1458
|
+
* Experimental (can break in patch releases).
|
|
1459
|
+
*/
|
|
1460
|
+
experimental_toolApprovalSecret?: string | Uint8Array;
|
|
1449
1461
|
/**
|
|
1450
1462
|
* Settings for controlling what data is included in step results.
|
|
1451
1463
|
* Disabling inclusion can help reduce memory usage when processing
|
|
@@ -1731,6 +1743,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1731
1743
|
id: string;
|
|
1732
1744
|
approved?: never;
|
|
1733
1745
|
reason?: never;
|
|
1746
|
+
signature?: string;
|
|
1734
1747
|
};
|
|
1735
1748
|
} | {
|
|
1736
1749
|
state: 'approval-responded';
|
|
@@ -1742,6 +1755,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1742
1755
|
id: string;
|
|
1743
1756
|
approved: boolean;
|
|
1744
1757
|
reason?: string;
|
|
1758
|
+
signature?: string;
|
|
1745
1759
|
};
|
|
1746
1760
|
} | {
|
|
1747
1761
|
state: 'output-available';
|
|
@@ -1755,6 +1769,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1755
1769
|
id: string;
|
|
1756
1770
|
approved: true;
|
|
1757
1771
|
reason?: string;
|
|
1772
|
+
signature?: string;
|
|
1758
1773
|
};
|
|
1759
1774
|
} | {
|
|
1760
1775
|
state: 'output-error';
|
|
@@ -1768,6 +1783,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1768
1783
|
id: string;
|
|
1769
1784
|
approved: true;
|
|
1770
1785
|
reason?: string;
|
|
1786
|
+
signature?: string;
|
|
1771
1787
|
};
|
|
1772
1788
|
} | {
|
|
1773
1789
|
state: 'output-denied';
|
|
@@ -1779,6 +1795,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1779
1795
|
id: string;
|
|
1780
1796
|
approved: false;
|
|
1781
1797
|
reason?: string;
|
|
1798
|
+
signature?: string;
|
|
1782
1799
|
};
|
|
1783
1800
|
});
|
|
1784
1801
|
type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
|
|
@@ -1826,6 +1843,7 @@ type DynamicToolUIPart = {
|
|
|
1826
1843
|
id: string;
|
|
1827
1844
|
approved?: never;
|
|
1828
1845
|
reason?: never;
|
|
1846
|
+
signature?: string;
|
|
1829
1847
|
};
|
|
1830
1848
|
} | {
|
|
1831
1849
|
state: 'approval-responded';
|
|
@@ -1837,6 +1855,7 @@ type DynamicToolUIPart = {
|
|
|
1837
1855
|
id: string;
|
|
1838
1856
|
approved: boolean;
|
|
1839
1857
|
reason?: string;
|
|
1858
|
+
signature?: string;
|
|
1840
1859
|
};
|
|
1841
1860
|
} | {
|
|
1842
1861
|
state: 'output-available';
|
|
@@ -1850,6 +1869,7 @@ type DynamicToolUIPart = {
|
|
|
1850
1869
|
id: string;
|
|
1851
1870
|
approved: true;
|
|
1852
1871
|
reason?: string;
|
|
1872
|
+
signature?: string;
|
|
1853
1873
|
};
|
|
1854
1874
|
} | {
|
|
1855
1875
|
state: 'output-error';
|
|
@@ -1862,6 +1882,7 @@ type DynamicToolUIPart = {
|
|
|
1862
1882
|
id: string;
|
|
1863
1883
|
approved: true;
|
|
1864
1884
|
reason?: string;
|
|
1885
|
+
signature?: string;
|
|
1865
1886
|
};
|
|
1866
1887
|
} | {
|
|
1867
1888
|
state: 'output-denied';
|
|
@@ -1873,6 +1894,7 @@ type DynamicToolUIPart = {
|
|
|
1873
1894
|
id: string;
|
|
1874
1895
|
approved: false;
|
|
1875
1896
|
reason?: string;
|
|
1897
|
+
signature?: string;
|
|
1876
1898
|
};
|
|
1877
1899
|
});
|
|
1878
1900
|
/**
|
|
@@ -1989,6 +2011,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1989
2011
|
type: "tool-approval-request";
|
|
1990
2012
|
approvalId: string;
|
|
1991
2013
|
toolCallId: string;
|
|
2014
|
+
signature?: string | undefined;
|
|
1992
2015
|
} | {
|
|
1993
2016
|
type: "tool-output-available";
|
|
1994
2017
|
toolCallId: string;
|
|
@@ -2126,6 +2149,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
2126
2149
|
type: 'tool-approval-request';
|
|
2127
2150
|
approvalId: string;
|
|
2128
2151
|
toolCallId: string;
|
|
2152
|
+
signature?: string;
|
|
2129
2153
|
} | {
|
|
2130
2154
|
type: 'tool-output-available';
|
|
2131
2155
|
toolCallId: string;
|
|
@@ -2732,7 +2756,7 @@ type StreamTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (even
|
|
|
2732
2756
|
* @returns
|
|
2733
2757
|
* A result object for accessing different stream types and additional information.
|
|
2734
2758
|
*/
|
|
2735
|
-
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2759
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_toolApprovalSecret, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
|
|
2736
2760
|
/**
|
|
2737
2761
|
* The language model to use.
|
|
2738
2762
|
*/
|
|
@@ -2865,6 +2889,14 @@ declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Outpu
|
|
|
2865
2889
|
* @default undefined
|
|
2866
2890
|
*/
|
|
2867
2891
|
experimental_context?: unknown;
|
|
2892
|
+
/**
|
|
2893
|
+
* Secret for HMAC-signing tool approval requests. When set, the server
|
|
2894
|
+
* signs each approval request at issuance and verifies the signature when
|
|
2895
|
+
* the approval is replayed, preventing client-forged approvals.
|
|
2896
|
+
*
|
|
2897
|
+
* Experimental (can break in patch releases).
|
|
2898
|
+
*/
|
|
2899
|
+
experimental_toolApprovalSecret?: string | Uint8Array;
|
|
2868
2900
|
/**
|
|
2869
2901
|
* Settings for controlling what data is included in step results.
|
|
2870
2902
|
* Disabling inclusion can help reduce memory usage when processing
|
|
@@ -4264,7 +4296,7 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
|
4264
4296
|
* Creates a UI message stream that can be used to send messages to the client.
|
|
4265
4297
|
*
|
|
4266
4298
|
* @param options.execute - A function that is called with a writer to write UI message chunks to the stream.
|
|
4267
|
-
* @param options.onError - A function that extracts an error message from an error. Defaults to `
|
|
4299
|
+
* @param options.onError - A function that extracts an error message from an error. Defaults to `() => 'An error occurred.'` so server-side error details are not leaked to the client; supply your own to surface richer messages.
|
|
4268
4300
|
* @param options.originalMessages - The original messages. If provided, persistence mode is assumed
|
|
4269
4301
|
* and a message ID is provided for the response message.
|
|
4270
4302
|
* @param options.onStepFinish - A callback that is called when each step finishes. Useful for persisting intermediate messages.
|
|
@@ -4273,7 +4305,8 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
|
4273
4305
|
*
|
|
4274
4306
|
* @returns A `ReadableStream` of UI message chunks.
|
|
4275
4307
|
*/
|
|
4276
|
-
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError,
|
|
4308
|
+
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, // prevent leaking server error details to the client by default
|
|
4309
|
+
originalMessages, onStepFinish, onFinish, generateId, }: {
|
|
4277
4310
|
execute: (options: {
|
|
4278
4311
|
writer: UIMessageStreamWriter<UI_MESSAGE>;
|
|
4279
4312
|
}) => Promise<void> | void;
|
|
@@ -4608,9 +4641,9 @@ declare function embedMany({ model: modelArg, values, maxParallelCalls, maxRetri
|
|
|
4608
4641
|
maxParallelCalls?: number;
|
|
4609
4642
|
}): Promise<EmbedManyResult>;
|
|
4610
4643
|
|
|
4611
|
-
declare const symbol$
|
|
4644
|
+
declare const symbol$i: unique symbol;
|
|
4612
4645
|
declare class InvalidArgumentError extends AISDKError {
|
|
4613
|
-
private readonly [symbol$
|
|
4646
|
+
private readonly [symbol$i];
|
|
4614
4647
|
readonly parameter: string;
|
|
4615
4648
|
readonly value: unknown;
|
|
4616
4649
|
constructor({ parameter, value, message, }: {
|
|
@@ -4697,9 +4730,9 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
|
|
4697
4730
|
rawValue: unknown;
|
|
4698
4731
|
};
|
|
4699
4732
|
|
|
4700
|
-
declare const symbol$
|
|
4733
|
+
declare const symbol$h: unique symbol;
|
|
4701
4734
|
declare class InvalidStreamPartError extends AISDKError {
|
|
4702
|
-
private readonly [symbol$
|
|
4735
|
+
private readonly [symbol$h];
|
|
4703
4736
|
readonly chunk: SingleRequestTextStreamPart<any>;
|
|
4704
4737
|
constructor({ chunk, message, }: {
|
|
4705
4738
|
chunk: SingleRequestTextStreamPart<any>;
|
|
@@ -4708,9 +4741,9 @@ declare class InvalidStreamPartError extends AISDKError {
|
|
|
4708
4741
|
static isInstance(error: unknown): error is InvalidStreamPartError;
|
|
4709
4742
|
}
|
|
4710
4743
|
|
|
4711
|
-
declare const symbol$
|
|
4744
|
+
declare const symbol$g: unique symbol;
|
|
4712
4745
|
declare class InvalidToolApprovalError extends AISDKError {
|
|
4713
|
-
private readonly [symbol$
|
|
4746
|
+
private readonly [symbol$g];
|
|
4714
4747
|
readonly approvalId: string;
|
|
4715
4748
|
constructor({ approvalId }: {
|
|
4716
4749
|
approvalId: string;
|
|
@@ -4718,6 +4751,19 @@ declare class InvalidToolApprovalError extends AISDKError {
|
|
|
4718
4751
|
static isInstance(error: unknown): error is InvalidToolApprovalError;
|
|
4719
4752
|
}
|
|
4720
4753
|
|
|
4754
|
+
declare const symbol$f: unique symbol;
|
|
4755
|
+
declare class InvalidToolApprovalSignatureError extends AISDKError {
|
|
4756
|
+
private readonly [symbol$f];
|
|
4757
|
+
readonly approvalId: string;
|
|
4758
|
+
readonly toolCallId: string;
|
|
4759
|
+
constructor({ approvalId, toolCallId, reason, }: {
|
|
4760
|
+
approvalId: string;
|
|
4761
|
+
toolCallId: string;
|
|
4762
|
+
reason: string;
|
|
4763
|
+
});
|
|
4764
|
+
static isInstance(error: unknown): error is InvalidToolApprovalSignatureError;
|
|
4765
|
+
}
|
|
4766
|
+
|
|
4721
4767
|
declare const symbol$e: unique symbol;
|
|
4722
4768
|
declare class ToolCallNotFoundForApprovalError extends AISDKError {
|
|
4723
4769
|
private readonly [symbol$e];
|
|
@@ -6440,4 +6486,4 @@ declare function bindTelemetryIntegration(integration: TelemetryIntegration): Te
|
|
|
6440
6486
|
*/
|
|
6441
6487
|
declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
|
|
6442
6488
|
|
|
6443
|
-
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|
|
6489
|
+
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|