@fondation-io/ai 7.0.0-beta.45
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 +7687 -0
- package/README.md +238 -0
- package/dist/index.d.mts +7056 -0
- package/dist/index.d.ts +7056 -0
- package/dist/index.js +14607 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +14578 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internal/index.d.mts +303 -0
- package/dist/internal/index.d.ts +303 -0
- package/dist/internal/index.js +1352 -0
- package/dist/internal/index.js.map +1 -0
- package/dist/internal/index.mjs +1336 -0
- package/dist/internal/index.mjs.map +1 -0
- package/dist/test/index.d.mts +265 -0
- package/dist/test/index.d.ts +265 -0
- package/dist/test/index.js +509 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/index.mjs +472 -0
- package/dist/test/index.mjs.map +1 -0
- package/docs/00-introduction/index.mdx +76 -0
- package/docs/02-foundations/01-overview.mdx +43 -0
- package/docs/02-foundations/02-providers-and-models.mdx +160 -0
- package/docs/02-foundations/03-prompts.mdx +616 -0
- package/docs/02-foundations/04-tools.mdx +251 -0
- package/docs/02-foundations/05-streaming.mdx +62 -0
- package/docs/02-foundations/06-provider-options.mdx +345 -0
- package/docs/02-foundations/index.mdx +49 -0
- package/docs/02-getting-started/00-choosing-a-provider.mdx +110 -0
- package/docs/02-getting-started/01-navigating-the-library.mdx +85 -0
- package/docs/02-getting-started/02-nextjs-app-router.mdx +559 -0
- package/docs/02-getting-started/03-nextjs-pages-router.mdx +542 -0
- package/docs/02-getting-started/04-svelte.mdx +627 -0
- package/docs/02-getting-started/05-nuxt.mdx +566 -0
- package/docs/02-getting-started/06-nodejs.mdx +512 -0
- package/docs/02-getting-started/07-expo.mdx +766 -0
- package/docs/02-getting-started/08-tanstack-start.mdx +583 -0
- package/docs/02-getting-started/09-coding-agents.mdx +179 -0
- package/docs/02-getting-started/index.mdx +44 -0
- package/docs/03-agents/01-overview.mdx +96 -0
- package/docs/03-agents/02-building-agents.mdx +449 -0
- package/docs/03-agents/03-workflows.mdx +386 -0
- package/docs/03-agents/04-loop-control.mdx +394 -0
- package/docs/03-agents/05-configuring-call-options.mdx +286 -0
- package/docs/03-agents/06-memory.mdx +222 -0
- package/docs/03-agents/06-subagents.mdx +362 -0
- package/docs/03-agents/index.mdx +46 -0
- package/docs/03-ai-sdk-core/01-overview.mdx +31 -0
- package/docs/03-ai-sdk-core/05-generating-text.mdx +707 -0
- package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +498 -0
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +1148 -0
- package/docs/03-ai-sdk-core/16-mcp-tools.mdx +383 -0
- package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +146 -0
- package/docs/03-ai-sdk-core/25-settings.mdx +216 -0
- package/docs/03-ai-sdk-core/26-reasoning.mdx +190 -0
- package/docs/03-ai-sdk-core/30-embeddings.mdx +236 -0
- package/docs/03-ai-sdk-core/31-reranking.mdx +218 -0
- package/docs/03-ai-sdk-core/35-image-generation.mdx +341 -0
- package/docs/03-ai-sdk-core/36-transcription.mdx +227 -0
- package/docs/03-ai-sdk-core/37-speech.mdx +169 -0
- package/docs/03-ai-sdk-core/38-video-generation.mdx +366 -0
- package/docs/03-ai-sdk-core/40-middleware.mdx +485 -0
- package/docs/03-ai-sdk-core/45-provider-management.mdx +349 -0
- package/docs/03-ai-sdk-core/50-error-handling.mdx +149 -0
- package/docs/03-ai-sdk-core/55-testing.mdx +219 -0
- package/docs/03-ai-sdk-core/60-telemetry.mdx +391 -0
- package/docs/03-ai-sdk-core/65-devtools.mdx +107 -0
- package/docs/03-ai-sdk-core/65-event-listeners.mdx +1303 -0
- package/docs/03-ai-sdk-core/index.mdx +99 -0
- package/docs/04-ai-sdk-ui/01-overview.mdx +44 -0
- package/docs/04-ai-sdk-ui/02-chatbot.mdx +1320 -0
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +534 -0
- package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +263 -0
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +682 -0
- package/docs/04-ai-sdk-ui/04-generative-user-interfaces.mdx +389 -0
- package/docs/04-ai-sdk-ui/05-completion.mdx +181 -0
- package/docs/04-ai-sdk-ui/08-object-generation.mdx +344 -0
- package/docs/04-ai-sdk-ui/20-streaming-data.mdx +397 -0
- package/docs/04-ai-sdk-ui/21-error-handling.mdx +190 -0
- package/docs/04-ai-sdk-ui/21-transport.mdx +174 -0
- package/docs/04-ai-sdk-ui/24-reading-ui-message-streams.mdx +104 -0
- package/docs/04-ai-sdk-ui/25-message-metadata.mdx +152 -0
- package/docs/04-ai-sdk-ui/50-stream-protocol.mdx +503 -0
- package/docs/04-ai-sdk-ui/index.mdx +64 -0
- package/docs/05-ai-sdk-rsc/01-overview.mdx +45 -0
- package/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +209 -0
- package/docs/05-ai-sdk-rsc/03-generative-ui-state.mdx +279 -0
- package/docs/05-ai-sdk-rsc/03-saving-and-restoring-states.mdx +105 -0
- package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +282 -0
- package/docs/05-ai-sdk-rsc/05-streaming-values.mdx +157 -0
- package/docs/05-ai-sdk-rsc/06-loading-state.mdx +273 -0
- package/docs/05-ai-sdk-rsc/08-error-handling.mdx +94 -0
- package/docs/05-ai-sdk-rsc/09-authentication.mdx +42 -0
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +722 -0
- package/docs/05-ai-sdk-rsc/index.mdx +63 -0
- package/docs/06-advanced/01-prompt-engineering.mdx +96 -0
- package/docs/06-advanced/02-stopping-streams.mdx +184 -0
- package/docs/06-advanced/03-backpressure.mdx +173 -0
- package/docs/06-advanced/04-caching.mdx +169 -0
- package/docs/06-advanced/05-multiple-streamables.mdx +68 -0
- package/docs/06-advanced/06-rate-limiting.mdx +60 -0
- package/docs/06-advanced/07-rendering-ui-with-language-models.mdx +225 -0
- package/docs/06-advanced/08-model-as-router.mdx +120 -0
- package/docs/06-advanced/09-multistep-interfaces.mdx +115 -0
- package/docs/06-advanced/09-sequential-generations.mdx +55 -0
- package/docs/06-advanced/10-vercel-deployment-guide.mdx +117 -0
- package/docs/06-advanced/index.mdx +11 -0
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +2785 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +3752 -0
- package/docs/07-reference/01-ai-sdk-core/05-embed.mdx +332 -0
- package/docs/07-reference/01-ai-sdk-core/06-embed-many.mdx +330 -0
- package/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +323 -0
- package/docs/07-reference/01-ai-sdk-core/10-generate-image.mdx +251 -0
- package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +152 -0
- package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +221 -0
- package/docs/07-reference/01-ai-sdk-core/13-generate-video.mdx +264 -0
- package/docs/07-reference/01-ai-sdk-core/15-agent.mdx +235 -0
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +973 -0
- package/docs/07-reference/01-ai-sdk-core/17-create-agent-ui-stream.mdx +154 -0
- package/docs/07-reference/01-ai-sdk-core/18-create-agent-ui-stream-response.mdx +173 -0
- package/docs/07-reference/01-ai-sdk-core/18-pipe-agent-ui-stream-to-response.mdx +150 -0
- package/docs/07-reference/01-ai-sdk-core/20-tool.mdx +209 -0
- package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +223 -0
- package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +423 -0
- package/docs/07-reference/01-ai-sdk-core/24-mcp-stdio-transport.mdx +68 -0
- package/docs/07-reference/01-ai-sdk-core/25-json-schema.mdx +94 -0
- package/docs/07-reference/01-ai-sdk-core/26-zod-schema.mdx +109 -0
- package/docs/07-reference/01-ai-sdk-core/27-valibot-schema.mdx +58 -0
- package/docs/07-reference/01-ai-sdk-core/28-output.mdx +342 -0
- package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +435 -0
- package/docs/07-reference/01-ai-sdk-core/31-ui-message.mdx +264 -0
- package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +101 -0
- package/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +113 -0
- package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +198 -0
- package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +157 -0
- package/docs/07-reference/01-ai-sdk-core/50-cosine-similarity.mdx +52 -0
- package/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +59 -0
- package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +64 -0
- package/docs/07-reference/01-ai-sdk-core/65-language-model-v2-middleware.mdx +74 -0
- package/docs/07-reference/01-ai-sdk-core/66-extract-reasoning-middleware.mdx +68 -0
- package/docs/07-reference/01-ai-sdk-core/67-simulate-streaming-middleware.mdx +71 -0
- package/docs/07-reference/01-ai-sdk-core/68-default-settings-middleware.mdx +80 -0
- package/docs/07-reference/01-ai-sdk-core/69-add-tool-input-examples-middleware.mdx +155 -0
- package/docs/07-reference/01-ai-sdk-core/70-extract-json-middleware.mdx +147 -0
- package/docs/07-reference/01-ai-sdk-core/70-step-count-is.mdx +84 -0
- package/docs/07-reference/01-ai-sdk-core/71-has-tool-call.mdx +120 -0
- package/docs/07-reference/01-ai-sdk-core/75-simulate-readable-stream.mdx +94 -0
- package/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +145 -0
- package/docs/07-reference/01-ai-sdk-core/90-generate-id.mdx +30 -0
- package/docs/07-reference/01-ai-sdk-core/91-create-id-generator.mdx +89 -0
- package/docs/07-reference/01-ai-sdk-core/92-default-generated-file.mdx +68 -0
- package/docs/07-reference/01-ai-sdk-core/index.mdx +160 -0
- package/docs/07-reference/02-ai-sdk-ui/01-use-chat.mdx +493 -0
- package/docs/07-reference/02-ai-sdk-ui/02-use-completion.mdx +185 -0
- package/docs/07-reference/02-ai-sdk-ui/03-use-object.mdx +196 -0
- package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +231 -0
- package/docs/07-reference/02-ai-sdk-ui/32-prune-messages.mdx +108 -0
- package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +162 -0
- package/docs/07-reference/02-ai-sdk-ui/41-create-ui-message-stream-response.mdx +119 -0
- package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +77 -0
- package/docs/07-reference/02-ai-sdk-ui/43-read-ui-message-stream.mdx +57 -0
- package/docs/07-reference/02-ai-sdk-ui/46-infer-ui-tools.mdx +99 -0
- package/docs/07-reference/02-ai-sdk-ui/47-infer-ui-tool.mdx +75 -0
- package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +333 -0
- package/docs/07-reference/02-ai-sdk-ui/index.mdx +89 -0
- package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +767 -0
- package/docs/07-reference/03-ai-sdk-rsc/02-create-ai.mdx +90 -0
- package/docs/07-reference/03-ai-sdk-rsc/03-create-streamable-ui.mdx +91 -0
- package/docs/07-reference/03-ai-sdk-rsc/04-create-streamable-value.mdx +78 -0
- package/docs/07-reference/03-ai-sdk-rsc/05-read-streamable-value.mdx +79 -0
- package/docs/07-reference/03-ai-sdk-rsc/06-get-ai-state.mdx +50 -0
- package/docs/07-reference/03-ai-sdk-rsc/07-get-mutable-ai-state.mdx +70 -0
- package/docs/07-reference/03-ai-sdk-rsc/08-use-ai-state.mdx +26 -0
- package/docs/07-reference/03-ai-sdk-rsc/09-use-actions.mdx +42 -0
- package/docs/07-reference/03-ai-sdk-rsc/10-use-ui-state.mdx +35 -0
- package/docs/07-reference/03-ai-sdk-rsc/11-use-streamable-value.mdx +46 -0
- package/docs/07-reference/03-ai-sdk-rsc/20-render.mdx +266 -0
- package/docs/07-reference/03-ai-sdk-rsc/index.mdx +67 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-api-call-error.mdx +31 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-download-error.mdx +28 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-empty-response-body-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-argument-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-data-content-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-message-role-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-prompt-error.mdx +47 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-response-data-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-approval-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-input-error.mdx +27 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-json-parse-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-load-api-key-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-load-setting-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-message-conversion-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-content-generated-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-image-generated-error.mdx +36 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-object-generated-error.mdx +43 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-output-generated-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-speech-generated-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-such-model-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-such-provider-error.mdx +28 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-such-tool-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-transcript-generated-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-video-generated-error.mdx +39 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-retry-error.mdx +27 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-too-many-embedding-values-for-call-error.mdx +27 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-tool-call-not-found-for-approval-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-tool-call-repair-error.mdx +28 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-type-validation-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-ui-message-stream-error.mdx +67 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-unsupported-functionality-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/index.mdx +39 -0
- package/docs/07-reference/index.mdx +28 -0
- package/docs/08-migration-guides/00-versioning.mdx +46 -0
- package/docs/08-migration-guides/23-migration-guide-7-0.mdx +95 -0
- package/docs/08-migration-guides/24-migration-guide-6-0.mdx +823 -0
- package/docs/08-migration-guides/25-migration-guide-5-0-data.mdx +882 -0
- package/docs/08-migration-guides/26-migration-guide-5-0.mdx +3427 -0
- package/docs/08-migration-guides/27-migration-guide-4-2.mdx +99 -0
- package/docs/08-migration-guides/28-migration-guide-4-1.mdx +14 -0
- package/docs/08-migration-guides/29-migration-guide-4-0.mdx +1157 -0
- package/docs/08-migration-guides/36-migration-guide-3-4.mdx +14 -0
- package/docs/08-migration-guides/37-migration-guide-3-3.mdx +64 -0
- package/docs/08-migration-guides/38-migration-guide-3-2.mdx +46 -0
- package/docs/08-migration-guides/39-migration-guide-3-1.mdx +168 -0
- package/docs/08-migration-guides/index.mdx +22 -0
- package/docs/09-troubleshooting/01-azure-stream-slow.mdx +33 -0
- package/docs/09-troubleshooting/03-server-actions-in-client-components.mdx +40 -0
- package/docs/09-troubleshooting/04-strange-stream-output.mdx +36 -0
- package/docs/09-troubleshooting/05-streamable-ui-errors.mdx +16 -0
- package/docs/09-troubleshooting/05-tool-invocation-missing-result.mdx +106 -0
- package/docs/09-troubleshooting/06-streaming-not-working-when-deployed.mdx +31 -0
- package/docs/09-troubleshooting/06-streaming-not-working-when-proxied.mdx +31 -0
- package/docs/09-troubleshooting/06-timeout-on-vercel.mdx +60 -0
- package/docs/09-troubleshooting/07-unclosed-streams.mdx +34 -0
- package/docs/09-troubleshooting/08-use-chat-failed-to-parse-stream.mdx +26 -0
- package/docs/09-troubleshooting/09-client-stream-error.mdx +25 -0
- package/docs/09-troubleshooting/10-use-chat-tools-no-response.mdx +32 -0
- package/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +149 -0
- package/docs/09-troubleshooting/12-typescript-performance-zod.mdx +46 -0
- package/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +59 -0
- package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +73 -0
- package/docs/09-troubleshooting/14-stream-abort-handling.mdx +73 -0
- package/docs/09-troubleshooting/14-tool-calling-with-structured-outputs.mdx +48 -0
- package/docs/09-troubleshooting/15-abort-breaks-resumable-streams.mdx +55 -0
- package/docs/09-troubleshooting/15-stream-text-not-working.mdx +33 -0
- package/docs/09-troubleshooting/16-streaming-status-delay.mdx +63 -0
- package/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +141 -0
- package/docs/09-troubleshooting/18-ontoolcall-type-narrowing.mdx +66 -0
- package/docs/09-troubleshooting/19-unsupported-model-version.mdx +50 -0
- package/docs/09-troubleshooting/20-no-object-generated-content-filter.mdx +76 -0
- package/docs/09-troubleshooting/21-missing-tool-results-error.mdx +82 -0
- package/docs/09-troubleshooting/30-model-is-not-assignable-to-type.mdx +21 -0
- package/docs/09-troubleshooting/40-typescript-cannot-find-namespace-jsx.mdx +24 -0
- package/docs/09-troubleshooting/50-react-maximum-update-depth-exceeded.mdx +39 -0
- package/docs/09-troubleshooting/60-jest-cannot-find-module-ai-rsc.mdx +22 -0
- package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +108 -0
- package/docs/09-troubleshooting/index.mdx +11 -0
- package/internal.d.ts +1 -0
- package/package.json +120 -0
- package/src/agent/agent.ts +156 -0
- package/src/agent/create-agent-ui-stream-response.ts +61 -0
- package/src/agent/create-agent-ui-stream.ts +84 -0
- package/src/agent/index.ts +37 -0
- package/src/agent/infer-agent-tools.ts +7 -0
- package/src/agent/infer-agent-ui-message.ts +11 -0
- package/src/agent/pipe-agent-ui-stream-to-response.ts +64 -0
- package/src/agent/tool-loop-agent-settings.ts +252 -0
- package/src/agent/tool-loop-agent.ts +205 -0
- package/src/embed/embed-events.ts +181 -0
- package/src/embed/embed-many-result.ts +53 -0
- package/src/embed/embed-many.ts +428 -0
- package/src/embed/embed-result.ts +50 -0
- package/src/embed/embed.ts +266 -0
- package/src/embed/index.ts +5 -0
- package/src/error/index.ts +37 -0
- package/src/error/invalid-argument-error.ts +34 -0
- package/src/error/invalid-stream-part-error.ts +28 -0
- package/src/error/invalid-tool-approval-error.ts +26 -0
- package/src/error/invalid-tool-input-error.ts +33 -0
- package/src/error/missing-tool-result-error.ts +28 -0
- package/src/error/no-image-generated-error.ts +39 -0
- package/src/error/no-object-generated-error.ts +70 -0
- package/src/error/no-output-generated-error.ts +26 -0
- package/src/error/no-speech-generated-error.ts +28 -0
- package/src/error/no-such-tool-error.ts +35 -0
- package/src/error/no-transcript-generated-error.ts +30 -0
- package/src/error/no-video-generated-error.ts +57 -0
- package/src/error/tool-call-not-found-for-approval-error.ts +32 -0
- package/src/error/tool-call-repair-error.ts +30 -0
- package/src/error/ui-message-stream-error.ts +48 -0
- package/src/error/unsupported-model-version-error.ts +23 -0
- package/src/error/verify-no-object-generated-error.ts +27 -0
- package/src/generate-image/generate-image-result.ts +42 -0
- package/src/generate-image/generate-image.ts +361 -0
- package/src/generate-image/index.ts +18 -0
- package/src/generate-object/generate-object-result.ts +67 -0
- package/src/generate-object/generate-object.ts +514 -0
- package/src/generate-object/index.ts +9 -0
- package/src/generate-object/inject-json-instruction.ts +30 -0
- package/src/generate-object/output-strategy.ts +415 -0
- package/src/generate-object/parse-and-validate-object-result.ts +111 -0
- package/src/generate-object/repair-text.ts +12 -0
- package/src/generate-object/stream-object-result.ts +120 -0
- package/src/generate-object/stream-object.ts +984 -0
- package/src/generate-object/validate-object-generation-input.ts +144 -0
- package/src/generate-speech/generate-speech-result.ts +30 -0
- package/src/generate-speech/generate-speech.ts +191 -0
- package/src/generate-speech/generated-audio-file.ts +65 -0
- package/src/generate-speech/index.ts +3 -0
- package/src/generate-text/collect-tool-approvals.ts +116 -0
- package/src/generate-text/content-part.ts +31 -0
- package/src/generate-text/core-events.ts +390 -0
- package/src/generate-text/create-execute-tools-transformation.ts +144 -0
- package/src/generate-text/execute-tool-call.ts +190 -0
- package/src/generate-text/extract-reasoning-content.ts +17 -0
- package/src/generate-text/extract-text-content.ts +15 -0
- package/src/generate-text/generate-text-result.ts +168 -0
- package/src/generate-text/generate-text.ts +1445 -0
- package/src/generate-text/generated-file.ts +70 -0
- package/src/generate-text/index.ts +78 -0
- package/src/generate-text/invoke-tool-callbacks-from-stream.ts +81 -0
- package/src/generate-text/is-approval-needed.ts +29 -0
- package/src/generate-text/output-utils.ts +23 -0
- package/src/generate-text/output.ts +590 -0
- package/src/generate-text/parse-tool-call.ts +188 -0
- package/src/generate-text/prepare-step.ts +103 -0
- package/src/generate-text/prune-messages.ts +167 -0
- package/src/generate-text/reasoning-output.ts +99 -0
- package/src/generate-text/reasoning.ts +10 -0
- package/src/generate-text/response-message.ts +10 -0
- package/src/generate-text/smooth-stream.ts +162 -0
- package/src/generate-text/step-result.ts +310 -0
- package/src/generate-text/stop-condition.ts +29 -0
- package/src/generate-text/stream-model-call.ts +418 -0
- package/src/generate-text/stream-text-result.ts +536 -0
- package/src/generate-text/stream-text.ts +2696 -0
- package/src/generate-text/to-response-messages.ts +195 -0
- package/src/generate-text/tool-approval-request-output.ts +21 -0
- package/src/generate-text/tool-call-repair-function.ts +27 -0
- package/src/generate-text/tool-call.ts +47 -0
- package/src/generate-text/tool-error.ts +34 -0
- package/src/generate-text/tool-output-denied.ts +21 -0
- package/src/generate-text/tool-output.ts +7 -0
- package/src/generate-text/tool-result.ts +36 -0
- package/src/generate-text/tool-set.ts +14 -0
- package/src/generate-video/generate-video-result.ts +36 -0
- package/src/generate-video/generate-video.ts +402 -0
- package/src/generate-video/index.ts +3 -0
- package/src/global.ts +36 -0
- package/src/index.ts +49 -0
- package/src/logger/index.ts +6 -0
- package/src/logger/log-warnings.ts +140 -0
- package/src/middleware/add-tool-input-examples-middleware.ts +90 -0
- package/src/middleware/default-embedding-settings-middleware.ts +22 -0
- package/src/middleware/default-settings-middleware.ts +33 -0
- package/src/middleware/extract-json-middleware.ts +197 -0
- package/src/middleware/extract-reasoning-middleware.ts +249 -0
- package/src/middleware/index.ts +10 -0
- package/src/middleware/simulate-streaming-middleware.ts +79 -0
- package/src/middleware/wrap-embedding-model.ts +89 -0
- package/src/middleware/wrap-image-model.ts +92 -0
- package/src/middleware/wrap-language-model.ts +108 -0
- package/src/middleware/wrap-provider.ts +51 -0
- package/src/model/as-embedding-model-v3.ts +24 -0
- package/src/model/as-embedding-model-v4.ts +25 -0
- package/src/model/as-image-model-v3.ts +24 -0
- package/src/model/as-image-model-v4.ts +21 -0
- package/src/model/as-language-model-v3.ts +103 -0
- package/src/model/as-language-model-v4.ts +25 -0
- package/src/model/as-provider-v3.ts +36 -0
- package/src/model/as-provider-v4.ts +47 -0
- package/src/model/as-reranking-model-v4.ts +16 -0
- package/src/model/as-speech-model-v3.ts +24 -0
- package/src/model/as-speech-model-v4.ts +21 -0
- package/src/model/as-transcription-model-v3.ts +24 -0
- package/src/model/as-transcription-model-v4.ts +25 -0
- package/src/model/as-video-model-v4.ts +19 -0
- package/src/model/resolve-model.ts +172 -0
- package/src/prompt/call-settings.ts +169 -0
- package/src/prompt/content-part.ts +236 -0
- package/src/prompt/convert-to-language-model-prompt.ts +548 -0
- package/src/prompt/create-tool-model-output.ts +34 -0
- package/src/prompt/data-content.ts +134 -0
- package/src/prompt/index.ts +27 -0
- package/src/prompt/invalid-data-content-error.ts +29 -0
- package/src/prompt/invalid-message-role-error.ts +27 -0
- package/src/prompt/message-conversion-error.ts +28 -0
- package/src/prompt/message.ts +72 -0
- package/src/prompt/prepare-call-settings.ts +110 -0
- package/src/prompt/prepare-tools-and-tool-choice.ts +86 -0
- package/src/prompt/prompt.ts +43 -0
- package/src/prompt/split-data-url.ts +17 -0
- package/src/prompt/standardize-prompt.ts +99 -0
- package/src/prompt/wrap-gateway-error.ts +29 -0
- package/src/registry/custom-provider.ts +210 -0
- package/src/registry/index.ts +7 -0
- package/src/registry/no-such-provider-error.ts +41 -0
- package/src/registry/provider-registry.ts +331 -0
- package/src/rerank/index.ts +8 -0
- package/src/rerank/rerank-events.ts +189 -0
- package/src/rerank/rerank-result.ts +70 -0
- package/src/rerank/rerank.ts +348 -0
- package/src/telemetry/assemble-operation-name.ts +21 -0
- package/src/telemetry/get-base-telemetry-attributes.ts +45 -0
- package/src/telemetry/get-global-telemetry-integration.ts +126 -0
- package/src/telemetry/get-tracer.ts +20 -0
- package/src/telemetry/index.ts +4 -0
- package/src/telemetry/noop-tracer.ts +69 -0
- package/src/telemetry/open-telemetry-integration.ts +875 -0
- package/src/telemetry/record-span.ts +75 -0
- package/src/telemetry/select-telemetry-attributes.ts +78 -0
- package/src/telemetry/stringify-for-telemetry.ts +33 -0
- package/src/telemetry/telemetry-integration-registry.ts +22 -0
- package/src/telemetry/telemetry-integration.ts +139 -0
- package/src/telemetry/telemetry-settings.ts +55 -0
- package/src/test/mock-embedding-model-v2.ts +35 -0
- package/src/test/mock-embedding-model-v3.ts +48 -0
- package/src/test/mock-embedding-model-v4.ts +48 -0
- package/src/test/mock-image-model-v2.ts +28 -0
- package/src/test/mock-image-model-v3.ts +28 -0
- package/src/test/mock-image-model-v4.ts +28 -0
- package/src/test/mock-language-model-v2.ts +72 -0
- package/src/test/mock-language-model-v3.ts +77 -0
- package/src/test/mock-language-model-v4.ts +77 -0
- package/src/test/mock-provider-v2.ts +68 -0
- package/src/test/mock-provider-v3.ts +80 -0
- package/src/test/mock-provider-v4.ts +80 -0
- package/src/test/mock-reranking-model-v3.ts +25 -0
- package/src/test/mock-reranking-model-v4.ts +25 -0
- package/src/test/mock-server-response.ts +69 -0
- package/src/test/mock-speech-model-v2.ts +24 -0
- package/src/test/mock-speech-model-v3.ts +24 -0
- package/src/test/mock-speech-model-v4.ts +24 -0
- package/src/test/mock-tracer.ts +156 -0
- package/src/test/mock-transcription-model-v2.ts +24 -0
- package/src/test/mock-transcription-model-v3.ts +24 -0
- package/src/test/mock-transcription-model-v4.ts +24 -0
- package/src/test/mock-values.ts +4 -0
- package/src/test/mock-video-model-v3.ts +28 -0
- package/src/test/mock-video-model-v4.ts +28 -0
- package/src/test/not-implemented.ts +3 -0
- package/src/text-stream/create-text-stream-response.ts +30 -0
- package/src/text-stream/index.ts +2 -0
- package/src/text-stream/pipe-text-stream-to-response.ts +38 -0
- package/src/transcribe/index.ts +2 -0
- package/src/transcribe/transcribe-result.ts +60 -0
- package/src/transcribe/transcribe.ts +187 -0
- package/src/types/embedding-model-middleware.ts +15 -0
- package/src/types/embedding-model.ts +20 -0
- package/src/types/image-model-middleware.ts +15 -0
- package/src/types/image-model-response-metadata.ts +16 -0
- package/src/types/image-model.ts +19 -0
- package/src/types/index.ts +29 -0
- package/src/types/json-value.ts +15 -0
- package/src/types/language-model-middleware.ts +15 -0
- package/src/types/language-model-request-metadata.ts +6 -0
- package/src/types/language-model-response-metadata.ts +21 -0
- package/src/types/language-model.ts +106 -0
- package/src/types/provider-metadata.ts +16 -0
- package/src/types/provider.ts +55 -0
- package/src/types/reranking-model.ts +6 -0
- package/src/types/speech-model-response-metadata.ts +21 -0
- package/src/types/speech-model.ts +10 -0
- package/src/types/transcription-model-response-metadata.ts +16 -0
- package/src/types/transcription-model.ts +14 -0
- package/src/types/usage.ts +200 -0
- package/src/types/video-model-response-metadata.ts +28 -0
- package/src/types/video-model.ts +15 -0
- package/src/types/warning.ts +7 -0
- package/src/ui/call-completion-api.ts +157 -0
- package/src/ui/chat-transport.ts +83 -0
- package/src/ui/chat.ts +786 -0
- package/src/ui/convert-file-list-to-file-ui-parts.ts +36 -0
- package/src/ui/convert-to-model-messages.ts +403 -0
- package/src/ui/default-chat-transport.ts +36 -0
- package/src/ui/direct-chat-transport.ts +117 -0
- package/src/ui/http-chat-transport.ts +273 -0
- package/src/ui/index.ts +76 -0
- package/src/ui/last-assistant-message-is-complete-with-approval-responses.ts +44 -0
- package/src/ui/last-assistant-message-is-complete-with-tool-calls.ts +39 -0
- package/src/ui/process-text-stream.ts +16 -0
- package/src/ui/process-ui-message-stream.ts +858 -0
- package/src/ui/text-stream-chat-transport.ts +23 -0
- package/src/ui/transform-text-to-ui-message-stream.ts +27 -0
- package/src/ui/ui-messages.ts +602 -0
- package/src/ui/use-completion.ts +84 -0
- package/src/ui/validate-ui-messages.ts +521 -0
- package/src/ui-message-stream/create-ui-message-stream-response.ts +44 -0
- package/src/ui-message-stream/create-ui-message-stream.ts +145 -0
- package/src/ui-message-stream/get-response-ui-message-id.ts +35 -0
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +170 -0
- package/src/ui-message-stream/index.ts +14 -0
- package/src/ui-message-stream/json-to-sse-transform-stream.ts +17 -0
- package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +51 -0
- package/src/ui-message-stream/read-ui-message-stream.ts +87 -0
- package/src/ui-message-stream/ui-message-chunks.ts +372 -0
- package/src/ui-message-stream/ui-message-stream-headers.ts +7 -0
- package/src/ui-message-stream/ui-message-stream-on-finish-callback.ts +32 -0
- package/src/ui-message-stream/ui-message-stream-on-step-finish-callback.ts +25 -0
- package/src/ui-message-stream/ui-message-stream-response-init.ts +14 -0
- package/src/ui-message-stream/ui-message-stream-writer.ts +24 -0
- package/src/util/as-array.ts +3 -0
- package/src/util/async-iterable-stream.ts +94 -0
- package/src/util/consume-stream.ts +31 -0
- package/src/util/cosine-similarity.ts +46 -0
- package/src/util/create-resolvable-promise.ts +30 -0
- package/src/util/create-stitchable-stream.ts +112 -0
- package/src/util/data-url.ts +17 -0
- package/src/util/deep-partial.ts +84 -0
- package/src/util/detect-media-type.ts +226 -0
- package/src/util/download/create-download.ts +13 -0
- package/src/util/download/download-function.ts +45 -0
- package/src/util/download/download.ts +74 -0
- package/src/util/error-handler.ts +1 -0
- package/src/util/fix-json.ts +401 -0
- package/src/util/get-potential-start-index.ts +39 -0
- package/src/util/index.ts +12 -0
- package/src/util/is-deep-equal-data.ts +48 -0
- package/src/util/is-non-empty-object.ts +5 -0
- package/src/util/job.ts +1 -0
- package/src/util/log-v2-compatibility-warning.ts +21 -0
- package/src/util/merge-abort-signals.ts +43 -0
- package/src/util/merge-objects.ts +79 -0
- package/src/util/notify.ts +22 -0
- package/src/util/now.ts +4 -0
- package/src/util/parse-partial-json.ts +30 -0
- package/src/util/prepare-headers.ts +14 -0
- package/src/util/prepare-retries.ts +47 -0
- package/src/util/retry-error.ts +41 -0
- package/src/util/retry-with-exponential-backoff.ts +154 -0
- package/src/util/serial-job-executor.ts +36 -0
- package/src/util/simulate-readable-stream.ts +39 -0
- package/src/util/split-array.ts +20 -0
- package/src/util/value-of.ts +65 -0
- package/src/util/write-to-server-response.ts +49 -0
- package/src/version.ts +5 -0
- package/test.d.ts +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SpeechModelV2, SpeechModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { logV2CompatibilityWarning } from '../util/log-v2-compatibility-warning';
|
|
3
|
+
|
|
4
|
+
export function asSpeechModelV3(
|
|
5
|
+
model: SpeechModelV3 | SpeechModelV2,
|
|
6
|
+
): SpeechModelV3 {
|
|
7
|
+
if (model.specificationVersion === 'v3') {
|
|
8
|
+
return model;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
logV2CompatibilityWarning({
|
|
12
|
+
provider: model.provider,
|
|
13
|
+
modelId: model.modelId,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// TODO this could break, we need to properly map v2 to v3
|
|
17
|
+
// and support all relevant v3 properties:
|
|
18
|
+
return new Proxy(model, {
|
|
19
|
+
get(target, prop: keyof SpeechModelV2) {
|
|
20
|
+
if (prop === 'specificationVersion') return 'v3';
|
|
21
|
+
return target[prop];
|
|
22
|
+
},
|
|
23
|
+
}) as unknown as SpeechModelV3;
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SpeechModelV2, SpeechModelV3, SpeechModelV4 } from '@ai-sdk/provider';
|
|
2
|
+
import { asSpeechModelV3 } from './as-speech-model-v3';
|
|
3
|
+
|
|
4
|
+
export function asSpeechModelV4(
|
|
5
|
+
model: SpeechModelV2 | SpeechModelV3 | SpeechModelV4,
|
|
6
|
+
): SpeechModelV4 {
|
|
7
|
+
if (model.specificationVersion === 'v4') {
|
|
8
|
+
return model;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// first convert v2 to v3, then proxy v3 as v4:
|
|
12
|
+
const v3Model =
|
|
13
|
+
model.specificationVersion === 'v2' ? asSpeechModelV3(model) : model;
|
|
14
|
+
|
|
15
|
+
return new Proxy(v3Model, {
|
|
16
|
+
get(target, prop: keyof SpeechModelV3) {
|
|
17
|
+
if (prop === 'specificationVersion') return 'v4';
|
|
18
|
+
return target[prop];
|
|
19
|
+
},
|
|
20
|
+
}) as unknown as SpeechModelV4;
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TranscriptionModelV2, TranscriptionModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { logV2CompatibilityWarning } from '../util/log-v2-compatibility-warning';
|
|
3
|
+
|
|
4
|
+
export function asTranscriptionModelV3(
|
|
5
|
+
model: TranscriptionModelV3 | TranscriptionModelV2,
|
|
6
|
+
): TranscriptionModelV3 {
|
|
7
|
+
if (model.specificationVersion === 'v3') {
|
|
8
|
+
return model;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
logV2CompatibilityWarning({
|
|
12
|
+
provider: model.provider,
|
|
13
|
+
modelId: model.modelId,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// TODO this could break, we need to properly map v2 to v3
|
|
17
|
+
// and support all relevant v3 properties:
|
|
18
|
+
return new Proxy(model, {
|
|
19
|
+
get(target, prop: keyof TranscriptionModelV2) {
|
|
20
|
+
if (prop === 'specificationVersion') return 'v3';
|
|
21
|
+
return target[prop];
|
|
22
|
+
},
|
|
23
|
+
}) as unknown as TranscriptionModelV3;
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TranscriptionModelV2,
|
|
3
|
+
TranscriptionModelV3,
|
|
4
|
+
TranscriptionModelV4,
|
|
5
|
+
} from '@ai-sdk/provider';
|
|
6
|
+
import { asTranscriptionModelV3 } from './as-transcription-model-v3';
|
|
7
|
+
|
|
8
|
+
export function asTranscriptionModelV4(
|
|
9
|
+
model: TranscriptionModelV2 | TranscriptionModelV3 | TranscriptionModelV4,
|
|
10
|
+
): TranscriptionModelV4 {
|
|
11
|
+
if (model.specificationVersion === 'v4') {
|
|
12
|
+
return model;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// first convert v2 to v3, then proxy v3 as v4:
|
|
16
|
+
const v3Model =
|
|
17
|
+
model.specificationVersion === 'v2' ? asTranscriptionModelV3(model) : model;
|
|
18
|
+
|
|
19
|
+
return new Proxy(v3Model, {
|
|
20
|
+
get(target, prop: keyof TranscriptionModelV3) {
|
|
21
|
+
if (prop === 'specificationVersion') return 'v4';
|
|
22
|
+
return target[prop];
|
|
23
|
+
},
|
|
24
|
+
}) as unknown as TranscriptionModelV4;
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Experimental_VideoModelV3,
|
|
3
|
+
Experimental_VideoModelV4,
|
|
4
|
+
} from '@ai-sdk/provider';
|
|
5
|
+
|
|
6
|
+
export function asVideoModelV4(
|
|
7
|
+
model: Experimental_VideoModelV3 | Experimental_VideoModelV4,
|
|
8
|
+
): Experimental_VideoModelV4 {
|
|
9
|
+
if (model.specificationVersion === 'v4') {
|
|
10
|
+
return model;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return new Proxy(model, {
|
|
14
|
+
get(target, prop: keyof Experimental_VideoModelV3) {
|
|
15
|
+
if (prop === 'specificationVersion') return 'v4';
|
|
16
|
+
return target[prop];
|
|
17
|
+
},
|
|
18
|
+
}) as unknown as Experimental_VideoModelV4;
|
|
19
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { gateway } from '@ai-sdk/gateway';
|
|
2
|
+
import {
|
|
3
|
+
EmbeddingModelV4,
|
|
4
|
+
Experimental_VideoModelV4,
|
|
5
|
+
ImageModelV4,
|
|
6
|
+
LanguageModelV4,
|
|
7
|
+
ProviderV4,
|
|
8
|
+
SpeechModelV4,
|
|
9
|
+
TranscriptionModelV4,
|
|
10
|
+
} from '@ai-sdk/provider';
|
|
11
|
+
import { UnsupportedModelVersionError } from '../error';
|
|
12
|
+
import { EmbeddingModel } from '../types/embedding-model';
|
|
13
|
+
import { LanguageModel } from '../types/language-model';
|
|
14
|
+
import { SpeechModel } from '../types/speech-model';
|
|
15
|
+
import { TranscriptionModel } from '../types/transcription-model';
|
|
16
|
+
import { asEmbeddingModelV4 } from './as-embedding-model-v4';
|
|
17
|
+
import { asImageModelV4 } from './as-image-model-v4';
|
|
18
|
+
import { asLanguageModelV4 } from './as-language-model-v4';
|
|
19
|
+
import { asSpeechModelV4 } from './as-speech-model-v4';
|
|
20
|
+
import { asTranscriptionModelV4 } from './as-transcription-model-v4';
|
|
21
|
+
import { asVideoModelV4 } from './as-video-model-v4';
|
|
22
|
+
import { asProviderV4 } from './as-provider-v4';
|
|
23
|
+
import { ImageModel } from '../types/image-model';
|
|
24
|
+
import { VideoModel } from '../types/video-model';
|
|
25
|
+
|
|
26
|
+
export function resolveLanguageModel(model: LanguageModel): LanguageModelV4 {
|
|
27
|
+
if (typeof model !== 'string') {
|
|
28
|
+
if (
|
|
29
|
+
model.specificationVersion !== 'v4' &&
|
|
30
|
+
model.specificationVersion !== 'v3' &&
|
|
31
|
+
model.specificationVersion !== 'v2'
|
|
32
|
+
) {
|
|
33
|
+
const unsupportedModel: any = model;
|
|
34
|
+
throw new UnsupportedModelVersionError({
|
|
35
|
+
version: unsupportedModel.specificationVersion,
|
|
36
|
+
provider: unsupportedModel.provider,
|
|
37
|
+
modelId: unsupportedModel.modelId,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return asLanguageModelV4(model);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return getGlobalProvider().languageModel(model);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function resolveEmbeddingModel(model: EmbeddingModel): EmbeddingModelV4 {
|
|
48
|
+
if (typeof model !== 'string') {
|
|
49
|
+
if (
|
|
50
|
+
model.specificationVersion !== 'v4' &&
|
|
51
|
+
model.specificationVersion !== 'v3' &&
|
|
52
|
+
model.specificationVersion !== 'v2'
|
|
53
|
+
) {
|
|
54
|
+
const unsupportedModel: any = model;
|
|
55
|
+
throw new UnsupportedModelVersionError({
|
|
56
|
+
version: unsupportedModel.specificationVersion,
|
|
57
|
+
provider: unsupportedModel.provider,
|
|
58
|
+
modelId: unsupportedModel.modelId,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return asEmbeddingModelV4(model);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return getGlobalProvider().embeddingModel(model);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function resolveTranscriptionModel(
|
|
69
|
+
model: TranscriptionModel,
|
|
70
|
+
): TranscriptionModelV4 | undefined {
|
|
71
|
+
if (typeof model !== 'string') {
|
|
72
|
+
if (
|
|
73
|
+
model.specificationVersion !== 'v4' &&
|
|
74
|
+
model.specificationVersion !== 'v3' &&
|
|
75
|
+
model.specificationVersion !== 'v2'
|
|
76
|
+
) {
|
|
77
|
+
const unsupportedModel: any = model;
|
|
78
|
+
throw new UnsupportedModelVersionError({
|
|
79
|
+
version: unsupportedModel.specificationVersion,
|
|
80
|
+
provider: unsupportedModel.provider,
|
|
81
|
+
modelId: unsupportedModel.modelId,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return asTranscriptionModelV4(model);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return getGlobalProvider().transcriptionModel?.(model);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function resolveSpeechModel(
|
|
91
|
+
model: SpeechModel,
|
|
92
|
+
): SpeechModelV4 | undefined {
|
|
93
|
+
if (typeof model !== 'string') {
|
|
94
|
+
if (
|
|
95
|
+
model.specificationVersion !== 'v4' &&
|
|
96
|
+
model.specificationVersion !== 'v3' &&
|
|
97
|
+
model.specificationVersion !== 'v2'
|
|
98
|
+
) {
|
|
99
|
+
const unsupportedModel: any = model;
|
|
100
|
+
throw new UnsupportedModelVersionError({
|
|
101
|
+
version: unsupportedModel.specificationVersion,
|
|
102
|
+
provider: unsupportedModel.provider,
|
|
103
|
+
modelId: unsupportedModel.modelId,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return asSpeechModelV4(model);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return getGlobalProvider().speechModel?.(model);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function resolveImageModel(model: ImageModel): ImageModelV4 {
|
|
113
|
+
if (typeof model !== 'string') {
|
|
114
|
+
if (
|
|
115
|
+
model.specificationVersion !== 'v4' &&
|
|
116
|
+
model.specificationVersion !== 'v3' &&
|
|
117
|
+
model.specificationVersion !== 'v2'
|
|
118
|
+
) {
|
|
119
|
+
const unsupportedModel: any = model;
|
|
120
|
+
throw new UnsupportedModelVersionError({
|
|
121
|
+
version: unsupportedModel.specificationVersion,
|
|
122
|
+
provider: unsupportedModel.provider,
|
|
123
|
+
modelId: unsupportedModel.modelId,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return asImageModelV4(model);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return getGlobalProvider().imageModel(model);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function resolveVideoModel(
|
|
134
|
+
model: VideoModel,
|
|
135
|
+
): Experimental_VideoModelV4 {
|
|
136
|
+
if (typeof model === 'string') {
|
|
137
|
+
// Use raw global provider because videoModel is experimental
|
|
138
|
+
// and not part of the ProviderV4 interface
|
|
139
|
+
const provider = globalThis.AI_SDK_DEFAULT_PROVIDER ?? gateway;
|
|
140
|
+
// TODO AI SDK v7
|
|
141
|
+
// @ts-expect-error - videoModel support is experimental
|
|
142
|
+
const videoModel = provider.videoModel;
|
|
143
|
+
|
|
144
|
+
if (!videoModel) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
'The default provider does not support video models. ' +
|
|
147
|
+
'Please use a Experimental_VideoModelV4 object from a provider (e.g., vertex.video("model-id")).',
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return videoModel(model);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
model.specificationVersion !== 'v4' &&
|
|
156
|
+
model.specificationVersion !== 'v3'
|
|
157
|
+
) {
|
|
158
|
+
const unsupportedModel: any = model;
|
|
159
|
+
throw new UnsupportedModelVersionError({
|
|
160
|
+
version: unsupportedModel.specificationVersion,
|
|
161
|
+
provider: unsupportedModel.provider,
|
|
162
|
+
modelId: unsupportedModel.modelId,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return asVideoModelV4(model);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getGlobalProvider(): ProviderV4 {
|
|
170
|
+
const provider = globalThis.AI_SDK_DEFAULT_PROVIDER ?? gateway;
|
|
171
|
+
return asProviderV4(provider);
|
|
172
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { LanguageModelV4CallOptions } from '@ai-sdk/provider';
|
|
2
|
+
import type { ToolSet } from '../generate-text/tool-set';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Timeout configuration for API calls. Can be specified as:
|
|
6
|
+
* - A number representing milliseconds
|
|
7
|
+
* - An object with `totalMs` property for the total timeout in milliseconds
|
|
8
|
+
* - An object with `stepMs` property for the timeout of each step in milliseconds
|
|
9
|
+
* - An object with `chunkMs` property for the timeout between stream chunks (streaming only)
|
|
10
|
+
*/
|
|
11
|
+
export type TimeoutConfiguration<TOOLS extends ToolSet> =
|
|
12
|
+
| number
|
|
13
|
+
| {
|
|
14
|
+
totalMs?: number;
|
|
15
|
+
stepMs?: number;
|
|
16
|
+
chunkMs?: number;
|
|
17
|
+
toolMs?: number;
|
|
18
|
+
tools?: Partial<Record<`${keyof TOOLS & string}Ms`, number>>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the total timeout value in milliseconds from a TimeoutConfiguration.
|
|
23
|
+
*
|
|
24
|
+
* @param timeout - The timeout configuration.
|
|
25
|
+
* @returns The total timeout in milliseconds, or undefined if no timeout is configured.
|
|
26
|
+
*/
|
|
27
|
+
export function getTotalTimeoutMs(
|
|
28
|
+
timeout: TimeoutConfiguration<any> | undefined,
|
|
29
|
+
): number | undefined {
|
|
30
|
+
if (timeout == null) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
if (typeof timeout === 'number') {
|
|
34
|
+
return timeout;
|
|
35
|
+
}
|
|
36
|
+
return timeout.totalMs;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Extracts the step timeout value in milliseconds from a TimeoutConfiguration.
|
|
41
|
+
*
|
|
42
|
+
* @param timeout - The timeout configuration.
|
|
43
|
+
* @returns The step timeout in milliseconds, or undefined if no step timeout is configured.
|
|
44
|
+
*/
|
|
45
|
+
export function getStepTimeoutMs(
|
|
46
|
+
timeout: TimeoutConfiguration<any> | undefined,
|
|
47
|
+
): number | undefined {
|
|
48
|
+
if (timeout == null || typeof timeout === 'number') {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return timeout.stepMs;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Extracts the chunk timeout value in milliseconds from a TimeoutConfiguration.
|
|
56
|
+
* This timeout is for streaming only - it aborts if no new chunk is received within the specified duration.
|
|
57
|
+
*
|
|
58
|
+
* @param timeout - The timeout configuration.
|
|
59
|
+
* @returns The chunk timeout in milliseconds, or undefined if no chunk timeout is configured.
|
|
60
|
+
*/
|
|
61
|
+
export function getChunkTimeoutMs(
|
|
62
|
+
timeout: TimeoutConfiguration<any> | undefined,
|
|
63
|
+
): number | undefined {
|
|
64
|
+
if (timeout == null || typeof timeout === 'number') {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return timeout.chunkMs;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function getToolTimeoutMs<TOOLS extends ToolSet>(
|
|
71
|
+
timeout: TimeoutConfiguration<TOOLS> | undefined,
|
|
72
|
+
toolName: keyof TOOLS & string,
|
|
73
|
+
): number | undefined {
|
|
74
|
+
if (timeout == null || typeof timeout === 'number') {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return timeout.tools?.[`${toolName}Ms`] ?? timeout.toolMs;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type CallSettings = {
|
|
82
|
+
/**
|
|
83
|
+
* Maximum number of tokens to generate.
|
|
84
|
+
*/
|
|
85
|
+
maxOutputTokens?: number;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Temperature setting. The range depends on the provider and model.
|
|
89
|
+
*
|
|
90
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
91
|
+
*/
|
|
92
|
+
temperature?: number;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Nucleus sampling. This is a number between 0 and 1.
|
|
96
|
+
*
|
|
97
|
+
* E.g. 0.1 would mean that only tokens with the top 10% probability mass
|
|
98
|
+
* are considered.
|
|
99
|
+
*
|
|
100
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
101
|
+
*/
|
|
102
|
+
topP?: number;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Only sample from the top K options for each subsequent token.
|
|
106
|
+
*
|
|
107
|
+
* Used to remove "long tail" low probability responses.
|
|
108
|
+
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
109
|
+
*/
|
|
110
|
+
topK?: number;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Presence penalty setting. It affects the likelihood of the model to
|
|
114
|
+
* repeat information that is already in the prompt.
|
|
115
|
+
*
|
|
116
|
+
* The presence penalty is a number between -1 (increase repetition)
|
|
117
|
+
* and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
|
118
|
+
*/
|
|
119
|
+
presencePenalty?: number;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Frequency penalty setting. It affects the likelihood of the model
|
|
123
|
+
* to repeatedly use the same words or phrases.
|
|
124
|
+
*
|
|
125
|
+
* The frequency penalty is a number between -1 (increase repetition)
|
|
126
|
+
* and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
|
127
|
+
*/
|
|
128
|
+
frequencyPenalty?: number;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Stop sequences.
|
|
132
|
+
* If set, the model will stop generating text when one of the stop sequences is generated.
|
|
133
|
+
* Providers may have limits on the number of stop sequences.
|
|
134
|
+
*/
|
|
135
|
+
stopSequences?: string[];
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The seed (integer) to use for random sampling. If set and supported
|
|
139
|
+
* by the model, calls will generate deterministic results.
|
|
140
|
+
*/
|
|
141
|
+
seed?: number;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Reasoning effort level for the model. Controls how much reasoning
|
|
145
|
+
* the model performs before generating a response.
|
|
146
|
+
*
|
|
147
|
+
* Use `'provider-default'` to use the provider's default reasoning level.
|
|
148
|
+
* Use `'none'` to disable reasoning (if supported by the provider).
|
|
149
|
+
*/
|
|
150
|
+
reasoning?: LanguageModelV4CallOptions['reasoning'];
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Maximum number of retries. Set to 0 to disable retries.
|
|
154
|
+
*
|
|
155
|
+
* @default 2
|
|
156
|
+
*/
|
|
157
|
+
maxRetries?: number;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Abort signal.
|
|
161
|
+
*/
|
|
162
|
+
abortSignal?: AbortSignal;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Additional HTTP headers to be sent with the request.
|
|
166
|
+
* Only applicable for HTTP-based providers.
|
|
167
|
+
*/
|
|
168
|
+
headers?: Record<string, string | undefined>;
|
|
169
|
+
};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CustomPart,
|
|
3
|
+
FilePart,
|
|
4
|
+
ImagePart,
|
|
5
|
+
ProviderOptions,
|
|
6
|
+
ReasoningFilePart,
|
|
7
|
+
ReasoningPart,
|
|
8
|
+
TextPart,
|
|
9
|
+
ToolApprovalRequest,
|
|
10
|
+
ToolApprovalResponse,
|
|
11
|
+
ToolResultOutput,
|
|
12
|
+
ToolResultPart,
|
|
13
|
+
} from '@ai-sdk/provider-utils';
|
|
14
|
+
import { z } from 'zod/v4';
|
|
15
|
+
import { jsonValueSchema } from '../types/json-value';
|
|
16
|
+
import { providerMetadataSchema } from '../types/provider-metadata';
|
|
17
|
+
import { dataContentSchema } from './data-content';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export const textPartSchema: z.ZodType<TextPart> = z.object({
|
|
23
|
+
type: z.literal('text'),
|
|
24
|
+
text: z.string(),
|
|
25
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export const imagePartSchema: z.ZodType<ImagePart> = z.object({
|
|
32
|
+
type: z.literal('image'),
|
|
33
|
+
image: z.union([dataContentSchema, z.instanceof(URL)]),
|
|
34
|
+
mediaType: z.string().optional(),
|
|
35
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export const filePartSchema: z.ZodType<FilePart> = z.object({
|
|
42
|
+
type: z.literal('file'),
|
|
43
|
+
data: z.union([dataContentSchema, z.instanceof(URL)]),
|
|
44
|
+
filename: z.string().optional(),
|
|
45
|
+
mediaType: z.string(),
|
|
46
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export const reasoningPartSchema: z.ZodType<ReasoningPart> = z.object({
|
|
53
|
+
type: z.literal('reasoning'),
|
|
54
|
+
text: z.string(),
|
|
55
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export const customPartSchema: z.ZodType<CustomPart> = z.object({
|
|
62
|
+
type: z.literal('custom'),
|
|
63
|
+
kind: z.string().transform(value => value as `${string}.${string}`),
|
|
64
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export const reasoningFilePartSchema: z.ZodType<ReasoningFilePart> = z.object({
|
|
71
|
+
type: z.literal('reasoning-file'),
|
|
72
|
+
data: z.union([dataContentSchema, z.instanceof(URL)]),
|
|
73
|
+
mediaType: z.string(),
|
|
74
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
79
|
+
*/
|
|
80
|
+
export interface ToolCallPart {
|
|
81
|
+
type: 'tool-call';
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
85
|
+
*/
|
|
86
|
+
toolCallId: string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Name of the tool that is being called.
|
|
90
|
+
*/
|
|
91
|
+
toolName: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
95
|
+
*/
|
|
96
|
+
input: unknown;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Additional provider-specific metadata. They are passed through
|
|
100
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
101
|
+
* functionality that can be fully encapsulated in the provider.
|
|
102
|
+
*/
|
|
103
|
+
providerOptions?: ProviderOptions;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export const toolCallPartSchema: z.ZodType<ToolCallPart> = z.object({
|
|
110
|
+
type: z.literal('tool-call'),
|
|
111
|
+
toolCallId: z.string(),
|
|
112
|
+
toolName: z.string(),
|
|
113
|
+
input: z.unknown(),
|
|
114
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
115
|
+
providerExecuted: z.boolean().optional(),
|
|
116
|
+
}) as z.ZodType<ToolCallPart>; // necessary bc input is optional on Zod type
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
export const outputSchema: z.ZodType<ToolResultOutput> = z.discriminatedUnion(
|
|
122
|
+
'type',
|
|
123
|
+
[
|
|
124
|
+
z.object({
|
|
125
|
+
type: z.literal('text'),
|
|
126
|
+
value: z.string(),
|
|
127
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
128
|
+
}),
|
|
129
|
+
z.object({
|
|
130
|
+
type: z.literal('json'),
|
|
131
|
+
value: jsonValueSchema,
|
|
132
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
133
|
+
}),
|
|
134
|
+
z.object({
|
|
135
|
+
type: z.literal('execution-denied'),
|
|
136
|
+
reason: z.string().optional(),
|
|
137
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
138
|
+
}),
|
|
139
|
+
z.object({
|
|
140
|
+
type: z.literal('error-text'),
|
|
141
|
+
value: z.string(),
|
|
142
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
143
|
+
}),
|
|
144
|
+
z.object({
|
|
145
|
+
type: z.literal('error-json'),
|
|
146
|
+
value: jsonValueSchema,
|
|
147
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
148
|
+
}),
|
|
149
|
+
z.object({
|
|
150
|
+
type: z.literal('content'),
|
|
151
|
+
value: z.array(
|
|
152
|
+
z.union([
|
|
153
|
+
z.object({
|
|
154
|
+
type: z.literal('text'),
|
|
155
|
+
text: z.string(),
|
|
156
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
157
|
+
}),
|
|
158
|
+
z.object({
|
|
159
|
+
type: z.literal('media'),
|
|
160
|
+
data: z.string(),
|
|
161
|
+
mediaType: z.string(),
|
|
162
|
+
}),
|
|
163
|
+
z.object({
|
|
164
|
+
type: z.literal('file-data'),
|
|
165
|
+
data: z.string(),
|
|
166
|
+
mediaType: z.string(),
|
|
167
|
+
filename: z.string().optional(),
|
|
168
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
169
|
+
}),
|
|
170
|
+
z.object({
|
|
171
|
+
type: z.literal('file-url'),
|
|
172
|
+
url: z.string(),
|
|
173
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
174
|
+
}),
|
|
175
|
+
z.object({
|
|
176
|
+
type: z.literal('file-id'),
|
|
177
|
+
fileId: z.union([z.string(), z.record(z.string(), z.string())]),
|
|
178
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
179
|
+
}),
|
|
180
|
+
z.object({
|
|
181
|
+
type: z.literal('image-data'),
|
|
182
|
+
data: z.string(),
|
|
183
|
+
mediaType: z.string(),
|
|
184
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
185
|
+
}),
|
|
186
|
+
z.object({
|
|
187
|
+
type: z.literal('image-url'),
|
|
188
|
+
url: z.string(),
|
|
189
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
190
|
+
}),
|
|
191
|
+
z.object({
|
|
192
|
+
type: z.literal('image-file-id'),
|
|
193
|
+
fileId: z.union([z.string(), z.record(z.string(), z.string())]),
|
|
194
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
195
|
+
}),
|
|
196
|
+
z.object({
|
|
197
|
+
type: z.literal('custom'),
|
|
198
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
199
|
+
}),
|
|
200
|
+
]),
|
|
201
|
+
),
|
|
202
|
+
}),
|
|
203
|
+
],
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
export const toolResultPartSchema: z.ZodType<ToolResultPart> = z.object({
|
|
210
|
+
type: z.literal('tool-result'),
|
|
211
|
+
toolCallId: z.string(),
|
|
212
|
+
toolName: z.string(),
|
|
213
|
+
output: outputSchema,
|
|
214
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
215
|
+
}) as z.ZodType<ToolResultPart>; // necessary bc result is optional on Zod type
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
export const toolApprovalRequestSchema: z.ZodType<ToolApprovalRequest> =
|
|
221
|
+
z.object({
|
|
222
|
+
type: z.literal('tool-approval-request'),
|
|
223
|
+
approvalId: z.string(),
|
|
224
|
+
toolCallId: z.string(),
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @internal
|
|
229
|
+
*/
|
|
230
|
+
export const toolApprovalResponseSchema: z.ZodType<ToolApprovalResponse> =
|
|
231
|
+
z.object({
|
|
232
|
+
type: z.literal('tool-approval-response'),
|
|
233
|
+
approvalId: z.string(),
|
|
234
|
+
approved: z.boolean(),
|
|
235
|
+
reason: z.string().optional(),
|
|
236
|
+
});
|