@mastra/core 0.9.0 → 0.9.1-alpha.1

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 (94) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.d.cts +4 -2
  3. package/dist/agent/index.d.ts +4 -2
  4. package/dist/agent/index.js +1 -1
  5. package/dist/{base-oP3DoUrm.d.cts → base-CZmT-p10.d.cts} +524 -53
  6. package/dist/{base-Bk5V1doj.d.ts → base-DDoWFpFc.d.ts} +524 -53
  7. package/dist/{chunk-NTHHPNOW.js → chunk-34622N67.js} +1 -1
  8. package/dist/{chunk-ATXF6TIO.cjs → chunk-422BXQRT.cjs} +24 -677
  9. package/dist/{chunk-HARYMLZH.js → chunk-4K4DHXRF.js} +6 -658
  10. package/dist/{chunk-N2ONCUUS.js → chunk-6AHC67YY.js} +132 -12
  11. package/dist/chunk-7AGAXO6B.cjs +588 -0
  12. package/dist/{chunk-GEIPVIW4.js → chunk-BFF2O6RO.js} +1 -1
  13. package/dist/{chunk-RASVJ3TR.js → chunk-BU45BMXY.js} +55 -1
  14. package/dist/{chunk-DIZZQ3E5.cjs → chunk-CEXM6WP5.cjs} +2 -2
  15. package/dist/chunk-HNEE7IF4.js +60 -0
  16. package/dist/{chunk-NZDXKMDP.cjs → chunk-LABUWBKX.cjs} +1 -1
  17. package/dist/chunk-MUNFCOMB.cjs +62 -0
  18. package/dist/{chunk-GJWCFDFN.js → chunk-PS2ZF6MA.js} +1 -1
  19. package/dist/{chunk-M472GIT6.js → chunk-SGGPJWRQ.js} +1 -1
  20. package/dist/{chunk-7CSNWYGJ.cjs → chunk-U5DGGGS2.cjs} +2 -2
  21. package/dist/{chunk-W5IA5OGL.cjs → chunk-V7IE36YV.cjs} +58 -4
  22. package/dist/chunk-VMVXIPGW.js +586 -0
  23. package/dist/{chunk-53P5ZBJE.cjs → chunk-YTTBFAQJ.cjs} +2 -2
  24. package/dist/{chunk-KZWBYRXW.cjs → chunk-YZFNMXY4.cjs} +135 -14
  25. package/dist/di/index.cjs +2 -2
  26. package/dist/di/index.d.cts +1 -52
  27. package/dist/di/index.d.ts +1 -52
  28. package/dist/di/index.js +1 -1
  29. package/dist/eval/index.d.cts +4 -2
  30. package/dist/eval/index.d.ts +4 -2
  31. package/dist/index.cjs +60 -55
  32. package/dist/index.d.cts +5 -3
  33. package/dist/index.d.ts +5 -3
  34. package/dist/index.js +10 -9
  35. package/dist/integration/index.cjs +3 -3
  36. package/dist/integration/index.d.cts +4 -2
  37. package/dist/integration/index.d.ts +4 -2
  38. package/dist/integration/index.js +1 -1
  39. package/dist/llm/index.cjs +8 -0
  40. package/dist/llm/index.d.cts +4 -2
  41. package/dist/llm/index.d.ts +4 -2
  42. package/dist/llm/index.js +1 -1
  43. package/dist/mastra/index.cjs +2 -2
  44. package/dist/mastra/index.d.cts +4 -2
  45. package/dist/mastra/index.d.ts +4 -2
  46. package/dist/mastra/index.js +1 -1
  47. package/dist/memory/index.cjs +7 -3
  48. package/dist/memory/index.d.cts +4 -2
  49. package/dist/memory/index.d.ts +4 -2
  50. package/dist/memory/index.js +1 -1
  51. package/dist/network/index.cjs +4 -4
  52. package/dist/network/index.d.cts +4 -2
  53. package/dist/network/index.d.ts +4 -2
  54. package/dist/network/index.js +2 -2
  55. package/dist/relevance/index.cjs +4 -4
  56. package/dist/relevance/index.d.cts +4 -2
  57. package/dist/relevance/index.d.ts +4 -2
  58. package/dist/relevance/index.js +1 -1
  59. package/dist/runtime-context/index.cjs +7 -68
  60. package/dist/runtime-context/index.js +1 -69
  61. package/dist/server/index.d.cts +4 -2
  62. package/dist/server/index.d.ts +4 -2
  63. package/dist/storage/index.d.cts +4 -2
  64. package/dist/storage/index.d.ts +4 -2
  65. package/dist/storage/libsql/index.cjs +19 -0
  66. package/dist/storage/libsql/index.d.cts +7 -8
  67. package/dist/storage/libsql/index.d.ts +7 -8
  68. package/dist/storage/libsql/index.js +19 -0
  69. package/dist/telemetry/index.d.cts +4 -2
  70. package/dist/telemetry/index.d.ts +4 -2
  71. package/dist/tools/index.cjs +4 -4
  72. package/dist/tools/index.d.cts +4 -2
  73. package/dist/tools/index.d.ts +4 -2
  74. package/dist/tools/index.js +1 -1
  75. package/dist/utils.cjs +14 -14
  76. package/dist/utils.d.cts +6 -4
  77. package/dist/utils.d.ts +6 -4
  78. package/dist/utils.js +1 -1
  79. package/dist/voice/index.d.cts +5 -3
  80. package/dist/voice/index.d.ts +5 -3
  81. package/dist/workflows/index.cjs +22 -26
  82. package/dist/workflows/index.d.cts +5 -3
  83. package/dist/workflows/index.d.ts +5 -3
  84. package/dist/workflows/index.js +1 -1
  85. package/dist/workflows/vNext/index.cjs +1058 -0
  86. package/dist/workflows/vNext/index.d.cts +180 -0
  87. package/dist/workflows/vNext/index.d.ts +180 -0
  88. package/dist/workflows/vNext/index.js +1046 -0
  89. package/package.json +11 -1
  90. package/workflows/vNext.d.ts +1 -0
  91. /package/dist/{chunk-WEYWYKLG.cjs → chunk-27PAET7X.cjs} +0 -0
  92. /package/dist/{chunk-FRQFWZDN.cjs → chunk-HSVOEWAM.cjs} +0 -0
  93. /package/dist/{chunk-ZDWFBE5L.js → chunk-NH5WJNNS.js} +0 -0
  94. /package/dist/{chunk-LANFNMEE.js → chunk-SGTFVHOZ.js} +0 -0
