@mastra/core 1.15.0-alpha.2 → 1.15.0-alpha.3

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 (120) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/agent/index.cjs +8 -8
  3. package/dist/agent/index.js +1 -1
  4. package/dist/{chunk-MHTWFVXK.js → chunk-3QVIGF2C.js} +3 -3
  5. package/dist/{chunk-MHTWFVXK.js.map → chunk-3QVIGF2C.js.map} +1 -1
  6. package/dist/{chunk-ORHPD25N.cjs → chunk-4HBFSEH5.cjs} +7 -7
  7. package/dist/{chunk-ORHPD25N.cjs.map → chunk-4HBFSEH5.cjs.map} +1 -1
  8. package/dist/{chunk-Q64Z437G.cjs → chunk-5TR3QHRW.cjs} +15 -15
  9. package/dist/{chunk-Q64Z437G.cjs.map → chunk-5TR3QHRW.cjs.map} +1 -1
  10. package/dist/{chunk-OX63O3QG.cjs → chunk-6H4DIT5W.cjs} +5 -5
  11. package/dist/{chunk-OX63O3QG.cjs.map → chunk-6H4DIT5W.cjs.map} +1 -1
  12. package/dist/{chunk-4YKZNIK6.js → chunk-6OM5P63S.js} +4 -4
  13. package/dist/{chunk-4YKZNIK6.js.map → chunk-6OM5P63S.js.map} +1 -1
  14. package/dist/{chunk-YV5UMIRV.cjs → chunk-7FCDSKDP.cjs} +3 -3
  15. package/dist/{chunk-YV5UMIRV.cjs.map → chunk-7FCDSKDP.cjs.map} +1 -1
  16. package/dist/{chunk-7BM5LQHF.cjs → chunk-A5IWSJLJ.cjs} +75 -75
  17. package/dist/{chunk-7BM5LQHF.cjs.map → chunk-A5IWSJLJ.cjs.map} +1 -1
  18. package/dist/{chunk-KCZ3R5SF.js → chunk-AVLD4VHQ.js} +3 -3
  19. package/dist/{chunk-KCZ3R5SF.js.map → chunk-AVLD4VHQ.js.map} +1 -1
  20. package/dist/{chunk-ECAVJWAH.js → chunk-B5M72XCG.js} +4 -4
  21. package/dist/{chunk-ECAVJWAH.js.map → chunk-B5M72XCG.js.map} +1 -1
  22. package/dist/{chunk-X4RVX77L.cjs → chunk-BAUAKBM6.cjs} +185 -185
  23. package/dist/{chunk-X4RVX77L.cjs.map → chunk-BAUAKBM6.cjs.map} +1 -1
  24. package/dist/{chunk-ASVFCNLS.js → chunk-CJHZXD3U.js} +6 -6
  25. package/dist/{chunk-ASVFCNLS.js.map → chunk-CJHZXD3U.js.map} +1 -1
  26. package/dist/{chunk-NWC75FLU.cjs → chunk-CTFO2ENI.cjs} +53 -20
  27. package/dist/chunk-CTFO2ENI.cjs.map +1 -0
  28. package/dist/{chunk-EFYYAFWD.cjs → chunk-DYFEJA5J.cjs} +17 -17
  29. package/dist/{chunk-EFYYAFWD.cjs.map → chunk-DYFEJA5J.cjs.map} +1 -1
  30. package/dist/{chunk-SHQKQEG2.js → chunk-JEF7ZU43.js} +50 -18
  31. package/dist/chunk-JEF7ZU43.js.map +1 -0
  32. package/dist/{chunk-M5BDH7B4.cjs → chunk-K5NREJ7B.cjs} +6 -6
  33. package/dist/{chunk-M5BDH7B4.cjs.map → chunk-K5NREJ7B.cjs.map} +1 -1
  34. package/dist/{chunk-FNOAF2SZ.js → chunk-K6EF74Q4.js} +3 -3
  35. package/dist/{chunk-FNOAF2SZ.js.map → chunk-K6EF74Q4.js.map} +1 -1
  36. package/dist/{chunk-CTJLKJMO.js → chunk-M4AJQGAW.js} +5 -5
  37. package/dist/{chunk-CTJLKJMO.js.map → chunk-M4AJQGAW.js.map} +1 -1
  38. package/dist/{chunk-Z76WT6W3.js → chunk-MFB7BS3L.js} +4 -4
  39. package/dist/{chunk-Z76WT6W3.js.map → chunk-MFB7BS3L.js.map} +1 -1
  40. package/dist/{chunk-EAWVRIHS.js → chunk-O5KUYSYB.js} +3 -3
  41. package/dist/{chunk-EAWVRIHS.js.map → chunk-O5KUYSYB.js.map} +1 -1
  42. package/dist/{chunk-NWPRZZ2K.cjs → chunk-OFY7LQSG.cjs} +48 -48
  43. package/dist/{chunk-NWPRZZ2K.cjs.map → chunk-OFY7LQSG.cjs.map} +1 -1
  44. package/dist/{chunk-JIBMK2QP.js → chunk-SVHGG25E.js} +8 -8
  45. package/dist/{chunk-JIBMK2QP.js.map → chunk-SVHGG25E.js.map} +1 -1
  46. package/dist/{chunk-TJB7IK7N.cjs → chunk-TRLOXCPX.cjs} +5 -5
  47. package/dist/{chunk-TJB7IK7N.cjs.map → chunk-TRLOXCPX.cjs.map} +1 -1
  48. package/dist/{chunk-HIZDAENF.js → chunk-VPN66PYF.js} +3 -3
  49. package/dist/{chunk-HIZDAENF.js.map → chunk-VPN66PYF.js.map} +1 -1
  50. package/dist/{chunk-RFZB2PQE.cjs → chunk-XOBYVWML.cjs} +9 -9
  51. package/dist/{chunk-RFZB2PQE.cjs.map → chunk-XOBYVWML.cjs.map} +1 -1
  52. package/dist/datasets/index.cjs +11 -11
  53. package/dist/datasets/index.js +1 -1
  54. package/dist/docs/SKILL.md +1 -1
  55. package/dist/docs/assets/SOURCE_MAP.json +119 -119
  56. package/dist/docs/references/docs-workspace-overview.md +15 -0
  57. package/dist/docs/references/reference-workspace-filesystem.md +2 -0
  58. package/dist/docs/references/reference-workspace-local-filesystem.md +2 -0
  59. package/dist/evals/index.cjs +5 -5
  60. package/dist/evals/index.js +2 -2
  61. package/dist/evals/scoreTraces/index.cjs +3 -3
  62. package/dist/evals/scoreTraces/index.js +1 -1
  63. package/dist/harness/index.cjs +11 -11
  64. package/dist/harness/index.js +6 -6
  65. package/dist/index.cjs +2 -2
  66. package/dist/index.js +1 -1
  67. package/dist/llm/index.cjs +16 -16
  68. package/dist/llm/index.js +5 -5
  69. package/dist/loop/index.cjs +14 -14
  70. package/dist/loop/index.js +1 -1
  71. package/dist/mastra/index.cjs +2 -2
  72. package/dist/mastra/index.js +1 -1
  73. package/dist/memory/index.cjs +14 -14
  74. package/dist/memory/index.js +1 -1
  75. package/dist/models-dev-KSUL2WSE.js +3 -0
  76. package/dist/{models-dev-E6FRPGHV.js.map → models-dev-KSUL2WSE.js.map} +1 -1
  77. package/dist/models-dev-N3BB7QC6.cjs +12 -0
  78. package/dist/{models-dev-WIROJ2IM.cjs.map → models-dev-N3BB7QC6.cjs.map} +1 -1
  79. package/dist/netlify-5FZZLF2V.cjs +12 -0
  80. package/dist/{netlify-7IRBQ2BY.cjs.map → netlify-5FZZLF2V.cjs.map} +1 -1
  81. package/dist/netlify-YHUBX5AX.js +3 -0
  82. package/dist/{netlify-OAGRP6WY.js.map → netlify-YHUBX5AX.js.map} +1 -1
  83. package/dist/processor-provider/index.cjs +10 -10
  84. package/dist/processor-provider/index.js +1 -1
  85. package/dist/processors/index.cjs +42 -42
  86. package/dist/processors/index.js +1 -1
  87. package/dist/provider-registry-52PKE45P.js +3 -0
  88. package/dist/{provider-registry-2MHU2NP6.js.map → provider-registry-52PKE45P.js.map} +1 -1
  89. package/dist/provider-registry-YH7WKSYN.cjs +40 -0
  90. package/dist/{provider-registry-FINEGQHE.cjs.map → provider-registry-YH7WKSYN.cjs.map} +1 -1
  91. package/dist/relevance/index.cjs +3 -3
  92. package/dist/relevance/index.js +1 -1
  93. package/dist/stream/index.cjs +8 -8
  94. package/dist/stream/index.js +1 -1
  95. package/dist/tool-loop-agent/index.cjs +4 -4
  96. package/dist/tool-loop-agent/index.js +1 -1
  97. package/dist/workflows/evented/index.cjs +10 -10
  98. package/dist/workflows/evented/index.js +1 -1
  99. package/dist/workflows/index.cjs +24 -24
  100. package/dist/workflows/index.js +1 -1
  101. package/dist/workspace/errors.d.ts +5 -0
  102. package/dist/workspace/errors.d.ts.map +1 -1
  103. package/dist/workspace/filesystem/filesystem.d.ts +6 -0
  104. package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
  105. package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
  106. package/dist/workspace/index.cjs +71 -67
  107. package/dist/workspace/index.js +1 -1
  108. package/dist/workspace/tools/ast-edit.d.ts.map +1 -1
  109. package/dist/workspace/tools/edit-file.d.ts.map +1 -1
  110. package/dist/workspace/tools/tools.d.ts.map +1 -1
  111. package/dist/workspace/tools/write-file.d.ts.map +1 -1
  112. package/package.json +5 -5
  113. package/dist/chunk-NWC75FLU.cjs.map +0 -1
  114. package/dist/chunk-SHQKQEG2.js.map +0 -1
  115. package/dist/models-dev-E6FRPGHV.js +0 -3
  116. package/dist/models-dev-WIROJ2IM.cjs +0 -12
  117. package/dist/netlify-7IRBQ2BY.cjs +0 -12
  118. package/dist/netlify-OAGRP6WY.js +0 -3
  119. package/dist/provider-registry-2MHU2NP6.js +0 -3
  120. package/dist/provider-registry-FINEGQHE.cjs +0 -40
