@mastra/core 1.2.0-alpha.0 → 1.2.0
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.
- package/CHANGELOG.md +314 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +1 -1
- package/dist/agent/agent.d.ts +17 -2
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/merge/MessageMerger.d.ts +5 -0
- package/dist/agent/message-list/merge/MessageMerger.d.ts.map +1 -1
- package/dist/agent/message-list/message-list.d.ts +15 -0
- package/dist/agent/message-list/message-list.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +9 -8
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +4 -0
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +9 -7
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts +24 -14
- package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
- package/dist/{chunk-XVHK5IAO.cjs → chunk-3LRUJTH3.cjs} +50 -333
- package/dist/chunk-3LRUJTH3.cjs.map +1 -0
- package/dist/{chunk-2CVY7S66.js → chunk-4XLGMCCQ.js} +18 -21
- package/dist/chunk-4XLGMCCQ.js.map +1 -0
- package/dist/{chunk-HIP5W3LZ.js → chunk-57O4TPB3.js} +60 -4
- package/dist/chunk-57O4TPB3.js.map +1 -0
- package/dist/{chunk-FAJYC6PA.js → chunk-5HDIPOLV.js} +363 -104
- package/dist/chunk-5HDIPOLV.js.map +1 -0
- package/dist/{chunk-OAOMKZXU.cjs → chunk-AP3Z4EAP.cjs} +60 -56
- package/dist/chunk-AP3Z4EAP.cjs.map +1 -0
- package/dist/{chunk-I6PWV32C.cjs → chunk-AQHO4OC2.cjs} +517 -61
- package/dist/chunk-AQHO4OC2.cjs.map +1 -0
- package/dist/{chunk-W57QS6F6.cjs → chunk-ARQG4ZSD.cjs} +430 -168
- package/dist/chunk-ARQG4ZSD.cjs.map +1 -0
- package/dist/{chunk-AC63Y6KP.js → chunk-BP2TSCBW.js} +3 -3
- package/dist/chunk-BP2TSCBW.js.map +1 -0
- package/dist/{chunk-NS33UC72.js → chunk-ENCTSDWC.js} +104 -11
- package/dist/chunk-ENCTSDWC.js.map +1 -0
- package/dist/{chunk-66BWIF4S.js → chunk-EY3WXGUD.js} +43 -326
- package/dist/chunk-EY3WXGUD.js.map +1 -0
- package/dist/{chunk-IUODLQMU.cjs → chunk-G5NRZOPO.cjs} +60 -4
- package/dist/chunk-G5NRZOPO.cjs.map +1 -0
- package/dist/{chunk-22EV7GMK.cjs → chunk-HMCXNOF6.cjs} +105 -10
- package/dist/chunk-HMCXNOF6.cjs.map +1 -0
- package/dist/{chunk-EYUXOOSQ.cjs → chunk-HN2MSTR6.cjs} +130 -9
- package/dist/chunk-HN2MSTR6.cjs.map +1 -0
- package/dist/{chunk-7ALOYTDY.cjs → chunk-I66TMZJ3.cjs} +15 -6
- package/dist/chunk-I66TMZJ3.cjs.map +1 -0
- package/dist/{chunk-Y2SVKUOQ.cjs → chunk-JRJJ5VQE.cjs} +44 -3
- package/dist/chunk-JRJJ5VQE.cjs.map +1 -0
- package/dist/{chunk-CILDTRXD.js → chunk-MNWW2R3U.js} +42 -4
- package/dist/chunk-MNWW2R3U.js.map +1 -0
- package/dist/{chunk-FYMM4PKR.js → chunk-NRMSZFAU.js} +12 -8
- package/dist/chunk-NRMSZFAU.js.map +1 -0
- package/dist/{chunk-SPVI7HCP.js → chunk-NYC6PYZF.js} +6 -6
- package/dist/{chunk-SPVI7HCP.js.map → chunk-NYC6PYZF.js.map} +1 -1
- package/dist/{chunk-XS2MED4Y.js → chunk-P62OJXQ4.js} +129 -8
- package/dist/chunk-P62OJXQ4.js.map +1 -0
- package/dist/{chunk-USHB3SPM.js → chunk-PPAJGWVW.js} +5 -5
- package/dist/chunk-PPAJGWVW.js.map +1 -0
- package/dist/{chunk-DWD5DB6W.js → chunk-RUMXBL6P.js} +4 -4
- package/dist/{chunk-DWD5DB6W.js.map → chunk-RUMXBL6P.js.map} +1 -1
- package/dist/{chunk-KNPIRLQQ.cjs → chunk-SS4AZHZW.cjs} +21 -24
- package/dist/chunk-SS4AZHZW.cjs.map +1 -0
- package/dist/{chunk-4DDIPGB6.js → chunk-T6PRRKMW.js} +15 -6
- package/dist/chunk-T6PRRKMW.js.map +1 -0
- package/dist/{chunk-ODNSWEMV.cjs → chunk-VBOO4F4D.cjs} +8 -8
- package/dist/chunk-VBOO4F4D.cjs.map +1 -0
- package/dist/{chunk-MCI7M6AT.cjs → chunk-YL6ETQ5I.cjs} +7 -7
- package/dist/{chunk-MCI7M6AT.cjs.map → chunk-YL6ETQ5I.cjs.map} +1 -1
- package/dist/{chunk-STNSGW7W.cjs → chunk-YLODOPYM.cjs} +3 -3
- package/dist/chunk-YLODOPYM.cjs.map +1 -0
- package/dist/{chunk-BLXWTBLL.cjs → chunk-Z2OKCLGV.cjs} +18 -18
- package/dist/{chunk-BLXWTBLL.cjs.map → chunk-Z2OKCLGV.cjs.map} +1 -1
- package/dist/{chunk-OQPAOUDS.js → chunk-ZODRDMZ7.js} +508 -52
- package/dist/chunk-ZODRDMZ7.js.map +1 -0
- package/dist/docs/README.md +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/SOURCE_MAP.json +357 -330
- package/dist/docs/agents/01-overview.md +2 -2
- package/dist/docs/configuration.mdx/01-reference.md +20 -0
- package/dist/docs/evals/01-overview.md +5 -5
- package/dist/docs/evals/04-reference.md +84 -10
- package/dist/docs/mcp/01-overview.md +2 -2
- package/dist/docs/memory/02-storage.md +10 -0
- package/dist/docs/observability/01-overview.md +1 -1
- package/dist/docs/observability/03-overview.md +3 -3
- package/dist/docs/rag/01-overview.md +1 -1
- package/dist/docs/tools-mcp/01-mcp-overview.md +2 -2
- package/dist/docs/voice/01-overview.md +1 -1
- package/dist/docs/workflows/01-overview.md +5 -5
- package/dist/docs/workspace/01-overview.md +2 -3
- package/dist/editor/index.cjs +4 -0
- package/dist/editor/index.cjs.map +1 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +3 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/types.d.ts +64 -0
- package/dist/editor/types.d.ts.map +1 -0
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/features/index.cjs +1 -1
- package/dist/features/index.cjs.map +1 -1
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +1 -1
- package/dist/features/index.js.map +1 -1
- package/dist/index.cjs +7 -2
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/llm/index.cjs +18 -18
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/embedding-router.d.ts +3 -1
- package/dist/llm/model/embedding-router.d.ts.map +1 -1
- package/dist/llm/model/model.d.ts +2 -2
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +54 -2
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/network/index.d.ts +4 -4
- package/dist/loop/types.d.ts +6 -1
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +22 -22
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +15 -15
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +7 -7
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +22 -22
- package/dist/loop/workflows/schema.d.ts +30 -30
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +30 -132
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +23 -11
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +6 -1
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/mock.d.ts.map +1 -1
- package/dist/memory/types.d.ts +282 -0
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/models-dev-OQKVMEIT.cjs +12 -0
- package/dist/{models-dev-SOIECXXQ.cjs.map → models-dev-OQKVMEIT.cjs.map} +1 -1
- package/dist/models-dev-Z45JSLWD.js +3 -0
- package/dist/{models-dev-2HBSVUOS.js.map → models-dev-Z45JSLWD.js.map} +1 -1
- package/dist/processors/index.cjs +41 -41
- package/dist/processors/index.d.ts +38 -1
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/message-history.d.ts +16 -0
- package/dist/processors/memory/message-history.d.ts.map +1 -1
- package/dist/processors/processors/skills.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +17 -3
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +34 -34
- package/dist/provider-registry-NR7FXV2Q.cjs +40 -0
- package/dist/{provider-registry-ML2VWWLB.cjs.map → provider-registry-NR7FXV2Q.cjs.map} +1 -1
- package/dist/provider-registry-RPOTQNHI.js +3 -0
- package/dist/{provider-registry-K5L4DHRK.js.map → provider-registry-RPOTQNHI.js.map} +1 -1
- package/dist/provider-registry.json +126 -5
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +28 -16
- package/dist/storage/constants.d.ts +13 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/agents/base.d.ts.map +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +3 -1
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
- package/dist/storage/domains/memory/base.d.ts +62 -1
- package/dist/storage/domains/memory/base.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts +24 -2
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +50 -50
- package/dist/storage/domains/operations/inmemory.d.ts +5 -3
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +113 -101
- package/dist/storage/index.js +2 -2
- package/dist/storage/types.d.ts +203 -16
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/utils.cjs +23 -23
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/vector.d.ts +3 -1
- package/dist/vector/vector.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +2 -1
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +2 -2
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/dist/workspace/filesystem/index.d.ts +1 -0
- package/dist/workspace/filesystem/index.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +3 -2
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/mastra-filesystem.d.ts +65 -0
- package/dist/workspace/filesystem/mastra-filesystem.d.ts.map +1 -0
- package/dist/workspace/index.cjs +40 -32
- package/dist/workspace/index.d.ts +2 -0
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/sandbox/index.d.ts +1 -0
- package/dist/workspace/sandbox/index.d.ts.map +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts +3 -2
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +52 -0
- package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -0
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/dist/workspace/workspace.d.ts +21 -0
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/editor.d.ts +1 -0
- package/package.json +8 -8
- package/src/llm/model/provider-types.generated.d.ts +54 -2
- package/dist/chunk-22EV7GMK.cjs.map +0 -1
- package/dist/chunk-2CVY7S66.js.map +0 -1
- package/dist/chunk-4DDIPGB6.js.map +0 -1
- package/dist/chunk-66BWIF4S.js.map +0 -1
- package/dist/chunk-7ALOYTDY.cjs.map +0 -1
- package/dist/chunk-AC63Y6KP.js.map +0 -1
- package/dist/chunk-CILDTRXD.js.map +0 -1
- package/dist/chunk-EYUXOOSQ.cjs.map +0 -1
- package/dist/chunk-FAJYC6PA.js.map +0 -1
- package/dist/chunk-FYMM4PKR.js.map +0 -1
- package/dist/chunk-HIP5W3LZ.js.map +0 -1
- package/dist/chunk-I6PWV32C.cjs.map +0 -1
- package/dist/chunk-IUODLQMU.cjs.map +0 -1
- package/dist/chunk-KNPIRLQQ.cjs.map +0 -1
- package/dist/chunk-NS33UC72.js.map +0 -1
- package/dist/chunk-OAOMKZXU.cjs.map +0 -1
- package/dist/chunk-ODNSWEMV.cjs.map +0 -1
- package/dist/chunk-OQPAOUDS.js.map +0 -1
- package/dist/chunk-STNSGW7W.cjs.map +0 -1
- package/dist/chunk-USHB3SPM.js.map +0 -1
- package/dist/chunk-W57QS6F6.cjs.map +0 -1
- package/dist/chunk-XS2MED4Y.js.map +0 -1
- package/dist/chunk-XVHK5IAO.cjs.map +0 -1
- package/dist/chunk-Y2SVKUOQ.cjs.map +0 -1
- package/dist/models-dev-2HBSVUOS.js +0 -3
- package/dist/models-dev-SOIECXXQ.cjs +0 -12
- package/dist/provider-registry-K5L4DHRK.js +0 -3
- package/dist/provider-registry-ML2VWWLB.cjs +0 -40
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createTool } from './chunk-IW3BNL7A.js';
|
|
2
|
+
import { MastraBase } from './chunk-JIT2OY3X.js';
|
|
3
|
+
import { RegisteredLogger } from './chunk-X2WMFSPB.js';
|
|
2
4
|
import * as fs2 from 'fs/promises';
|
|
3
5
|
import * as nodePath from 'path';
|
|
4
6
|
import { constants } from 'fs';
|
|
@@ -113,6 +115,20 @@ var FileReadRequiredError = class extends FilesystemError {
|
|
|
113
115
|
}
|
|
114
116
|
};
|
|
115
117
|
|
|
118
|
+
// src/workspace/filesystem/mastra-filesystem.ts
|
|
119
|
+
var MastraFilesystem = class extends MastraBase {
|
|
120
|
+
constructor(options) {
|
|
121
|
+
super({ name: options.name, component: RegisteredLogger.WORKSPACE });
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// src/workspace/sandbox/mastra-sandbox.ts
|
|
126
|
+
var MastraSandbox = class extends MastraBase {
|
|
127
|
+
constructor(options) {
|
|
128
|
+
super({ name: options.name, component: RegisteredLogger.WORKSPACE });
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
116
132
|
// src/workspace/line-utils.ts
|
|
117
133
|
function extractLines(content, startLine, endLine) {
|
|
118
134
|
const allLines = content.split("\n");
|
|
@@ -1088,7 +1104,7 @@ async function fsStat(absolutePath, userPath) {
|
|
|
1088
1104
|
}
|
|
1089
1105
|
|
|
1090
1106
|
// src/workspace/filesystem/local-filesystem.ts
|
|
1091
|
-
var LocalFilesystem = class {
|
|
1107
|
+
var LocalFilesystem = class extends MastraFilesystem {
|
|
1092
1108
|
id;
|
|
1093
1109
|
name = "LocalFilesystem";
|
|
1094
1110
|
provider = "local";
|
|
@@ -1104,6 +1120,7 @@ var LocalFilesystem = class {
|
|
|
1104
1120
|
return this._basePath;
|
|
1105
1121
|
}
|
|
1106
1122
|
constructor(options) {
|
|
1123
|
+
super({ name: "LocalFilesystem" });
|
|
1107
1124
|
this.id = options.id ?? this.generateId();
|
|
1108
1125
|
this._basePath = nodePath.resolve(options.basePath);
|
|
1109
1126
|
this._contained = options.contained ?? true;
|
|
@@ -1187,6 +1204,7 @@ var LocalFilesystem = class {
|
|
|
1187
1204
|
}
|
|
1188
1205
|
}
|
|
1189
1206
|
async readFile(inputPath, options) {
|
|
1207
|
+
this.logger.debug("Reading file", { path: inputPath, encoding: options?.encoding });
|
|
1190
1208
|
await this.ensureInitialized();
|
|
1191
1209
|
const absolutePath = this.resolvePath(inputPath);
|
|
1192
1210
|
await this.assertPathContained(absolutePath);
|
|
@@ -1208,6 +1226,8 @@ var LocalFilesystem = class {
|
|
|
1208
1226
|
}
|
|
1209
1227
|
}
|
|
1210
1228
|
async writeFile(inputPath, content, options) {
|
|
1229
|
+
const contentSize = Buffer.isBuffer(content) ? content.length : content.length;
|
|
1230
|
+
this.logger.debug("Writing file", { path: inputPath, size: contentSize, recursive: options?.recursive });
|
|
1211
1231
|
await this.ensureInitialized();
|
|
1212
1232
|
this.assertWritable("writeFile");
|
|
1213
1233
|
const absolutePath = this.resolvePath(inputPath);
|
|
@@ -1243,6 +1263,8 @@ var LocalFilesystem = class {
|
|
|
1243
1263
|
}
|
|
1244
1264
|
}
|
|
1245
1265
|
async appendFile(inputPath, content) {
|
|
1266
|
+
const contentSize = Buffer.isBuffer(content) ? content.length : content.length;
|
|
1267
|
+
this.logger.debug("Appending to file", { path: inputPath, size: contentSize });
|
|
1246
1268
|
await this.ensureInitialized();
|
|
1247
1269
|
this.assertWritable("appendFile");
|
|
1248
1270
|
const absolutePath = this.resolvePath(inputPath);
|
|
@@ -1252,6 +1274,7 @@ var LocalFilesystem = class {
|
|
|
1252
1274
|
await fs2.appendFile(absolutePath, this.toBuffer(content));
|
|
1253
1275
|
}
|
|
1254
1276
|
async deleteFile(inputPath, options) {
|
|
1277
|
+
this.logger.debug("Deleting file", { path: inputPath, force: options?.force });
|
|
1255
1278
|
await this.ensureInitialized();
|
|
1256
1279
|
this.assertWritable("deleteFile");
|
|
1257
1280
|
const absolutePath = this.resolvePath(inputPath);
|
|
@@ -1274,6 +1297,7 @@ var LocalFilesystem = class {
|
|
|
1274
1297
|
}
|
|
1275
1298
|
}
|
|
1276
1299
|
async copyFile(src, dest, options) {
|
|
1300
|
+
this.logger.debug("Copying file", { src, dest, recursive: options?.recursive });
|
|
1277
1301
|
await this.ensureInitialized();
|
|
1278
1302
|
this.assertWritable("copyFile");
|
|
1279
1303
|
const srcPath = this.resolvePath(src);
|
|
@@ -1332,6 +1356,7 @@ var LocalFilesystem = class {
|
|
|
1332
1356
|
}
|
|
1333
1357
|
}
|
|
1334
1358
|
async moveFile(src, dest, options) {
|
|
1359
|
+
this.logger.debug("Moving file", { src, dest, overwrite: options?.overwrite });
|
|
1335
1360
|
await this.ensureInitialized();
|
|
1336
1361
|
this.assertWritable("moveFile");
|
|
1337
1362
|
const srcPath = this.resolvePath(src);
|
|
@@ -1364,6 +1389,7 @@ var LocalFilesystem = class {
|
|
|
1364
1389
|
}
|
|
1365
1390
|
}
|
|
1366
1391
|
async mkdir(inputPath, options) {
|
|
1392
|
+
this.logger.debug("Creating directory", { path: inputPath, recursive: options?.recursive });
|
|
1367
1393
|
await this.ensureInitialized();
|
|
1368
1394
|
this.assertWritable("mkdir");
|
|
1369
1395
|
const absolutePath = this.resolvePath(inputPath);
|
|
@@ -1385,6 +1411,7 @@ var LocalFilesystem = class {
|
|
|
1385
1411
|
}
|
|
1386
1412
|
}
|
|
1387
1413
|
async rmdir(inputPath, options) {
|
|
1414
|
+
this.logger.debug("Removing directory", { path: inputPath, recursive: options?.recursive, force: options?.force });
|
|
1388
1415
|
await this.ensureInitialized();
|
|
1389
1416
|
this.assertWritable("rmdir");
|
|
1390
1417
|
const absolutePath = this.resolvePath(inputPath);
|
|
@@ -1417,6 +1444,7 @@ var LocalFilesystem = class {
|
|
|
1417
1444
|
}
|
|
1418
1445
|
}
|
|
1419
1446
|
async readdir(inputPath, options) {
|
|
1447
|
+
this.logger.debug("Reading directory", { path: inputPath, recursive: options?.recursive });
|
|
1420
1448
|
await this.ensureInitialized();
|
|
1421
1449
|
const absolutePath = this.resolvePath(inputPath);
|
|
1422
1450
|
await this.assertPathContained(absolutePath);
|
|
@@ -1505,12 +1533,15 @@ var LocalFilesystem = class {
|
|
|
1505
1533
|
};
|
|
1506
1534
|
}
|
|
1507
1535
|
async init() {
|
|
1536
|
+
this.logger.debug("Initializing filesystem", { basePath: this._basePath });
|
|
1508
1537
|
this.status = "starting";
|
|
1509
1538
|
try {
|
|
1510
1539
|
await fs2.mkdir(this._basePath, { recursive: true });
|
|
1511
1540
|
this.status = "running";
|
|
1541
|
+
this.logger.debug("Filesystem initialized", { basePath: this._basePath, status: this.status });
|
|
1512
1542
|
} catch (error) {
|
|
1513
1543
|
this.status = "error";
|
|
1544
|
+
this.logger.error("Failed to initialize filesystem", { basePath: this._basePath, error });
|
|
1514
1545
|
throw error;
|
|
1515
1546
|
}
|
|
1516
1547
|
}
|
|
@@ -2142,6 +2173,25 @@ var Workspace = class {
|
|
|
2142
2173
|
throw new WorkspaceError("vectorStore requires an embedder", "INVALID_SEARCH_CONFIG");
|
|
2143
2174
|
}
|
|
2144
2175
|
if (config.bm25 || config.vectorStore && config.embedder) {
|
|
2176
|
+
const buildIndexName = () => {
|
|
2177
|
+
const defaultName = `${this.id}_search`.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
2178
|
+
const indexName = config.searchIndexName ?? defaultName;
|
|
2179
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(indexName)) {
|
|
2180
|
+
throw new WorkspaceError(
|
|
2181
|
+
`Invalid searchIndexName: "${indexName}". Must start with a letter or underscore, and contain only letters, numbers, or underscores.`,
|
|
2182
|
+
"INVALID_SEARCH_CONFIG",
|
|
2183
|
+
this.id
|
|
2184
|
+
);
|
|
2185
|
+
}
|
|
2186
|
+
if (indexName.length > 63) {
|
|
2187
|
+
throw new WorkspaceError(
|
|
2188
|
+
`searchIndexName exceeds 63 characters (got ${indexName.length})`,
|
|
2189
|
+
"INVALID_SEARCH_CONFIG",
|
|
2190
|
+
this.id
|
|
2191
|
+
);
|
|
2192
|
+
}
|
|
2193
|
+
return indexName;
|
|
2194
|
+
};
|
|
2145
2195
|
this._searchEngine = new SearchEngine({
|
|
2146
2196
|
bm25: config.bm25 ? {
|
|
2147
2197
|
bm25: typeof config.bm25 === "object" ? config.bm25 : void 0
|
|
@@ -2149,7 +2199,7 @@ var Workspace = class {
|
|
|
2149
2199
|
vector: config.vectorStore && config.embedder ? {
|
|
2150
2200
|
vectorStore: config.vectorStore,
|
|
2151
2201
|
embedder: config.embedder,
|
|
2152
|
-
indexName:
|
|
2202
|
+
indexName: buildIndexName()
|
|
2153
2203
|
} : void 0
|
|
2154
2204
|
});
|
|
2155
2205
|
}
|
|
@@ -2422,6 +2472,22 @@ var Workspace = class {
|
|
|
2422
2472
|
instructions
|
|
2423
2473
|
};
|
|
2424
2474
|
}
|
|
2475
|
+
// ---------------------------------------------------------------------------
|
|
2476
|
+
// Logger Integration
|
|
2477
|
+
// ---------------------------------------------------------------------------
|
|
2478
|
+
/**
|
|
2479
|
+
* Set the logger for this workspace and propagate to providers.
|
|
2480
|
+
* Called by Mastra when the logger is set.
|
|
2481
|
+
* @internal
|
|
2482
|
+
*/
|
|
2483
|
+
__setLogger(logger) {
|
|
2484
|
+
if (this._fs instanceof MastraFilesystem) {
|
|
2485
|
+
this._fs.__setLogger(logger);
|
|
2486
|
+
}
|
|
2487
|
+
if (this._sandbox instanceof MastraSandbox) {
|
|
2488
|
+
this._sandbox.__setLogger(logger);
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2425
2491
|
};
|
|
2426
2492
|
|
|
2427
2493
|
// src/workspace/sandbox/sandbox.ts
|
|
@@ -2736,7 +2802,7 @@ Process terminated by ${signal}`;
|
|
|
2736
2802
|
});
|
|
2737
2803
|
});
|
|
2738
2804
|
}
|
|
2739
|
-
var LocalSandbox = class {
|
|
2805
|
+
var LocalSandbox = class extends MastraSandbox {
|
|
2740
2806
|
id;
|
|
2741
2807
|
name = "LocalSandbox";
|
|
2742
2808
|
provider = "local";
|
|
@@ -2779,6 +2845,7 @@ var LocalSandbox = class {
|
|
|
2779
2845
|
return detectIsolation();
|
|
2780
2846
|
}
|
|
2781
2847
|
constructor(options = {}) {
|
|
2848
|
+
super({ name: "LocalSandbox" });
|
|
2782
2849
|
this.id = options.id ?? this.generateId();
|
|
2783
2850
|
this._createdAt = /* @__PURE__ */ new Date();
|
|
2784
2851
|
this._workingDirectory = options.workingDirectory ?? nodePath.join(process.cwd(), ".sandbox");
|
|
@@ -2809,6 +2876,7 @@ var LocalSandbox = class {
|
|
|
2809
2876
|
};
|
|
2810
2877
|
}
|
|
2811
2878
|
async start() {
|
|
2879
|
+
this.logger.debug("Starting sandbox", { workingDirectory: this._workingDirectory, isolation: this._isolation });
|
|
2812
2880
|
this.status = "starting";
|
|
2813
2881
|
try {
|
|
2814
2882
|
await fs2.mkdir(this.workingDirectory, { recursive: true });
|
|
@@ -2834,15 +2902,19 @@ var LocalSandbox = class {
|
|
|
2834
2902
|
}
|
|
2835
2903
|
}
|
|
2836
2904
|
this.status = "running";
|
|
2905
|
+
this.logger.debug("Sandbox started", { workingDirectory: this._workingDirectory, status: this.status });
|
|
2837
2906
|
} catch (error) {
|
|
2838
2907
|
this.status = "error";
|
|
2908
|
+
this.logger.error("Failed to start sandbox", { workingDirectory: this._workingDirectory, error });
|
|
2839
2909
|
throw error;
|
|
2840
2910
|
}
|
|
2841
2911
|
}
|
|
2842
2912
|
async stop() {
|
|
2913
|
+
this.logger.debug("Stopping sandbox", { workingDirectory: this._workingDirectory });
|
|
2843
2914
|
this.status = "stopped";
|
|
2844
2915
|
}
|
|
2845
2916
|
async destroy() {
|
|
2917
|
+
this.logger.debug("Destroying sandbox", { workingDirectory: this._workingDirectory });
|
|
2846
2918
|
if (this._seatbeltProfilePath && !this._userProvidedProfilePath) {
|
|
2847
2919
|
try {
|
|
2848
2920
|
await fs2.unlink(this._seatbeltProfilePath);
|
|
@@ -2909,6 +2981,7 @@ var LocalSandbox = class {
|
|
|
2909
2981
|
});
|
|
2910
2982
|
}
|
|
2911
2983
|
async executeCommand(command, args = [], options = {}) {
|
|
2984
|
+
this.logger.debug("Executing command", { command, args, cwd: options.cwd ?? this.workingDirectory });
|
|
2912
2985
|
if (this.status !== "running") {
|
|
2913
2986
|
await this.start();
|
|
2914
2987
|
}
|
|
@@ -2922,20 +2995,28 @@ var LocalSandbox = class {
|
|
|
2922
2995
|
onStdout: options.onStdout,
|
|
2923
2996
|
onStderr: options.onStderr
|
|
2924
2997
|
});
|
|
2925
|
-
|
|
2998
|
+
const commandResult = {
|
|
2926
2999
|
success: result.exitCode === 0,
|
|
2927
3000
|
stdout: result.stdout,
|
|
2928
3001
|
stderr: result.stderr,
|
|
2929
3002
|
exitCode: result.exitCode,
|
|
2930
3003
|
executionTimeMs: Date.now() - startTime
|
|
2931
3004
|
};
|
|
3005
|
+
this.logger.info("Command completed", {
|
|
3006
|
+
command,
|
|
3007
|
+
exitCode: commandResult.exitCode,
|
|
3008
|
+
executionTimeMs: commandResult.executionTimeMs
|
|
3009
|
+
});
|
|
3010
|
+
return commandResult;
|
|
2932
3011
|
} catch (error) {
|
|
3012
|
+
const executionTimeMs = Date.now() - startTime;
|
|
3013
|
+
this.logger.error("Command failed", { command, error, executionTimeMs });
|
|
2933
3014
|
return {
|
|
2934
3015
|
success: false,
|
|
2935
3016
|
stdout: "",
|
|
2936
3017
|
stderr: error instanceof Error ? error.message : String(error),
|
|
2937
3018
|
exitCode: 1,
|
|
2938
|
-
executionTimeMs
|
|
3019
|
+
executionTimeMs
|
|
2939
3020
|
};
|
|
2940
3021
|
}
|
|
2941
3022
|
}
|
|
@@ -3098,7 +3179,7 @@ function createWorkspaceTools(workspace) {
|
|
|
3098
3179
|
if (readFileConfig.enabled) {
|
|
3099
3180
|
tools[WORKSPACE_TOOLS.FILESYSTEM.READ_FILE] = createTool({
|
|
3100
3181
|
id: WORKSPACE_TOOLS.FILESYSTEM.READ_FILE,
|
|
3101
|
-
description: "Read the contents of a file from the workspace filesystem.
|
|
3182
|
+
description: "Read the contents of a file from the workspace filesystem. Use offset/limit parameters to read specific line ranges for large files.",
|
|
3102
3183
|
requireApproval: readFileConfig.requireApproval,
|
|
3103
3184
|
inputSchema: z.object({
|
|
3104
3185
|
path: z.string().describe('The path to the file to read (e.g., "/data/config.json")'),
|
|
@@ -3201,7 +3282,13 @@ function createWorkspaceTools(workspace) {
|
|
|
3201
3282
|
if (!isReadOnly && editFileConfig.enabled) {
|
|
3202
3283
|
tools[WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE] = createTool({
|
|
3203
3284
|
id: WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE,
|
|
3204
|
-
description:
|
|
3285
|
+
description: `Edit a file by replacing specific text. The old_string must match exactly and be unique in the file.
|
|
3286
|
+
|
|
3287
|
+
Usage:
|
|
3288
|
+
- Read the file first to get the exact text to replace.
|
|
3289
|
+
- By default, ${WORKSPACE_TOOLS.FILESYSTEM.READ_FILE} output includes line number prefixes (e.g., " 1\u2192"). Ensure you preserve the exact indentation as it appears AFTER the arrow. Never include any part of the line number prefix in old_string or new_string.
|
|
3290
|
+
- Include enough surrounding context (multiple lines) to make old_string unique. If it still isn't unique, include more lines.
|
|
3291
|
+
- Use replace_all only when intentionally replacing all occurrences.`,
|
|
3205
3292
|
requireApproval: editFileConfig.requireApproval,
|
|
3206
3293
|
inputSchema: z.object({
|
|
3207
3294
|
path: z.string().describe("The path to the file to edit"),
|
|
@@ -3491,7 +3578,13 @@ Examples:
|
|
|
3491
3578
|
if (workspace.sandbox.executeCommand && executeCommandConfig.enabled) {
|
|
3492
3579
|
tools[WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND] = createTool({
|
|
3493
3580
|
id: WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND,
|
|
3494
|
-
description: `Execute a shell command in the workspace sandbox
|
|
3581
|
+
description: `Execute a shell command in the workspace sandbox.${pathInfo}
|
|
3582
|
+
|
|
3583
|
+
Usage:
|
|
3584
|
+
- Verify parent directories exist before running commands that create files or directories.
|
|
3585
|
+
- Always quote file paths that contain spaces (e.g., cd "/path/with spaces").
|
|
3586
|
+
- Commands timeout after 30 seconds by default. Use the timeout parameter for longer operations.
|
|
3587
|
+
- Use cwd to set the working directory, or commands run from the sandbox default.`,
|
|
3495
3588
|
requireApproval: executeCommandConfig.requireApproval,
|
|
3496
3589
|
inputSchema: z.object({
|
|
3497
3590
|
command: z.string().describe('The command to execute (e.g., "ls", "npm", "python")'),
|
|
@@ -3575,6 +3668,6 @@ Examples:
|
|
|
3575
3668
|
return tools;
|
|
3576
3669
|
}
|
|
3577
3670
|
|
|
3578
|
-
export { BM25Index, DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, FileReadRequiredError, FilesystemError, FilesystemNotAvailableError, IsDirectoryError, IsolationUnavailableError, LocalFilesystem, LocalSandbox, NotDirectoryError, PermissionError, SandboxError, SandboxExecutionError, SandboxFeatureNotSupportedError, SandboxNotAvailableError, SandboxNotReadyError, SandboxTimeoutError, SearchNotAvailableError, WORKSPACE_TOOLS, WORKSPACE_TOOLS_PREFIX, Workspace, WorkspaceError, WorkspaceNotReadyError, WorkspaceReadOnlyError, createWorkspaceTools, detectIsolation, extractLines, getRecommendedIsolation, isIsolationAvailable, resolveToolConfig };
|
|
3579
|
-
//# sourceMappingURL=chunk-
|
|
3580
|
-
//# sourceMappingURL=chunk-
|
|
3671
|
+
export { BM25Index, DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, FileReadRequiredError, FilesystemError, FilesystemNotAvailableError, IsDirectoryError, IsolationUnavailableError, LocalFilesystem, LocalSandbox, MastraFilesystem, MastraSandbox, NotDirectoryError, PermissionError, SandboxError, SandboxExecutionError, SandboxFeatureNotSupportedError, SandboxNotAvailableError, SandboxNotReadyError, SandboxTimeoutError, SearchNotAvailableError, WORKSPACE_TOOLS, WORKSPACE_TOOLS_PREFIX, Workspace, WorkspaceError, WorkspaceNotReadyError, WorkspaceReadOnlyError, createWorkspaceTools, detectIsolation, extractLines, getRecommendedIsolation, isIsolationAvailable, resolveToolConfig };
|
|
3672
|
+
//# sourceMappingURL=chunk-ENCTSDWC.js.map
|
|
3673
|
+
//# sourceMappingURL=chunk-ENCTSDWC.js.map
|