@mastra/core 0.9.4 → 0.10.0-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 (168) hide show
  1. package/README.md +3 -2
  2. package/dist/agent/index.cjs +2 -2
  3. package/dist/agent/index.d.cts +13 -14
  4. package/dist/agent/index.d.ts +13 -14
  5. package/dist/agent/index.js +1 -1
  6. package/dist/{base-BCfssGt6.d.ts → base-DttB7sJD.d.ts} +1187 -886
  7. package/dist/{base-CAEcd6q2.d.cts → base-aJ3etsh5.d.cts} +1187 -886
  8. package/dist/{base-H7siSAfu.d.cts → base-aPYtPBT2.d.cts} +3 -3
  9. package/dist/{base-4Z34GQL8.d.ts → base-tc5kgDTD.d.ts} +3 -3
  10. package/dist/base.cjs +2 -2
  11. package/dist/base.d.cts +2 -3
  12. package/dist/base.d.ts +2 -3
  13. package/dist/base.js +1 -1
  14. package/dist/bundler/index.cjs +2 -2
  15. package/dist/bundler/index.d.cts +2 -3
  16. package/dist/bundler/index.d.ts +2 -3
  17. package/dist/bundler/index.js +1 -1
  18. package/dist/{chunk-W4BSLENO.js → chunk-2NTUAUGH.js} +1 -1
  19. package/dist/{chunk-S34QVMKE.js → chunk-2PW6UJMW.js} +77 -10
  20. package/dist/{chunk-WE36CRQV.cjs → chunk-2U7ZZUFO.cjs} +2 -2
  21. package/dist/{workflows/vNext/index.js → chunk-3SQ3G2EJ.js} +19 -16
  22. package/dist/chunk-5HULBQ2W.cjs +38 -0
  23. package/dist/{chunk-XRGDVLM4.cjs → chunk-5JRD3NDP.cjs} +15 -15
  24. package/dist/{chunk-GXKODTLA.cjs → chunk-5W2G7S44.cjs} +83 -68
  25. package/dist/chunk-75Z4BZEE.js +36 -0
  26. package/dist/{chunk-66GQROSI.cjs → chunk-AOGUTJUO.cjs} +58 -51
  27. package/dist/{chunk-WIKOYZ63.js → chunk-BPTSLJHA.js} +9 -9
  28. package/dist/{chunk-JBJ7KXN5.js → chunk-C3ICEF6E.js} +1 -1
  29. package/dist/{chunk-E4FAXBUV.cjs → chunk-CWSFP2HS.cjs} +2 -2
  30. package/dist/{chunk-FW5RS6WV.js → chunk-E7CLY6SK.js} +42 -35
  31. package/dist/{chunk-235X76GC.js → chunk-FI7R232B.js} +2 -2
  32. package/dist/chunk-GQ2XQ4UN.js +321 -0
  33. package/dist/{chunk-H4CEZSRM.js → chunk-J7GDGV6F.js} +1 -1
  34. package/dist/{chunk-NLBJOFNG.js → chunk-JW5TMK2L.js} +1 -1
  35. package/dist/{chunk-NOPY74PV.js → chunk-KJQFFEEQ.js} +1 -1
  36. package/dist/{chunk-V2Q2FEVO.cjs → chunk-KSPHQSZX.cjs} +2 -2
  37. package/dist/{chunk-NZV4OA6P.js → chunk-LHRZV5VG.js} +2 -23
  38. package/dist/chunk-NMDM4IZN.cjs +78 -0
  39. package/dist/chunk-OBEALYTK.js +74 -0
  40. package/dist/{chunk-PEK4TY3P.js → chunk-OCT2762Q.js} +1 -1
  41. package/dist/{chunk-5DUFC7TV.cjs → chunk-P7BGXOQV.cjs} +2 -2
  42. package/dist/{chunk-WQKOM7XM.cjs → chunk-PIZM25KI.cjs} +3 -24
  43. package/dist/{chunk-S7J63JOG.cjs → chunk-RVS6OUJN.cjs} +2 -2
  44. package/dist/{chunk-5JUWUTPJ.cjs → chunk-SKG2NIZW.cjs} +2 -2
  45. package/dist/chunk-SWW4EBUZ.cjs +96 -0
  46. package/dist/{chunk-RGE4UF6A.cjs → chunk-TMPFLJLG.cjs} +2 -2
  47. package/dist/{workflows/vNext/index.cjs → chunk-TTKQ37ZZ.cjs} +24 -21
  48. package/dist/{chunk-EJITEVAB.cjs → chunk-U3L3NEOM.cjs} +81 -10
  49. package/dist/chunk-VHLL4AZK.js +90 -0
  50. package/dist/{chunk-EG74VBSP.cjs → chunk-YEULQPUY.cjs} +6 -6
  51. package/dist/{chunk-SOLXHDNQ.js → chunk-ZB3LEHL2.js} +81 -66
  52. package/dist/{chunk-TAFOICHR.js → chunk-ZKN6HYYQ.js} +1 -1
  53. package/dist/chunk-ZZDAC5KD.cjs +325 -0
  54. package/dist/deployer/index.cjs +2 -2
  55. package/dist/deployer/index.d.cts +2 -3
  56. package/dist/deployer/index.d.ts +2 -3
  57. package/dist/deployer/index.js +1 -1
  58. package/dist/eval/index.d.cts +13 -14
  59. package/dist/eval/index.d.ts +13 -14
  60. package/dist/hooks/index.d.cts +1 -1
  61. package/dist/hooks/index.d.ts +1 -1
  62. package/dist/index.cjs +88 -159
  63. package/dist/index.d.cts +17 -25
  64. package/dist/index.d.ts +17 -25
  65. package/dist/index.js +18 -25
  66. package/dist/integration/index.cjs +3 -3
  67. package/dist/integration/index.d.cts +12 -13
  68. package/dist/integration/index.d.ts +12 -13
  69. package/dist/integration/index.js +1 -1
  70. package/dist/llm/index.d.cts +13 -14
  71. package/dist/llm/index.d.ts +13 -14
  72. package/dist/logger/index.cjs +18 -17
  73. package/dist/logger/index.d.cts +42 -2
  74. package/dist/logger/index.d.ts +42 -2
  75. package/dist/logger/index.js +2 -1
  76. package/dist/{index-QV27jkxQ.d.ts → logger-EhZkzZOr.d.cts} +38 -52
  77. package/dist/{index-QV27jkxQ.d.cts → logger-EhZkzZOr.d.ts} +38 -52
  78. package/dist/mastra/index.cjs +2 -2
  79. package/dist/mastra/index.d.cts +11 -12
  80. package/dist/mastra/index.d.ts +11 -12
  81. package/dist/mastra/index.js +1 -1
  82. package/dist/mcp/index.cjs +75 -17
  83. package/dist/mcp/index.d.cts +14 -15
  84. package/dist/mcp/index.d.ts +14 -15
  85. package/dist/mcp/index.js +69 -15
  86. package/dist/memory/index.cjs +4 -4
  87. package/dist/memory/index.d.cts +12 -13
  88. package/dist/memory/index.d.ts +12 -13
  89. package/dist/memory/index.js +1 -1
  90. package/dist/network/index.cjs +8 -8
  91. package/dist/network/index.d.cts +12 -13
  92. package/dist/network/index.d.ts +12 -13
  93. package/dist/network/index.js +5 -5
  94. package/dist/relevance/index.cjs +4 -4
  95. package/dist/relevance/index.d.cts +15 -16
  96. package/dist/relevance/index.d.ts +15 -16
  97. package/dist/relevance/index.js +1 -1
  98. package/dist/server/index.cjs +4 -0
  99. package/dist/server/index.d.cts +13 -12
  100. package/dist/server/index.d.ts +13 -12
  101. package/dist/server/index.js +4 -1
  102. package/dist/storage/index.cjs +184 -3
  103. package/dist/storage/index.d.cts +83 -13
  104. package/dist/storage/index.d.ts +83 -13
  105. package/dist/storage/index.js +186 -1
  106. package/dist/telemetry/index.d.cts +14 -15
  107. package/dist/telemetry/index.d.ts +14 -15
  108. package/dist/telemetry/otel-vendor.cjs +2 -2
  109. package/dist/telemetry/otel-vendor.d.cts +1 -1
  110. package/dist/telemetry/otel-vendor.d.ts +1 -1
  111. package/dist/telemetry/otel-vendor.js +1 -1
  112. package/dist/tools/index.cjs +4 -4
  113. package/dist/tools/index.d.cts +12 -13
  114. package/dist/tools/index.d.ts +12 -13
  115. package/dist/tools/index.js +1 -1
  116. package/dist/tts/index.cjs +2 -2
  117. package/dist/tts/index.d.cts +2 -3
  118. package/dist/tts/index.d.ts +2 -3
  119. package/dist/tts/index.js +1 -1
  120. package/dist/{types-BtMyV38I.d.ts → types-Bo1uigWx.d.cts} +1 -1
  121. package/dist/{types-BtMyV38I.d.cts → types-Bo1uigWx.d.ts} +1 -1
  122. package/dist/utils.cjs +28 -12
  123. package/dist/utils.d.cts +59 -16
  124. package/dist/utils.d.ts +59 -16
  125. package/dist/utils.js +1 -1
  126. package/dist/vector/filter/index.cjs +189 -7
  127. package/dist/vector/filter/index.js +190 -1
  128. package/dist/vector/index.cjs +2 -2
  129. package/dist/vector/index.d.cts +28 -20
  130. package/dist/vector/index.d.ts +28 -20
  131. package/dist/vector/index.js +1 -1
  132. package/dist/voice/index.cjs +4 -4
  133. package/dist/voice/index.d.cts +12 -13
  134. package/dist/voice/index.d.ts +12 -13
  135. package/dist/voice/index.js +1 -1
  136. package/dist/workflows/index.cjs +17 -69
  137. package/dist/workflows/index.d.cts +197 -77
  138. package/dist/workflows/index.d.ts +197 -77
  139. package/dist/workflows/index.js +1 -1
  140. package/dist/workflows/legacy/index.cjs +90 -0
  141. package/dist/workflows/legacy/index.d.cts +87 -0
  142. package/dist/workflows/legacy/index.d.ts +87 -0
  143. package/dist/workflows/legacy/index.js +1 -0
  144. package/package.json +19 -40
  145. package/workflows/legacy.d.ts +1 -0
  146. package/dist/chunk-4WABQORE.js +0 -781
  147. package/dist/chunk-CIEPFV6B.js +0 -658
  148. package/dist/chunk-CMPPXW4U.js +0 -154
  149. package/dist/chunk-CTKNWYK2.js +0 -131
  150. package/dist/chunk-LGERQTJM.js +0 -190
  151. package/dist/chunk-O44MSFMZ.cjs +0 -168
  152. package/dist/chunk-QDAMIZY3.cjs +0 -783
  153. package/dist/chunk-QHDPLMHB.cjs +0 -667
  154. package/dist/chunk-RAQBTCIR.cjs +0 -134
  155. package/dist/chunk-YK3XJ52U.cjs +0 -192
  156. package/dist/storage/libsql/index.cjs +0 -581
  157. package/dist/storage/libsql/index.d.cts +0 -104
  158. package/dist/storage/libsql/index.d.ts +0 -104
  159. package/dist/storage/libsql/index.js +0 -578
  160. package/dist/vector/libsql/index.cjs +0 -14
  161. package/dist/vector/libsql/index.d.cts +0 -82
  162. package/dist/vector/libsql/index.d.ts +0 -82
  163. package/dist/vector/libsql/index.js +0 -1
  164. package/dist/workflows/vNext/index.d.cts +0 -209
  165. package/dist/workflows/vNext/index.d.ts +0 -209
  166. package/storage/libsql.d.ts +0 -1
  167. package/vector/libsql.d.ts +0 -1
  168. package/workflows/vNext.d.ts +0 -1
