@mastra/core 1.21.0 → 1.22.0-alpha.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 +29 -0
- 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/adapters/AIV5Adapter.d.ts.map +1 -1
- package/dist/agent/message-list/conversion/output-converter.d.ts.map +1 -1
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/message-list.d.ts.map +1 -1
- package/dist/{chunk-5WJWEAD2.cjs → chunk-2G5U5LCK.cjs} +148 -17
- package/dist/chunk-2G5U5LCK.cjs.map +1 -0
- package/dist/{chunk-CSD7PXFP.js → chunk-2VC36BDH.js} +5 -5
- package/dist/{chunk-CSD7PXFP.js.map → chunk-2VC36BDH.js.map} +1 -1
- package/dist/{chunk-7ONDK22Y.js → chunk-3RAYTSPI.js} +16 -9
- package/dist/chunk-3RAYTSPI.js.map +1 -0
- package/dist/{chunk-IZNWC32Y.js → chunk-46DASRFB.js} +4 -4
- package/dist/{chunk-IZNWC32Y.js.map → chunk-46DASRFB.js.map} +1 -1
- package/dist/{chunk-YPMF3QLA.cjs → chunk-AVRRH42W.cjs} +233 -233
- package/dist/chunk-AVRRH42W.cjs.map +1 -0
- package/dist/{chunk-QYCMMBOV.js → chunk-B7PS7GR7.js} +147 -17
- package/dist/{chunk-QYCMMBOV.js.map → chunk-B7PS7GR7.js.map} +1 -1
- package/dist/{chunk-6ZRIEGLG.cjs → chunk-BFOGUVFL.cjs} +5 -5
- package/dist/{chunk-6ZRIEGLG.cjs.map → chunk-BFOGUVFL.cjs.map} +1 -1
- package/dist/{chunk-UWYGTSWV.cjs → chunk-DOPULILR.cjs} +34 -30
- package/dist/chunk-DOPULILR.cjs.map +1 -0
- package/dist/{chunk-UDRSF2TK.cjs → chunk-DTQCQXSX.cjs} +55 -55
- package/dist/{chunk-UDRSF2TK.cjs.map → chunk-DTQCQXSX.cjs.map} +1 -1
- package/dist/{chunk-ZEZNT32H.js → chunk-EFXVHFAI.js} +12 -4
- package/dist/chunk-EFXVHFAI.js.map +1 -0
- package/dist/{chunk-UBRTW3SO.cjs → chunk-FHQY4G2O.cjs} +12 -3
- package/dist/chunk-FHQY4G2O.cjs.map +1 -0
- package/dist/{chunk-WG4GNZZZ.js → chunk-FXONBE4Y.js} +3 -3
- package/dist/{chunk-WG4GNZZZ.js.map → chunk-FXONBE4Y.js.map} +1 -1
- package/dist/{chunk-LOA2BVRK.js → chunk-HJBVUY76.js} +230 -230
- package/dist/chunk-HJBVUY76.js.map +1 -0
- package/dist/{chunk-NT2E64KG.cjs → chunk-HVE6QR4G.cjs} +6 -6
- package/dist/{chunk-NT2E64KG.cjs.map → chunk-HVE6QR4G.cjs.map} +1 -1
- package/dist/{chunk-3FASTXAM.cjs → chunk-JZBAUINL.cjs} +85 -77
- package/dist/chunk-JZBAUINL.cjs.map +1 -0
- package/dist/{chunk-OBXLCUSC.cjs → chunk-K7TAXUW5.cjs} +6 -6
- package/dist/{chunk-OBXLCUSC.cjs.map → chunk-K7TAXUW5.cjs.map} +1 -1
- package/dist/{chunk-56RUNELD.js → chunk-M5PKEDYH.js} +3 -3
- package/dist/{chunk-56RUNELD.js.map → chunk-M5PKEDYH.js.map} +1 -1
- package/dist/{chunk-NRA3BO5W.js → chunk-MOVQYN2F.js} +34 -30
- package/dist/chunk-MOVQYN2F.js.map +1 -0
- package/dist/{chunk-WI4KUV2M.js → chunk-NB435LXG.js} +4 -4
- package/dist/{chunk-WI4KUV2M.js.map → chunk-NB435LXG.js.map} +1 -1
- package/dist/{chunk-UOJUR3HB.cjs → chunk-O2FAC2JL.cjs} +186 -185
- package/dist/{chunk-UOJUR3HB.cjs.map → chunk-O2FAC2JL.cjs.map} +1 -1
- package/dist/{chunk-Z5ABABPJ.js → chunk-PBVPRLDI.js} +17 -10
- package/dist/chunk-PBVPRLDI.js.map +1 -0
- package/dist/{chunk-4ALVPSUM.cjs → chunk-PCDPQEYH.cjs} +7 -7
- package/dist/{chunk-4ALVPSUM.cjs.map → chunk-PCDPQEYH.cjs.map} +1 -1
- package/dist/{chunk-F3T776ZA.js → chunk-PJRKKSYW.js} +25 -13
- package/dist/chunk-PJRKKSYW.js.map +1 -0
- package/dist/{chunk-TLEMLJH7.cjs → chunk-QF4KRWYU.cjs} +64 -52
- package/dist/chunk-QF4KRWYU.cjs.map +1 -0
- package/dist/{chunk-KXITWMFN.js → chunk-RZISMMDM.js} +4 -4
- package/dist/{chunk-KXITWMFN.js.map → chunk-RZISMMDM.js.map} +1 -1
- package/dist/{chunk-HFH7JKN3.js → chunk-U63DZ6E6.js} +4 -4
- package/dist/{chunk-HFH7JKN3.js.map → chunk-U63DZ6E6.js.map} +1 -1
- package/dist/{chunk-63ZXVPM5.cjs → chunk-WTV62NHE.cjs} +10 -10
- package/dist/{chunk-63ZXVPM5.cjs.map → chunk-WTV62NHE.cjs.map} +1 -1
- package/dist/{chunk-P2JYPYF6.cjs → chunk-YYPOSWKA.cjs} +23 -16
- package/dist/chunk-YYPOSWKA.cjs.map +1 -0
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +263 -245
- package/dist/evals/index.cjs +5 -5
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/harness/index.cjs +11 -11
- package/dist/harness/index.js +6 -6
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +36 -20
- package/dist/llm/index.d.ts +5 -4
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/gateways/base.d.ts +5 -0
- package/dist/llm/model/gateways/base.d.ts.map +1 -1
- package/dist/llm/model/gateways/constants.d.ts +1 -0
- package/dist/llm/model/gateways/constants.d.ts.map +1 -1
- package/dist/llm/model/gateways/index.d.ts +1 -0
- package/dist/llm/model/gateways/index.d.ts.map +1 -1
- package/dist/llm/model/gateways/mastra.d.ts +25 -0
- package/dist/llm/model/gateways/mastra.d.ts.map +1 -0
- package/dist/llm/model/provider-registry.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +1 -0
- package/dist/llm/model/registry-generator.d.ts.map +1 -1
- package/dist/llm/model/router.d.ts +4 -2
- package/dist/llm/model/router.d.ts.map +1 -1
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mastra-2EQZYM7C.js +3 -0
- package/dist/mastra-2EQZYM7C.js.map +1 -0
- package/dist/mastra-XPBVZO54.cjs +12 -0
- package/dist/mastra-XPBVZO54.cjs.map +1 -0
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-DA5OEOGQ.js +3 -0
- package/dist/{models-dev-IF67OFXR.js.map → models-dev-DA5OEOGQ.js.map} +1 -1
- package/dist/models-dev-HDA3INHC.cjs +12 -0
- package/dist/{models-dev-ARAO7S6W.cjs.map → models-dev-HDA3INHC.cjs.map} +1 -1
- package/dist/netlify-6PWJPWSI.cjs +12 -0
- package/dist/{netlify-XPEVGT6A.cjs.map → netlify-6PWJPWSI.cjs.map} +1 -1
- package/dist/netlify-EENUHCAW.js +3 -0
- package/dist/{netlify-G5DNBXIP.js.map → netlify-EENUHCAW.js.map} +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +44 -44
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-TQS5D74S.js +3 -0
- package/dist/{provider-registry-MQVQ6NJP.js.map → provider-registry-TQS5D74S.js.map} +1 -1
- package/dist/provider-registry-VE7OCGGU.cjs +40 -0
- package/dist/{provider-registry-ZAJJQN5I.cjs.map → provider-registry-VE7OCGGU.cjs.map} +1 -1
- package/dist/{registry-generator-BRPCL2LG.js → registry-generator-QMLHG25G.js} +10 -3
- package/dist/registry-generator-QMLHG25G.js.map +1 -0
- package/dist/{registry-generator-PUWKZKVW.cjs → registry-generator-VNYH6GDH.cjs} +10 -3
- package/dist/registry-generator-VNYH6GDH.cjs.map +1 -0
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.cjs +74 -74
- package/dist/storage/index.js +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/dist/workspace/index.cjs +68 -68
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/sandbox/local-process-manager.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/llm/model/provider-types.generated.d.ts +1 -0
- package/dist/chunk-3FASTXAM.cjs.map +0 -1
- package/dist/chunk-5WJWEAD2.cjs.map +0 -1
- package/dist/chunk-7ONDK22Y.js.map +0 -1
- package/dist/chunk-F3T776ZA.js.map +0 -1
- package/dist/chunk-LOA2BVRK.js.map +0 -1
- package/dist/chunk-NRA3BO5W.js.map +0 -1
- package/dist/chunk-P2JYPYF6.cjs.map +0 -1
- package/dist/chunk-TLEMLJH7.cjs.map +0 -1
- package/dist/chunk-UBRTW3SO.cjs.map +0 -1
- package/dist/chunk-UWYGTSWV.cjs.map +0 -1
- package/dist/chunk-YPMF3QLA.cjs.map +0 -1
- package/dist/chunk-Z5ABABPJ.js.map +0 -1
- package/dist/chunk-ZEZNT32H.js.map +0 -1
- package/dist/models-dev-ARAO7S6W.cjs +0 -12
- package/dist/models-dev-IF67OFXR.js +0 -3
- package/dist/netlify-G5DNBXIP.js +0 -3
- package/dist/netlify-XPEVGT6A.cjs +0 -12
- package/dist/provider-registry-MQVQ6NJP.js +0 -3
- package/dist/provider-registry-ZAJJQN5I.cjs +0 -40
- package/dist/registry-generator-BRPCL2LG.js.map +0 -1
- package/dist/registry-generator-PUWKZKVW.cjs.map +0 -1
|
@@ -72,68 +72,68 @@ var WorkspaceReadOnlyError = class extends WorkspaceError {
|
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
var FilesystemError = class extends Error {
|
|
75
|
-
constructor(message, code,
|
|
75
|
+
constructor(message, code, path9) {
|
|
76
76
|
super(message);
|
|
77
77
|
this.code = code;
|
|
78
|
-
this.path =
|
|
78
|
+
this.path = path9;
|
|
79
79
|
this.name = "FilesystemError";
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
var FileNotFoundError = class extends FilesystemError {
|
|
83
|
-
constructor(
|
|
84
|
-
super(`File not found: ${
|
|
83
|
+
constructor(path9) {
|
|
84
|
+
super(`File not found: ${path9}`, "ENOENT", path9);
|
|
85
85
|
this.name = "FileNotFoundError";
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
var DirectoryNotFoundError = class extends FilesystemError {
|
|
89
|
-
constructor(
|
|
90
|
-
super(`Directory not found: ${
|
|
89
|
+
constructor(path9) {
|
|
90
|
+
super(`Directory not found: ${path9}`, "ENOENT", path9);
|
|
91
91
|
this.name = "DirectoryNotFoundError";
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
var FileExistsError = class extends FilesystemError {
|
|
95
|
-
constructor(
|
|
96
|
-
super(`File already exists: ${
|
|
95
|
+
constructor(path9) {
|
|
96
|
+
super(`File already exists: ${path9}`, "EEXIST", path9);
|
|
97
97
|
this.name = "FileExistsError";
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
var IsDirectoryError = class extends FilesystemError {
|
|
101
|
-
constructor(
|
|
102
|
-
super(`Path is a directory: ${
|
|
101
|
+
constructor(path9) {
|
|
102
|
+
super(`Path is a directory: ${path9}`, "EISDIR", path9);
|
|
103
103
|
this.name = "IsDirectoryError";
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
var NotDirectoryError = class extends FilesystemError {
|
|
107
|
-
constructor(
|
|
108
|
-
super(`Path is not a directory: ${
|
|
107
|
+
constructor(path9) {
|
|
108
|
+
super(`Path is not a directory: ${path9}`, "ENOTDIR", path9);
|
|
109
109
|
this.name = "NotDirectoryError";
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
var DirectoryNotEmptyError = class extends FilesystemError {
|
|
113
|
-
constructor(
|
|
114
|
-
super(`Directory not empty: ${
|
|
113
|
+
constructor(path9) {
|
|
114
|
+
super(`Directory not empty: ${path9}`, "ENOTEMPTY", path9);
|
|
115
115
|
this.name = "DirectoryNotEmptyError";
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
var PermissionError = class extends FilesystemError {
|
|
119
|
-
constructor(
|
|
120
|
-
super(`Permission denied: ${operation} on ${
|
|
119
|
+
constructor(path9, operation) {
|
|
120
|
+
super(`Permission denied: ${operation} on ${path9}`, "EACCES", path9);
|
|
121
121
|
this.operation = operation;
|
|
122
122
|
this.name = "PermissionError";
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
var FileReadRequiredError = class extends FilesystemError {
|
|
126
|
-
constructor(
|
|
127
|
-
super(reason, "EREAD_REQUIRED",
|
|
126
|
+
constructor(path9, reason) {
|
|
127
|
+
super(reason, "EREAD_REQUIRED", path9);
|
|
128
128
|
this.name = "FileReadRequiredError";
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
var StaleFileError = class extends FilesystemError {
|
|
132
|
-
constructor(
|
|
132
|
+
constructor(path9, expectedMtime, actualMtime) {
|
|
133
133
|
super(
|
|
134
|
-
`File was modified externally: ${
|
|
134
|
+
`File was modified externally: ${path9} (expected mtime ${expectedMtime.toISOString()}, actual ${actualMtime.toISOString()})`,
|
|
135
135
|
"ESTALE",
|
|
136
|
-
|
|
136
|
+
path9
|
|
137
137
|
);
|
|
138
138
|
this.expectedMtime = expectedMtime;
|
|
139
139
|
this.actualMtime = actualMtime;
|
|
@@ -172,8 +172,8 @@ var CompositeFilesystem = class {
|
|
|
172
172
|
constructor(config) {
|
|
173
173
|
this.id = `cfs-${Date.now().toString(36)}`;
|
|
174
174
|
this._mounts = /* @__PURE__ */ new Map();
|
|
175
|
-
for (const [
|
|
176
|
-
const normalized = this.normalizePath(
|
|
175
|
+
for (const [path9, fs6] of Object.entries(config.mounts)) {
|
|
176
|
+
const normalized = this.normalizePath(path9);
|
|
177
177
|
this._mounts.set(normalized, fs6);
|
|
178
178
|
}
|
|
179
179
|
if (this._mounts.size === 0) {
|
|
@@ -224,37 +224,37 @@ var CompositeFilesystem = class {
|
|
|
224
224
|
* Get the underlying filesystem for a given path.
|
|
225
225
|
* Returns undefined if the path doesn't resolve to any mount.
|
|
226
226
|
*/
|
|
227
|
-
getFilesystemForPath(
|
|
228
|
-
const resolved = this.resolveMount(
|
|
227
|
+
getFilesystemForPath(path9) {
|
|
228
|
+
const resolved = this.resolveMount(path9);
|
|
229
229
|
return resolved?.fs;
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
232
232
|
* Get the mount path for a given path.
|
|
233
233
|
* Returns undefined if the path doesn't resolve to any mount.
|
|
234
234
|
*/
|
|
235
|
-
getMountPathForPath(
|
|
236
|
-
const resolved = this.resolveMount(
|
|
235
|
+
getMountPathForPath(path9) {
|
|
236
|
+
const resolved = this.resolveMount(path9);
|
|
237
237
|
return resolved?.mountPath;
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* Resolve a workspace-relative path to an absolute disk path.
|
|
241
241
|
* Strips the mount prefix and delegates to the underlying filesystem.
|
|
242
242
|
*/
|
|
243
|
-
resolveAbsolutePath(
|
|
244
|
-
const r = this.resolveMount(
|
|
243
|
+
resolveAbsolutePath(path9) {
|
|
244
|
+
const r = this.resolveMount(path9);
|
|
245
245
|
if (!r) return void 0;
|
|
246
246
|
return r.fs.resolveAbsolutePath?.(r.fsPath);
|
|
247
247
|
}
|
|
248
|
-
normalizePath(
|
|
249
|
-
if (!
|
|
250
|
-
let n = posixPath.normalize(
|
|
248
|
+
normalizePath(path9) {
|
|
249
|
+
if (!path9 || path9 === "/" || path9 === ".") return "/";
|
|
250
|
+
let n = posixPath.normalize(path9);
|
|
251
251
|
if (n === ".") return "/";
|
|
252
252
|
if (!n.startsWith("/")) n = `/${n}`;
|
|
253
253
|
if (n.length > 1 && n.endsWith("/")) n = n.slice(0, -1);
|
|
254
254
|
return n;
|
|
255
255
|
}
|
|
256
|
-
resolveMount(
|
|
257
|
-
const normalized = this.normalizePath(
|
|
256
|
+
resolveMount(path9) {
|
|
257
|
+
const normalized = this.normalizePath(path9);
|
|
258
258
|
let best = null;
|
|
259
259
|
for (const [mountPath, fs6] of this._mounts) {
|
|
260
260
|
if (normalized === mountPath || normalized.startsWith(mountPath + "/")) {
|
|
@@ -269,8 +269,8 @@ var CompositeFilesystem = class {
|
|
|
269
269
|
else if (fsPath.startsWith("/")) fsPath = fsPath.slice(1);
|
|
270
270
|
return { fs: best.fs, fsPath, mountPath: best.mountPath };
|
|
271
271
|
}
|
|
272
|
-
getVirtualEntries(
|
|
273
|
-
const normalized = this.normalizePath(
|
|
272
|
+
getVirtualEntries(path9) {
|
|
273
|
+
const normalized = this.normalizePath(path9);
|
|
274
274
|
if (this.resolveMount(normalized)) return null;
|
|
275
275
|
const entriesMap = /* @__PURE__ */ new Map();
|
|
276
276
|
for (const [mountPath, fs6] of this._mounts.entries()) {
|
|
@@ -297,8 +297,8 @@ var CompositeFilesystem = class {
|
|
|
297
297
|
}
|
|
298
298
|
return entriesMap.size > 0 ? Array.from(entriesMap.values()) : null;
|
|
299
299
|
}
|
|
300
|
-
isVirtualPath(
|
|
301
|
-
const normalized = this.normalizePath(
|
|
300
|
+
isVirtualPath(path9) {
|
|
301
|
+
const normalized = this.normalizePath(path9);
|
|
302
302
|
if (normalized === "/" && !this._mounts.has("/")) return true;
|
|
303
303
|
for (const mountPath of this._mounts.keys()) {
|
|
304
304
|
if (mountPath.startsWith(normalized + "/")) return true;
|
|
@@ -309,9 +309,9 @@ var CompositeFilesystem = class {
|
|
|
309
309
|
* Assert that a filesystem is writable (not read-only).
|
|
310
310
|
* @throws {PermissionError} if the filesystem is read-only
|
|
311
311
|
*/
|
|
312
|
-
assertWritable(fs6,
|
|
312
|
+
assertWritable(fs6, path9, operation) {
|
|
313
313
|
if (fs6.readOnly) {
|
|
314
|
-
throw new PermissionError(
|
|
314
|
+
throw new PermissionError(path9, `${operation} (filesystem is read-only)`);
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
// ===========================================================================
|
|
@@ -345,27 +345,27 @@ var CompositeFilesystem = class {
|
|
|
345
345
|
}
|
|
346
346
|
this.status = "destroyed";
|
|
347
347
|
}
|
|
348
|
-
async readFile(
|
|
349
|
-
const r = this.resolveMount(
|
|
350
|
-
if (!r) throw new Error(`No mount for path: ${
|
|
348
|
+
async readFile(path9, options) {
|
|
349
|
+
const r = this.resolveMount(path9);
|
|
350
|
+
if (!r) throw new Error(`No mount for path: ${path9}`);
|
|
351
351
|
return r.fs.readFile(r.fsPath, options);
|
|
352
352
|
}
|
|
353
|
-
async writeFile(
|
|
354
|
-
const r = this.resolveMount(
|
|
355
|
-
if (!r) throw new Error(`No mount for path: ${
|
|
356
|
-
this.assertWritable(r.fs,
|
|
353
|
+
async writeFile(path9, content, options) {
|
|
354
|
+
const r = this.resolveMount(path9);
|
|
355
|
+
if (!r) throw new Error(`No mount for path: ${path9}`);
|
|
356
|
+
this.assertWritable(r.fs, path9, "writeFile");
|
|
357
357
|
return r.fs.writeFile(r.fsPath, content, options);
|
|
358
358
|
}
|
|
359
|
-
async appendFile(
|
|
360
|
-
const r = this.resolveMount(
|
|
361
|
-
if (!r) throw new Error(`No mount for path: ${
|
|
362
|
-
this.assertWritable(r.fs,
|
|
359
|
+
async appendFile(path9, content) {
|
|
360
|
+
const r = this.resolveMount(path9);
|
|
361
|
+
if (!r) throw new Error(`No mount for path: ${path9}`);
|
|
362
|
+
this.assertWritable(r.fs, path9, "appendFile");
|
|
363
363
|
return r.fs.appendFile(r.fsPath, content);
|
|
364
364
|
}
|
|
365
|
-
async deleteFile(
|
|
366
|
-
const r = this.resolveMount(
|
|
367
|
-
if (!r) throw new Error(`No mount for path: ${
|
|
368
|
-
this.assertWritable(r.fs,
|
|
365
|
+
async deleteFile(path9, options) {
|
|
366
|
+
const r = this.resolveMount(path9);
|
|
367
|
+
if (!r) throw new Error(`No mount for path: ${path9}`);
|
|
368
|
+
this.assertWritable(r.fs, path9, "deleteFile");
|
|
369
369
|
return r.fs.deleteFile(r.fsPath, options);
|
|
370
370
|
}
|
|
371
371
|
async copyFile(src, dest, options) {
|
|
@@ -393,35 +393,35 @@ var CompositeFilesystem = class {
|
|
|
393
393
|
await this.copyFile(src, dest, options);
|
|
394
394
|
await srcR.fs.deleteFile(srcR.fsPath);
|
|
395
395
|
}
|
|
396
|
-
async readdir(
|
|
397
|
-
const virtual = this.getVirtualEntries(
|
|
396
|
+
async readdir(path9, options) {
|
|
397
|
+
const virtual = this.getVirtualEntries(path9);
|
|
398
398
|
if (virtual) return virtual;
|
|
399
|
-
const r = this.resolveMount(
|
|
400
|
-
if (!r) throw new Error(`No mount for path: ${
|
|
399
|
+
const r = this.resolveMount(path9);
|
|
400
|
+
if (!r) throw new Error(`No mount for path: ${path9}`);
|
|
401
401
|
return r.fs.readdir(r.fsPath, options);
|
|
402
402
|
}
|
|
403
|
-
async mkdir(
|
|
404
|
-
const r = this.resolveMount(
|
|
405
|
-
if (!r) throw new Error(`No mount for path: ${
|
|
406
|
-
this.assertWritable(r.fs,
|
|
403
|
+
async mkdir(path9, options) {
|
|
404
|
+
const r = this.resolveMount(path9);
|
|
405
|
+
if (!r) throw new Error(`No mount for path: ${path9}`);
|
|
406
|
+
this.assertWritable(r.fs, path9, "mkdir");
|
|
407
407
|
return r.fs.mkdir(r.fsPath, options);
|
|
408
408
|
}
|
|
409
|
-
async rmdir(
|
|
410
|
-
const r = this.resolveMount(
|
|
411
|
-
if (!r) throw new Error(`No mount for path: ${
|
|
412
|
-
this.assertWritable(r.fs,
|
|
409
|
+
async rmdir(path9, options) {
|
|
410
|
+
const r = this.resolveMount(path9);
|
|
411
|
+
if (!r) throw new Error(`No mount for path: ${path9}`);
|
|
412
|
+
this.assertWritable(r.fs, path9, "rmdir");
|
|
413
413
|
return r.fs.rmdir(r.fsPath, options);
|
|
414
414
|
}
|
|
415
|
-
async exists(
|
|
416
|
-
if (this.isVirtualPath(
|
|
417
|
-
const r = this.resolveMount(
|
|
415
|
+
async exists(path9) {
|
|
416
|
+
if (this.isVirtualPath(path9)) return true;
|
|
417
|
+
const r = this.resolveMount(path9);
|
|
418
418
|
if (!r) return false;
|
|
419
419
|
if (r.fsPath === "") return true;
|
|
420
420
|
return r.fs.exists(r.fsPath);
|
|
421
421
|
}
|
|
422
|
-
async stat(
|
|
423
|
-
const normalized = this.normalizePath(
|
|
424
|
-
if (this.isVirtualPath(
|
|
422
|
+
async stat(path9) {
|
|
423
|
+
const normalized = this.normalizePath(path9);
|
|
424
|
+
if (this.isVirtualPath(path9)) {
|
|
425
425
|
const parts = normalized.split("/").filter(Boolean);
|
|
426
426
|
const now = /* @__PURE__ */ new Date();
|
|
427
427
|
return {
|
|
@@ -433,8 +433,8 @@ var CompositeFilesystem = class {
|
|
|
433
433
|
modifiedAt: now
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
|
-
const r = this.resolveMount(
|
|
437
|
-
if (!r) throw new Error(`No mount for path: ${
|
|
436
|
+
const r = this.resolveMount(path9);
|
|
437
|
+
if (!r) throw new Error(`No mount for path: ${path9}`);
|
|
438
438
|
if (r.fsPath === "") {
|
|
439
439
|
const parts = normalized.split("/").filter(Boolean);
|
|
440
440
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -449,9 +449,9 @@ var CompositeFilesystem = class {
|
|
|
449
449
|
}
|
|
450
450
|
return r.fs.stat(r.fsPath);
|
|
451
451
|
}
|
|
452
|
-
async isFile(
|
|
453
|
-
if (this.isVirtualPath(
|
|
454
|
-
const r = this.resolveMount(
|
|
452
|
+
async isFile(path9) {
|
|
453
|
+
if (this.isVirtualPath(path9)) return false;
|
|
454
|
+
const r = this.resolveMount(path9);
|
|
455
455
|
if (!r) return false;
|
|
456
456
|
try {
|
|
457
457
|
const stat3 = await r.fs.stat(r.fsPath);
|
|
@@ -460,9 +460,9 @@ var CompositeFilesystem = class {
|
|
|
460
460
|
return false;
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
|
-
async isDirectory(
|
|
464
|
-
if (this.isVirtualPath(
|
|
465
|
-
const r = this.resolveMount(
|
|
463
|
+
async isDirectory(path9) {
|
|
464
|
+
if (this.isVirtualPath(path9)) return true;
|
|
465
|
+
const r = this.resolveMount(path9);
|
|
466
466
|
if (!r) return false;
|
|
467
467
|
if (r.fsPath === "") return true;
|
|
468
468
|
try {
|
|
@@ -1347,35 +1347,35 @@ var LocalFilesystem = class extends MastraFilesystem {
|
|
|
1347
1347
|
};
|
|
1348
1348
|
var InMemoryFileReadTracker = class {
|
|
1349
1349
|
records = /* @__PURE__ */ new Map();
|
|
1350
|
-
recordRead(
|
|
1351
|
-
const normalizedPath = this.normalizePath(
|
|
1350
|
+
recordRead(path9, modifiedAt) {
|
|
1351
|
+
const normalizedPath = this.normalizePath(path9);
|
|
1352
1352
|
this.records.set(normalizedPath, {
|
|
1353
1353
|
path: normalizedPath,
|
|
1354
1354
|
readAt: /* @__PURE__ */ new Date(),
|
|
1355
1355
|
modifiedAtRead: modifiedAt
|
|
1356
1356
|
});
|
|
1357
1357
|
}
|
|
1358
|
-
getReadRecord(
|
|
1359
|
-
return this.records.get(this.normalizePath(
|
|
1358
|
+
getReadRecord(path9) {
|
|
1359
|
+
return this.records.get(this.normalizePath(path9));
|
|
1360
1360
|
}
|
|
1361
|
-
needsReRead(
|
|
1362
|
-
const record = this.getReadRecord(
|
|
1361
|
+
needsReRead(path9, currentModifiedAt) {
|
|
1362
|
+
const record = this.getReadRecord(path9);
|
|
1363
1363
|
if (!record) {
|
|
1364
1364
|
return {
|
|
1365
1365
|
needsReRead: true,
|
|
1366
|
-
reason: `File "${
|
|
1366
|
+
reason: `File "${path9}" has not been read. You must read a file before writing to it.`
|
|
1367
1367
|
};
|
|
1368
1368
|
}
|
|
1369
1369
|
if (currentModifiedAt.getTime() > record.modifiedAtRead.getTime()) {
|
|
1370
1370
|
return {
|
|
1371
1371
|
needsReRead: true,
|
|
1372
|
-
reason: `File "${
|
|
1372
|
+
reason: `File "${path9}" was modified since last read (read at: ${record.modifiedAtRead.toISOString()}, current: ${currentModifiedAt.toISOString()}). Please re-read the file to get the latest contents.`
|
|
1373
1373
|
};
|
|
1374
1374
|
}
|
|
1375
1375
|
return { needsReRead: false };
|
|
1376
1376
|
}
|
|
1377
|
-
clearReadRecord(
|
|
1378
|
-
this.records.delete(this.normalizePath(
|
|
1377
|
+
clearReadRecord(path9) {
|
|
1378
|
+
this.records.delete(this.normalizePath(path9));
|
|
1379
1379
|
}
|
|
1380
1380
|
clear() {
|
|
1381
1381
|
this.records.clear();
|
|
@@ -1397,10 +1397,10 @@ var InMemoryFileWriteLock = class {
|
|
|
1397
1397
|
withLock(filePath, fn) {
|
|
1398
1398
|
const key = this.normalizePath(filePath);
|
|
1399
1399
|
const currentQueue = this.queues.get(key) ?? Promise.resolve();
|
|
1400
|
-
let
|
|
1400
|
+
let resolve6;
|
|
1401
1401
|
let reject;
|
|
1402
1402
|
const resultPromise = new Promise((res, rej) => {
|
|
1403
|
-
|
|
1403
|
+
resolve6 = res;
|
|
1404
1404
|
reject = rej;
|
|
1405
1405
|
});
|
|
1406
1406
|
const queuePromise = currentQueue.catch(() => {
|
|
@@ -1417,7 +1417,7 @@ var InMemoryFileWriteLock = class {
|
|
|
1417
1417
|
})
|
|
1418
1418
|
]);
|
|
1419
1419
|
clearTimeout(timeoutId);
|
|
1420
|
-
|
|
1420
|
+
resolve6(result);
|
|
1421
1421
|
} catch (error) {
|
|
1422
1422
|
clearTimeout(timeoutId);
|
|
1423
1423
|
reject(error);
|
|
@@ -1463,10 +1463,10 @@ function createGlobMatcher(patterns, options) {
|
|
|
1463
1463
|
posix: true,
|
|
1464
1464
|
dot: options?.dot ?? false
|
|
1465
1465
|
});
|
|
1466
|
-
return (
|
|
1466
|
+
return (path9) => matcher(normalizeForMatch(path9));
|
|
1467
1467
|
}
|
|
1468
|
-
function matchGlob(
|
|
1469
|
-
return createGlobMatcher(pattern, options)(
|
|
1468
|
+
function matchGlob(path9, pattern, options) {
|
|
1469
|
+
return createGlobMatcher(pattern, options)(path9);
|
|
1470
1470
|
}
|
|
1471
1471
|
async function walkAll(readdir4, dir, depth, maxDepth) {
|
|
1472
1472
|
if (depth >= maxDepth) return [];
|
|
@@ -1778,7 +1778,7 @@ var LSPClient = class {
|
|
|
1778
1778
|
if (Date.now() - emptyReceivedAt >= settleMs) return currentDiagnostics;
|
|
1779
1779
|
}
|
|
1780
1780
|
}
|
|
1781
|
-
await new Promise((
|
|
1781
|
+
await new Promise((resolve6) => setTimeout(resolve6, 100));
|
|
1782
1782
|
}
|
|
1783
1783
|
return waitForChange ? initialDiagnostics || [] : this.diagnostics.get(uri) || [];
|
|
1784
1784
|
}
|
|
@@ -2112,8 +2112,8 @@ var LSPManager = class {
|
|
|
2112
2112
|
await this.fileLocks.get(filePath);
|
|
2113
2113
|
}
|
|
2114
2114
|
let release;
|
|
2115
|
-
const lockPromise = new Promise((
|
|
2116
|
-
release =
|
|
2115
|
+
const lockPromise = new Promise((resolve6) => {
|
|
2116
|
+
release = resolve6;
|
|
2117
2117
|
});
|
|
2118
2118
|
this.fileLocks.set(filePath, lockPromise);
|
|
2119
2119
|
return () => {
|
|
@@ -2613,7 +2613,7 @@ var LocalProcessHandle = class extends ProcessHandle {
|
|
|
2613
2613
|
timedOut = true;
|
|
2614
2614
|
void killProcessTree(this._numericPid, subprocess, "SIGTERM");
|
|
2615
2615
|
}, options.timeout) : void 0;
|
|
2616
|
-
this.waitPromise = new Promise((
|
|
2616
|
+
this.waitPromise = new Promise((resolve6) => {
|
|
2617
2617
|
subprocess.on("close", (code, signal) => {
|
|
2618
2618
|
if (timeoutId) clearTimeout(timeoutId);
|
|
2619
2619
|
if (timedOut) {
|
|
@@ -2624,7 +2624,7 @@ Process timed out after ${options.timeout}ms`;
|
|
|
2624
2624
|
} else {
|
|
2625
2625
|
this.exitCode = signal && code === null ? 128 : code ?? 0;
|
|
2626
2626
|
}
|
|
2627
|
-
|
|
2627
|
+
resolve6({
|
|
2628
2628
|
success: this.exitCode === 0,
|
|
2629
2629
|
exitCode: this.exitCode,
|
|
2630
2630
|
stdout: this.stdout,
|
|
@@ -2638,7 +2638,7 @@ Process timed out after ${options.timeout}ms`;
|
|
|
2638
2638
|
if (timeoutId) clearTimeout(timeoutId);
|
|
2639
2639
|
this.emitStderr(err.message);
|
|
2640
2640
|
this.exitCode = 1;
|
|
2641
|
-
|
|
2641
|
+
resolve6({
|
|
2642
2642
|
success: false,
|
|
2643
2643
|
exitCode: 1,
|
|
2644
2644
|
stdout: this.stdout,
|
|
@@ -2669,8 +2669,8 @@ Process timed out after ${options.timeout}ms`;
|
|
|
2669
2669
|
if (!this.subprocess.stdin) {
|
|
2670
2670
|
throw new Error(`Process ${this.pid} does not have stdin available`);
|
|
2671
2671
|
}
|
|
2672
|
-
return new Promise((
|
|
2673
|
-
this.subprocess.stdin.write(data, (err) => err ? reject(err) :
|
|
2672
|
+
return new Promise((resolve6, reject) => {
|
|
2673
|
+
this.subprocess.stdin.write(data, (err) => err ? reject(err) : resolve6());
|
|
2674
2674
|
});
|
|
2675
2675
|
}
|
|
2676
2676
|
};
|
|
@@ -2692,7 +2692,7 @@ async function killProcessTree(pid, subprocess, signal) {
|
|
|
2692
2692
|
}
|
|
2693
2693
|
var LocalProcessManager = class extends SandboxProcessManager {
|
|
2694
2694
|
async spawn(command, options = {}) {
|
|
2695
|
-
const cwd = options.cwd
|
|
2695
|
+
const cwd = options.cwd ? nodePath.resolve(this.sandbox.workingDirectory, options.cwd) : this.sandbox.workingDirectory;
|
|
2696
2696
|
const env = this.sandbox.buildEnv(options.env);
|
|
2697
2697
|
const wrapped = this.sandbox.wrapCommandForIsolation(command);
|
|
2698
2698
|
const baseOptions = {
|
|
@@ -2795,14 +2795,14 @@ var MountManager = class {
|
|
|
2795
2795
|
/**
|
|
2796
2796
|
* Get a mount entry by path.
|
|
2797
2797
|
*/
|
|
2798
|
-
get(
|
|
2799
|
-
return this._entries.get(
|
|
2798
|
+
get(path9) {
|
|
2799
|
+
return this._entries.get(path9);
|
|
2800
2800
|
}
|
|
2801
2801
|
/**
|
|
2802
2802
|
* Check if a mount exists at the given path.
|
|
2803
2803
|
*/
|
|
2804
|
-
has(
|
|
2805
|
-
return this._entries.has(
|
|
2804
|
+
has(path9) {
|
|
2805
|
+
return this._entries.has(path9);
|
|
2806
2806
|
}
|
|
2807
2807
|
// ---------------------------------------------------------------------------
|
|
2808
2808
|
// Entry Modification
|
|
@@ -2814,8 +2814,8 @@ var MountManager = class {
|
|
|
2814
2814
|
add(mounts) {
|
|
2815
2815
|
const paths = Object.keys(mounts);
|
|
2816
2816
|
this.logger.debug("Adding pending mounts", { count: paths.length, paths });
|
|
2817
|
-
for (const [
|
|
2818
|
-
this._entries.set(
|
|
2817
|
+
for (const [path9, filesystem] of Object.entries(mounts)) {
|
|
2818
|
+
this._entries.set(path9, {
|
|
2819
2819
|
filesystem,
|
|
2820
2820
|
state: "pending"
|
|
2821
2821
|
});
|
|
@@ -2825,8 +2825,8 @@ var MountManager = class {
|
|
|
2825
2825
|
* Update a mount entry's state.
|
|
2826
2826
|
* Creates the entry if it doesn't exist.
|
|
2827
2827
|
*/
|
|
2828
|
-
set(
|
|
2829
|
-
const existing = this._entries.get(
|
|
2828
|
+
set(path9, updates) {
|
|
2829
|
+
const existing = this._entries.get(path9);
|
|
2830
2830
|
if (existing) {
|
|
2831
2831
|
existing.state = updates.state;
|
|
2832
2832
|
if (updates.config) {
|
|
@@ -2837,7 +2837,7 @@ var MountManager = class {
|
|
|
2837
2837
|
existing.error = updates.error;
|
|
2838
2838
|
}
|
|
2839
2839
|
} else if (updates.filesystem) {
|
|
2840
|
-
this._entries.set(
|
|
2840
|
+
this._entries.set(path9, {
|
|
2841
2841
|
filesystem: updates.filesystem,
|
|
2842
2842
|
state: updates.state,
|
|
2843
2843
|
config: updates.config,
|
|
@@ -2845,14 +2845,14 @@ var MountManager = class {
|
|
|
2845
2845
|
error: updates.error
|
|
2846
2846
|
});
|
|
2847
2847
|
} else {
|
|
2848
|
-
this.logger.debug("set() called for unknown path without filesystem", { path:
|
|
2848
|
+
this.logger.debug("set() called for unknown path without filesystem", { path: path9 });
|
|
2849
2849
|
}
|
|
2850
2850
|
}
|
|
2851
2851
|
/**
|
|
2852
2852
|
* Delete a mount entry.
|
|
2853
2853
|
*/
|
|
2854
|
-
delete(
|
|
2855
|
-
return this._entries.delete(
|
|
2854
|
+
delete(path9) {
|
|
2855
|
+
return this._entries.delete(path9);
|
|
2856
2856
|
}
|
|
2857
2857
|
/**
|
|
2858
2858
|
* Clear all mount entries.
|
|
@@ -2873,7 +2873,7 @@ var MountManager = class {
|
|
|
2873
2873
|
return;
|
|
2874
2874
|
}
|
|
2875
2875
|
this.logger.debug("Processing pending mounts", { count: pendingCount });
|
|
2876
|
-
for (const [
|
|
2876
|
+
for (const [path9, entry] of this._entries) {
|
|
2877
2877
|
if (entry.state !== "pending") {
|
|
2878
2878
|
continue;
|
|
2879
2879
|
}
|
|
@@ -2883,7 +2883,7 @@ var MountManager = class {
|
|
|
2883
2883
|
try {
|
|
2884
2884
|
const hookResult = await this._onMount({
|
|
2885
2885
|
filesystem: entry.filesystem,
|
|
2886
|
-
mountPath:
|
|
2886
|
+
mountPath: path9,
|
|
2887
2887
|
config,
|
|
2888
2888
|
sandbox: this._sandbox,
|
|
2889
2889
|
workspace: this._workspace
|
|
@@ -2891,7 +2891,7 @@ var MountManager = class {
|
|
|
2891
2891
|
if (hookResult === false) {
|
|
2892
2892
|
entry.state = "unsupported";
|
|
2893
2893
|
entry.error = "Skipped by onMount hook";
|
|
2894
|
-
this.logger.debug("Mount skipped by onMount hook", { path:
|
|
2894
|
+
this.logger.debug("Mount skipped by onMount hook", { path: path9, provider: fsProvider });
|
|
2895
2895
|
continue;
|
|
2896
2896
|
}
|
|
2897
2897
|
if (hookResult && typeof hookResult === "object") {
|
|
@@ -2899,54 +2899,54 @@ var MountManager = class {
|
|
|
2899
2899
|
entry.state = "mounted";
|
|
2900
2900
|
entry.config = config;
|
|
2901
2901
|
entry.configHash = config ? this.hashConfig(config) : void 0;
|
|
2902
|
-
this.logger.info("Mount handled by onMount hook", { path:
|
|
2902
|
+
this.logger.info("Mount handled by onMount hook", { path: path9, provider: fsProvider });
|
|
2903
2903
|
} else {
|
|
2904
2904
|
entry.state = "error";
|
|
2905
2905
|
entry.error = hookResult.error ?? "Mount hook failed";
|
|
2906
|
-
this.logger.error("Mount hook failed", { path:
|
|
2906
|
+
this.logger.error("Mount hook failed", { path: path9, provider: fsProvider, error: entry.error });
|
|
2907
2907
|
}
|
|
2908
2908
|
continue;
|
|
2909
2909
|
}
|
|
2910
2910
|
} catch (err) {
|
|
2911
2911
|
entry.state = "error";
|
|
2912
2912
|
entry.error = `Mount hook error: ${String(err)}`;
|
|
2913
|
-
this.logger.error("Mount hook threw error", { path:
|
|
2913
|
+
this.logger.error("Mount hook threw error", { path: path9, provider: fsProvider, error: entry.error });
|
|
2914
2914
|
continue;
|
|
2915
2915
|
}
|
|
2916
2916
|
}
|
|
2917
2917
|
if (!config) {
|
|
2918
2918
|
entry.state = "unsupported";
|
|
2919
2919
|
entry.error = "Filesystem does not support mounting";
|
|
2920
|
-
this.logger.debug("Filesystem does not support mounting", { path:
|
|
2920
|
+
this.logger.debug("Filesystem does not support mounting", { path: path9, provider: fsProvider });
|
|
2921
2921
|
continue;
|
|
2922
2922
|
}
|
|
2923
2923
|
entry.config = config;
|
|
2924
2924
|
entry.configHash = this.hashConfig(config);
|
|
2925
2925
|
entry.state = "mounting";
|
|
2926
|
-
this.logger.debug("Mounting filesystem", { path:
|
|
2926
|
+
this.logger.debug("Mounting filesystem", { path: path9, provider: fsProvider, type: config.type });
|
|
2927
2927
|
try {
|
|
2928
|
-
const result = await this._mountFn(entry.filesystem,
|
|
2928
|
+
const result = await this._mountFn(entry.filesystem, path9);
|
|
2929
2929
|
if (result.success) {
|
|
2930
2930
|
entry.state = "mounted";
|
|
2931
|
-
this.logger.info("Mount successful", { path:
|
|
2931
|
+
this.logger.info("Mount successful", { path: path9, provider: fsProvider });
|
|
2932
2932
|
} else if (result.unavailable) {
|
|
2933
2933
|
entry.state = "unavailable";
|
|
2934
2934
|
entry.error = result.error ?? "FUSE tool not installed";
|
|
2935
|
-
this.logger.warn("FUSE mount unavailable", { path:
|
|
2935
|
+
this.logger.warn("FUSE mount unavailable", { path: path9, provider: fsProvider, error: entry.error });
|
|
2936
2936
|
} else {
|
|
2937
2937
|
entry.state = "error";
|
|
2938
2938
|
entry.error = result.error ?? "Mount failed";
|
|
2939
|
-
this.logger.error("Mount failed", { path:
|
|
2939
|
+
this.logger.error("Mount failed", { path: path9, provider: fsProvider, error: entry.error });
|
|
2940
2940
|
}
|
|
2941
2941
|
} catch (err) {
|
|
2942
2942
|
if (err instanceof MountToolNotFoundError) {
|
|
2943
2943
|
entry.state = "unavailable";
|
|
2944
2944
|
entry.error = String(err);
|
|
2945
|
-
this.logger.warn("FUSE mount unavailable", { path:
|
|
2945
|
+
this.logger.warn("FUSE mount unavailable", { path: path9, provider: fsProvider, error: entry.error });
|
|
2946
2946
|
} else {
|
|
2947
2947
|
entry.state = "error";
|
|
2948
2948
|
entry.error = String(err);
|
|
2949
|
-
this.logger.error("Mount threw error", { path:
|
|
2949
|
+
this.logger.error("Mount threw error", { path: path9, provider: fsProvider, error: entry.error });
|
|
2950
2950
|
}
|
|
2951
2951
|
}
|
|
2952
2952
|
}
|
|
@@ -2995,10 +2995,10 @@ var MountManager = class {
|
|
|
2995
2995
|
if (separatorIndex <= 0) {
|
|
2996
2996
|
return null;
|
|
2997
2997
|
}
|
|
2998
|
-
const
|
|
2998
|
+
const path9 = content.slice(0, separatorIndex);
|
|
2999
2999
|
const configHash = content.slice(separatorIndex + 1);
|
|
3000
|
-
if (!
|
|
3001
|
-
return { path:
|
|
3000
|
+
if (!path9 || !configHash) return null;
|
|
3001
|
+
return { path: path9, configHash };
|
|
3002
3002
|
}
|
|
3003
3003
|
/**
|
|
3004
3004
|
* Check if a config hash matches the expected hash for a mount path.
|
|
@@ -3488,11 +3488,11 @@ function buildBwrapCommand(command, workspacePath, config) {
|
|
|
3488
3488
|
}
|
|
3489
3489
|
bwrapArgs.push("--proc", "/proc");
|
|
3490
3490
|
bwrapArgs.push("--tmpfs", "/tmp");
|
|
3491
|
-
for (const
|
|
3492
|
-
bwrapArgs.push("--ro-bind-try",
|
|
3491
|
+
for (const path9 of DEFAULT_READONLY_BINDS) {
|
|
3492
|
+
bwrapArgs.push("--ro-bind-try", path9, path9);
|
|
3493
3493
|
}
|
|
3494
|
-
for (const
|
|
3495
|
-
bwrapArgs.push("--ro-bind",
|
|
3494
|
+
for (const path9 of config.readOnlyPaths ?? []) {
|
|
3495
|
+
bwrapArgs.push("--ro-bind", path9, path9);
|
|
3496
3496
|
}
|
|
3497
3497
|
if (config.allowSystemBinaries !== false) {
|
|
3498
3498
|
const nodePath4 = process.execPath;
|
|
@@ -3504,8 +3504,8 @@ function buildBwrapCommand(command, workspacePath, config) {
|
|
|
3504
3504
|
bwrapArgs.push("--ro-bind-try", "/snap", "/snap");
|
|
3505
3505
|
}
|
|
3506
3506
|
bwrapArgs.push("--bind", workspacePath, workspacePath);
|
|
3507
|
-
for (const
|
|
3508
|
-
bwrapArgs.push("--bind",
|
|
3507
|
+
for (const path9 of config.readWritePaths ?? []) {
|
|
3508
|
+
bwrapArgs.push("--bind", path9, path9);
|
|
3509
3509
|
}
|
|
3510
3510
|
bwrapArgs.push("--chdir", workspacePath);
|
|
3511
3511
|
bwrapArgs.push("--die-with-parent");
|
|
@@ -4915,18 +4915,18 @@ var VersionedSkillSource = class {
|
|
|
4915
4915
|
/**
|
|
4916
4916
|
* Normalize a path by stripping leading/trailing slashes and dots.
|
|
4917
4917
|
*/
|
|
4918
|
-
#normalizePath(
|
|
4919
|
-
let normalized =
|
|
4918
|
+
#normalizePath(path9) {
|
|
4919
|
+
let normalized = path9.replace(/^[./\\]+|[/\\]+$/g, "");
|
|
4920
4920
|
if (normalized === "") return "";
|
|
4921
4921
|
return normalized;
|
|
4922
4922
|
}
|
|
4923
|
-
async exists(
|
|
4924
|
-
const normalized = this.#normalizePath(
|
|
4923
|
+
async exists(path9) {
|
|
4924
|
+
const normalized = this.#normalizePath(path9);
|
|
4925
4925
|
if (this.#tree.entries[normalized]) return true;
|
|
4926
4926
|
return this.#directories.has(normalized);
|
|
4927
4927
|
}
|
|
4928
|
-
async stat(
|
|
4929
|
-
const normalized = this.#normalizePath(
|
|
4928
|
+
async stat(path9) {
|
|
4929
|
+
const normalized = this.#normalizePath(path9);
|
|
4930
4930
|
const name = normalized.split("/").pop() || normalized || ".";
|
|
4931
4931
|
const entry = this.#tree.entries[normalized];
|
|
4932
4932
|
if (entry) {
|
|
@@ -4948,27 +4948,27 @@ var VersionedSkillSource = class {
|
|
|
4948
4948
|
modifiedAt: this.#versionCreatedAt
|
|
4949
4949
|
};
|
|
4950
4950
|
}
|
|
4951
|
-
throw new Error(`Path not found in skill version tree: ${
|
|
4951
|
+
throw new Error(`Path not found in skill version tree: ${path9}`);
|
|
4952
4952
|
}
|
|
4953
|
-
async readFile(
|
|
4954
|
-
const normalized = this.#normalizePath(
|
|
4953
|
+
async readFile(path9) {
|
|
4954
|
+
const normalized = this.#normalizePath(path9);
|
|
4955
4955
|
const entry = this.#tree.entries[normalized];
|
|
4956
4956
|
if (!entry) {
|
|
4957
|
-
throw new Error(`File not found in skill version tree: ${
|
|
4957
|
+
throw new Error(`File not found in skill version tree: ${path9}`);
|
|
4958
4958
|
}
|
|
4959
4959
|
const blob = await this.#blobStore.get(entry.blobHash);
|
|
4960
4960
|
if (!blob) {
|
|
4961
|
-
throw new Error(`Blob not found for hash ${entry.blobHash} (file: ${
|
|
4961
|
+
throw new Error(`Blob not found for hash ${entry.blobHash} (file: ${path9})`);
|
|
4962
4962
|
}
|
|
4963
4963
|
if (entry.encoding === "base64") {
|
|
4964
4964
|
return Buffer.from(blob.content, "base64");
|
|
4965
4965
|
}
|
|
4966
4966
|
return blob.content;
|
|
4967
4967
|
}
|
|
4968
|
-
async readdir(
|
|
4969
|
-
const normalized = this.#normalizePath(
|
|
4968
|
+
async readdir(path9) {
|
|
4969
|
+
const normalized = this.#normalizePath(path9);
|
|
4970
4970
|
if (!this.#directories.has(normalized)) {
|
|
4971
|
-
throw new Error(`Directory not found in skill version tree: ${
|
|
4971
|
+
throw new Error(`Directory not found in skill version tree: ${path9}`);
|
|
4972
4972
|
}
|
|
4973
4973
|
const prefix = normalized === "" ? "" : normalized + "/";
|
|
4974
4974
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -5001,15 +5001,15 @@ var CompositeVersionedSkillSource = class {
|
|
|
5001
5001
|
this.#fallback = options?.fallback;
|
|
5002
5002
|
this.#fallbackSkills = new Set(options?.fallbackSkills ?? []);
|
|
5003
5003
|
}
|
|
5004
|
-
#normalizePath(
|
|
5005
|
-
return
|
|
5004
|
+
#normalizePath(path9) {
|
|
5005
|
+
return path9.replace(/^[./\\]+|[/\\]+$/g, "");
|
|
5006
5006
|
}
|
|
5007
5007
|
/**
|
|
5008
5008
|
* Route a path to the correct source.
|
|
5009
5009
|
* Returns the source and the remaining path within that source.
|
|
5010
5010
|
*/
|
|
5011
|
-
#routePath(
|
|
5012
|
-
const normalized = this.#normalizePath(
|
|
5011
|
+
#routePath(path9) {
|
|
5012
|
+
const normalized = this.#normalizePath(path9);
|
|
5013
5013
|
if (normalized === "") return null;
|
|
5014
5014
|
const segments = normalized.split("/");
|
|
5015
5015
|
const skillDir = segments[0];
|
|
@@ -5026,15 +5026,15 @@ var CompositeVersionedSkillSource = class {
|
|
|
5026
5026
|
}
|
|
5027
5027
|
return null;
|
|
5028
5028
|
}
|
|
5029
|
-
async exists(
|
|
5030
|
-
const normalized = this.#normalizePath(
|
|
5029
|
+
async exists(path9) {
|
|
5030
|
+
const normalized = this.#normalizePath(path9);
|
|
5031
5031
|
if (normalized === "") return true;
|
|
5032
|
-
const route = this.#routePath(
|
|
5032
|
+
const route = this.#routePath(path9);
|
|
5033
5033
|
if (!route) return false;
|
|
5034
5034
|
return route.source.exists(route.subPath);
|
|
5035
5035
|
}
|
|
5036
|
-
async stat(
|
|
5037
|
-
const normalized = this.#normalizePath(
|
|
5036
|
+
async stat(path9) {
|
|
5037
|
+
const normalized = this.#normalizePath(path9);
|
|
5038
5038
|
if (normalized === "") {
|
|
5039
5039
|
return {
|
|
5040
5040
|
name: ".",
|
|
@@ -5044,21 +5044,21 @@ var CompositeVersionedSkillSource = class {
|
|
|
5044
5044
|
modifiedAt: /* @__PURE__ */ new Date()
|
|
5045
5045
|
};
|
|
5046
5046
|
}
|
|
5047
|
-
const route = this.#routePath(
|
|
5047
|
+
const route = this.#routePath(path9);
|
|
5048
5048
|
if (!route) {
|
|
5049
|
-
throw new Error(`Path not found in composite skill source: ${
|
|
5049
|
+
throw new Error(`Path not found in composite skill source: ${path9}`);
|
|
5050
5050
|
}
|
|
5051
5051
|
return route.source.stat(route.subPath);
|
|
5052
5052
|
}
|
|
5053
|
-
async readFile(
|
|
5054
|
-
const route = this.#routePath(
|
|
5053
|
+
async readFile(path9) {
|
|
5054
|
+
const route = this.#routePath(path9);
|
|
5055
5055
|
if (!route) {
|
|
5056
|
-
throw new Error(`File not found in composite skill source: ${
|
|
5056
|
+
throw new Error(`File not found in composite skill source: ${path9}`);
|
|
5057
5057
|
}
|
|
5058
5058
|
return route.source.readFile(route.subPath);
|
|
5059
5059
|
}
|
|
5060
|
-
async readdir(
|
|
5061
|
-
const normalized = this.#normalizePath(
|
|
5060
|
+
async readdir(path9) {
|
|
5061
|
+
const normalized = this.#normalizePath(path9);
|
|
5062
5062
|
if (normalized === "") {
|
|
5063
5063
|
const entries = [];
|
|
5064
5064
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -5074,9 +5074,9 @@ var CompositeVersionedSkillSource = class {
|
|
|
5074
5074
|
}
|
|
5075
5075
|
return entries;
|
|
5076
5076
|
}
|
|
5077
|
-
const route = this.#routePath(
|
|
5077
|
+
const route = this.#routePath(path9);
|
|
5078
5078
|
if (!route) {
|
|
5079
|
-
throw new Error(`Directory not found in composite skill source: ${
|
|
5079
|
+
throw new Error(`Directory not found in composite skill source: ${path9}`);
|
|
5080
5080
|
}
|
|
5081
5081
|
return route.source.readdir(route.subPath);
|
|
5082
5082
|
}
|
|
@@ -5276,7 +5276,7 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
|
|
|
5276
5276
|
if (a.length !== b.length) return false;
|
|
5277
5277
|
const sortedA = [...a].sort();
|
|
5278
5278
|
const sortedB = [...b].sort();
|
|
5279
|
-
return sortedA.every((
|
|
5279
|
+
return sortedA.every((path9, i) => path9 === sortedB[i]);
|
|
5280
5280
|
}
|
|
5281
5281
|
// ===========================================================================
|
|
5282
5282
|
// Search
|
|
@@ -5882,9 +5882,9 @@ ${validation.errors.join("\n")}`);
|
|
|
5882
5882
|
/**
|
|
5883
5883
|
* Get parent path
|
|
5884
5884
|
*/
|
|
5885
|
-
#getParentPath(
|
|
5886
|
-
const lastSlash =
|
|
5887
|
-
return lastSlash > 0 ?
|
|
5885
|
+
#getParentPath(path9) {
|
|
5886
|
+
const lastSlash = path9.lastIndexOf("/");
|
|
5887
|
+
return lastSlash > 0 ? path9.substring(0, lastSlash) : "/";
|
|
5888
5888
|
}
|
|
5889
5889
|
};
|
|
5890
5890
|
function hashContent(content) {
|
|
@@ -6115,14 +6115,14 @@ function createSkillReadTool(skills) {
|
|
|
6115
6115
|
startLine: z.number().optional().describe("Starting line number (1-indexed). If omitted, starts from the beginning."),
|
|
6116
6116
|
endLine: z.number().optional().describe("Ending line number (1-indexed, inclusive). If omitted, reads to the end.")
|
|
6117
6117
|
}),
|
|
6118
|
-
execute: async ({ skillName, path:
|
|
6118
|
+
execute: async ({ skillName, path: path9, startLine, endLine }) => {
|
|
6119
6119
|
const resolved = await resolveSkill(skills, skillName);
|
|
6120
6120
|
if ("notFound" in resolved) return resolved.notFound;
|
|
6121
6121
|
const resolvedPath = resolved.skill.path;
|
|
6122
6122
|
let content = null;
|
|
6123
|
-
content = await skills.getReference(resolvedPath,
|
|
6124
|
-
if (content === null) content = await skills.getScript(resolvedPath,
|
|
6125
|
-
if (content === null) content = await skills.getAsset(resolvedPath,
|
|
6123
|
+
content = await skills.getReference(resolvedPath, path9);
|
|
6124
|
+
if (content === null) content = await skills.getScript(resolvedPath, path9);
|
|
6125
|
+
if (content === null) content = await skills.getAsset(resolvedPath, path9);
|
|
6126
6126
|
if (content === null) {
|
|
6127
6127
|
const refs = (await skills.listReferences(resolvedPath)).map((f) => `references/${f}`);
|
|
6128
6128
|
const scriptsList = (await skills.listScripts(resolvedPath)).map((f) => `scripts/${f}`);
|
|
@@ -6130,11 +6130,11 @@ function createSkillReadTool(skills) {
|
|
|
6130
6130
|
const allFiles = [...refs, ...scriptsList, ...assets];
|
|
6131
6131
|
const fileList = allFiles.length > 0 ? `
|
|
6132
6132
|
Available files: ${allFiles.join(", ")}` : "";
|
|
6133
|
-
return `File "${
|
|
6133
|
+
return `File "${path9}" not found in skill "${skillName}".${fileList}`;
|
|
6134
6134
|
}
|
|
6135
6135
|
const textContent = typeof content === "string" ? content : content.toString("utf-8");
|
|
6136
6136
|
if (textContent.slice(0, 1e3).includes("\0")) {
|
|
6137
|
-
const fullPath = `${resolved.skill.path}/${
|
|
6137
|
+
const fullPath = `${resolved.skill.path}/${path9}`;
|
|
6138
6138
|
const size = typeof content === "string" ? Buffer.byteLength(content) : content.length;
|
|
6139
6139
|
return `Binary file: ${fullPath} (${size} bytes)`;
|
|
6140
6140
|
}
|
|
@@ -6368,13 +6368,13 @@ var Workspace = class {
|
|
|
6368
6368
|
* @param options - Index options (metadata, type hints)
|
|
6369
6369
|
* @throws {SearchNotAvailableError} if search is not configured
|
|
6370
6370
|
*/
|
|
6371
|
-
async index(
|
|
6371
|
+
async index(path9, content, options) {
|
|
6372
6372
|
if (!this._searchEngine) {
|
|
6373
6373
|
throw new SearchNotAvailableError();
|
|
6374
6374
|
}
|
|
6375
6375
|
this.lastAccessedAt = /* @__PURE__ */ new Date();
|
|
6376
6376
|
const doc = {
|
|
6377
|
-
id:
|
|
6377
|
+
id: path9,
|
|
6378
6378
|
content,
|
|
6379
6379
|
metadata: {
|
|
6380
6380
|
type: options?.type,
|
|
@@ -7012,7 +7012,7 @@ Pattern replace (for everything else):
|
|
|
7012
7012
|
isDefault: z.boolean().optional().describe("Whether the first name is a default import")
|
|
7013
7013
|
}).optional().describe("Required for add-import transform. Specifies the module and names to import.")
|
|
7014
7014
|
}),
|
|
7015
|
-
execute: async ({ path:
|
|
7015
|
+
execute: async ({ path: path9, pattern, replacement, transform, targetName, newName, importSpec }, context) => {
|
|
7016
7016
|
const { workspace, filesystem } = requireFilesystem(context);
|
|
7017
7017
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.AST_EDIT);
|
|
7018
7018
|
if (filesystem.readOnly) {
|
|
@@ -7025,19 +7025,19 @@ Pattern replace (for everything else):
|
|
|
7025
7025
|
const { parse: parse2, Lang } = astGrep;
|
|
7026
7026
|
let content;
|
|
7027
7027
|
try {
|
|
7028
|
-
content = await filesystem.readFile(
|
|
7028
|
+
content = await filesystem.readFile(path9, { encoding: "utf-8" });
|
|
7029
7029
|
} catch (error) {
|
|
7030
7030
|
if (error instanceof FileNotFoundError) {
|
|
7031
|
-
return `File not found: ${
|
|
7031
|
+
return `File not found: ${path9}. Use the write file tool to create it first.`;
|
|
7032
7032
|
}
|
|
7033
7033
|
throw error;
|
|
7034
7034
|
}
|
|
7035
7035
|
if (typeof content !== "string") {
|
|
7036
7036
|
return `Cannot perform AST edits on binary files. Use the write file tool instead.`;
|
|
7037
7037
|
}
|
|
7038
|
-
const lang = getLanguageFromPath(
|
|
7038
|
+
const lang = getLanguageFromPath(path9, Lang);
|
|
7039
7039
|
if (!lang) {
|
|
7040
|
-
return `Unsupported file type for AST editing: ${
|
|
7040
|
+
return `Unsupported file type for AST editing: ${path9}`;
|
|
7041
7041
|
}
|
|
7042
7042
|
const ast = parse2(lang, content);
|
|
7043
7043
|
const root = ast.root();
|
|
@@ -7087,16 +7087,16 @@ Pattern replace (for everything else):
|
|
|
7087
7087
|
}
|
|
7088
7088
|
const wasModified = modifiedContent !== content;
|
|
7089
7089
|
if (wasModified) {
|
|
7090
|
-
await filesystem.writeFile(
|
|
7090
|
+
await filesystem.writeFile(path9, modifiedContent, {
|
|
7091
7091
|
overwrite: true,
|
|
7092
7092
|
expectedMtime: context?.__expectedMtime
|
|
7093
7093
|
});
|
|
7094
7094
|
}
|
|
7095
7095
|
if (!wasModified) {
|
|
7096
|
-
return `No changes made to ${
|
|
7096
|
+
return `No changes made to ${path9} (${changes.join("; ")})`;
|
|
7097
7097
|
}
|
|
7098
|
-
let output = `${
|
|
7099
|
-
output += await getEditDiagnosticsText(workspace,
|
|
7098
|
+
let output = `${path9}: ${changes.join("; ")}`;
|
|
7099
|
+
output += await getEditDiagnosticsText(workspace, path9, modifiedContent);
|
|
7100
7100
|
return output;
|
|
7101
7101
|
}
|
|
7102
7102
|
});
|
|
@@ -7107,19 +7107,19 @@ var deleteFileTool = createTool({
|
|
|
7107
7107
|
path: z.string().describe("The path to the file or directory to delete"),
|
|
7108
7108
|
recursive: z.boolean().optional().default(false).describe("If true, delete directories and their contents recursively. Required for non-empty directories.")
|
|
7109
7109
|
}),
|
|
7110
|
-
execute: async ({ path:
|
|
7110
|
+
execute: async ({ path: path9, recursive }, context) => {
|
|
7111
7111
|
const { filesystem } = requireFilesystem(context);
|
|
7112
7112
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.DELETE);
|
|
7113
7113
|
if (filesystem.readOnly) {
|
|
7114
7114
|
throw new WorkspaceReadOnlyError("delete");
|
|
7115
7115
|
}
|
|
7116
|
-
const stat3 = await filesystem.stat(
|
|
7116
|
+
const stat3 = await filesystem.stat(path9);
|
|
7117
7117
|
if (stat3.type === "directory") {
|
|
7118
|
-
await filesystem.rmdir(
|
|
7118
|
+
await filesystem.rmdir(path9, { recursive, force: recursive });
|
|
7119
7119
|
} else {
|
|
7120
|
-
await filesystem.deleteFile(
|
|
7120
|
+
await filesystem.deleteFile(path9);
|
|
7121
7121
|
}
|
|
7122
|
-
return `Deleted ${
|
|
7122
|
+
return `Deleted ${path9}`;
|
|
7123
7123
|
}
|
|
7124
7124
|
});
|
|
7125
7125
|
var editFileTool = createTool({
|
|
@@ -7137,24 +7137,24 @@ Usage:
|
|
|
7137
7137
|
new_string: z.string().describe("The text to replace old_string with"),
|
|
7138
7138
|
replace_all: z.boolean().optional().default(false).describe("If true, replace all occurrences. If false (default), old_string must be unique.")
|
|
7139
7139
|
}),
|
|
7140
|
-
execute: async ({ path:
|
|
7140
|
+
execute: async ({ path: path9, old_string, new_string, replace_all }, context) => {
|
|
7141
7141
|
const { workspace, filesystem } = requireFilesystem(context);
|
|
7142
7142
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE);
|
|
7143
7143
|
if (filesystem.readOnly) {
|
|
7144
7144
|
throw new WorkspaceReadOnlyError("edit_file");
|
|
7145
7145
|
}
|
|
7146
7146
|
try {
|
|
7147
|
-
const content = await filesystem.readFile(
|
|
7147
|
+
const content = await filesystem.readFile(path9, { encoding: "utf-8" });
|
|
7148
7148
|
if (typeof content !== "string") {
|
|
7149
7149
|
return `Cannot edit binary files. Use the write file tool instead.`;
|
|
7150
7150
|
}
|
|
7151
7151
|
const result = replaceString(content, old_string, new_string, replace_all);
|
|
7152
|
-
await filesystem.writeFile(
|
|
7152
|
+
await filesystem.writeFile(path9, result.content, {
|
|
7153
7153
|
overwrite: true,
|
|
7154
7154
|
expectedMtime: context?.__expectedMtime
|
|
7155
7155
|
});
|
|
7156
|
-
let output = `Replaced ${result.replacements} occurrence${result.replacements !== 1 ? "s" : ""} in ${
|
|
7157
|
-
output += await getEditDiagnosticsText(workspace,
|
|
7156
|
+
let output = `Replaced ${result.replacements} occurrence${result.replacements !== 1 ? "s" : ""} in ${path9}`;
|
|
7157
|
+
output += await getEditDiagnosticsText(workspace, path9, result.content);
|
|
7158
7158
|
return output;
|
|
7159
7159
|
} catch (error) {
|
|
7160
7160
|
if (error instanceof StringNotFoundError) {
|
|
@@ -7406,19 +7406,19 @@ var fileStatTool = createTool({
|
|
|
7406
7406
|
inputSchema: z.object({
|
|
7407
7407
|
path: z.string().describe("The path to check")
|
|
7408
7408
|
}),
|
|
7409
|
-
execute: async ({ path:
|
|
7409
|
+
execute: async ({ path: path9 }, context) => {
|
|
7410
7410
|
const { filesystem } = requireFilesystem(context);
|
|
7411
7411
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.FILE_STAT);
|
|
7412
7412
|
try {
|
|
7413
|
-
const stat3 = await filesystem.stat(
|
|
7413
|
+
const stat3 = await filesystem.stat(path9);
|
|
7414
7414
|
const modifiedAt = stat3.modifiedAt.toISOString();
|
|
7415
|
-
const parts = [`${
|
|
7415
|
+
const parts = [`${path9}`, `Type: ${stat3.type}`];
|
|
7416
7416
|
if (stat3.size !== void 0) parts.push(`Size: ${stat3.size} bytes`);
|
|
7417
7417
|
parts.push(`Modified: ${modifiedAt}`);
|
|
7418
7418
|
return parts.join(" ");
|
|
7419
7419
|
} catch (error) {
|
|
7420
7420
|
if (error instanceof FileNotFoundError) {
|
|
7421
|
-
return `${
|
|
7421
|
+
return `${path9}: not found`;
|
|
7422
7422
|
}
|
|
7423
7423
|
throw error;
|
|
7424
7424
|
}
|
|
@@ -7684,11 +7684,11 @@ var indexContentTool = createTool({
|
|
|
7684
7684
|
content: z.string().describe("The text content to index"),
|
|
7685
7685
|
metadata: z.record(z.string(), z.unknown()).optional().describe("Optional metadata to store with the document")
|
|
7686
7686
|
}),
|
|
7687
|
-
execute: async ({ path:
|
|
7687
|
+
execute: async ({ path: path9, content, metadata }, context) => {
|
|
7688
7688
|
const workspace = requireWorkspace(context);
|
|
7689
7689
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.SEARCH.INDEX);
|
|
7690
|
-
await workspace.index(
|
|
7691
|
-
return `Indexed ${
|
|
7690
|
+
await workspace.index(path9, content, { metadata });
|
|
7691
|
+
return `Indexed ${path9}`;
|
|
7692
7692
|
}
|
|
7693
7693
|
});
|
|
7694
7694
|
var KILL_TAIL_LINES = 50;
|
|
@@ -7744,7 +7744,7 @@ Use this to stop a long-running background process that was started with execute
|
|
|
7744
7744
|
});
|
|
7745
7745
|
|
|
7746
7746
|
// src/workspace/tools/tree-formatter.ts
|
|
7747
|
-
async function formatAsTree(fs6,
|
|
7747
|
+
async function formatAsTree(fs6, path9, options) {
|
|
7748
7748
|
const maxDepth = options?.maxDepth ?? Infinity;
|
|
7749
7749
|
const showHidden = options?.showHidden ?? false;
|
|
7750
7750
|
const dirsOnly = options?.dirsOnly ?? false;
|
|
@@ -7756,7 +7756,7 @@ async function formatAsTree(fs6, path8, options) {
|
|
|
7756
7756
|
if (!ignoreFilter && respectGitignore) {
|
|
7757
7757
|
const rawFilter = await loadGitignore(fs6);
|
|
7758
7758
|
if (rawFilter) {
|
|
7759
|
-
const normalizedPath =
|
|
7759
|
+
const normalizedPath = path9.replace(/^\.\//, "").replace(/^\//, "").replace(/\/$/, "");
|
|
7760
7760
|
const targetIsIgnored = normalizedPath && rawFilter(normalizedPath + "/");
|
|
7761
7761
|
ignoreFilter = targetIsIgnored ? void 0 : rawFilter;
|
|
7762
7762
|
}
|
|
@@ -7818,7 +7818,7 @@ async function formatAsTree(fs6, path8, options) {
|
|
|
7818
7818
|
if (globMatcher && !dirsOnly) {
|
|
7819
7819
|
filtered = filtered.filter((e) => {
|
|
7820
7820
|
if (e.type === "directory") return true;
|
|
7821
|
-
const relativePath = getRelativePath(
|
|
7821
|
+
const relativePath = getRelativePath(path9, currentPath, e.name);
|
|
7822
7822
|
return globMatcher(relativePath);
|
|
7823
7823
|
});
|
|
7824
7824
|
}
|
|
@@ -7832,7 +7832,7 @@ async function formatAsTree(fs6, path8, options) {
|
|
|
7832
7832
|
const entry = filtered[i];
|
|
7833
7833
|
const displayName = entry.isSymlink && entry.symlinkTarget ? `${entry.name} -> ${entry.symlinkTarget}` : entry.name;
|
|
7834
7834
|
lines.push(`${indent}${displayName}`);
|
|
7835
|
-
paths.push(getRelativePath(
|
|
7835
|
+
paths.push(getRelativePath(path9, currentPath, entry.name));
|
|
7836
7836
|
if (entry.type === "directory") {
|
|
7837
7837
|
dirCount++;
|
|
7838
7838
|
if (!entry.isSymlink) {
|
|
@@ -7844,7 +7844,7 @@ async function formatAsTree(fs6, path8, options) {
|
|
|
7844
7844
|
}
|
|
7845
7845
|
}
|
|
7846
7846
|
}
|
|
7847
|
-
await buildTree(
|
|
7847
|
+
await buildTree(path9, 0);
|
|
7848
7848
|
const dirPart = dirCount === 1 ? "1 directory" : `${dirCount} directories`;
|
|
7849
7849
|
const filePart = fileCount === 1 ? "1 file" : `${fileCount} files`;
|
|
7850
7850
|
let summary = `${dirPart}, ${filePart}`;
|
|
@@ -7909,10 +7909,10 @@ To list ALL files, omit the pattern parameter \u2014 do NOT pass pattern: "*".`,
|
|
|
7909
7909
|
),
|
|
7910
7910
|
respectGitignore: z.boolean().optional().default(true).describe("Respect .gitignore in the listed directory (default: true).")
|
|
7911
7911
|
}),
|
|
7912
|
-
execute: async ({ path:
|
|
7912
|
+
execute: async ({ path: path9 = ".", maxDepth = 2, showHidden, dirsOnly, exclude, extension, pattern, respectGitignore }, context) => {
|
|
7913
7913
|
const { workspace, filesystem } = requireFilesystem(context);
|
|
7914
7914
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.LIST_FILES);
|
|
7915
|
-
const result = await formatAsTree(filesystem,
|
|
7915
|
+
const result = await formatAsTree(filesystem, path9, {
|
|
7916
7916
|
maxDepth,
|
|
7917
7917
|
showHidden,
|
|
7918
7918
|
dirsOnly,
|
|
@@ -8125,14 +8125,14 @@ var mkdirTool = createTool({
|
|
|
8125
8125
|
path: z.string().describe("The path of the directory to create"),
|
|
8126
8126
|
recursive: z.boolean().optional().default(true).describe("Whether to create parent directories if they do not exist")
|
|
8127
8127
|
}),
|
|
8128
|
-
execute: async ({ path:
|
|
8128
|
+
execute: async ({ path: path9, recursive }, context) => {
|
|
8129
8129
|
const { filesystem } = requireFilesystem(context);
|
|
8130
8130
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.MKDIR);
|
|
8131
8131
|
if (filesystem.readOnly) {
|
|
8132
8132
|
throw new WorkspaceReadOnlyError("mkdir");
|
|
8133
8133
|
}
|
|
8134
|
-
await filesystem.mkdir(
|
|
8135
|
-
return `Created directory ${
|
|
8134
|
+
await filesystem.mkdir(path9, { recursive });
|
|
8135
|
+
return `Created directory ${path9}`;
|
|
8136
8136
|
}
|
|
8137
8137
|
});
|
|
8138
8138
|
var readFileTool = createTool({
|
|
@@ -8145,12 +8145,12 @@ var readFileTool = createTool({
|
|
|
8145
8145
|
limit: z.number().optional().describe("Maximum number of lines to read. If omitted, reads to the end of the file."),
|
|
8146
8146
|
showLineNumbers: z.boolean().optional().default(true).describe("Whether to prefix each line with its line number (default: true)")
|
|
8147
8147
|
}),
|
|
8148
|
-
execute: async ({ path:
|
|
8148
|
+
execute: async ({ path: path9, encoding, offset, limit, showLineNumbers }, context) => {
|
|
8149
8149
|
const { workspace, filesystem } = requireFilesystem(context);
|
|
8150
8150
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.READ_FILE);
|
|
8151
8151
|
const effectiveEncoding = encoding ?? "utf-8";
|
|
8152
|
-
const fullContent = await filesystem.readFile(
|
|
8153
|
-
const stat3 = await filesystem.stat(
|
|
8152
|
+
const fullContent = await filesystem.readFile(path9, { encoding: effectiveEncoding });
|
|
8153
|
+
const stat3 = await filesystem.stat(path9);
|
|
8154
8154
|
const isTextEncoding = !encoding || encoding === "utf-8" || encoding === "utf8";
|
|
8155
8155
|
const tokenLimit = workspace.getToolsConfig()?.[WORKSPACE_TOOLS.FILESYSTEM.READ_FILE]?.maxOutputTokens;
|
|
8156
8156
|
if (!isTextEncoding) {
|
|
@@ -8218,19 +8218,19 @@ var writeFileTool = createTool({
|
|
|
8218
8218
|
content: z.string().describe("The content to write to the file"),
|
|
8219
8219
|
overwrite: z.boolean().optional().default(true).describe("Whether to overwrite the file if it already exists")
|
|
8220
8220
|
}),
|
|
8221
|
-
execute: async ({ path:
|
|
8221
|
+
execute: async ({ path: path9, content, overwrite }, context) => {
|
|
8222
8222
|
const { workspace, filesystem } = requireFilesystem(context);
|
|
8223
8223
|
await emitWorkspaceMetadata(context, WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE);
|
|
8224
8224
|
if (filesystem.readOnly) {
|
|
8225
8225
|
throw new WorkspaceReadOnlyError("write_file");
|
|
8226
8226
|
}
|
|
8227
|
-
await filesystem.writeFile(
|
|
8227
|
+
await filesystem.writeFile(path9, content, {
|
|
8228
8228
|
overwrite,
|
|
8229
8229
|
expectedMtime: context?.__expectedMtime
|
|
8230
8230
|
});
|
|
8231
8231
|
const size = Buffer.byteLength(content, "utf-8");
|
|
8232
|
-
let output = `Wrote ${size} bytes to ${
|
|
8233
|
-
output += await getEditDiagnosticsText(workspace,
|
|
8232
|
+
let output = `Wrote ${size} bytes to ${path9}`;
|
|
8233
|
+
output += await getEditDiagnosticsText(workspace, path9, content);
|
|
8234
8234
|
return output;
|
|
8235
8235
|
}
|
|
8236
8236
|
});
|
|
@@ -8390,5 +8390,5 @@ function createWorkspaceTools(workspace) {
|
|
|
8390
8390
|
}
|
|
8391
8391
|
|
|
8392
8392
|
export { BM25Index, CompositeFilesystem, CompositeVersionedSkillSource, DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, FileReadRequiredError, FilesystemError, FilesystemNotAvailableError, FilesystemNotMountableError, FilesystemNotReadyError, IsDirectoryError, IsolationUnavailableError, LocalFilesystem, LocalSandbox, LocalSkillSource, MastraFilesystem, MastraSandbox, MountError, MountManager, MountNotSupportedError, NotDirectoryError, PermissionError, ProcessHandle, SandboxError, SandboxExecutionError, SandboxFeatureNotSupportedError, SandboxNotAvailableError, SandboxNotReadyError, SandboxProcessManager, SandboxTimeoutError, SearchNotAvailableError, StaleFileError, VersionedSkillSource, WORKSPACE_TOOLS, WORKSPACE_TOOLS_PREFIX, Workspace, WorkspaceError, WorkspaceNotAvailableError, WorkspaceNotReadyError, WorkspaceReadOnlyError, callLifecycle, collectSkillForPublish, createGlobMatcher, createSkillTools, createWorkspaceTools, deleteFileTool, detectIsolation, editFileTool, executeCommandTool, extractGlobBase, fileStatTool, getRecommendedIsolation, getTiktoken, indexContentTool, isGlobPattern, isIsolationAvailable, listFilesTool, matchGlob, mkdirTool, publishSkillFromSource, readFileTool, requireFilesystem, requireSandbox, requireWorkspace, resolveToolConfig, searchTool, writeFileTool };
|
|
8393
|
-
//# sourceMappingURL=chunk-
|
|
8394
|
-
//# sourceMappingURL=chunk-
|
|
8393
|
+
//# sourceMappingURL=chunk-HJBVUY76.js.map
|
|
8394
|
+
//# sourceMappingURL=chunk-HJBVUY76.js.map
|