How an agent stores files, reads them back, and hands one to someone outside with a link that expires. What the drive is and what it costs is on Services.
Every account has the drive. An agent acts on it with its Passport. You act on it with your key or sign-in and need no Passport.
Save these meeting notes to the drive as notes.md.The client calls stack_drive_upload. From code or the terminal:
const file = await stack.drive.upload({
name: 'notes.md',
content_text: '# Notes',
visibility: 'account',
}, { passportToken });npx @getstackrun/cli drive upload ./report.pdf --accountFor a file up to 1 GB, the agent asks for a one-time upload address and sends the file to it from its workspace or its own code. The bytes never pass through the model. A file typed as text, Markdown, CSV or JSON is 10 MB at most this way too.
const slot = await stack.drive.createUploadLink({ name: 'archive.zip' }, { passportToken });
// slot.url, slot.expires_atcurl -T ./archive.zip '<the url>'stack_drive_list lists files, newest first, with how much of the drive is used. stack_drive_get returns one file's facts, and stack_drive_read returns its content, up to 256 KB. To get a larger file out, make a share link and fetch it.
Every file on the drive is content from outside, whatever its name says. With controls on, a flagged text file is withheld from the agent that reads it.
Make a link to report.pdf that works for one hour and five downloads.const link = await stack.drive.share(file.id, { ttl_seconds: 3600, max_downloads: 5 }, { passportToken });
// link.url is returned once
await stack.drive.revokeLink(file.id, link.id, { passportToken });stack_drive_copy makes a new file of the caller's own from one it can see, for example to keep an email attachment. stack_drive_update changes who can see a file or when it expires. stack_drive_delete removes the file and ends every link to it.
When a tool returns more than a call can carry (about 3 MB), STACK saves the result to the drive as a JSON file and answers with handed_off: true and the file's id. The file is kept 30 days. This costs no extra action.
If storage beyond the free amount cannot be paid from credit, the drive goes read-only: nothing is uploaded, changed, copied or newly shared. Reading, listing, deleting and existing links still work. Topping up, or deleting files down to the free amount, ends it at once. stack_drive_list shows storage_unpaid with the date files would be deleted.
Storing a file, asking for an upload address, copying and sharing are one action each. Listing, reading, changing, deleting and ending a link are free.
Every field is on Drive. Every tool is in the tool reference.