Class: MastraFileSystemAdapter
Thin Mastra MastraFilesystem adapter over a @dbx-tools/shared-fs
FileSystem. Identity fields are getters that read the source on
access; construction does not snapshot them.
Extends
Section titled “Extends”MastraFilesystem
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MastraFileSystemAdapter(
fs,options?):MastraFileSystemAdapter
Parameters
Section titled “Parameters”FileSystem
options?
Section titled “options?”MastraFileSystemAdapterOptions = {}
Returns
Section titled “Returns”MastraFileSystemAdapter
Overrides
Section titled “Overrides”MastraFilesystem.constructor
Properties
Section titled “Properties”component
Section titled “component”component:
RegisteredLogger
Inherited from
Section titled “Inherited from”MastraFilesystem.component
error?
Section titled “error?”
optionalerror?:string
Error message when status is ‘error’
Inherited from
Section titled “Inherited from”MastraFilesystem.error
logger
Section titled “logger”
protectedlogger:IMastraLogger
Inherited from
Section titled “Inherited from”MastraFilesystem.logger
status
Section titled “status”status:
ProviderStatus="pending"
Current status of the filesystem
Overrides
Section titled “Overrides”MastraFilesystem.status
Accessors
Section titled “Accessors”basePath
Section titled “basePath”Get Signature
Section titled “Get Signature”get basePath():
string
Returns
Section titled “Returns”string
Get Signature
Section titled “Get Signature”get id():
string
Unique identifier for this filesystem instance
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”MastraFilesystem.id
Get Signature
Section titled “Get Signature”get name():
string
Human-readable name (e.g., ‘LocalFilesystem’, ‘AgentFS’)
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”MastraFilesystem.name
provider
Section titled “provider”Get Signature
Section titled “Get Signature”get provider():
string
Provider type identifier
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”MastraFilesystem.provider
readOnly
Section titled “readOnly”Get Signature
Section titled “Get Signature”get readOnly():
boolean
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”__setLogger()
Section titled “__setLogger()”__setLogger(
logger):void
Set the logger for the agent
Parameters
Section titled “Parameters”logger
Section titled “logger”IMastraLogger
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”MastraFilesystem.__setLogger
__setRawConfig()
Section titled “__setRawConfig()”__setRawConfig(
rawConfig):void
Internal
Sets the raw storage configuration for this primitive.
Parameters
Section titled “Parameters”rawConfig
Section titled “rawConfig”Record<string, unknown>
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”MastraFilesystem.__setRawConfig
_destroy()
Section titled “_destroy()”_destroy():
Promise<void>
Destroy the filesystem and clean up all resources (wrapper with status management).
This method is race-condition-safe - concurrent calls will return the same promise. Handles status management.
Subclasses override destroy() to provide their destroy logic.
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MastraFilesystem._destroy
_init()
Section titled “_init()”_init():
Promise<void>
Initialize the filesystem (wrapper with status management and race-condition safety).
This method is race-condition-safe - concurrent calls will return the same promise. Handles status management automatically.
Subclasses override init() to provide their initialization logic.
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”MastraFilesystem._init
appendFile()
Section titled “appendFile()”appendFile(
inputPath,content):Promise<void>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
content
Section titled “content”FileContent
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MastraFilesystem.appendFile
copyFile()
Section titled “copyFile()”copyFile(
src,dest,options?):Promise<void>
Parameters
Section titled “Parameters”string
string
options?
Section titled “options?”CopyOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MastraFilesystem.copyFile
deleteFile()
Section titled “deleteFile()”deleteFile(
inputPath,options?):Promise<void>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
options?
Section titled “options?”RemoveOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MastraFilesystem.deleteFile
destroy()
Section titled “destroy()”destroy():
Promise<void>
Override this method to implement filesystem destroy logic.
Called by _destroy() after status is set to ‘destroying’.
Status will be set to ‘destroyed’ on success, ‘error’ on failure.
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MastraFilesystem.destroy
ensureReady()
Section titled “ensureReady()”
protectedensureReady():Promise<void>
Ensure the filesystem is ready.
Calls _init() if status is not ‘ready’. Useful for lazy initialization
where operations should automatically initialize the filesystem if needed.
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”if the filesystem fails to reach ‘ready’ status
Example
Section titled “Example”async readFile(path: string): Promise<string | Buffer> { await this.ensureReady(); // Now safe to use the filesystem}Inherited from
Section titled “Inherited from”MastraFilesystem.ensureReady
exists()
Section titled “exists()”exists(
inputPath):Promise<boolean>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
Returns
Section titled “Returns”Promise<boolean>
Overrides
Section titled “Overrides”MastraFilesystem.exists
getInfo()
Section titled “getInfo()”getInfo():
FilesystemInfo<{backend:string;root:string; }>
Returns
Section titled “Returns”FilesystemInfo<{ backend: string; root: string; }>
getInstructions()
Section titled “getInstructions()”getInstructions():
string
Returns
Section titled “Returns”string
init()
Section titled “init()”init():
Promise<void>
Override this method to implement filesystem initialization logic.
Called by _init() after status is set to ‘initializing’.
Status will be set to ‘ready’ on success, ‘error’ on failure.
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”async init(): Promise<void> { this._client = new StorageClient({ ... }); await this._client.connect();}Overrides
Section titled “Overrides”MastraFilesystem.init
mkdir()
Section titled “mkdir()”mkdir(
inputPath,options?):Promise<void>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
options?
Section titled “options?”recursive?
Section titled “recursive?”boolean
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MastraFilesystem.mkdir
moveFile()
Section titled “moveFile()”moveFile(
src,dest,options?):Promise<void>
Parameters
Section titled “Parameters”string
string
options?
Section titled “options?”CopyOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MastraFilesystem.moveFile
readdir()
Section titled “readdir()”readdir(
inputPath,options?):Promise<FileEntry[]>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
options?
Section titled “options?”ListOptions
Returns
Section titled “Returns”Promise<FileEntry[]>
Overrides
Section titled “Overrides”MastraFilesystem.readdir
readFile()
Section titled “readFile()”readFile(
inputPath,options?):Promise<string|Buffer<ArrayBufferLike>>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
options?
Section titled “options?”ReadOptions
Returns
Section titled “Returns”Promise<string | Buffer<ArrayBufferLike>>
Overrides
Section titled “Overrides”MastraFilesystem.readFile
rmdir()
Section titled “rmdir()”rmdir(
inputPath,options?):Promise<void>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
options?
Section titled “options?”RemoveOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MastraFilesystem.rmdir
stat()
Section titled “stat()”stat(
inputPath):Promise<FileStat>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
Returns
Section titled “Returns”Promise<FileStat>
Overrides
Section titled “Overrides”MastraFilesystem.stat
toRawConfig()
Section titled “toRawConfig()”toRawConfig():
Record<string,unknown> |undefined
Returns the raw storage configuration this primitive was created from, or undefined if it was created from code.
Returns
Section titled “Returns”Record<string, unknown> | undefined
Inherited from
Section titled “Inherited from”MastraFilesystem.toRawConfig
writeFile()
Section titled “writeFile()”writeFile(
inputPath,content,options?):Promise<void>
Parameters
Section titled “Parameters”inputPath
Section titled “inputPath”string
content
Section titled “content”FileContent
options?
Section titled “options?”WriteOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”MastraFilesystem.writeFile