ai 7.0.122 → 7.0.124
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 +29 -0
- package/dist/index.d.ts +7598 -7268
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19555 -22545
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +2235 -2004
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +3261 -3921
- package/dist/internal/index.js.map +1 -1
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/test/index.d.ts +294 -273
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +325 -469
- package/dist/test/index.js.map +1 -1
- package/docs/02-foundations/03-prompts.mdx +3 -1
- package/docs/02-foundations/06-provider-options.mdx +1 -1
- package/docs/02-getting-started/06-nodejs.mdx +4 -4
- package/docs/02-getting-started/08-tanstack-start.mdx +1 -1
- package/docs/03-agents/05-configuring-call-options.mdx +1 -1
- package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +1 -1
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +3 -0
- package/docs/03-ai-sdk-core/17-mcp-apps.mdx +5 -5
- package/docs/03-ai-sdk-core/36-transcription.mdx +36 -0
- package/docs/03-ai-sdk-core/37-speech.mdx +22 -1
- package/docs/03-ai-sdk-core/42-batch.mdx +1 -1
- package/docs/03-ai-sdk-core/60-telemetry.mdx +51 -3
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +24 -0
- package/docs/03-ai-sdk-harnesses/05-harness-adapters.mdx +12 -12
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +9 -7
- package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +2 -2
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +7 -9
- package/docs/04-ai-sdk-ui/05-completion.mdx +1 -1
- package/docs/04-ai-sdk-ui/50-stream-protocol.mdx +2 -2
- package/docs/05-ai-sdk-rsc/03-generative-ui-state.mdx +8 -7
- package/docs/05-ai-sdk-rsc/06-loading-state.mdx +19 -10
- package/docs/05-ai-sdk-rsc/08-error-handling.mdx +2 -0
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +4 -3
- package/docs/06-advanced/02-stopping-streams.mdx +2 -2
- package/docs/06-advanced/04-caching.mdx +9 -5
- package/docs/06-advanced/05-multiple-streamables.mdx +1 -1
- package/docs/06-advanced/07-rendering-ui-with-language-models.mdx +16 -16
- package/docs/06-advanced/09-multistep-interfaces.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +4 -4
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +4 -4
- package/docs/07-reference/01-ai-sdk-core/11-stream-transcribe.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/14-upload-file.mdx +4 -4
- package/docs/07-reference/01-ai-sdk-core/14-upload-skill.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/15-agent.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/18-create-agent-ui-stream-response.mdx +1 -4
- package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +2 -2
- package/docs/07-reference/01-ai-sdk-core/69-add-tool-input-examples-middleware.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +5 -4
- package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +3 -2
- package/docs/07-reference/02-ai-sdk-ui/41-create-ui-message-stream-response.mdx +7 -0
- package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +7 -0
- package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +2 -2
- package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +2 -2
- package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +1 -1
- package/docs/08-migration-guides/25-migration-guide-5-0-data.mdx +4 -5
- package/docs/08-migration-guides/26-migration-guide-5-0.mdx +2 -1
- package/docs/08-migration-guides/29-migration-guide-4-0.mdx +4 -4
- package/docs/08-migration-guides/38-migration-guide-3-2.mdx +1 -1
- package/docs/08-migration-guides/39-migration-guide-3-1.mdx +1 -1
- package/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +8 -6
- package/docs/09-troubleshooting/50-react-maximum-update-depth-exceeded.mdx +6 -6
- package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +1 -1
- package/package.json +17 -17
- package/src/agent/create-agent-ui-stream-response.ts +3 -0
- package/src/agent/pipe-agent-ui-stream-to-response.ts +3 -0
- package/src/generate-speech/generate-speech.ts +163 -38
- package/src/generate-speech/index.ts +4 -0
- package/src/generate-speech/speech-events.ts +91 -0
- package/src/generate-text/prune-messages.ts +1 -1
- package/src/middleware/extract-reasoning-middleware.ts +27 -11
- package/src/telemetry/create-telemetry-dispatcher.ts +18 -5
- package/src/telemetry/telemetry.ts +38 -6
- package/src/telemetry/tracing-channel.ts +3 -0
- package/src/transcribe/index.ts +6 -0
- package/src/transcribe/stream-transcribe.ts +182 -31
- package/src/transcribe/transcribe.ts +186 -33
- package/src/transcribe/transcription-events.ts +111 -0
- package/src/ui/convert-to-model-messages.ts +18 -6
- package/src/ui-message-stream/create-sse-stream-with-keep-alive.ts +89 -0
- package/src/ui-message-stream/create-ui-message-stream-response.ts +7 -1
- package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +7 -1
- package/src/ui-message-stream/ui-message-stream-response-init.ts +7 -0
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/simulate-readable-stream.ts","../../test/index.ts","../../src/test/not-implemented.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-model-v4.ts","../../src/test/evaluation-mock-model-v4.ts","../../src/test/mock-image-model-v3.ts","../../src/test/mock-image-model-v4.ts","../../src/test/mock-language-model-v3.ts","../../src/test/mock-language-model-v4.ts","../../src/test/mock-provider-v3.ts","../../src/test/mock-provider-v4.ts","../../src/test/mock-speech-model-v3.ts","../../src/test/mock-speech-model-v4.ts","../../src/test/mock-speech-translation-model-v4.ts","../../src/test/mock-transcription-model-v3.ts","../../src/test/mock-transcription-model-v4.ts","../../src/test/mock-reranking-model-v3.ts","../../src/test/mock-reranking-model-v4.ts","../../src/test/mock-video-model-v3.ts","../../src/test/mock-video-model-v4.ts","../../src/test/mock-values.ts"],"sourcesContent":["import { delay as delayFunction } from '@ai-sdk/provider-utils';\n\n/**\n * Creates a ReadableStream that emits the provided values with an optional delay between each value.\n *\n * @param options - The configuration options\n * @param options.chunks - Array of values to be emitted by the stream\n * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @returns A ReadableStream that emits the provided values\n */\nexport function simulateReadableStream<T>({\n chunks,\n initialDelayInMs = 0,\n chunkDelayInMs = 0,\n _internal,\n}: {\n chunks: T[];\n initialDelayInMs?: number | null;\n chunkDelayInMs?: number | null;\n _internal?: {\n delay?: (ms: number | null) => Promise<void>;\n };\n}): ReadableStream<T> {\n const delay = _internal?.delay ?? delayFunction;\n\n let index = 0;\n\n return new ReadableStream({\n async pull(controller) {\n if (index < chunks.length) {\n await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);\n controller.enqueue(chunks[index++]);\n } else {\n controller.close();\n }\n },\n });\n}\n","import { simulateReadableStream as originalSimulateReadableStream } from '../src/util/simulate-readable-stream';\n\nexport {\n convertArrayToAsyncIterable,\n convertArrayToReadableStream,\n convertReadableStreamToArray,\n mockId,\n} from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV3 } from '../src/test/mock-embedding-model-v3';\nexport { MockEmbeddingModelV4 } from '../src/test/mock-embedding-model-v4';\nexport { EvaluationMockModelV4 as Experimental_EvaluationMockModelV4 } from '../src/test/evaluation-mock-model-v4';\nexport { MockImageModelV3 } from '../src/test/mock-image-model-v3';\nexport { MockImageModelV4 } from '../src/test/mock-image-model-v4';\nexport { MockLanguageModelV3 } from '../src/test/mock-language-model-v3';\nexport { MockLanguageModelV4 } from '../src/test/mock-language-model-v4';\nexport { MockProviderV3 } from '../src/test/mock-provider-v3';\nexport { MockProviderV4 } from '../src/test/mock-provider-v4';\nexport { MockSpeechModelV3 } from '../src/test/mock-speech-model-v3';\nexport { MockSpeechModelV4 } from '../src/test/mock-speech-model-v4';\nexport { MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4 } from '../src/test/mock-speech-translation-model-v4';\nexport { MockTranscriptionModelV3 } from '../src/test/mock-transcription-model-v3';\nexport { MockTranscriptionModelV4 } from '../src/test/mock-transcription-model-v4';\nexport { MockRerankingModelV3 } from '../src/test/mock-reranking-model-v3';\nexport { MockRerankingModelV4 } from '../src/test/mock-reranking-model-v4';\nexport { MockVideoModelV3 } from '../src/test/mock-video-model-v3';\nexport { MockVideoModelV4 } from '../src/test/mock-video-model-v4';\nexport { mockValues } from '../src/test/mock-values';\n\n/**\n * @deprecated Use `simulateReadableStream` from `ai` instead.\n */\nexport const simulateReadableStream = originalSimulateReadableStream;\n","export function notImplemented(): never {\n throw new Error('Not implemented');\n}\n","import type { EmbeddingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV3 implements EmbeddingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: EmbeddingModelV3['provider'];\n readonly modelId: EmbeddingModelV3['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV3['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV3['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV3['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV3['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV3['provider'];\n modelId?: EmbeddingModelV3['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV3['maxEmbeddingsPerCall'] | null;\n supportsParallelCalls?: EmbeddingModelV3['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV3['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { EmbeddingModelV4 } from '@ai-sdk/provider';\nimport { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from '@ai-sdk/provider-utils';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV4 implements EmbeddingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: EmbeddingModelV4['provider'];\n readonly modelId: EmbeddingModelV4['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV4['maxEmbeddingsPerCall'];\n readonly [EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL]:\n | PromiseLike<number | undefined>\n | number\n | undefined;\n readonly supportsParallelCalls: EmbeddingModelV4['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV4['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV4['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n maxInputBytesPerCall,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV4['provider'];\n modelId?: EmbeddingModelV4['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV4['maxEmbeddingsPerCall'] | null;\n maxInputBytesPerCall?: PromiseLike<number | undefined> | number | undefined;\n supportsParallelCalls?: EmbeddingModelV4['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV4['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] =\n maxInputBytesPerCall;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { Experimental_EvaluationModelV4 as EvaluationModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class EvaluationMockModelV4 implements EvaluationModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: string;\n readonly modelId: string;\n readonly supportedQuestionTypes: EvaluationModelV4['supportedQuestionTypes'];\n doEvaluate: EvaluationModelV4['doEvaluate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedQuestionTypes = ['choice', 'score', 'boolean'],\n doEvaluate = notImplemented,\n }: {\n provider?: string;\n modelId?: string;\n supportedQuestionTypes?: EvaluationModelV4['supportedQuestionTypes'];\n doEvaluate?: EvaluationModelV4['doEvaluate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.supportedQuestionTypes = supportedQuestionTypes;\n this.doEvaluate = doEvaluate;\n }\n}\n","import type { ImageModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV3 implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: ImageModelV3['provider'];\n readonly modelId: ImageModelV3['modelId'];\n readonly maxImagesPerCall: ImageModelV3['maxImagesPerCall'];\n\n doGenerate: ImageModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV3['provider'];\n modelId?: ImageModelV3['modelId'];\n maxImagesPerCall?: ImageModelV3['maxImagesPerCall'];\n doGenerate?: ImageModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { ImageModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV4 implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: ImageModelV4['provider'];\n readonly modelId: ImageModelV4['modelId'];\n readonly maxImagesPerCall: ImageModelV4['maxImagesPerCall'];\n readonly supportsFileInputs: ImageModelV4['supportsFileInputs'];\n readonly supportsMaskInputs: ImageModelV4['supportsMaskInputs'];\n\n doGenerate: ImageModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n supportsFileInputs,\n supportsMaskInputs,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV4['provider'];\n modelId?: ImageModelV4['modelId'];\n maxImagesPerCall?: ImageModelV4['maxImagesPerCall'];\n supportsFileInputs?: ImageModelV4['supportsFileInputs'];\n supportsMaskInputs?: ImageModelV4['supportsMaskInputs'];\n doGenerate?: ImageModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.supportsFileInputs = supportsFileInputs;\n this.supportsMaskInputs = supportsMaskInputs;\n this.doGenerate = doGenerate;\n }\n}\n","import type {\n LanguageModelV3,\n LanguageModelV3CallOptions,\n LanguageModelV3GenerateResult,\n LanguageModelV3StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV3 implements LanguageModelV3 {\n readonly specificationVersion = 'v3';\n\n private _supportedUrls: () => LanguageModelV3['supportedUrls'];\n\n readonly provider: LanguageModelV3['provider'];\n readonly modelId: LanguageModelV3['modelId'];\n\n doGenerate: LanguageModelV3['doGenerate'];\n doStream: LanguageModelV3['doStream'];\n\n doGenerateCalls: LanguageModelV3CallOptions[] = [];\n doStreamCalls: LanguageModelV3CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV3['provider'];\n modelId?: LanguageModelV3['modelId'];\n supportedUrls?:\n | LanguageModelV3['supportedUrls']\n | (() => LanguageModelV3['supportedUrls']);\n doGenerate?:\n | LanguageModelV3['doGenerate']\n | LanguageModelV3GenerateResult\n | LanguageModelV3GenerateResult[];\n doStream?:\n | LanguageModelV3['doStream']\n | LanguageModelV3StreamResult\n | LanguageModelV3StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV4 implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n private _supportedUrls: () => LanguageModelV4['supportedUrls'];\n\n readonly provider: LanguageModelV4['provider'];\n readonly modelId: LanguageModelV4['modelId'];\n\n doGenerate: LanguageModelV4['doGenerate'];\n doStream: LanguageModelV4['doStream'];\n\n doGenerateCalls: LanguageModelV4CallOptions[] = [];\n doStreamCalls: LanguageModelV4CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV4['provider'];\n modelId?: LanguageModelV4['modelId'];\n supportedUrls?:\n | LanguageModelV4['supportedUrls']\n | (() => LanguageModelV4['supportedUrls']);\n doGenerate?:\n | LanguageModelV4['doGenerate']\n | LanguageModelV4GenerateResult\n | LanguageModelV4GenerateResult[];\n doStream?:\n | LanguageModelV4['doStream']\n | LanguageModelV4StreamResult\n | LanguageModelV4StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV3,\n type ImageModelV3,\n type LanguageModelV3,\n type ProviderV3,\n type SpeechModelV3,\n type TranscriptionModelV3,\n type RerankingModelV3,\n} from '@ai-sdk/provider';\nexport class MockProviderV3 implements ProviderV3 {\n readonly specificationVersion = 'v3' as const;\n\n languageModel: ProviderV3['languageModel'];\n embeddingModel: ProviderV3['embeddingModel'];\n imageModel: ProviderV3['imageModel'];\n transcriptionModel: ProviderV3['transcriptionModel'];\n speechModel: ProviderV3['speechModel'];\n rerankingModel: ProviderV3['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV3>;\n embeddingModels?: Record<string, EmbeddingModelV3>;\n imageModels?: Record<string, ImageModelV3>;\n transcriptionModels?: Record<string, TranscriptionModelV3>;\n speechModels?: Record<string, SpeechModelV3>;\n rerankingModels?: Record<string, RerankingModelV3>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV3 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV4,\n type ImageModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n type RerankingModelV4,\n} from '@ai-sdk/provider';\nexport class MockProviderV4 implements ProviderV4 {\n readonly specificationVersion = 'v4' as const;\n\n languageModel: ProviderV4['languageModel'];\n embeddingModel: ProviderV4['embeddingModel'];\n imageModel: ProviderV4['imageModel'];\n transcriptionModel: ProviderV4['transcriptionModel'];\n speechModel: ProviderV4['speechModel'];\n rerankingModel: ProviderV4['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV4>;\n embeddingModels?: Record<string, EmbeddingModelV4>;\n imageModels?: Record<string, ImageModelV4>;\n transcriptionModels?: Record<string, TranscriptionModelV4>;\n speechModels?: Record<string, SpeechModelV4>;\n rerankingModels?: Record<string, RerankingModelV4>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV4 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import type { SpeechModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV3 implements SpeechModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: SpeechModelV3['provider'];\n readonly modelId: SpeechModelV3['modelId'];\n\n doGenerate: SpeechModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV3['provider'];\n modelId?: SpeechModelV3['modelId'];\n doGenerate?: SpeechModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { SpeechModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV4 implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: SpeechModelV4['provider'];\n readonly modelId: SpeechModelV4['modelId'];\n\n doGenerate: SpeechModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV4['provider'];\n modelId?: SpeechModelV4['modelId'];\n doGenerate?: SpeechModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_SpeechTranslationModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechTranslationModelV4 implements Experimental_SpeechTranslationModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_SpeechTranslationModelV4['provider'];\n readonly modelId: Experimental_SpeechTranslationModelV4['modelId'];\n\n doStream: Experimental_SpeechTranslationModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doStream = notImplemented,\n }: {\n provider?: Experimental_SpeechTranslationModelV4['provider'];\n modelId?: Experimental_SpeechTranslationModelV4['modelId'];\n doStream?: Experimental_SpeechTranslationModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doStream = doStream;\n }\n}\n","import type { TranscriptionModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV3 implements TranscriptionModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: TranscriptionModelV3['provider'];\n readonly modelId: TranscriptionModelV3['modelId'];\n\n doGenerate: TranscriptionModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: TranscriptionModelV3['provider'];\n modelId?: TranscriptionModelV3['modelId'];\n doGenerate?: TranscriptionModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { TranscriptionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV4 implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: TranscriptionModelV4['provider'];\n readonly modelId: TranscriptionModelV4['modelId'];\n\n doGenerate: TranscriptionModelV4['doGenerate'];\n doStream: TranscriptionModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream,\n }: {\n provider?: TranscriptionModelV4['provider'];\n modelId?: TranscriptionModelV4['modelId'];\n doGenerate?: TranscriptionModelV4['doGenerate'];\n doStream?: TranscriptionModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n }\n}\n","import type { RerankingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV3 implements RerankingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: RerankingModelV3['provider'];\n readonly modelId: RerankingModelV3['modelId'];\n\n doRerank: RerankingModelV3['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV3['provider'];\n modelId?: RerankingModelV3['modelId'];\n doRerank?: RerankingModelV3['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { RerankingModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV4 implements RerankingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: RerankingModelV4['provider'];\n readonly modelId: RerankingModelV4['modelId'];\n\n doRerank: RerankingModelV4['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV4['provider'];\n modelId?: RerankingModelV4['modelId'];\n doRerank?: RerankingModelV4['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { Experimental_VideoModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV3 implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: Experimental_VideoModelV3['provider'];\n readonly modelId: Experimental_VideoModelV3['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV3['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxVideosPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: Experimental_VideoModelV3['provider'];\n modelId?: Experimental_VideoModelV3['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV3['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxVideosPerCall = maxVideosPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_VideoModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV4 implements Experimental_VideoModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_VideoModelV4['provider'];\n readonly modelId: Experimental_VideoModelV4['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV4['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV4['doGenerate'];\n handleWebhookOption: Experimental_VideoModelV4['handleWebhookOption'];\n doStart: Experimental_VideoModelV4['doStart'];\n doStatus: Experimental_VideoModelV4['doStatus'];\n\n constructor(\n options: {\n provider?: Experimental_VideoModelV4['provider'];\n modelId?: Experimental_VideoModelV4['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV4['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV4['doGenerate'];\n handleWebhookOption?: Experimental_VideoModelV4['handleWebhookOption'];\n doStart?: Experimental_VideoModelV4['doStart'];\n doStatus?: Experimental_VideoModelV4['doStatus'];\n } = {},\n ) {\n this.provider = options.provider ?? 'mock-provider';\n this.modelId = options.modelId ?? 'mock-model-id';\n this.maxVideosPerCall = options.maxVideosPerCall ?? 1;\n this.doGenerate =\n 'doGenerate' in options ? options.doGenerate : notImplemented;\n this.handleWebhookOption = options.handleWebhookOption;\n this.doStart = options.doStart;\n this.doStatus = options.doStatus;\n }\n}\n","export function mockValues<T>(...values: T[]): () => T {\n let counter = 0;\n return () => values[counter++] ?? values[values.length - 1];\n}\n"],"mappings":";AAAA,SAAS,SAAS,qBAAqB;AAWhC,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AACpB,QAAM,QAAQ,WAAW,SAAS;AAElC,MAAI,QAAQ;AAEZ,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,UAAI,QAAQ,OAAO,QAAQ;AACzB,cAAM,MAAM,UAAU,IAAI,mBAAmB,cAAc;AAC3D,mBAAW,QAAQ,OAAO,OAAO,CAAC;AAAA,MACpC,OAAO;AACL,mBAAW,MAAM;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;ACpCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACPA,SAAS,iBAAwB;AACtC,QAAM,IAAI,MAAM,iBAAiB;AACnC;;;ACCO,IAAM,uBAAN,MAAuD;AAAA,EAY5D,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,UAAU;AAAA,EACZ,IASI,CAAC,GAAG;AA1BR,SAAS,uBAAuB;AAShC,wBAA6D,CAAC;AAkB5D,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,uBAAuB,wBAAwB;AACpD,SAAK,wBAAwB;AAC7B,SAAK,UAAU,OAAM,YAAW;AAC9B,WAAK,aAAa,KAAK,OAAO;AAE9B,UAAI,OAAO,YAAY,YAAY;AACjC,eAAO,QAAQ,OAAO;AAAA,MACxB,WAAW,MAAM,QAAQ,OAAO,GAAG;AACjC,eAAO,QAAQ,KAAK,aAAa,SAAS,CAAC;AAAA,MAC7C,OAAO;AACL,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;;;AC9CA,SAAS,6DAA6D;AAS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AA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,EACb,IAII,CAAC,GAAG;AAfR,SAAS,uBAAuB;AAgB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AACF;;;ACrBO,IAAM,mBAAN,MAA4D;AAAA,EAQjE,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,mBAAmB;AAAA,IACnB,aAAa;AAAA,EACf,IAKI,CAAC,GAAG;AAjBR,SAAS,uBAAuB;AAkB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,mBAAmB;AACxB,SAAK,aAAa;AAAA,EACpB;AACF;;;ACxBO,IAAM,mBAAN,MAA4D;AAAA,EAWjE,YACE,UAQI,CAAC,GACL;AApBF,SAAS,uBAAuB;AAqB9B,SAAK,WAAW,QAAQ,YAAY;AACpC,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,mBAAmB,QAAQ,oBAAoB;AACpD,SAAK,aACH,gBAAgB,UAAU,QAAQ,aAAa;AACjD,SAAK,sBAAsB,QAAQ;AACnC,SAAK,UAAU,QAAQ;AACvB,SAAK,WAAW,QAAQ;AAAA,EAC1B;AACF;;;AClCO,SAAS,cAAiB,QAAsB;AACrD,MAAI,UAAU;AACd,SAAO,MAAM,OAAO,SAAS,KAAK,OAAO,OAAO,SAAS,CAAC;AAC5D;;;ApB4BO,IAAMC,0BAAyB;","names":["NoSuchModelError","simulateReadableStream"]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["simulateReadableStream","delay","delayFunction","originalSimulateReadableStream"],"sources":["../../src/util/simulate-readable-stream.ts","../../src/test/not-implemented.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-model-v4.ts","../../src/test/evaluation-mock-model-v4.ts","../../src/test/mock-image-model-v3.ts","../../src/test/mock-image-model-v4.ts","../../src/test/mock-language-model-v3.ts","../../src/test/mock-language-model-v4.ts","../../src/test/mock-provider-v3.ts","../../src/test/mock-provider-v4.ts","../../src/test/mock-speech-model-v3.ts","../../src/test/mock-speech-model-v4.ts","../../src/test/mock-speech-translation-model-v4.ts","../../src/test/mock-transcription-model-v3.ts","../../src/test/mock-transcription-model-v4.ts","../../src/test/mock-reranking-model-v3.ts","../../src/test/mock-reranking-model-v4.ts","../../src/test/mock-video-model-v3.ts","../../src/test/mock-video-model-v4.ts","../../src/test/mock-values.ts","../../test/index.ts"],"sourcesContent":["import { delay as delayFunction } from '@ai-sdk/provider-utils';\n\n/**\n * Creates a ReadableStream that emits the provided values with an optional delay between each value.\n *\n * @param options - The configuration options\n * @param options.chunks - Array of values to be emitted by the stream\n * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @returns A ReadableStream that emits the provided values\n */\nexport function simulateReadableStream<T>({\n chunks,\n initialDelayInMs = 0,\n chunkDelayInMs = 0,\n _internal,\n}: {\n chunks: T[];\n initialDelayInMs?: number | null;\n chunkDelayInMs?: number | null;\n _internal?: {\n delay?: (ms: number | null) => Promise<void>;\n };\n}): ReadableStream<T> {\n const delay = _internal?.delay ?? delayFunction;\n\n let index = 0;\n\n return new ReadableStream({\n async pull(controller) {\n if (index < chunks.length) {\n await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);\n controller.enqueue(chunks[index++]);\n } else {\n controller.close();\n }\n },\n });\n}\n","export function notImplemented(): never {\n throw new Error('Not implemented');\n}\n","import type { EmbeddingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV3 implements EmbeddingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: EmbeddingModelV3['provider'];\n readonly modelId: EmbeddingModelV3['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV3['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV3['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV3['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV3['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV3['provider'];\n modelId?: EmbeddingModelV3['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV3['maxEmbeddingsPerCall'] | null;\n supportsParallelCalls?: EmbeddingModelV3['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV3['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { EmbeddingModelV4 } from '@ai-sdk/provider';\nimport { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from '@ai-sdk/provider-utils';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV4 implements EmbeddingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: EmbeddingModelV4['provider'];\n readonly modelId: EmbeddingModelV4['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV4['maxEmbeddingsPerCall'];\n readonly [EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL]:\n | PromiseLike<number | undefined>\n | number\n | undefined;\n readonly supportsParallelCalls: EmbeddingModelV4['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV4['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV4['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n maxInputBytesPerCall,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV4['provider'];\n modelId?: EmbeddingModelV4['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV4['maxEmbeddingsPerCall'] | null;\n maxInputBytesPerCall?: PromiseLike<number | undefined> | number | undefined;\n supportsParallelCalls?: EmbeddingModelV4['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV4['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] =\n maxInputBytesPerCall;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { Experimental_EvaluationModelV4 as EvaluationModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class EvaluationMockModelV4 implements EvaluationModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: string;\n readonly modelId: string;\n readonly supportedQuestionTypes: EvaluationModelV4['supportedQuestionTypes'];\n doEvaluate: EvaluationModelV4['doEvaluate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedQuestionTypes = ['choice', 'score', 'boolean'],\n doEvaluate = notImplemented,\n }: {\n provider?: string;\n modelId?: string;\n supportedQuestionTypes?: EvaluationModelV4['supportedQuestionTypes'];\n doEvaluate?: EvaluationModelV4['doEvaluate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.supportedQuestionTypes = supportedQuestionTypes;\n this.doEvaluate = doEvaluate;\n }\n}\n","import type { ImageModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV3 implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: ImageModelV3['provider'];\n readonly modelId: ImageModelV3['modelId'];\n readonly maxImagesPerCall: ImageModelV3['maxImagesPerCall'];\n\n doGenerate: ImageModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV3['provider'];\n modelId?: ImageModelV3['modelId'];\n maxImagesPerCall?: ImageModelV3['maxImagesPerCall'];\n doGenerate?: ImageModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { ImageModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV4 implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: ImageModelV4['provider'];\n readonly modelId: ImageModelV4['modelId'];\n readonly maxImagesPerCall: ImageModelV4['maxImagesPerCall'];\n readonly supportsFileInputs: ImageModelV4['supportsFileInputs'];\n readonly supportsMaskInputs: ImageModelV4['supportsMaskInputs'];\n\n doGenerate: ImageModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n supportsFileInputs,\n supportsMaskInputs,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV4['provider'];\n modelId?: ImageModelV4['modelId'];\n maxImagesPerCall?: ImageModelV4['maxImagesPerCall'];\n supportsFileInputs?: ImageModelV4['supportsFileInputs'];\n supportsMaskInputs?: ImageModelV4['supportsMaskInputs'];\n doGenerate?: ImageModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.supportsFileInputs = supportsFileInputs;\n this.supportsMaskInputs = supportsMaskInputs;\n this.doGenerate = doGenerate;\n }\n}\n","import type {\n LanguageModelV3,\n LanguageModelV3CallOptions,\n LanguageModelV3GenerateResult,\n LanguageModelV3StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV3 implements LanguageModelV3 {\n readonly specificationVersion = 'v3';\n\n private _supportedUrls: () => LanguageModelV3['supportedUrls'];\n\n readonly provider: LanguageModelV3['provider'];\n readonly modelId: LanguageModelV3['modelId'];\n\n doGenerate: LanguageModelV3['doGenerate'];\n doStream: LanguageModelV3['doStream'];\n\n doGenerateCalls: LanguageModelV3CallOptions[] = [];\n doStreamCalls: LanguageModelV3CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV3['provider'];\n modelId?: LanguageModelV3['modelId'];\n supportedUrls?:\n | LanguageModelV3['supportedUrls']\n | (() => LanguageModelV3['supportedUrls']);\n doGenerate?:\n | LanguageModelV3['doGenerate']\n | LanguageModelV3GenerateResult\n | LanguageModelV3GenerateResult[];\n doStream?:\n | LanguageModelV3['doStream']\n | LanguageModelV3StreamResult\n | LanguageModelV3StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV4 implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n private _supportedUrls: () => LanguageModelV4['supportedUrls'];\n\n readonly provider: LanguageModelV4['provider'];\n readonly modelId: LanguageModelV4['modelId'];\n\n doGenerate: LanguageModelV4['doGenerate'];\n doStream: LanguageModelV4['doStream'];\n\n doGenerateCalls: LanguageModelV4CallOptions[] = [];\n doStreamCalls: LanguageModelV4CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV4['provider'];\n modelId?: LanguageModelV4['modelId'];\n supportedUrls?:\n | LanguageModelV4['supportedUrls']\n | (() => LanguageModelV4['supportedUrls']);\n doGenerate?:\n | LanguageModelV4['doGenerate']\n | LanguageModelV4GenerateResult\n | LanguageModelV4GenerateResult[];\n doStream?:\n | LanguageModelV4['doStream']\n | LanguageModelV4StreamResult\n | LanguageModelV4StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV3,\n type ImageModelV3,\n type LanguageModelV3,\n type ProviderV3,\n type SpeechModelV3,\n type TranscriptionModelV3,\n type RerankingModelV3,\n} from '@ai-sdk/provider';\nexport class MockProviderV3 implements ProviderV3 {\n readonly specificationVersion = 'v3' as const;\n\n languageModel: ProviderV3['languageModel'];\n embeddingModel: ProviderV3['embeddingModel'];\n imageModel: ProviderV3['imageModel'];\n transcriptionModel: ProviderV3['transcriptionModel'];\n speechModel: ProviderV3['speechModel'];\n rerankingModel: ProviderV3['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV3>;\n embeddingModels?: Record<string, EmbeddingModelV3>;\n imageModels?: Record<string, ImageModelV3>;\n transcriptionModels?: Record<string, TranscriptionModelV3>;\n speechModels?: Record<string, SpeechModelV3>;\n rerankingModels?: Record<string, RerankingModelV3>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV3 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV4,\n type ImageModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n type RerankingModelV4,\n} from '@ai-sdk/provider';\nexport class MockProviderV4 implements ProviderV4 {\n readonly specificationVersion = 'v4' as const;\n\n languageModel: ProviderV4['languageModel'];\n embeddingModel: ProviderV4['embeddingModel'];\n imageModel: ProviderV4['imageModel'];\n transcriptionModel: ProviderV4['transcriptionModel'];\n speechModel: ProviderV4['speechModel'];\n rerankingModel: ProviderV4['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV4>;\n embeddingModels?: Record<string, EmbeddingModelV4>;\n imageModels?: Record<string, ImageModelV4>;\n transcriptionModels?: Record<string, TranscriptionModelV4>;\n speechModels?: Record<string, SpeechModelV4>;\n rerankingModels?: Record<string, RerankingModelV4>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV4 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import type { SpeechModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV3 implements SpeechModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: SpeechModelV3['provider'];\n readonly modelId: SpeechModelV3['modelId'];\n\n doGenerate: SpeechModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV3['provider'];\n modelId?: SpeechModelV3['modelId'];\n doGenerate?: SpeechModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { SpeechModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV4 implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: SpeechModelV4['provider'];\n readonly modelId: SpeechModelV4['modelId'];\n\n doGenerate: SpeechModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV4['provider'];\n modelId?: SpeechModelV4['modelId'];\n doGenerate?: SpeechModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_SpeechTranslationModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechTranslationModelV4 implements Experimental_SpeechTranslationModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_SpeechTranslationModelV4['provider'];\n readonly modelId: Experimental_SpeechTranslationModelV4['modelId'];\n\n doStream: Experimental_SpeechTranslationModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doStream = notImplemented,\n }: {\n provider?: Experimental_SpeechTranslationModelV4['provider'];\n modelId?: Experimental_SpeechTranslationModelV4['modelId'];\n doStream?: Experimental_SpeechTranslationModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doStream = doStream;\n }\n}\n","import type { TranscriptionModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV3 implements TranscriptionModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: TranscriptionModelV3['provider'];\n readonly modelId: TranscriptionModelV3['modelId'];\n\n doGenerate: TranscriptionModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: TranscriptionModelV3['provider'];\n modelId?: TranscriptionModelV3['modelId'];\n doGenerate?: TranscriptionModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { TranscriptionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV4 implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: TranscriptionModelV4['provider'];\n readonly modelId: TranscriptionModelV4['modelId'];\n\n doGenerate: TranscriptionModelV4['doGenerate'];\n doStream: TranscriptionModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream,\n }: {\n provider?: TranscriptionModelV4['provider'];\n modelId?: TranscriptionModelV4['modelId'];\n doGenerate?: TranscriptionModelV4['doGenerate'];\n doStream?: TranscriptionModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n }\n}\n","import type { RerankingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV3 implements RerankingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: RerankingModelV3['provider'];\n readonly modelId: RerankingModelV3['modelId'];\n\n doRerank: RerankingModelV3['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV3['provider'];\n modelId?: RerankingModelV3['modelId'];\n doRerank?: RerankingModelV3['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { RerankingModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV4 implements RerankingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: RerankingModelV4['provider'];\n readonly modelId: RerankingModelV4['modelId'];\n\n doRerank: RerankingModelV4['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV4['provider'];\n modelId?: RerankingModelV4['modelId'];\n doRerank?: RerankingModelV4['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { Experimental_VideoModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV3 implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: Experimental_VideoModelV3['provider'];\n readonly modelId: Experimental_VideoModelV3['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV3['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxVideosPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: Experimental_VideoModelV3['provider'];\n modelId?: Experimental_VideoModelV3['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV3['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxVideosPerCall = maxVideosPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_VideoModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV4 implements Experimental_VideoModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_VideoModelV4['provider'];\n readonly modelId: Experimental_VideoModelV4['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV4['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV4['doGenerate'];\n handleWebhookOption: Experimental_VideoModelV4['handleWebhookOption'];\n doStart: Experimental_VideoModelV4['doStart'];\n doStatus: Experimental_VideoModelV4['doStatus'];\n\n constructor(\n options: {\n provider?: Experimental_VideoModelV4['provider'];\n modelId?: Experimental_VideoModelV4['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV4['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV4['doGenerate'];\n handleWebhookOption?: Experimental_VideoModelV4['handleWebhookOption'];\n doStart?: Experimental_VideoModelV4['doStart'];\n doStatus?: Experimental_VideoModelV4['doStatus'];\n } = {},\n ) {\n this.provider = options.provider ?? 'mock-provider';\n this.modelId = options.modelId ?? 'mock-model-id';\n this.maxVideosPerCall = options.maxVideosPerCall ?? 1;\n this.doGenerate =\n 'doGenerate' in options ? options.doGenerate : notImplemented;\n this.handleWebhookOption = options.handleWebhookOption;\n this.doStart = options.doStart;\n this.doStatus = options.doStatus;\n }\n}\n","export function mockValues<T>(...values: T[]): () => T {\n let counter = 0;\n return () => values[counter++] ?? values[values.length - 1];\n}\n","import { simulateReadableStream as originalSimulateReadableStream } from '../src/util/simulate-readable-stream';\n\nexport {\n convertArrayToAsyncIterable,\n convertArrayToReadableStream,\n convertReadableStreamToArray,\n mockId,\n} from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV3 } from '../src/test/mock-embedding-model-v3';\nexport { MockEmbeddingModelV4 } from '../src/test/mock-embedding-model-v4';\nexport { EvaluationMockModelV4 as Experimental_EvaluationMockModelV4 } from '../src/test/evaluation-mock-model-v4';\nexport { MockImageModelV3 } from '../src/test/mock-image-model-v3';\nexport { MockImageModelV4 } from '../src/test/mock-image-model-v4';\nexport { MockLanguageModelV3 } from '../src/test/mock-language-model-v3';\nexport { MockLanguageModelV4 } from '../src/test/mock-language-model-v4';\nexport { MockProviderV3 } from '../src/test/mock-provider-v3';\nexport { MockProviderV4 } from '../src/test/mock-provider-v4';\nexport { MockSpeechModelV3 } from '../src/test/mock-speech-model-v3';\nexport { MockSpeechModelV4 } from '../src/test/mock-speech-model-v4';\nexport { MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4 } from '../src/test/mock-speech-translation-model-v4';\nexport { MockTranscriptionModelV3 } from '../src/test/mock-transcription-model-v3';\nexport { MockTranscriptionModelV4 } from '../src/test/mock-transcription-model-v4';\nexport { MockRerankingModelV3 } from '../src/test/mock-reranking-model-v3';\nexport { MockRerankingModelV4 } from '../src/test/mock-reranking-model-v4';\nexport { MockVideoModelV3 } from '../src/test/mock-video-model-v3';\nexport { MockVideoModelV4 } from '../src/test/mock-video-model-v4';\nexport { mockValues } from '../src/test/mock-values';\n\n/**\n * @deprecated Use `simulateReadableStream` from `ai` instead.\n */\nexport const simulateReadableStream = originalSimulateReadableStream;\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgBA,yBAA0B,EACxC,QACA,mBAAmB,GACnB,iBAAiB,GACjB,aAQoB;CACpB,MAAMC,UAAQ,WAAW,SAASC;CAElC,IAAI,QAAQ;CAEZ,OAAO,IAAI,eAAe,EACxB,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ages
|
|
609
609
|
|
|
610
610
|
System messages are messages that are sent to the model before the user messages to guide the assistant's behavior.
|
|
611
|
+
Sending system messages in `messages` requires `allowSystemInMessages: true`.
|
|
611
612
|
You can alternatively use the `instructions` property.
|
|
612
613
|
|
|
613
|
-
```ts highlight="
|
|
614
|
+
```ts highlight="3,5"
|
|
614
615
|
const result = await generateText({
|
|
615
616
|
model: __MODEL__,
|
|
617
|
+
allowSystemInMessages: true,
|
|
616
618
|
messages: [
|
|
617
619
|
{ role: 'system', content: 'You help planning travel itineraries.' },
|
|
618
620
|
{
|
|
@@ -239,7 +239,7 @@ import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
|
|
|
239
239
|
import { generateText } from 'ai';
|
|
240
240
|
|
|
241
241
|
const { text } = await generateText({
|
|
242
|
-
model: anthropic('claude-opus-
|
|
242
|
+
model: anthropic('claude-opus-4-6'),
|
|
243
243
|
prompt: 'Write a short poem about the sea.',
|
|
244
244
|
providerOptions: {
|
|
245
245
|
anthropic: {
|
|
@@ -248,7 +248,7 @@ Now your agent can "fetch" weather information for any location the user asks ab
|
|
|
248
248
|
|
|
249
249
|
Try asking something like "What's the weather in New York?" and see how the agent uses the new tool.
|
|
250
250
|
|
|
251
|
-
Notice the blank "assistant" response? This is because instead of generating a text response, the agent generated a tool call. You can access the tool call and subsequent tool result in the `
|
|
251
|
+
Notice the blank "assistant" response? This is because instead of generating a text response, the agent generated a tool call. You can access the tool call and subsequent tool result in the `toolCalls` and `toolResults` properties of the result object.
|
|
252
252
|
|
|
253
253
|
```typescript highlight="50-51"
|
|
254
254
|
import { ModelMessage, streamText, tool } from 'ai';
|
|
@@ -387,15 +387,15 @@ main().catch(console.error);
|
|
|
387
387
|
In this updated code:
|
|
388
388
|
|
|
389
389
|
1. You set `stopWhen` to be when `isStepCount` 5, allowing the agent to use up to 5 "steps" for any given generation.
|
|
390
|
-
2. You add an `onStepEnd` callback to log any `toolResults` from each step of the interaction, helping you understand the agent's tool usage. This means we can also delete the `
|
|
390
|
+
2. You add an `onStepEnd` callback to log any `toolResults` from each step of the interaction, helping you understand the agent's tool usage. This means we can also delete the `toolCalls` and `toolResults` `console.log` statements from the previous example.
|
|
391
391
|
|
|
392
392
|
Now, when you ask about the weather in a location, you should see the agent using the weather tool results to answer your question.
|
|
393
393
|
|
|
394
|
-
By setting `stopWhen: isStepCount(5)`, you're allowing the agent to use up to 5 "steps" for any given generation. This enables more complex interactions and allows the agent to gather and process information over several steps if needed. You can see this in action by adding another tool to convert the temperature from
|
|
394
|
+
By setting `stopWhen: isStepCount(5)`, you're allowing the agent to use up to 5 "steps" for any given generation. This enables more complex interactions and allows the agent to gather and process information over several steps if needed. You can see this in action by adding another tool to convert the temperature from Fahrenheit to Celsius.
|
|
395
395
|
|
|
396
396
|
### Adding a second tool
|
|
397
397
|
|
|
398
|
-
Update your `index.ts` file to add a new tool to convert the temperature from
|
|
398
|
+
Update your `index.ts` file to add a new tool to convert the temperature from Fahrenheit to Celsius:
|
|
399
399
|
|
|
400
400
|
```ts filename="index.ts" highlight="39-52"
|
|
401
401
|
import { ModelMessage, streamText, tool, isStepCount } from 'ai';
|
|
@@ -423,7 +423,7 @@ In this updated code, you set `stopWhen` to be when `isStepCount(5)`, allowing t
|
|
|
423
423
|
|
|
424
424
|
Head back to the browser and ask about the weather in a location. You should now see the model using the weather tool results to answer your question.
|
|
425
425
|
|
|
426
|
-
By setting `stopWhen: isStepCount(5)`, you're allowing the model to use up to 5 "steps" for any given generation. This enables more complex interactions and allows the model to gather and process information over several steps if needed. You can see this in action by adding another tool to convert the temperature from
|
|
426
|
+
By setting `stopWhen: isStepCount(5)`, you're allowing the model to use up to 5 "steps" for any given generation. This enables more complex interactions and allows the model to gather and process information over several steps if needed. You can see this in action by adding another tool to convert the temperature from Fahrenheit to Celsius.
|
|
427
427
|
|
|
428
428
|
### Add another tool
|
|
429
429
|
|
|
@@ -68,7 +68,7 @@ The `options` parameter is now required and type-checked. If you don't provide i
|
|
|
68
68
|
|
|
69
69
|
## Modifying Agent Settings
|
|
70
70
|
|
|
71
|
-
Use `prepareCall` to modify any agent setting.
|
|
71
|
+
Use `prepareCall` to modify any agent setting. The returned object replaces the call settings, so spread the incoming settings and override only the ones you want to change.
|
|
72
72
|
|
|
73
73
|
### Dynamic Model Selection
|
|
74
74
|
|
|
@@ -396,7 +396,7 @@ This works with all output types that support structured generation:
|
|
|
396
396
|
|
|
397
397
|
## Accessing Reasoning
|
|
398
398
|
|
|
399
|
-
You can access the reasoning used by the language model to generate the object via the `
|
|
399
|
+
You can access the reasoning used by the language model to generate the object via the `reasoningText` property on the result. This property contains a string with the model's thought process, if available.
|
|
400
400
|
|
|
401
401
|
```ts
|
|
402
402
|
import { generateText, Output } from 'ai';
|
|
@@ -92,9 +92,9 @@ When the model calls an app-backed tool, the MCP client preserves the app metada
|
|
|
92
92
|
|
|
93
93
|
Use `readMCPAppResource` to read and normalize an app resource before sending it to the browser host.
|
|
94
94
|
|
|
95
|
-
```ts filename="app/api/mcp-app-host/route.ts"
|
|
95
|
+
```ts filename="app/api/mcp-app-host/read-resource/route.ts"
|
|
96
96
|
import { readMCPAppResource } from '@ai-sdk/mcp';
|
|
97
|
-
import { createMCPAppsClient } from '
|
|
97
|
+
import { createMCPAppsClient } from '../../chat/mcp-client';
|
|
98
98
|
|
|
99
99
|
export async function POST(req: Request) {
|
|
100
100
|
const requestUrl = new URL(req.url);
|
|
@@ -117,11 +117,11 @@ The iframe cannot connect directly to your MCP server. It sends JSON-RPC message
|
|
|
117
117
|
|
|
118
118
|
For app-initiated tool calls, validate that the requested tool is app-visible before calling the MCP server.
|
|
119
119
|
|
|
120
|
-
```ts filename="app/api/mcp-app-host/route.ts"
|
|
120
|
+
```ts filename="app/api/mcp-app-host/call-tool/route.ts"
|
|
121
121
|
import { splitMCPAppTools } from '@ai-sdk/mcp';
|
|
122
|
-
import { createMCPAppsClient } from '
|
|
122
|
+
import { createMCPAppsClient } from '../../chat/mcp-client';
|
|
123
123
|
|
|
124
|
-
export async function
|
|
124
|
+
export async function POST(req: Request) {
|
|
125
125
|
const requestUrl = new URL(req.url);
|
|
126
126
|
const { name, arguments: toolArguments } = await req.json();
|
|
127
127
|
const client = await createMCPAppsClient(requestUrl.origin);
|
|
@@ -30,6 +30,42 @@ const language = transcript.language; // language of the transcript e.g. "en", i
|
|
|
30
30
|
const durationInSeconds = transcript.durationInSeconds; // duration of the transcript in seconds, if available
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
## Telemetry
|
|
34
|
+
|
|
35
|
+
`transcribe` and `experimental_streamTranscribe` accept the standard
|
|
36
|
+
`telemetry` option. Registered integrations receive start, end, and error
|
|
37
|
+
events with the provider and model, audio byte length and media type, final
|
|
38
|
+
transcript, warnings, response metadata, provider metadata, and usage when the
|
|
39
|
+
provider reports it. Because streaming transcription is experimental, custom
|
|
40
|
+
integrations receive its lifecycle through
|
|
41
|
+
`experimental_onStreamTranscriptionStart` and
|
|
42
|
+
`experimental_onStreamTranscriptionEnd`; errors continue to use `onError`.
|
|
43
|
+
Integrations that wrap or delegate to another telemetry integration must
|
|
44
|
+
forward these experimental callbacks explicitly for streaming transcription
|
|
45
|
+
to be observed.
|
|
46
|
+
|
|
47
|
+
```ts highlight="5-7"
|
|
48
|
+
const transcript = await transcribe({
|
|
49
|
+
model: openai.transcription('gpt-4o-transcribe'),
|
|
50
|
+
audio: await readFile('audio.mp3'),
|
|
51
|
+
telemetry: {
|
|
52
|
+
functionId: 'transcribe-customer-call',
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Raw audio is not included in telemetry events. For streaming transcription,
|
|
58
|
+
the final byte length is emitted only after the input stream is consumed and
|
|
59
|
+
the transcription finishes. Use `recordInputs: false` or
|
|
60
|
+
`recordOutputs: false` to prevent integrations from recording sensitive input
|
|
61
|
+
or output fields.
|
|
62
|
+
|
|
63
|
+
For URL audio, the downloaded media type is passed to the provider and reported
|
|
64
|
+
on successful telemetry events. If downloading or decoding input audio fails,
|
|
65
|
+
the start event is still emitted before the correlated error event, but its
|
|
66
|
+
audio byte length and media type can be undefined because preparation did not
|
|
67
|
+
complete.
|
|
68
|
+
|
|
33
69
|
## Streaming Transcription
|
|
34
70
|
|
|
35
71
|
<Note type="warning">Streaming transcription is an experimental feature.</Note>
|
|
@@ -12,13 +12,34 @@ function to generate speech from text using a speech model.
|
|
|
12
12
|
import { generateSpeech } from 'ai';
|
|
13
13
|
import { openai } from '@ai-sdk/openai';
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const result = await generateSpeech({
|
|
16
16
|
model: openai.speech('gpt-4o-mini-tts'),
|
|
17
17
|
text: 'Hello, world!',
|
|
18
18
|
voice: 'alloy',
|
|
19
19
|
});
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
## Telemetry
|
|
23
|
+
|
|
24
|
+
`generateSpeech` accepts the standard `telemetry` option. Registered
|
|
25
|
+
integrations receive start, end, and error events with the provider and model,
|
|
26
|
+
source text, generated audio byte length, media type and format, warnings,
|
|
27
|
+
response metadata, provider metadata, and usage when the provider reports it.
|
|
28
|
+
Raw generated audio is not included in telemetry events.
|
|
29
|
+
|
|
30
|
+
```ts highlight="5-7"
|
|
31
|
+
const result = await generateSpeech({
|
|
32
|
+
model: openai.speech('gpt-4o-mini-tts'),
|
|
33
|
+
text: 'Hello from the AI SDK!',
|
|
34
|
+
telemetry: {
|
|
35
|
+
functionId: 'speak-greeting',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Use `recordInputs: false` or `recordOutputs: false` when the text or output
|
|
41
|
+
metadata should not be recorded by telemetry integrations.
|
|
42
|
+
|
|
22
43
|
To access the generated audio:
|
|
23
44
|
|
|
24
45
|
```ts
|
|
@@ -71,7 +71,7 @@ Responses API, not `openai.chat()`.
|
|
|
71
71
|
## Starting a batch
|
|
72
72
|
|
|
73
73
|
Pass a provider and one or more uniquely identified requests to `startBatch`.
|
|
74
|
-
Each request must specify `type: 'text'`, a model ID, and either a text `prompt`
|
|
74
|
+
Each text request must specify `type: 'text'`, a model ID, and either a text `prompt`
|
|
75
75
|
or a `messages` array. Requests can use different model IDs when supported by
|
|
76
76
|
the provider. Each request can also use the usual text-generation settings such
|
|
77
77
|
as `instructions`, `maxOutputTokens`, `temperature`, `topP`, `topK`,
|
|
@@ -53,7 +53,10 @@ For Node.js applications (without Next.js), register the integration at the top
|
|
|
53
53
|
|
|
54
54
|
### Step 2: Enabling Telemetry
|
|
55
55
|
|
|
56
|
-
Once a telemetry integration is registered,
|
|
56
|
+
Once a telemetry integration is registered, supported AI SDK calls emit
|
|
57
|
+
telemetry events by default. This includes text and object generation,
|
|
58
|
+
embeddings, reranking, speech generation, and both non-streaming and streaming
|
|
59
|
+
transcription.
|
|
57
60
|
You can still pass `telemetry` to attach metadata (like `functionId`) or to opt out of a specific call:
|
|
58
61
|
|
|
59
62
|
```ts highlight="4-6"
|
|
@@ -71,6 +74,34 @@ By default, both inputs and outputs are recorded. You can disable them by settin
|
|
|
71
74
|
Disabling the recording of inputs and outputs can be useful for privacy, data transfer, and performance reasons.
|
|
72
75
|
You might for example want to disable recording inputs if they contain sensitive information.
|
|
73
76
|
|
|
77
|
+
For `generateSpeech`, input telemetry contains the source text and output
|
|
78
|
+
telemetry contains the generated audio byte length, media type, and format.
|
|
79
|
+
For `transcribe` and `experimental_streamTranscribe`, telemetry contains the
|
|
80
|
+
input audio byte length and media type plus the output transcript. Raw audio is
|
|
81
|
+
never included in telemetry events. Streaming transcription reports its final
|
|
82
|
+
byte length when the audio stream has been consumed and the transcription
|
|
83
|
+
finishes.
|
|
84
|
+
|
|
85
|
+
Custom integrations receive stable `generateSpeech` and `transcribe`
|
|
86
|
+
operations through `onStart` and `onEnd`. To keep the experimental API isolated,
|
|
87
|
+
`experimental_streamTranscribe` uses
|
|
88
|
+
`experimental_onStreamTranscriptionStart` and
|
|
89
|
+
`experimental_onStreamTranscriptionEnd`; all three operations report failures
|
|
90
|
+
through `onError`.
|
|
91
|
+
|
|
92
|
+
An integration that wraps or delegates to another integration must explicitly
|
|
93
|
+
forward the experimental streaming transcription callbacks. Forwarding only
|
|
94
|
+
the stable `onStart` and `onEnd` callbacks does not observe
|
|
95
|
+
`experimental_streamTranscribe`.
|
|
96
|
+
|
|
97
|
+
The built-in OpenTelemetry integrations record numeric provider usage by
|
|
98
|
+
default, preserving each reported unit. The modern integration uses attributes
|
|
99
|
+
such as `gen_ai.usage.characters`, `gen_ai.usage.seconds`, and
|
|
100
|
+
`gen_ai.usage.input_tokens`; `LegacyOpenTelemetry` uses the corresponding
|
|
101
|
+
`ai.usage.*` attributes. The provider-native usage object remains available to
|
|
102
|
+
callbacks, and can also be included as the supplemental `ai.response.usage`
|
|
103
|
+
attribute by enabling `usage: true`.
|
|
104
|
+
|
|
74
105
|
### Opting out
|
|
75
106
|
|
|
76
107
|
Telemetry is opt-out. To disable telemetry for a specific call, set `isEnabled: false`:
|
|
@@ -219,11 +250,11 @@ registerTelemetry(new OpenTelemetry());
|
|
|
219
250
|
You can also register multiple integrations in a single call by passing them as additional arguments. They all receive the same lifecycle events:
|
|
220
251
|
|
|
221
252
|
```ts
|
|
222
|
-
import {
|
|
253
|
+
import { registerTelemetry } from 'ai';
|
|
223
254
|
import { OpenTelemetry } from '@ai-sdk/otel';
|
|
224
255
|
import { DevToolsTelemetry } from '@ai-sdk/devtools';
|
|
225
256
|
|
|
226
|
-
|
|
257
|
+
registerTelemetry(new OpenTelemetry(), DevToolsTelemetry());
|
|
227
258
|
```
|
|
228
259
|
|
|
229
260
|
### Per-call integrations
|
|
@@ -550,6 +581,23 @@ For `rerank`, the integration records spans with `CLIENT` kind:
|
|
|
550
581
|
- `gen_ai.provider.name`: the provider
|
|
551
582
|
- `gen_ai.request.model`: the model ID
|
|
552
583
|
|
|
584
|
+
#### generateSpeech / transcribe / experimental_streamTranscribe
|
|
585
|
+
|
|
586
|
+
Each call records a single `CLIENT` span named `{operationId} {modelId}`, where
|
|
587
|
+
`operationId` is `ai.generateSpeech`, `ai.transcribe`, or `ai.streamTranscribe`.
|
|
588
|
+
|
|
589
|
+
- `gen_ai.output.type`: `"speech"` for speech generation and `"text"` for transcription.
|
|
590
|
+
- `gen_ai.request.stream`: `true` for streaming transcription and `false` otherwise.
|
|
591
|
+
- `gen_ai.input.messages`: speech generation input text as a user message with a text part, when `recordInputs` is enabled.
|
|
592
|
+
- `gen_ai.output.messages`: the completed transcript as an assistant message with a text part, when `recordOutputs` is enabled. Streaming transcription records this once on completion.
|
|
593
|
+
|
|
594
|
+
The existing `ai.request.text` and `ai.response.text` attributes are also retained.
|
|
595
|
+
Audio byte length, media type, and output format remain in the
|
|
596
|
+
`ai.request.audio.*` and `ai.response.audio.*` attributes, subject to the
|
|
597
|
+
corresponding input/output recording controls. Raw audio is not captured, so
|
|
598
|
+
transcription input and speech output do not populate message attributes with
|
|
599
|
+
audio content or placeholder audio parts.
|
|
600
|
+
|
|
553
601
|
#### experimental_evaluate
|
|
554
602
|
|
|
555
603
|
For `experimental_evaluate`, the integration records two spans with `CLIENT`
|
|
@@ -239,6 +239,30 @@ This is different from model calls, where the application usually sends the full
|
|
|
239
239
|
message history. In chat routes, persist and resume the harness session instead
|
|
240
240
|
of relying on message replay.
|
|
241
241
|
|
|
242
|
+
### Reading the Runtime's Own History
|
|
243
|
+
|
|
244
|
+
The runtime's conversation can grow outside your process — the same
|
|
245
|
+
conversation continued interactively in the agent's own CLI, for instance —
|
|
246
|
+
and the live event stream never sees those exchanges. Adapters that can reach
|
|
247
|
+
their runtime's store expose them through `session.readHistory()`:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
const { messages, cursor } = await session.readHistory();
|
|
251
|
+
// Messages use role/content shapes. Adapter-specific details, including the
|
|
252
|
+
// runtime's raw record, are available under harnessMetadata.
|
|
253
|
+
|
|
254
|
+
// Later: read only what was recorded since.
|
|
255
|
+
const delta = await session.readHistory({ since: cursor });
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
History reads are adapter-specific; see the adapter capability table before
|
|
259
|
+
calling this method.
|
|
260
|
+
`readHistory()` throws `HarnessCapabilityUnsupportedError` when the adapter
|
|
261
|
+
does not implement history reads, and `HarnessHistoryUnavailableError` when it
|
|
262
|
+
does but cannot reach the runtime's store from this environment (for example,
|
|
263
|
+
the store lives inside a remote sandbox). A conversation with no recorded
|
|
264
|
+
messages yet is not an error; it resolves to an empty `messages` array.
|
|
265
|
+
|
|
242
266
|
## Session Lifecycle
|
|
243
267
|
|
|
244
268
|
End every session explicitly:
|
|
@@ -33,15 +33,15 @@ The AI SDK includes the following harness adapters:
|
|
|
33
33
|
|
|
34
34
|
## Adapter Capabilities
|
|
35
35
|
|
|
36
|
-
| Adapter | Runtime location | Custom tools | Custom skills | Structured output | Built-in tool approval | Built-in tool filtering |
|
|
37
|
-
| ------------------------------------------------------------ | ---------------- | ------------ | ------------- | ----------------- | ---------------------- | ---------------------------- |
|
|
38
|
-
| [Claude Code](/providers/ai-sdk-harnesses/claude-code) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
39
|
-
| [Cline](/providers/ai-sdk-harnesses/cline) | Host process | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
40
|
-
| [Codex](/providers/ai-sdk-harnesses/codex) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> |
|
|
41
|
-
| [Cursor](/providers/ai-sdk-harnesses/cursor) | Sandbox via ACP | <Check /> | <Check /> | <Cross /> | <Cross /> | <Cross /> |
|
|
42
|
-
| [Deep Agents](/providers/ai-sdk-harnesses/deepagents) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> via auto-rejection |
|
|
43
|
-
| [fx](/providers/ai-sdk-harnesses/fx) | Sandbox via ACP | <Check /> | <Check /> | <Cross /> | <Check /> | <Cross /> |
|
|
44
|
-
| [GitHub Copilot](/providers/ai-sdk-harnesses/github-copilot) | Sandbox via ACP | <Check /> | <Check /> | <Cross /> | <Cross /> | <Cross /> |
|
|
45
|
-
| [Grok Build](/providers/ai-sdk-harnesses/grok-build) | Sandbox via ACP | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> |
|
|
46
|
-
| [OpenCode](/providers/ai-sdk-harnesses/opencode) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> via auto-rejection |
|
|
47
|
-
| [Pi](/providers/ai-sdk-harnesses/pi) | Host process | <Check /> | <Check /> | <Cross /> | <Check /> | <Check /> |
|
|
36
|
+
| Adapter | Runtime location | Custom tools | Custom skills | Structured output | Built-in tool approval | Built-in tool filtering | History access |
|
|
37
|
+
| ------------------------------------------------------------ | ---------------- | ------------ | ------------- | ----------------- | ---------------------- | ---------------------------- | -------------- |
|
|
38
|
+
| [Claude Code](/providers/ai-sdk-harnesses/claude-code) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> |
|
|
39
|
+
| [Cline](/providers/ai-sdk-harnesses/cline) | Host process | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> |
|
|
40
|
+
| [Codex](/providers/ai-sdk-harnesses/codex) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> | <Cross /> |
|
|
41
|
+
| [Cursor](/providers/ai-sdk-harnesses/cursor) | Sandbox via ACP | <Check /> | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
|
|
42
|
+
| [Deep Agents](/providers/ai-sdk-harnesses/deepagents) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> via auto-rejection | <Cross /> |
|
|
43
|
+
| [fx](/providers/ai-sdk-harnesses/fx) | Sandbox via ACP | <Check /> | <Check /> | <Cross /> | <Check /> | <Cross /> | <Cross /> |
|
|
44
|
+
| [GitHub Copilot](/providers/ai-sdk-harnesses/github-copilot) | Sandbox via ACP | <Check /> | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
|
|
45
|
+
| [Grok Build](/providers/ai-sdk-harnesses/grok-build) | Sandbox via ACP | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> | <Cross /> |
|
|
46
|
+
| [OpenCode](/providers/ai-sdk-harnesses/opencode) | Sandbox bridge | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> via auto-rejection | <Cross /> |
|
|
47
|
+
| [Pi](/providers/ai-sdk-harnesses/pi) | Host process | <Check /> | <Check /> | <Cross /> | <Check /> | <Check /> | <Cross /> |
|
|
@@ -151,7 +151,7 @@ import {
|
|
|
151
151
|
} from 'ai';
|
|
152
152
|
import { z } from 'zod';
|
|
153
153
|
import { loadChat, saveChat } from '@util/chat-store';
|
|
154
|
-
import {
|
|
154
|
+
import { dataSchemas, metadataSchema } from '@util/schemas';
|
|
155
155
|
|
|
156
156
|
// Define your tools
|
|
157
157
|
const tools = {
|
|
@@ -182,13 +182,13 @@ export async function POST(req: Request) {
|
|
|
182
182
|
const validatedMessages = await validateUIMessages({
|
|
183
183
|
messages,
|
|
184
184
|
tools, // Ensures tool calls in messages match current schemas
|
|
185
|
-
|
|
185
|
+
dataSchemas,
|
|
186
186
|
metadataSchema,
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
const result = streamText({
|
|
190
190
|
model: 'openai/gpt-6-luna',
|
|
191
|
-
messages: convertToModelMessages(validatedMessages),
|
|
191
|
+
messages: await convertToModelMessages(validatedMessages),
|
|
192
192
|
tools,
|
|
193
193
|
});
|
|
194
194
|
|
|
@@ -399,7 +399,8 @@ You can use this message ID to e.g. manipulate individual messages.
|
|
|
399
399
|
By default, message IDs are generated client-side:
|
|
400
400
|
|
|
401
401
|
- User message IDs are generated by the `useChat` hook on the client
|
|
402
|
-
- AI response message IDs are generated by `
|
|
402
|
+
- AI response message IDs are also generated by `useChat` on the client, unless
|
|
403
|
+
the server sends one in the stream (see below)
|
|
403
404
|
|
|
404
405
|
For applications without persistence, client-side ID generation works perfectly.
|
|
405
406
|
However, **for persistence, you should use IDs that are stable before messages
|
|
@@ -459,8 +460,9 @@ export async function POST(req: Request) {
|
|
|
459
460
|
|
|
460
461
|
Alternatively, you can use `createUIMessageStream` to control the message ID by writing a start message part:
|
|
461
462
|
|
|
462
|
-
```tsx filename="app/api/chat/route.ts" highlight="
|
|
463
|
+
```tsx filename="app/api/chat/route.ts" highlight="15-19,26-28"
|
|
463
464
|
import {
|
|
465
|
+
convertToModelMessages,
|
|
464
466
|
generateId,
|
|
465
467
|
streamText,
|
|
466
468
|
createUIMessageStream,
|
|
@@ -472,7 +474,7 @@ export async function POST(req: Request) {
|
|
|
472
474
|
const { messages, chatId } = await req.json();
|
|
473
475
|
|
|
474
476
|
const stream = createUIMessageStream({
|
|
475
|
-
execute: ({ writer }) => {
|
|
477
|
+
execute: async ({ writer }) => {
|
|
476
478
|
// Write start message part with custom ID
|
|
477
479
|
writer.write({
|
|
478
480
|
type: 'start',
|
|
@@ -572,7 +574,7 @@ export async function POST(req: Request) {
|
|
|
572
574
|
|
|
573
575
|
const result = streamText({
|
|
574
576
|
// ...
|
|
575
|
-
messages: convertToModelMessages(validatedMessages),
|
|
577
|
+
messages: await convertToModelMessages(validatedMessages),
|
|
576
578
|
});
|
|
577
579
|
|
|
578
580
|
return createUIMessageStreamResponse({
|