@mastra/agentfs 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -16,7 +16,7 @@ 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));
@@ -53,11 +53,11 @@ function resolveDbPath(p) {
53
53
  }
54
54
  function normalizePath(input) {
55
55
  if (input === "" || input === ".") return "/";
56
- let path$1 = input.startsWith("/") ? input : "/" + input;
56
+ let path = input.startsWith("/") ? input : "/" + input;
57
57
  let result = "";
58
58
  let prevSlash = false;
59
- for (let i = 0; i < path$1.length; i++) {
60
- const ch = path$1[i];
59
+ for (let i = 0; i < path.length; i++) {
60
+ const ch = path[i];
61
61
  if (ch === "/") {
62
62
  if (!prevSlash) result += ch;
63
63
  prevSlash = true;
@@ -69,8 +69,8 @@ function normalizePath(input) {
69
69
  if (result.length > 1 && result.endsWith("/")) result = result.slice(0, -1);
70
70
  return result;
71
71
  }
72
- function getParentPath(path$2) {
73
- const normalized = normalizePath(path$2);
72
+ function getParentPath(path) {
73
+ const normalized = normalizePath(path);
74
74
  if (normalized === "/") return "/";
75
75
  const lastSlash = normalized.lastIndexOf("/");
76
76
  return lastSlash <= 0 ? "/" : normalized.slice(0, lastSlash);
@@ -79,8 +79,8 @@ function joinPath(base, name) {
79
79
  if (base === "/") return normalizePath("/" + name);
80
80
  return normalizePath(base + "/" + name);
81
81
  }
82
- function getBaseName(path$3) {
83
- const normalized = normalizePath(path$3);
82
+ function getBaseName(path) {
83
+ const normalized = normalizePath(path);
84
84
  if (normalized === "/") return "";
85
85
  const lastSlash = normalized.lastIndexOf("/");
86
86
  return normalized.slice(lastSlash + 1);
@@ -88,16 +88,16 @@ function getBaseName(path$3) {
88
88
  function isErrnoError(error) {
89
89
  return typeof error === "object" && error !== null && "code" in error;
90
90
  }
91
- function mapError(error, path$4, context = "file") {
91
+ function mapError(error, path, context = "file") {
92
92
  if (!isErrnoError(error)) return error instanceof Error ? error : new Error(String(error));
93
93
  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);
94
+ case "ENOENT": return context === "directory" ? new _mastra_core_workspace.DirectoryNotFoundError(path) : new _mastra_core_workspace.FileNotFoundError(path);
95
+ case "EEXIST": return new _mastra_core_workspace.FileExistsError(path);
96
+ case "EISDIR": return new _mastra_core_workspace.IsDirectoryError(path);
97
+ case "ENOTDIR": return new _mastra_core_workspace.NotDirectoryError(path);
98
+ case "ENOTEMPTY": return new _mastra_core_workspace.DirectoryNotEmptyError(path);
99
99
  case "EPERM":
100
- case "EACCES": return new _mastra_core_workspace.PermissionError(path$4, "access");
100
+ case "EACCES": return new _mastra_core_workspace.PermissionError(path, "access");
101
101
  default: return error instanceof Error ? error : new Error(String(error));
102
102
  }
103
103
  }
@@ -199,9 +199,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
199
199
  assertWritable(operation) {
200
200
  if (this.readOnly) throw new _mastra_core_workspace.WorkspaceReadOnlyError(operation);
201
201
  }
202
- async readFile(path$5, options) {
202
+ async readFile(path, options) {
203
203
  const agent = await this.getAgent();
204
- const normalized = normalizePath(path$5);
204
+ const normalized = normalizePath(path);
205
205
  try {
206
206
  if (options?.encoding) return await agent.fs.readFile(normalized, options.encoding);
207
207
  return await agent.fs.readFile(normalized);
@@ -209,10 +209,10 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
209
209
  throw mapError(error, normalized, "file");
210
210
  }
211
211
  }
212
- async writeFile(path$6, content, options) {
212
+ async writeFile(path, content, options) {
213
213
  this.assertWritable("writeFile");
214
214
  const agent = await this.getAgent();
215
- const normalized = normalizePath(path$6);
215
+ const normalized = normalizePath(path);
216
216
  if (options?.recursive !== false) await this.mkdirRecursive(agent, getParentPath(normalized));
217
217
  if (options?.overwrite === false) try {
218
218
  await agent.fs.access(normalized);
@@ -228,22 +228,22 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
228
228
  throw mapError(error, normalized, "file");
229
229
  }
230
230
  }
231
- async appendFile(path$7, content) {
231
+ async appendFile(path, content) {
232
232
  this.assertWritable("appendFile");
233
233
  let existing = Buffer.alloc(0);
234
234
  try {
235
- const current = await this.readFile(path$7);
235
+ const current = await this.readFile(path);
236
236
  existing = Buffer.isBuffer(current) ? Buffer.from(current) : Buffer.from(current);
237
237
  } catch (error) {
238
238
  if (error instanceof _mastra_core_workspace.FileNotFoundError) {} else throw error;
239
239
  }
240
240
  const appendBuffer = typeof content === "string" ? Buffer.from(content, "utf-8") : Buffer.from(content);
241
- await this.writeFile(path$7, Buffer.concat([existing, appendBuffer]));
241
+ await this.writeFile(path, Buffer.concat([existing, appendBuffer]));
242
242
  }
243
- async deleteFile(path$8, options) {
243
+ async deleteFile(path, options) {
244
244
  this.assertWritable("deleteFile");
245
245
  const agent = await this.getAgent();
246
- const normalized = normalizePath(path$8);
246
+ const normalized = normalizePath(path);
247
247
  try {
248
248
  if ((await agent.fs.stat(normalized)).isDirectory()) throw new _mastra_core_workspace.IsDirectoryError(normalized);
249
249
  } catch (error) {
@@ -305,10 +305,10 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
305
305
  throw mapError(error, normalizedSrc, "file");
306
306
  }
307
307
  }
308
- async mkdir(path$9, options) {
308
+ async mkdir(path, options) {
309
309
  this.assertWritable("mkdir");
310
310
  const agent = await this.getAgent();
311
- const normalized = normalizePath(path$9);
311
+ const normalized = normalizePath(path);
312
312
  if (options?.recursive !== false) {
313
313
  await this.mkdirRecursive(agent, normalized);
314
314
  return;
@@ -319,10 +319,10 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
319
319
  throw mapError(error, normalized, "directory");
320
320
  }
321
321
  }
322
- async rmdir(path$10, options) {
322
+ async rmdir(path, options) {
323
323
  this.assertWritable("rmdir");
324
324
  const agent = await this.getAgent();
325
- const normalized = normalizePath(path$10);
325
+ const normalized = normalizePath(path);
326
326
  if (options?.recursive) {
327
327
  try {
328
328
  await agent.fs.rm(normalized, { recursive: true });
@@ -341,9 +341,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
341
341
  throw mapError(error, normalized, "directory");
342
342
  }
343
343
  }
344
- async readdir(path$11, options) {
344
+ async readdir(path, options) {
345
345
  const agent = await this.getAgent();
346
- const normalized = normalizePath(path$11);
346
+ const normalized = normalizePath(path);
347
347
  try {
348
348
  if (!(await agent.fs.stat(normalized)).isDirectory()) throw new _mastra_core_workspace.NotDirectoryError(normalized);
349
349
  let entries = (await agent.fs.readdirPlus(normalized)).map((entry) => ({
@@ -378,9 +378,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
378
378
  throw mapError(error, normalized, "directory");
379
379
  }
380
380
  }
381
- async exists(path$12) {
381
+ async exists(path) {
382
382
  const agent = await this.getAgent();
383
- const normalized = normalizePath(path$12);
383
+ const normalized = normalizePath(path);
384
384
  try {
385
385
  await agent.fs.access(normalized);
386
386
  return true;
@@ -388,9 +388,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
388
388
  return false;
389
389
  }
390
390
  }
391
- async stat(path$13) {
391
+ async stat(path) {
392
392
  const agent = await this.getAgent();
393
- const normalized = normalizePath(path$13);
393
+ const normalized = normalizePath(path);
394
394
  try {
395
395
  const st = await agent.fs.stat(normalized);
396
396
  return {
@@ -409,9 +409,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
409
409
  * Check if the path points to a file.
410
410
  * Returns `false` if the path doesn't exist.
411
411
  */
412
- async isFile(path$14) {
412
+ async isFile(path) {
413
413
  try {
414
- return (await this.stat(path$14)).type === "file";
414
+ return (await this.stat(path)).type === "file";
415
415
  } catch (error) {
416
416
  if (error instanceof _mastra_core_workspace.FileNotFoundError) return false;
417
417
  throw error;
@@ -421,9 +421,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
421
421
  * Check if the path points to a directory.
422
422
  * Returns `false` if the path doesn't exist.
423
423
  */
424
- async isDirectory(path$15) {
424
+ async isDirectory(path) {
425
425
  try {
426
- return (await this.stat(path$15)).type === "directory";
426
+ return (await this.stat(path)).type === "directory";
427
427
  } catch (error) {
428
428
  if (error instanceof _mastra_core_workspace.FileNotFoundError) return false;
429
429
  throw error;
@@ -432,9 +432,9 @@ var AgentFSFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
432
432
  /**
433
433
  * Recursively create directories, ignoring EEXIST errors.
434
434
  */
435
- async mkdirRecursive(agent, path$16) {
436
- if (path$16 === "/") return;
437
- const segments = path$16.split("/").filter(Boolean);
435
+ async mkdirRecursive(agent, path) {
436
+ if (path === "/") return;
437
+ const segments = path.split("/").filter(Boolean);
438
438
  let current = "";
439
439
  for (const segment of segments) {
440
440
  current += "/" + segment;
@@ -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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K,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"],"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,IAAI,OAAO,MAAM,WAAW,GAAG,IAAI,QAAQ,MAAM;CAEjD,IAAI,SAAS;CACb,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N,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.1",
3
+ "version": "0.2.2",
4
4
  "description": "AgentFS (Turso/SQLite-backed) filesystem provider for Mastra workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,17 +24,16 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "22.20.1",
27
- "@vitest/coverage-v8": "4.1.10",
28
- "@vitest/ui": "4.1.10",
27
+ "@vitest/coverage-v8": "4.1.11",
28
+ "@vitest/ui": "4.1.11",
29
29
  "dotenv": "^17.4.2",
30
- "eslint": "^10.7.0",
31
30
  "tsdown": "0.22.9",
32
31
  "typescript": "^7.0.2",
33
- "vitest": "4.1.10",
34
- "@internal/lint": "0.0.130",
35
- "@internal/types-builder": "0.0.105",
36
- "@internal/workspace-test-utils": "0.0.74",
37
- "@mastra/core": "1.64.0"
32
+ "vitest": "4.1.11",
33
+ "@internal/lint": "0.0.145",
34
+ "@internal/types-builder": "0.0.120",
35
+ "@mastra/core": "1.79.0",
36
+ "@internal/workspace-test-utils": "0.0.89"
38
37
  },
39
38
  "peerDependencies": {
40
39
  "@mastra/core": ">=1.12.0-0 <2.0.0-0"
@@ -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
  }