@mastra/agentfs 0.2.2-alpha.0 → 0.2.3-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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filesystem/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EASjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA2HtC;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,uBAAuB;IACvE,qDAAqD;IACrD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,iBAAkB,SAAQ,gBAAgB;IACrD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,uBAAuB;IACpC,QAAQ,CAAC,QAAQ,aAAa;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B,MAAM,EAAE,cA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AAI,CAAC,CA2BhE;IAEK,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAsDvE;IAMK,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU3C;IAEK,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoB1C;IAMD;;;OAGG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ3C;IAED;;;OAGG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQhD;IAMD;;OAEG;YACW,cAAc;IAiB5B;;OAEG;YACW,gBAAgB;CAwB/B"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -16,11 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- //#endregion
24
23
  let fs = require("fs");
25
24
  let os = require("os");
26
25
  os = __toESM(os, 1);
@@ -28,7 +27,7 @@ let path = require("path");
28
27
  path = __toESM(path, 1);
29
28
  let _mastra_core_workspace = require("@mastra/core/workspace");
30
29
  let agentfs_sdk = require("agentfs-sdk");
31
- //#region src/filesystem/index.ts
30
+ // src/filesystem/index.ts
32
31
  /**
33
32
  * AgentFS Filesystem Provider
34
33
  *
@@ -53,11 +52,11 @@ function resolveDbPath(p) {
53
52
  }
54
53
  function normalizePath(input) {
55
54
  if (input === "" || input === ".") return "/";
56
- let path$1 = input.startsWith("/") ? input : "/" + input;
55
+ let path = input.startsWith("/") ? input : "/" + input;
57
56
  let result = "";
58
57
  let prevSlash = false;
59
- for (let i = 0; i < path$1.length; i++) {
60
- const ch = path$1[i];
58
+ for (let i = 0; i < path.length; i++) {
59
+ const ch = path[i];
61
60
  if (ch === "/") {
62
61
  if (!prevSlash) result += ch;
63
62
  prevSlash = true;
@@ -69,8 +68,8 @@ function normalizePath(input) {
69
68
  if (result.length > 1 && result.endsWith("/")) result = result.slice(0, -1);
70
69
  return result;
71
70
  }
72
- function getParentPath(path$2) {
73
- const normalized = normalizePath(path$2);
71
+ function getParentPath(path) {
72
+ const normalized = normalizePath(path);
74
73
  if (normalized === "/") return "/";
75
74
  const lastSlash = normalized.lastIndexOf("/");
76
75
  return lastSlash <= 0 ? "/" : normalized.slice(0, lastSlash);
@@ -79,8 +78,8 @@ function joinPath(base, name) {
79
78
  if (base === "/") return normalizePath("/" + name);
80
79
  return normalizePath(base + "/" + name);
81
80
  }
82
- function getBaseName(path$3) {
83
- const normalized = normalizePath(path$3);
81
+ function getBaseName(path) {
82
+ const normalized = normalizePath(path);
84
83
  if (normalized === "/") return "";
85
84
  const lastSlash = normalized.lastIndexOf("/");
86
85
  return normalized.slice(lastSlash + 1);
@@ -88,16 +87,16 @@ function getBaseName(path$3) {
88
87
  function isErrnoError(error) {
89
88
  return typeof error === "object" && error !== null && "code" in error;
90
89
  }
91
- function mapError(error, path$4, context = "file") {
90
+ function mapError(error, path, context = "file") {
92
91
  if (!isErrnoError(error)) return error instanceof Error ? error : new Error(String(error));
93
92
  switch (error.code) {
94
- case "ENOENT": return context === "directory" ? new _mastra_core_workspace.DirectoryNotFoundError(path$4) : new _mastra_core_workspace.FileNotFoundError(path$4);
95
- case "EEXIST": return new _mastra_core_workspace.FileExistsError(path$4);
96
- case "EISDIR": return new _mastra_core_workspace.IsDirectoryError(path$4);
97
- case "ENOTDIR": return new _mastra_core_workspace.NotDirectoryError(path$4);
98
- case "ENOTEMPTY": return new _mastra_core_workspace.DirectoryNotEmptyError(path$4);
93
+ case "ENOENT": return context === "directory" ? new _mastra_core_workspace.DirectoryNotFoundError(path) : new _mastra_core_workspace.FileNotFoundError(path);
94
+ case "EEXIST": return new _mastra_core_workspace.FileExistsError(path);
95
+ case "EISDIR": return new _mastra_core_workspace.IsDirectoryError(path);
96
+ case "ENOTDIR": return new _mastra_core_workspace.NotDirectoryError(path);
97
+ case "ENOTEMPTY": return new _mastra_core_workspace.DirectoryNotEmptyError(path);
99
98
  case "EPERM":
100
- case "EACCES": return new _mastra_core_workspace.PermissionError(path$4, "access");
99
+ case "EACCES": return new _mastra_core_workspace.PermissionError(path, "access");
101
100
  default: return error instanceof Error ? error : new Error(String(error));
102
101
  }
103
102
  }
@@ -199,9 +198,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
199
198
  assertWritable(operation) {
200
199
  if (this.readOnly) throw new _mastra_core_workspace.WorkspaceReadOnlyError(operation);
201
200
  }
202
- async readFile(path$5, options) {
201
+ async readFile(path, options) {
203
202
  const agent = await this.getAgent();
204
- const normalized = normalizePath(path$5);
203
+ const normalized = normalizePath(path);
205
204
  try {
206
205
  if (options?.encoding) return await agent.fs.readFile(normalized, options.encoding);
207
206
  return await agent.fs.readFile(normalized);
@@ -209,10 +208,10 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
209
208
  throw mapError(error, normalized, "file");
210
209
  }
211
210
  }
212
- async writeFile(path$6, content, options) {
211
+ async writeFile(path, content, options) {
213
212
  this.assertWritable("writeFile");
214
213
  const agent = await this.getAgent();
215
- const normalized = normalizePath(path$6);
214
+ const normalized = normalizePath(path);
216
215
  if (options?.recursive !== false) await this.mkdirRecursive(agent, getParentPath(normalized));
217
216
  if (options?.overwrite === false) try {
218
217
  await agent.fs.access(normalized);
@@ -228,22 +227,22 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
228
227
  throw mapError(error, normalized, "file");
229
228
  }
230
229
  }
231
- async appendFile(path$7, content) {
230
+ async appendFile(path, content) {
232
231
  this.assertWritable("appendFile");
233
232
  let existing = Buffer.alloc(0);
234
233
  try {
235
- const current = await this.readFile(path$7);
234
+ const current = await this.readFile(path);
236
235
  existing = Buffer.isBuffer(current) ? Buffer.from(current) : Buffer.from(current);
237
236
  } catch (error) {
238
237
  if (error instanceof _mastra_core_workspace.FileNotFoundError) {} else throw error;
239
238
  }
240
239
  const appendBuffer = typeof content === "string" ? Buffer.from(content, "utf-8") : Buffer.from(content);
241
- await this.writeFile(path$7, Buffer.concat([existing, appendBuffer]));
240
+ await this.writeFile(path, Buffer.concat([existing, appendBuffer]));
242
241
  }
243
- async deleteFile(path$8, options) {
242
+ async deleteFile(path, options) {
244
243
  this.assertWritable("deleteFile");
245
244
  const agent = await this.getAgent();
246
- const normalized = normalizePath(path$8);
245
+ const normalized = normalizePath(path);
247
246
  try {
248
247
  if ((await agent.fs.stat(normalized)).isDirectory()) throw new _mastra_core_workspace.IsDirectoryError(normalized);
249
248
  } catch (error) {
@@ -305,10 +304,10 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
305
304
  throw mapError(error, normalizedSrc, "file");
306
305
  }
307
306
  }
308
- async mkdir(path$9, options) {
307
+ async mkdir(path, options) {
309
308
  this.assertWritable("mkdir");
310
309
  const agent = await this.getAgent();
311
- const normalized = normalizePath(path$9);
310
+ const normalized = normalizePath(path);
312
311
  if (options?.recursive !== false) {
313
312
  await this.mkdirRecursive(agent, normalized);
314
313
  return;
@@ -319,10 +318,10 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
319
318
  throw mapError(error, normalized, "directory");
320
319
  }
321
320
  }
322
- async rmdir(path$10, options) {
321
+ async rmdir(path, options) {
323
322
  this.assertWritable("rmdir");
324
323
  const agent = await this.getAgent();
325
- const normalized = normalizePath(path$10);
324
+ const normalized = normalizePath(path);
326
325
  if (options?.recursive) {
327
326
  try {
328
327
  await agent.fs.rm(normalized, { recursive: true });
@@ -341,9 +340,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
341
340
  throw mapError(error, normalized, "directory");
342
341
  }
343
342
  }
344
- async readdir(path$11, options) {
343
+ async readdir(path, options) {
345
344
  const agent = await this.getAgent();
346
- const normalized = normalizePath(path$11);
345
+ const normalized = normalizePath(path);
347
346
  try {
348
347
  if (!(await agent.fs.stat(normalized)).isDirectory()) throw new _mastra_core_workspace.NotDirectoryError(normalized);
349
348
  let entries = (await agent.fs.readdirPlus(normalized)).map((entry) => ({
@@ -378,9 +377,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
378
377
  throw mapError(error, normalized, "directory");
379
378
  }
380
379
  }
381
- async exists(path$12) {
380
+ async exists(path) {
382
381
  const agent = await this.getAgent();
383
- const normalized = normalizePath(path$12);
382
+ const normalized = normalizePath(path);
384
383
  try {
385
384
  await agent.fs.access(normalized);
386
385
  return true;
@@ -388,18 +387,20 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
388
387
  return false;
389
388
  }
390
389
  }
391
- async stat(path$13) {
390
+ async stat(path) {
392
391
  const agent = await this.getAgent();
393
- const normalized = normalizePath(path$13);
392
+ const normalized = normalizePath(path);
394
393
  try {
395
394
  const st = await agent.fs.stat(normalized);
395
+ const isDirectory = st.isDirectory();
396
396
  return {
397
397
  name: getBaseName(normalized) || "",
398
398
  path: normalized,
399
- type: st.isDirectory() ? "directory" : "file",
399
+ type: isDirectory ? "directory" : "file",
400
400
  size: st.size,
401
401
  createdAt: /* @__PURE__ */ new Date(st.ctime * 1e3),
402
- modifiedAt: /* @__PURE__ */ new Date(st.mtime * 1e3)
402
+ modifiedAt: /* @__PURE__ */ new Date(st.mtime * 1e3),
403
+ ...!isDirectory && { mimeType: (0, _mastra_core_workspace.getMimeType)(normalized) }
403
404
  };
