@mastra/core 0.8.2 → 0.8.3-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 (73) hide show
  1. package/{LICENSE → LICENSE.md} +3 -1
  2. package/README.md +4 -4
  3. package/dist/agent/index.cjs +2 -2
  4. package/dist/agent/index.d.cts +2 -1
  5. package/dist/agent/index.d.ts +2 -1
  6. package/dist/agent/index.js +1 -1
  7. package/dist/{base-CRsNpPj6.d.cts → base-Ca8Hlcj4.d.cts} +34 -16
  8. package/dist/{base-D0afZZ9D.d.ts → base-Cb5pwtMe.d.ts} +34 -16
  9. package/dist/chunk-3PBEAM6M.js +69 -0
  10. package/dist/{chunk-IUU6FRPI.cjs → chunk-B23KFOTM.cjs} +33 -14
  11. package/dist/{chunk-MP3UIX44.cjs → chunk-EFNSCE3V.cjs} +114 -99
  12. package/dist/{chunk-4RMSGSQN.js → chunk-EO7KZJF6.js} +1 -1
  13. package/dist/{chunk-6BT5XRRD.cjs → chunk-FDVSKYK2.cjs} +2 -2
  14. package/dist/{chunk-26NMSLXS.js → chunk-G2E5PLJV.js} +1 -1
  15. package/dist/{chunk-7I7AKQH3.cjs → chunk-IPQW4HAT.cjs} +2 -2
  16. package/dist/{chunk-BC5B4EGI.js → chunk-K5TZKHR7.js} +4 -2
  17. package/dist/chunk-LZQIMLJV.cjs +71 -0
  18. package/dist/{chunk-Q5Q3V2SQ.js → chunk-MUM4UGX3.js} +32 -13
  19. package/dist/{chunk-64VPB7ZD.cjs → chunk-PY3DCT4A.cjs} +4 -2
  20. package/dist/{chunk-FFOLLSHP.js → chunk-TOA2RYEW.js} +101 -86
  21. package/dist/di/index.cjs +10 -0
  22. package/dist/di/index.d.cts +52 -0
  23. package/dist/di/index.d.ts +52 -0
  24. package/dist/di/index.js +1 -0
  25. package/dist/eval/index.d.cts +2 -1
  26. package/dist/eval/index.d.ts +2 -1
  27. package/dist/index.cjs +49 -49
  28. package/dist/index.d.cts +3 -2
  29. package/dist/index.d.ts +3 -2
  30. package/dist/index.js +8 -8
  31. package/dist/integration/index.cjs +3 -3
  32. package/dist/integration/index.d.cts +2 -1
  33. package/dist/integration/index.d.ts +2 -1
  34. package/dist/integration/index.js +1 -1
  35. package/dist/llm/index.d.cts +2 -1
  36. package/dist/llm/index.d.ts +2 -1
  37. package/dist/mastra/index.d.cts +2 -1
  38. package/dist/mastra/index.d.ts +2 -1
  39. package/dist/memory/index.cjs +3 -3
  40. package/dist/memory/index.d.cts +2 -1
  41. package/dist/memory/index.d.ts +2 -1
  42. package/dist/memory/index.js +1 -1
  43. package/dist/network/index.cjs +4 -4
  44. package/dist/network/index.d.cts +2 -1
  45. package/dist/network/index.d.ts +2 -1
  46. package/dist/network/index.js +2 -2
  47. package/dist/relevance/index.cjs +4 -4
  48. package/dist/relevance/index.d.cts +2 -1
  49. package/dist/relevance/index.d.ts +2 -1
  50. package/dist/relevance/index.js +1 -1
  51. package/dist/server/index.d.cts +2 -1
  52. package/dist/server/index.d.ts +2 -1
  53. package/dist/storage/index.d.cts +2 -1
  54. package/dist/storage/index.d.ts +2 -1
  55. package/dist/storage/libsql/index.d.cts +2 -1
  56. package/dist/storage/libsql/index.d.ts +2 -1
  57. package/dist/telemetry/index.d.cts +2 -1
  58. package/dist/telemetry/index.d.ts +2 -1
  59. package/dist/tools/index.cjs +4 -4
  60. package/dist/tools/index.d.cts +2 -1
  61. package/dist/tools/index.d.ts +2 -1
  62. package/dist/tools/index.js +1 -1
  63. package/dist/utils.cjs +13 -13
  64. package/dist/utils.d.cts +3 -1
  65. package/dist/utils.d.ts +3 -1
  66. package/dist/utils.js +1 -1
  67. package/dist/voice/index.d.cts +3 -2
  68. package/dist/voice/index.d.ts +3 -2
  69. package/dist/workflows/index.cjs +23 -23
  70. package/dist/workflows/index.d.cts +3 -2
  71. package/dist/workflows/index.d.ts +3 -2
  72. package/dist/workflows/index.js +1 -1
  73. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-FFOLLSHP.js';
