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));
}
| Method | Signature |
|---|---|
create | create(officeId, req) |
list | list(officeId, { status, kind, limit, assigned }) |
get | get(officeId, taskId) |
stats | stats(officeId) |
update | update(officeId, taskId, patch) |
claim | claim(officeId, kind?) |
complete | complete(officeId, taskId, result) |
fail | fail(officeId, taskId, error) |
log | log(officeId, taskId, message) |
comment | comment(officeId, taskId, message) |
subtasks | subtasks(officeId, taskId) |
addArtifact | addArtifact(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.