@mastra/mesa 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/index.cjs +49 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -50
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -13,13 +13,15 @@ npm install @mastra/mesa
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { Agent } from '@mastra/core/agent';
|
|
15
15
|
import { Workspace } from '@mastra/core/workspace';
|
|
16
|
-
import { MesaFilesystem } from '@mastra/mesa';
|
|
16
|
+
import { MesaFilesystem, repo } from '@mastra/mesa';
|
|
17
17
|
|
|
18
18
|
const workspace = new Workspace({
|
|
19
19
|
filesystem: new MesaFilesystem({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
privateKey: process.env.MESA_PRIVATE_KEY,
|
|
21
|
+
authors: [{ name: 'My Agent', email: 'agent@example.com' }],
|
|
22
|
+
layout: {
|
|
23
|
+
'/docs': repo('docs', { mode: 'rw', at: { bookmark: 'main' } }),
|
|
24
|
+
},
|
|
23
25
|
}),
|
|
24
26
|
});
|
|
25
27
|
|
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,17 @@ function matchesExtension(name, extensions) {
|
|
|
41
41
|
const ext = getExtension(name);
|
|
42
42
|
return extensions.some((candidate) => candidate === ext || candidate === ext.slice(1));
|
|
43
43
|
}
|
|
44
|
+
function toReadOnlyLayout(layout) {
|
|
45
|
+
const toReadOnly = (repo) => {
|
|
46
|
+
if (repo.branchedFrom) throw new Error(`MesaFilesystem readOnly cannot mount repo "${repo.name}" with branchedFrom, which requires mode "rw".`);
|
|
47
|
+
return {
|
|
48
|
+
...repo,
|
|
49
|
+
mode: "ro",
|
|
50
|
+
...repo.subPaths && { subPaths: toReadOnlyLayout(repo.subPaths) }
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
return Object.fromEntries(Object.entries(layout).map(([key, entry]) => [key, Array.isArray(entry) ? entry.map(toReadOnly) : toReadOnly(entry)]));
|
|
54
|
+
}
|
|
44
55
|
function toMesaContent(content) {
|
|
45
56
|
if (typeof content === "string") return content;
|
|
46
57
|
if (Buffer.isBuffer(content)) return new Uint8Array(content);
|
|
@@ -99,9 +110,9 @@ var MesaFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
|
|
|
99
110
|
displayName = "Mesa";
|
|
100
111
|
description = "Versioned Mesa filesystem for workspace files";
|
|
101
112
|
status = "pending";
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
_privateKey;
|
|
114
|
+
_authors;
|
|
115
|
+
_layout;
|
|
105
116
|
_cache;
|
|
106
117
|
_ttl;
|
|
107
118
|
_telemetry;
|
|
@@ -116,9 +127,9 @@ var MesaFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
|
|
|
116
127
|
});
|
|
117
128
|
this.id = generateId();
|
|
118
129
|
this.readOnly = options.readOnly;
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
130
|
+
this._privateKey = options.privateKey;
|
|
131
|
+
this._authors = options.authors;
|
|
132
|
+
this._layout = options.layout;
|
|
122
133
|
this._cache = options.cache;
|
|
123
134
|
this._ttl = options.ttl;
|
|
124
135
|
this._telemetry = options.telemetry;
|
|
@@ -140,21 +151,19 @@ var MesaFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
|
|
|
140
151
|
return this._filesystem;
|
|
141
152
|
}
|
|
142
153
|
async init() {
|
|
143
|
-
if (
|
|
154
|
+
if (Object.keys(this._layout).length === 0) throw new Error("MesaFilesystem requires a layout with at least one path.");
|
|
144
155
|
this._mesa = new _mesadev_sdk.Mesa({
|
|
145
|
-
|
|
146
|
-
org: this._org,
|
|
156
|
+
privateKey: this._privateKey,
|
|
147
157
|
fetch: this._fetch,
|
|
148
158
|
userAgent: this._userAgent
|
|
149
159
|
});
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
})) : this._repos;
|
|
154
|
-
this._filesystem = await this._mesa.fs.mount({
|
|
155
|
-
repos,
|
|
156
|
-
cache: this._cache,
|
|
160
|
+
const layout = this.readOnly ? toReadOnlyLayout(this._layout) : this._layout;
|
|
161
|
+
this._filesystem = await this._mesa.fs({
|
|
162
|
+
layout,
|
|
157
163
|
ttl: this._ttl,
|
|
164
|
+
authors: this._authors
|
|
165
|
+
}).mount({
|
|
166
|
+
cache: this._cache,
|
|
158
167
|
telemetry: this._telemetry
|
|
159
168
|
});
|
|
160
169
|
}
|
|
@@ -168,22 +177,15 @@ var MesaFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
|
|
|
168
177
|
readOnly: this.readOnly,
|
|
169
178
|
icon: this.icon,
|
|
170
179
|
metadata: {
|
|
171
|
-
|
|
172
|
-
...this._repos && { repos: this._repos.map((repo) => repo.name) },
|
|
180
|
+
paths: Object.keys(this._layout),
|
|
173
181
|
mode: "client"
|
|
174
182
|
}
|
|
175
183
|
};
|
|
176
184
|
}
|
|
177
185
|
getInstructions() {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (this._repos && this._repos.length > 0) {
|
|
182
|
-
const repoNames = this._repos.map((repo) => `"${repo.name}"`).join(", ");
|
|
183
|
-
const firstRepo = this._repos[0]?.name ?? "repo";
|
|
184
|
-
const orgSegment = this._org ?? "org";
|
|
185
|
-
parts.push(`Mounted repos: ${repoNames}. For example "/${orgSegment}/${firstRepo}/file.txt".`);
|
|
186
|
-
}
|
|
186
|
+
const paths = Object.keys(this._layout);
|
|
187
|
+
const parts = ["Mesa filesystem. Paths are rooted at the Mesa mount layout."];
|
|
188
|
+
if (paths.length > 0) parts.push(`Mounted paths: ${paths.map((p) => `"${p}"`).join(", ")}. For example "${paths[0]}/file.txt".`);
|
|
187
189
|
parts.push("Files are versioned by Mesa.");
|
|
188
190
|
if (this.readOnly) parts.push("Mounted read-only.");
|
|
189
191
|
return parts.join(" ");
|
|
@@ -476,19 +478,15 @@ const mesaFilesystemProvider = {
|
|
|
476
478
|
description: "Versioned Mesa filesystem for workspace files",
|
|
477
479
|
configSchema: {
|
|
478
480
|
type: "object",
|
|
479
|
-
required: ["
|
|
481
|
+
required: ["authors", "layout"],
|
|
480
482
|
properties: {
|
|
481
|
-
|
|
483
|
+
privateKey: {
|
|
482
484
|
type: "string",
|
|
483
|
-
description: "Mesa
|
|
485
|
+
description: "Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted."
|
|
484
486
|
},
|
|
485
|
-
|
|
486
|
-
type: "string",
|
|
487
|
-
description: "Mesa org slug"
|
|
488
|
-
},
|
|
489
|
-
repos: {
|
|
487
|
+
authors: {
|
|
490
488
|
type: "array",
|
|
491
|
-
description: "
|
|
489
|
+
description: "Commit authors attributed to writes",
|
|
492
490
|
minItems: 1,
|
|
493
491
|
items: {
|
|
494
492
|
type: "object",
|
|
@@ -496,23 +494,20 @@ const mesaFilesystemProvider = {
|
|
|
496
494
|
properties: {
|
|
497
495
|
name: {
|
|
498
496
|
type: "string",
|
|
499
|
-
description: "
|
|
500
|
-
},
|
|
501
|
-
bookmark: {
|
|
502
|
-
type: "string",
|
|
503
|
-
description: "Bookmark to mount"
|
|
497
|
+
description: "Author name"
|
|
504
498
|
},
|
|
505
|
-
|
|
499
|
+
email: {
|
|
506
500
|
type: "string",
|
|
507
|
-
description: "
|
|
508
|
-
},
|
|
509
|
-
readOnly: {
|
|
510
|
-
type: "boolean",
|
|
511
|
-
description: "Mount this repo as read-only"
|
|
501
|
+
description: "Author email"
|
|
512
502
|
}
|
|
513
503
|
}
|
|
514
504
|
}
|
|
515
505
|
},
|
|
506
|
+
layout: {
|
|
507
|
+
type: "object",
|
|
508
|
+
minProperties: 1,
|
|
509
|
+
description: "Mesa mount layout mapping absolute paths to repo declarations, e.g. { \"/docs\": { \"kind\": \"repo\", \"name\": \"docs\", \"mode\": \"rw\" } }"
|
|
510
|
+
},
|
|
516
511
|
cache: {
|
|
517
512
|
type: "object",
|
|
518
513
|
description: "Mesa filesystem cache configuration",
|
|
@@ -537,7 +532,7 @@ const mesaFilesystemProvider = {
|
|
|
537
532
|
},
|
|
538
533
|
readOnly: {
|
|
539
534
|
type: "boolean",
|
|
540
|
-
description: "Mount
|
|
535
|
+
description: "Mount every layout repo as read-only",
|
|
541
536
|
default: false
|
|
542
537
|
}
|
|
543
538
|
}
|
|
@@ -547,5 +542,11 @@ const mesaFilesystemProvider = {
|
|
|
547
542
|
//#endregion
|
|
548
543
|
exports.MesaFilesystem = MesaFilesystem;
|
|
549
544
|
exports.mesaFilesystemProvider = mesaFilesystemProvider;
|
|
545
|
+
Object.defineProperty(exports, "repo", {
|
|
546
|
+
enumerable: true,
|
|
547
|
+
get: function() {
|
|
548
|
+
return _mesadev_sdk.repo;
|
|
549
|
+
}
|
|
550
|
+
});
|
|
550
551
|
|
|
551
552
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -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 { Bash, MesaBashOptions, MesaFileSystem, MesaOptions, RepoConfig, TelemetryConfig } 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 API key. Falls back to MESA_API_KEY when omitted. */\n apiKey?: string;\n /** Block all write operations through the Mastra filesystem interface. */\n readOnly?: boolean;\n /** Mesa org slug. Falls back to Mesa SDK org inference when omitted. */\n org?: string;\n /** Mesa repos to mount. */\n repos: RepoConfig[];\n /** Mesa filesystem cache configuration. */\n cache?: {\n diskCache?: {\n path: string;\n maxSizeBytes?: number;\n };\n };\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 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 _apiKey?: string;\n private readonly _org?: string;\n private readonly _repos?: RepoConfig[];\n private readonly _cache?: {\n diskCache?: {\n path: string;\n maxSizeBytes?: number;\n };\n };\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._org = options.org;\n this._repos = options.repos;\n this._apiKey = options.apiKey;\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 (!this._repos || this._repos.length === 0) {\n throw new Error('MesaFilesystem requires at least one repo.');\n }\n\n this._mesa = new Mesa({\n apiKey: this._apiKey,\n org: this._org,\n fetch: this._fetch,\n userAgent: this._userAgent,\n });\n\n const repos = this.readOnly ? this._repos.map(repo => ({ ...repo, readOnly: true })) : this._repos;\n this._filesystem = await this._mesa.fs.mount({\n repos,\n cache: this._cache,\n ttl: this._ttl,\n telemetry: this._telemetry,\n });\n }\n\n getInfo(): FilesystemInfo<{\n org?: string;\n repos?: 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 ...(this._org && { org: this._org }),\n ...(this._repos && { repos: this._repos.map(repo => repo.name) }),\n mode: 'client',\n },\n };\n }\n\n getInstructions(): string {\n const parts = ['Mesa filesystem. Paths are rooted at the Mesa mount. Include the org and repo name in paths.'];\n\n if (this._org) {\n parts.push(`Org: \"${this._org}\".`);\n } else {\n parts.push('Use the Mesa org resolved by the SDK as the first path segment.');\n }\n\n if (this._repos && this._repos.length > 0) {\n const repoNames = this._repos.map(repo => `\"${repo.name}\"`).join(', ');\n const firstRepo = this._repos[0]?.name ?? 'repo';\n const orgSegment = this._org ?? 'org';\n parts.push(`Mounted repos: ${repoNames}. For example \"/${orgSegment}/${firstRepo}/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: ['repos'],\n properties: {\n apiKey: { type: 'string', description: 'Mesa API key. Falls back to MESA_API_KEY when omitted.' },\n org: { type: 'string', description: 'Mesa org slug' },\n repos: {\n type: 'array',\n description: 'Mesa repos to mount',\n minItems: 1,\n items: {\n type: 'object',\n required: ['name'],\n properties: {\n name: { type: 'string', description: 'Mesa repo name' },\n bookmark: { type: 'string', description: 'Bookmark to mount' },\n changeId: { type: 'string', description: 'Change ID to mount' },\n readOnly: { type: 'boolean', description: 'Mount this repo as read-only' },\n },\n },\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 all repos as read-only', default: false },\n },\n },\n createFilesystem: config => new MesaFilesystem(config),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,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,cAAc,SAA2C;CAChE,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,IAAI,OAAO,SAAS,OAAO,GAAG,OAAO,IAAI,WAAW,OAAO;CAC3D,OA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;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,UAAU,CAAC,OAAO;EAClB,YAAY;GACV,QAAQ;IAAE,MAAM;IAAU,aAAa;GAAyD;GAChG,KAAK;IAAE,MAAM;IAAU,aAAa;GAAgB;GACpD,OAAO;IACL,MAAM;IACN,aAAa;IACb,UAAU;IACV,OAAO;KACL,MAAM;KACN,UAAU,CAAC,MAAM;KACjB,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,aAAa;MAAiB;MACtD,UAAU;OAAE,MAAM;OAAU,aAAa;MAAoB;MAC7D,UAAU;OAAE,MAAM;OAAU,aAAa;MAAqB;MAC9D,UAAU;OAAE,MAAM;OAAW,aAAa;MAA+B;KAC3E;IACF;GACF;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;IAAgC,SAAS;GAAM;EAC3F;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"],"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;CAC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D"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path/posix";
|
|
2
2
|
import { DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, NotDirectoryError, StaleFileError, WorkspaceReadOnlyError } from "@mastra/core/workspace";
|
|
3
|
-
import { Mesa } from "@mesadev/sdk";
|
|
3
|
+
import { Mesa, repo } from "@mesadev/sdk";
|
|
4
4
|
//#region src/filesystem/index.ts
|
|
5
5
|
function generateId() {
|
|
6
6
|
return `mesa-fs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -17,6 +17,17 @@ function matchesExtension(name, extensions) {
|
|
|
17
17
|
const ext = getExtension(name);
|
|
18
18
|
return extensions.some((candidate) => candidate === ext || candidate === ext.slice(1));
|
|
19
19
|
}
|
|
20
|
+
function toReadOnlyLayout(layout) {
|
|
21
|
+
const toReadOnly = (repo) => {
|
|
22
|
+
if (repo.branchedFrom) throw new Error(`MesaFilesystem readOnly cannot mount repo "${repo.name}" with branchedFrom, which requires mode "rw".`);
|
|
23
|
+
return {
|
|
24
|
+
...repo,
|
|
25
|
+
mode: "ro",
|
|
26
|
+
...repo.subPaths && { subPaths: toReadOnlyLayout(repo.subPaths) }
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
return Object.fromEntries(Object.entries(layout).map(([key, entry]) => [key, Array.isArray(entry) ? entry.map(toReadOnly) : toReadOnly(entry)]));
|
|
30
|
+
}
|
|
20
31
|
function toMesaContent(content) {
|
|
21
32
|
if (typeof content === "string") return content;
|
|
22
33
|
if (Buffer.isBuffer(content)) return new Uint8Array(content);
|
|
@@ -75,9 +86,9 @@ var MesaFilesystem = class extends MastraFilesystem {
|
|
|
75
86
|
displayName = "Mesa";
|
|
76
87
|
description = "Versioned Mesa filesystem for workspace files";
|
|
77
88
|
status = "pending";
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
_privateKey;
|
|
90
|
+
_authors;
|
|
91
|
+
_layout;
|
|
81
92
|
_cache;
|
|
82
93
|
_ttl;
|
|
83
94
|
_telemetry;
|
|
@@ -92,9 +103,9 @@ var MesaFilesystem = class extends MastraFilesystem {
|
|
|
92
103
|
});
|
|
93
104
|
this.id = generateId();
|
|
94
105
|
this.readOnly = options.readOnly;
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
106
|
+
this._privateKey = options.privateKey;
|
|
107
|
+
this._authors = options.authors;
|
|
108
|
+
this._layout = options.layout;
|
|
98
109
|
this._cache = options.cache;
|
|
99
110
|
this._ttl = options.ttl;
|
|
100
111
|
this._telemetry = options.telemetry;
|
|
@@ -116,21 +127,19 @@ var MesaFilesystem = class extends MastraFilesystem {
|
|
|
116
127
|
return this._filesystem;
|
|
117
128
|
}
|
|
118
129
|
async init() {
|
|
119
|
-
if (
|
|
130
|
+
if (Object.keys(this._layout).length === 0) throw new Error("MesaFilesystem requires a layout with at least one path.");
|
|
120
131
|
this._mesa = new Mesa({
|
|
121
|
-
|
|
122
|
-
org: this._org,
|
|
132
|
+
privateKey: this._privateKey,
|
|
123
133
|
fetch: this._fetch,
|
|
124
134
|
userAgent: this._userAgent
|
|
125
135
|
});
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
})) : this._repos;
|
|
130
|
-
this._filesystem = await this._mesa.fs.mount({
|
|
131
|
-
repos,
|
|
132
|
-
cache: this._cache,
|
|
136
|
+
const layout = this.readOnly ? toReadOnlyLayout(this._layout) : this._layout;
|
|
137
|
+
this._filesystem = await this._mesa.fs({
|
|
138
|
+
layout,
|
|
133
139
|
ttl: this._ttl,
|
|
140
|
+
authors: this._authors
|
|
141
|
+
}).mount({
|
|
142
|
+
cache: this._cache,
|
|
134
143
|
telemetry: this._telemetry
|
|
135
144
|
});
|
|
136
145
|
}
|
|
@@ -144,22 +153,15 @@ var MesaFilesystem = class extends MastraFilesystem {
|
|
|
144
153
|
readOnly: this.readOnly,
|
|
145
154
|
icon: this.icon,
|
|
146
155
|
metadata: {
|
|
147
|
-
|
|
148
|
-
...this._repos && { repos: this._repos.map((repo) => repo.name) },
|
|
156
|
+
paths: Object.keys(this._layout),
|
|
149
157
|
mode: "client"
|
|
150
158
|
}
|
|
151
159
|
};
|
|
152
160
|
}
|
|
153
161
|
getInstructions() {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (this._repos && this._repos.length > 0) {
|
|
158
|
-
const repoNames = this._repos.map((repo) => `"${repo.name}"`).join(", ");
|
|
159
|
-
const firstRepo = this._repos[0]?.name ?? "repo";
|
|
160
|
-
const orgSegment = this._org ?? "org";
|
|
161
|
-
parts.push(`Mounted repos: ${repoNames}. For example "/${orgSegment}/${firstRepo}/file.txt".`);
|
|
162
|
-
}
|
|
162
|
+
const paths = Object.keys(this._layout);
|
|
163
|
+
const parts = ["Mesa filesystem. Paths are rooted at the Mesa mount layout."];
|
|
164
|
+
if (paths.length > 0) parts.push(`Mounted paths: ${paths.map((p) => `"${p}"`).join(", ")}. For example "${paths[0]}/file.txt".`);
|
|
163
165
|
parts.push("Files are versioned by Mesa.");
|
|
164
166
|
if (this.readOnly) parts.push("Mounted read-only.");
|
|
165
167
|
return parts.join(" ");
|
|
@@ -452,19 +454,15 @@ const mesaFilesystemProvider = {
|
|
|
452
454
|
description: "Versioned Mesa filesystem for workspace files",
|
|
453
455
|
configSchema: {
|
|
454
456
|
type: "object",
|
|
455
|
-
required: ["
|
|
457
|
+
required: ["authors", "layout"],
|
|
456
458
|
properties: {
|
|
457
|
-
|
|
459
|
+
privateKey: {
|
|
458
460
|
type: "string",
|
|
459
|
-
description: "Mesa
|
|
461
|
+
description: "Mesa private key. Falls back to MESA_PRIVATE_KEY when omitted."
|
|
460
462
|
},
|
|
461
|
-
|
|
462
|
-
type: "string",
|
|
463
|
-
description: "Mesa org slug"
|
|
464
|
-
},
|
|
465
|
-
repos: {
|
|
463
|
+
authors: {
|
|
466
464
|
type: "array",
|
|
467
|
-
description: "
|
|
465
|
+
description: "Commit authors attributed to writes",
|
|
468
466
|
minItems: 1,
|
|
469
467
|
items: {
|
|
470
468
|
type: "object",
|
|
@@ -472,23 +470,20 @@ const mesaFilesystemProvider = {
|
|
|
472
470
|
properties: {
|
|
473
471
|
name: {
|
|
474
472
|
type: "string",
|
|
475
|
-
description: "
|
|
476
|
-
},
|
|
477
|
-
bookmark: {
|
|
478
|
-
type: "string",
|
|
479
|
-
description: "Bookmark to mount"
|
|
473
|
+
description: "Author name"
|
|
480
474
|
},
|
|
481
|
-
|
|
475
|
+
email: {
|
|
482
476
|
type: "string",
|
|
483
|
-
description: "
|
|
484
|
-
},
|
|
485
|
-
readOnly: {
|
|
486
|
-
type: "boolean",
|
|
487
|
-
description: "Mount this repo as read-only"
|
|
477
|
+
description: "Author email"
|
|
488
478
|
}
|
|
489
479
|
}
|
|
490
480
|
}
|
|
491
481
|
},
|
|
482
|
+
layout: {
|
|
483
|
+
type: "object",
|
|
484
|
+
minProperties: 1,
|
|
485
|
+
description: "Mesa mount layout mapping absolute paths to repo declarations, e.g. { \"/docs\": { \"kind\": \"repo\", \"name\": \"docs\", \"mode\": \"rw\" } }"
|
|
486
|
+
},
|
|
492
487
|
cache: {
|
|
493
488
|
type: "object",
|
|
494
489
|
description: "Mesa filesystem cache configuration",
|
|
@@ -513,7 +508,7 @@ const mesaFilesystemProvider = {
|
|
|
513
508
|
},
|
|
514
509
|
readOnly: {
|
|
515
510
|
type: "boolean",
|
|
516
|
-
description: "Mount
|
|
511
|
+
description: "Mount every layout repo as read-only",
|
|
517
512
|
default: false
|
|
518
513
|
}
|
|
519
514
|
}
|
|
@@ -521,6 +516,6 @@ const mesaFilesystemProvider = {
|
|
|
521
516
|
createFilesystem: (config) => new MesaFilesystem(config)
|
|
522
517
|
};
|
|
523
518
|
//#endregion
|
|
524
|
-
export { MesaFilesystem, mesaFilesystemProvider };
|
|
519
|
+
export { MesaFilesystem, mesaFilesystemProvider, repo };
|
|
525
520
|
|
|
526
521
|
//# 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 { Bash, MesaBashOptions, MesaFileSystem, MesaOptions, RepoConfig, TelemetryConfig } 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 API key. Falls back to MESA_API_KEY when omitted. */\n apiKey?: string;\n /** Block all write operations through the Mastra filesystem interface. */\n readOnly?: boolean;\n /** Mesa org slug. Falls back to Mesa SDK org inference when omitted. */\n org?: string;\n /** Mesa repos to mount. */\n repos: RepoConfig[];\n /** Mesa filesystem cache configuration. */\n cache?: {\n diskCache?: {\n path: string;\n maxSizeBytes?: number;\n };\n };\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 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 _apiKey?: string;\n private readonly _org?: string;\n private readonly _repos?: RepoConfig[];\n private readonly _cache?: {\n diskCache?: {\n path: string;\n maxSizeBytes?: number;\n };\n };\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._org = options.org;\n this._repos = options.repos;\n this._apiKey = options.apiKey;\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 (!this._repos || this._repos.length === 0) {\n throw new Error('MesaFilesystem requires at least one repo.');\n }\n\n this._mesa = new Mesa({\n apiKey: this._apiKey,\n org: this._org,\n fetch: this._fetch,\n userAgent: this._userAgent,\n });\n\n const repos = this.readOnly ? this._repos.map(repo => ({ ...repo, readOnly: true })) : this._repos;\n this._filesystem = await this._mesa.fs.mount({\n repos,\n cache: this._cache,\n ttl: this._ttl,\n telemetry: this._telemetry,\n });\n }\n\n getInfo(): FilesystemInfo<{\n org?: string;\n repos?: 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 ...(this._org && { org: this._org }),\n ...(this._repos && { repos: this._repos.map(repo => repo.name) }),\n mode: 'client',\n },\n };\n }\n\n getInstructions(): string {\n const parts = ['Mesa filesystem. Paths are rooted at the Mesa mount. Include the org and repo name in paths.'];\n\n if (this._org) {\n parts.push(`Org: \"${this._org}\".`);\n } else {\n parts.push('Use the Mesa org resolved by the SDK as the first path segment.');\n }\n\n if (this._repos && this._repos.length > 0) {\n const repoNames = this._repos.map(repo => `\"${repo.name}\"`).join(', ');\n const firstRepo = this._repos[0]?.name ?? 'repo';\n const orgSegment = this._org ?? 'org';\n parts.push(`Mounted repos: ${repoNames}. For example \"/${orgSegment}/${firstRepo}/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: ['repos'],\n properties: {\n apiKey: { type: 'string', description: 'Mesa API key. Falls back to MESA_API_KEY when omitted.' },\n org: { type: 'string', description: 'Mesa org slug' },\n repos: {\n type: 'array',\n description: 'Mesa repos to mount',\n minItems: 1,\n items: {\n type: 'object',\n required: ['name'],\n properties: {\n name: { type: 'string', description: 'Mesa repo name' },\n bookmark: { type: 'string', description: 'Bookmark to mount' },\n changeId: { type: 'string', description: 'Change ID to mount' },\n readOnly: { type: 'boolean', description: 'Mount this repo as read-only' },\n },\n },\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 all repos as read-only', default: false },\n },\n },\n createFilesystem: config => new MesaFilesystem(config),\n};\n"],"mappings":";;;;AA0DA,SAAS,aAAqB;CAC5B,OAAO,WAAW,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAA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AAW,MAAM;GACjB,YAAY,MAAM;EACpB;CACF;AACF;;;ACxmBA,MAAa,yBAAoE;CAC/E,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,UAAU,CAAC,OAAO;EAClB,YAAY;GACV,QAAQ;IAAE,MAAM;IAAU,aAAa;GAAyD;GAChG,KAAK;IAAE,MAAM;IAAU,aAAa;GAAgB;GACpD,OAAO;IACL,MAAM;IACN,aAAa;IACb,UAAU;IACV,OAAO;KACL,MAAM;KACN,UAAU,CAAC,MAAM;KACjB,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,aAAa;MAAiB;MACtD,UAAU;OAAE,MAAM;OAAU,aAAa;MAAoB;MAC7D,UAAU;OAAE,MAAM;OAAU,aAAa;MAAqB;MAC9D,UAAU;OAAE,MAAM;OAAW,aAAa;MAA+B;KAC3E;IACF;GACF;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;IAAgC,SAAS;GAAM;EAC3F;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 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,OAAO,KAAK,UAAU,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,WAAW;AAC/E;AAEA,SAAS,aAAa,MAAsB;CAC1C,MAAM,MAAM,KAAK,YAAY,GAAG;CAChC,OAAO,QAAQ,KAAK,KA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N,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
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Mesa filesystem provider for Mastra workspaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@mesadev/sdk": "0.
|
|
23
|
+
"@mesadev/sdk": "0.49.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "22.20.1",
|
|
27
27
|
"eslint": "^10.7.0",
|
|
28
28
|
"tsdown": "0.22.9",
|
|
29
29
|
"typescript": "^7.0.2",
|
|
30
|
-
"vitest": "4.1.
|
|
31
|
-
"@internal/lint": "0.0.
|
|
32
|
-
"@
|
|
33
|
-
"@internal/types-builder": "0.0.
|
|
34
|
-
"@
|
|
30
|
+
"vitest": "4.1.11",
|
|
31
|
+
"@internal/lint": "0.0.141",
|
|
32
|
+
"@internal/workspace-test-utils": "0.0.85",
|
|
33
|
+
"@internal/types-builder": "0.0.116",
|
|
34
|
+
"@mastra/core": "1.75.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@mastra/core": ">=1.4.0-0 <2.0.0-0"
|