@mastra/core 0.10.13 → 0.10.14

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 (235) hide show
  1. package/a2a.d.ts +1 -0
  2. package/agent.d.ts +1 -0
  3. package/base.d.ts +1 -0
  4. package/bundler.d.ts +1 -0
  5. package/deployer.d.ts +1 -0
  6. package/di.d.ts +1 -0
  7. package/dist/a2a/index.cjs +79 -0
  8. package/dist/a2a/index.d.cts +780 -0
  9. package/dist/a2a/index.d.ts +780 -0
  10. package/dist/a2a/index.js +68 -0
  11. package/dist/agent/index.cjs +15 -0
  12. package/dist/agent/index.d.cts +29 -0
  13. package/dist/agent/index.d.ts +29 -0
  14. package/dist/agent/index.js +2 -0
  15. package/dist/base-B_y9sMg0.d.cts +162 -0
  16. package/dist/base-CS5eSXbL.d.cts +4117 -0
  17. package/dist/base-ClrXcCRx.d.ts +162 -0
  18. package/dist/base-DBhKcre4.d.ts +4117 -0
  19. package/dist/base.cjs +10 -0
  20. package/dist/base.d.cts +6 -0
  21. package/dist/base.d.ts +6 -0
  22. package/dist/base.js +1 -0
  23. package/dist/bundler/index.cjs +10 -0
  24. package/dist/bundler/index.d.cts +30 -0
  25. package/dist/bundler/index.d.ts +30 -0
  26. package/dist/bundler/index.js +1 -0
  27. package/dist/chunk-2GRYVZ2O.cjs +244 -0
  28. package/dist/chunk-2HDFKWFU.js +2249 -0
  29. package/dist/chunk-32C7JDIZ.js +1 -0
  30. package/dist/chunk-4UBOJFSL.js +989 -0
  31. package/dist/chunk-4UWPFBC6.js +88 -0
  32. package/dist/chunk-4Z3OU5RY.cjs +31 -0
  33. package/dist/chunk-5HTMDAXP.js +359 -0
  34. package/dist/chunk-5IEKR756.js +53 -0
  35. package/dist/chunk-5YDTZN2X.js +114 -0
  36. package/dist/chunk-6UNGH46J.js +75 -0
  37. package/dist/chunk-6Y4UL5Z6.cjs +94 -0
  38. package/dist/chunk-7F6BQXE2.cjs +425 -0
  39. package/dist/chunk-7H2GET5Z.cjs +668 -0
  40. package/dist/chunk-7HZ6NIAF.cjs +2 -0
  41. package/dist/chunk-7MZNOW6W.cjs +2263 -0
  42. package/dist/chunk-7XQIPES3.js +668 -0
  43. package/dist/chunk-AKYTYALY.js +70 -0
  44. package/dist/chunk-ATXBSEFT.js +22 -0
  45. package/dist/chunk-B6TOBUS6.cjs +80 -0
  46. package/dist/chunk-B7SQOKEC.cjs +91 -0
  47. package/dist/chunk-BB4KXGBU.js +83 -0
  48. package/dist/chunk-BB6DPGIV.cjs +6 -0
  49. package/dist/chunk-C4LMN2IR.js +27 -0
  50. package/dist/chunk-DFFVEKIG.js +407 -0
  51. package/dist/chunk-E7AX3U6M.cjs +659 -0
  52. package/dist/chunk-EWCOOO3H.js +5007 -0
  53. package/dist/chunk-F2WMR75C.cjs +183 -0
  54. package/dist/chunk-FBKJ3652.cjs +5034 -0
  55. package/dist/chunk-FEYYOBBG.cjs +24 -0
  56. package/dist/chunk-FL5SZ2XU.js +181 -0
  57. package/dist/chunk-GH2KM66J.js +37 -0
  58. package/dist/chunk-GWFS5DAR.cjs +37 -0
  59. package/dist/chunk-HNEE7IF4.js +60 -0
  60. package/dist/chunk-HSVOEWAM.cjs +2 -0
  61. package/dist/chunk-J52TXHZV.cjs +73 -0
  62. package/dist/chunk-JNMQKJH4.js +10 -0
  63. package/dist/chunk-JQOMTERC.js +89 -0
  64. package/dist/chunk-LABUWBKX.cjs +71 -0
  65. package/dist/chunk-LXFZUKP3.cjs +34 -0
  66. package/dist/chunk-MP2QBLUJ.cjs +70 -0
  67. package/dist/chunk-MUNFCOMB.cjs +62 -0
  68. package/dist/chunk-NH5WJNNS.js +1 -0
  69. package/dist/chunk-P3Q73CAW.cjs +55 -0
  70. package/dist/chunk-PA2YIVIT.js +61 -0
  71. package/dist/chunk-QFTBW7ZZ.cjs +2 -0
  72. package/dist/chunk-QQ5K5TZE.cjs +619 -0
  73. package/dist/chunk-QUSEDVYI.cjs +991 -0
  74. package/dist/chunk-R4V75T7J.js +1 -0
  75. package/dist/chunk-SGGPJWRQ.js +69 -0
  76. package/dist/chunk-ST5RMVLG.cjs +87 -0
  77. package/dist/chunk-TC2SCOTE.js +605 -0
  78. package/dist/chunk-U64IJDC5.cjs +109 -0
  79. package/dist/chunk-UX3B6S2I.cjs +65 -0
  80. package/dist/chunk-V5D2LIF5.js +68 -0
  81. package/dist/chunk-VG4OPO2R.js +240 -0
  82. package/dist/chunk-WQNOATKB.js +103 -0
  83. package/dist/chunk-Y7D2JLKS.js +4 -0
  84. package/dist/chunk-YJEHXYK5.js +657 -0
  85. package/dist/chunk-YOQP5T77.js +32 -0
  86. package/dist/chunk-ZIZ3CVHN.cjs +120 -0
  87. package/dist/chunk-ZPOUMTTH.cjs +362 -0
  88. package/dist/chunk-ZZLBNB3U.cjs +12 -0
  89. package/dist/deployer/index.cjs +10 -0
  90. package/dist/deployer/index.d.cts +19 -0
  91. package/dist/deployer/index.d.ts +19 -0
  92. package/dist/deployer/index.js +1 -0
  93. package/dist/di/index.cjs +10 -0
  94. package/dist/di/index.d.cts +1 -0
  95. package/dist/di/index.d.ts +1 -0
  96. package/dist/di/index.js +1 -0
  97. package/dist/error/index.cjs +22 -0
  98. package/dist/error/index.d.cts +86 -0
  99. package/dist/error/index.d.ts +86 -0
  100. package/dist/error/index.js +1 -0
  101. package/dist/eval/index.cjs +14 -0
  102. package/dist/eval/index.d.cts +43 -0
  103. package/dist/eval/index.d.ts +43 -0
  104. package/dist/eval/index.js +1 -0
  105. package/dist/hooks/index.cjs +18 -0
  106. package/dist/hooks/index.d.cts +33 -0
  107. package/dist/hooks/index.d.ts +33 -0
  108. package/dist/hooks/index.js +1 -0
  109. package/dist/index.cjs +281 -0
  110. package/dist/index.d.cts +92 -0
  111. package/dist/index.d.ts +92 -0
  112. package/dist/index.js +112 -0
  113. package/dist/integration/index.cjs +14 -0
  114. package/dist/integration/index.d.cts +65 -0
  115. package/dist/integration/index.d.ts +65 -0
  116. package/dist/integration/index.js +1 -0
  117. package/dist/llm/index.cjs +10 -0
  118. package/dist/llm/index.d.cts +29 -0
  119. package/dist/llm/index.d.ts +29 -0
  120. package/dist/llm/index.js +1 -0
  121. package/dist/logger/index.cjs +43 -0
  122. package/dist/logger/index.d.cts +96 -0
  123. package/dist/logger/index.d.ts +96 -0
  124. package/dist/logger/index.js +2 -0
  125. package/dist/logger-B8XXh6ya.d.cts +159 -0
  126. package/dist/logger-Bpa2oLL4.d.ts +159 -0
  127. package/dist/mastra/index.cjs +10 -0
  128. package/dist/mastra/index.d.cts +29 -0
  129. package/dist/mastra/index.d.ts +29 -0
  130. package/dist/mastra/index.js +1 -0
  131. package/dist/mcp/index.cjs +106 -0
  132. package/dist/mcp/index.d.cts +29 -0
  133. package/dist/mcp/index.d.ts +29 -0
  134. package/dist/mcp/index.js +100 -0
  135. package/dist/memory/index.cjs +18 -0
  136. package/dist/memory/index.d.cts +29 -0
  137. package/dist/memory/index.d.ts +29 -0
  138. package/dist/memory/index.js +1 -0
  139. package/dist/network/index.cjs +311 -0
  140. package/dist/network/index.d.cts +29 -0
  141. package/dist/network/index.d.ts +29 -0
  142. package/dist/network/index.js +309 -0
  143. package/dist/network/vNext/index.cjs +873 -0
  144. package/dist/network/vNext/index.d.cts +29 -0
  145. package/dist/network/vNext/index.d.ts +29 -0
  146. package/dist/network/vNext/index.js +871 -0
  147. package/dist/relevance/index.cjs +18 -0
  148. package/dist/relevance/index.d.cts +49 -0
  149. package/dist/relevance/index.d.ts +49 -0
  150. package/dist/relevance/index.js +1 -0
  151. package/dist/runtime-context/index.cjs +10 -0
  152. package/dist/runtime-context/index.d.cts +52 -0
  153. package/dist/runtime-context/index.d.ts +52 -0
  154. package/dist/runtime-context/index.js +1 -0
  155. package/dist/server/index.cjs +62 -0
  156. package/dist/server/index.d.cts +52 -0
  157. package/dist/server/index.d.ts +52 -0
  158. package/dist/server/index.js +59 -0
  159. package/dist/storage/index.cjs +336 -0
  160. package/dist/storage/index.d.cts +149 -0
  161. package/dist/storage/index.d.ts +149 -0
  162. package/dist/storage/index.js +303 -0
  163. package/dist/telemetry/index.cjs +30 -0
  164. package/dist/telemetry/index.d.cts +75 -0
  165. package/dist/telemetry/index.d.ts +75 -0
  166. package/dist/telemetry/index.js +1 -0
  167. package/dist/telemetry/otel-vendor.cjs +103 -0
  168. package/dist/telemetry/otel-vendor.d.cts +20 -0
  169. package/dist/telemetry/otel-vendor.d.ts +20 -0
  170. package/dist/telemetry/otel-vendor.js +57 -0
  171. package/dist/tools/index.cjs +18 -0
  172. package/dist/tools/index.d.cts +41 -0
  173. package/dist/tools/index.d.ts +41 -0
  174. package/dist/tools/index.js +1 -0
  175. package/dist/tts/index.cjs +10 -0
  176. package/dist/tts/index.d.cts +28 -0
  177. package/dist/tts/index.d.ts +28 -0
  178. package/dist/tts/index.js +1 -0
  179. package/dist/types-Bo1uigWx.d.cts +17 -0
  180. package/dist/types-Bo1uigWx.d.ts +17 -0
  181. package/dist/utils.cjs +58 -0
  182. package/dist/utils.d.cts +149 -0
  183. package/dist/utils.d.ts +149 -0
  184. package/dist/utils.js +1 -0
  185. package/dist/vector/filter/index.cjs +192 -0
  186. package/dist/vector/filter/index.d.cts +128 -0
  187. package/dist/vector/filter/index.d.ts +128 -0
  188. package/dist/vector/filter/index.js +190 -0
  189. package/dist/vector/index.cjs +10 -0
  190. package/dist/vector/index.d.cts +77 -0
  191. package/dist/vector/index.d.ts +77 -0
  192. package/dist/vector/index.js +1 -0
  193. package/dist/voice/index.cjs +18 -0
  194. package/dist/voice/index.d.cts +29 -0
  195. package/dist/voice/index.d.ts +29 -0
  196. package/dist/voice/index.js +1 -0
  197. package/dist/workflows/constants.cjs +10 -0
  198. package/dist/workflows/constants.d.cts +3 -0
  199. package/dist/workflows/constants.d.ts +3 -0
  200. package/dist/workflows/constants.js +1 -0
  201. package/dist/workflows/index.cjs +42 -0
  202. package/dist/workflows/index.d.cts +282 -0
  203. package/dist/workflows/index.d.ts +282 -0
  204. package/dist/workflows/index.js +1 -0
  205. package/dist/workflows/legacy/index.cjs +90 -0
  206. package/dist/workflows/legacy/index.d.cts +91 -0
  207. package/dist/workflows/legacy/index.d.ts +91 -0
  208. package/dist/workflows/legacy/index.js +1 -0
  209. package/error.d.ts +1 -0
  210. package/eval.d.ts +1 -0
  211. package/hooks.d.ts +1 -0
  212. package/integration.d.ts +1 -0
  213. package/llm.d.ts +1 -0
  214. package/logger.d.ts +1 -0
  215. package/mastra.d.ts +1 -0
  216. package/mcp.d.ts +1 -0
  217. package/memory.d.ts +1 -0
  218. package/network/vNext.d.ts +1 -0
  219. package/network.d.ts +1 -0
  220. package/package.json +1 -1
  221. package/relevance.d.ts +1 -0
  222. package/runtime-context.d.ts +1 -0
  223. package/server.d.ts +1 -0
  224. package/storage.d.ts +1 -0
  225. package/telemetry/otel-vendor.d.ts +1 -0
  226. package/telemetry.d.ts +1 -0
  227. package/tools.d.ts +1 -0
  228. package/tts.d.ts +1 -0
  229. package/utils.d.ts +1 -0
  230. package/vector/filter.d.ts +1 -0
  231. package/vector.d.ts +1 -0
  232. package/voice.d.ts +1 -0
  233. package/workflows/_constants.d.ts +1 -0
  234. package/workflows/legacy.d.ts +1 -0
  235. package/workflows.d.ts +1 -0
