Files API
The Files API provides managed file storage (Storage v2). Upload files to Castari’s managed storage and attach them to agents. Access viaclient.files:
Methods
upload(file, filename, options?)
Upload a file to managed storage.| Name | Type | Required | Description |
|---|---|---|---|
file | Blob | Yes | The file data |
filename | string | Yes | File name |
options.description | string | No | File description |
options.tags | string[] | No | Tags for organization |
Promise<FileUploadResponse>
Example:
list(options?)
List files in managed storage.| Name | Type | Required | Description |
|---|---|---|---|
options.limit | number | No | Max results (default: 50) |
options.offset | number | No | Pagination offset |
options.scope | 'user' | 'agent' | 'session' | No | Filter by scope |
options.tags | string[] | No | Filter by tags |
options.search | string | No | Search by filename |
Promise<ManagedFileList>
get(fileId)
Get file metadata.Promise<ManagedFile>
update(fileId, options)
Update file metadata.Promise<ManagedFile>
delete(fileId)
Delete a file from managed storage.Promise<void>
download(fileId)
Download a file.Promise<Response>
getUsage()
Get storage usage statistics.Promise<StorageUsage>
Example:
getUploadUrl(filename, sizeBytes, options?)
Get a presigned upload URL for large files.Promise<PresignedUpload>
confirmUpload(fileId, sha256Hash)
Confirm a presigned upload completed successfully.Promise<ManagedFile>
attachToAgent(agentSlug, options)
Attach a file to an agent.| Name | Type | Required | Description |
|---|---|---|---|
agentSlug | string | Yes | The agent’s slug |
options.fileId | string | Yes | File ID to attach |
options.mountPath | string | No | Path inside the sandbox |
options.readOnly | boolean | No | Mount as read-only |
Promise<AgentFile>
listAgentFiles(agentSlug)
List files attached to an agent.Promise<AgentFileList>
detachFromAgent(agentSlug, fileId)
Detach a file from an agent.Promise<void>
See Also
- cast files — CLI equivalent
- Storage API — Cloud bucket storage
- Types — TypeScript interfaces