Skip to content

Class: MountedCompositeFilesystem

Composite mount namespace whose virtual root has no repository-level .gitignore. Mastra’s list tool probes that relative file before walking; an empty result keeps native ignore handling enabled without routing the virtual-root lookup into an unrelated mount.

  • CompositeFilesystem

new MountedCompositeFilesystem(config): MountedCompositeFilesystem

CompositeFilesystemConfig

MountedCompositeFilesystem

CompositeFilesystem.constructor

readonly id: string

Unique identifier for this filesystem instance

CompositeFilesystem.id


readonly name: "CompositeFilesystem" = "CompositeFilesystem"

Human-readable name (e.g., ‘LocalFilesystem’, ‘AgentFS’)

CompositeFilesystem.name


readonly provider: "composite" = "composite"

Provider type identifier

CompositeFilesystem.provider


readonly optional readOnly?: boolean

When true, all write operations to this filesystem are blocked. Read operations are still allowed.

false

CompositeFilesystem.readOnly


status: ProviderStatus

Current status

CompositeFilesystem.status

get mountPaths(): string[]

Get all mount paths.

string[]

CompositeFilesystem.mountPaths


get mounts(): ReadonlyMountMap<TMounts>

Get the mounts map. Returns a typed map where get() preserves the concrete filesystem type per mount path.

ReadonlyMountMap<TMounts>

CompositeFilesystem.mounts

appendFile(path, content): Promise<void>

Append content to a file. Creates the file if it doesn’t exist.

string

FileContent

Promise<void>

CompositeFilesystem.appendFile


copyFile(src, dest, options?): Promise<void>

Copy a file to a new location.

string

string

CopyOptions

Promise<void>

if source doesn’t exist

if destination exists and overwrite is false

CompositeFilesystem.copyFile


deleteFile(path, options?): Promise<void>

Delete a file.

string

RemoveOptions

Promise<void>

if file doesn’t exist and force is false

if path is a directory

CompositeFilesystem.deleteFile


destroy(): Promise<void>

Clean up all resources.

Called when the workspace is being permanently shut down. Use for operations like:

  • Terminating cloud instances
  • Closing all connections
  • Cleaning up temporary files

Promise<void>

CompositeFilesystem.destroy


exists(path): Promise<boolean>

Check if a path exists.

string

Promise<boolean>

CompositeFilesystem.exists


getFilesystemForPath(path): WorkspaceFilesystem | undefined

Get the underlying filesystem for a given path. Returns undefined if the path doesn’t resolve to any mount.

string

WorkspaceFilesystem | undefined

CompositeFilesystem.getFilesystemForPath


getInfo(): Promise<FilesystemInfo<Record<string, unknown>>>

Get status and metadata for this composite filesystem. Includes info from each mounted filesystem in metadata.mounts.

Promise<FilesystemInfo<Record<string, unknown>>>

CompositeFilesystem.getInfo


getInstructions(_opts?): string

Get instructions describing the mounted filesystems. Used by agents to understand available storage locations.

RequestContext<unknown>

string

CompositeFilesystem.getInstructions


getMountPathForPath(path): string | undefined

Get the mount path for a given path. Returns undefined if the path doesn’t resolve to any mount.

string

string | undefined

CompositeFilesystem.getMountPathForPath


init(): Promise<void>

One-time setup operations.

Called once when the workspace is first initialized. Use for operations like:

  • Creating base directories
  • Setting up database tables
  • Provisioning cloud resources
  • Installing dependencies

Promise<void>

CompositeFilesystem.init


isDirectory(path): Promise<boolean>

string

Promise<boolean>

CompositeFilesystem.isDirectory


isFile(path): Promise<boolean>

string

Promise<boolean>

CompositeFilesystem.isFile


mkdir(path, options?): Promise<void>

Create a directory.

string

boolean

Promise<void>

if path already exists as a file

CompositeFilesystem.mkdir


moveFile(src, dest, options?): Promise<void>

Move/rename a file.

string

string

CopyOptions

Promise<void>

if source doesn’t exist

if destination exists and overwrite is false

CompositeFilesystem.moveFile


readdir(path, options?): Promise<FileEntry[]>

List directory contents.

string

ListOptions

Promise<FileEntry[]>

if directory doesn’t exist

if path is a file

CompositeFilesystem.readdir


readFile(inputPath, options?): Promise<string | Buffer<ArrayBufferLike>>

string

ReadOptions

Promise<string | Buffer<ArrayBufferLike>>

CompositeFilesystem.readFile


resolveAbsolutePath(path): string | undefined

Resolve a workspace-relative path to an absolute disk path. Strips the mount prefix and delegates to the underlying filesystem.

string

string | undefined

CompositeFilesystem.resolveAbsolutePath


rmdir(path, options?): Promise<void>

Remove a directory.

string

RemoveOptions

Promise<void>

if directory doesn’t exist and force is false

if directory is not empty and recursive is false

CompositeFilesystem.rmdir


stat(path): Promise<FileStat>

Get file/directory metadata.

string

Promise<FileStat>

if path doesn’t exist

CompositeFilesystem.stat


writeFile(path, content, options?): Promise<void>

Write content to a file. Creates the file if it doesn’t exist.

string

FileContent

WriteOptions

Promise<void>

if parent directory doesn’t exist and recursive is false

if file exists and overwrite is false

CompositeFilesystem.writeFile