ai 0.0.0-85f9a635-20240518005312 → 0.0.0-9477ebb9-20250403064906

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +3521 -0
  2. package/README.md +112 -22
  3. package/dist/index.d.mts +3697 -1642
  4. package/dist/index.d.ts +3697 -1642
  5. package/dist/index.js +7201 -2942
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +7249 -2963
  8. package/dist/index.mjs.map +1 -1
  9. package/mcp-stdio/create-child-process.test.ts +92 -0
  10. package/mcp-stdio/create-child-process.ts +21 -0
  11. package/mcp-stdio/dist/index.d.mts +169 -0
  12. package/mcp-stdio/dist/index.d.ts +169 -0
  13. package/mcp-stdio/dist/index.js +352 -0
  14. package/mcp-stdio/dist/index.js.map +1 -0
  15. package/mcp-stdio/dist/index.mjs +337 -0
  16. package/mcp-stdio/dist/index.mjs.map +1 -0
  17. package/mcp-stdio/get-environment.ts +43 -0
  18. package/mcp-stdio/index.ts +4 -0
  19. package/mcp-stdio/mcp-stdio-transport.test.ts +262 -0
  20. package/mcp-stdio/mcp-stdio-transport.ts +157 -0
  21. package/package.json +46 -103
  22. package/react/dist/index.d.mts +10 -557
  23. package/react/dist/index.d.ts +10 -574
  24. package/react/dist/index.js +6 -1397
  25. package/react/dist/index.js.map +1 -1
  26. package/react/dist/index.mjs +10 -1384
  27. package/react/dist/index.mjs.map +1 -1
  28. package/rsc/dist/index.d.ts +432 -199
  29. package/rsc/dist/rsc-server.d.mts +431 -199
  30. package/rsc/dist/rsc-server.mjs +1599 -1357
  31. package/rsc/dist/rsc-server.mjs.map +1 -1
  32. package/rsc/dist/rsc-shared.d.mts +30 -23
  33. package/rsc/dist/rsc-shared.mjs +70 -108
  34. package/rsc/dist/rsc-shared.mjs.map +1 -1
  35. package/test/dist/index.d.mts +65 -0
  36. package/test/dist/index.d.ts +65 -0
  37. package/test/dist/index.js +121 -0
  38. package/test/dist/index.js.map +1 -0
  39. package/test/dist/index.mjs +94 -0
  40. package/test/dist/index.mjs.map +1 -0
  41. package/prompts/dist/index.d.mts +0 -324
  42. package/prompts/dist/index.d.ts +0 -324
  43. package/prompts/dist/index.js +0 -178
  44. package/prompts/dist/index.js.map +0 -1
  45. package/prompts/dist/index.mjs +0 -146
  46. package/prompts/dist/index.mjs.map +0 -1
  47. package/react/dist/index.server.d.mts +0 -17
  48. package/react/dist/index.server.d.ts +0 -17
  49. package/react/dist/index.server.js +0 -50
  50. package/react/dist/index.server.js.map +0 -1
  51. package/react/dist/index.server.mjs +0 -23
  52. package/react/dist/index.server.mjs.map +0 -1
  53. package/solid/dist/index.d.mts +0 -408
  54. package/solid/dist/index.d.ts +0 -408
  55. package/solid/dist/index.js +0 -1072
  56. package/solid/dist/index.js.map +0 -1
  57. package/solid/dist/index.mjs +0 -1044
  58. package/solid/dist/index.mjs.map +0 -1
  59. package/svelte/dist/index.d.mts +0 -484
  60. package/svelte/dist/index.d.ts +0 -484
  61. package/svelte/dist/index.js +0 -1778
  62. package/svelte/dist/index.js.map +0 -1
  63. package/svelte/dist/index.mjs +0 -1749
  64. package/svelte/dist/index.mjs.map +0 -1
  65. package/vue/dist/index.d.mts +0 -402
  66. package/vue/dist/index.d.ts +0 -402
  67. package/vue/dist/index.js +0 -1072
  68. package/vue/dist/index.js.map +0 -1
  69. package/vue/dist/index.mjs +0 -1034
  70. package/vue/dist/index.mjs.map +0 -1
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // test/index.ts
21
+ var test_exports = {};
22
+ __export(test_exports, {
23
+ MockEmbeddingModelV1: () => MockEmbeddingModelV1,
24
+ MockLanguageModelV1: () => MockLanguageModelV1,
25
+ convertArrayToReadableStream: () => import_test.convertArrayToReadableStream,
26
+ mockId: () => import_test.mockId,
27
+ mockValues: () => mockValues,
28
+ simulateReadableStream: () => simulateReadableStream2
29
+ });
30
+ module.exports = __toCommonJS(test_exports);
31
+ var import_test = require("@ai-sdk/provider-utils/test");
32
+
33
+ // core/test/not-implemented.ts
34
+ function notImplemented() {
35
+ throw new Error("Not implemented");
36
+ }
37
+
38
+ // core/test/mock-embedding-model-v1.ts
39
+ var MockEmbeddingModelV1 = class {
40
+ constructor({
41
+ provider = "mock-provider",
42
+ modelId = "mock-model-id",
43
+ maxEmbeddingsPerCall = 1,
44
+ supportsParallelCalls = false,
45
+ doEmbed = notImplemented
46
+ } = {}) {
47
+ this.specificationVersion = "v1";
48
+ this.provider = provider;
49
+ this.modelId = modelId;
50
+ this.maxEmbeddingsPerCall = maxEmbeddingsPerCall != null ? maxEmbeddingsPerCall : void 0;
51
+ this.supportsParallelCalls = supportsParallelCalls;
52
+ this.doEmbed = doEmbed;
53
+ }
54
+ };
55
+
56
+ // core/test/mock-language-model-v1.ts
57
+ var MockLanguageModelV1 = class {
58
+ constructor({
59
+ provider = "mock-provider",
60
+ modelId = "mock-model-id",
61
+ supportsUrl = void 0,
62
+ doGenerate = notImplemented,
63
+ doStream = notImplemented,
64
+ defaultObjectGenerationMode = void 0,
65
+ supportsStructuredOutputs = void 0
66
+ } = {}) {
67
+ this.specificationVersion = "v1";
68
+ this.provider = provider;
69
+ this.modelId = modelId;
70
+ this.doGenerate = doGenerate;
71
+ this.doStream = doStream;
72
+ this.supportsUrl = supportsUrl;
73
+ this.defaultObjectGenerationMode = defaultObjectGenerationMode;
74
+ this.supportsStructuredOutputs = supportsStructuredOutputs;
75
+ }
76
+ };
77
+
78
+ // core/test/mock-values.ts
79
+ function mockValues(...values) {
80
+ let counter = 0;
81
+ return () => {
82
+ var _a;
83
+ return (_a = values[counter++]) != null ? _a : values[values.length - 1];
84
+ };
85
+ }
86
+
87
+ // core/util/simulate-readable-stream.ts
88
+ var import_provider_utils = require("@ai-sdk/provider-utils");
89
+ function simulateReadableStream({
90
+ chunks,
91
+ initialDelayInMs = 0,
92
+ chunkDelayInMs = 0,
93
+ _internal
94
+ }) {
95
+ var _a;
96
+ const delay = (_a = _internal == null ? void 0 : _internal.delay) != null ? _a : import_provider_utils.delay;
97
+ let index = 0;
98
+ return new ReadableStream({
99
+ async pull(controller) {
100
+ if (index < chunks.length) {
101
+ await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);
102
+ controller.enqueue(chunks[index++]);
103
+ } else {
104
+ controller.close();
105
+ }
106
+ }
107
+ });
108
+ }
109
+
110
+ // test/index.ts
111
+ var simulateReadableStream2 = simulateReadableStream;
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ MockEmbeddingModelV1,
115
+ MockLanguageModelV1,
116
+ convertArrayToReadableStream,
117
+ mockId,
118
+ mockValues,
119
+ simulateReadableStream
120
+ });
121
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts","../../core/test/not-implemented.ts","../../core/test/mock-embedding-model-v1.ts","../../core/test/mock-language-model-v1.ts","../../core/test/mock-values.ts","../../core/util/simulate-readable-stream.ts"],"sourcesContent":["export {\n convertArrayToReadableStream,\n mockId,\n} from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV1 } from '../core/test/mock-embedding-model-v1';\nexport { MockLanguageModelV1 } from '../core/test/mock-language-model-v1';\nexport { mockValues } from '../core/test/mock-values';\n\nimport { simulateReadableStream as originalSimulateReadableStream } from '../core/util/simulate-readable-stream';\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 { EmbeddingModelV1 } from '@ai-sdk/provider';\nimport { Embedding } from '../types';\nimport { EmbeddingModelUsage } from '../types/usage';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV1<VALUE> implements EmbeddingModelV1<VALUE> {\n readonly specificationVersion = 'v1';\n\n readonly provider: EmbeddingModelV1<VALUE>['provider'];\n readonly modelId: EmbeddingModelV1<VALUE>['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV1<VALUE>['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV1<VALUE>['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV1<VALUE>['doEmbed'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV1<VALUE>['provider'];\n modelId?: EmbeddingModelV1<VALUE>['modelId'];\n maxEmbeddingsPerCall?:\n | EmbeddingModelV1<VALUE>['maxEmbeddingsPerCall']\n | null;\n supportsParallelCalls?: EmbeddingModelV1<VALUE>['supportsParallelCalls'];\n doEmbed?: EmbeddingModelV1<VALUE>['doEmbed'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = doEmbed;\n }\n}\n\nexport function mockEmbed<VALUE>(\n expectedValues: Array<VALUE>,\n embeddings: Array<Embedding>,\n usage?: EmbeddingModelUsage,\n): EmbeddingModelV1<VALUE>['doEmbed'] {\n return async ({ values }) => {\n assert.deepStrictEqual(expectedValues, values);\n return { embeddings, usage };\n };\n}\n","import { LanguageModelV1 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV1 implements LanguageModelV1 {\n readonly specificationVersion = 'v1';\n\n readonly provider: LanguageModelV1['provider'];\n readonly modelId: LanguageModelV1['modelId'];\n\n supportsUrl: LanguageModelV1['supportsUrl'];\n doGenerate: LanguageModelV1['doGenerate'];\n doStream: LanguageModelV1['doStream'];\n\n readonly defaultObjectGenerationMode: LanguageModelV1['defaultObjectGenerationMode'];\n readonly supportsStructuredOutputs: LanguageModelV1['supportsStructuredOutputs'];\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportsUrl = undefined,\n doGenerate = notImplemented,\n doStream = notImplemented,\n defaultObjectGenerationMode = undefined,\n supportsStructuredOutputs = undefined,\n }: {\n provider?: LanguageModelV1['provider'];\n modelId?: LanguageModelV1['modelId'];\n supportsUrl?: LanguageModelV1['supportsUrl'];\n doGenerate?: LanguageModelV1['doGenerate'];\n doStream?: LanguageModelV1['doStream'];\n defaultObjectGenerationMode?: LanguageModelV1['defaultObjectGenerationMode'];\n supportsStructuredOutputs?: LanguageModelV1['supportsStructuredOutputs'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n this.supportsUrl = supportsUrl;\n\n this.defaultObjectGenerationMode = defaultObjectGenerationMode;\n this.supportsStructuredOutputs = supportsStructuredOutputs;\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 { 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAAA;AAAA;AAAA;AAAA,kBAGO;;;ACHA,SAAS,iBAAwB;AACtC,QAAM,IAAI,MAAM,iBAAiB;AACnC;;;ACGO,IAAM,uBAAN,MAAqE;AAAA,EAU1E,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,UAAU;AAAA,EACZ,IAQI,CAAC,GAAG;AAvBR,SAAS,uBAAuB;AAwB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,uBAAuB,sDAAwB;AACpD,SAAK,wBAAwB;AAC7B,SAAK,UAAU;AAAA,EACjB;AACF;;;ACjCO,IAAM,sBAAN,MAAqD;AAAA,EAY1D,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,IACd,aAAa;AAAA,IACb,WAAW;AAAA,IACX,8BAA8B;AAAA,IAC9B,4BAA4B;AAAA,EAC9B,IAQI,CAAC,GAAG;AA3BR,SAAS,uBAAuB;AA4B9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,WAAW;AAChB,SAAK,cAAc;AAEnB,SAAK,8BAA8B;AACnC,SAAK,4BAA4B;AAAA,EACnC;AACF;;;ACzCO,SAAS,cAAiB,QAAsB;AACrD,MAAI,UAAU;AACd,SAAO,MAAG;AAFZ;AAEe,wBAAO,SAAS,MAAhB,YAAqB,OAAO,OAAO,SAAS,CAAC;AAAA;AAC5D;;;ACHA,4BAAuC;AAWhC,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AAvBtB;AAwBE,QAAM,SAAQ,4CAAW,UAAX,YAAoB,sBAAAC;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;;;ALzBO,IAAMC,0BAAyB;","names":["simulateReadableStream","delayFunction","simulateReadableStream"]}
@@ -0,0 +1,94 @@
1
+ // test/index.ts
2
+ import {
3
+ convertArrayToReadableStream,
4
+ mockId
5
+ } from "@ai-sdk/provider-utils/test";
6
+
7
+ // core/test/not-implemented.ts
8
+ function notImplemented() {
9
+ throw new Error("Not implemented");
10
+ }
11
+
12
+ // core/test/mock-embedding-model-v1.ts
13
+ var MockEmbeddingModelV1 = class {
14
+ constructor({
15
+ provider = "mock-provider",
16
+ modelId = "mock-model-id",
17
+ maxEmbeddingsPerCall = 1,
18
+ supportsParallelCalls = false,
19
+ doEmbed = notImplemented
20
+ } = {}) {
21
+ this.specificationVersion = "v1";
22
+ this.provider = provider;
23
+ this.modelId = modelId;
24
+ this.maxEmbeddingsPerCall = maxEmbeddingsPerCall != null ? maxEmbeddingsPerCall : void 0;
25
+ this.supportsParallelCalls = supportsParallelCalls;
26
+ this.doEmbed = doEmbed;
27
+ }
28
+ };
29
+
30
+ // core/test/mock-language-model-v1.ts
31
+ var MockLanguageModelV1 = class {
32
+ constructor({
33
+ provider = "mock-provider",
34
+ modelId = "mock-model-id",
35
+ supportsUrl = void 0,
36
+ doGenerate = notImplemented,
37
+ doStream = notImplemented,
38
+ defaultObjectGenerationMode = void 0,
39
+ supportsStructuredOutputs = void 0
40
+ } = {}) {
41
+ this.specificationVersion = "v1";
42
+ this.provider = provider;
43
+ this.modelId = modelId;
44
+ this.doGenerate = doGenerate;
45
+ this.doStream = doStream;
46
+ this.supportsUrl = supportsUrl;
47
+ this.defaultObjectGenerationMode = defaultObjectGenerationMode;
48
+ this.supportsStructuredOutputs = supportsStructuredOutputs;
49
+ }
50
+ };
51
+
52
+ // core/test/mock-values.ts
53
+ function mockValues(...values) {
54
+ let counter = 0;
55
+ return () => {
56
+ var _a;
57
+ return (_a = values[counter++]) != null ? _a : values[values.length - 1];
58
+ };
59
+ }
60
+
61
+ // core/util/simulate-readable-stream.ts
62
+ import { delay as delayFunction } from "@ai-sdk/provider-utils";
63
+ function simulateReadableStream({
64
+ chunks,
65
+ initialDelayInMs = 0,
66
+ chunkDelayInMs = 0,
67
+ _internal
68
+ }) {
69
+ var _a;
70
+ const delay = (_a = _internal == null ? void 0 : _internal.delay) != null ? _a : delayFunction;
71
+ let index = 0;
72
+ return new ReadableStream({
73
+ async pull(controller) {
74
+ if (index < chunks.length) {
75
+ await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);
76
+ controller.enqueue(chunks[index++]);
77
+ } else {
78
+ controller.close();
79
+ }
80
+ }
81
+ });
82
+ }
83
+
84
+ // test/index.ts
85
+ var simulateReadableStream2 = simulateReadableStream;
86
+ export {
87
+ MockEmbeddingModelV1,
88
+ MockLanguageModelV1,
89
+ convertArrayToReadableStream,
90
+ mockId,
91
+ mockValues,
92
+ simulateReadableStream2 as simulateReadableStream
93
+ };
94
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts","../../core/test/not-implemented.ts","../../core/test/mock-embedding-model-v1.ts","../../core/test/mock-language-model-v1.ts","../../core/test/mock-values.ts","../../core/util/simulate-readable-stream.ts"],"sourcesContent":["export {\n convertArrayToReadableStream,\n mockId,\n} from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV1 } from '../core/test/mock-embedding-model-v1';\nexport { MockLanguageModelV1 } from '../core/test/mock-language-model-v1';\nexport { mockValues } from '../core/test/mock-values';\n\nimport { simulateReadableStream as originalSimulateReadableStream } from '../core/util/simulate-readable-stream';\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 { EmbeddingModelV1 } from '@ai-sdk/provider';\nimport { Embedding } from '../types';\nimport { EmbeddingModelUsage } from '../types/usage';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV1<VALUE> implements EmbeddingModelV1<VALUE> {\n readonly specificationVersion = 'v1';\n\n readonly provider: EmbeddingModelV1<VALUE>['provider'];\n readonly modelId: EmbeddingModelV1<VALUE>['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV1<VALUE>['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV1<VALUE>['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV1<VALUE>['doEmbed'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV1<VALUE>['provider'];\n modelId?: EmbeddingModelV1<VALUE>['modelId'];\n maxEmbeddingsPerCall?:\n | EmbeddingModelV1<VALUE>['maxEmbeddingsPerCall']\n | null;\n supportsParallelCalls?: EmbeddingModelV1<VALUE>['supportsParallelCalls'];\n doEmbed?: EmbeddingModelV1<VALUE>['doEmbed'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = doEmbed;\n }\n}\n\nexport function mockEmbed<VALUE>(\n expectedValues: Array<VALUE>,\n embeddings: Array<Embedding>,\n usage?: EmbeddingModelUsage,\n): EmbeddingModelV1<VALUE>['doEmbed'] {\n return async ({ values }) => {\n assert.deepStrictEqual(expectedValues, values);\n return { embeddings, usage };\n };\n}\n","import { LanguageModelV1 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV1 implements LanguageModelV1 {\n readonly specificationVersion = 'v1';\n\n readonly provider: LanguageModelV1['provider'];\n readonly modelId: LanguageModelV1['modelId'];\n\n supportsUrl: LanguageModelV1['supportsUrl'];\n doGenerate: LanguageModelV1['doGenerate'];\n doStream: LanguageModelV1['doStream'];\n\n readonly defaultObjectGenerationMode: LanguageModelV1['defaultObjectGenerationMode'];\n readonly supportsStructuredOutputs: LanguageModelV1['supportsStructuredOutputs'];\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportsUrl = undefined,\n doGenerate = notImplemented,\n doStream = notImplemented,\n defaultObjectGenerationMode = undefined,\n supportsStructuredOutputs = undefined,\n }: {\n provider?: LanguageModelV1['provider'];\n modelId?: LanguageModelV1['modelId'];\n supportsUrl?: LanguageModelV1['supportsUrl'];\n doGenerate?: LanguageModelV1['doGenerate'];\n doStream?: LanguageModelV1['doStream'];\n defaultObjectGenerationMode?: LanguageModelV1['defaultObjectGenerationMode'];\n supportsStructuredOutputs?: LanguageModelV1['supportsStructuredOutputs'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n this.supportsUrl = supportsUrl;\n\n this.defaultObjectGenerationMode = defaultObjectGenerationMode;\n this.supportsStructuredOutputs = supportsStructuredOutputs;\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 { 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"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACHA,SAAS,iBAAwB;AACtC,QAAM,IAAI,MAAM,iBAAiB;AACnC;;;ACGO,IAAM,uBAAN,MAAqE;AAAA,EAU1E,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,UAAU;AAAA,EACZ,IAQI,CAAC,GAAG;AAvBR,SAAS,uBAAuB;AAwB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,uBAAuB,sDAAwB;AACpD,SAAK,wBAAwB;AAC7B,SAAK,UAAU;AAAA,EACjB;AACF;;;ACjCO,IAAM,sBAAN,MAAqD;AAAA,EAY1D,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,IACd,aAAa;AAAA,IACb,WAAW;AAAA,IACX,8BAA8B;AAAA,IAC9B,4BAA4B;AAAA,EAC9B,IAQI,CAAC,GAAG;AA3BR,SAAS,uBAAuB;AA4B9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,WAAW;AAChB,SAAK,cAAc;AAEnB,SAAK,8BAA8B;AACnC,SAAK,4BAA4B;AAAA,EACnC;AACF;;;ACzCO,SAAS,cAAiB,QAAsB;AACrD,MAAI,UAAU;AACd,SAAO,MAAG;AAFZ;AAEe,wBAAO,SAAS,MAAhB,YAAqB,OAAO,OAAO,SAAS,CAAC;AAAA;AAC5D;;;ACHA,SAAS,SAAS,qBAAqB;AAWhC,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AAvBtB;AAwBE,QAAM,SAAQ,4CAAW,UAAX,YAAoB;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;;;ALzBO,IAAMA,0BAAyB;","names":["simulateReadableStream"]}
@@ -1,324 +0,0 @@
1
- /**
2
- Typed tool call that is returned by generateText and streamText.
3
- It contains the tool call ID, the tool name, and the tool arguments.
4
- */
5
- interface ToolCall$1<NAME extends string, ARGS> {
6
- /**
7
- ID of the tool call. This ID is used to match the tool call with the tool result.
8
- */
9
- toolCallId: string;
10
- /**
11
- Name of the tool that is being called.
12
- */
13
- toolName: NAME;
14
- /**
15
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
16
- */
17
- args: ARGS;
18
- }
19
-
20
- /**
21
- Typed tool result that is returned by generateText and streamText.
22
- It contains the tool call ID, the tool name, the tool arguments, and the tool result.
23
- */
24
- interface ToolResult<NAME extends string, ARGS, RESULT> {
25
- /**
26
- ID of the tool call. This ID is used to match the tool call with the tool result.
27
- */
28
- toolCallId: string;
29
- /**
30
- Name of the tool that was called.
31
- */
32
- toolName: NAME;
33
- /**
34
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
35
- */
36
- args: ARGS;
37
- /**
38
- Result of the tool call. This is the result of the tool's execution.
39
- */
40
- result: RESULT;
41
- }
42
-
43
- interface FunctionCall {
44
- /**
45
- * The arguments to call the function with, as generated by the model in JSON
46
- * format. Note that the model does not always generate valid JSON, and may
47
- * hallucinate parameters not defined by your function schema. Validate the
48
- * arguments in your code before calling your function.
49
- */
50
- arguments?: string;
51
- /**
52
- * The name of the function to call.
53
- */
54
- name?: string;
55
- }
56
- /**
57
- * The tool calls generated by the model, such as function calls.
58
- */
59
- interface ToolCall {
60
- id: string;
61
- type: string;
62
- function: {
63
- name: string;
64
- arguments: string;
65
- };
66
- }
67
- /**
68
- Tool invocations are either tool calls or tool results. For each assistant tool call,
69
- there is one tool invocation. While the call is in progress, the invocation is a tool call.
70
- Once the call is complete, the invocation is a tool result.
71
- */
72
- type ToolInvocation = ToolCall$1<string, any> | ToolResult<string, any, any>;
73
- /**
74
- * Shared types between the API and UI packages.
75
- */
76
- interface Message {
77
- id: string;
78
- tool_call_id?: string;
79
- createdAt?: Date;
80
- content: string;
81
- /**
82
- @deprecated Use AI SDK RSC instead: https://sdk.vercel.ai/docs/ai-sdk-rsc
83
- */
84
- ui?: string | JSX.Element | JSX.Element[] | null | undefined;
85
- role: 'system' | 'user' | 'assistant' | 'function' | 'data' | 'tool';
86
- /**
87
- *
88
- * If the message has a role of `function`, the `name` field is the name of the function.
89
- * Otherwise, the name field should not be set.
90
- */
91
- name?: string;
92
- /**
93
- * If the assistant role makes a function call, the `function_call` field
94
- * contains the function call name and arguments. Otherwise, the field should
95
- * not be set. (Deprecated and replaced by tool_calls.)
96
- */
97
- function_call?: string | FunctionCall;
98
- data?: JSONValue;
99
- /**
100
- * If the assistant role makes a tool call, the `tool_calls` field contains
101
- * the tool call name and arguments. Otherwise, the field should not be set.
102
- */
103
- tool_calls?: string | ToolCall[];
104
- /**
105
- * Additional message-specific information added on the server via StreamData
106
- */
107
- annotations?: JSONValue[] | undefined;
108
- /**
109
- Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
110
- that the assistant made as part of this message.
111
- */
112
- toolInvocations?: Array<ToolInvocation>;
113
- }
114
- type JSONValue = null | string | number | boolean | {
115
- [x: string]: JSONValue;
116
- } | Array<JSONValue>;
117
-
118
- /**
119
- * A prompt constructor for Anthropic models.
120
- * Does not support `function` messages.
121
- * @see https://docs.anthropic.com/claude/reference/getting-started-with-the-api
122
- */
123
- declare function experimental_buildAnthropicPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
124
- /**
125
- * A prompt constructor for Anthropic V3 models which require Messages API.
126
- * Does not support message with image content
127
- * @see https://docs.anthropic.com/claude/reference/messages_post
128
- */
129
- declare function experimental_buildAnthropicMessages(messages: Pick<Message, 'content' | 'role'>[]): {
130
- role: "function" | "system" | "user" | "assistant" | "data" | "tool";
131
- content: {
132
- type: string;
133
- text: string;
134
- }[];
135
- }[];
136
-
137
- /**
138
- * A prompt constructor for the HuggingFace StarChat Beta model.
139
- * Does not support `function` messages.
140
- * @see https://huggingface.co/HuggingFaceH4/starchat-beta
141
- */
142
- declare function experimental_buildStarChatBetaPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
143
- /**
144
- * A prompt constructor for HuggingFace OpenAssistant models.
145
- * Does not support `function` or `system` messages.
146
- * @see https://huggingface.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5
147
- */
148
- declare function experimental_buildOpenAssistantPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
149
- /**
150
- * A prompt constructor for HuggingFace LLama 2 chat models.
151
- * Does not support `function` messages.
152
- * @see https://huggingface.co/meta-llama/Llama-2-70b-chat-hf and https://huggingface.co/blog/llama2#how-to-prompt-llama-2
153
- */
154
- declare function experimental_buildLlama2Prompt(messages: Pick<Message, 'content' | 'role'>[]): string;
155
-
156
- declare function experimental_buildOpenAIMessages(messages: Message[]): ChatCompletionMessageParam[];
157
- type ChatCompletionMessageParam = ChatCompletionSystemMessageParam | ChatCompletionUserMessageParam | ChatCompletionAssistantMessageParam | ChatCompletionToolMessageParam | ChatCompletionFunctionMessageParam;
158
- interface ChatCompletionSystemMessageParam {
159
- /**
160
- * The contents of the system message.
161
- */
162
- content: string;
163
- /**
164
- * The role of the messages author, in this case `system`.
165
- */
166
- role: 'system';
167
- /**
168
- * An optional name for the participant. Provides the model information to
169
- * differentiate between participants of the same role.
170
- */
171
- name?: string;
172
- }
173
- interface ChatCompletionUserMessageParam {
174
- /**
175
- * The contents of the user message.
176
- */
177
- content: string | Array<ChatCompletionContentPart>;
178
- /**
179
- * The role of the messages author, in this case `user`.
180
- */
181
- role: 'user';
182
- /**
183
- * An optional name for the participant. Provides the model information to
184
- * differentiate between participants of the same role.
185
- */
186
- name?: string;
187
- }
188
- type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage;
189
- interface ChatCompletionContentPartText {
190
- /**
191
- * The text content.
192
- */
193
- text: string;
194
- /**
195
- * The type of the content part.
196
- */
197
- type: 'text';
198
- }
199
- interface ChatCompletionContentPartImage {
200
- image_url: ChatCompletionContentPartImage.ImageURL;
201
- /**
202
- * The type of the content part.
203
- */
204
- type: 'image_url';
205
- }
206
- declare namespace ChatCompletionContentPartImage {
207
- interface ImageURL {
208
- /**
209
- * Either a URL of the image or the base64 encoded image data.
210
- */
211
- url: string;
212
- /**
213
- * Specifies the detail level of the image. Learn more in the
214
- * [Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).
215
- */
216
- detail?: 'auto' | 'low' | 'high';
217
- }
218
- }
219
- interface ChatCompletionAssistantMessageParam {
220
- /**
221
- * The role of the messages author, in this case `assistant`.
222
- */
223
- role: 'assistant';
224
- /**
225
- * The contents of the assistant message. Required unless `tool_calls` or
226
- * `function_call` is specified.
227
- */
228
- content?: string | null;
229
- /**
230
- * @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
231
- * a function that should be called, as generated by the model.
232
- */
233
- function_call?: ChatCompletionAssistantMessageParam.FunctionCall;
234
- /**
235
- * An optional name for the participant. Provides the model information to
236
- * differentiate between participants of the same role.
237
- */
238
- name?: string;
239
- /**
240
- * The tool calls generated by the model, such as function calls.
241
- */
242
- tool_calls?: Array<ChatCompletionMessageToolCall>;
243
- }
244
- declare namespace ChatCompletionAssistantMessageParam {
245
- /**
246
- * @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
247
- * a function that should be called, as generated by the model.
248
- */
249
- interface FunctionCall {
250
- /**
251
- * The arguments to call the function with, as generated by the model in JSON
252
- * format. Note that the model does not always generate valid JSON, and may
253
- * hallucinate parameters not defined by your function schema. Validate the
254
- * arguments in your code before calling your function.
255
- */
256
- arguments: string;
257
- /**
258
- * The name of the function to call.
259
- */
260
- name: string;
261
- }
262
- }
263
- interface ChatCompletionMessageToolCall {
264
- /**
265
- * The ID of the tool call.
266
- */
267
- id: string;
268
- /**
269
- * The function that the model called.
270
- */
271
- function: ChatCompletionMessageToolCall.Function;
272
- /**
273
- * The type of the tool. Currently, only `function` is supported.
274
- */
275
- type: 'function';
276
- }
277
- declare namespace ChatCompletionMessageToolCall {
278
- /**
279
- * The function that the model called.
280
- */
281
- interface Function {
282
- /**
283
- * The arguments to call the function with, as generated by the model in JSON
284
- * format. Note that the model does not always generate valid JSON, and may
285
- * hallucinate parameters not defined by your function schema. Validate the
286
- * arguments in your code before calling your function.
287
- */
288
- arguments: string;
289
- /**
290
- * The name of the function to call.
291
- */
292
- name: string;
293
- }
294
- }
295
- interface ChatCompletionToolMessageParam {
296
- /**
297
- * The contents of the tool message.
298
- */
299
- content: string;
300
- /**
301
- * The role of the messages author, in this case `tool`.
302
- */
303
- role: 'tool';
304
- /**
305
- * Tool call that this message is responding to.
306
- */
307
- tool_call_id: string;
308
- }
309
- interface ChatCompletionFunctionMessageParam {
310
- /**
311
- * The return value from the function call, to return to the model.
312
- */
313
- content: string | null;
314
- /**
315
- * The name of the function to call.
316
- */
317
- name: string;
318
- /**
319
- * The role of the messages author, in this case `function`.
320
- */
321
- role: 'function';
322
- }
323
-
324
- export { ChatCompletionAssistantMessageParam, ChatCompletionContentPart, ChatCompletionContentPartImage, ChatCompletionContentPartText, ChatCompletionFunctionMessageParam, ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionSystemMessageParam, ChatCompletionToolMessageParam, ChatCompletionUserMessageParam, experimental_buildAnthropicMessages, experimental_buildAnthropicPrompt, experimental_buildLlama2Prompt, experimental_buildOpenAIMessages, experimental_buildOpenAssistantPrompt, experimental_buildStarChatBetaPrompt };