@mastra/mesa 0.3.2 → 0.3.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":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,cAAc,EACd,QAAQ,EACR,WAAW,EACX,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAML,gBAAgB,EAIjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EACV,MAAM,EACN,IAAI,EACJ,qBAAqB,EACrB,MAAM,EACN,eAAe,EACf,cAAc,EACd,WAAW,EAEX,eAAe,EAChB,MAAM,cAAc,CAAC;AAKtB,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB;IACpE,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IACxC,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,kGAAkG;IAClG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACvC,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,sDAAsD;IACtD,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA8GD;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,gBA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AE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAU/C;IAEK,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOjD;IAED;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnD;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,cAAc,CAAC,QAAQ,CAAC,CAErC;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,cAAc,CAAC,UAAU,CAAC,CAEzC;IAED,OAAO,CAAC,cAAc;YAMR,mBAAmB;YAanB,qBAAqB;YAqBrB,2BAA2B;YAe3B,aAAa;YAmCb,QAAQ;IAQtB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,UAAU;CAcnB"}
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;
@@ -20,12 +20,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- //#endregion
24
23
  let path_posix = require("path/posix");
25
24
  path_posix = __toESM(path_posix, 1);
26
25
  let _mastra_core_workspace = require("@mastra/core/workspace");
27
26
  let _mesadev_sdk = require("@mesadev/sdk");
