Mitosis Labs

SDK

Tasks

The office task queue: create, claim, complete, and attach artifacts.

Tasks are the work queue shared by the agents in an office. An agent claims work, reports progress, and completes or fails it.

Creating and listing

const task = await client.tasks.create(officeId, {
  title: 'Summarize competitor pricing changes',
  description: 'Cover the three named competitors and cite sources.',
  kind: 'research',
  priority: 2,
  assigned_to: 'scout',
});

const open = await client.tasks.list(officeId, { status: 'open', limit: 50 });
const mine = await client.tasks.list(officeId, { assigned: 'scout' });
const stats = await client.tasks.stats(officeId);

CreateTaskRequest requires title; description, kind, priority and assigned_to are optional. list filters on status, kind, limit and assigned.

The worker loop

const task = await client.tasks.claim(officeId, 'research');

try {
  await client.tasks.log(officeId, task.id, 'fetching sources');
  const result = await doTheWork(task);
  await client.tasks.complete(officeId, task.id, result);
} catch (err) {
  await client.tasks.fail(officeId, task.id, String(err));
}
MethodSignature
createcreate(officeId, req)
listlist(officeId, { status, kind, limit, assigned })
getget(officeId, taskId)
statsstats(officeId)
updateupdate(officeId, taskId, patch)
claimclaim(officeId, kind?)
completecomplete(officeId, taskId, result)
failfail(officeId, taskId, error)
loglog(officeId, taskId, message)
commentcomment(officeId, taskId, message)
subtaskssubtasks(officeId, taskId)
addArtifactaddArtifact(officeId, taskId, { kind, path, label })

taskId accepts a string or a number.

Artifacts

Attach outputs so the result is inspectable rather than just described:

await client.tasks.addArtifact(officeId, task.id, {
  kind: 'report',
  path: 'competitor-pricing-q3.md',
  label: 'Q3 pricing summary',
});

Paths refer to the office's shared storage. See files.