1
+ import { Agent } from './chunk-TOA2RYEW.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk64VPB7ZD_cjs = require('./chunk-64VPB7ZD.cjs');
3
+ var chunkPY3DCT4A_cjs = require('./chunk-PY3DCT4A.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 = chunk64VPB7ZD_cjs.createTool({
71
+ const tool = chunkPY3DCT4A_cjs.createTool({
72
72
  id: key,
73
73
  inputSchema: schemas[key] || zod.z.object({}),
74
74
  description: comment || fallbackComment,
@@ -1,3 +1,4 @@
1
+ import { Container } from './chunk-3PBEAM6M.js';
1
2
  import { createHash } from 'crypto';
2
3
  import { convertToCoreMessages } from 'ai';
3
4
  import jsonSchemaToZod from 'json-schema-to-zod';
@@ -221,7 +222,7 @@ function createLogMessageOptions({ agentName, toolName, tool, type }) {
221
222
  };
222
223
  }
223
224
  function createExecute(tool, options, logType) {
224
- const { logger, mastra: _mastra, memory: _memory, ...rest } = options;
225
+ const { logger, mastra: _mastra, memory: _memory, container, ...rest } = options;
225
226
  const { start, error } = createLogMessageOptions({
226
227
  agentName: options.agentName,
227
228
  toolName: options.name,
@@ -239,7 +240,8 @@ function createExecute(tool, options, logType) {
239
240
  resourceId: options.resourceId,
240
241
  mastra: options.mastra,
241
242
  memory: options.memory,
242
- runId: options.runId
243
+ runId: options.runId,
244
+ container: container ?? new Container()
243
245
  },
244
246
  execOptions
245
247
  ) ?? void 0;
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ // src/di/index.ts
4
+ var Container = class {
5
+ registry = /* @__PURE__ */ new Map();
6
+ constructor(iterable) {
7
+ this.registry = new Map(iterable);
8
+ }
9
+ /**
10
+ * set a value with strict typing if `Values` is a Record and the key exists in it.
11
+ */
12
+ set(key, value) {
13
+ this.registry.set(key, value);
14
+ }
15
+ /**
16
+ * Get a value with its type
17
+ */
18
+ get(key) {
19
+ return this.registry.get(key);
20
+ }
21
+ /**
22
+ * Check if a key exists in the container
23
+ */
24
+ has(key) {
25
+ return this.registry.has(key);
26
+ }
27
+ /**
28
+ * Delete a value by key
29
+ */
30
+ delete(key) {
31
+ return this.registry.delete(key);
32
+ }
33
+ /**
34
+ * Clear all values from the container
35
+ */
36
+ clear() {
37
+ this.registry.clear();
38
+ }
39
+ /**
40
+ * Get all keys in the container
41
+ */
42
+ keys() {
43
+ return this.registry.keys();
44
+ }
45
+ /**
46
+ * Get all values in the container
47
+ */
48
+ values() {
49
+ return this.registry.values();
50
+ }
51
+ /**
52
+ * Get all entries in the container
53
+ */
54
+ entries() {
55
+ return this.registry.entries();
56
+ }
57
+ /**
58
+ * Get the size of the container
59
+ */
60
+ size() {
61
+ return this.registry.size;
62
+ }
63
+ /**
64
+ * Execute a function for each entry in the container
65
+ */
66
+ forEach(callbackfn) {
67
+ this.registry.forEach(callbackfn);
68
+ }
69
+ };
70
+
71
+ exports.Container = Container;
@@ -1,6 +1,6 @@
1
1
  import { LibSQLVector } from './chunk-YVPTMEI4.js';
2
2
  import { DefaultProxyStorage } from './chunk-3FLA6LJB.js';
3
- import { deepMerge } from './chunk-BC5B4EGI.js';
3
+ import { deepMerge } from './chunk-K5TZKHR7.js';
4
4
  import { MastraBase } from './chunk-CLJQYXNM.js';
5
5
  import { existsSync } from 'fs';
6
6
  import { join } from 'path';
@@ -132,14 +132,27 @@ var MastraMemory = class extends MastraBase {
132
132
  };
133
133
  constructor(config) {
134
134
  super({ component: "MEMORY", name: config.name });
135
- this.storage = config.storage || new DefaultProxyStorage({
136
- config: {
137
- url: "file:memory.db"
138
- }
139
- });
140
- if (config.vector) {
141
- this.vector = config.vector;
135
+ if (config.options) {
136
+ this.threadConfig = this.getMergedThreadConfig(config.options);
137
+ }
138
+ if (config.storage) {
139
+ this.storage = config.storage;
142
140
  } else {
141
+ this.storage = new DefaultProxyStorage({
142
+ config: {
143
+ url: "file:memory.db"
144
+ }
145
+ });
146
+ }
147
+ const semanticRecallIsEnabled = this.threadConfig.semanticRecall !== false;
148
+ if (config.vector && semanticRecallIsEnabled) {
149
+ this.vector = config.vector;
150
+ } else if (
151
+ // if there's no configured vector store
152
+ // and the vector store hasn't been explicitly disabled with vector: false
153
+ config.vector !== false && // and semanticRecall is enabled
154
+ semanticRecallIsEnabled
155
+ ) {
143
156
  const oldDb = "memory-vector.db";
144
157
  const hasOldDb = existsSync(join(process.cwd(), oldDb)) || existsSync(join(process.cwd(), ".mastra", oldDb));
145
158
  const newDb = "memory.db";
@@ -154,12 +167,14 @@ var MastraMemory = class extends MastraBase {
154
167
  }
155
168
  if (config.embedder) {
156
169
  this.embedder = config.embedder;
157
- } else {
170
+ } else if (
171
+ // if there's no configured embedder
172
+ // and there's a vector store
173
+ typeof this.vector !== `undefined` && // and semanticRecall is enabled
174
+ semanticRecallIsEnabled
175
+ ) {
158
176
  this.embedder = defaultEmbedder("bge-small-en-v1.5");
159
177
  }
160
- if (config.options) {
161
- this.threadConfig = this.getMergedThreadConfig(config.options);
162
- }
163
178
  if (config.processors) {
164
179
  this.processors = config.processors;
165
180
  }
@@ -194,6 +209,9 @@ var MastraMemory = class extends MastraBase {
194
209
  const isDefault = dimensions === defaultDimensions;
195
210
  const usedDimensions = dimensions ?? defaultDimensions;
196
211
  const indexName = isDefault ? "memory_messages" : `memory_messages_${usedDimensions}`;
212
+ if (typeof this.vector === `undefined`) {
213
+ throw new Error(`Tried to create embedding index but no vector db is attached to this Memory instance.`);
214
+ }
197
215
  await this.vector.createIndex({
198
216
  indexName,
199
217
  dimension: usedDimensions
@@ -313,7 +331,8 @@ var MastraMemory = class extends MastraBase {
313
331
  id: message.id,
314
332
  role: message.role,
315
333
  content: textContent,
316
- toolInvocations
334
+ toolInvocations,
335
+ createdAt: message.createdAt
317
336
  });
318
337
  return obj;
319
338
  },
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var chunkLZQIMLJV_cjs = require('./chunk-LZQIMLJV.cjs');
3
4
  var crypto = require('crypto');
4
5
  var ai = require('ai');
5
6
  var jsonSchemaToZod = require('json-schema-to-zod');
@@ -227,7 +228,7 @@ function createLogMessageOptions({ agentName, toolName, tool, type }) {
227
228
  };
228
229
  }
229
230
  function createExecute(tool, options, logType) {
230
- const { logger, mastra: _mastra, memory: _memory, ...rest } = options;
231
+ const { logger, mastra: _mastra, memory: _memory, container, ...rest } = options;
231
232
  const { start, error } = createLogMessageOptions({
232
233
  agentName: options.agentName,
233
234
  toolName: options.name,
@@ -245,7 +246,8 @@ function createExecute(tool, options, logType) {
245
246
  resourceId: options.resourceId,
246
247
  mastra: options.mastra,
247
248
  memory: options.memory,
248
- runId: options.runId
249
+ runId: options.runId,
250
+ container: container ?? new chunkLZQIMLJV_cjs.Container()
249
251
  },
250
252
  execOptions
251
253
  ) ?? void 0;