@@ -0,0 +1,60 @@
1
+ import { simulateReadableStream } from 'ai';
2
+ import { MockLanguageModelV1 } from 'ai/test';
3
+
4
+ // src/llm/model/mock.ts
5
+ function createMockModel({
6
+ objectGenerationMode,
7
+ mockText,
8
+ spyGenerate,
9
+ spyStream
10
+ }) {
11
+ const mockModel = new MockLanguageModelV1({
12
+ defaultObjectGenerationMode: objectGenerationMode,
13
+ doGenerate: async (props) => {
14
+ if (spyGenerate) {
15
+ spyGenerate(props);
16
+ }
17
+ if (objectGenerationMode === "json") {
18
+ return {
19
+ rawCall: { rawPrompt: null, rawSettings: {} },
20
+ finishReason: "stop",
21
+ usage: { promptTokens: 10, completionTokens: 20 },
22
+ text: JSON.stringify(mockText)
23
+ };
24
+ }
25
+ return {
26
+ rawCall: { rawPrompt: null, rawSettings: {} },
27
+ finishReason: "stop",
28
+ usage: { promptTokens: 10, completionTokens: 20 },
29
+ text: typeof mockText === "string" ? mockText : JSON.stringify(mockText)
30
+ };
31
+ },
32
+ doStream: async (props) => {
33
+ if (spyStream) {
34
+ spyStream(props);
35
+ }
36
+ const text = typeof mockText === "string" ? mockText : JSON.stringify(mockText);
37
+ const chunks = text.split(" ").map((word) => ({
38
+ type: "text-delta",
39
+ textDelta: word + " "
40
+ }));
41
+ return {
42
+ stream: simulateReadableStream({
43
+ chunks: [
44
+ ...chunks,
45
+ {
46
+ type: "finish",
47
+ finishReason: "stop",
48
+ logprobs: void 0,
49
+ usage: { completionTokens: 10, promptTokens: 3 }
50
+ }
51
+ ]
52
+ }),
53
+ rawCall: { rawPrompt: null, rawSettings: {} }
54
+ };
55
+ }
56
+ });
57
+ return mockModel;
58
+ }
59
+
60
+ export { createMockModel };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- // src/di/index.ts
3
+ // src/runtime-context/index.ts
4
4
  var RuntimeContext = class {
5
5
  registry = /* @__PURE__ */ new Map();
6
6
  constructor(iterable) {
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ var ai = require('ai');
4
+ var test = require('ai/test');
5
+
6
+ // src/llm/model/mock.ts
7
+ function createMockModel({
8
+ objectGenerationMode,
9
+ mockText,
10
+ spyGenerate,
11
+ spyStream
12
+ }) {
13
+ const mockModel = new test.MockLanguageModelV1({
14
+ defaultObjectGenerationMode: objectGenerationMode,
15
+ doGenerate: async (props) => {
16
+ if (spyGenerate) {
17
+ spyGenerate(props);
18
+ }
19
+ if (objectGenerationMode === "json") {
20
+ return {
21
+ rawCall: { rawPrompt: null, rawSettings: {} },
22
+ finishReason: "stop",
23
+ usage: { promptTokens: 10, completionTokens: 20 },
24
+ text: JSON.stringify(mockText)
25
+ };
26
+ }
27
+ return {
28
+ rawCall: { rawPrompt: null, rawSettings: {} },
29
+ finishReason: "stop",
30
+ usage: { promptTokens: 10, completionTokens: 20 },
31
+ text: typeof mockText === "string" ? mockText : JSON.stringify(mockText)
32
+ };
33
+ },
34
+ doStream: async (props) => {
35
+ if (spyStream) {
36
+ spyStream(props);
37
+ }
38
+ const text = typeof mockText === "string" ? mockText : JSON.stringify(mockText);
39
+ const chunks = text.split(" ").map((word) => ({
40
+ type: "text-delta",
41
+ textDelta: word + " "
42
+ }));
43
+ return {
44
+ stream: ai.simulateReadableStream({
45
+ chunks: [
46
+ ...chunks,
47
+ {
48
+ type: "finish",
49
+ finishReason: "stop",
50
+ logprobs: void 0,
51
+ usage: { completionTokens: 10, promptTokens: 3 }
52
+ }
53
+ ]
54
+ }),
55
+ rawCall: { rawPrompt: null, rawSettings: {} }
56
+ };
57
+ }
58
+ });
59
+ return mockModel;
60
+ }
61
+
62
+ exports.createMockModel = createMockModel;
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-HARYMLZH.js';
1
+ import { Agent } from './chunk-4K4DHXRF.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -1,4 +1,4 @@
1
- // src/di/index.ts
1
+ // src/runtime-context/index.ts
2
2
  var RuntimeContext = class {
3
3
  registry = /* @__PURE__ */ new Map();
4
4
  constructor(iterable) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk53P5ZBJE_cjs = require('./chunk-53P5ZBJE.cjs');
3
+ var chunkYTTBFAQJ_cjs = require('./chunk-YTTBFAQJ.cjs');
4
4
  var zod = require('zod');
5
5
 
6
6
  // src/integration/integration.ts
@@ -68,7 +68,7 @@ var OpenAPIToolset = class {
68
68
  const tools = Object.keys(clientMethods).reduce((acc, key) => {
69
69
  const comment = documentations[key]?.comment;
70
70
  const fallbackComment = `Execute ${key}`;
71
- const tool = chunk53P5ZBJE_cjs.createTool({
71
+ const tool = chunkYTTBFAQJ_cjs.createTool({
72
72
  id: key,
73
73
  inputSchema: schemas[key] || zod.z.object({}),
74
74
  description: comment || fallbackComment,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkWEYWYKLG_cjs = require('./chunk-WEYWYKLG.cjs');
3
+ var chunk27PAET7X_cjs = require('./chunk-27PAET7X.cjs');
4
4
  var chunkRIBNDTA6_cjs = require('./chunk-RIBNDTA6.cjs');
5
5
  var chunkO7IW545H_cjs = require('./chunk-O7IW545H.cjs');
6
6
  var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
@@ -16,6 +16,7 @@ exports.Mastra = class Mastra {
16
16
  #agents;
17
17
  #logger;
18
18
  #workflows;
19
+ #vnext_workflows;
19
20
  #tts;
20
21
  #deployer;
21
22
  #serverMiddleware = [];
@@ -66,13 +67,13 @@ exports.Mastra = class Mastra {
66
67
  this.#logger = logger;
67
68
  let storage = config?.storage;
68
69
  if (!storage) {
69
- storage = new chunkWEYWYKLG_cjs.DefaultProxyStorage({
70
+ storage = new chunk27PAET7X_cjs.DefaultProxyStorage({
70
71
  config: {
71
72
  url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
72
73
  }
73
74
  });
74
75
  }
75
- storage = chunkWEYWYKLG_cjs.augmentWithInit(storage);
76
+ storage = chunk27PAET7X_cjs.augmentWithInit(storage);
76
77
  this.#telemetry = chunkRIBNDTA6_cjs.Telemetry.init(config?.telemetry);
77
78
  if (this.#telemetry) {
78
79
  this.#storage = this.#telemetry.traceClass(storage, {
@@ -183,6 +184,22 @@ This is a warning for now, but will throw an error in the future
183
184
  }
184
185
  });
185
186
  }
187
+ this.#vnext_workflows = {};
188
+ if (config?.vnext_workflows) {
189
+ Object.entries(config.vnext_workflows).forEach(([key, workflow]) => {
190
+ workflow.__registerMastra(this);
191
+ workflow.__registerPrimitives({
192
+ logger: this.getLogger(),
193
+ telemetry: this.#telemetry,
194
+ storage: this.storage,
195
+ memory: this.memory,
196
+ agents,
197
+ tts: this.#tts,
198
+ vectors: this.#vectors
199
+ });
200
+ this.#vnext_workflows[key] = workflow;
201
+ });
202
+ }
186
203
  if (config?.server) {
187
204
  this.#server = config.server;
188
205
  }
@@ -227,6 +244,20 @@ This is a warning for now, but will throw an error in the future
227
244
  }
228
245
  return workflow;
229
246
  }
247
+ vnext_getWorkflow(id, {
248
+ serialized
249
+ } = {}) {
250
+ const workflow = this.#vnext_workflows?.[id];
251
+ if (!workflow) {
252
+ throw new Error(`Workflow with ID ${String(id)} not found`);
253
+ }
254
+ if (serialized) {
255
+ return {
256
+ name: workflow.name
257
+ };
258
+ }
259
+ return workflow;
260
+ }
230
261
  getWorkflows(props = {}) {
231
262
  if (props.serialized) {
232
263
  return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
@@ -240,8 +271,31 @@ This is a warning for now, but will throw an error in the future
240
271
  }
241
272
  return this.#workflows;
242
273
  }
274
+ vnext_getWorkflows(props = {}) {
275
+ if (props.serialized) {
276
+ return Object.entries(this.#vnext_workflows).reduce((acc, [k, v]) => {
277
+ return {
278
+ ...acc,
279
+ [k]: {
280
+ name: v.name
281
+ }
282
+ };
283
+ }, {});
284
+ }
285
+ return this.#vnext_workflows;
286
+ }
243
287
  setStorage(storage) {
244
- this.#storage = chunkWEYWYKLG_cjs.augmentWithInit(storage);
288
+ if (storage instanceof chunk27PAET7X_cjs.DefaultProxyStorage) {
289
+ this.#logger.warn(`Importing "DefaultStorage" from '@mastra/core/storage/libsql' is deprecated.
290
+
291
+ Instead of:
292
+ import { DefaultStorage } from '@mastra/core/storage/libsql';
293
+
294
+ Do:
295
+ import { LibSQLStore } from '@mastra/libsql';
296
+ `);
297
+ }
298
+ this.#storage = chunk27PAET7X_cjs.augmentWithInit(storage);
245
299
  }
246
300
  setLogger({
247
301
  logger