404
405
  } catch (error) {
405
406
  throw mapError(error, normalized, "file");
@@ -409,9 +410,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
409
410
  * Check if the path points to a file.
410
411
  * Returns `false` if the path doesn't exist.
411
412
  */
412
- async isFile(path$14) {
413
+ async isFile(path) {
413
414
  try {
414
- return (await this.stat(path$14)).type === "file";
415
+ return (await this.stat(path)).type === "file";
415
416
  } catch (error) {
416
417
  if (error instanceof _mastra_core_workspace.FileNotFoundError) return false;
417
418
  throw error;
@@ -421,9 +422,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
421
422
  * Check if the path points to a directory.
422
423
  * Returns `false` if the path doesn't exist.
423
424
  */
424
- async isDirectory(path$15) {
425
+ async isDirectory(path) {
425
426
  try {
426
- return (await this.stat(path$15)).type === "directory";
427
+ return (await this.stat(path)).type === "directory";
427
428
  } catch (error) {
428
429
  if (error instanceof _mastra_core_workspace.FileNotFoundError) return false;
429
430
  throw error;
@@ -432,9 +433,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
432
433
  /**
433
434
  * Recursively create directories, ignoring EEXIST errors.
434
435
  */
435
- async mkdirRecursive(agent, path$16) {
436
- if (path$16 === "/") return;
437
- const segments = path$16.split("/").filter(Boolean);
436
+ async mkdirRecursive(agent, path) {
437
+ if (path === "/") return;
438
+ const segments = path.split("/").filter(Boolean);
438
439
  let current = "";
439
440
  for (const segment of segments) {
440
441
  current += "/" + segment;
@@ -468,8 +469,7 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
468
469
  }
469
470
  }
470
471
  };
471
- //#endregion
472
- //#region src/provider.ts
472
+ // src/provider.ts
473
473
  const agentfsFilesystemProvider = {
474
474
  id: "agentfs",
475
475
  name: "AgentFS",
@@ -494,7 +494,6 @@ const agentfsFilesystemProvider = {
494
494
  },
495
495
  createFilesystem: (config) => new AgentFSFilesystem(config)
496
496
  };
497
- //#endregion
498
497
  exports.AgentFSFilesystem = AgentFSFilesystem;
499
498
  exports.agentfsFilesystemProvider = agentfsFilesystemProvider;
500
499
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["nodePath","path","DirectoryNotFoundError","FileNotFoundError","FileExistsError","IsDirectoryError","NotDirectoryError","DirectoryNotEmptyError","PermissionError","MastraFilesystem","AgentFS","WorkspaceReadOnlyError"],"sources":["../src/filesystem/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * AgentFS Filesystem Provider\n *\n * Implements WorkspaceFilesystem backed by AgentFS (Turso/SQLite).\n * Follows the same pattern as S3Filesystem.\n */\n\nimport { mkdirSync } from 'node:fs';\nimport os from 'node:os';\nimport nodePath from 'node:path';\nimport type {\n FileContent,\n FileStat,\n FileEntry,\n ReadOptions,\n WriteOptions,\n ListOptions,\n RemoveOptions,\n CopyOptions,\n FilesystemIcon,\n FilesystemInfo,\n ProviderStatus,\n MastraFilesystemOptions,\n} from '@mastra/core/workspace';\nimport {\n MastraFilesystem,\n FileNotFoundError,\n FileExistsError,\n IsDirectoryError,\n NotDirectoryError,\n DirectoryNotFoundError,\n DirectoryNotEmptyError,\n PermissionError,\n WorkspaceReadOnlyError,\n} from '@mastra/core/workspace';\nimport { AgentFS } from 'agentfs-sdk';\n\n// ---------------------------------------------------------------------------\n// Database path resolution\n// ---------------------------------------------------------------------------\n\n/**\n * Expand a leading `~` to the user's home directory.\n * Node.js path APIs don't handle tilde — only the shell does.\n */\nfunction expandTilde(p: string): string {\n if (p === '~') return os.homedir();\n if (p.startsWith('~/') || p.startsWith('~\\\\')) {\n return nodePath.join(os.homedir(), p.slice(2));\n }\n return p;\n}\n\n/**\n * Resolve a database path to an absolute path.\n * Expands tilde and resolves relative paths against cwd (at construction time).\n */\nfunction resolveDbPath(p: string): string {\n return nodePath.resolve(expandTilde(p));\n}\n\n// ---------------------------------------------------------------------------\n// Path utilities (POSIX-style with leading slash)\n// ---------------------------------------------------------------------------\n\nfunction normalizePath(input: string): string {\n // Treat \".\" and \"\" as root — consistent with how CompositeFilesystem\n // and the Studio UI use \".\" to mean \"filesystem root\".\n if (input === '' || input === '.') return '/';\n\n let path = input.startsWith('/') ? input : '/' + input;\n\n let result = '';\n let prevSlash = false;\n for (let i = 0; i < path.length; i++) {\n const ch = path[i];\n if (ch === '/') {\n if (!prevSlash) {\n result += ch;\n }\n prevSlash = true;\n } else {\n result += ch;\n prevSlash = false;\n }\n }\n\n if (result.length > 1 && result.endsWith('/')) {\n result = result.slice(0, -1);\n }\n\n return result;\n}\n\nfunction getParentPath(path: string): string {\n const normalized = normalizePath(path);\n if (normalized === '/') return '/';\n const lastSlash = normalized.lastIndexOf('/');\n return lastSlash <= 0 ? '/' : normalized.slice(0, lastSlash);\n}\n\nfunction joinPath(base: string, name: string): string {\n if (base === '/') return normalizePath('/' + name);\n return normalizePath(base + '/' + name);\n}\n\nfunction getBaseName(path: string): string {\n const normalized = normalizePath(path);\n if (normalized === '/') return '';\n const lastSlash = normalized.lastIndexOf('/');\n return normalized.slice(lastSlash + 1);\n}\n\n// ---------------------------------------------------------------------------\n// Error mapping (AgentFS errno → Mastra workspace errors)\n// ---------------------------------------------------------------------------\n\ninterface ErrnoError {\n code?: string;\n message?: string;\n}\n\nfunction isErrnoError(error: unknown): error is ErrnoError {\n return typeof error === 'object' && error !== null && 'code' in error;\n}\n\nfunction mapError(error: unknown, path: string, context: 'file' | 'directory' = 'file'): Error {\n if (!isErrnoError(error)) {\n return error instanceof Error ? error : new Error(String(error));\n }\n\n switch (error.code) {\n case 'ENOENT':\n return context === 'directory' ? new DirectoryNotFoundError(path) : new FileNotFoundError(path);\n case 'EEXIST':\n return new FileExistsError(path);\n case 'EISDIR':\n return new IsDirectoryError(path);\n case 'ENOTDIR':\n return new NotDirectoryError(path);\n case 'ENOTEMPTY':\n return new DirectoryNotEmptyError(path);\n case 'EPERM':\n case 'EACCES':\n return new PermissionError(path, 'access');\n default:\n return error instanceof Error ? error : new Error(String(error));\n }\n}\n\nfunction hasCode(error: unknown, code: string): boolean {\n return isErrnoError(error) && error.code === code;\n}\n\n// ---------------------------------------------------------------------------\n// AgentFS Filesystem\n// ---------------------------------------------------------------------------\n\n/**\n * AgentFS filesystem provider configuration.\n */\nexport interface AgentFSFilesystemOptions extends MastraFilesystemOptions {\n /** Unique identifier for this filesystem instance */\n id?: string;\n /** Agent ID — creates database at `.agentfs/<agentId>.db` */\n agentId?: string;\n /** Explicit database file path */\n path?: string;\n /** Pre-opened AgentFS instance (skips open/close — caller manages lifecycle) */\n agent?: AgentFS;\n /** Block write operations (default: false) */\n readOnly?: boolean;\n /** Human-friendly display name for the UI */\n displayName?: string;\n /** Icon identifier for the UI (default: 'database') */\n icon?: FilesystemIcon;\n /** Description shown in tooltips */\n description?: string;\n}\n\n/**\n * AgentFS filesystem implementation.\n *\n * Stores files in a Turso/SQLite database via the AgentFS SDK.\n *\n * @example Using agentId\n * ```typescript\n * import { AgentFSFilesystem } from '@mastra/agentfs';\n *\n * const fs = new AgentFSFilesystem({ agentId: 'my-agent' });\n * ```\n *\n * @example Using a pre-opened instance\n * ```typescript\n * import { AgentFS } from 'agentfs-sdk';\n * import { AgentFSFilesystem } from '@mastra/agentfs';\n *\n * const agent = await AgentFS.open({ id: 'my-agent' });\n * const fs = new AgentFSFilesystem({ agent });\n * ```\n */\nexport class AgentFSFilesystem extends MastraFilesystem {\n readonly id: string;\n readonly name = 'AgentFSFilesystem';\n readonly provider = 'agentfs';\n readonly readOnly?: boolean;\n\n status: ProviderStatus = 'pending';\n\n // Display metadata\n readonly displayName?: string;\n readonly icon: FilesystemIcon;\n readonly description?: string;\n\n private _agent: AgentFS | null = null;\n private readonly _ownsAgent: boolean;\n private readonly _agentId?: string;\n private readonly _path?: string;\n\n constructor(options: AgentFSFilesystemOptions) {\n if (!options.agentId && !options.path && !options.agent) {\n throw new Error(\"AgentFSFilesystem requires at least one of 'agentId', 'path', or 'agent'.\");\n }\n\n super({ ...options, name: 'AgentFSFilesystem' });\n this.id = options.id ?? `agentfs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._agentId = options.agentId;\n this._path = options.path ? resolveDbPath(options.path) : undefined;\n this.readOnly = options.readOnly;\n\n if (options.agent) {\n this._agent = options.agent;\n this._ownsAgent = false;\n } else {\n this._ownsAgent = true;\n }\n\n this.icon = options.icon ?? 'database';\n this.displayName = options.displayName ?? 'AgentFS';\n this.description = options.description;\n }\n\n /** The underlying AgentFS instance, or null if not yet initialized. */\n get agent(): AgentFS | null {\n return this._agent;\n }\n\n // ---------------------------------------------------------------------------\n // Info\n // ---------------------------------------------------------------------------\n\n getInfo(): FilesystemInfo<{\n agentId?: string;\n dbPath?: string;\n }> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n error: this.error,\n readOnly: this.readOnly,\n icon: this.icon,\n metadata: {\n ...(this._agentId && { agentId: this._agentId }),\n ...(this._path && { dbPath: this._path }),\n },\n };\n }\n\n getInstructions(): string {\n const label = this._agentId ? `agent \"${this._agentId}\"` : 'database';\n const access = this.readOnly ? 'Read-only' : 'Persistent';\n return `AgentFS storage for ${label}. ${access} SQLite-backed filesystem — files are retained across sessions.`;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n async init(): Promise<void> {\n if (this._agent) return; // Pre-opened instance\n\n const openOptions: { id?: string; path?: string } = {};\n if (this._agentId) openOptions.id = this._agentId;\n if (this._path) {\n openOptions.path = this._path;\n // Ensure parent directory exists — the SDK only auto-creates `.agentfs/`\n // for the agentId-only case, not for explicit paths.\n mkdirSync(nodePath.dirname(this._path), { recursive: true });\n }\n\n this._agent = await AgentFS.open(openOptions);\n }\n\n async destroy(): Promise<void> {\n if (this._agent && this._ownsAgent) {\n await this._agent.close();\n }\n this._agent = null;\n }\n\n // ---------------------------------------------------------------------------\n // Internal helpers\n // ---------------------------------------------------------------------------\n\n private async getAgent(): Promise<AgentFS> {\n await this.ensureReady();\n return this._agent!;\n }\n\n private assertWritable(operation: string): void {\n if (this.readOnly) {\n throw new WorkspaceReadOnlyError(operation);\n }\n }\n\n // ---------------------------------------------------------------------------\n // File Operations\n // ---------------------------------------------------------------------------\n\n async readFile(path: string, options?: ReadOptions): Promise<string | Buffer> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n if (options?.encoding) {\n return await agent.fs.readFile(normalized, options.encoding);\n }\n return await agent.fs.readFile(normalized);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n async writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void> {\n this.assertWritable('writeFile');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Create parent directories (default behavior)\n if (options?.recursive !== false) {\n await this.mkdirRecursive(agent, getParentPath(normalized));\n }\n\n // Check overwrite\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalized);\n throw new FileExistsError(normalized);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalized, 'file');\n }\n }\n\n try {\n const data = typeof content === 'string' ? content : Buffer.from(content);\n await agent.fs.writeFile(normalized, data);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n async appendFile(path: string, content: FileContent): Promise<void> {\n this.assertWritable('appendFile');\n // AgentFS doesn't have native append — read + write (same pattern as S3Filesystem)\n let existing: Buffer = Buffer.alloc(0);\n try {\n const current = await this.readFile(path);\n existing = Buffer.isBuffer(current) ? Buffer.from(current) : Buffer.from(current);\n } catch (error) {\n if (error instanceof FileNotFoundError) {\n // File doesn't exist — start fresh\n } else {\n throw error;\n }\n }\n\n const appendBuffer = typeof content === 'string' ? Buffer.from(content, 'utf-8') : Buffer.from(content);\n await this.writeFile(path, Buffer.concat([existing, appendBuffer]));\n }\n\n async deleteFile(path: string, options?: RemoveOptions): Promise<void> {\n this.assertWritable('deleteFile');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Check if it's a directory\n try {\n const st = await agent.fs.stat(normalized);\n if (st.isDirectory()) {\n throw new IsDirectoryError(normalized);\n }\n } catch (error: unknown) {\n if (error instanceof IsDirectoryError) throw error;\n if (hasCode(error, 'ENOENT')) {\n if (options?.force) return;\n throw new FileNotFoundError(normalized);\n }\n throw mapError(error, normalized, 'file');\n }\n\n try {\n await agent.fs.unlink(normalized);\n } catch (error: unknown) {\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'file');\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n this.assertWritable('copyFile');\n const agent = await this.getAgent();\n const normalizedSrc = normalizePath(src);\n const normalizedDest = normalizePath(dest);\n\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalizedDest);\n throw new FileExistsError(normalizedDest);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalizedDest, 'file');\n }\n }\n\n try {\n // Check if source is a directory\n const st = await agent.fs.stat(normalizedSrc);\n if (st.isDirectory()) {\n if (!options?.recursive) {\n throw new IsDirectoryError(normalizedSrc);\n }\n await this.copyDirRecursive(agent, normalizedSrc, normalizedDest, options);\n return;\n }\n\n // Ensure parent directory of dest exists\n await this.mkdirRecursive(agent, getParentPath(normalizedDest));\n await agent.fs.copyFile(normalizedSrc, normalizedDest);\n } catch (error: unknown) {\n if (error instanceof IsDirectoryError || error instanceof FileExistsError) throw error;\n throw mapError(error, normalizedSrc, 'file');\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n this.assertWritable('moveFile');\n const agent = await this.getAgent();\n const normalizedSrc = normalizePath(src);\n const normalizedDest = normalizePath(dest);\n\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalizedDest);\n throw new FileExistsError(normalizedDest);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalizedDest, 'file');\n }\n }\n\n // Ensure parent directory of dest exists\n await this.mkdirRecursive(agent, getParentPath(normalizedDest));\n\n try {\n await agent.fs.rename(normalizedSrc, normalizedDest);\n } catch (error: unknown) {\n throw mapError(error, normalizedSrc, 'file');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Directory Operations\n // ---------------------------------------------------------------------------\n\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n this.assertWritable('mkdir');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Default to recursive (matches LocalFilesystem behavior)\n if (options?.recursive !== false) {\n await this.mkdirRecursive(agent, normalized);\n return;\n }\n\n try {\n await agent.fs.mkdir(normalized);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'directory');\n }\n }\n\n async rmdir(path: string, options?: RemoveOptions): Promise<void> {\n this.assertWritable('rmdir');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n if (options?.recursive) {\n try {\n await agent.fs.rm(normalized, { recursive: true });\n } catch (error: unknown) {\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'directory');\n }\n return;\n }\n\n // Non-recursive: check if empty first\n try {\n const entries = await agent.fs.readdir(normalized);\n if (entries.length > 0) {\n throw new DirectoryNotEmptyError(normalized);\n }\n await agent.fs.rmdir(normalized);\n } catch (error: unknown) {\n if (error instanceof DirectoryNotEmptyError) throw error;\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'directory');\n }\n }\n\n async readdir(path: string, options?: ListOptions): Promise<FileEntry[]> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n // Verify it's a directory\n const st = await agent.fs.stat(normalized);\n if (!st.isDirectory()) {\n throw new NotDirectoryError(normalized);\n }\n\n const dirEntries = await agent.fs.readdirPlus(normalized);\n let entries: FileEntry[] = dirEntries.map(entry => ({\n name: entry.name,\n type: entry.stats.isDirectory() ? ('directory' as const) : ('file' as const),\n size: entry.stats.size,\n }));\n\n // Apply extension filter\n if (options?.extension) {\n const extensions = Array.isArray(options.extension) ? options.extension : [options.extension];\n entries = entries.filter(entry => {\n if (entry.type === 'directory') return true;\n return extensions.some(ext => entry.name.endsWith(ext));\n });\n }\n\n // Recurse if requested\n if (options?.recursive) {\n const maxDepth = options.maxDepth ?? Infinity;\n const subdirs = entries.filter(e => e.type === 'directory');\n for (const dir of subdirs) {\n if (maxDepth > 1) {\n const subEntries = await this.readdir(joinPath(normalized, dir.name), {\n ...options,\n maxDepth: maxDepth - 1,\n });\n for (const sub of subEntries) {\n entries.push({\n ...sub,\n name: dir.name + '/' + sub.name,\n });\n }\n }\n }\n }\n\n return entries;\n } catch (error: unknown) {\n if (error instanceof NotDirectoryError || error instanceof DirectoryNotFoundError) {\n throw error;\n }\n throw mapError(error, normalized, 'directory');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Path Operations\n // ---------------------------------------------------------------------------\n\n async exists(path: string): Promise<boolean> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n await agent.fs.access(normalized);\n return true;\n } catch {\n return false;\n }\n }\n\n async stat(path: string): Promise<FileStat> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n const st = await agent.fs.stat(normalized);\n return {\n name: getBaseName(normalized) || '',\n path: normalized,\n type: st.isDirectory() ? 'directory' : 'file',\n size: st.size,\n createdAt: new Date(st.ctime * 1000),\n modifiedAt: new Date(st.mtime * 1000),\n };\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Type checks\n // ---------------------------------------------------------------------------\n\n /**\n * Check if the path points to a file.\n * Returns `false` if the path doesn't exist.\n */\n async isFile(path: string): Promise<boolean> {\n try {\n const st = await this.stat(path);\n return st.type === 'file';\n } catch (error) {\n if (error instanceof FileNotFoundError) return false;\n throw error;\n }\n }\n\n /**\n * Check if the path points to a directory.\n * Returns `false` if the path doesn't exist.\n */\n async isDirectory(path: string): Promise<boolean> {\n try {\n const st = await this.stat(path);\n return st.type === 'directory';\n } catch (error) {\n if (error instanceof FileNotFoundError) return false;\n throw error;\n }\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Recursively create directories, ignoring EEXIST errors.\n */\n private async mkdirRecursive(agent: AgentFS, path: string): Promise<void> {\n if (path === '/') return;\n\n const segments = path.split('/').filter(Boolean);\n let current = '';\n for (const segment of segments) {\n current += '/' + segment;\n try {\n await agent.fs.mkdir(current);\n } catch (error: unknown) {\n if (!hasCode(error, 'EEXIST')) {\n throw mapError(error, current, 'directory');\n }\n }\n }\n }\n\n /**\n * Recursively copy a directory tree.\n */\n private async copyDirRecursive(agent: AgentFS, src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.mkdirRecursive(agent, dest);\n\n const entries = await agent.fs.readdirPlus(src);\n for (const entry of entries) {\n const srcChild = joinPath(src, entry.name);\n const destChild = joinPath(dest, entry.name);\n\n if (entry.stats.isDirectory()) {\n await this.copyDirRecursive(agent, srcChild, destChild, options);\n } else {\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(destChild);\n throw new FileExistsError(destChild);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, destChild, 'file');\n }\n }\n await agent.fs.copyFile(srcChild, destChild);\n }\n }\n }\n}\n","/**\n * AgentFS filesystem provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { agentfsFilesystemProvider } from '@mastra/agentfs';\n *\n * const editor = new MastraEditor({\n * filesystems: [agentfsFilesystemProvider],\n * });\n * ```\n */\nimport type { FilesystemProvider } from '@mastra/core/editor';\nimport { AgentFSFilesystem } from './filesystem';\nimport type { AgentFSFilesystemOptions } from './filesystem';\n\nexport const agentfsFilesystemProvider: FilesystemProvider<AgentFSFilesystemOptions> = {\n id: 'agentfs',\n name: 'AgentFS',\n description: 'Turso/SQLite-backed filesystem via AgentFS',\n configSchema: {\n type: 'object',\n properties: {\n agentId: { type: 'string', description: 'Agent ID — creates database at .agentfs/<agentId>.db' },\n path: { type: 'string', description: 'Explicit database file path (alternative to agentId)' },\n readOnly: { type: 'boolean', description: 'Mount as read-only', default: false },\n },\n },\n createFilesystem: config => new AgentFSFilesystem(config),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAS,YAAY,GAAmB;CACtC,IAAI,MAAM,KAAK,OAAO,GAAA,QAAG,QAAQ;CACjC,IAAI,EAAE,WAAW,IAAI,KAAK,EAAE,WAAW,KAAK,GAC1C,OAAOA,KAAAA,QAAS,KAAK,GAAA,QAAG,QAAQ,GAAG,EAAE,MAAM,CAAC,CAAC;CAE/C,OAAO;AACT;;;;;AAMA,SAAS,cAAc,GAAmB;CACxC,OAAOA,KAAAA,QAAS,QAAQ,YAAY,CAAC,CAAC;AACxC;AAMA,SAAS,cAAc,OAAuB;CAG5C,IAAI,UAAU,MAAM,UAAU,KAAK,OAAO;CAE1C,IAAIC,SAAO,MAAM,WAAW,GAAG,IAAI,QAAQ,MAAM;CAEjD,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,KAAK,IAAI,IAAI,GAAG,IAAIA,OAAK,QAAQ,KAAK;EACpC,MAAM,KAAKA,OAAK;EAChB,IAAI,OAAO,KAAK;GACd,IAAI,CAAC,WACH,UAAU;GAEZ,YAAY;EACd,OAAO;GACL,UAAU;GACV,YAAY;EACd;CACF;CAEA,IAAI,OAAO,SAAS,KAAK,OAAO,SAAS,GAAG,GAC1C,SAAS,OAAO,MAAM,GAAG,EAAE;CAG7B,OAAO;AACT;AAEA,SAAS,cAAc,QAAsB;CAC3C,MAAM,aAAa,cAAcA,MAAI;CACrC,IAAI,eAAe,KAAK,OAAO;CAC/B,MAAM,YAAY,WAAW,YAA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vB,IAAI,CAAC,QAAQ,OAAO,QAAQ,GAC1B,MAAM,SAAS,OAAO,SAAS,WAAW;GAE9C;EACF;CACF;;;;CAKA,MAAc,iBAAiB,OAAgB,KAAa,MAAc,SAAsC;EAC9G,MAAM,KAAK,eAAe,OAAO,IAAI;EAErC,MAAM,UAAU,MAAM,MAAM,GAAG,YAAY,GAAG;EAC9C,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,WAAW,SAAS,KAAK,MAAM,IAAI;GACzC,MAAM,YAAY,SAAS,MAAM,MAAM,IAAI;GAE3C,IAAI,MAAM,MAAM,YAAY,GAC1B,MAAM,KAAK,iBAAiB,OAAO,UAAU,WAAW,OAAO;QAC1D;IACL,IAAI,SAAS,cAAc,OACzB,IAAI;KACF,MAAM,MAAM,GAAG,OAAO,SAAS;KAC/B,MAAM,IAAIG,uBAAAA,gBAAgB,SAAS;IACrC,SAAS,OAAgB;KACvB,IAAI,iBAAiBA,uBAAAA,iBAAiB,MAAM;KAC5C,IAAI,CAAC,QAAQ,OAAO,QAAQ,GAAG,MAAM,SAAS,OAAO,WAAW,MAAM;IACxE;IAEF,MAAM,MAAM,GAAG,SAAS,UAAU,SAAS;GAC7C;EACF;CACF;AACF;;;AC1qBA,MAAa,4BAA0E;CACrF,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,YAAY;GACV,SAAS;IAAE,MAAM;IAAU,aAAa;GAAuD;GAC/F,MAAM;IAAE,MAAM;IAAU,aAAa;GAAuD;GAC5F,UAAU;IAAE,MAAM;IAAW,aAAa;IAAsB,SAAS;GAAM;EACjF;CACF;CACA,mBAAkB,WAAU,IAAI,kBAAkB,MAAM;AAC1D"}
1
+ {"version":3,"file":"index.cjs","names":["nodePath","DirectoryNotFoundError","FileNotFoundError","FileExistsError","IsDirectoryError","NotDirectoryError","DirectoryNotEmptyError","PermissionError","MastraFilesystem","AgentFS","WorkspaceReadOnlyError","getMimeType"],"sources":["../src/filesystem/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * AgentFS Filesystem Provider\n *\n * Implements WorkspaceFilesystem backed by AgentFS (Turso/SQLite).\n * Follows the same pattern as S3Filesystem.\n */\n\nimport { mkdirSync } from 'node:fs';\nimport os from 'node:os';\nimport nodePath from 'node:path';\nimport type {\n FileContent,\n FileStat,\n FileEntry,\n ReadOptions,\n WriteOptions,\n ListOptions,\n RemoveOptions,\n CopyOptions,\n FilesystemIcon,\n FilesystemInfo,\n ProviderStatus,\n MastraFilesystemOptions,\n} from '@mastra/core/workspace';\nimport {\n MastraFilesystem,\n FileNotFoundError,\n FileExistsError,\n getMimeType,\n IsDirectoryError,\n NotDirectoryError,\n DirectoryNotFoundError,\n DirectoryNotEmptyError,\n PermissionError,\n WorkspaceReadOnlyError,\n} from '@mastra/core/workspace';\nimport { AgentFS } from 'agentfs-sdk';\n\n// ---------------------------------------------------------------------------\n// Database path resolution\n// ---------------------------------------------------------------------------\n\n/**\n * Expand a leading `~` to the user's home directory.\n * Node.js path APIs don't handle tilde — only the shell does.\n */\nfunction expandTilde(p: string): string {\n if (p === '~') return os.homedir();\n if (p.startsWith('~/') || p.startsWith('~\\\\')) {\n return nodePath.join(os.homedir(), p.slice(2));\n }\n return p;\n}\n\n/**\n * Resolve a database path to an absolute path.\n * Expands tilde and resolves relative paths against cwd (at construction time).\n */\nfunction resolveDbPath(p: string): string {\n return nodePath.resolve(expandTilde(p));\n}\n\n// ---------------------------------------------------------------------------\n// Path utilities (POSIX-style with leading slash)\n// ---------------------------------------------------------------------------\n\nfunction normalizePath(input: string): string {\n // Treat \".\" and \"\" as root — consistent with how CompositeFilesystem\n // and the Studio UI use \".\" to mean \"filesystem root\".\n if (input === '' || input === '.') return '/';\n\n let path = input.startsWith('/') ? input : '/' + input;\n\n let result = '';\n let prevSlash = false;\n for (let i = 0; i < path.length; i++) {\n const ch = path[i];\n if (ch === '/') {\n if (!prevSlash) {\n result += ch;\n }\n prevSlash = true;\n } else {\n result += ch;\n prevSlash = false;\n }\n }\n\n if (result.length > 1 && result.endsWith('/')) {\n result = result.slice(0, -1);\n }\n\n return result;\n}\n\nfunction getParentPath(path: string): string {\n const normalized = normalizePath(path);\n if (normalized === '/') return '/';\n const lastSlash = normalized.lastIndexOf('/');\n return lastSlash <= 0 ? '/' : normalized.slice(0, lastSlash);\n}\n\nfunction joinPath(base: string, name: string): string {\n if (base === '/') return normalizePath('/' + name);\n return normalizePath(base + '/' + name);\n}\n\nfunction getBaseName(path: string): string {\n const normalized = normalizePath(path);\n if (normalized === '/') return '';\n const lastSlash = normalized.lastIndexOf('/');\n return normalized.slice(lastSlash + 1);\n}\n\n// ---------------------------------------------------------------------------\n// Error mapping (AgentFS errno → Mastra workspace errors)\n// ---------------------------------------------------------------------------\n\ninterface ErrnoError {\n code?: string;\n message?: string;\n}\n\nfunction isErrnoError(error: unknown): error is ErrnoError {\n return typeof error === 'object' && error !== null && 'code' in error;\n}\n\nfunction mapError(error: unknown, path: string, context: 'file' | 'directory' = 'file'): Error {\n if (!isErrnoError(error)) {\n return error instanceof Error ? error : new Error(String(error));\n }\n\n switch (error.code) {\n case 'ENOENT':\n return context === 'directory' ? new DirectoryNotFoundError(path) : new FileNotFoundError(path);\n case 'EEXIST':\n return new FileExistsError(path);\n case 'EISDIR':\n return new IsDirectoryError(path);\n case 'ENOTDIR':\n return new NotDirectoryError(path);\n case 'ENOTEMPTY':\n return new DirectoryNotEmptyError(path);\n case 'EPERM':\n case 'EACCES':\n return new PermissionError(path, 'access');\n default:\n return error instanceof Error ? error : new Error(String(error));\n }\n}\n\nfunction hasCode(error: unknown, code: string): boolean {\n return isErrnoError(error) && error.code === code;\n}\n\n// ---------------------------------------------------------------------------\n// AgentFS Filesystem\n// ---------------------------------------------------------------------------\n\n/**\n * AgentFS filesystem provider configuration.\n */\nexport interface AgentFSFilesystemOptions extends MastraFilesystemOptions {\n /** Unique identifier for this filesystem instance */\n id?: string;\n /** Agent ID — creates database at `.agentfs/<agentId>.db` */\n agentId?: string;\n /** Explicit database file path */\n path?: string;\n /** Pre-opened AgentFS instance (skips open/close — caller manages lifecycle) */\n agent?: AgentFS;\n /** Block write operations (default: false) */\n readOnly?: boolean;\n /** Human-friendly display name for the UI */\n displayName?: string;\n /** Icon identifier for the UI (default: 'database') */\n icon?: FilesystemIcon;\n /** Description shown in tooltips */\n description?: string;\n}\n\n/**\n * AgentFS filesystem implementation.\n *\n * Stores files in a Turso/SQLite database via the AgentFS SDK.\n *\n * @example Using agentId\n * ```typescript\n * import { AgentFSFilesystem } from '@mastra/agentfs';\n *\n * const fs = new AgentFSFilesystem({ agentId: 'my-agent' });\n * ```\n *\n * @example Using a pre-opened instance\n * ```typescript\n * import { AgentFS } from 'agentfs-sdk';\n * import { AgentFSFilesystem } from '@mastra/agentfs';\n *\n * const agent = await AgentFS.open({ id: 'my-agent' });\n * const fs = new AgentFSFilesystem({ agent });\n * ```\n */\nexport class AgentFSFilesystem extends MastraFilesystem {\n readonly id: string;\n readonly name = 'AgentFSFilesystem';\n readonly provider = 'agentfs';\n readonly readOnly?: boolean;\n\n status: ProviderStatus = 'pending';\n\n // Display metadata\n readonly displayName?: string;\n readonly icon: FilesystemIcon;\n readonly description?: string;\n\n private _agent: AgentFS | null = null;\n private readonly _ownsAgent: boolean;\n private readonly _agentId?: string;\n private readonly _path?: string;\n\n constructor(options: AgentFSFilesystemOptions) {\n if (!options.agentId && !options.path && !options.agent) {\n throw new Error(\"AgentFSFilesystem requires at least one of 'agentId', 'path', or 'agent'.\");\n }\n\n super({ ...options, name: 'AgentFSFilesystem' });\n this.id = options.id ?? `agentfs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._agentId = options.agentId;\n this._path = options.path ? resolveDbPath(options.path) : undefined;\n this.readOnly = options.readOnly;\n\n if (options.agent) {\n this._agent = options.agent;\n this._ownsAgent = false;\n } else {\n this._ownsAgent = true;\n }\n\n this.icon = options.icon ?? 'database';\n this.displayName = options.displayName ?? 'AgentFS';\n this.description = options.description;\n }\n\n /** The underlying AgentFS instance, or null if not yet initialized. */\n get agent(): AgentFS | null {\n return this._agent;\n }\n\n // ---------------------------------------------------------------------------\n // Info\n // ---------------------------------------------------------------------------\n\n getInfo(): FilesystemInfo<{\n agentId?: string;\n dbPath?: string;\n }> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n error: this.error,\n readOnly: this.readOnly,\n icon: this.icon,\n metadata: {\n ...(this._agentId && { agentId: this._agentId }),\n ...(this._path && { dbPath: this._path }),\n },\n };\n }\n\n getInstructions(): string {\n const label = this._agentId ? `agent \"${this._agentId}\"` : 'database';\n const access = this.readOnly ? 'Read-only' : 'Persistent';\n return `AgentFS storage for ${label}. ${access} SQLite-backed filesystem — files are retained across sessions.`;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n async init(): Promise<void> {\n if (this._agent) return; // Pre-opened instance\n\n const openOptions: { id?: string; path?: string } = {};\n if (this._agentId) openOptions.id = this._agentId;\n if (this._path) {\n openOptions.path = this._path;\n // Ensure parent directory exists — the SDK only auto-creates `.agentfs/`\n // for the agentId-only case, not for explicit paths.\n mkdirSync(nodePath.dirname(this._path), { recursive: true });\n }\n\n this._agent = await AgentFS.open(openOptions);\n }\n\n async destroy(): Promise<void> {\n if (this._agent && this._ownsAgent) {\n await this._agent.close();\n }\n this._agent = null;\n }\n\n // ---------------------------------------------------------------------------\n // Internal helpers\n // ---------------------------------------------------------------------------\n\n private async getAgent(): Promise<AgentFS> {\n await this.ensureReady();\n return this._agent!;\n }\n\n private assertWritable(operation: string): void {\n if (this.readOnly) {\n throw new WorkspaceReadOnlyError(operation);\n }\n }\n\n // ---------------------------------------------------------------------------\n // File Operations\n // ---------------------------------------------------------------------------\n\n async readFile(path: string, options?: ReadOptions): Promise<string | Buffer> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n if (options?.encoding) {\n return await agent.fs.readFile(normalized, options.encoding);\n }\n return await agent.fs.readFile(normalized);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n async writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void> {\n this.assertWritable('writeFile');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Create parent directories (default behavior)\n if (options?.recursive !== false) {\n await this.mkdirRecursive(agent, getParentPath(normalized));\n }\n\n // Check overwrite\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalized);\n throw new FileExistsError(normalized);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalized, 'file');\n }\n }\n\n try {\n const data = typeof content === 'string' ? content : Buffer.from(content);\n await agent.fs.writeFile(normalized, data);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n async appendFile(path: string, content: FileContent): Promise<void> {\n this.assertWritable('appendFile');\n // AgentFS doesn't have native append — read + write (same pattern as S3Filesystem)\n let existing: Buffer = Buffer.alloc(0);\n try {\n const current = await this.readFile(path);\n existing = Buffer.isBuffer(current) ? Buffer.from(current) : Buffer.from(current);\n } catch (error) {\n if (error instanceof FileNotFoundError) {\n // File doesn't exist — start fresh\n } else {\n throw error;\n }\n }\n\n const appendBuffer = typeof content === 'string' ? Buffer.from(content, 'utf-8') : Buffer.from(content);\n await this.writeFile(path, Buffer.concat([existing, appendBuffer]));\n }\n\n async deleteFile(path: string, options?: RemoveOptions): Promise<void> {\n this.assertWritable('deleteFile');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Check if it's a directory\n try {\n const st = await agent.fs.stat(normalized);\n if (st.isDirectory()) {\n throw new IsDirectoryError(normalized);\n }\n } catch (error: unknown) {\n if (error instanceof IsDirectoryError) throw error;\n if (hasCode(error, 'ENOENT')) {\n if (options?.force) return;\n throw new FileNotFoundError(normalized);\n }\n throw mapError(error, normalized, 'file');\n }\n\n try {\n await agent.fs.unlink(normalized);\n } catch (error: unknown) {\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'file');\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n this.assertWritable('copyFile');\n const agent = await this.getAgent();\n const normalizedSrc = normalizePath(src);\n const normalizedDest = normalizePath(dest);\n\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalizedDest);\n throw new FileExistsError(normalizedDest);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalizedDest, 'file');\n }\n }\n\n try {\n // Check if source is a directory\n const st = await agent.fs.stat(normalizedSrc);\n if (st.isDirectory()) {\n if (!options?.recursive) {\n throw new IsDirectoryError(normalizedSrc);\n }\n await this.copyDirRecursive(agent, normalizedSrc, normalizedDest, options);\n return;\n }\n\n // Ensure parent directory of dest exists\n await this.mkdirRecursive(agent, getParentPath(normalizedDest));\n await agent.fs.copyFile(normalizedSrc, normalizedDest);\n } catch (error: unknown) {\n if (error instanceof IsDirectoryError || error instanceof FileExistsError) throw error;\n throw mapError(error, normalizedSrc, 'file');\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n this.assertWritable('moveFile');\n const agent = await this.getAgent();\n const normalizedSrc = normalizePath(src);\n const normalizedDest = normalizePath(dest);\n\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalizedDest);\n throw new FileExistsError(normalizedDest);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalizedDest, 'file');\n }\n }\n\n // Ensure parent directory of dest exists\n await this.mkdirRecursive(agent, getParentPath(normalizedDest));\n\n try {\n await agent.fs.rename(normalizedSrc, normalizedDest);\n } catch (error: unknown) {\n throw mapError(error, normalizedSrc, 'file');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Directory Operations\n // ---------------------------------------------------------------------------\n\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n this.assertWritable('mkdir');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Default to recursive (matches LocalFilesystem behavior)\n if (options?.recursive !== false) {\n await this.mkdirRecursive(agent, normalized);\n return;\n }\n\n try {\n await agent.fs.mkdir(normalized);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'directory');\n }\n }\n\n async rmdir(path: string, options?: RemoveOptions): Promise<void> {\n this.assertWritable('rmdir');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n if (options?.recursive) {\n try {\n await agent.fs.rm(normalized, { recursive: true });\n } catch (error: unknown) {\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'directory');\n }\n return;\n }\n\n // Non-recursive: check if empty first\n try {\n const entries = await agent.fs.readdir(normalized);\n if (entries.length > 0) {\n throw new DirectoryNotEmptyError(normalized);\n }\n await agent.fs.rmdir(normalized);\n } catch (error: unknown) {\n if (error instanceof DirectoryNotEmptyError) throw error;\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'directory');\n }\n }\n\n async readdir(path: string, options?: ListOptions): Promise<FileEntry[]> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n // Verify it's a directory\n const st = await agent.fs.stat(normalized);\n if (!st.isDirectory()) {\n throw new NotDirectoryError(normalized);\n }\n\n const dirEntries = await agent.fs.readdirPlus(normalized);\n let entries: FileEntry[] = dirEntries.map(entry => ({\n name: entry.name,\n type: entry.stats.isDirectory() ? ('directory' as const) : ('file' as const),\n size: entry.stats.size,\n }));\n\n // Apply extension filter\n if (options?.extension) {\n const extensions = Array.isArray(options.extension) ? options.extension : [options.extension];\n entries = entries.filter(entry => {\n if (entry.type === 'directory') return true;\n return extensions.some(ext => entry.name.endsWith(ext));\n });\n }\n\n // Recurse if requested\n if (options?.recursive) {\n const maxDepth = options.maxDepth ?? Infinity;\n const subdirs = entries.filter(e => e.type === 'directory');\n for (const dir of subdirs) {\n if (maxDepth > 1) {\n const subEntries = await this.readdir(joinPath(normalized, dir.name), {\n ...options,\n maxDepth: maxDepth - 1,\n });\n for (const sub of subEntries) {\n entries.push({\n ...sub,\n name: dir.name + '/' + sub.name,\n });\n }\n }\n }\n }\n\n return entries;\n } catch (error: unknown) {\n if (error instanceof NotDirectoryError || error instanceof DirectoryNotFoundError) {\n throw error;\n }\n throw mapError(error, normalized, 'directory');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Path Operations\n // ---------------------------------------------------------------------------\n\n async exists(path: string): Promise<boolean> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n await agent.fs.access(normalized);\n return true;\n } catch {\n return false;\n }\n }\n\n async stat(path: string): Promise<FileStat> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n const st = await agent.fs.stat(normalized);\n const isDirectory = st.isDirectory();\n return {\n name: getBaseName(normalized) || '',\n path: normalized,\n type: isDirectory ? 'directory' : 'file',\n size: st.size,\n createdAt: new Date(st.ctime * 1000),\n modifiedAt: new Date(st.mtime * 1000),\n // read_file picks media, binary or text from mimeType.\n ...(!isDirectory && { mimeType: getMimeType(normalized) }),\n };\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Type checks\n // ---------------------------------------------------------------------------\n\n /**\n * Check if the path points to a file.\n * Returns `false` if the path doesn't exist.\n */\n async isFile(path: string): Promise<boolean> {\n try {\n const st = await this.stat(path);\n return st.type === 'file';\n } catch (error) {\n if (error instanceof FileNotFoundError) return false;\n throw error;\n }\n }\n\n /**\n * Check if the path points to a directory.\n * Returns `false` if the path doesn't exist.\n */\n async isDirectory(path: string): Promise<boolean> {\n try {\n const st = await this.stat(path);\n return st.type === 'directory';\n } catch (error) {\n if (error instanceof FileNotFoundError) return false;\n throw error;\n }\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Recursively create directories, ignoring EEXIST errors.\n */\n private async mkdirRecursive(agent: AgentFS, path: string): Promise<void> {\n if (path === '/') return;\n\n const segments = path.split('/').filter(Boolean);\n let current = '';\n for (const segment of segments) {\n current += '/' + segment;\n try {\n await agent.fs.mkdir(current);\n } catch (error: unknown) {\n if (!hasCode(error, 'EEXIST')) {\n throw mapError(error, current, 'directory');\n }\n }\n }\n }\n\n /**\n * Recursively copy a directory tree.\n */\n private async copyDirRecursive(agent: AgentFS, src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.mkdirRecursive(agent, dest);\n\n const entries = await agent.fs.readdirPlus(src);\n for (const entry of entries) {\n const srcChild = joinPath(src, entry.name);\n const destChild = joinPath(dest, entry.name);\n\n if (entry.stats.isDirectory()) {\n await this.copyDirRecursive(agent, srcChild, destChild, options);\n } else {\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(destChild);\n throw new FileExistsError(destChild);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, destChild, 'file');\n }\n }\n await agent.fs.copyFile(srcChild, destChild);\n }\n }\n }\n}\n","/**\n * AgentFS filesystem provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { agentfsFilesystemProvider } from '@mastra/agentfs';\n *\n * const editor = new MastraEditor({\n * filesystems: [agentfsFilesystemProvider],\n * });\n * ```\n */\nimport type { FilesystemProvider } from '@mastra/core/editor';\nimport { AgentFSFilesystem } from './filesystem';\nimport type { AgentFSFilesystemOptions } from './filesystem';\n\nexport const agentfsFilesystemProvider: FilesystemProvider<AgentFSFilesystemOptions> = {\n id: 'agentfs',\n name: 'AgentFS',\n description: 'Turso/SQLite-backed filesystem via AgentFS',\n configSchema: {\n type: 'object',\n properties: {\n agentId: { type: 'string', description: 'Agent ID — creates database at .agentfs/<agentId>.db' },\n path: { type: 'string', description: 'Explicit database file path (alternative to agentId)' },\n readOnly: { type: 'boolean', description: 'Mount as read-only', default: false },\n },\n },\n createFilesystem: config => new AgentFSFilesystem(config),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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C3B,MAAM,WAAW,SAAS,KAAK,MAAM,IAAI;GACzC,MAAM,YAAY,SAAS,MAAM,MAAM,IAAI;GAE3C,IAAI,MAAM,MAAM,YAAY,GAC1B,MAAM,KAAK,iBAAiB,OAAO,UAAU,WAAW,OAAO;QAC1D;IACL,IAAI,SAAS,cAAc,OACzB,IAAI;KACF,MAAM,MAAM,GAAG,OAAO,SAAS;KAC/B,MAAM,IAAIC,uBAAAA,gBAAgB,SAAS;IACrC,SAAS,OAAgB;KACvB,IAAI,iBAAiBA,uBAAAA,iBAAiB,MAAM;KAC5C,IAAI,CAAC,QAAQ,OAAO,QAAQ,GAAG,MAAM,SAAS,OAAO,WAAW,MAAM;IACxE;IAEF,MAAM,MAAM,GAAG,SAAS,UAAU,SAAS;GAC7C;EACF;CACF;AACF;;AC9qBA,MAAa,4BAA0E;CACrF,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,YAAY;GACV,SAAS;IAAE,MAAM;IAAU,aAAa;GAAuD;GAC/F,MAAM;IAAE,MAAM;IAAU,aAAa;GAAuD;GAC5F,UAAU;IAAE,MAAM;IAAW,aAAa;IAAsB,SAAS;GAAM;EACjF;CACF;CACA,mBAAkB,WAAU,IAAI,kBAAkB,MAAM;AAC1D"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { mkdirSync } from "fs";
2
2
  import os from "os";
3
3
  import nodePath from "path";
4
- import { DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, NotDirectoryError, PermissionError, WorkspaceReadOnlyError } from "@mastra/core/workspace";
4
+ import { DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, NotDirectoryError, PermissionError, WorkspaceReadOnlyError, getMimeType } from "@mastra/core/workspace";
5
5
  import { AgentFS } from "agentfs-sdk";
6
- //#region src/filesystem/index.ts
6
+ // src/filesystem/index.ts
7
7
  /**
8
8
  * AgentFS Filesystem Provider
9
9
  *
@@ -368,13 +368,15 @@ var AgentFSFilesystem = class extends MastraFilesystem {
368
368
  const normalized = normalizePath(path);
369
369
  try {
370
370
  const st = await agent.fs.stat(normalized);
371
+ const isDirectory = st.isDirectory();
371
372
  return {
372
373
  name: getBaseName(normalized) || "",
373
374
  path: normalized,
374
- type: st.isDirectory() ? "directory" : "file",
375
+ type: isDirectory ? "directory" : "file",
375
376
  size: st.size,
376
377
  createdAt: /* @__PURE__ */ new Date(st.ctime * 1e3),
377
- modifiedAt: /* @__PURE__ */ new Date(st.mtime * 1e3)
378
+ modifiedAt: /* @__PURE__ */ new Date(st.mtime * 1e3),
379
+ ...!isDirectory && { mimeType: getMimeType(normalized) }
378
380
  };
379
381
  } catch (error) {
380
382
  throw mapError(error, normalized, "file");
@@ -443,8 +445,7 @@ var AgentFSFilesystem = class extends MastraFilesystem {
443
445
  }
444
446
  }
445
447
  };
446
- //#endregion
447
- //#region src/provider.ts
448
+ // src/provider.ts
448
449
  const agentfsFilesystemProvider = {
449
450
  id: "agentfs",
450
451
  name: "AgentFS",
@@ -469,7 +470,6 @@ const agentfsFilesystemProvider = {
469
470
  },
470
471
  createFilesystem: (config) => new AgentFSFilesystem(config)
471
472
  };
472
- //#endregion
473
473
  export { AgentFSFilesystem, agentfsFilesystemProvider };
474
474
 
475
475
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/filesystem/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * AgentFS Filesystem Provider\n *\n * Implements WorkspaceFilesystem backed by AgentFS (Turso/SQLite).\n * Follows the same pattern as S3Filesystem.\n */\n\nimport { mkdirSync } from 'node:fs';\nimport os from 'node:os';\nimport nodePath from 'node:path';\nimport type {\n FileContent,\n FileStat,\n FileEntry,\n ReadOptions,\n WriteOptions,\n ListOptions,\n RemoveOptions,\n CopyOptions,\n FilesystemIcon,\n FilesystemInfo,\n ProviderStatus,\n MastraFilesystemOptions,\n} from '@mastra/core/workspace';\nimport {\n MastraFilesystem,\n FileNotFoundError,\n FileExistsError,\n IsDirectoryError,\n NotDirectoryError,\n DirectoryNotFoundError,\n DirectoryNotEmptyError,\n PermissionError,\n WorkspaceReadOnlyError,\n} from '@mastra/core/workspace';\nimport { AgentFS } from 'agentfs-sdk';\n\n// ---------------------------------------------------------------------------\n// Database path resolution\n// ---------------------------------------------------------------------------\n\n/**\n * Expand a leading `~` to the user's home directory.\n * Node.js path APIs don't handle tilde — only the shell does.\n */\nfunction expandTilde(p: string): string {\n if (p === '~') return os.homedir();\n if (p.startsWith('~/') || p.startsWith('~\\\\')) {\n return nodePath.join(os.homedir(), p.slice(2));\n }\n return p;\n}\n\n/**\n * Resolve a database path to an absolute path.\n * Expands tilde and resolves relative paths against cwd (at construction time).\n */\nfunction resolveDbPath(p: string): string {\n return nodePath.resolve(expandTilde(p));\n}\n\n// ---------------------------------------------------------------------------\n// Path utilities (POSIX-style with leading slash)\n// ---------------------------------------------------------------------------\n\nfunction normalizePath(input: string): string {\n // Treat \".\" and \"\" as root — consistent with how CompositeFilesystem\n // and the Studio UI use \".\" to mean \"filesystem root\".\n if (input === '' || input === '.') return '/';\n\n let path = input.startsWith('/') ? input : '/' + input;\n\n let result = '';\n let prevSlash = false;\n for (let i = 0; i < path.length; i++) {\n const ch = path[i];\n if (ch === '/') {\n if (!prevSlash) {\n result += ch;\n }\n prevSlash = true;\n } else {\n result += ch;\n prevSlash = false;\n }\n }\n\n if (result.length > 1 && result.endsWith('/')) {\n result = result.slice(0, -1);\n }\n\n return result;\n}\n\nfunction getParentPath(path: string): string {\n const normalized = normalizePath(path);\n if (normalized === '/') return '/';\n const lastSlash = normalized.lastIndexOf('/');\n return lastSlash <= 0 ? '/' : normalized.slice(0, lastSlash);\n}\n\nfunction joinPath(base: string, name: string): string {\n if (base === '/') return normalizePath('/' + name);\n return normalizePath(base + '/' + name);\n}\n\nfunction getBaseName(path: string): string {\n const normalized = normalizePath(path);\n if (normalized === '/') return '';\n const lastSlash = normalized.lastIndexOf('/');\n return normalized.slice(lastSlash + 1);\n}\n\n// ---------------------------------------------------------------------------\n// Error mapping (AgentFS errno → Mastra workspace errors)\n// ---------------------------------------------------------------------------\n\ninterface ErrnoError {\n code?: string;\n message?: string;\n}\n\nfunction isErrnoError(error: unknown): error is ErrnoError {\n return typeof error === 'object' && error !== null && 'code' in error;\n}\n\nfunction mapError(error: unknown, path: string, context: 'file' | 'directory' = 'file'): Error {\n if (!isErrnoError(error)) {\n return error instanceof Error ? error : new Error(String(error));\n }\n\n switch (error.code) {\n case 'ENOENT':\n return context === 'directory' ? new DirectoryNotFoundError(path) : new FileNotFoundError(path);\n case 'EEXIST':\n return new FileExistsError(path);\n case 'EISDIR':\n return new IsDirectoryError(path);\n case 'ENOTDIR':\n return new NotDirectoryError(path);\n case 'ENOTEMPTY':\n return new DirectoryNotEmptyError(path);\n case 'EPERM':\n case 'EACCES':\n return new PermissionError(path, 'access');\n default:\n return error instanceof Error ? error : new Error(String(error));\n }\n}\n\nfunction hasCode(error: unknown, code: string): boolean {\n return isErrnoError(error) && error.code === code;\n}\n\n// ---------------------------------------------------------------------------\n// AgentFS Filesystem\n// ---------------------------------------------------------------------------\n\n/**\n * AgentFS filesystem provider configuration.\n */\nexport interface AgentFSFilesystemOptions extends MastraFilesystemOptions {\n /** Unique identifier for this filesystem instance */\n id?: string;\n /** Agent ID — creates database at `.agentfs/<agentId>.db` */\n agentId?: string;\n /** Explicit database file path */\n path?: string;\n /** Pre-opened AgentFS instance (skips open/close — caller manages lifecycle) */\n agent?: AgentFS;\n /** Block write operations (default: false) */\n readOnly?: boolean;\n /** Human-friendly display name for the UI */\n displayName?: string;\n /** Icon identifier for the UI (default: 'database') */\n icon?: FilesystemIcon;\n /** Description shown in tooltips */\n description?: string;\n}\n\n/**\n * AgentFS filesystem implementation.\n *\n * Stores files in a Turso/SQLite database via the AgentFS SDK.\n *\n * @example Using agentId\n * ```typescript\n * import { AgentFSFilesystem } from '@mastra/agentfs';\n *\n * const fs = new AgentFSFilesystem({ agentId: 'my-agent' });\n * ```\n *\n * @example Using a pre-opened instance\n * ```typescript\n * import { AgentFS } from 'agentfs-sdk';\n * import { AgentFSFilesystem } from '@mastra/agentfs';\n *\n * const agent = await AgentFS.open({ id: 'my-agent' });\n * const fs = new AgentFSFilesystem({ agent });\n * ```\n */\nexport class AgentFSFilesystem extends MastraFilesystem {\n readonly id: string;\n readonly name = 'AgentFSFilesystem';\n readonly provider = 'agentfs';\n readonly readOnly?: boolean;\n\n status: ProviderStatus = 'pending';\n\n // Display metadata\n readonly displayName?: string;\n readonly icon: FilesystemIcon;\n readonly description?: string;\n\n private _agent: AgentFS | null = null;\n private readonly _ownsAgent: boolean;\n private readonly _agentId?: string;\n private readonly _path?: string;\n\n constructor(options: AgentFSFilesystemOptions) {\n if (!options.agentId && !options.path && !options.agent) {\n throw new Error(\"AgentFSFilesystem requires at least one of 'agentId', 'path', or 'agent'.\");\n }\n\n super({ ...options, name: 'AgentFSFilesystem' });\n this.id = options.id ?? `agentfs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._agentId = options.agentId;\n this._path = options.path ? resolveDbPath(options.path) : undefined;\n this.readOnly = options.readOnly;\n\n if (options.agent) {\n this._agent = options.agent;\n this._ownsAgent = false;\n } else {\n this._ownsAgent = true;\n }\n\n this.icon = options.icon ?? 'database';\n this.displayName = options.displayName ?? 'AgentFS';\n this.description = options.description;\n }\n\n /** The underlying AgentFS instance, or null if not yet initialized. */\n get agent(): AgentFS | null {\n return this._agent;\n }\n\n // ---------------------------------------------------------------------------\n // Info\n // ---------------------------------------------------------------------------\n\n getInfo(): FilesystemInfo<{\n agentId?: string;\n dbPath?: string;\n }> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n error: this.error,\n readOnly: this.readOnly,\n icon: this.icon,\n metadata: {\n ...(this._agentId && { agentId: this._agentId }),\n ...(this._path && { dbPath: this._path }),\n },\n };\n }\n\n getInstructions(): string {\n const label = this._agentId ? `agent \"${this._agentId}\"` : 'database';\n const access = this.readOnly ? 'Read-only' : 'Persistent';\n return `AgentFS storage for ${label}. ${access} SQLite-backed filesystem — files are retained across sessions.`;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n async init(): Promise<void> {\n if (this._agent) return; // Pre-opened instance\n\n const openOptions: { id?: string; path?: string } = {};\n if (this._agentId) openOptions.id = this._agentId;\n if (this._path) {\n openOptions.path = this._path;\n // Ensure parent directory exists — the SDK only auto-creates `.agentfs/`\n // for the agentId-only case, not for explicit paths.\n mkdirSync(nodePath.dirname(this._path), { recursive: true });\n }\n\n this._agent = await AgentFS.open(openOptions);\n }\n\n async destroy(): Promise<void> {\n if (this._agent && this._ownsAgent) {\n await this._agent.close();\n }\n this._agent = null;\n }\n\n // ---------------------------------------------------------------------------\n // Internal helpers\n // ---------------------------------------------------------------------------\n\n private async getAgent(): Promise<AgentFS> {\n await this.ensureReady();\n return this._agent!;\n }\n\n private assertWritable(operation: string): void {\n if (this.readOnly) {\n throw new WorkspaceReadOnlyError(operation);\n }\n }\n\n // ---------------------------------------------------------------------------\n // File Operations\n // ---------------------------------------------------------------------------\n\n async readFile(path: string, options?: ReadOptions): Promise<string | Buffer> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n if (options?.encoding) {\n return await agent.fs.readFile(normalized, options.encoding);\n }\n return await agent.fs.readFile(normalized);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n async writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void> {\n this.assertWritable('writeFile');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Create parent directories (default behavior)\n if (options?.recursive !== false) {\n await this.mkdirRecursive(agent, getParentPath(normalized));\n }\n\n // Check overwrite\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalized);\n throw new FileExistsError(normalized);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalized, 'file');\n }\n }\n\n try {\n const data = typeof content === 'string' ? content : Buffer.from(content);\n await agent.fs.writeFile(normalized, data);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n async appendFile(path: string, content: FileContent): Promise<void> {\n this.assertWritable('appendFile');\n // AgentFS doesn't have native append — read + write (same pattern as S3Filesystem)\n let existing: Buffer = Buffer.alloc(0);\n try {\n const current = await this.readFile(path);\n existing = Buffer.isBuffer(current) ? Buffer.from(current) : Buffer.from(current);\n } catch (error) {\n if (error instanceof FileNotFoundError) {\n // File doesn't exist — start fresh\n } else {\n throw error;\n }\n }\n\n const appendBuffer = typeof content === 'string' ? Buffer.from(content, 'utf-8') : Buffer.from(content);\n await this.writeFile(path, Buffer.concat([existing, appendBuffer]));\n }\n\n async deleteFile(path: string, options?: RemoveOptions): Promise<void> {\n this.assertWritable('deleteFile');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Check if it's a directory\n try {\n const st = await agent.fs.stat(normalized);\n if (st.isDirectory()) {\n throw new IsDirectoryError(normalized);\n }\n } catch (error: unknown) {\n if (error instanceof IsDirectoryError) throw error;\n if (hasCode(error, 'ENOENT')) {\n if (options?.force) return;\n throw new FileNotFoundError(normalized);\n }\n throw mapError(error, normalized, 'file');\n }\n\n try {\n await agent.fs.unlink(normalized);\n } catch (error: unknown) {\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'file');\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n this.assertWritable('copyFile');\n const agent = await this.getAgent();\n const normalizedSrc = normalizePath(src);\n const normalizedDest = normalizePath(dest);\n\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalizedDest);\n throw new FileExistsError(normalizedDest);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalizedDest, 'file');\n }\n }\n\n try {\n // Check if source is a directory\n const st = await agent.fs.stat(normalizedSrc);\n if (st.isDirectory()) {\n if (!options?.recursive) {\n throw new IsDirectoryError(normalizedSrc);\n }\n await this.copyDirRecursive(agent, normalizedSrc, normalizedDest, options);\n return;\n }\n\n // Ensure parent directory of dest exists\n await this.mkdirRecursive(agent, getParentPath(normalizedDest));\n await agent.fs.copyFile(normalizedSrc, normalizedDest);\n } catch (error: unknown) {\n if (error instanceof IsDirectoryError || error instanceof FileExistsError) throw error;\n throw mapError(error, normalizedSrc, 'file');\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n this.assertWritable('moveFile');\n const agent = await this.getAgent();\n const normalizedSrc = normalizePath(src);\n const normalizedDest = normalizePath(dest);\n\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalizedDest);\n throw new FileExistsError(normalizedDest);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalizedDest, 'file');\n }\n }\n\n // Ensure parent directory of dest exists\n await this.mkdirRecursive(agent, getParentPath(normalizedDest));\n\n try {\n await agent.fs.rename(normalizedSrc, normalizedDest);\n } catch (error: unknown) {\n throw mapError(error, normalizedSrc, 'file');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Directory Operations\n // ---------------------------------------------------------------------------\n\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n this.assertWritable('mkdir');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Default to recursive (matches LocalFilesystem behavior)\n if (options?.recursive !== false) {\n await this.mkdirRecursive(agent, normalized);\n return;\n }\n\n try {\n await agent.fs.mkdir(normalized);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'directory');\n }\n }\n\n async rmdir(path: string, options?: RemoveOptions): Promise<void> {\n this.assertWritable('rmdir');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n if (options?.recursive) {\n try {\n await agent.fs.rm(normalized, { recursive: true });\n } catch (error: unknown) {\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'directory');\n }\n return;\n }\n\n // Non-recursive: check if empty first\n try {\n const entries = await agent.fs.readdir(normalized);\n if (entries.length > 0) {\n throw new DirectoryNotEmptyError(normalized);\n }\n await agent.fs.rmdir(normalized);\n } catch (error: unknown) {\n if (error instanceof DirectoryNotEmptyError) throw error;\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'directory');\n }\n }\n\n async readdir(path: string, options?: ListOptions): Promise<FileEntry[]> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n // Verify it's a directory\n const st = await agent.fs.stat(normalized);\n if (!st.isDirectory()) {\n throw new NotDirectoryError(normalized);\n }\n\n const dirEntries = await agent.fs.readdirPlus(normalized);\n let entries: FileEntry[] = dirEntries.map(entry => ({\n name: entry.name,\n type: entry.stats.isDirectory() ? ('directory' as const) : ('file' as const),\n size: entry.stats.size,\n }));\n\n // Apply extension filter\n if (options?.extension) {\n const extensions = Array.isArray(options.extension) ? options.extension : [options.extension];\n entries = entries.filter(entry => {\n if (entry.type === 'directory') return true;\n return extensions.some(ext => entry.name.endsWith(ext));\n });\n }\n\n // Recurse if requested\n if (options?.recursive) {\n const maxDepth = options.maxDepth ?? Infinity;\n const subdirs = entries.filter(e => e.type === 'directory');\n for (const dir of subdirs) {\n if (maxDepth > 1) {\n const subEntries = await this.readdir(joinPath(normalized, dir.name), {\n ...options,\n maxDepth: maxDepth - 1,\n });\n for (const sub of subEntries) {\n entries.push({\n ...sub,\n name: dir.name + '/' + sub.name,\n });\n }\n }\n }\n }\n\n return entries;\n } catch (error: unknown) {\n if (error instanceof NotDirectoryError || error instanceof DirectoryNotFoundError) {\n throw error;\n }\n throw mapError(error, normalized, 'directory');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Path Operations\n // ---------------------------------------------------------------------------\n\n async exists(path: string): Promise<boolean> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n await agent.fs.access(normalized);\n return true;\n } catch {\n return false;\n }\n }\n\n async stat(path: string): Promise<FileStat> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n const st = await agent.fs.stat(normalized);\n return {\n name: getBaseName(normalized) || '',\n path: normalized,\n type: st.isDirectory() ? 'directory' : 'file',\n size: st.size,\n createdAt: new Date(st.ctime * 1000),\n modifiedAt: new Date(st.mtime * 1000),\n };\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Type checks\n // ---------------------------------------------------------------------------\n\n /**\n * Check if the path points to a file.\n * Returns `false` if the path doesn't exist.\n */\n async isFile(path: string): Promise<boolean> {\n try {\n const st = await this.stat(path);\n return st.type === 'file';\n } catch (error) {\n if (error instanceof FileNotFoundError) return false;\n throw error;\n }\n }\n\n /**\n * Check if the path points to a directory.\n * Returns `false` if the path doesn't exist.\n */\n async isDirectory(path: string): Promise<boolean> {\n try {\n const st = await this.stat(path);\n return st.type === 'directory';\n } catch (error) {\n if (error instanceof FileNotFoundError) return false;\n throw error;\n }\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Recursively create directories, ignoring EEXIST errors.\n */\n private async mkdirRecursive(agent: AgentFS, path: string): Promise<void> {\n if (path === '/') return;\n\n const segments = path.split('/').filter(Boolean);\n let current = '';\n for (const segment of segments) {\n current += '/' + segment;\n try {\n await agent.fs.mkdir(current);\n } catch (error: unknown) {\n if (!hasCode(error, 'EEXIST')) {\n throw mapError(error, current, 'directory');\n }\n }\n }\n }\n\n /**\n * Recursively copy a directory tree.\n */\n private async copyDirRecursive(agent: AgentFS, src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.mkdirRecursive(agent, dest);\n\n const entries = await agent.fs.readdirPlus(src);\n for (const entry of entries) {\n const srcChild = joinPath(src, entry.name);\n const destChild = joinPath(dest, entry.name);\n\n if (entry.stats.isDirectory()) {\n await this.copyDirRecursive(agent, srcChild, destChild, options);\n } else {\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(destChild);\n throw new FileExistsError(destChild);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, destChild, 'file');\n }\n }\n await agent.fs.copyFile(srcChild, destChild);\n }\n }\n }\n}\n","/**\n * AgentFS filesystem provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { agentfsFilesystemProvider } from '@mastra/agentfs';\n *\n * const editor = new MastraEditor({\n * filesystems: [agentfsFilesystemProvider],\n * });\n * ```\n */\nimport type { FilesystemProvider } from '@mastra/core/editor';\nimport { AgentFSFilesystem } from './filesystem';\nimport type { AgentFSFilesystemOptions } from './filesystem';\n\nexport const agentfsFilesystemProvider: FilesystemProvider<AgentFSFilesystemOptions> = {\n id: 'agentfs',\n name: 'AgentFS',\n description: 'Turso/SQLite-backed filesystem via AgentFS',\n configSchema: {\n type: 'object',\n properties: {\n agentId: { type: 'string', description: 'Agent ID — creates database at .agentfs/<agentId>.db' },\n path: { type: 'string', description: 'Explicit database file path (alternative to agentId)' },\n readOnly: { type: 'boolean', description: 'Mount as read-only', default: false },\n },\n },\n createFilesystem: config => new AgentFSFilesystem(config),\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA6CA,SAAS,YAAY,GAAmB;CACtC,IAAI,MAAM,KAAK,OAAO,GAAG,QAAQ;CACjC,IAAI,EAAE,WAAW,IAAI,KAAK,EAAE,WAAW,KAAK,GAC1C,OAAO,SAAS,KAAK,GAAG,QAAQ,GAAG,EAAE,MAAM,CAAC,CAAC;CAE/C,OAAO;AACT;;;;;AAMA,SAAS,cAAc,GAAmB;CACxC,OAAO,SAAS,QAAQ,YAAY,CAAC,CAAC;AACxC;AAMA,SAAS,cAAc,OAAuB;CAG5C,IAAI,UAAU,MAAM,UAAU,KAAK,OAAO;CAE1C,IAAI,OAAO,MAAM,WAAW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AgentFS Filesystem Provider\n *\n * Implements WorkspaceFilesystem backed by AgentFS (Turso/SQLite).\n * Follows the same pattern as S3Filesystem.\n */\n\nimport { mkdirSync } from 'node:fs';\nimport os from 'node:os';\nimport nodePath from 'node:path';\nimport type {\n FileContent,\n FileStat,\n FileEntry,\n ReadOptions,\n WriteOptions,\n ListOptions,\n RemoveOptions,\n CopyOptions,\n FilesystemIcon,\n FilesystemInfo,\n ProviderStatus,\n MastraFilesystemOptions,\n} from '@mastra/core/workspace';\nimport {\n MastraFilesystem,\n FileNotFoundError,\n FileExistsError,\n getMimeType,\n IsDirectoryError,\n NotDirectoryError,\n DirectoryNotFoundError,\n DirectoryNotEmptyError,\n PermissionError,\n WorkspaceReadOnlyError,\n} from '@mastra/core/workspace';\nimport { AgentFS } from 'agentfs-sdk';\n\n// ---------------------------------------------------------------------------\n// Database path resolution\n// ---------------------------------------------------------------------------\n\n/**\n * Expand a leading `~` to the user's home directory.\n * Node.js path APIs don't handle tilde — only the shell does.\n */\nfunction expandTilde(p: string): string {\n if (p === '~') return os.homedir();\n if (p.startsWith('~/') || p.startsWith('~\\\\')) {\n return nodePath.join(os.homedir(), p.slice(2));\n }\n return p;\n}\n\n/**\n * Resolve a database path to an absolute path.\n * Expands tilde and resolves relative paths against cwd (at construction time).\n */\nfunction resolveDbPath(p: string): string {\n return nodePath.resolve(expandTilde(p));\n}\n\n// ---------------------------------------------------------------------------\n// Path utilities (POSIX-style with leading slash)\n// ---------------------------------------------------------------------------\n\nfunction normalizePath(input: string): string {\n // Treat \".\" and \"\" as root — consistent with how CompositeFilesystem\n // and the Studio UI use \".\" to mean \"filesystem root\".\n if (input === '' || input === '.') return '/';\n\n let path = input.startsWith('/') ? input : '/' + input;\n\n let result = '';\n let prevSlash = false;\n for (let i = 0; i < path.length; i++) {\n const ch = path[i];\n if (ch === '/') {\n if (!prevSlash) {\n result += ch;\n }\n prevSlash = true;\n } else {\n result += ch;\n prevSlash = false;\n }\n }\n\n if (result.length > 1 && result.endsWith('/')) {\n result = result.slice(0, -1);\n }\n\n return result;\n}\n\nfunction getParentPath(path: string): string {\n const normalized = normalizePath(path);\n if (normalized === '/') return '/';\n const lastSlash = normalized.lastIndexOf('/');\n return lastSlash <= 0 ? '/' : normalized.slice(0, lastSlash);\n}\n\nfunction joinPath(base: string, name: string): string {\n if (base === '/') return normalizePath('/' + name);\n return normalizePath(base + '/' + name);\n}\n\nfunction getBaseName(path: string): string {\n const normalized = normalizePath(path);\n if (normalized === '/') return '';\n const lastSlash = normalized.lastIndexOf('/');\n return normalized.slice(lastSlash + 1);\n}\n\n// ---------------------------------------------------------------------------\n// Error mapping (AgentFS errno → Mastra workspace errors)\n// ---------------------------------------------------------------------------\n\ninterface ErrnoError {\n code?: string;\n message?: string;\n}\n\nfunction isErrnoError(error: unknown): error is ErrnoError {\n return typeof error === 'object' && error !== null && 'code' in error;\n}\n\nfunction mapError(error: unknown, path: string, context: 'file' | 'directory' = 'file'): Error {\n if (!isErrnoError(error)) {\n return error instanceof Error ? error : new Error(String(error));\n }\n\n switch (error.code) {\n case 'ENOENT':\n return context === 'directory' ? new DirectoryNotFoundError(path) : new FileNotFoundError(path);\n case 'EEXIST':\n return new FileExistsError(path);\n case 'EISDIR':\n return new IsDirectoryError(path);\n case 'ENOTDIR':\n return new NotDirectoryError(path);\n case 'ENOTEMPTY':\n return new DirectoryNotEmptyError(path);\n case 'EPERM':\n case 'EACCES':\n return new PermissionError(path, 'access');\n default:\n return error instanceof Error ? error : new Error(String(error));\n }\n}\n\nfunction hasCode(error: unknown, code: string): boolean {\n return isErrnoError(error) && error.code === code;\n}\n\n// ---------------------------------------------------------------------------\n// AgentFS Filesystem\n// ---------------------------------------------------------------------------\n\n/**\n * AgentFS filesystem provider configuration.\n */\nexport interface AgentFSFilesystemOptions extends MastraFilesystemOptions {\n /** Unique identifier for this filesystem instance */\n id?: string;\n /** Agent ID — creates database at `.agentfs/<agentId>.db` */\n agentId?: string;\n /** Explicit database file path */\n path?: string;\n /** Pre-opened AgentFS instance (skips open/close — caller manages lifecycle) */\n agent?: AgentFS;\n /** Block write operations (default: false) */\n readOnly?: boolean;\n /** Human-friendly display name for the UI */\n displayName?: string;\n /** Icon identifier for the UI (default: 'database') */\n icon?: FilesystemIcon;\n /** Description shown in tooltips */\n description?: string;\n}\n\n/**\n * AgentFS filesystem implementation.\n *\n * Stores files in a Turso/SQLite database via the AgentFS SDK.\n *\n * @example Using agentId\n * ```typescript\n * import { AgentFSFilesystem } from '@mastra/agentfs';\n *\n * const fs = new AgentFSFilesystem({ agentId: 'my-agent' });\n * ```\n *\n * @example Using a pre-opened instance\n * ```typescript\n * import { AgentFS } from 'agentfs-sdk';\n * import { AgentFSFilesystem } from '@mastra/agentfs';\n *\n * const agent = await AgentFS.open({ id: 'my-agent' });\n * const fs = new AgentFSFilesystem({ agent });\n * ```\n */\nexport class AgentFSFilesystem extends MastraFilesystem {\n readonly id: string;\n readonly name = 'AgentFSFilesystem';\n readonly provider = 'agentfs';\n readonly readOnly?: boolean;\n\n status: ProviderStatus = 'pending';\n\n // Display metadata\n readonly displayName?: string;\n readonly icon: FilesystemIcon;\n readonly description?: string;\n\n private _agent: AgentFS | null = null;\n private readonly _ownsAgent: boolean;\n private readonly _agentId?: string;\n private readonly _path?: string;\n\n constructor(options: AgentFSFilesystemOptions) {\n if (!options.agentId && !options.path && !options.agent) {\n throw new Error(\"AgentFSFilesystem requires at least one of 'agentId', 'path', or 'agent'.\");\n }\n\n super({ ...options, name: 'AgentFSFilesystem' });\n this.id = options.id ?? `agentfs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._agentId = options.agentId;\n this._path = options.path ? resolveDbPath(options.path) : undefined;\n this.readOnly = options.readOnly;\n\n if (options.agent) {\n this._agent = options.agent;\n this._ownsAgent = false;\n } else {\n this._ownsAgent = true;\n }\n\n this.icon = options.icon ?? 'database';\n this.displayName = options.displayName ?? 'AgentFS';\n this.description = options.description;\n }\n\n /** The underlying AgentFS instance, or null if not yet initialized. */\n get agent(): AgentFS | null {\n return this._agent;\n }\n\n // ---------------------------------------------------------------------------\n // Info\n // ---------------------------------------------------------------------------\n\n getInfo(): FilesystemInfo<{\n agentId?: string;\n dbPath?: string;\n }> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n error: this.error,\n readOnly: this.readOnly,\n icon: this.icon,\n metadata: {\n ...(this._agentId && { agentId: this._agentId }),\n ...(this._path && { dbPath: this._path }),\n },\n };\n }\n\n getInstructions(): string {\n const label = this._agentId ? `agent \"${this._agentId}\"` : 'database';\n const access = this.readOnly ? 'Read-only' : 'Persistent';\n return `AgentFS storage for ${label}. ${access} SQLite-backed filesystem — files are retained across sessions.`;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n async init(): Promise<void> {\n if (this._agent) return; // Pre-opened instance\n\n const openOptions: { id?: string; path?: string } = {};\n if (this._agentId) openOptions.id = this._agentId;\n if (this._path) {\n openOptions.path = this._path;\n // Ensure parent directory exists — the SDK only auto-creates `.agentfs/`\n // for the agentId-only case, not for explicit paths.\n mkdirSync(nodePath.dirname(this._path), { recursive: true });\n }\n\n this._agent = await AgentFS.open(openOptions);\n }\n\n async destroy(): Promise<void> {\n if (this._agent && this._ownsAgent) {\n await this._agent.close();\n }\n this._agent = null;\n }\n\n // ---------------------------------------------------------------------------\n // Internal helpers\n // ---------------------------------------------------------------------------\n\n private async getAgent(): Promise<AgentFS> {\n await this.ensureReady();\n return this._agent!;\n }\n\n private assertWritable(operation: string): void {\n if (this.readOnly) {\n throw new WorkspaceReadOnlyError(operation);\n }\n }\n\n // ---------------------------------------------------------------------------\n // File Operations\n // ---------------------------------------------------------------------------\n\n async readFile(path: string, options?: ReadOptions): Promise<string | Buffer> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n if (options?.encoding) {\n return await agent.fs.readFile(normalized, options.encoding);\n }\n return await agent.fs.readFile(normalized);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n async writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void> {\n this.assertWritable('writeFile');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Create parent directories (default behavior)\n if (options?.recursive !== false) {\n await this.mkdirRecursive(agent, getParentPath(normalized));\n }\n\n // Check overwrite\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalized);\n throw new FileExistsError(normalized);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalized, 'file');\n }\n }\n\n try {\n const data = typeof content === 'string' ? content : Buffer.from(content);\n await agent.fs.writeFile(normalized, data);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n async appendFile(path: string, content: FileContent): Promise<void> {\n this.assertWritable('appendFile');\n // AgentFS doesn't have native append — read + write (same pattern as S3Filesystem)\n let existing: Buffer = Buffer.alloc(0);\n try {\n const current = await this.readFile(path);\n existing = Buffer.isBuffer(current) ? Buffer.from(current) : Buffer.from(current);\n } catch (error) {\n if (error instanceof FileNotFoundError) {\n // File doesn't exist — start fresh\n } else {\n throw error;\n }\n }\n\n const appendBuffer = typeof content === 'string' ? Buffer.from(content, 'utf-8') : Buffer.from(content);\n await this.writeFile(path, Buffer.concat([existing, appendBuffer]));\n }\n\n async deleteFile(path: string, options?: RemoveOptions): Promise<void> {\n this.assertWritable('deleteFile');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Check if it's a directory\n try {\n const st = await agent.fs.stat(normalized);\n if (st.isDirectory()) {\n throw new IsDirectoryError(normalized);\n }\n } catch (error: unknown) {\n if (error instanceof IsDirectoryError) throw error;\n if (hasCode(error, 'ENOENT')) {\n if (options?.force) return;\n throw new FileNotFoundError(normalized);\n }\n throw mapError(error, normalized, 'file');\n }\n\n try {\n await agent.fs.unlink(normalized);\n } catch (error: unknown) {\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'file');\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n this.assertWritable('copyFile');\n const agent = await this.getAgent();\n const normalizedSrc = normalizePath(src);\n const normalizedDest = normalizePath(dest);\n\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalizedDest);\n throw new FileExistsError(normalizedDest);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalizedDest, 'file');\n }\n }\n\n try {\n // Check if source is a directory\n const st = await agent.fs.stat(normalizedSrc);\n if (st.isDirectory()) {\n if (!options?.recursive) {\n throw new IsDirectoryError(normalizedSrc);\n }\n await this.copyDirRecursive(agent, normalizedSrc, normalizedDest, options);\n return;\n }\n\n // Ensure parent directory of dest exists\n await this.mkdirRecursive(agent, getParentPath(normalizedDest));\n await agent.fs.copyFile(normalizedSrc, normalizedDest);\n } catch (error: unknown) {\n if (error instanceof IsDirectoryError || error instanceof FileExistsError) throw error;\n throw mapError(error, normalizedSrc, 'file');\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n this.assertWritable('moveFile');\n const agent = await this.getAgent();\n const normalizedSrc = normalizePath(src);\n const normalizedDest = normalizePath(dest);\n\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(normalizedDest);\n throw new FileExistsError(normalizedDest);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, normalizedDest, 'file');\n }\n }\n\n // Ensure parent directory of dest exists\n await this.mkdirRecursive(agent, getParentPath(normalizedDest));\n\n try {\n await agent.fs.rename(normalizedSrc, normalizedDest);\n } catch (error: unknown) {\n throw mapError(error, normalizedSrc, 'file');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Directory Operations\n // ---------------------------------------------------------------------------\n\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n this.assertWritable('mkdir');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n // Default to recursive (matches LocalFilesystem behavior)\n if (options?.recursive !== false) {\n await this.mkdirRecursive(agent, normalized);\n return;\n }\n\n try {\n await agent.fs.mkdir(normalized);\n } catch (error: unknown) {\n throw mapError(error, normalized, 'directory');\n }\n }\n\n async rmdir(path: string, options?: RemoveOptions): Promise<void> {\n this.assertWritable('rmdir');\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n if (options?.recursive) {\n try {\n await agent.fs.rm(normalized, { recursive: true });\n } catch (error: unknown) {\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'directory');\n }\n return;\n }\n\n // Non-recursive: check if empty first\n try {\n const entries = await agent.fs.readdir(normalized);\n if (entries.length > 0) {\n throw new DirectoryNotEmptyError(normalized);\n }\n await agent.fs.rmdir(normalized);\n } catch (error: unknown) {\n if (error instanceof DirectoryNotEmptyError) throw error;\n if (options?.force && hasCode(error, 'ENOENT')) return;\n throw mapError(error, normalized, 'directory');\n }\n }\n\n async readdir(path: string, options?: ListOptions): Promise<FileEntry[]> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n // Verify it's a directory\n const st = await agent.fs.stat(normalized);\n if (!st.isDirectory()) {\n throw new NotDirectoryError(normalized);\n }\n\n const dirEntries = await agent.fs.readdirPlus(normalized);\n let entries: FileEntry[] = dirEntries.map(entry => ({\n name: entry.name,\n type: entry.stats.isDirectory() ? ('directory' as const) : ('file' as const),\n size: entry.stats.size,\n }));\n\n // Apply extension filter\n if (options?.extension) {\n const extensions = Array.isArray(options.extension) ? options.extension : [options.extension];\n entries = entries.filter(entry => {\n if (entry.type === 'directory') return true;\n return extensions.some(ext => entry.name.endsWith(ext));\n });\n }\n\n // Recurse if requested\n if (options?.recursive) {\n const maxDepth = options.maxDepth ?? Infinity;\n const subdirs = entries.filter(e => e.type === 'directory');\n for (const dir of subdirs) {\n if (maxDepth > 1) {\n const subEntries = await this.readdir(joinPath(normalized, dir.name), {\n ...options,\n maxDepth: maxDepth - 1,\n });\n for (const sub of subEntries) {\n entries.push({\n ...sub,\n name: dir.name + '/' + sub.name,\n });\n }\n }\n }\n }\n\n return entries;\n } catch (error: unknown) {\n if (error instanceof NotDirectoryError || error instanceof DirectoryNotFoundError) {\n throw error;\n }\n throw mapError(error, normalized, 'directory');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Path Operations\n // ---------------------------------------------------------------------------\n\n async exists(path: string): Promise<boolean> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n await agent.fs.access(normalized);\n return true;\n } catch {\n return false;\n }\n }\n\n async stat(path: string): Promise<FileStat> {\n const agent = await this.getAgent();\n const normalized = normalizePath(path);\n\n try {\n const st = await agent.fs.stat(normalized);\n const isDirectory = st.isDirectory();\n return {\n name: getBaseName(normalized) || '',\n path: normalized,\n type: isDirectory ? 'directory' : 'file',\n size: st.size,\n createdAt: new Date(st.ctime * 1000),\n modifiedAt: new Date(st.mtime * 1000),\n // read_file picks media, binary or text from mimeType.\n ...(!isDirectory && { mimeType: getMimeType(normalized) }),\n };\n } catch (error: unknown) {\n throw mapError(error, normalized, 'file');\n }\n }\n\n // ---------------------------------------------------------------------------\n // Type checks\n // ---------------------------------------------------------------------------\n\n /**\n * Check if the path points to a file.\n * Returns `false` if the path doesn't exist.\n */\n async isFile(path: string): Promise<boolean> {\n try {\n const st = await this.stat(path);\n return st.type === 'file';\n } catch (error) {\n if (error instanceof FileNotFoundError) return false;\n throw error;\n }\n }\n\n /**\n * Check if the path points to a directory.\n * Returns `false` if the path doesn't exist.\n */\n async isDirectory(path: string): Promise<boolean> {\n try {\n const st = await this.stat(path);\n return st.type === 'directory';\n } catch (error) {\n if (error instanceof FileNotFoundError) return false;\n throw error;\n }\n }\n\n // ---------------------------------------------------------------------------\n // Private helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Recursively create directories, ignoring EEXIST errors.\n */\n private async mkdirRecursive(agent: AgentFS, path: string): Promise<void> {\n if (path === '/') return;\n\n const segments = path.split('/').filter(Boolean);\n let current = '';\n for (const segment of segments) {\n current += '/' + segment;\n try {\n await agent.fs.mkdir(current);\n } catch (error: unknown) {\n if (!hasCode(error, 'EEXIST')) {\n throw mapError(error, current, 'directory');\n }\n }\n }\n }\n\n /**\n * Recursively copy a directory tree.\n */\n private async copyDirRecursive(agent: AgentFS, src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.mkdirRecursive(agent, dest);\n\n const entries = await agent.fs.readdirPlus(src);\n for (const entry of entries) {\n const srcChild = joinPath(src, entry.name);\n const destChild = joinPath(dest, entry.name);\n\n if (entry.stats.isDirectory()) {\n await this.copyDirRecursive(agent, srcChild, destChild, options);\n } else {\n if (options?.overwrite === false) {\n try {\n await agent.fs.access(destChild);\n throw new FileExistsError(destChild);\n } catch (error: unknown) {\n if (error instanceof FileExistsError) throw error;\n if (!hasCode(error, 'ENOENT')) throw mapError(error, destChild, 'file');\n }\n }\n await agent.fs.copyFile(srcChild, destChild);\n }\n }\n }\n}\n","/**\n * AgentFS filesystem provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { agentfsFilesystemProvider } from '@mastra/agentfs';\n *\n * const editor = new MastraEditor({\n * filesystems: [agentfsFilesystemProvider],\n * });\n * ```\n */\nimport type { FilesystemProvider } from '@mastra/core/editor';\nimport { AgentFSFilesystem } from './filesystem';\nimport type { AgentFSFilesystemOptions } from './filesystem';\n\nexport const agentfsFilesystemProvider: FilesystemProvider<AgentFSFilesystemOptions> = {\n id: 'agentfs',\n name: 'AgentFS',\n description: 'Turso/SQLite-backed filesystem via AgentFS',\n configSchema: {\n type: 'object',\n properties: {\n agentId: { type: 'string', description: 'Agent ID — creates database at .agentfs/<agentId>.db' },\n path: { type: 'string', description: 'Explicit database file path (alternative to agentId)' },\n readOnly: { type: 'boolean', description: 'Mount as read-only', default: false },\n },\n },\n createFilesystem: config => new AgentFSFilesystem(config),\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA8CA,SAAS,YAAY,GAAmB;CACtC,IAAI,M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AM,GAAG,SAAS,UAAU,SAAS;GAC7C;EACF;CACF;AACF;;AC9qBA,MAAa,4BAA0E;CACrF,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,YAAY;GACV,SAAS;IAAE,MAAM;IAAU,aAAa;GAAuD;GAC/F,MAAM;IAAE,MAAM;IAAU,aAAa;GAAuD;GAC5F,UAAU;IAAE,MAAM;IAAW,aAAa;IAAsB,SAAS;GAAM;EACjF;CACF;CACA,mBAAkB,WAAU,IAAI,kBAAkB,MAAM;AAC1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/agentfs",
3
- "version": "0.2.2-alpha.0",
3
+ "version": "0.2.3-alpha.0",
4
4
  "description": "AgentFS (Turso/SQLite-backed) filesystem provider for Mastra workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,21 +23,20 @@
23
23
  "agentfs-sdk": "^0.6.4"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "22.20.1",
27
- "@vitest/coverage-v8": "4.1.11",
28
- "@vitest/ui": "4.1.11",
26
+ "@types/node": "22.19.15",
27
+ "@vitest/coverage-v8": "4.1.12",
28
+ "@vitest/ui": "4.1.12",
29
29
  "dotenv": "^17.4.2",
30
- "eslint": "^10.7.0",
31
- "tsdown": "0.22.9",
30
+ "tsdown": "0.23.1",
32
31
  "typescript": "^7.0.2",
33
- "vitest": "4.1.11",
34
- "@internal/lint": "0.0.144",
35
- "@internal/types-builder": "0.0.119",
36
- "@internal/workspace-test-utils": "0.0.88",
37
- "@mastra/core": "1.78.1-alpha.0"
32
+ "vitest": "4.1.12",
33
+ "@internal/lint": "0.0.145",
34
+ "@internal/types-builder": "0.0.120",
35
+ "@internal/workspace-test-utils": "0.0.89",
36
+ "@mastra/core": "1.80.0-alpha.4"
38
37
  },
39
38
  "peerDependencies": {
40
- "@mastra/core": ">=1.12.0-0 <2.0.0-0"
39
+ "@mastra/core": ">=1.80.0-0 <2.0.0-0"
41
40
  },
42
41
  "files": [
43
42
  "dist"
@@ -62,7 +61,7 @@
62
61
  "test:cloud": "vitest run ./src/**/*.integration.test.ts",
63
62
  "test:watch": "vitest watch",
64
63
  "test": "vitest run",
65
- "lint": "oxlint . && eslint .",
66
- "lint:fix": "oxlint --fix . && eslint --fix ."
64
+ "lint": "oxlint --type-aware .",
65
+ "lint:fix": "oxlint --type-aware --fix ."
67
66
  }
68
67
  }