@@ -158,6 +158,18 @@ var FileReadRequiredError = class extends FilesystemError {
158
158
  this.name = "FileReadRequiredError";
159
159
  }
160
160
  };
161
+ var StaleFileError = class extends FilesystemError {
162
+ constructor(path7, expectedMtime, actualMtime) {
163
+ super(
164
+ `File was modified externally: ${path7} (expected mtime ${expectedMtime.toISOString()}, actual ${actualMtime.toISOString()})`,
165
+ "ESTALE",
166
+ path7
167
+ );
168
+ this.expectedMtime = expectedMtime;
169
+ this.actualMtime = actualMtime;
170
+ this.name = "StaleFileError";
171
+ }
172
+ };
161
173
  var FilesystemNotReadyError = class extends FilesystemError {
162
174
  constructor(id) {
163
175
  super(`Filesystem "${id}" is not ready. Call init() first or use ensureReady().`, "ENOTREADY", id);
@@ -1022,6 +1034,17 @@ var LocalFilesystem = class extends MastraFilesystem {
1022
1034
  const dir = nodePath__namespace.dirname(absolutePath);
1023
1035
  await fs2__namespace.mkdir(dir, { recursive: true });
1024
1036
  }
1037
+ if (options?.expectedMtime) {
1038
+ try {
1039
+ const currentStat = await fs2__namespace.stat(absolutePath);
1040
+ if (currentStat.mtime.getTime() !== options.expectedMtime.getTime()) {
1041
+ throw new StaleFileError(inputPath, options.expectedMtime, currentStat.mtime);
1042
+ }
1043
+ } catch (error) {
1044
+ if (error instanceof StaleFileError) throw error;
1045
+ if (!isEnoentError(error)) throw error;
1046
+ }
1047
+ }
1025
1048
  const writeFlag = options?.overwrite === false ? "wx" : "w";
1026
1049
  try {
1027
1050
  await fs2__namespace.writeFile(absolutePath, this.toBuffer(content), { flag: writeFlag });
@@ -1563,7 +1586,7 @@ function isLSPAvailable() {
1563
1586
  return jsonrpcModule !== null;
1564
1587
  }
1565
1588
  try {
1566
- const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-NWC75FLU.cjs', document.baseURI).href)));
1589
+ const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-CTFO2ENI.cjs', document.baseURI).href)));
1567
1590
  req.resolve("vscode-jsonrpc/node");
1568
1591
  req.resolve("vscode-languageserver-protocol");
1569
1592
  return true;
@@ -1577,7 +1600,7 @@ async function loadLSPDeps() {
1577
1600
  return { ...jsonrpcModule, ...lspProtocolModule };
1578
1601
  }
1579
1602
  try {
1580
- const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-NWC75FLU.cjs', document.baseURI).href)));
1603
+ const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-CTFO2ENI.cjs', document.baseURI).href)));
1581
1604
  const jsonrpc = req("vscode-jsonrpc/node");
1582
1605
  const protocol = req("vscode-languageserver-protocol");
1583
1606
  jsonrpcModule = {
@@ -6621,7 +6644,7 @@ function isAstGrepAvailable() {
6621
6644
  return astGrepModule !== null;
6622
6645
  }
6623
6646
  try {
6624
- const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-NWC75FLU.cjs', document.baseURI).href)));
6647
+ const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-CTFO2ENI.cjs', document.baseURI).href)));
6625
6648
  req.resolve("@ast-grep/napi");
6626
6649
  return true;
6627
6650
  } catch {
@@ -6895,7 +6918,10 @@ Pattern replace (for everything else):
6895
6918
  }
6896
6919
  const wasModified = modifiedContent !== content;
6897
6920
  if (wasModified) {
6898
- await filesystem.writeFile(path7, modifiedContent, { overwrite: true });
6921
+ await filesystem.writeFile(path7, modifiedContent, {
6922
+ overwrite: true,
6923
+ expectedMtime: context?.__expectedMtime
6924
+ });
6899
6925
  }
6900
6926
  if (!wasModified) {
6901
6927
  return `No changes made to ${path7} (${changes.join("; ")})`;
@@ -6954,7 +6980,10 @@ Usage:
6954
6980
  return `Cannot edit binary files. Use the write file tool instead.`;
6955
6981
  }
6956
6982
  const result = replaceString(content, old_string, new_string, replace_all);
6957
- await filesystem.writeFile(path7, result.content, { overwrite: true });
6983
+ await filesystem.writeFile(path7, result.content, {
6984
+ overwrite: true,
6985
+ expectedMtime: context?.__expectedMtime
6986
+ });
6958
6987
  let output = `Replaced ${result.replacements} occurrence${result.replacements !== 1 ? "s" : ""} in ${path7}`;
6959
6988
  output += await getEditDiagnosticsText(workspace, path7, result.content);
6960
6989
  return output;
@@ -7836,7 +7865,10 @@ var writeFileTool = chunkNQXA2BUF_cjs.createTool({
7836
7865
  if (filesystem.readOnly) {
7837
7866
  throw new WorkspaceReadOnlyError("write_file");
7838
7867
  }
7839
- await filesystem.writeFile(path7, content, { overwrite });
7868
+ await filesystem.writeFile(path7, content, {
7869
+ overwrite,
7870
+ expectedMtime: context?.__expectedMtime
7871
+ });
7840
7872
  const size = Buffer.byteLength(content, "utf-8");
7841
7873
  let output = `Wrote ${size} bytes to ${path7}`;
7842
7874
  output += await getEditDiagnosticsText(workspace, path7, content);
@@ -7883,12 +7915,18 @@ function wrapWithReadTracker(tool, workspace, readTracker, config, mode) {
7883
7915
  return {
7884
7916
  ...tool,
7885
7917
  execute: async (input, context = {}) => {
7886
- if (mode === "write" && config.requireReadBeforeWrite) {
7918
+ if (mode === "write") {
7919
+ const record = readTracker.getReadRecord(input.path);
7920
+ if (record) {
7921
+ context = { ...context, __expectedMtime: record.modifiedAtRead };
7922
+ }
7887
7923
  try {
7888
7924
  const stat3 = await workspace.filesystem.stat(input.path);
7889
- const check = readTracker.needsReRead(input.path, stat3.modifiedAt);
7890
- if (check.needsReRead) {
7891
- throw new FileReadRequiredError(input.path, check.reason);
7925
+ if (config.requireReadBeforeWrite) {
7926
+ const check = readTracker.needsReRead(input.path, stat3.modifiedAt);
7927
+ if (check.needsReRead) {
7928
+ throw new FileReadRequiredError(input.path, check.reason);
7929
+ }
7892
7930
  }
7893
7931
  } catch (error) {
7894
7932
  if (!(error instanceof FileNotFoundError)) {
@@ -7926,19 +7964,13 @@ function createWorkspaceTools(workspace) {
7926
7964
  const toolsConfig = workspace.getToolsConfig();
7927
7965
  const isReadOnly = workspace.filesystem?.readOnly ?? false;
7928
7966
  const writeLock = new InMemoryFileWriteLock();
7929
- let readTracker;
7930
- const writeFileConfig = resolveToolConfig(toolsConfig, WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE);
7931
- const editFileConfig = resolveToolConfig(toolsConfig, WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE);
7932
- const astEditConfig = resolveToolConfig(toolsConfig, WORKSPACE_TOOLS.FILESYSTEM.AST_EDIT);
7933
- if (writeFileConfig.requireReadBeforeWrite || editFileConfig.requireReadBeforeWrite || astEditConfig.requireReadBeforeWrite) {
7934
- readTracker = new InMemoryFileReadTracker();
7935
- }
7967
+ const readTracker = new InMemoryFileReadTracker();
7936
7968
  const addTool = (name, tool, opts) => {
7937
7969
  const config = resolveToolConfig(toolsConfig, name);
7938
7970
  if (!config.enabled) return;
7939
7971
  if (opts?.requireWrite && isReadOnly) return;
7940
7972
  let wrapped = { ...tool, requireApproval: config.requireApproval };
7941
- if (readTracker && opts?.readTrackerMode) {
7973
+ if (opts?.readTrackerMode) {
7942
7974
  wrapped = wrapWithReadTracker(wrapped, workspace, readTracker, config, opts.readTrackerMode);
7943
7975
  }
7944
7976
  if (opts?.useWriteLock) {
@@ -8030,6 +8062,7 @@ exports.SandboxNotReadyError = SandboxNotReadyError;
8030
8062
  exports.SandboxProcessManager = SandboxProcessManager;
8031
8063
  exports.SandboxTimeoutError = SandboxTimeoutError;
8032
8064
  exports.SearchNotAvailableError = SearchNotAvailableError;
8065
+ exports.StaleFileError = StaleFileError;
8033
8066
  exports.VersionedSkillSource = VersionedSkillSource;
8034
8067
  exports.WORKSPACE_TOOLS = WORKSPACE_TOOLS;
8035
8068
  exports.WORKSPACE_TOOLS_PREFIX = WORKSPACE_TOOLS_PREFIX;
@@ -8065,5 +8098,5 @@ exports.requireWorkspace = requireWorkspace;
8065
8098
  exports.resolveToolConfig = resolveToolConfig;
8066
8099
  exports.searchTool = searchTool;
8067
8100
  exports.writeFileTool = writeFileTool;
8068
- //# sourceMappingURL=chunk-NWC75FLU.cjs.map
8069
- //# sourceMappingURL=chunk-NWC75FLU.cjs.map
8101
+ //# sourceMappingURL=chunk-CTFO2ENI.cjs.map
8102
+ //# sourceMappingURL=chunk-CTFO2ENI.cjs.map