ArchilFilesystem
Stores files on Archil elastic, serverless disks. Combines an S3-compatible object API for fast reads/writes with exec() for POSIX shell operations and grep() for parallel server-side search.
For interface details, see WorkspaceFilesystem Interface.
InstallationDirect link to Installation
- npm
- pnpm
- Yarn
- Bun
npm install @mastra/archil
pnpm add @mastra/archil
yarn add @mastra/archil
bun add @mastra/archil
UsageDirect link to Usage
Add an ArchilFilesystem to a workspace and assign it to an agent:
import { Agent } from '@mastra/core/agent'
import { Workspace } from '@mastra/core/workspace'
import { ArchilFilesystem } from '@mastra/archil'
const workspace = new Workspace({
filesystem: new ArchilFilesystem({
diskId: 'dsk-0123456789abcdef',
apiKey: process.env.ARCHIL_API_KEY,
region: 'aws-us-east-1',
}),
})
const agent = new Agent({
name: 'file-agent',
model: 'anthropic/claude-opus-4-7',
workspace,
})
Creating a new disk on initDirect link to Creating a new disk on init
If you don't have an existing disk, provide createDiskOptions to create one automatically:
import { ArchilFilesystem } from '@mastra/archil'
const filesystem = new ArchilFilesystem({
apiKey: process.env.ARCHIL_API_KEY,
region: 'aws-us-east-1',
createDiskOptions: {
name: 'my-agent-workspace',
},
})
await filesystem.init()
// filesystem.diskId now contains the newly created disk ID
Environment variable fallbacksDirect link to Environment variable fallbacks
When apiKey and region are omitted, the provider reads from environment variables:
ARCHIL_API_KEY- API keyARCHIL_REGION- Region (e.g.aws-us-east-1)ARCHIL_S3_BASE_URL- Custom S3 endpoint (optional)
import { ArchilFilesystem } from '@mastra/archil'
// Uses ARCHIL_API_KEY and ARCHIL_REGION from environment
const filesystem = new ArchilFilesystem({
diskId: 'dsk-0123456789abcdef',
})
Constructor parametersDirect link to Constructor parameters
diskId?:
createDiskOptions?:
apiKey?:
region?:
baseUrl?:
s3BaseUrl?:
id?:
displayName?:
icon?:
description?:
readOnly?:
PropertiesDirect link to Properties
id:
name:
provider:
diskId:
readOnly:
MethodsDirect link to Methods
ArchilFilesystem implements the WorkspaceFilesystem interface, providing all standard filesystem methods:
readFile(path, options?)- Read file contentswriteFile(path, content, options?)- Write content to a fileappendFile(path, content)- Append content to a filedeleteFile(path, options?)- Delete a filecopyFile(src, dest, options?)- Copy a filemoveFile(src, dest, options?)- Move or rename a filemkdir(path, options?)- Create a directoryrmdir(path, options?)- Remove a directoryreaddir(path, options?)- List directory contentsexists(path)- Check if a path existsstat(path)- Get file or directory metadata
init()Direct link to init
Initialize the filesystem. Connects to the existing disk or creates a new one.
await filesystem.init()
getInfo()Direct link to getinfo
Returns metadata about this filesystem instance.
const info = filesystem.getInfo()
// { id: '...', name: 'ArchilFilesystem', provider: 'archil', status: 'ready' }
Archil-specific methodsDirect link to Archil-specific methods
exec(command)Direct link to execcommand
Run a shell command on the disk. Returns exit code, stdout, and stderr.
const result = await filesystem.exec('ls -la /data')
// { exitCode: 0, stdout: '...', stderr: '' }
grep(options)Direct link to grepoptions
Run a parallel server-side search across files on the disk.
const results = await filesystem.grep({
directory: '/logs',
pattern: 'ERROR',
recursive: true,
glob: '*.log',
})
// { matches: [...], stoppedReason: null }
share(path, options?)Direct link to sharepath-options
Generate a signed URL for sharing a file.
const { url } = await filesystem.share('/reports/output.pdf', {
expiresIn: 3600,
})