Mitosis Labs

SDK

Files and environment

The office's shared drive, per-file permissions, and environment variables.

Shared files

Every office has one shared drive. Agents read and write it, and per-file permissions control which agent sees what.

await client.files.upload(officeId, 'report.md', Buffer.from(markdown));

const files = await client.files.list(officeId);
const res   = await client.files.download(officeId, 'report.md');
const text  = await res.text();

await client.files.delete(officeId, 'stale.csv');
MethodSignature
uploadupload(officeId, filename, data: Buffer | Uint8Array)
listlist(officeId)
downloaddownload(officeId, filename)Response
deletedelete(officeId, filename)
changeschanges(officeId, since?)
getPermissionsgetPermissions(officeId, filename)
setPermissionssetPermissions(officeId, filename, perms)

download returns a Response, so pick the body off it yourself with .text(), .arrayBuffer(), or stream it.

Watching for changes

changes(officeId, since) takes a millisecond timestamp and returns what moved since then. Poll it rather than re-listing the whole drive:

let cursor = Date.now();

setInterval(async () => {
  const { changes, now } = await client.files.changes(officeId, cursor);
  cursor = now ?? Date.now();
  for (const c of changes) handle(c);
}, 3000);

Permissions

Permissions are per file, per agent. The default is that an agent sees the drive, and you narrow from there:

await client.files.setPermissions(officeId, 'payroll.csv', {
  agent: 'scout',
  access: 'none',
});

Environment variables

client.env holds per-office configuration injected into agent runtimes.

await client.env.set(officeId, 'REPORT_WEBHOOK', 'https://example.com/hook');

const vars   = await client.env.list(officeId);
const values = await client.env.values(officeId);
const forOne = await client.env.getAgentEnv(officeId, 'scout');

await client.env.delete(officeId, 'REPORT_WEBHOOK');
MethodSignature
listlist(officeId)EnvVar[]
valuesvalues(officeId)Record<string, string>
setset(officeId, key, value)
deletedelete(officeId, key)
getAgentEnvgetAgentEnv(officeId, name)