@@ -1,28 +1,27 @@
1
- import '../base-H7siSAfu.cjs';
2
- import { b2 as MastraLanguageModel } from '../base-CAEcd6q2.cjs';
3
- import '@opentelemetry/api';
4
- import '../index-QV27jkxQ.cjs';
5
- import 'stream';
6
- import 'pino';
7
- import '@opentelemetry/sdk-trace-base';
1
+ import { be as MastraLanguageModel } from '../base-aJ3etsh5.cjs';
2
+ import '../base-aPYtPBT2.cjs';
8
3
  import 'ai';
9
- import '../types-BtMyV38I.cjs';
4
+ import '../types-Bo1uigWx.cjs';
10
5
  import 'sift';
11
6
  import 'zod';
12
7
  import 'json-schema';
8
+ import '../deployer/index.cjs';
9
+ import '../bundler/index.cjs';
10
+ import '@opentelemetry/api';
11
+ import '../logger-EhZkzZOr.cjs';
12
+ import 'stream';
13
+ import '@opentelemetry/sdk-trace-base';
14
+ import 'node:http';
15
+ import 'hono';
13
16
  import '../runtime-context/index.cjs';
14
- import 'xstate';
15
- import 'node:events';
16
17
  import '../vector/index.cjs';
17
18
  import '../vector/filter/index.cjs';
