ai 7.0.79 → 7.0.83
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 +48 -0
- package/dist/index.d.ts +139 -53
- package/dist/index.js +872 -496
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +9 -1
- package/dist/internal/index.js +4 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/test/index.d.ts +4 -1
- package/dist/test/index.js +4 -0
- package/dist/test/index.js.map +1 -1
- package/docs/03-agents/06-policy-tool-approvals.mdx +1 -1
- package/docs/03-agents/06-tool-approvals.mdx +6 -0
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +6 -4
- package/docs/03-ai-sdk-core/50-error-handling.mdx +17 -2
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +6 -0
- package/docs/04-ai-sdk-ui/50-stream-protocol.mdx +2 -2
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +8 -7
- package/docs/07-reference/01-ai-sdk-core/06-embed-many.mdx +6 -2
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +2 -2
- package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +35 -6
- package/docs/07-reference/04-ai-sdk-workflow/03-generate-video.mdx +157 -0
- package/docs/07-reference/04-ai-sdk-workflow/index.mdx +6 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-stream-provider-error.mdx +52 -0
- package/docs/07-reference/05-ai-sdk-errors/index.mdx +1 -0
- package/package.json +14 -3
- package/src/agent/create-agent-ui-stream.ts +2 -2
- package/src/embed/embed-many.ts +78 -8
- package/src/error/index.ts +1 -0
- package/src/error/stream-provider-error.ts +78 -0
- package/src/generate-text/execute-tools-from-stream.ts +3 -0
- package/src/generate-text/generate-text-result.ts +2 -1
- package/src/generate-text/generate-text.ts +6 -3
- package/src/generate-text/stream-language-model-call.ts +8 -0
- package/src/generate-text/to-response-messages.ts +1 -0
- package/src/generate-text/tool-approval-configuration.ts +5 -1
- package/src/generate-text/tool-approval-request-output.ts +5 -0
- package/src/middleware/wrap-embedding-model.ts +11 -2
- package/src/model/get-embedding-model-max-input-bytes-per-call.ts +15 -0
- package/src/prompt/content-part.ts +1 -0
- package/src/prompt/normalize-stream-provider-error.ts +131 -0
- package/src/test/mock-embedding-model-v4.ts +9 -0
- package/src/ui/convert-to-model-messages.ts +3 -0
- package/src/ui/direct-chat-transport.ts +2 -2
- package/src/ui/last-assistant-message-is-complete-with-approval-responses.ts +1 -0
- package/src/ui/process-ui-message-stream.ts +6 -0
- package/src/ui/ui-messages.ts +10 -0
- package/src/ui/validate-ui-messages.ts +146 -55
- package/src/ui-message-stream/create-ui-message-stream.ts +47 -17
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +51 -14
- package/src/ui-message-stream/index.ts +5 -1
- package/src/ui-message-stream/to-ui-message-chunk.ts +1 -0
- package/src/ui-message-stream/to-ui-message-stream.ts +108 -26
- package/src/ui-message-stream/ui-message-chunks.ts +2 -0
- package/src/ui-message-stream/ui-message-stream-on-end-callback.ts +7 -0
- package/src/ui-message-stream/ui-message-stream-outcome.ts +12 -0
- package/src/ui-message-stream/ui-message-stream-writer.ts +15 -0
- package/src/util/create-stitchable-stream.ts +31 -1
package/dist/internal/index.d.ts
CHANGED
|
@@ -942,6 +942,10 @@ type ToolApprovalRequestOutput<TOOLS extends ToolSet> = {
|
|
|
942
942
|
* Tool call that the approval request is for.
|
|
943
943
|
*/
|
|
944
944
|
toolCall: TypedToolCall<TOOLS>;
|
|
945
|
+
/**
|
|
946
|
+
* Reason why the tool call requires approval.
|
|
947
|
+
*/
|
|
948
|
+
reason?: string;
|
|
945
949
|
/**
|
|
946
950
|
* Flag indicating whether the tool was automatically approved or denied.
|
|
947
951
|
*
|
|
@@ -1631,6 +1635,8 @@ type TextStreamPart<TOOLS extends ToolSet> = TextStreamTextStartPart | TextStrea
|
|
|
1631
1635
|
* - 'user-approval': The tool requires user approval.
|
|
1632
1636
|
*
|
|
1633
1637
|
* In addition to the string statuses, you can also use object statuses with a reason property.
|
|
1638
|
+
* For approved and denied statuses, the reason is emitted on the approval response.
|
|
1639
|
+
* For user-approval statuses, the reason is emitted on the approval request so it can be shown to the approver.
|
|
1634
1640
|
*
|
|
1635
1641
|
* `undefined` is treated as the `not-applicable` status.
|
|
1636
1642
|
*/
|
|
@@ -1645,7 +1651,7 @@ type ToolApprovalStatus = undefined | 'not-applicable' | 'approved' | 'denied' |
|
|
|
1645
1651
|
reason?: string;
|
|
1646
1652
|
} | {
|
|
1647
1653
|
type: 'user-approval';
|
|
1648
|
-
reason?:
|
|
1654
|
+
reason?: string;
|
|
1649
1655
|
};
|
|
1650
1656
|
/**
|
|
1651
1657
|
* Function that is called to determine if the tool needs approval before it can be executed.
|
|
@@ -1700,6 +1706,8 @@ type GenericToolApprovalFunction<TOOLS extends ToolSet, TOOLS_CONTEXT extends In
|
|
|
1700
1706
|
* - 'user-approval': The tool requires user approval.
|
|
1701
1707
|
*
|
|
1702
1708
|
* In addition to the string statuses, you can also use object statuses with a reason property.
|
|
1709
|
+
* For approved and denied statuses, the reason is emitted on the approval response.
|
|
1710
|
+
* For user-approval statuses, the reason is emitted on the approval request so it can be shown to the approver.
|
|
1703
1711
|
*/
|
|
1704
1712
|
type ToolApprovalConfiguration<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context | unknown | never> = GenericToolApprovalFunction<TOOLS, InferToolSetContext<TOOLS>, RUNTIME_CONTEXT> | {
|
|
1705
1713
|
[key in keyof TOOLS]?: ToolApprovalStatus | SingleToolApprovalFunction<InferToolInput<TOOLS[key]>, InferToolContext<TOOLS[key]>, RUNTIME_CONTEXT>;
|
package/dist/internal/index.js
CHANGED
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
} from "@ai-sdk/provider-utils";
|
|
93
93
|
|
|
94
94
|
// src/version.ts
|
|
95
|
-
var VERSION = true ? "7.0.
|
|
95
|
+
var VERSION = true ? "7.0.83" : "0.0.0-test";
|
|
96
96
|
|
|
97
97
|
// src/util/download/download.ts
|
|
98
98
|
var download = async ({
|
|
@@ -1443,7 +1443,8 @@ var toolApprovalRequestSchema = z.object(
|
|
|
1443
1443
|
{
|
|
1444
1444
|
type: z.literal("tool-approval-request"),
|
|
1445
1445
|
approvalId: z.string(),
|
|
1446
|
-
toolCallId: z.string()
|
|
1446
|
+
toolCallId: z.string(),
|
|
1447
|
+
reason: z.string().optional()
|
|
1447
1448
|
}
|
|
1448
1449
|
);
|
|
1449
1450
|
var toolApprovalResponseSchema = z.object({
|
|
@@ -3568,6 +3569,7 @@ async function toResponseMessages({
|
|
|
3568
3569
|
type: "tool-approval-request",
|
|
3569
3570
|
approvalId: part.approvalId,
|
|
3570
3571
|
toolCallId: part.toolCall.toolCallId,
|
|
3572
|
+
...part.reason != null ? { reason: part.reason } : {},
|
|
3571
3573
|
isAutomatic: part.isAutomatic,
|
|
3572
3574
|
...part.signature != null ? { signature: part.signature } : {}
|
|
3573
3575
|
});
|