SDK ReferenceTypeScript SDK

ToolRouterSessionFilesMount

Markdown

Usage

Access this class through the composio.toolRouterSessionFilesMount property:

const composio = new Composio({ apiKey: 'your-api-key' });
const result = await composio.toolRouterSessionFilesMount.list();

Methods

delete()

Deletes a file or directory at the specified path on the session's file mount.

Removes the file or directory from the virtual filesystem. Use with caution: deletion is typically irreversible. Ensure the path exists and is intended for removal.

async delete(remotePath: string, options?: { mountId?: string }): Promise<{ mountRelativePath: string; sandboxMountPrefix: string }>

Parameters

NameTypeDescription
remotePathstringThe path of the file or directory to delete on the mount.
options?objectOptional configuration for the delete operation.

Returns

Promise<...> — Confirmation of deletion (implementation-specific).

Example

const session = await composio.toolRouter.use('session_123');
await session.experimental.files.delete('/temp/cache.json');
// Delete from a custom mount
await session.experimental.files.delete('/old-backup', {
  mountId: 'custom-mount',
});

download()

Downloads a file from the session's file mount to the local filesystem.

Retrieves a file stored in the session's virtual filesystem (e.g., one produced by a tool or previously uploaded) and saves it to the specified local path.

async download(filePath: string, options?: { mountId?: string }): Promise<RemoteFile>

Parameters

NameTypeDescription
filePathstringThe path of the file on the mount to download, or the local path where the file should be saved (implementation-specific).
options?objectOptional configuration for the download.

Returns

Promise<RemoteFile> — The downloaded file data or path (implementation-specific).

Example

const session = await composio.toolRouter.use('session_123');
const result = await session.experimental.files.download('/output/report.pdf');
// Download from a custom mount
await session.experimental.files.download('/exports/data.json', {
  mountId: 'custom-mount',
});

list()

Lists files and directories at the specified path on the session's file mount.

Use this to browse the virtual filesystem attached to the tool router session. The path is relative to the mount root (e.g., "/" for root, "/documents" for a subdirectory). Supports cursor-based pagination via cursor and limit options.

async list(options?: { cursor?: string; limit?: number; mountId?: string; path?: string }): Promise<...>

Parameters

NameTypeDescription
options?objectOptional configuration for the list operation.

Returns

Promise<...> — List of files with nextCursor for pagination.

Example

const session = await composio.toolRouter.use('session_123');
const { items, nextCursor } = await session.experimental.files.list({ path: '/' });
// Paginated listing
let result = await session.experimental.files.list({ path: '/', limit: 10 });
while (result.nextCursor) {
  result = await session.experimental.files.list({ path: '/', cursor: result.nextCursor, limit: 10 });
}

upload()

Uploads a file to the session's file mount.

Accepts a file path (local or URL), a native File object, or a raw buffer. The file is stored in the virtual filesystem associated with the tool router session.

async upload(input: string | File | ArrayBuffer | Uint8Array, options?: { mimetype?: string; mountId?: string; remotePath?: string }): Promise<RemoteFile>

Parameters

NameTypeDescription
input`stringFile
options?objectOptional configuration. When passing a buffer, remotePath is required.

Returns

Promise<RemoteFile> — Metadata about the uploaded file.

Example

// From file path (local or URL)
await session.experimental.files.upload('/path/to/report.pdf');
await session.experimental.files.upload('https://example.com/file.pdf');
// From native File (e.g. from input[type=file])
await session.experimental.files.upload(fileInput.files[0]);
// From raw buffer
await session.experimental.files.upload(buffer, { remotePath: 'data.json', mimetype: 'application/json' });