18
- import '../tts/index.cjs';
19
- import 'node:http';
20
- import 'hono';
21
- import 'events';
22
- import '../deployer/index.cjs';
23
- import '../bundler/index.cjs';
24
19
  import 'hono/cors';
25
20
  import 'hono-openapi';
21
+ import '../tts/index.cjs';
22
+ import 'xstate';
23
+ import 'node:events';
24
+ import 'events';
26
25
  import 'ai/test';
27
26
 
28
27
  interface RelevanceScoreProvider {
@@ -1,28 +1,27 @@
1
- import '../base-4Z34GQL8.js';
2
- import { b2 as MastraLanguageModel } from '../base-BCfssGt6.js';
3
- import '@opentelemetry/api';
4
- import '../index-QV27jkxQ.js';
5
- import 'stream';
6
- import 'pino';
7
- import '@opentelemetry/sdk-trace-base';
1
+ import { be as MastraLanguageModel } from '../base-DttB7sJD.js';
2
+ import '../base-tc5kgDTD.js';
8
3
  import 'ai';
9
- import '../types-BtMyV38I.js';
4
+ import '../types-Bo1uigWx.js';
10
5
  import 'sift';
11
6
  import 'zod';
12
7
  import 'json-schema';
8
+ import '../deployer/index.js';
9
+ import '../bundler/index.js';
10
+ import '@opentelemetry/api';
11
+ import '../logger-EhZkzZOr.js';
12
+ import 'stream';
13
+ import '@opentelemetry/sdk-trace-base';
14
+ import 'node:http';
15
+ import 'hono';
13
16
  import '../runtime-context/index.js';
14
- import 'xstate';
15
- import 'node:events';
16
17
  import '../vector/index.js';
17
18
  import '../vector/filter/index.js';
18
- import '../tts/index.js';
19
- import 'node:http';
20
- import 'hono';
21
- import 'events';
22
- import '../deployer/index.js';
23
- import '../bundler/index.js';
24
19
  import 'hono/cors';
25
20
  import 'hono-openapi';
21
+ import '../tts/index.js';
22
+ import 'xstate';
23
+ import 'node:events';
24
+ import 'events';
26
25
  import 'ai/test';
27
26
 
28
27
  interface RelevanceScoreProvider {
@@ -1 +1 @@
1
- export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from '../chunk-H4CEZSRM.js';
1
+ export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt } from '../chunk-J7GDGV6F.js';
@@ -14,5 +14,9 @@ function registerApiRoute(path, options) {
14
14
  middleware: options.middleware
15
15
  };
16
16
  }