@@ -0,0 +1,303 @@
1
+ import { MastraStorage } from '../chunk-FL5SZ2XU.js';
2
+ export { MastraStorage } from '../chunk-FL5SZ2XU.js';
3
+ import { MessageList } from '../chunk-4UBOJFSL.js';
4
+ export { TABLE_EVALS, TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCHEMAS, TABLE_THREADS, TABLE_TRACES, TABLE_WORKFLOW_SNAPSHOT } from '../chunk-TC2SCOTE.js';
5
+
6
+ // src/storage/mock.ts
7
+ var MockStore = class extends MastraStorage {
8
+ data = {
9
+ mastra_workflow_snapshot: {},
10
+ mastra_evals: {},
11
+ mastra_messages: {},
12
+ mastra_threads: {},
13
+ mastra_traces: {},
14
+ mastra_resources: {}
15
+ };
16
+ constructor() {
17
+ super({ name: "MockStore" });
18
+ this.hasInitialized = Promise.resolve(true);
19
+ }
20
+ async createTable(_) {
21
+ }
22
+ async alterTable({
23
+ tableName
24
+ }) {
25
+ this.logger.debug(`MockStore: alterTable called for ${tableName}`);
26
+ }
27
+ async clearTable({ tableName }) {
28
+ this.logger.debug(`MockStore: clearTable called for ${tableName}`);
29
+ this.data[tableName] = {};
30
+ }
31
+ async insert({ tableName, record }) {
32
+ this.logger.debug(`MockStore: insert called for ${tableName}`, record);
33
+ this.data[tableName][record.run_id] = JSON.parse(JSON.stringify(record));
34
+ }
35
+ async batchInsert({ tableName, records }) {
36
+ this.logger.debug(`MockStore: batchInsert called for ${tableName} with ${records.length} records`);
37
+ for (const record of records) {
38
+ this.data[tableName][record.run_id] = JSON.parse(JSON.stringify(record));
39
+ }
40
+ }
41
+ async load({ tableName, keys }) {
42
+ this.logger.debug(`MockStore: load called for ${tableName} with keys`, keys);
43
+ const record = this.data[tableName][keys.run_id];
44
+ return record ? record : null;
45
+ }
46
+ async getThreadById({ threadId }) {
47
+ this.logger.debug(`MockStore: getThreadById called for ${threadId}`);
48
+ const thread = Object.values(this.data.mastra_threads).find((t) => t.id === threadId);
49
+ return thread ? thread : null;
50
+ }
51
+ async getThreadsByResourceId({ resourceId }) {
52
+ this.logger.debug(`MockStore: getThreadsByResourceId called for ${resourceId}`);
53
+ const threads = Object.values(this.data.mastra_threads).filter((t) => t.resourceId === resourceId);
54
+ return threads;
55
+ }
56
+ async saveThread({ thread }) {
57
+ this.logger.debug(`MockStore: saveThread called for ${thread.id}`);
58
+ const key = thread.id;
59
+ this.data.mastra_threads[key] = thread;
60
+ return thread;
61
+ }
62
+ async updateThread({
63
+ id,
64
+ title,
65
+ metadata
66
+ }) {
67
+ this.logger.debug(`MockStore: updateThread called for ${id}`);
68
+ const thread = this.data.mastra_threads[id];
69
+ if (thread) {
70
+ thread.title = title;
71
+ thread.metadata = { ...thread.metadata, ...metadata };
72
+ thread.updatedAt = /* @__PURE__ */ new Date();
73
+ }
74
+ return thread;
75
+ }
76
+ async deleteThread({ threadId }) {
77
+ this.logger.debug(`MockStore: deleteThread called for ${threadId}`);
78
+ delete this.data.mastra_threads[threadId];
79
+ this.data.mastra_messages = Object.fromEntries(
80
+ Object.entries(this.data.mastra_messages).filter(([, msg]) => msg.threadId !== threadId)
81
+ );
82
+ }
83
+ async getResourceById({ resourceId }) {
84
+ this.logger.debug(`MockStore: getResourceById called for ${resourceId}`);
85
+ const resource = this.data.mastra_resources[resourceId];
86
+ return resource ? resource : null;
87
+ }
88
+ async saveResource({ resource }) {
89
+ this.logger.debug(`MockStore: saveResource called for ${resource.id}`);
90
+ this.data.mastra_resources[resource.id] = JSON.parse(JSON.stringify(resource));
91
+ return resource;
92
+ }
93
+ async updateResource({
94
+ resourceId,
95
+ workingMemory,
96
+ metadata
97
+ }) {
98
+ this.logger.debug(`MockStore: updateResource called for ${resourceId}`);
99
+ let resource = this.data.mastra_resources[resourceId];
100
+ if (!resource) {
101
+ resource = {
102
+ id: resourceId,
103
+ workingMemory,
104
+ metadata: metadata || {},
105
+ createdAt: /* @__PURE__ */ new Date(),
106
+ updatedAt: /* @__PURE__ */ new Date()
107
+ };
108
+ } else {
109
+ resource = {
110
+ ...resource,
111
+ workingMemory: workingMemory !== void 0 ? workingMemory : resource.workingMemory,
112
+ metadata: {
113
+ ...resource.metadata,
114
+ ...metadata
115
+ },
116
+ updatedAt: /* @__PURE__ */ new Date()
117
+ };
118
+ }
119
+ this.data.mastra_resources[resourceId] = resource;
120
+ return resource;
121
+ }
122
+ async getMessages({ threadId, selectBy }) {
123
+ this.logger.debug(`MockStore: getMessages called for thread ${threadId}`);
124
+ let messages = Object.values(this.data.mastra_messages).filter((msg) => msg.threadId === threadId);
125
+ if (selectBy?.last) {
126
+ messages = messages.slice(-selectBy.last);
127
+ }
128
+ messages.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
129
+ return messages;
130
+ }
131
+ async saveMessages(args) {
132
+ const { messages, format = "v1" } = args;
133
+ this.logger.debug(`MockStore: saveMessages called with ${messages.length} messages`);
134
+ for (const message of messages) {
135
+ const key = message.id;
136
+ this.data.mastra_messages[key] = message;
137
+ }
138
+ const list = new MessageList().add(messages, "memory");
139
+ if (format === `v2`) return list.get.all.v2();
140
+ return list.get.all.v1();
141
+ }
142
+ async updateMessages(args) {
143
+ this.logger.debug(`MockStore: updateMessages called with ${args.messages.length} messages`);
144
+ const messages = args.messages.map((m) => this.data.mastra_messages[m.id]);
145
+ return messages;
146
+ }
147
+ async getTraces({
148
+ name,
149
+ scope,
150
+ page,
151
+ perPage,
152
+ attributes,
153
+ filters,
154
+ fromDate,
155
+ toDate
156
+ }) {
157
+ this.logger.debug(`MockStore: getTraces called`);
158
+ let traces = Object.values(this.data.mastra_traces);
159
+ if (name) traces = traces.filter((t) => t.name?.startsWith(name));
160
+ if (scope) traces = traces.filter((t) => t.scope === scope);
161
+ if (attributes) {
162
+ traces = traces.filter(
163
+ (t) => Object.entries(attributes).every(([key, value]) => t.attributes?.[key] === value)
164
+ );
165
+ }
166
+ if (filters) {
167
+ traces = traces.filter((t) => Object.entries(filters).every(([key, value]) => t[key] === value));
168
+ }
169
+ if (fromDate) traces = traces.filter((t) => new Date(t.createdAt) >= fromDate);
170
+ if (toDate) traces = traces.filter((t) => new Date(t.createdAt) <= toDate);
171
+ traces.sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime());
172
+ const start = page * perPage;
173
+ const end = start + perPage;
174
+ return traces.slice(start, end);
175
+ }
176
+ async getEvalsByAgentName(agentName, type) {
177
+ this.logger.debug(`MockStore: getEvalsByAgentName called for ${agentName}`);
178
+ let evals = Object.values(this.data.mastra_evals).filter((e) => e.agentName === agentName);
179
+ if (type === "test") {
180
+ evals = evals.filter((e) => e.testInfo && e.testInfo.testPath);
181
+ } else if (type === "live") {
182
+ evals = evals.filter((e) => !e.testInfo || !e.testInfo.testPath);
183
+ }
184
+ evals.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
185
+ return evals;
186
+ }
187
+ async getWorkflowRuns({
188
+ workflowName,
189
+ fromDate,
190
+ toDate,
191
+ limit,
192
+ offset,
193
+ resourceId
194
+ } = {}) {
195
+ this.logger.debug(`MockStore: getWorkflowRuns called`);
196
+ let runs = Object.values(this.data.mastra_workflow_snapshot || {});
197
+ if (workflowName) runs = runs.filter((run) => run.workflow_name === workflowName);
198
+ if (fromDate) runs = runs.filter((run) => new Date(run.createdAt) >= fromDate);
199
+ if (toDate) runs = runs.filter((run) => new Date(run.createdAt) <= toDate);
200
+ if (resourceId) runs = runs.filter((run) => run.resourceId === resourceId);
201
+ const total = runs.length;
202
+ runs.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
203
+ if (limit !== void 0 && offset !== void 0) {
204
+ const start = offset;
205
+ const end = start + limit;
206
+ runs = runs.slice(start, end);
207
+ }
208
+ const parsedRuns = runs.map((run) => ({
209
+ ...run,
210
+ snapshot: typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : { ...run.snapshot },
211
+ createdAt: new Date(run.createdAt),
212
+ updatedAt: new Date(run.updatedAt),
213
+ runId: run.run_id,
214
+ workflowName: run.workflow_name
215
+ }));
216
+ return { runs: parsedRuns, total };
217
+ }
218
+ async getWorkflowRunById({
219
+ runId,
220
+ workflowName
221
+ }) {
222
+ this.logger.debug(`MockStore: getWorkflowRunById called for runId ${runId}`);
223
+ let run = Object.values(this.data.mastra_workflow_snapshot || {}).find((r) => r.run_id === runId);
224
+ if (run && workflowName && run.workflow_name !== workflowName) {
225
+ run = void 0;
226
+ }
227
+ if (!run) return null;
228
+ const parsedRun = {
229
+ ...run,
230
+ snapshot: typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot,
231
+ createdAt: new Date(run.createdAt),
232
+ updatedAt: new Date(run.updatedAt),
233
+ runId: run.run_id,
234
+ workflowName: run.workflow_name
235
+ };
236
+ return parsedRun;
237
+ }
238
+ async getTracesPaginated({
239
+ name,
240
+ scope,
241
+ attributes,
242
+ page,
243
+ perPage,
244
+ fromDate,
245
+ toDate
246
+ }) {
247
+ this.logger.debug(`MockStore: getTracesPaginated called`);
248
+ let traces = Object.values(this.data.mastra_traces);
249
+ if (name) traces = traces.filter((t) => t.name?.startsWith(name));
250
+ if (scope) traces = traces.filter((t) => t.scope === scope);
251
+ if (attributes) {
252
+ traces = traces.filter(
253
+ (t) => Object.entries(attributes).every(([key, value]) => t.attributes?.[key] === value)
254
+ );
255
+ }
256
+ if (fromDate) traces = traces.filter((t) => new Date(t.createdAt) >= fromDate);
257
+ if (toDate) traces = traces.filter((t) => new Date(t.createdAt) <= toDate);
258
+ traces.sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime());
259
+ const start = page * perPage;
260
+ const end = start + perPage;
261
+ return {
262
+ traces: traces.slice(start, end),
263
+ total: traces.length,
264
+ page,
265
+ perPage,
266
+ hasMore: traces.length > end
267
+ };
268
+ }
269
+ async getThreadsByResourceIdPaginated(args) {
270
+ this.logger.debug(`MockStore: getThreadsByResourceIdPaginated called for ${args.resourceId}`);
271
+ const threads = Object.values(this.data.mastra_threads).filter((t) => t.resourceId === args.resourceId);
272
+ return {
273
+ threads: threads.slice(args.page * args.perPage, (args.page + 1) * args.perPage),
274
+ total: threads.length,
275
+ page: args.page,
276
+ perPage: args.perPage,
277
+ hasMore: threads.length > (args.page + 1) * args.perPage
278
+ };
279
+ }
280
+ async getMessagesPaginated({
281
+ threadId,
282
+ selectBy
283
+ }) {
284
+ this.logger.debug(`MockStore: getMessagesPaginated called for thread ${threadId}`);
285
+ const { page = 0, perPage = 40 } = selectBy?.pagination || {};
286
+ let messages = Object.values(this.data.mastra_messages).filter((msg) => msg.threadId === threadId);
287
+ if (selectBy?.last) {
288
+ messages = messages.slice(-selectBy.last);
289
+ }
290
+ messages.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
291
+ const start = page * perPage;
292
+ const end = start + perPage;
293
+ return {
294
+ messages: messages.slice(start, end),
295
+ total: messages.length,
296
+ page,
297
+ perPage,
298
+ hasMore: messages.length > end
299
+ };
300
+ }
301
+ };
302
+
303
+ export { MockStore };
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ var chunkQQ5K5TZE_cjs = require('../chunk-QQ5K5TZE.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "InstrumentClass", {
8
+ enumerable: true,
9
+ get: function () { return chunkQQ5K5TZE_cjs.InstrumentClass; }
10
+ });
11
+ Object.defineProperty(exports, "OTLPStorageExporter", {
12
+ enumerable: true,
13
+ get: function () { return chunkQQ5K5TZE_cjs.OTLPTraceExporter; }
14
+ });
15
+ Object.defineProperty(exports, "Telemetry", {
16
+ enumerable: true,
17
+ get: function () { return chunkQQ5K5TZE_cjs.Telemetry; }
18
+ });
19
+ Object.defineProperty(exports, "getBaggageValues", {
20
+ enumerable: true,
21
+ get: function () { return chunkQQ5K5TZE_cjs.getBaggageValues; }
22
+ });
23
+ Object.defineProperty(exports, "hasActiveTelemetry", {
24
+ enumerable: true,
25
+ get: function () { return chunkQQ5K5TZE_cjs.hasActiveTelemetry; }
26
+ });
27
+ Object.defineProperty(exports, "withSpan", {
28
+ enumerable: true,
29
+ get: function () { return chunkQQ5K5TZE_cjs.withSpan; }
30
+ });
@@ -0,0 +1,75 @@
1
+ export { O as OtelConfig, S as SamplingStrategy, a as Telemetry, T as Trace } from '../base-B_y9sMg0.cjs';
2
+ import { SpanKind, Context } from '@opentelemetry/api';
3
+ import { ExportResult } from '@opentelemetry/core';
4
+ import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
5
+ import { I as IMastraLogger } from '../logger-B8XXh6ya.cjs';
6
+ import { o as MastraStorage } from '../base-CS5eSXbL.cjs';
7
+ import '../error/index.cjs';
8
+ import 'stream';
9
+ import 'ai';
10
+ import 'zod';
11
+ import 'json-schema';
12
+ import '../types-Bo1uigWx.cjs';
13
+ import 'sift';
14
+ import '../runtime-context/index.cjs';
15
+ import 'xstate';
16
+ import 'node:events';
17
+ import '../vector/index.cjs';
18
+ import '../vector/filter/index.cjs';
19
+ import '../tts/index.cjs';
20
+ import 'node:http';
21
+ import 'hono';
22
+ import 'stream/web';
23
+ import 'events';
24
+ import 'node:stream/web';
25
+ import '../workflows/constants.cjs';
26
+ import 'ai/test';
27
+ import '../deployer/index.cjs';
28
+ import '../bundler/index.cjs';
29
+ import 'hono/cors';
30
+ import 'hono-openapi';
31
+
32
+ declare function withSpan(options: {
33
+ spanName?: string;
34
+ skipIfNoTelemetry?: boolean;
35
+ spanKind?: SpanKind;
36
+ tracerName?: string;
37
+ }): any;
38
+ declare function InstrumentClass(options?: {
39
+ prefix?: string;
40
+ spanKind?: SpanKind;
41
+ excludeMethods?: string[];
42
+ methodFilter?: (methodName: string) => boolean;
43
+ tracerName?: string;
44
+ }): (target: any) => any;
45
+
46
+ declare function hasActiveTelemetry(tracerName?: string): boolean;
47
+ /**
48
+ * Get baggage values from context
49
+ * @param ctx The context to get baggage values from
50
+ * @returns
51
+ */
52
+ declare function getBaggageValues(ctx: Context): {
53
+ requestId: string | undefined;
54
+ componentName: string | undefined;
55
+ runId: string | undefined;
56
+ };
57
+
58
+ declare class OTLPTraceExporter implements SpanExporter {
59
+ private storage;
60
+ private queue;
61
+ private serializer;
62
+ private logger;
63
+ private activeFlush;
64
+ constructor({ logger, storage }: {
65
+ logger: IMastraLogger;
66
+ storage: MastraStorage;
67
+ });
68
+ export(internalRepresentation: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
69
+ shutdown(): Promise<void>;
70
+ flush(): Promise<void>;
71
+ forceFlush(): Promise<void>;
72
+ __setLogger(logger: IMastraLogger): void;
73
+ }
74
+
75
+ export { InstrumentClass, OTLPTraceExporter as OTLPStorageExporter, getBaggageValues, hasActiveTelemetry, withSpan };
@@ -0,0 +1,75 @@
1
+ export { O as OtelConfig, S as SamplingStrategy, a as Telemetry, T as Trace } from '../base-ClrXcCRx.js';
2
+ import { SpanKind, Context } from '@opentelemetry/api';
3
+ import { ExportResult } from '@opentelemetry/core';
4
+ import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
5
+ import { I as IMastraLogger } from '../logger-Bpa2oLL4.js';
6
+ import { o as MastraStorage } from '../base-DBhKcre4.js';
7
+ import '../error/index.js';
8
+ import 'stream';
9
+ import 'ai';
10
+ import 'zod';
11
+ import 'json-schema';
12
+ import '../types-Bo1uigWx.js';
13
+ import 'sift';
14
+ import '../runtime-context/index.js';
15
+ import 'xstate';
16
+ import 'node:events';
17
+ import '../vector/index.js';
18
+ import '../vector/filter/index.js';
19
+ import '../tts/index.js';
20
+ import 'node:http';
21
+ import 'hono';
22
+ import 'stream/web';
23
+ import 'events';
24
+ import 'node:stream/web';
25
+ import '../workflows/constants.js';
26
+ import 'ai/test';
27
+ import '../deployer/index.js';
28
+ import '../bundler/index.js';
29
+ import 'hono/cors';
30
+ import 'hono-openapi';
31
+
32
+ declare function withSpan(options: {
33
+ spanName?: string;
34
+ skipIfNoTelemetry?: boolean;
35
+ spanKind?: SpanKind;
36
+ tracerName?: string;
37
+ }): any;
38
+ declare function InstrumentClass(options?: {
39
+ prefix?: string;
40
+ spanKind?: SpanKind;
41
+ excludeMethods?: string[];
42
+ methodFilter?: (methodName: string) => boolean;
43
+ tracerName?: string;
44
+ }): (target: any) => any;
45
+
46
+ declare function hasActiveTelemetry(tracerName?: string): boolean;
47
+ /**
48
+ * Get baggage values from context
49
+ * @param ctx The context to get baggage values from
50
+ * @returns
51
+ */
52
+ declare function getBaggageValues(ctx: Context): {
53
+ requestId: string | undefined;
54
+ componentName: string | undefined;
55
+ runId: string | undefined;
56
+ };
57
+
58
+ declare class OTLPTraceExporter implements SpanExporter {
59
+ private storage;
60
+ private queue;
61
+ private serializer;
62
+ private logger;
63
+ private activeFlush;
64
+ constructor({ logger, storage }: {
65
+ logger: IMastraLogger;
66
+ storage: MastraStorage;
67
+ });
68
+ export(internalRepresentation: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
69
+ shutdown(): Promise<void>;
70
+ flush(): Promise<void>;
71
+ forceFlush(): Promise<void>;
72
+ __setLogger(logger: IMastraLogger): void;
73
+ }
74
+
75
+ export { InstrumentClass, OTLPTraceExporter as OTLPStorageExporter, getBaggageValues, hasActiveTelemetry, withSpan };
@@ -0,0 +1 @@
1
+ export { InstrumentClass, OTLPTraceExporter as OTLPStorageExporter, Telemetry, getBaggageValues, hasActiveTelemetry, withSpan } from '../chunk-TC2SCOTE.js';
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ var sdkNode = require('@opentelemetry/sdk-node');
4
+ var sdkTraceNode = require('@opentelemetry/sdk-trace-node');
5
+ var autoInstrumentationsNode = require('@opentelemetry/auto-instrumentations-node');
6
+ var semanticConventions = require('@opentelemetry/semantic-conventions');
7
+ var resources = require('@opentelemetry/resources');
8
+ var exporterTraceOtlpHttp = require('@opentelemetry/exporter-trace-otlp-http');
9
+ var exporterTraceOtlpGrpc = require('@opentelemetry/exporter-trace-otlp-grpc');
10
+ var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
11
+ var core = require('@opentelemetry/core');
12
+
13
+ var CompositeExporter = class {
14
+ exporters;
15
+ constructor(exporters) {
16
+ this.exporters = exporters;
17
+ }
18
+ export(spans, resultCallback) {
19
+ const telemetryTraceIds = new Set(
20
+ spans.filter((span) => {
21
+ const attrs = span.attributes || {};
22
+ const httpTarget = attrs["http.target"];
23
+ return httpTarget === "/api/telemetry";
24
+ }).map((span) => span.spanContext().traceId)
25
+ );
26
+ const filteredSpans = spans.filter((span) => !telemetryTraceIds.has(span.spanContext().traceId));
27
+ if (filteredSpans.length === 0) {
28
+ resultCallback({ code: core.ExportResultCode.SUCCESS });
29
+ return;
30
+ }
31
+ void Promise.all(
32
+ this.exporters.map(
33
+ (exporter) => new Promise((resolve) => {
34
+ if (exporter.export) {
35
+ exporter.export(filteredSpans, resolve);
36
+ } else {
37
+ resolve({ code: core.ExportResultCode.FAILED });
38
+ }
39
+ })
40
+ )
41
+ ).then((results) => {
42
+ const hasError = results.some((r) => r.code === core.ExportResultCode.FAILED);
43
+ resultCallback({
44
+ code: hasError ? core.ExportResultCode.FAILED : core.ExportResultCode.SUCCESS
45
+ });
46
+ }).catch((error) => {
47
+ console.error("[CompositeExporter] Export error:", error);
48
+ resultCallback({ code: core.ExportResultCode.FAILED, error });
49
+ });
50
+ }
51
+ shutdown() {
52
+ return Promise.all(this.exporters.map((e) => e.shutdown?.() ?? Promise.resolve())).then(() => void 0);
53
+ }
54
+ forceFlush() {
55
+ return Promise.all(this.exporters.map((e) => e.forceFlush?.() ?? Promise.resolve())).then(() => void 0);
56
+ }
57
+ };
58
+
59
+ Object.defineProperty(exports, "NodeSDK", {
60
+ enumerable: true,
61
+ get: function () { return sdkNode.NodeSDK; }
62
+ });
63
+ Object.defineProperty(exports, "ConsoleSpanExporter", {
64
+ enumerable: true,
65
+ get: function () { return sdkTraceNode.ConsoleSpanExporter; }
66
+ });
67
+ Object.defineProperty(exports, "getNodeAutoInstrumentations", {
68
+ enumerable: true,
69
+ get: function () { return autoInstrumentationsNode.getNodeAutoInstrumentations; }
70
+ });
71
+ Object.defineProperty(exports, "ATTR_SERVICE_NAME", {
72
+ enumerable: true,
73
+ get: function () { return semanticConventions.ATTR_SERVICE_NAME; }
74
+ });
75
+ Object.defineProperty(exports, "resourceFromAttributes", {
76
+ enumerable: true,
77
+ get: function () { return resources.resourceFromAttributes; }
78
+ });
79
+ Object.defineProperty(exports, "OTLPHttpExporter", {
80
+ enumerable: true,
81
+ get: function () { return exporterTraceOtlpHttp.OTLPTraceExporter; }
82
+ });
83
+ Object.defineProperty(exports, "OTLPGrpcExporter", {
84
+ enumerable: true,
85
+ get: function () { return exporterTraceOtlpGrpc.OTLPTraceExporter; }
86
+ });
87
+ Object.defineProperty(exports, "AlwaysOffSampler", {
88
+ enumerable: true,
89
+ get: function () { return sdkTraceBase.AlwaysOffSampler; }
90
+ });
91
+ Object.defineProperty(exports, "AlwaysOnSampler", {
92
+ enumerable: true,
93
+ get: function () { return sdkTraceBase.AlwaysOnSampler; }
94
+ });
95
+ Object.defineProperty(exports, "ParentBasedSampler", {
96
+ enumerable: true,
97
+ get: function () { return sdkTraceBase.ParentBasedSampler; }
98
+ });
99
+ Object.defineProperty(exports, "TraceIdRatioBasedSampler", {
100
+ enumerable: true,
101
+ get: function () { return sdkTraceBase.TraceIdRatioBasedSampler; }
102
+ });
103
+ exports.CompositeExporter = CompositeExporter;
@@ -0,0 +1,20 @@
1
+ export { NodeSDK } from '@opentelemetry/sdk-node';
2
+ export { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node';
3
+ export { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
4
+ export { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
5
+ export { resourceFromAttributes } from '@opentelemetry/resources';
6
+ export { OTLPTraceExporter as OTLPHttpExporter } from '@opentelemetry/exporter-trace-otlp-http';
7
+ export { OTLPTraceExporter as OTLPGrpcExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
8
+ import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
9
+ export { AlwaysOffSampler, AlwaysOnSampler, ParentBasedSampler, Sampler, TraceIdRatioBasedSampler } from '@opentelemetry/sdk-trace-base';
10
+ import { ExportResult } from '@opentelemetry/core';
11
+
12
+ declare class CompositeExporter implements SpanExporter {
13
+ private exporters;
14
+ constructor(exporters: SpanExporter[]);
15
+ export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
16
+ shutdown(): Promise<void>;
17
+ forceFlush(): Promise<void>;
18
+ }
19
+
20
+ export { CompositeExporter };
@@ -0,0 +1,20 @@
1
+ export { NodeSDK } from '@opentelemetry/sdk-node';
2
+ export { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node';
3
+ export { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
4
+ export { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
5
+ export { resourceFromAttributes } from '@opentelemetry/resources';
6
+ export { OTLPTraceExporter as OTLPHttpExporter } from '@opentelemetry/exporter-trace-otlp-http';
7
+ export { OTLPTraceExporter as OTLPGrpcExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
8
+ import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
9
+ export { AlwaysOffSampler, AlwaysOnSampler, ParentBasedSampler, Sampler, TraceIdRatioBasedSampler } from '@opentelemetry/sdk-trace-base';
10
+ import { ExportResult } from '@opentelemetry/core';
11
+
12
+ declare class CompositeExporter implements SpanExporter {
13
+ private exporters;
14
+ constructor(exporters: SpanExporter[]);
15
+ export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
16
+ shutdown(): Promise<void>;
17
+ forceFlush(): Promise<void>;
18
+ }
19
+
20
+ export { CompositeExporter };
@@ -0,0 +1,57 @@
1
+ export { NodeSDK } from '@opentelemetry/sdk-node';
2
+ export { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node';
3
+ export { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
4
+ export { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
5
+ export { resourceFromAttributes } from '@opentelemetry/resources';
6
+ export { OTLPTraceExporter as OTLPHttpExporter } from '@opentelemetry/exporter-trace-otlp-http';
7
+ export { OTLPTraceExporter as OTLPGrpcExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
8
+ export { AlwaysOffSampler, AlwaysOnSampler, ParentBasedSampler, TraceIdRatioBasedSampler } from '@opentelemetry/sdk-trace-base';
9
+ import { ExportResultCode } from '@opentelemetry/core';
10
+
11
+ var CompositeExporter = class {
12
+ exporters;
13
+ constructor(exporters) {
14
+ this.exporters = exporters;
15
+ }
16
+ export(spans, resultCallback) {
17
+ const telemetryTraceIds = new Set(
18
+ spans.filter((span) => {
19
+ const attrs = span.attributes || {};
20
+ const httpTarget = attrs["http.target"];
21
+ return httpTarget === "/api/telemetry";
22
+ }).map((span) => span.spanContext().traceId)
23
+ );
24
+ const filteredSpans = spans.filter((span) => !telemetryTraceIds.has(span.spanContext().traceId));
25
+ if (filteredSpans.length === 0) {
26
+ resultCallback({ code: ExportResultCode.SUCCESS });
27
+ return;
28
+ }
29
+ void Promise.all(
30
+ this.exporters.map(
31
+ (exporter) => new Promise((resolve) => {
32
+ if (exporter.export) {
33
+ exporter.export(filteredSpans, resolve);
34
+ } else {
35
+ resolve({ code: ExportResultCode.FAILED });
36
+ }
37
+ })
38
+ )
39
+ ).then((results) => {
40
+ const hasError = results.some((r) => r.code === ExportResultCode.FAILED);
41
+ resultCallback({
42
+ code: hasError ? ExportResultCode.FAILED : ExportResultCode.SUCCESS
43
+ });
44
+ }).catch((error) => {
45
+ console.error("[CompositeExporter] Export error:", error);
46
+ resultCallback({ code: ExportResultCode.FAILED, error });
47
+ });
48
+ }
49
+ shutdown() {
50
+ return Promise.all(this.exporters.map((e) => e.shutdown?.() ?? Promise.resolve())).then(() => void 0);
51
+ }
52
+ forceFlush() {
53
+ return Promise.all(this.exporters.map((e) => e.forceFlush?.() ?? Promise.resolve())).then(() => void 0);
54
+ }
55
+ };
56
+
57
+ export { CompositeExporter };