28
- //#region src/filesystem/index.ts
27
+ // src/filesystem/index.ts
29
28
  function generateId() {
30
29
  return `mesa-fs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
31
30
  }
@@ -466,12 +465,12 @@ var MesaFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
466
465
  type: stats.isDirectory ? "directory" : "file",
467
466
  size: stats.isDirectory ? 0 : stats.size,
468
467
  createdAt: stats.mtime,
469
- modifiedAt: stats.mtime
468
+ modifiedAt: stats.mtime,
469
+ ...!stats.isDirectory && { mimeType: (0, _mastra_core_workspace.getMimeType)(target) }
470
470
  };
471
471
  }
472
472
  };
473
- //#endregion
474
- //#region src/provider.ts
473
+ // src/provider.ts
475
474
  const mesaFilesystemProvider = {
476
475
  id: "mesa",
477
476
  name: "Mesa",
@@ -539,7 +538,6 @@ const mesaFilesystemProvider = {
539
538
  },
540
539
  createFilesystem: (config) => new MesaFilesystem(config)
541
540
  };
542
- //#endregion
543
541
  exports.MesaFilesystem = MesaFilesystem;
544
542
  exports.mesaFilesystemProvider = mesaFilesystemProvider;
545
543
  Object.defineProperty(exports, "repo", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["path","DirectoryNotFoundError","FileNotFoundError","FileExistsError","NotDirectoryError","IsDirectoryError","DirectoryNotEmptyError","MastraFilesystem","Mesa","WorkspaceReadOnlyError","StaleFileError"],"sources":["../src/filesystem/index.ts","../src/provider.ts"],"sourcesContent":["import path from 'node:path/posix';\n\nimport type {\n CopyOptions,\n FileContent,\n FileEntry,\n FilesystemInfo,\n FileStat,\n ListOptions,\n MastraFilesystemOptions,\n ProviderStatus,\n ReadOptions,\n RemoveOptions,\n WriteOptions,\n} from '@mastra/core/workspace';\nimport {\n DirectoryNotEmptyError,\n DirectoryNotFoundError,\n FileExistsError,\n FileNotFoundError,\n IsDirectoryError,\n MastraFilesystem,\n NotDirectoryError,\n StaleFileError,\n WorkspaceReadOnlyError,\n} from '@mastra/core/workspace';\nimport { Mesa } from '@mesadev/sdk';\nimport type {\n Author,\n Bash,\n FsMountRuntimeOptions,\n Layout,\n MesaBashOptions,\n MesaFileSystem,\n MesaOptions,\n Repo,\n TelemetryConfig,\n} from '@mesadev/sdk';\n\ntype MesaFsStat = Awaited<ReturnType<MesaFileSystem['stat']>>;\ntype MesaDirent = Awaited<ReturnType<NonNullable<MesaFileSystem['readdirWithFileTypes']>>>[number];\n\nexport interface MesaFilesystemOptions extends MastraFilesystemOptions {\n /** Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted. */\n privateKey?: string;\n /** Commit authors attributed to writes made through this filesystem. */\n authors: readonly [Author, ...Author[]];\n /** Mesa mount layout mapping absolute paths to repos, built with `repo()`. */\n layout: Layout;\n /** Mount every layout repo read-only and block writes through the Mastra filesystem interface. */\n readOnly?: boolean;\n /** Mesa filesystem cache configuration. */\n cache?: FsMountRuntimeOptions['cache'];\n /** Mesa mount token lifetime in seconds. */\n ttl?: number;\n /** Mesa filesystem telemetry configuration. */\n telemetry?: TelemetryConfig;\n /** Custom fetch implementation for Mesa API calls. */\n fetch?: MesaOptions['fetch'];\n /** User agent for Mesa API calls. */\n userAgent?: string;\n}\n\nfunction generateId(): string {\n return `mesa-fs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nfunction normalizePath(inputPath: string): string {\n return path.normalize(inputPath.startsWith('/') ? inputPath : `/${inputPath}`);\n}\n\nfunction getExtension(name: string): string {\n const dot = name.lastIndexOf('.');\n return dot === -1 ? '' : name.slice(dot);\n}\n\nfunction matchesExtension(name: string, extensions?: string[]): boolean {\n if (!extensions) return true;\n const ext = getExtension(name);\n return extensions.some(candidate => candidate === ext || candidate === ext.slice(1));\n}\n\nfunction toReadOnlyLayout(layout: Record<string, Repo | Repo[]>): Layout {\n const toReadOnly = (repo: Repo): Repo => {\n if (repo.branchedFrom) {\n throw new Error(\n `MesaFilesystem readOnly cannot mount repo \"${repo.name}\" with branchedFrom, which requires mode \"rw\".`,\n );\n }\n return {\n ...repo,\n mode: 'ro',\n ...(repo.subPaths && { subPaths: toReadOnlyLayout(repo.subPaths) }),\n } as Repo;\n };\n return Object.fromEntries(\n Object.entries(layout).map(([key, entry]) => [\n key,\n Array.isArray(entry) ? entry.map(toReadOnly) : toReadOnly(entry),\n ]),\n ) as Layout;\n}\n\nfunction toMesaContent(content: FileContent): string | Uint8Array {\n if (typeof content === 'string') return content;\n if (Buffer.isBuffer(content)) return new Uint8Array(content);\n return content;\n}\n\ntype MesaErrorKind = 'notFound' | 'alreadyExists' | 'notDirectory' | 'isDirectory' | 'directoryNotEmpty';\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\nfunction getMesaErrorKind(error: unknown): MesaErrorKind | undefined {\n const err =\n error && typeof error === 'object' ? (error as { code?: unknown; name?: unknown; message?: unknown }) : undefined;\n const code = typeof err?.code === 'string' ? err.code : undefined;\n const name = typeof err?.name === 'string' ? err.name : undefined;\n\n for (const value of [code, name]) {\n switch (value) {\n case 'ENOENT':\n case 'NotFound':\n case 'NoSuchFile':\n case 'NoSuchKey':\n return 'notFound';\n case 'EEXIST':\n case 'AlreadyExists':\n return 'alreadyExists';\n case 'ENOTDIR':\n case 'NotDirectory':\n return 'notDirectory';\n case 'EISDIR':\n case 'IsDirectory':\n return 'isDirectory';\n case 'ENOTEMPTY':\n case 'DirectoryNotEmpty':\n return 'directoryNotEmpty';\n }\n }\n\n const message =\n typeof err?.message === 'string' ? err.message : error instanceof Error ? error.message : String(error);\n if (/\\b(no such file|not found|enoent)\\b/i.test(message)) return 'notFound';\n if (/\\b(already exists|eexist)\\b/i.test(message)) return 'alreadyExists';\n if (/\\b(not a directory|enotdir)\\b/i.test(message)) return 'notDirectory';\n if (/\\b(is a directory|eisdir)\\b/i.test(message)) return 'isDirectory';\n if (/\\b(directory not empty|enotempty)\\b/i.test(message)) return 'directoryNotEmpty';\n\n return undefined;\n}\n\nfunction mapMesaError(error: unknown, inputPath: string, context: 'file' | 'directory' = 'file'): Error {\n switch (getMesaErrorKind(error)) {\n case 'notFound':\n return context === 'directory' ? new DirectoryNotFoundError(inputPath) : new FileNotFoundError(inputPath);\n case 'alreadyExists':\n return new FileExistsError(inputPath);\n case 'notDirectory':\n return new NotDirectoryError(inputPath);\n case 'isDirectory':\n return new IsDirectoryError(inputPath);\n case 'directoryNotEmpty':\n return new DirectoryNotEmptyError(inputPath);\n default:\n return toError(error);\n }\n}\n\n/**\n * Workspace filesystem adapter backed by Mesa.\n *\n * This provider runs in the Mastra process and implements the workspace file\n * API against Mesa repos. It does not mount Mesa into a sandbox.\n */\nexport class MesaFilesystem extends MastraFilesystem {\n readonly id: string;\n readonly name = 'MesaFilesystem';\n readonly provider = 'mesa';\n readonly readOnly?: boolean;\n readonly icon = 'mesa';\n readonly displayName = 'Mesa';\n readonly description = 'Versioned Mesa filesystem for workspace files';\n\n status: ProviderStatus = 'pending';\n\n private readonly _privateKey?: string;\n private readonly _authors: readonly [Author, ...Author[]];\n private readonly _layout: Layout;\n private readonly _cache?: FsMountRuntimeOptions['cache'];\n private readonly _ttl?: number;\n private readonly _telemetry?: TelemetryConfig;\n private readonly _fetch?: MesaOptions['fetch'];\n private readonly _userAgent?: string;\n\n private _mesa?: Mesa;\n private _filesystem?: MesaFileSystem;\n\n constructor(options: MesaFilesystemOptions) {\n super({ name: 'MesaFilesystem', ...options });\n\n this.id = generateId();\n this.readOnly = options.readOnly;\n this._privateKey = options.privateKey;\n this._authors = options.authors;\n this._layout = options.layout;\n this._cache = options.cache;\n this._ttl = options.ttl;\n this._telemetry = options.telemetry;\n this._fetch = options.fetch;\n this._userAgent = options.userAgent;\n }\n\n /**\n * The active Mesa client, available after initialization when this instance\n * created the client itself.\n */\n get client(): Mesa | undefined {\n return this._mesa;\n }\n\n /**\n * The active Mesa filesystem. Accessing this before initialization throws.\n */\n get filesystem(): MesaFileSystem {\n if (!this._filesystem) {\n throw new Error('MesaFilesystem is not initialized. Call init() first or perform a filesystem operation.');\n }\n return this._filesystem;\n }\n\n override async init(): Promise<void> {\n if (Object.keys(this._layout).length === 0) {\n throw new Error('MesaFilesystem requires a layout with at least one path.');\n }\n\n this._mesa = new Mesa({\n privateKey: this._privateKey,\n fetch: this._fetch,\n userAgent: this._userAgent,\n });\n\n const layout = this.readOnly ? toReadOnlyLayout(this._layout) : this._layout;\n this._filesystem = await this._mesa\n .fs({ layout, ttl: this._ttl, authors: this._authors })\n .mount({ cache: this._cache, telemetry: this._telemetry });\n }\n\n getInfo(): FilesystemInfo<{\n paths: string[];\n mode: 'mounted' | 'client';\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 paths: Object.keys(this._layout),\n mode: 'client',\n },\n };\n }\n\n getInstructions(): string {\n const paths = Object.keys(this._layout);\n const parts = ['Mesa filesystem. Paths are rooted at the Mesa mount layout.'];\n\n if (paths.length > 0) {\n parts.push(`Mounted paths: ${paths.map(p => `\"${p}\"`).join(', ')}. For example \"${paths[0]}/file.txt\".`);\n }\n\n parts.push('Files are versioned by Mesa.');\n\n if (this.readOnly) {\n parts.push('Mounted read-only.');\n }\n\n return parts.join(' ');\n }\n\n async readFile(inputPath: string, options?: ReadOptions): Promise<string | Buffer> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n const buffer = Buffer.from(await this.filesystem.readFileBuffer(target));\n if (options?.encoding) return buffer.toString(options.encoding);\n return buffer;\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n async writeFile(inputPath: string, content: FileContent, options?: WriteOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('writeFile');\n const target = normalizePath(inputPath);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(inputPath);\n }\n\n if (options?.expectedMtime) {\n await this.assertExpectedMtime(inputPath, options.expectedMtime);\n }\n\n if (options?.recursive === false) {\n await this.assertParentDirectoryExists(target);\n } else {\n await this.ensureParentDirectory(target);\n }\n\n try {\n await this.filesystem.writeFile(target, toMesaContent(content));\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof NotDirectoryError) throw new NotDirectoryError(path.dirname(target));\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async appendFile(inputPath: string, content: FileContent): Promise<void> {\n await this.ensureReady();\n this.assertWritable('appendFile');\n const target = normalizePath(inputPath);\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.appendFile(target, toMesaContent(content));\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async deleteFile(inputPath: string, options?: RemoveOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('deleteFile');\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n if (stats.isDirectory) throw new IsDirectoryError(inputPath);\n await this.filesystem.rm(target, { force: options?.force });\n } catch (error) {\n if (error instanceof IsDirectoryError) throw error;\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) {\n if (options?.force) return;\n throw mapped;\n }\n throw mapped;\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('copyFile');\n const source = normalizePath(src);\n const target = normalizePath(dest);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(dest);\n }\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.cp(source, target, { recursive: options?.recursive });\n } catch (error) {\n const mapped = mapMesaError(error, src);\n if (mapped instanceof FileExistsError) throw new FileExistsError(dest);\n throw mapped;\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('moveFile');\n const source = normalizePath(src);\n const target = normalizePath(dest);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(dest);\n }\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.mv(source, target);\n } catch (error) {\n const mapped = mapMesaError(error, src);\n if (mapped instanceof FileExistsError) throw new FileExistsError(dest);\n throw mapped;\n }\n }\n\n async mkdir(inputPath: string, options?: { recursive?: boolean }): Promise<void> {\n await this.ensureReady();\n this.assertWritable('mkdir');\n const target = normalizePath(inputPath);\n\n try {\n await this.filesystem.mkdir(target, { recursive: options?.recursive ?? true });\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async rmdir(inputPath: string, options?: RemoveOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('rmdir');\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n if (!stats.isDirectory) throw new NotDirectoryError(inputPath);\n\n if (!options?.recursive) {\n const entries = await this.filesystem.readdirWithFileTypes(target);\n if (entries.length > 0) throw new DirectoryNotEmptyError(inputPath);\n }\n\n await this.filesystem.rm(target, { recursive: options?.recursive ?? true, force: options?.force });\n } catch (error) {\n if (error instanceof NotDirectoryError) throw error;\n if (error instanceof DirectoryNotEmptyError) throw error;\n const mapped = mapMesaError(error, inputPath, 'directory');\n if (mapped instanceof DirectoryNotFoundError) {\n if (options?.force) return;\n throw mapped;\n }\n throw mapped;\n }\n }\n\n async readdir(inputPath: string, options?: ListOptions): Promise<FileEntry[]> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n return await this.readDirectory(target, options);\n } catch (error) {\n throw mapMesaError(error, inputPath, 'directory');\n }\n }\n\n async exists(inputPath: string): Promise<boolean> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n return await this.filesystem.exists(target);\n } catch (error) {\n if (getMesaErrorKind(error) === 'notFound') return false;\n throw mapMesaError(error, inputPath);\n }\n }\n\n async stat(inputPath: string): Promise<FileStat> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n return this.toFileStat(target, stats);\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n async realpath(inputPath: string): Promise<string> {\n await this.ensureReady();\n try {\n return await this.filesystem.realpath(normalizePath(inputPath));\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n /**\n * Create a Mesa-backed Bash runtime for this filesystem.\n */\n async bash(options?: MesaBashOptions): Promise<Bash> {\n await this.ensureReady();\n return this.filesystem.bash(options);\n }\n\n /**\n * Mesa change management operations for the mounted filesystem.\n */\n get change(): MesaFileSystem['change'] {\n return this.filesystem.change;\n }\n\n /**\n * Mesa bookmark management operations for the mounted filesystem.\n */\n get bookmark(): MesaFileSystem['bookmark'] {\n return this.filesystem.bookmark;\n }\n\n private assertWritable(operation: string): void {\n if (this.readOnly) {\n throw new WorkspaceReadOnlyError(operation);\n }\n }\n\n private async assertExpectedMtime(inputPath: string, expectedMtime: Date): Promise<void> {\n try {\n const currentStat = await this.stat(inputPath);\n if (currentStat.modifiedAt.getTime() !== expectedMtime.getTime()) {\n throw new StaleFileError(inputPath, expectedMtime, currentStat.modifiedAt);\n }\n } catch (error) {\n if (error instanceof StaleFileError) throw error;\n if (error instanceof FileNotFoundError) return;\n throw error;\n }\n }\n\n private async ensureParentDirectory(inputPath: string): Promise<void> {\n const parent = path.dirname(inputPath);\n if (parent === '/' || parent === inputPath) return;\n\n try {\n await this.filesystem.mkdir(parent, { recursive: true });\n } catch (error) {\n const mapped = mapMesaError(error, parent, 'directory');\n if (!(mapped instanceof FileExistsError)) throw mapped;\n try {\n const stats = await this.filesystem.stat(parent);\n if (!stats.isDirectory) {\n throw new NotDirectoryError(parent);\n }\n } catch (statError) {\n if (statError instanceof NotDirectoryError) throw statError;\n throw mapMesaError(statError, parent, 'directory');\n }\n }\n }\n\n private async assertParentDirectoryExists(inputPath: string): Promise<void> {\n const parent = path.dirname(inputPath);\n if (parent === '/' || parent === inputPath) return;\n\n try {\n const stats = await this.filesystem.stat(parent);\n if (!stats.isDirectory) {\n throw new NotDirectoryError(parent);\n }\n } catch (error) {\n if (error instanceof NotDirectoryError) throw error;\n throw mapMesaError(error, parent, 'directory');\n }\n }\n\n private async readDirectory(inputPath: string, options?: ListOptions, depth = 0): Promise<FileEntry[]> {\n const entries = await this.filesystem.readdirWithFileTypes(inputPath);\n const extensions = options?.extension\n ? Array.isArray(options.extension)\n ? options.extension\n : [options.extension]\n : undefined;\n\n const result: FileEntry[] = [];\n for (const entry of entries) {\n const childPath = path.join(inputPath, entry.name);\n if (entry.isFile) {\n if (matchesExtension(entry.name, extensions)) {\n const stat = await this.safeStat(childPath);\n result.push({ name: entry.name, type: 'file', size: stat?.size });\n }\n continue;\n }\n\n if (entry.isDirectory) {\n result.push({ name: entry.name, type: 'directory' });\n\n if (options?.recursive && (options.maxDepth === undefined || depth < options.maxDepth)) {\n const childEntries = await this.readDirectory(childPath, options, depth + 1);\n result.push(...childEntries.map(child => ({ ...child, name: `${entry.name}/${child.name}` })));\n }\n continue;\n }\n\n result.push(this.toFileEntry(entry));\n }\n\n return result;\n }\n\n private async safeStat(inputPath: string): Promise<MesaFsStat | undefined> {\n try {\n return await this.filesystem.stat(inputPath);\n } catch {\n return undefined;\n }\n }\n\n private toFileEntry(entry: MesaDirent): FileEntry {\n return {\n name: entry.name,\n type: entry.isDirectory ? 'directory' : 'file',\n isSymlink: entry.isSymbolicLink || undefined,\n };\n }\n\n private toFileStat(inputPath: string, stats: MesaFsStat): FileStat {\n const target = normalizePath(inputPath);\n\n return {\n name: target === '/' ? '/' : path.basename(target),\n path: target,\n type: stats.isDirectory ? 'directory' : 'file',\n size: stats.isDirectory ? 0 : stats.size,\n createdAt: stats.mtime,\n modifiedAt: stats.mtime,\n };\n }\n}\n","/**\n * Mesa filesystem provider descriptor for MastraEditor.\n */\nimport type { FilesystemProvider } from '@mastra/core/editor';\n\nimport { MesaFilesystem } from './filesystem';\nimport type { MesaFilesystemOptions } from './filesystem';\n\nexport const mesaFilesystemProvider: FilesystemProvider<MesaFilesystemOptions> = {\n id: 'mesa',\n name: 'Mesa',\n description: 'Versioned Mesa filesystem for workspace files',\n configSchema: {\n type: 'object',\n required: ['authors', 'layout'],\n properties: {\n privateKey: { type: 'string', description: 'Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted.' },\n authors: {\n type: 'array',\n description: 'Commit authors attributed to writes',\n minItems: 1,\n items: {\n type: 'object',\n required: ['name'],\n properties: {\n name: { type: 'string', description: 'Author name' },\n email: { type: 'string', description: 'Author email' },\n },\n },\n },\n layout: {\n type: 'object',\n minProperties: 1,\n description:\n 'Mesa mount layout mapping absolute paths to repo declarations, e.g. { \"/docs\": { \"kind\": \"repo\", \"name\": \"docs\", \"mode\": \"rw\" } }',\n },\n cache: {\n type: 'object',\n description: 'Mesa filesystem cache configuration',\n properties: {\n diskCache: {\n type: 'object',\n required: ['path'],\n properties: {\n path: { type: 'string', description: 'Disk cache path' },\n maxSizeBytes: { type: 'number', description: 'Maximum disk cache size in bytes' },\n },\n },\n },\n },\n ttl: { type: 'number', description: 'Mesa mount token lifetime in seconds' },\n readOnly: { type: 'boolean', description: 'Mount every layout repo as read-only', default: false },\n },\n },\n createFilesystem: config => new MesaFilesystem(config),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,SAAS,aAAqB;CAC5B,OAAO,WAAW,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AACpF;AAEA,SAAS,cAAc,WAA2B;CAChD,OAAOA,WAAAA,QAAK,UAAU,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,WAAW;AAC/E;AAEA,SAAS,aAAa,MAAsB;CAC1C,MAAM,MAAM,KAAK,YAAY,GAAG;CAChC,OAAO,QAAQ,KAAK,KAAK,KAAK,MAAM,GAAG;AACzC;AAEA,SAAS,iBAAiB,MAAc,YAAgC;CACtE,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,MAAM,aAAa,IAAI;CAC7B,OAAO,WAAW,MAAK,cAAa,cAAc,OAAO,cAAc,IAAI,MAAM,CAAC,CAAC;AACrF;AAEA,SAAS,iBAAiB,QAA+C;CACvE,MAAM,cAAc,SAAqB;EACvC,IAAI,KAAK,cACP,MAAM,IAAI,MACR,8CAA8C,KAAK,KAAK,+CAC1D;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M,cAAc,IAAI,MAAM;GACpC,WAAW,MAAM;GACjB,YAAY,MAAM;EACpB;CACF;AACF;;;AC/mBA,MAAa,yBAAoE;CAC/E,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,UAAU,CAAC,WAAW,QAAQ;EAC9B,YAAY;GACV,YAAY;IAAE,MAAM;IAAU,aAAa;GAAiE;GAC5G,SAAS;IACP,MAAM;IACN,aAAa;IACb,UAAU;IACV,OAAO;KACL,MAAM;KACN,UAAU,CAAC,MAAM;KACjB,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,aAAa;MAAc;MACnD,OAAO;OAAE,MAAM;OAAU,aAAa;MAAe;KACvD;IACF;GACF;GACA,QAAQ;IACN,MAAM;IACN,eAAe;IACf,aACE;GACJ;GACA,OAAO;IACL,MAAM;IACN,aAAa;IACb,YAAY,EACV,WAAW;KACT,MAAM;KACN,UAAU,CAAC,MAAM;KACjB,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,aAAa;MAAkB;MACvD,cAAc;OAAE,MAAM;OAAU,aAAa;MAAmC;KAClF;IACF,EACF;GACF;GACA,KAAK;IAAE,MAAM;IAAU,aAAa;GAAuC;GAC3E,UAAU;IAAE,MAAM;IAAW,aAAa;IAAwC,SAAS;GAAM;EACnG;CACF;CACA,mBAAkB,WAAU,IAAI,eAAe,MAAM;AACvD"}
1
+ {"version":3,"file":"index.cjs","names":["path","DirectoryNotFoundError","FileNotFoundError","FileExistsError","NotDirectoryError","IsDirectoryError","DirectoryNotEmptyError","MastraFilesystem","Mesa","WorkspaceReadOnlyError","StaleFileError","getMimeType"],"sources":["../src/filesystem/index.ts","../src/provider.ts"],"sourcesContent":["import path from 'node:path/posix';\n\nimport type {\n CopyOptions,\n FileContent,\n FileEntry,\n FilesystemInfo,\n FileStat,\n ListOptions,\n MastraFilesystemOptions,\n ProviderStatus,\n ReadOptions,\n RemoveOptions,\n WriteOptions,\n} from '@mastra/core/workspace';\nimport {\n DirectoryNotEmptyError,\n DirectoryNotFoundError,\n FileExistsError,\n FileNotFoundError,\n getMimeType,\n IsDirectoryError,\n MastraFilesystem,\n NotDirectoryError,\n StaleFileError,\n WorkspaceReadOnlyError,\n} from '@mastra/core/workspace';\nimport { Mesa } from '@mesadev/sdk';\nimport type {\n Author,\n Bash,\n FsMountRuntimeOptions,\n Layout,\n MesaBashOptions,\n MesaFileSystem,\n MesaOptions,\n Repo,\n TelemetryConfig,\n} from '@mesadev/sdk';\n\ntype MesaFsStat = Awaited<ReturnType<MesaFileSystem['stat']>>;\ntype MesaDirent = Awaited<ReturnType<NonNullable<MesaFileSystem['readdirWithFileTypes']>>>[number];\n\nexport interface MesaFilesystemOptions extends MastraFilesystemOptions {\n /** Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted. */\n privateKey?: string;\n /** Commit authors attributed to writes made through this filesystem. */\n authors: readonly [Author, ...Author[]];\n /** Mesa mount layout mapping absolute paths to repos, built with `repo()`. */\n layout: Layout;\n /** Mount every layout repo read-only and block writes through the Mastra filesystem interface. */\n readOnly?: boolean;\n /** Mesa filesystem cache configuration. */\n cache?: FsMountRuntimeOptions['cache'];\n /** Mesa mount token lifetime in seconds. */\n ttl?: number;\n /** Mesa filesystem telemetry configuration. */\n telemetry?: TelemetryConfig;\n /** Custom fetch implementation for Mesa API calls. */\n fetch?: MesaOptions['fetch'];\n /** User agent for Mesa API calls. */\n userAgent?: string;\n}\n\nfunction generateId(): string {\n return `mesa-fs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nfunction normalizePath(inputPath: string): string {\n return path.normalize(inputPath.startsWith('/') ? inputPath : `/${inputPath}`);\n}\n\nfunction getExtension(name: string): string {\n const dot = name.lastIndexOf('.');\n return dot === -1 ? '' : name.slice(dot);\n}\n\nfunction matchesExtension(name: string, extensions?: string[]): boolean {\n if (!extensions) return true;\n const ext = getExtension(name);\n return extensions.some(candidate => candidate === ext || candidate === ext.slice(1));\n}\n\nfunction toReadOnlyLayout(layout: Record<string, Repo | Repo[]>): Layout {\n const toReadOnly = (repo: Repo): Repo => {\n if (repo.branchedFrom) {\n throw new Error(\n `MesaFilesystem readOnly cannot mount repo \"${repo.name}\" with branchedFrom, which requires mode \"rw\".`,\n );\n }\n return {\n ...repo,\n mode: 'ro',\n ...(repo.subPaths && { subPaths: toReadOnlyLayout(repo.subPaths) }),\n } as Repo;\n };\n return Object.fromEntries(\n Object.entries(layout).map(([key, entry]) => [\n key,\n Array.isArray(entry) ? entry.map(toReadOnly) : toReadOnly(entry),\n ]),\n ) as Layout;\n}\n\nfunction toMesaContent(content: FileContent): string | Uint8Array {\n if (typeof content === 'string') return content;\n if (Buffer.isBuffer(content)) return new Uint8Array(content);\n return content;\n}\n\ntype MesaErrorKind = 'notFound' | 'alreadyExists' | 'notDirectory' | 'isDirectory' | 'directoryNotEmpty';\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\nfunction getMesaErrorKind(error: unknown): MesaErrorKind | undefined {\n const err =\n error && typeof error === 'object' ? (error as { code?: unknown; name?: unknown; message?: unknown }) : undefined;\n const code = typeof err?.code === 'string' ? err.code : undefined;\n const name = typeof err?.name === 'string' ? err.name : undefined;\n\n for (const value of [code, name]) {\n switch (value) {\n case 'ENOENT':\n case 'NotFound':\n case 'NoSuchFile':\n case 'NoSuchKey':\n return 'notFound';\n case 'EEXIST':\n case 'AlreadyExists':\n return 'alreadyExists';\n case 'ENOTDIR':\n case 'NotDirectory':\n return 'notDirectory';\n case 'EISDIR':\n case 'IsDirectory':\n return 'isDirectory';\n case 'ENOTEMPTY':\n case 'DirectoryNotEmpty':\n return 'directoryNotEmpty';\n }\n }\n\n const message =\n typeof err?.message === 'string' ? err.message : error instanceof Error ? error.message : String(error);\n if (/\\b(no such file|not found|enoent)\\b/i.test(message)) return 'notFound';\n if (/\\b(already exists|eexist)\\b/i.test(message)) return 'alreadyExists';\n if (/\\b(not a directory|enotdir)\\b/i.test(message)) return 'notDirectory';\n if (/\\b(is a directory|eisdir)\\b/i.test(message)) return 'isDirectory';\n if (/\\b(directory not empty|enotempty)\\b/i.test(message)) return 'directoryNotEmpty';\n\n return undefined;\n}\n\nfunction mapMesaError(error: unknown, inputPath: string, context: 'file' | 'directory' = 'file'): Error {\n switch (getMesaErrorKind(error)) {\n case 'notFound':\n return context === 'directory' ? new DirectoryNotFoundError(inputPath) : new FileNotFoundError(inputPath);\n case 'alreadyExists':\n return new FileExistsError(inputPath);\n case 'notDirectory':\n return new NotDirectoryError(inputPath);\n case 'isDirectory':\n return new IsDirectoryError(inputPath);\n case 'directoryNotEmpty':\n return new DirectoryNotEmptyError(inputPath);\n default:\n return toError(error);\n }\n}\n\n/**\n * Workspace filesystem adapter backed by Mesa.\n *\n * This provider runs in the Mastra process and implements the workspace file\n * API against Mesa repos. It does not mount Mesa into a sandbox.\n */\nexport class MesaFilesystem extends MastraFilesystem {\n readonly id: string;\n readonly name = 'MesaFilesystem';\n readonly provider = 'mesa';\n readonly readOnly?: boolean;\n readonly icon = 'mesa';\n readonly displayName = 'Mesa';\n readonly description = 'Versioned Mesa filesystem for workspace files';\n\n status: ProviderStatus = 'pending';\n\n private readonly _privateKey?: string;\n private readonly _authors: readonly [Author, ...Author[]];\n private readonly _layout: Layout;\n private readonly _cache?: FsMountRuntimeOptions['cache'];\n private readonly _ttl?: number;\n private readonly _telemetry?: TelemetryConfig;\n private readonly _fetch?: MesaOptions['fetch'];\n private readonly _userAgent?: string;\n\n private _mesa?: Mesa;\n private _filesystem?: MesaFileSystem;\n\n constructor(options: MesaFilesystemOptions) {\n super({ name: 'MesaFilesystem', ...options });\n\n this.id = generateId();\n this.readOnly = options.readOnly;\n this._privateKey = options.privateKey;\n this._authors = options.authors;\n this._layout = options.layout;\n this._cache = options.cache;\n this._ttl = options.ttl;\n this._telemetry = options.telemetry;\n this._fetch = options.fetch;\n this._userAgent = options.userAgent;\n }\n\n /**\n * The active Mesa client, available after initialization when this instance\n * created the client itself.\n */\n get client(): Mesa | undefined {\n return this._mesa;\n }\n\n /**\n * The active Mesa filesystem. Accessing this before initialization throws.\n */\n get filesystem(): MesaFileSystem {\n if (!this._filesystem) {\n throw new Error('MesaFilesystem is not initialized. Call init() first or perform a filesystem operation.');\n }\n return this._filesystem;\n }\n\n override async init(): Promise<void> {\n if (Object.keys(this._layout).length === 0) {\n throw new Error('MesaFilesystem requires a layout with at least one path.');\n }\n\n this._mesa = new Mesa({\n privateKey: this._privateKey,\n fetch: this._fetch,\n userAgent: this._userAgent,\n });\n\n const layout = this.readOnly ? toReadOnlyLayout(this._layout) : this._layout;\n this._filesystem = await this._mesa\n .fs({ layout, ttl: this._ttl, authors: this._authors })\n .mount({ cache: this._cache, telemetry: this._telemetry });\n }\n\n getInfo(): FilesystemInfo<{\n paths: string[];\n mode: 'mounted' | 'client';\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 paths: Object.keys(this._layout),\n mode: 'client',\n },\n };\n }\n\n getInstructions(): string {\n const paths = Object.keys(this._layout);\n const parts = ['Mesa filesystem. Paths are rooted at the Mesa mount layout.'];\n\n if (paths.length > 0) {\n parts.push(`Mounted paths: ${paths.map(p => `\"${p}\"`).join(', ')}. For example \"${paths[0]}/file.txt\".`);\n }\n\n parts.push('Files are versioned by Mesa.');\n\n if (this.readOnly) {\n parts.push('Mounted read-only.');\n }\n\n return parts.join(' ');\n }\n\n async readFile(inputPath: string, options?: ReadOptions): Promise<string | Buffer> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n const buffer = Buffer.from(await this.filesystem.readFileBuffer(target));\n if (options?.encoding) return buffer.toString(options.encoding);\n return buffer;\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n async writeFile(inputPath: string, content: FileContent, options?: WriteOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('writeFile');\n const target = normalizePath(inputPath);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(inputPath);\n }\n\n if (options?.expectedMtime) {\n await this.assertExpectedMtime(inputPath, options.expectedMtime);\n }\n\n if (options?.recursive === false) {\n await this.assertParentDirectoryExists(target);\n } else {\n await this.ensureParentDirectory(target);\n }\n\n try {\n await this.filesystem.writeFile(target, toMesaContent(content));\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof NotDirectoryError) throw new NotDirectoryError(path.dirname(target));\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async appendFile(inputPath: string, content: FileContent): Promise<void> {\n await this.ensureReady();\n this.assertWritable('appendFile');\n const target = normalizePath(inputPath);\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.appendFile(target, toMesaContent(content));\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async deleteFile(inputPath: string, options?: RemoveOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('deleteFile');\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n if (stats.isDirectory) throw new IsDirectoryError(inputPath);\n await this.filesystem.rm(target, { force: options?.force });\n } catch (error) {\n if (error instanceof IsDirectoryError) throw error;\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) {\n if (options?.force) return;\n throw mapped;\n }\n throw mapped;\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('copyFile');\n const source = normalizePath(src);\n const target = normalizePath(dest);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(dest);\n }\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.cp(source, target, { recursive: options?.recursive });\n } catch (error) {\n const mapped = mapMesaError(error, src);\n if (mapped instanceof FileExistsError) throw new FileExistsError(dest);\n throw mapped;\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('moveFile');\n const source = normalizePath(src);\n const target = normalizePath(dest);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(dest);\n }\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.mv(source, target);\n } catch (error) {\n const mapped = mapMesaError(error, src);\n if (mapped instanceof FileExistsError) throw new FileExistsError(dest);\n throw mapped;\n }\n }\n\n async mkdir(inputPath: string, options?: { recursive?: boolean }): Promise<void> {\n await this.ensureReady();\n this.assertWritable('mkdir');\n const target = normalizePath(inputPath);\n\n try {\n await this.filesystem.mkdir(target, { recursive: options?.recursive ?? true });\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async rmdir(inputPath: string, options?: RemoveOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('rmdir');\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n if (!stats.isDirectory) throw new NotDirectoryError(inputPath);\n\n if (!options?.recursive) {\n const entries = await this.filesystem.readdirWithFileTypes(target);\n if (entries.length > 0) throw new DirectoryNotEmptyError(inputPath);\n }\n\n await this.filesystem.rm(target, { recursive: options?.recursive ?? true, force: options?.force });\n } catch (error) {\n if (error instanceof NotDirectoryError) throw error;\n if (error instanceof DirectoryNotEmptyError) throw error;\n const mapped = mapMesaError(error, inputPath, 'directory');\n if (mapped instanceof DirectoryNotFoundError) {\n if (options?.force) return;\n throw mapped;\n }\n throw mapped;\n }\n }\n\n async readdir(inputPath: string, options?: ListOptions): Promise<FileEntry[]> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n return await this.readDirectory(target, options);\n } catch (error) {\n throw mapMesaError(error, inputPath, 'directory');\n }\n }\n\n async exists(inputPath: string): Promise<boolean> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n return await this.filesystem.exists(target);\n } catch (error) {\n if (getMesaErrorKind(error) === 'notFound') return false;\n throw mapMesaError(error, inputPath);\n }\n }\n\n async stat(inputPath: string): Promise<FileStat> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n return this.toFileStat(target, stats);\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n async realpath(inputPath: string): Promise<string> {\n await this.ensureReady();\n try {\n return await this.filesystem.realpath(normalizePath(inputPath));\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n /**\n * Create a Mesa-backed Bash runtime for this filesystem.\n */\n async bash(options?: MesaBashOptions): Promise<Bash> {\n await this.ensureReady();\n return this.filesystem.bash(options);\n }\n\n /**\n * Mesa change management operations for the mounted filesystem.\n */\n get change(): MesaFileSystem['change'] {\n return this.filesystem.change;\n }\n\n /**\n * Mesa bookmark management operations for the mounted filesystem.\n */\n get bookmark(): MesaFileSystem['bookmark'] {\n return this.filesystem.bookmark;\n }\n\n private assertWritable(operation: string): void {\n if (this.readOnly) {\n throw new WorkspaceReadOnlyError(operation);\n }\n }\n\n private async assertExpectedMtime(inputPath: string, expectedMtime: Date): Promise<void> {\n try {\n const currentStat = await this.stat(inputPath);\n if (currentStat.modifiedAt.getTime() !== expectedMtime.getTime()) {\n throw new StaleFileError(inputPath, expectedMtime, currentStat.modifiedAt);\n }\n } catch (error) {\n if (error instanceof StaleFileError) throw error;\n if (error instanceof FileNotFoundError) return;\n throw error;\n }\n }\n\n private async ensureParentDirectory(inputPath: string): Promise<void> {\n const parent = path.dirname(inputPath);\n if (parent === '/' || parent === inputPath) return;\n\n try {\n await this.filesystem.mkdir(parent, { recursive: true });\n } catch (error) {\n const mapped = mapMesaError(error, parent, 'directory');\n if (!(mapped instanceof FileExistsError)) throw mapped;\n try {\n const stats = await this.filesystem.stat(parent);\n if (!stats.isDirectory) {\n throw new NotDirectoryError(parent);\n }\n } catch (statError) {\n if (statError instanceof NotDirectoryError) throw statError;\n throw mapMesaError(statError, parent, 'directory');\n }\n }\n }\n\n private async assertParentDirectoryExists(inputPath: string): Promise<void> {\n const parent = path.dirname(inputPath);\n if (parent === '/' || parent === inputPath) return;\n\n try {\n const stats = await this.filesystem.stat(parent);\n if (!stats.isDirectory) {\n throw new NotDirectoryError(parent);\n }\n } catch (error) {\n if (error instanceof NotDirectoryError) throw error;\n throw mapMesaError(error, parent, 'directory');\n }\n }\n\n private async readDirectory(inputPath: string, options?: ListOptions, depth = 0): Promise<FileEntry[]> {\n const entries = await this.filesystem.readdirWithFileTypes(inputPath);\n const extensions = options?.extension\n ? Array.isArray(options.extension)\n ? options.extension\n : [options.extension]\n : undefined;\n\n const result: FileEntry[] = [];\n for (const entry of entries) {\n const childPath = path.join(inputPath, entry.name);\n if (entry.isFile) {\n if (matchesExtension(entry.name, extensions)) {\n const stat = await this.safeStat(childPath);\n result.push({ name: entry.name, type: 'file', size: stat?.size });\n }\n continue;\n }\n\n if (entry.isDirectory) {\n result.push({ name: entry.name, type: 'directory' });\n\n if (options?.recursive && (options.maxDepth === undefined || depth < options.maxDepth)) {\n const childEntries = await this.readDirectory(childPath, options, depth + 1);\n result.push(...childEntries.map(child => ({ ...child, name: `${entry.name}/${child.name}` })));\n }\n continue;\n }\n\n result.push(this.toFileEntry(entry));\n }\n\n return result;\n }\n\n private async safeStat(inputPath: string): Promise<MesaFsStat | undefined> {\n try {\n return await this.filesystem.stat(inputPath);\n } catch {\n return undefined;\n }\n }\n\n private toFileEntry(entry: MesaDirent): FileEntry {\n return {\n name: entry.name,\n type: entry.isDirectory ? 'directory' : 'file',\n isSymlink: entry.isSymbolicLink || undefined,\n };\n }\n\n private toFileStat(inputPath: string, stats: MesaFsStat): FileStat {\n const target = normalizePath(inputPath);\n\n return {\n name: target === '/' ? '/' : path.basename(target),\n path: target,\n type: stats.isDirectory ? 'directory' : 'file',\n size: stats.isDirectory ? 0 : stats.size,\n createdAt: stats.mtime,\n modifiedAt: stats.mtime,\n // read_file picks media, binary or text from mimeType.\n ...(!stats.isDirectory && { mimeType: getMimeType(target) }),\n };\n }\n}\n","/**\n * Mesa filesystem provider descriptor for MastraEditor.\n */\nimport type { FilesystemProvider } from '@mastra/core/editor';\n\nimport { MesaFilesystem } from './filesystem';\nimport type { MesaFilesystemOptions } from './filesystem';\n\nexport const mesaFilesystemProvider: FilesystemProvider<MesaFilesystemOptions> = {\n id: 'mesa',\n name: 'Mesa',\n description: 'Versioned Mesa filesystem for workspace files',\n configSchema: {\n type: 'object',\n required: ['authors', 'layout'],\n properties: {\n privateKey: { type: 'string', description: 'Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted.' },\n authors: {\n type: 'array',\n description: 'Commit authors attributed to writes',\n minItems: 1,\n items: {\n type: 'object',\n required: ['name'],\n properties: {\n name: { type: 'string', description: 'Author name' },\n email: { type: 'string', description: 'Author email' },\n },\n },\n },\n layout: {\n type: 'object',\n minProperties: 1,\n description:\n 'Mesa mount layout mapping absolute paths to repo declarations, e.g. { \"/docs\": { \"kind\": \"repo\", \"name\": \"docs\", \"mode\": \"rw\" } }',\n },\n cache: {\n type: 'object',\n description: 'Mesa filesystem cache configuration',\n properties: {\n diskCache: {\n type: 'object',\n required: ['path'],\n properties: {\n path: { type: 'string', description: 'Disk cache path' },\n maxSizeBytes: { type: 'number', description: 'Maximum disk cache size in bytes' },\n },\n },\n },\n },\n ttl: { type: 'number', description: 'Mesa mount token lifetime in seconds' },\n readOnly: { type: 'boolean', description: 'Mount every layout repo as read-only', default: false },\n },\n },\n createFilesystem: config => new MesaFilesystem(config),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAS,aAAqB;CAC5B,OAAO,WAAW,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AACpF;AAEA,SAAS,cAAc,WAA2B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AM;OAAU,aAAa;MAAmC;KAClF;IACF,EACF;GACF;GACA,KAAK;IAAE,MAAM;IAAU,aAAa;GAAuC;GAC3E,UAAU;IAAE,MAAM;IAAW,aAAa;IAAwC,SAAS;GAAM;EACnG;CACF;CACA,mBAAkB,WAAU,IAAI,eAAe,MAAM;AACvD"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import path from "path/posix";
2
- import { DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, NotDirectoryError, StaleFileError, WorkspaceReadOnlyError } from "@mastra/core/workspace";
2
+ import { DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, NotDirectoryError, StaleFileError, WorkspaceReadOnlyError, getMimeType } from "@mastra/core/workspace";
3
3
  import { Mesa, repo } from "@mesadev/sdk";
4
- //#region src/filesystem/index.ts
4
+ // src/filesystem/index.ts
5
5
  function generateId() {
6
6
  return `mesa-fs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
7
7
  }
@@ -442,12 +442,12 @@ var MesaFilesystem = class extends MastraFilesystem {
442
442
  type: stats.isDirectory ? "directory" : "file",
443
443
  size: stats.isDirectory ? 0 : stats.size,
444
444
  createdAt: stats.mtime,
445
- modifiedAt: stats.mtime
445
+ modifiedAt: stats.mtime,
446
+ ...!stats.isDirectory && { mimeType: getMimeType(target) }
446
447
  };
447
448
  }
448
449
  };
449
- //#endregion
450
- //#region src/provider.ts
450
+ // src/provider.ts
451
451
  const mesaFilesystemProvider = {
452
452
  id: "mesa",
453
453
  name: "Mesa",
@@ -515,7 +515,6 @@ const mesaFilesystemProvider = {
515
515
  },
516
516
  createFilesystem: (config) => new MesaFilesystem(config)
517
517
  };
518
- //#endregion
519
518
  export { MesaFilesystem, mesaFilesystemProvider, repo };
520
519
 
521
520
  //# 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":["import path from 'node:path/posix';\n\nimport type {\n CopyOptions,\n FileContent,\n FileEntry,\n FilesystemInfo,\n FileStat,\n ListOptions,\n MastraFilesystemOptions,\n ProviderStatus,\n ReadOptions,\n RemoveOptions,\n WriteOptions,\n} from '@mastra/core/workspace';\nimport {\n DirectoryNotEmptyError,\n DirectoryNotFoundError,\n FileExistsError,\n FileNotFoundError,\n IsDirectoryError,\n MastraFilesystem,\n NotDirectoryError,\n StaleFileError,\n WorkspaceReadOnlyError,\n} from '@mastra/core/workspace';\nimport { Mesa } from '@mesadev/sdk';\nimport type {\n Author,\n Bash,\n FsMountRuntimeOptions,\n Layout,\n MesaBashOptions,\n MesaFileSystem,\n MesaOptions,\n Repo,\n TelemetryConfig,\n} from '@mesadev/sdk';\n\ntype MesaFsStat = Awaited<ReturnType<MesaFileSystem['stat']>>;\ntype MesaDirent = Awaited<ReturnType<NonNullable<MesaFileSystem['readdirWithFileTypes']>>>[number];\n\nexport interface MesaFilesystemOptions extends MastraFilesystemOptions {\n /** Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted. */\n privateKey?: string;\n /** Commit authors attributed to writes made through this filesystem. */\n authors: readonly [Author, ...Author[]];\n /** Mesa mount layout mapping absolute paths to repos, built with `repo()`. */\n layout: Layout;\n /** Mount every layout repo read-only and block writes through the Mastra filesystem interface. */\n readOnly?: boolean;\n /** Mesa filesystem cache configuration. */\n cache?: FsMountRuntimeOptions['cache'];\n /** Mesa mount token lifetime in seconds. */\n ttl?: number;\n /** Mesa filesystem telemetry configuration. */\n telemetry?: TelemetryConfig;\n /** Custom fetch implementation for Mesa API calls. */\n fetch?: MesaOptions['fetch'];\n /** User agent for Mesa API calls. */\n userAgent?: string;\n}\n\nfunction generateId(): string {\n return `mesa-fs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nfunction normalizePath(inputPath: string): string {\n return path.normalize(inputPath.startsWith('/') ? inputPath : `/${inputPath}`);\n}\n\nfunction getExtension(name: string): string {\n const dot = name.lastIndexOf('.');\n return dot === -1 ? '' : name.slice(dot);\n}\n\nfunction matchesExtension(name: string, extensions?: string[]): boolean {\n if (!extensions) return true;\n const ext = getExtension(name);\n return extensions.some(candidate => candidate === ext || candidate === ext.slice(1));\n}\n\nfunction toReadOnlyLayout(layout: Record<string, Repo | Repo[]>): Layout {\n const toReadOnly = (repo: Repo): Repo => {\n if (repo.branchedFrom) {\n throw new Error(\n `MesaFilesystem readOnly cannot mount repo \"${repo.name}\" with branchedFrom, which requires mode \"rw\".`,\n );\n }\n return {\n ...repo,\n mode: 'ro',\n ...(repo.subPaths && { subPaths: toReadOnlyLayout(repo.subPaths) }),\n } as Repo;\n };\n return Object.fromEntries(\n Object.entries(layout).map(([key, entry]) => [\n key,\n Array.isArray(entry) ? entry.map(toReadOnly) : toReadOnly(entry),\n ]),\n ) as Layout;\n}\n\nfunction toMesaContent(content: FileContent): string | Uint8Array {\n if (typeof content === 'string') return content;\n if (Buffer.isBuffer(content)) return new Uint8Array(content);\n return content;\n}\n\ntype MesaErrorKind = 'notFound' | 'alreadyExists' | 'notDirectory' | 'isDirectory' | 'directoryNotEmpty';\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\nfunction getMesaErrorKind(error: unknown): MesaErrorKind | undefined {\n const err =\n error && typeof error === 'object' ? (error as { code?: unknown; name?: unknown; message?: unknown }) : undefined;\n const code = typeof err?.code === 'string' ? err.code : undefined;\n const name = typeof err?.name === 'string' ? err.name : undefined;\n\n for (const value of [code, name]) {\n switch (value) {\n case 'ENOENT':\n case 'NotFound':\n case 'NoSuchFile':\n case 'NoSuchKey':\n return 'notFound';\n case 'EEXIST':\n case 'AlreadyExists':\n return 'alreadyExists';\n case 'ENOTDIR':\n case 'NotDirectory':\n return 'notDirectory';\n case 'EISDIR':\n case 'IsDirectory':\n return 'isDirectory';\n case 'ENOTEMPTY':\n case 'DirectoryNotEmpty':\n return 'directoryNotEmpty';\n }\n }\n\n const message =\n typeof err?.message === 'string' ? err.message : error instanceof Error ? error.message : String(error);\n if (/\\b(no such file|not found|enoent)\\b/i.test(message)) return 'notFound';\n if (/\\b(already exists|eexist)\\b/i.test(message)) return 'alreadyExists';\n if (/\\b(not a directory|enotdir)\\b/i.test(message)) return 'notDirectory';\n if (/\\b(is a directory|eisdir)\\b/i.test(message)) return 'isDirectory';\n if (/\\b(directory not empty|enotempty)\\b/i.test(message)) return 'directoryNotEmpty';\n\n return undefined;\n}\n\nfunction mapMesaError(error: unknown, inputPath: string, context: 'file' | 'directory' = 'file'): Error {\n switch (getMesaErrorKind(error)) {\n case 'notFound':\n return context === 'directory' ? new DirectoryNotFoundError(inputPath) : new FileNotFoundError(inputPath);\n case 'alreadyExists':\n return new FileExistsError(inputPath);\n case 'notDirectory':\n return new NotDirectoryError(inputPath);\n case 'isDirectory':\n return new IsDirectoryError(inputPath);\n case 'directoryNotEmpty':\n return new DirectoryNotEmptyError(inputPath);\n default:\n return toError(error);\n }\n}\n\n/**\n * Workspace filesystem adapter backed by Mesa.\n *\n * This provider runs in the Mastra process and implements the workspace file\n * API against Mesa repos. It does not mount Mesa into a sandbox.\n */\nexport class MesaFilesystem extends MastraFilesystem {\n readonly id: string;\n readonly name = 'MesaFilesystem';\n readonly provider = 'mesa';\n readonly readOnly?: boolean;\n readonly icon = 'mesa';\n readonly displayName = 'Mesa';\n readonly description = 'Versioned Mesa filesystem for workspace files';\n\n status: ProviderStatus = 'pending';\n\n private readonly _privateKey?: string;\n private readonly _authors: readonly [Author, ...Author[]];\n private readonly _layout: Layout;\n private readonly _cache?: FsMountRuntimeOptions['cache'];\n private readonly _ttl?: number;\n private readonly _telemetry?: TelemetryConfig;\n private readonly _fetch?: MesaOptions['fetch'];\n private readonly _userAgent?: string;\n\n private _mesa?: Mesa;\n private _filesystem?: MesaFileSystem;\n\n constructor(options: MesaFilesystemOptions) {\n super({ name: 'MesaFilesystem', ...options });\n\n this.id = generateId();\n this.readOnly = options.readOnly;\n this._privateKey = options.privateKey;\n this._authors = options.authors;\n this._layout = options.layout;\n this._cache = options.cache;\n this._ttl = options.ttl;\n this._telemetry = options.telemetry;\n this._fetch = options.fetch;\n this._userAgent = options.userAgent;\n }\n\n /**\n * The active Mesa client, available after initialization when this instance\n * created the client itself.\n */\n get client(): Mesa | undefined {\n return this._mesa;\n }\n\n /**\n * The active Mesa filesystem. Accessing this before initialization throws.\n */\n get filesystem(): MesaFileSystem {\n if (!this._filesystem) {\n throw new Error('MesaFilesystem is not initialized. Call init() first or perform a filesystem operation.');\n }\n return this._filesystem;\n }\n\n override async init(): Promise<void> {\n if (Object.keys(this._layout).length === 0) {\n throw new Error('MesaFilesystem requires a layout with at least one path.');\n }\n\n this._mesa = new Mesa({\n privateKey: this._privateKey,\n fetch: this._fetch,\n userAgent: this._userAgent,\n });\n\n const layout = this.readOnly ? toReadOnlyLayout(this._layout) : this._layout;\n this._filesystem = await this._mesa\n .fs({ layout, ttl: this._ttl, authors: this._authors })\n .mount({ cache: this._cache, telemetry: this._telemetry });\n }\n\n getInfo(): FilesystemInfo<{\n paths: string[];\n mode: 'mounted' | 'client';\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 paths: Object.keys(this._layout),\n mode: 'client',\n },\n };\n }\n\n getInstructions(): string {\n const paths = Object.keys(this._layout);\n const parts = ['Mesa filesystem. Paths are rooted at the Mesa mount layout.'];\n\n if (paths.length > 0) {\n parts.push(`Mounted paths: ${paths.map(p => `\"${p}\"`).join(', ')}. For example \"${paths[0]}/file.txt\".`);\n }\n\n parts.push('Files are versioned by Mesa.');\n\n if (this.readOnly) {\n parts.push('Mounted read-only.');\n }\n\n return parts.join(' ');\n }\n\n async readFile(inputPath: string, options?: ReadOptions): Promise<string | Buffer> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n const buffer = Buffer.from(await this.filesystem.readFileBuffer(target));\n if (options?.encoding) return buffer.toString(options.encoding);\n return buffer;\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n async writeFile(inputPath: string, content: FileContent, options?: WriteOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('writeFile');\n const target = normalizePath(inputPath);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(inputPath);\n }\n\n if (options?.expectedMtime) {\n await this.assertExpectedMtime(inputPath, options.expectedMtime);\n }\n\n if (options?.recursive === false) {\n await this.assertParentDirectoryExists(target);\n } else {\n await this.ensureParentDirectory(target);\n }\n\n try {\n await this.filesystem.writeFile(target, toMesaContent(content));\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof NotDirectoryError) throw new NotDirectoryError(path.dirname(target));\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async appendFile(inputPath: string, content: FileContent): Promise<void> {\n await this.ensureReady();\n this.assertWritable('appendFile');\n const target = normalizePath(inputPath);\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.appendFile(target, toMesaContent(content));\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async deleteFile(inputPath: string, options?: RemoveOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('deleteFile');\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n if (stats.isDirectory) throw new IsDirectoryError(inputPath);\n await this.filesystem.rm(target, { force: options?.force });\n } catch (error) {\n if (error instanceof IsDirectoryError) throw error;\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) {\n if (options?.force) return;\n throw mapped;\n }\n throw mapped;\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('copyFile');\n const source = normalizePath(src);\n const target = normalizePath(dest);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(dest);\n }\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.cp(source, target, { recursive: options?.recursive });\n } catch (error) {\n const mapped = mapMesaError(error, src);\n if (mapped instanceof FileExistsError) throw new FileExistsError(dest);\n throw mapped;\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('moveFile');\n const source = normalizePath(src);\n const target = normalizePath(dest);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(dest);\n }\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.mv(source, target);\n } catch (error) {\n const mapped = mapMesaError(error, src);\n if (mapped instanceof FileExistsError) throw new FileExistsError(dest);\n throw mapped;\n }\n }\n\n async mkdir(inputPath: string, options?: { recursive?: boolean }): Promise<void> {\n await this.ensureReady();\n this.assertWritable('mkdir');\n const target = normalizePath(inputPath);\n\n try {\n await this.filesystem.mkdir(target, { recursive: options?.recursive ?? true });\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async rmdir(inputPath: string, options?: RemoveOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('rmdir');\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n if (!stats.isDirectory) throw new NotDirectoryError(inputPath);\n\n if (!options?.recursive) {\n const entries = await this.filesystem.readdirWithFileTypes(target);\n if (entries.length > 0) throw new DirectoryNotEmptyError(inputPath);\n }\n\n await this.filesystem.rm(target, { recursive: options?.recursive ?? true, force: options?.force });\n } catch (error) {\n if (error instanceof NotDirectoryError) throw error;\n if (error instanceof DirectoryNotEmptyError) throw error;\n const mapped = mapMesaError(error, inputPath, 'directory');\n if (mapped instanceof DirectoryNotFoundError) {\n if (options?.force) return;\n throw mapped;\n }\n throw mapped;\n }\n }\n\n async readdir(inputPath: string, options?: ListOptions): Promise<FileEntry[]> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n return await this.readDirectory(target, options);\n } catch (error) {\n throw mapMesaError(error, inputPath, 'directory');\n }\n }\n\n async exists(inputPath: string): Promise<boolean> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n return await this.filesystem.exists(target);\n } catch (error) {\n if (getMesaErrorKind(error) === 'notFound') return false;\n throw mapMesaError(error, inputPath);\n }\n }\n\n async stat(inputPath: string): Promise<FileStat> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n return this.toFileStat(target, stats);\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n async realpath(inputPath: string): Promise<string> {\n await this.ensureReady();\n try {\n return await this.filesystem.realpath(normalizePath(inputPath));\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n /**\n * Create a Mesa-backed Bash runtime for this filesystem.\n */\n async bash(options?: MesaBashOptions): Promise<Bash> {\n await this.ensureReady();\n return this.filesystem.bash(options);\n }\n\n /**\n * Mesa change management operations for the mounted filesystem.\n */\n get change(): MesaFileSystem['change'] {\n return this.filesystem.change;\n }\n\n /**\n * Mesa bookmark management operations for the mounted filesystem.\n */\n get bookmark(): MesaFileSystem['bookmark'] {\n return this.filesystem.bookmark;\n }\n\n private assertWritable(operation: string): void {\n if (this.readOnly) {\n throw new WorkspaceReadOnlyError(operation);\n }\n }\n\n private async assertExpectedMtime(inputPath: string, expectedMtime: Date): Promise<void> {\n try {\n const currentStat = await this.stat(inputPath);\n if (currentStat.modifiedAt.getTime() !== expectedMtime.getTime()) {\n throw new StaleFileError(inputPath, expectedMtime, currentStat.modifiedAt);\n }\n } catch (error) {\n if (error instanceof StaleFileError) throw error;\n if (error instanceof FileNotFoundError) return;\n throw error;\n }\n }\n\n private async ensureParentDirectory(inputPath: string): Promise<void> {\n const parent = path.dirname(inputPath);\n if (parent === '/' || parent === inputPath) return;\n\n try {\n await this.filesystem.mkdir(parent, { recursive: true });\n } catch (error) {\n const mapped = mapMesaError(error, parent, 'directory');\n if (!(mapped instanceof FileExistsError)) throw mapped;\n try {\n const stats = await this.filesystem.stat(parent);\n if (!stats.isDirectory) {\n throw new NotDirectoryError(parent);\n }\n } catch (statError) {\n if (statError instanceof NotDirectoryError) throw statError;\n throw mapMesaError(statError, parent, 'directory');\n }\n }\n }\n\n private async assertParentDirectoryExists(inputPath: string): Promise<void> {\n const parent = path.dirname(inputPath);\n if (parent === '/' || parent === inputPath) return;\n\n try {\n const stats = await this.filesystem.stat(parent);\n if (!stats.isDirectory) {\n throw new NotDirectoryError(parent);\n }\n } catch (error) {\n if (error instanceof NotDirectoryError) throw error;\n throw mapMesaError(error, parent, 'directory');\n }\n }\n\n private async readDirectory(inputPath: string, options?: ListOptions, depth = 0): Promise<FileEntry[]> {\n const entries = await this.filesystem.readdirWithFileTypes(inputPath);\n const extensions = options?.extension\n ? Array.isArray(options.extension)\n ? options.extension\n : [options.extension]\n : undefined;\n\n const result: FileEntry[] = [];\n for (const entry of entries) {\n const childPath = path.join(inputPath, entry.name);\n if (entry.isFile) {\n if (matchesExtension(entry.name, extensions)) {\n const stat = await this.safeStat(childPath);\n result.push({ name: entry.name, type: 'file', size: stat?.size });\n }\n continue;\n }\n\n if (entry.isDirectory) {\n result.push({ name: entry.name, type: 'directory' });\n\n if (options?.recursive && (options.maxDepth === undefined || depth < options.maxDepth)) {\n const childEntries = await this.readDirectory(childPath, options, depth + 1);\n result.push(...childEntries.map(child => ({ ...child, name: `${entry.name}/${child.name}` })));\n }\n continue;\n }\n\n result.push(this.toFileEntry(entry));\n }\n\n return result;\n }\n\n private async safeStat(inputPath: string): Promise<MesaFsStat | undefined> {\n try {\n return await this.filesystem.stat(inputPath);\n } catch {\n return undefined;\n }\n }\n\n private toFileEntry(entry: MesaDirent): FileEntry {\n return {\n name: entry.name,\n type: entry.isDirectory ? 'directory' : 'file',\n isSymlink: entry.isSymbolicLink || undefined,\n };\n }\n\n private toFileStat(inputPath: string, stats: MesaFsStat): FileStat {\n const target = normalizePath(inputPath);\n\n return {\n name: target === '/' ? '/' : path.basename(target),\n path: target,\n type: stats.isDirectory ? 'directory' : 'file',\n size: stats.isDirectory ? 0 : stats.size,\n createdAt: stats.mtime,\n modifiedAt: stats.mtime,\n };\n }\n}\n","/**\n * Mesa filesystem provider descriptor for MastraEditor.\n */\nimport type { FilesystemProvider } from '@mastra/core/editor';\n\nimport { MesaFilesystem } from './filesystem';\nimport type { MesaFilesystemOptions } from './filesystem';\n\nexport const mesaFilesystemProvider: FilesystemProvider<MesaFilesystemOptions> = {\n id: 'mesa',\n name: 'Mesa',\n description: 'Versioned Mesa filesystem for workspace files',\n configSchema: {\n type: 'object',\n required: ['authors', 'layout'],\n properties: {\n privateKey: { type: 'string', description: 'Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted.' },\n authors: {\n type: 'array',\n description: 'Commit authors attributed to writes',\n minItems: 1,\n items: {\n type: 'object',\n required: ['name'],\n properties: {\n name: { type: 'string', description: 'Author name' },\n email: { type: 'string', description: 'Author email' },\n },\n },\n },\n layout: {\n type: 'object',\n minProperties: 1,\n description:\n 'Mesa mount layout mapping absolute paths to repo declarations, e.g. { \"/docs\": { \"kind\": \"repo\", \"name\": \"docs\", \"mode\": \"rw\" } }',\n },\n cache: {\n type: 'object',\n description: 'Mesa filesystem cache configuration',\n properties: {\n diskCache: {\n type: 'object',\n required: ['path'],\n properties: {\n path: { type: 'string', description: 'Disk cache path' },\n maxSizeBytes: { type: 'number', description: 'Maximum disk cache size in bytes' },\n },\n },\n },\n },\n ttl: { type: 'number', description: 'Mesa mount token lifetime in seconds' },\n readOnly: { type: 'boolean', description: 'Mount every layout repo as read-only', default: false },\n },\n },\n createFilesystem: config => new MesaFilesystem(config),\n};\n"],"mappings":";;;;AA+DA,SAAS,aAAqB;CAC5B,OAAO,WAA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;EACrC;CACF;CAEA,WAAmB,WAAmB,OAA6B;EACjE,MAAM,SAAS,cAAc,SAAS;EAEtC,OAAO;GACL,MAAM,WAAW,MAAM,MAAM,KAAK,SAAS,MAAM;GACjD,MAAM;GACN,MAAM,MAAM,cAAc,cAAc;GACxC,MAAM,MAAM,cAAc,IAAI,MAAM;GACpC,WAAW,MAAM;GACjB,YAAY,MAAM;EACpB;CACF;AACF;;;AC/mBA,MAAa,yBAAoE;CAC/E,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,UAAU,CAAC,WAAW,QAAQ;EAC9B,YAAY;GACV,YAAY;IAAE,MAAM;IAAU,aAAa;GAAiE;GAC5G,SAAS;IACP,MAAM;IACN,aAAa;IACb,UAAU;IACV,OAAO;KACL,MAAM;KACN,UAAU,CAAC,MAAM;KACjB,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,aAAa;MAAc;MACnD,OAAO;OAAE,MAAM;OAAU,aAAa;MAAe;KACvD;IACF;GACF;GACA,QAAQ;IACN,MAAM;IACN,eAAe;IACf,aACE;GACJ;GACA,OAAO;IACL,MAAM;IACN,aAAa;IACb,YAAY,EACV,WAAW;KACT,MAAM;KACN,UAAU,CAAC,MAAM;KACjB,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,aAAa;MAAkB;MACvD,cAAc;OAAE,MAAM;OAAU,aAAa;MAAmC;KAClF;IACF,EACF;GACF;GACA,KAAK;IAAE,MAAM;IAAU,aAAa;GAAuC;GAC3E,UAAU;IAAE,MAAM;IAAW,aAAa;IAAwC,SAAS;GAAM;EACnG;CACF;CACA,mBAAkB,WAAU,IAAI,eAAe,MAAM;AACvD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/filesystem/index.ts","../src/provider.ts"],"sourcesContent":["import path from 'node:path/posix';\n\nimport type {\n CopyOptions,\n FileContent,\n FileEntry,\n FilesystemInfo,\n FileStat,\n ListOptions,\n MastraFilesystemOptions,\n ProviderStatus,\n ReadOptions,\n RemoveOptions,\n WriteOptions,\n} from '@mastra/core/workspace';\nimport {\n DirectoryNotEmptyError,\n DirectoryNotFoundError,\n FileExistsError,\n FileNotFoundError,\n getMimeType,\n IsDirectoryError,\n MastraFilesystem,\n NotDirectoryError,\n StaleFileError,\n WorkspaceReadOnlyError,\n} from '@mastra/core/workspace';\nimport { Mesa } from '@mesadev/sdk';\nimport type {\n Author,\n Bash,\n FsMountRuntimeOptions,\n Layout,\n MesaBashOptions,\n MesaFileSystem,\n MesaOptions,\n Repo,\n TelemetryConfig,\n} from '@mesadev/sdk';\n\ntype MesaFsStat = Awaited<ReturnType<MesaFileSystem['stat']>>;\ntype MesaDirent = Awaited<ReturnType<NonNullable<MesaFileSystem['readdirWithFileTypes']>>>[number];\n\nexport interface MesaFilesystemOptions extends MastraFilesystemOptions {\n /** Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted. */\n privateKey?: string;\n /** Commit authors attributed to writes made through this filesystem. */\n authors: readonly [Author, ...Author[]];\n /** Mesa mount layout mapping absolute paths to repos, built with `repo()`. */\n layout: Layout;\n /** Mount every layout repo read-only and block writes through the Mastra filesystem interface. */\n readOnly?: boolean;\n /** Mesa filesystem cache configuration. */\n cache?: FsMountRuntimeOptions['cache'];\n /** Mesa mount token lifetime in seconds. */\n ttl?: number;\n /** Mesa filesystem telemetry configuration. */\n telemetry?: TelemetryConfig;\n /** Custom fetch implementation for Mesa API calls. */\n fetch?: MesaOptions['fetch'];\n /** User agent for Mesa API calls. */\n userAgent?: string;\n}\n\nfunction generateId(): string {\n return `mesa-fs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nfunction normalizePath(inputPath: string): string {\n return path.normalize(inputPath.startsWith('/') ? inputPath : `/${inputPath}`);\n}\n\nfunction getExtension(name: string): string {\n const dot = name.lastIndexOf('.');\n return dot === -1 ? '' : name.slice(dot);\n}\n\nfunction matchesExtension(name: string, extensions?: string[]): boolean {\n if (!extensions) return true;\n const ext = getExtension(name);\n return extensions.some(candidate => candidate === ext || candidate === ext.slice(1));\n}\n\nfunction toReadOnlyLayout(layout: Record<string, Repo | Repo[]>): Layout {\n const toReadOnly = (repo: Repo): Repo => {\n if (repo.branchedFrom) {\n throw new Error(\n `MesaFilesystem readOnly cannot mount repo \"${repo.name}\" with branchedFrom, which requires mode \"rw\".`,\n );\n }\n return {\n ...repo,\n mode: 'ro',\n ...(repo.subPaths && { subPaths: toReadOnlyLayout(repo.subPaths) }),\n } as Repo;\n };\n return Object.fromEntries(\n Object.entries(layout).map(([key, entry]) => [\n key,\n Array.isArray(entry) ? entry.map(toReadOnly) : toReadOnly(entry),\n ]),\n ) as Layout;\n}\n\nfunction toMesaContent(content: FileContent): string | Uint8Array {\n if (typeof content === 'string') return content;\n if (Buffer.isBuffer(content)) return new Uint8Array(content);\n return content;\n}\n\ntype MesaErrorKind = 'notFound' | 'alreadyExists' | 'notDirectory' | 'isDirectory' | 'directoryNotEmpty';\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\nfunction getMesaErrorKind(error: unknown): MesaErrorKind | undefined {\n const err =\n error && typeof error === 'object' ? (error as { code?: unknown; name?: unknown; message?: unknown }) : undefined;\n const code = typeof err?.code === 'string' ? err.code : undefined;\n const name = typeof err?.name === 'string' ? err.name : undefined;\n\n for (const value of [code, name]) {\n switch (value) {\n case 'ENOENT':\n case 'NotFound':\n case 'NoSuchFile':\n case 'NoSuchKey':\n return 'notFound';\n case 'EEXIST':\n case 'AlreadyExists':\n return 'alreadyExists';\n case 'ENOTDIR':\n case 'NotDirectory':\n return 'notDirectory';\n case 'EISDIR':\n case 'IsDirectory':\n return 'isDirectory';\n case 'ENOTEMPTY':\n case 'DirectoryNotEmpty':\n return 'directoryNotEmpty';\n }\n }\n\n const message =\n typeof err?.message === 'string' ? err.message : error instanceof Error ? error.message : String(error);\n if (/\\b(no such file|not found|enoent)\\b/i.test(message)) return 'notFound';\n if (/\\b(already exists|eexist)\\b/i.test(message)) return 'alreadyExists';\n if (/\\b(not a directory|enotdir)\\b/i.test(message)) return 'notDirectory';\n if (/\\b(is a directory|eisdir)\\b/i.test(message)) return 'isDirectory';\n if (/\\b(directory not empty|enotempty)\\b/i.test(message)) return 'directoryNotEmpty';\n\n return undefined;\n}\n\nfunction mapMesaError(error: unknown, inputPath: string, context: 'file' | 'directory' = 'file'): Error {\n switch (getMesaErrorKind(error)) {\n case 'notFound':\n return context === 'directory' ? new DirectoryNotFoundError(inputPath) : new FileNotFoundError(inputPath);\n case 'alreadyExists':\n return new FileExistsError(inputPath);\n case 'notDirectory':\n return new NotDirectoryError(inputPath);\n case 'isDirectory':\n return new IsDirectoryError(inputPath);\n case 'directoryNotEmpty':\n return new DirectoryNotEmptyError(inputPath);\n default:\n return toError(error);\n }\n}\n\n/**\n * Workspace filesystem adapter backed by Mesa.\n *\n * This provider runs in the Mastra process and implements the workspace file\n * API against Mesa repos. It does not mount Mesa into a sandbox.\n */\nexport class MesaFilesystem extends MastraFilesystem {\n readonly id: string;\n readonly name = 'MesaFilesystem';\n readonly provider = 'mesa';\n readonly readOnly?: boolean;\n readonly icon = 'mesa';\n readonly displayName = 'Mesa';\n readonly description = 'Versioned Mesa filesystem for workspace files';\n\n status: ProviderStatus = 'pending';\n\n private readonly _privateKey?: string;\n private readonly _authors: readonly [Author, ...Author[]];\n private readonly _layout: Layout;\n private readonly _cache?: FsMountRuntimeOptions['cache'];\n private readonly _ttl?: number;\n private readonly _telemetry?: TelemetryConfig;\n private readonly _fetch?: MesaOptions['fetch'];\n private readonly _userAgent?: string;\n\n private _mesa?: Mesa;\n private _filesystem?: MesaFileSystem;\n\n constructor(options: MesaFilesystemOptions) {\n super({ name: 'MesaFilesystem', ...options });\n\n this.id = generateId();\n this.readOnly = options.readOnly;\n this._privateKey = options.privateKey;\n this._authors = options.authors;\n this._layout = options.layout;\n this._cache = options.cache;\n this._ttl = options.ttl;\n this._telemetry = options.telemetry;\n this._fetch = options.fetch;\n this._userAgent = options.userAgent;\n }\n\n /**\n * The active Mesa client, available after initialization when this instance\n * created the client itself.\n */\n get client(): Mesa | undefined {\n return this._mesa;\n }\n\n /**\n * The active Mesa filesystem. Accessing this before initialization throws.\n */\n get filesystem(): MesaFileSystem {\n if (!this._filesystem) {\n throw new Error('MesaFilesystem is not initialized. Call init() first or perform a filesystem operation.');\n }\n return this._filesystem;\n }\n\n override async init(): Promise<void> {\n if (Object.keys(this._layout).length === 0) {\n throw new Error('MesaFilesystem requires a layout with at least one path.');\n }\n\n this._mesa = new Mesa({\n privateKey: this._privateKey,\n fetch: this._fetch,\n userAgent: this._userAgent,\n });\n\n const layout = this.readOnly ? toReadOnlyLayout(this._layout) : this._layout;\n this._filesystem = await this._mesa\n .fs({ layout, ttl: this._ttl, authors: this._authors })\n .mount({ cache: this._cache, telemetry: this._telemetry });\n }\n\n getInfo(): FilesystemInfo<{\n paths: string[];\n mode: 'mounted' | 'client';\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 paths: Object.keys(this._layout),\n mode: 'client',\n },\n };\n }\n\n getInstructions(): string {\n const paths = Object.keys(this._layout);\n const parts = ['Mesa filesystem. Paths are rooted at the Mesa mount layout.'];\n\n if (paths.length > 0) {\n parts.push(`Mounted paths: ${paths.map(p => `\"${p}\"`).join(', ')}. For example \"${paths[0]}/file.txt\".`);\n }\n\n parts.push('Files are versioned by Mesa.');\n\n if (this.readOnly) {\n parts.push('Mounted read-only.');\n }\n\n return parts.join(' ');\n }\n\n async readFile(inputPath: string, options?: ReadOptions): Promise<string | Buffer> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n const buffer = Buffer.from(await this.filesystem.readFileBuffer(target));\n if (options?.encoding) return buffer.toString(options.encoding);\n return buffer;\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n async writeFile(inputPath: string, content: FileContent, options?: WriteOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('writeFile');\n const target = normalizePath(inputPath);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(inputPath);\n }\n\n if (options?.expectedMtime) {\n await this.assertExpectedMtime(inputPath, options.expectedMtime);\n }\n\n if (options?.recursive === false) {\n await this.assertParentDirectoryExists(target);\n } else {\n await this.ensureParentDirectory(target);\n }\n\n try {\n await this.filesystem.writeFile(target, toMesaContent(content));\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof NotDirectoryError) throw new NotDirectoryError(path.dirname(target));\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async appendFile(inputPath: string, content: FileContent): Promise<void> {\n await this.ensureReady();\n this.assertWritable('appendFile');\n const target = normalizePath(inputPath);\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.appendFile(target, toMesaContent(content));\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async deleteFile(inputPath: string, options?: RemoveOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('deleteFile');\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n if (stats.isDirectory) throw new IsDirectoryError(inputPath);\n await this.filesystem.rm(target, { force: options?.force });\n } catch (error) {\n if (error instanceof IsDirectoryError) throw error;\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) {\n if (options?.force) return;\n throw mapped;\n }\n throw mapped;\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('copyFile');\n const source = normalizePath(src);\n const target = normalizePath(dest);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(dest);\n }\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.cp(source, target, { recursive: options?.recursive });\n } catch (error) {\n const mapped = mapMesaError(error, src);\n if (mapped instanceof FileExistsError) throw new FileExistsError(dest);\n throw mapped;\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('moveFile');\n const source = normalizePath(src);\n const target = normalizePath(dest);\n\n if (options?.overwrite === false && (await this.exists(target))) {\n throw new FileExistsError(dest);\n }\n\n await this.ensureParentDirectory(target);\n\n try {\n await this.filesystem.mv(source, target);\n } catch (error) {\n const mapped = mapMesaError(error, src);\n if (mapped instanceof FileExistsError) throw new FileExistsError(dest);\n throw mapped;\n }\n }\n\n async mkdir(inputPath: string, options?: { recursive?: boolean }): Promise<void> {\n await this.ensureReady();\n this.assertWritable('mkdir');\n const target = normalizePath(inputPath);\n\n try {\n await this.filesystem.mkdir(target, { recursive: options?.recursive ?? true });\n } catch (error) {\n const mapped = mapMesaError(error, inputPath);\n if (mapped instanceof FileNotFoundError) throw new DirectoryNotFoundError(path.dirname(target));\n throw mapped;\n }\n }\n\n async rmdir(inputPath: string, options?: RemoveOptions): Promise<void> {\n await this.ensureReady();\n this.assertWritable('rmdir');\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n if (!stats.isDirectory) throw new NotDirectoryError(inputPath);\n\n if (!options?.recursive) {\n const entries = await this.filesystem.readdirWithFileTypes(target);\n if (entries.length > 0) throw new DirectoryNotEmptyError(inputPath);\n }\n\n await this.filesystem.rm(target, { recursive: options?.recursive ?? true, force: options?.force });\n } catch (error) {\n if (error instanceof NotDirectoryError) throw error;\n if (error instanceof DirectoryNotEmptyError) throw error;\n const mapped = mapMesaError(error, inputPath, 'directory');\n if (mapped instanceof DirectoryNotFoundError) {\n if (options?.force) return;\n throw mapped;\n }\n throw mapped;\n }\n }\n\n async readdir(inputPath: string, options?: ListOptions): Promise<FileEntry[]> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n return await this.readDirectory(target, options);\n } catch (error) {\n throw mapMesaError(error, inputPath, 'directory');\n }\n }\n\n async exists(inputPath: string): Promise<boolean> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n return await this.filesystem.exists(target);\n } catch (error) {\n if (getMesaErrorKind(error) === 'notFound') return false;\n throw mapMesaError(error, inputPath);\n }\n }\n\n async stat(inputPath: string): Promise<FileStat> {\n await this.ensureReady();\n const target = normalizePath(inputPath);\n\n try {\n const stats = await this.filesystem.stat(target);\n return this.toFileStat(target, stats);\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n async realpath(inputPath: string): Promise<string> {\n await this.ensureReady();\n try {\n return await this.filesystem.realpath(normalizePath(inputPath));\n } catch (error) {\n throw mapMesaError(error, inputPath);\n }\n }\n\n /**\n * Create a Mesa-backed Bash runtime for this filesystem.\n */\n async bash(options?: MesaBashOptions): Promise<Bash> {\n await this.ensureReady();\n return this.filesystem.bash(options);\n }\n\n /**\n * Mesa change management operations for the mounted filesystem.\n */\n get change(): MesaFileSystem['change'] {\n return this.filesystem.change;\n }\n\n /**\n * Mesa bookmark management operations for the mounted filesystem.\n */\n get bookmark(): MesaFileSystem['bookmark'] {\n return this.filesystem.bookmark;\n }\n\n private assertWritable(operation: string): void {\n if (this.readOnly) {\n throw new WorkspaceReadOnlyError(operation);\n }\n }\n\n private async assertExpectedMtime(inputPath: string, expectedMtime: Date): Promise<void> {\n try {\n const currentStat = await this.stat(inputPath);\n if (currentStat.modifiedAt.getTime() !== expectedMtime.getTime()) {\n throw new StaleFileError(inputPath, expectedMtime, currentStat.modifiedAt);\n }\n } catch (error) {\n if (error instanceof StaleFileError) throw error;\n if (error instanceof FileNotFoundError) return;\n throw error;\n }\n }\n\n private async ensureParentDirectory(inputPath: string): Promise<void> {\n const parent = path.dirname(inputPath);\n if (parent === '/' || parent === inputPath) return;\n\n try {\n await this.filesystem.mkdir(parent, { recursive: true });\n } catch (error) {\n const mapped = mapMesaError(error, parent, 'directory');\n if (!(mapped instanceof FileExistsError)) throw mapped;\n try {\n const stats = await this.filesystem.stat(parent);\n if (!stats.isDirectory) {\n throw new NotDirectoryError(parent);\n }\n } catch (statError) {\n if (statError instanceof NotDirectoryError) throw statError;\n throw mapMesaError(statError, parent, 'directory');\n }\n }\n }\n\n private async assertParentDirectoryExists(inputPath: string): Promise<void> {\n const parent = path.dirname(inputPath);\n if (parent === '/' || parent === inputPath) return;\n\n try {\n const stats = await this.filesystem.stat(parent);\n if (!stats.isDirectory) {\n throw new NotDirectoryError(parent);\n }\n } catch (error) {\n if (error instanceof NotDirectoryError) throw error;\n throw mapMesaError(error, parent, 'directory');\n }\n }\n\n private async readDirectory(inputPath: string, options?: ListOptions, depth = 0): Promise<FileEntry[]> {\n const entries = await this.filesystem.readdirWithFileTypes(inputPath);\n const extensions = options?.extension\n ? Array.isArray(options.extension)\n ? options.extension\n : [options.extension]\n : undefined;\n\n const result: FileEntry[] = [];\n for (const entry of entries) {\n const childPath = path.join(inputPath, entry.name);\n if (entry.isFile) {\n if (matchesExtension(entry.name, extensions)) {\n const stat = await this.safeStat(childPath);\n result.push({ name: entry.name, type: 'file', size: stat?.size });\n }\n continue;\n }\n\n if (entry.isDirectory) {\n result.push({ name: entry.name, type: 'directory' });\n\n if (options?.recursive && (options.maxDepth === undefined || depth < options.maxDepth)) {\n const childEntries = await this.readDirectory(childPath, options, depth + 1);\n result.push(...childEntries.map(child => ({ ...child, name: `${entry.name}/${child.name}` })));\n }\n continue;\n }\n\n result.push(this.toFileEntry(entry));\n }\n\n return result;\n }\n\n private async safeStat(inputPath: string): Promise<MesaFsStat | undefined> {\n try {\n return await this.filesystem.stat(inputPath);\n } catch {\n return undefined;\n }\n }\n\n private toFileEntry(entry: MesaDirent): FileEntry {\n return {\n name: entry.name,\n type: entry.isDirectory ? 'directory' : 'file',\n isSymlink: entry.isSymbolicLink || undefined,\n };\n }\n\n private toFileStat(inputPath: string, stats: MesaFsStat): FileStat {\n const target = normalizePath(inputPath);\n\n return {\n name: target === '/' ? '/' : path.basename(target),\n path: target,\n type: stats.isDirectory ? 'directory' : 'file',\n size: stats.isDirectory ? 0 : stats.size,\n createdAt: stats.mtime,\n modifiedAt: stats.mtime,\n // read_file picks media, binary or text from mimeType.\n ...(!stats.isDirectory && { mimeType: getMimeType(target) }),\n };\n }\n}\n","/**\n * Mesa filesystem provider descriptor for MastraEditor.\n */\nimport type { FilesystemProvider } from '@mastra/core/editor';\n\nimport { MesaFilesystem } from './filesystem';\nimport type { MesaFilesystemOptions } from './filesystem';\n\nexport const mesaFilesystemProvider: FilesystemProvider<MesaFilesystemOptions> = {\n id: 'mesa',\n name: 'Mesa',\n description: 'Versioned Mesa filesystem for workspace files',\n configSchema: {\n type: 'object',\n required: ['authors', 'layout'],\n properties: {\n privateKey: { type: 'string', description: 'Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted.' },\n authors: {\n type: 'array',\n description: 'Commit authors attributed to writes',\n minItems: 1,\n items: {\n type: 'object',\n required: ['name'],\n properties: {\n name: { type: 'string', description: 'Author name' },\n email: { type: 'string', description: 'Author email' },\n },\n },\n },\n layout: {\n type: 'object',\n minProperties: 1,\n description:\n 'Mesa mount layout mapping absolute paths to repo declarations, e.g. { \"/docs\": { \"kind\": \"repo\", \"name\": \"docs\", \"mode\": \"rw\" } }',\n },\n cache: {\n type: 'object',\n description: 'Mesa filesystem cache configuration',\n properties: {\n diskCache: {\n type: 'object',\n required: ['path'],\n properties: {\n path: { type: 'string', description: 'Disk cache path' },\n maxSizeBytes: { type: 'number', description: 'Maximum disk cache size in bytes' },\n },\n },\n },\n },\n ttl: { type: 'number', description: 'Mesa mount token lifetime in seconds' },\n readOnly: { type: 'boolean', description: 'Mount every layout repo as read-only', default: false },\n },\n },\n createFilesystem: config => new MesaFilesystem(config),\n};\n"],"mappings":";;;;AAgEA,SAAS,aAAqB;CAC5B,OAAO,WAAW,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,CA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AAK,SAAS,MAAM;GACjD,MAAM;GACN,MAAM,MAAM,cAAc,cAAc;GACxC,MAAM,MAAM,cAAc,IAAI,MAAM;GACpC,WAAW,MAAM;GACjB,YAAY,MAAM;GAElB,GAAI,CAAC,MAAM,eAAe,EAAE,UAAU,YAAY,MAAM,EAAE;EAC5D;CACF;AACF;;AClnBA,MAAa,yBAAoE;CAC/E,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,UAAU,CAAC,WAAW,QAAQ;EAC9B,YAAY;GACV,YAAY;IAAE,MAAM;IAAU,aAAa;GAAiE;GAC5G,SAAS;IACP,MAAM;IACN,aAAa;IACb,UAAU;IACV,OAAO;KACL,MAAM;KACN,UAAU,CAAC,MAAM;KACjB,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,aAAa;MAAc;MACnD,OAAO;OAAE,MAAM;OAAU,aAAa;MAAe;KACvD;IACF;GACF;GACA,QAAQ;IACN,MAAM;IACN,eAAe;IACf,aACE;GACJ;GACA,OAAO;IACL,MAAM;IACN,aAAa;IACb,YAAY,EACV,WAAW;KACT,MAAM;KACN,UAAU,CAAC,MAAM;KACjB,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,aAAa;MAAkB;MACvD,cAAc;OAAE,MAAM;OAAU,aAAa;MAAmC;KAClF;IACF,EACF;GACF;GACA,KAAK;IAAE,MAAM;IAAU,aAAa;GAAuC;GAC3E,UAAU;IAAE,MAAM;IAAW,aAAa;IAAwC,SAAS;GAAM;EACnG;CACF;CACA,mBAAkB,WAAU,IAAI,eAAe,MAAM;AACvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mesa",
3
- "version": "0.3.2",
3
+ "version": "0.3.3-alpha.0",
4
4
  "description": "Mesa filesystem provider for Mastra workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,17 +23,17 @@
23
23
  "@mesadev/sdk": "0.49.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "22.20.1",
27
- "tsdown": "0.22.9",
26
+ "@types/node": "22.19.15",
27
+ "tsdown": "0.23.1",
28
28
  "typescript": "^7.0.2",
29
- "vitest": "4.1.11",
30
- "@internal/workspace-test-utils": "0.0.89",
29
+ "vitest": "4.1.12",
31
30
  "@internal/lint": "0.0.145",
32
- "@mastra/core": "1.79.0",
33
- "@internal/types-builder": "0.0.120"
31
+ "@internal/types-builder": "0.0.120",
32
+ "@internal/workspace-test-utils": "0.0.89",
33
+ "@mastra/core": "1.80.0-alpha.4"
34
34
  },
35
35
  "peerDependencies": {
36
- "@mastra/core": ">=1.4.0-0 <2.0.0-0"
36
+ "@mastra/core": ">=1.80.0-0 <2.0.0-0"
37
37
  },
38
38
  "files": [
39
39
  "dist"