17
+ function defineAuth(config) {
18
+ return config;
19
+ }
17
20
 
21
+ exports.defineAuth = defineAuth;
18
22
  exports.registerApiRoute = registerApiRoute;
@@ -1,28 +1,28 @@
1
1
  import { Handler, Context, MiddlewareHandler } from 'hono';
2
2
  import { DescribeRouteOptions } from 'hono-openapi';
3
- import { M as Methods, a as Mastra, A as ApiRoute } from '../base-CAEcd6q2.cjs';
3
+ import { M as Methods, a as Mastra, A as ApiRoute, b as MastraAuthConfig } from '../base-aJ3etsh5.cjs';
4
+ export { C as ContextWithMastra } from '../base-aJ3etsh5.cjs';
4
5
  import 'ai';
5
- import '../base-H7siSAfu.cjs';
6
+ import '../base-aPYtPBT2.cjs';
6
7
  import '@opentelemetry/api';
7
- import '../index-QV27jkxQ.cjs';
8
+ import '../logger-EhZkzZOr.cjs';
8
9
  import 'stream';
9
- import 'pino';
10
10
  import '@opentelemetry/sdk-trace-base';
11
- import '../types-BtMyV38I.cjs';
11
+ import '../types-Bo1uigWx.cjs';
12
12
  import 'sift';
13
13
  import 'zod';
14
14
  import 'json-schema';
15
+ import '../deployer/index.cjs';
16
+ import '../bundler/index.cjs';
17
+ import 'node:http';
15
18
  import '../runtime-context/index.cjs';
16
- import 'xstate';
17
- import 'node:events';
18
19
  import '../vector/index.cjs';
19
20
  import '../vector/filter/index.cjs';
21
+ import 'hono/cors';
20
22
  import '../tts/index.cjs';
21
- import 'node:http';
23
+ import 'xstate';
24
+ import 'node:events';
22
25
  import 'events';
23
- import '../deployer/index.cjs';
24
- import '../bundler/index.cjs';
25
- import 'hono/cors';
26
26
  import 'ai/test';
27
27
 
28
28
  type ParamsFromPath<P extends string> = {
@@ -43,5 +43,6 @@ declare function registerApiRoute<P extends string>(path: P, options: P extends
43
43
  }, P, ParamsFromPath<P>>>;
44
44
  middleware?: MiddlewareHandler | MiddlewareHandler[];
45
45
  }): P extends `/api/${string}` ? never : ApiRoute;
46
+ declare function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser>;
46
47
 
47
- export { registerApiRoute };
48
+ export { MastraAuthConfig, defineAuth, registerApiRoute };
@@ -1,28 +1,28 @@
1
1
  import { Handler, Context, MiddlewareHandler } from 'hono';
2
2
  import { DescribeRouteOptions } from 'hono-openapi';
3
- import { M as Methods, a as Mastra, A as ApiRoute } from '../base-BCfssGt6.js';
3
+ import { M as Methods, a as Mastra, A as ApiRoute, b as MastraAuthConfig } from '../base-DttB7sJD.js';
4
+ export { C as ContextWithMastra } from '../base-DttB7sJD.js';
4
5
  import 'ai';
5
- import '../base-4Z34GQL8.js';
6
+ import '../base-tc5kgDTD.js';
6
7
  import '@opentelemetry/api';
7
- import '../index-QV27jkxQ.js';
8
+ import '../logger-EhZkzZOr.js';
8
9
  import 'stream';
9
- import 'pino';
10
10
  import '@opentelemetry/sdk-trace-base';
11
- import '../types-BtMyV38I.js';
11
+ import '../types-Bo1uigWx.js';
12
12
  import 'sift';
13
13
  import 'zod';
14
14
  import 'json-schema';
15
+ import '../deployer/index.js';
16
+ import '../bundler/index.js';
17
+ import 'node:http';
15
18
  import '../runtime-context/index.js';
16
- import 'xstate';
17
- import 'node:events';
18
19
  import '../vector/index.js';
19
20
  import '../vector/filter/index.js';
21
+ import 'hono/cors';
20
22
  import '../tts/index.js';
21
- import 'node:http';
23
+ import 'xstate';
24
+ import 'node:events';
22
25
  import 'events';
23
- import '../deployer/index.js';
24
- import '../bundler/index.js';
25
- import 'hono/cors';
26
26
  import 'ai/test';
27
27
 
28
28
  type ParamsFromPath<P extends string> = {
@@ -43,5 +43,6 @@ declare function registerApiRoute<P extends string>(path: P, options: P extends
43
43
  }, P, ParamsFromPath<P>>>;
44
44
  middleware?: MiddlewareHandler | MiddlewareHandler[];
45
45
  }): P extends `/api/${string}` ? never : ApiRoute;
46
+ declare function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser>;
46
47
 
47
- export { registerApiRoute };
48
+ export { MastraAuthConfig, defineAuth, registerApiRoute };
@@ -12,5 +12,8 @@ function registerApiRoute(path, options) {
12
12
  middleware: options.middleware
13
13
  };
14
14
  }
15
+ function defineAuth(config) {
16
+ return config;
17
+ }
15
18
 
16
- export { registerApiRoute };
19
+ export { defineAuth, registerApiRoute };
@@ -1,13 +1,193 @@
1
1
  'use strict';
2
2
 
3
- var chunk5DUFC7TV_cjs = require('../chunk-5DUFC7TV.cjs');
3
+ var chunkP7BGXOQV_cjs = require('../chunk-P7BGXOQV.cjs');
4
4
  var chunk6KB5CPBV_cjs = require('../chunk-6KB5CPBV.cjs');
5
5
 
6
-
6
+ // src/storage/mock.ts
7
+ var MockStore = class extends chunkP7BGXOQV_cjs.MastraStorage {
8
+ data = {
9
+ mastra_workflow_snapshot: {},
10
+ mastra_evals: {},
11
+ mastra_messages: {},
12
+ mastra_threads: {},
13
+ mastra_traces: {}
14
+ };
15
+ constructor() {
16
+ super({ name: "MockStore" });
17
+ this.hasInitialized = Promise.resolve(true);
18
+ }
19
+ async createTable({ tableName }) {
20
+ this.logger.debug(`MockStore: createTable called for ${tableName}`);
21
+ }
22
+ async clearTable({ tableName }) {
23
+ this.logger.debug(`MockStore: clearTable called for ${tableName}`);
24
+ this.data[tableName] = {};
25
+ }
26
+ async insert({ tableName, record }) {
27
+ this.logger.debug(`MockStore: insert called for ${tableName}`, record);
28
+ this.data[tableName][record.run_id] = JSON.parse(JSON.stringify(record));
29
+ }
30
+ async batchInsert({ tableName, records }) {
31
+ this.logger.debug(`MockStore: batchInsert called for ${tableName} with ${records.length} records`);
32
+ for (const record of records) {
33
+ this.data[tableName][record.run_id] = JSON.parse(JSON.stringify(record));
34
+ }
35
+ }
36
+ async load({ tableName, keys }) {
37
+ this.logger.debug(`MockStore: load called for ${tableName} with keys`, keys);
38
+ const record = this.data[tableName][keys.run_id];
39
+ return record ? record : null;
40
+ }
41
+ async getThreadById({ threadId }) {
42
+ this.logger.debug(`MockStore: getThreadById called for ${threadId}`);
43
+ const thread = Object.values(this.data.mastra_threads).find((t) => t.id === threadId);
44
+ return thread ? thread : null;
45
+ }
46
+ async getThreadsByResourceId({ resourceId }) {
47
+ this.logger.debug(`MockStore: getThreadsByResourceId called for ${resourceId}`);
48
+ const threads = Object.values(this.data.mastra_threads).filter((t) => t.resourceId === resourceId);
49
+ return threads;
50
+ }
51
+ async saveThread({ thread }) {
52
+ this.logger.debug(`MockStore: saveThread called for ${thread.id}`);
53
+ const key = thread.id;
54
+ this.data.mastra_threads[key] = thread;
55
+ return thread;
56
+ }
57
+ async updateThread({
58
+ id,
59
+ title,
60
+ metadata
61
+ }) {
62
+ this.logger.debug(`MockStore: updateThread called for ${id}`);
63
+ const thread = this.data.mastra_threads[id];
64
+ if (thread) {
65
+ thread.title = title;
66
+ thread.metadata = { ...thread.metadata, ...metadata };
67
+ thread.updatedAt = /* @__PURE__ */ new Date();
68
+ }
69
+ return thread;
70
+ }
71
+ async deleteThread({ threadId }) {
72
+ this.logger.debug(`MockStore: deleteThread called for ${threadId}`);
73
+ delete this.data.mastra_threads[threadId];
74
+ this.data.mastra_messages = Object.fromEntries(
75
+ Object.entries(this.data.mastra_messages).filter(([, msg]) => msg.threadId !== threadId)
76
+ );
77
+ }
78
+ async getMessages({ threadId, selectBy }) {
79
+ this.logger.debug(`MockStore: getMessages called for thread ${threadId}`);
80
+ let messages = Object.values(this.data.mastra_messages).filter((msg) => msg.threadId === threadId);
81
+ if (selectBy?.last) {
82
+ messages = messages.slice(-selectBy.last);
83
+ }
84
+ messages.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
85
+ return messages;
86
+ }
87
+ async saveMessages({ messages }) {
88
+ this.logger.debug(`MockStore: saveMessages called with ${messages.length} messages`);
89
+ for (const message of messages) {
90
+ const key = message.id;
91
+ this.data.mastra_messages[key] = message;
92
+ }
93
+ return messages;
94
+ }
95
+ async getTraces({
96
+ name,
97
+ scope,
98
+ page,
99
+ perPage,
100
+ attributes,
101
+ filters,
102
+ fromDate,
103
+ toDate
104
+ }) {
105
+ this.logger.debug(`MockStore: getTraces called`);
106
+ let traces = Object.values(this.data.mastra_traces);
107
+ if (name) traces = traces.filter((t) => t.name?.startsWith(name));
108
+ if (scope) traces = traces.filter((t) => t.scope === scope);
109
+ if (attributes) {
110
+ traces = traces.filter(
111
+ (t) => Object.entries(attributes).every(([key, value]) => t.attributes?.[key] === value)
112
+ );
113
+ }
114
+ if (filters) {
115
+ traces = traces.filter((t) => Object.entries(filters).every(([key, value]) => t[key] === value));
116
+ }
117
+ if (fromDate) traces = traces.filter((t) => new Date(t.createdAt) >= fromDate);
118
+ if (toDate) traces = traces.filter((t) => new Date(t.createdAt) <= toDate);
119
+ traces.sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime());
120
+ const start = page * perPage;
121
+ const end = start + perPage;
122
+ return traces.slice(start, end);
123
+ }
124
+ async getEvalsByAgentName(agentName, type) {
125
+ this.logger.debug(`MockStore: getEvalsByAgentName called for ${agentName}`);
126
+ let evals = Object.values(this.data.mastra_evals).filter((e) => e.agentName === agentName);
127
+ if (type === "test") {
128
+ evals = evals.filter((e) => e.testInfo && e.testInfo.testPath);
129
+ } else if (type === "live") {
130
+ evals = evals.filter((e) => !e.testInfo || !e.testInfo.testPath);
131
+ }
132
+ evals.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
133
+ return evals;
134
+ }
135
+ async getWorkflowRuns({
136
+ workflowName,
137
+ fromDate,
138
+ toDate,
139
+ limit,
140
+ offset,
141
+ resourceId
142
+ } = {}) {
143
+ this.logger.debug(`MockStore: getWorkflowRuns called`);
144
+ let runs = Object.values(this.data.mastra_workflow_snapshot || {});
145
+ if (workflowName) runs = runs.filter((run) => run.workflow_name === workflowName);
146
+ if (fromDate) runs = runs.filter((run) => new Date(run.createdAt) >= fromDate);
147
+ if (toDate) runs = runs.filter((run) => new Date(run.createdAt) <= toDate);
148
+ if (resourceId) runs = runs.filter((run) => run.resourceId === resourceId);
149
+ const total = runs.length;
150
+ runs.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
151
+ if (limit !== void 0 && offset !== void 0) {
152
+ const start = offset;
153
+ const end = start + limit;
154
+ runs = runs.slice(start, end);
155
+ }
156
+ const parsedRuns = runs.map((run) => ({
157
+ ...run,
158
+ snapshot: typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : { ...run.snapshot },
159
+ createdAt: new Date(run.createdAt),
160
+ updatedAt: new Date(run.updatedAt),
161
+ runId: run.run_id,
162
+ workflowName: run.workflow_name
163
+ }));
164
+ return { runs: parsedRuns, total };
165
+ }
166
+ async getWorkflowRunById({
167
+ runId,
168
+ workflowName
169
+ }) {
170
+ this.logger.debug(`MockStore: getWorkflowRunById called for runId ${runId}`);
171
+ let run = Object.values(this.data.mastra_workflow_snapshot || {}).find((r) => r.run_id === runId);
172
+ if (run && workflowName && run.workflow_name !== workflowName) {
173
+ run = void 0;
174
+ }
175
+ if (!run) return null;
176
+ const parsedRun = {
177
+ ...run,
178
+ snapshot: typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot,
179
+ createdAt: new Date(run.createdAt),
180
+ updatedAt: new Date(run.updatedAt),
181
+ runId: run.run_id,
182
+ workflowName: run.workflow_name
183
+ };
184
+ return parsedRun;
185
+ }
186
+ };
7
187
 
8
188
  Object.defineProperty(exports, "MastraStorage", {
9
189
  enumerable: true,
10
- get: function () { return chunk5DUFC7TV_cjs.MastraStorage; }
190
+ get: function () { return chunkP7BGXOQV_cjs.MastraStorage; }
11
191
  });
12
192
  Object.defineProperty(exports, "TABLE_EVALS", {
13
193
  enumerable: true,
@@ -33,3 +213,4 @@ Object.defineProperty(exports, "TABLE_WORKFLOW_SNAPSHOT", {
33
213
  enumerable: true,
34
214
  get: function () { return chunk6KB5CPBV_cjs.TABLE_WORKFLOW_SNAPSHOT; }
35
215
  });
216
+ exports.MockStore = MockStore;
@@ -1,26 +1,96 @@
1
- export { E as EvalRow, b as MastraStorage, S as StorageColumn, e as StorageGetMessagesArg, bo as TABLE_EVALS, bp as TABLE_MESSAGES, T as TABLE_NAMES, bs as TABLE_SCHEMAS, bq as TABLE_THREADS, br as TABLE_TRACES, bn as TABLE_WORKFLOW_SNAPSHOT, f as WorkflowRun, W as WorkflowRuns } from '../base-CAEcd6q2.cjs';
1
+ import { c as MastraStorage, T as TABLE_NAMES, S as StorageColumn, d as StorageThreadType, e as MessageType, f as StorageGetMessagesArg, E as EvalRow, W as WorkflowRuns, g as WorkflowRun } from '../base-aJ3etsh5.cjs';
2
+ export { h as LegacyWorkflowRun, L as LegacyWorkflowRuns, j as TABLE_EVALS, k as TABLE_MESSAGES, n as TABLE_SCHEMAS, l as TABLE_THREADS, m as TABLE_TRACES, i as TABLE_WORKFLOW_SNAPSHOT } from '../base-aJ3etsh5.cjs';
2
3
  import 'ai';
3
- import '../base-H7siSAfu.cjs';
4
+ import '../base-aPYtPBT2.cjs';
4
5
  import '@opentelemetry/api';
5
- import '../index-QV27jkxQ.cjs';
6
+ import '../logger-EhZkzZOr.cjs';
6
7
  import 'stream';
7
- import 'pino';
8
8
  import '@opentelemetry/sdk-trace-base';
9
- import '../types-BtMyV38I.cjs';
9
+ import '../types-Bo1uigWx.cjs';
10
10
  import 'sift';
11
11
  import 'zod';
12
12
  import 'json-schema';
13
+ import '../deployer/index.cjs';
14
+ import '../bundler/index.cjs';
15
+ import 'node:http';
16
+ import 'hono';
13
17
  import '../runtime-context/index.cjs';
14
- import 'xstate';
15
- import 'node:events';
16
18
  import '../vector/index.cjs';
17
19
  import '../vector/filter/index.cjs';
18
- import '../tts/index.cjs';
19
- import 'node:http';
20
- import 'hono';
21
- import 'events';
22
- import '../deployer/index.cjs';
23
- import '../bundler/index.cjs';
24
20
  import 'hono/cors';
25
21
  import 'hono-openapi';
22
+ import '../tts/index.cjs';
23
+ import 'xstate';
24
+ import 'node:events';
25
+ import 'events';
26
26
  import 'ai/test';
27
+
28
+ declare class MockStore extends MastraStorage {
29
+ private data;
30
+ constructor();
31
+ createTable({ tableName }: {
32
+ tableName: TABLE_NAMES;
33
+ schema: Record<string, StorageColumn>;
34
+ }): Promise<void>;
35
+ clearTable({ tableName }: {
36
+ tableName: TABLE_NAMES;
37
+ }): Promise<void>;
38
+ insert({ tableName, record }: {
39
+ tableName: TABLE_NAMES;
40
+ record: Record<string, any>;
41
+ }): Promise<void>;
42
+ batchInsert({ tableName, records }: {
43
+ tableName: TABLE_NAMES;
44
+ records: Record<string, any>[];
45
+ }): Promise<void>;
46
+ load<R>({ tableName, keys }: {
47
+ tableName: TABLE_NAMES;
48
+ keys: Record<string, string>;
49
+ }): Promise<R | null>;
50
+ getThreadById({ threadId }: {
51
+ threadId: string;
52
+ }): Promise<StorageThreadType | null>;
53
+ getThreadsByResourceId({ resourceId }: {
54
+ resourceId: string;
55
+ }): Promise<StorageThreadType[]>;
56
+ saveThread({ thread }: {
57
+ thread: StorageThreadType;
58
+ }): Promise<StorageThreadType>;
59
+ updateThread({ id, title, metadata, }: {
60
+ id: string;
61
+ title: string;
62
+ metadata: Record<string, unknown>;
63
+ }): Promise<StorageThreadType>;
64
+ deleteThread({ threadId }: {
65
+ threadId: string;
66
+ }): Promise<void>;
67
+ getMessages<T extends MessageType[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
68
+ saveMessages({ messages }: {
69
+ messages: MessageType[];
70
+ }): Promise<MessageType[]>;
71
+ getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: {
72
+ name?: string;
73
+ scope?: string;
74
+ page: number;
75
+ perPage: number;
76
+ attributes?: Record<string, string>;
77
+ filters?: Record<string, any>;
78
+ fromDate?: Date;
79
+ toDate?: Date;
80
+ }): Promise<any[]>;
81
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
82
+ getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
83
+ workflowName?: string;
84
+ fromDate?: Date;
85
+ toDate?: Date;
86
+ limit?: number;
87
+ offset?: number;
88
+ resourceId?: string;
89
+ }): Promise<WorkflowRuns>;
90
+ getWorkflowRunById({ runId, workflowName, }: {
91
+ runId: string;
92
+ workflowName?: string;
93
+ }): Promise<WorkflowRun | null>;
94
+ }
95
+
96
+ export { EvalRow, MastraStorage, MockStore, StorageColumn, StorageGetMessagesArg, TABLE_NAMES, WorkflowRun, WorkflowRuns };
@@ -1,26 +1,96 @@
1
- export { E as EvalRow, b as MastraStorage, S as StorageColumn, e as StorageGetMessagesArg, bo as TABLE_EVALS, bp as TABLE_MESSAGES, T as TABLE_NAMES, bs as TABLE_SCHEMAS, bq as TABLE_THREADS, br as TABLE_TRACES, bn as TABLE_WORKFLOW_SNAPSHOT, f as WorkflowRun, W as WorkflowRuns } from '../base-BCfssGt6.js';
1
+ import { c as MastraStorage, T as TABLE_NAMES, S as StorageColumn, d as StorageThreadType, e as MessageType, f as StorageGetMessagesArg, E as EvalRow, W as WorkflowRuns, g as WorkflowRun } from '../base-DttB7sJD.js';
2
+ export { h as LegacyWorkflowRun, L as LegacyWorkflowRuns, j as TABLE_EVALS, k as TABLE_MESSAGES, n as TABLE_SCHEMAS, l as TABLE_THREADS, m as TABLE_TRACES, i as TABLE_WORKFLOW_SNAPSHOT } from '../base-DttB7sJD.js';
2
3
  import 'ai';
3
- import '../base-4Z34GQL8.js';
4
+ import '../base-tc5kgDTD.js';
4
5
  import '@opentelemetry/api';
5
- import '../index-QV27jkxQ.js';
6
+ import '../logger-EhZkzZOr.js';
6
7
  import 'stream';
7
- import 'pino';
8
8
  import '@opentelemetry/sdk-trace-base';
9
- import '../types-BtMyV38I.js';
9
+ import '../types-Bo1uigWx.js';
10
10
  import 'sift';
11
11
  import 'zod';
12
12
  import 'json-schema';
13
+ import '../deployer/index.js';
14
+ import '../bundler/index.js';
15
+ import 'node:http';
16
+ import 'hono';
13
17
  import '../runtime-context/index.js';
14
- import 'xstate';
15
- import 'node:events';
16
18
  import '../vector/index.js';
17
19
  import '../vector/filter/index.js';
18
- import '../tts/index.js';
19
- import 'node:http';
20
- import 'hono';
21
- import 'events';
22
- import '../deployer/index.js';
23
- import '../bundler/index.js';
24
20
  import 'hono/cors';
25
21
  import 'hono-openapi';
22
+ import '../tts/index.js';
23
+ import 'xstate';
24
+ import 'node:events';
25
+ import 'events';
26
26
  import 'ai/test';
27
+
28
+ declare class MockStore extends MastraStorage {
29
+ private data;
30
+ constructor();
31
+ createTable({ tableName }: {
32
+ tableName: TABLE_NAMES;
33
+ schema: Record<string, StorageColumn>;
34
+ }): Promise<void>;
35
+ clearTable({ tableName }: {
36
+ tableName: TABLE_NAMES;
37
+ }): Promise<void>;
38
+ insert({ tableName, record }: {
39
+ tableName: TABLE_NAMES;
40
+ record: Record<string, any>;
41
+ }): Promise<void>;
42
+ batchInsert({ tableName, records }: {
43
+ tableName: TABLE_NAMES;
44
+ records: Record<string, any>[];
45
+ }): Promise<void>;
46
+ load<R>({ tableName, keys }: {
47
+ tableName: TABLE_NAMES;
48
+ keys: Record<string, string>;
49
+ }): Promise<R | null>;
50
+ getThreadById({ threadId }: {
51
+ threadId: string;
52
+ }): Promise<StorageThreadType | null>;
53
+ getThreadsByResourceId({ resourceId }: {
54
+ resourceId: string;
55
+ }): Promise<StorageThreadType[]>;
56
+ saveThread({ thread }: {
57
+ thread: StorageThreadType;
58
+ }): Promise<StorageThreadType>;
59
+ updateThread({ id, title, metadata, }: {
60
+ id: string;
61
+ title: string;
62
+ metadata: Record<string, unknown>;
63
+ }): Promise<StorageThreadType>;
64
+ deleteThread({ threadId }: {
65
+ threadId: string;
66
+ }): Promise<void>;
67
+ getMessages<T extends MessageType[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
68
+ saveMessages({ messages }: {
69
+ messages: MessageType[];
70
+ }): Promise<MessageType[]>;
71
+ getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: {
72
+ name?: string;
73
+ scope?: string;
74
+ page: number;
75
+ perPage: number;
76
+ attributes?: Record<string, string>;
77
+ filters?: Record<string, any>;
78
+ fromDate?: Date;
79
+ toDate?: Date;
80
+ }): Promise<any[]>;
81
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
82
+ getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
83
+ workflowName?: string;
84
+ fromDate?: Date;
85
+ toDate?: Date;
86
+ limit?: number;
87
+ offset?: number;
88
+ resourceId?: string;
89
+ }): Promise<WorkflowRuns>;
90
+ getWorkflowRunById({ runId, workflowName, }: {
91
+ runId: string;
92
+ workflowName?: string;
93
+ }): Promise<WorkflowRun | null>;
94
+ }
95
+
96
+ export { EvalRow, MastraStorage, MockStore, StorageColumn, StorageGetMessagesArg, TABLE_NAMES, WorkflowRun, WorkflowRuns };