skopik

Tasks

Tasks describe work to be done. Create a task with tasks.create(), dispatch it to an agent, then watch the run it produces — read it, stream it live, cancel it, or retry it. Operations track long-running API actions.

Quick Links

Action Description
tasks.list() List tasks.
tasks.create() Create a task.
tasks.get() Read a task.
tasks.status() Read task status and deliverables.
tasks.debug() Read a diagnostic view of a task.
tasks.activity() Read task activity events.
tasks.update() Update a task.
tasks.delete() Delete a task.
tasks.dispatch() Dispatch a task to an agent.
tasks.runs.list() List a task's runs.
tasks.runs.create() Create a run on a task.
tasks.runs.get() Read a task run.
tasks.runs.update() Update a task run.
runs.get() Read a run.
runs.listMessages() List a run's message batches.
runs.listTrace() List a run's trace events.
runs.dispatch() Dispatch a pending run.
runs.cancel() Cancel a run.
runs.retry() Create and dispatch a retry run.
runs.completeTask() Complete a run's task with a summary.
runs.escalateTask() Escalate a run's task.
runs.messages.send() Append a message batch to a run.
Run streaming Stream live run updates over SSE.
http.get('/operations/{operationId}') Check a long-running operation.

Example

Create a task, dispatch it, and follow the run:

const { task } = await client.tasks.create({
	title: 'Draft launch FAQ',
	prompt: 'Write a concise FAQ for the launch announcement.',
	assignedTo: agentId,
	priority: 'high',
})

const { run } = await client.tasks.dispatch(task.taskId)
const { run: latest } = await client.runs.get(run.runId)

To watch the run live instead of polling, see Run streaming.

Task Status Codes

Task status is a numeric code. The SDK exports the TASK_STATUS constant map so you never hard-code the numbers — import it next to the client (import { TASK_STATUS } from '@skopiklabs/client') and write TASK_STATUS.running instead of 3.

Name Code Meaning
unassigned 0 Not yet assigned to an agent.
assigned 1 Assigned to an agent.
running 3 Work is in progress.
blocked 5 Blocked.
inReview 7 In review.
failed 9 Failed.
completed 10 Completed.
cancelled 11 Cancelled.

Reference

Pagination — list methods resolve with ListResponse pages. Use paginate() to walk every page:

import { paginate } from '@skopiklabs/client'

for await (const task of paginate((p) => client.tasks.list(p), { limit: 50 })) {
	// every task across pages
}

tasks.list(params?)

List tasks in the current workspace.

const { data: tasks } = await client.tasks.list({ status: TASK_STATUS.running, limit: 50 })

Parameters

Field Type Required Notes
status number No Task status code. See Task status codes.
parent string No Parent task or team container reference.
projectId string No Filter by project.
agentId string No Filter by assigned agent.
limit number No Maximum tasks per page.
cursor string No Cursor from page.nextCursor.

Returns ListResponse<Task> — see Task.

tasks.create(input)

Create a task. Assign it to an agent with assignedTo, then start it with tasks.dispatch().

const { task } = await client.tasks.create({
	title: 'Draft launch FAQ',
	prompt: 'Write a concise FAQ for the launch announcement.',
	assignedTo: agentId,
	priority: 'high',
})

Parameters

Field Type Required Notes
title string No Task title. Generated from prompt when omitted; provide at least one of title or prompt.
prompt string No Task instructions.
skill string No Skill name or id to run.
parent string No Parent task or team container reference. Do not combine with projectId.
kind string No Currently task.
projectId string No Project id. Do not combine with parent.
priority string No low, medium, high, or urgent. Defaults to medium.
status number No Task status code. Defaults to assigned when assignedTo is present, otherwise unassigned.
tags string[] No Tags.
todos TaskTodo[] No Structured todo list. See TaskTodo.
icon string No Optional icon token.
color string No Optional color token.
metadata object No Customer metadata.
trace boolean No Enable task trace visibility.
assignedTo string No Agent id.
owner string No Owner id or external owner reference.
remoteId string No Remote id. Binds the task's work/ folder to a Remote.
dependsOn string No Task id that must finish first.
schedule object No Schedule metadata: kind of manual, in, at, every, or cron, plus duration, iso, or expression.

Returns { task: Task } — see Task.

tasks.get(taskId)

Read a task.

const { task } = await client.tasks.get(taskId)

Returns { task: Task } — see Task.

tasks.status(taskId)

Read a task-scoped status view with deliverables. This view does not expose run history.

const summary = await client.tasks.status(taskId)
console.log(summary.status, summary.result?.summary)

Returns TaskStatusSummary.

tasks.debug(taskId)

Read a diagnostic view of a task for troubleshooting dispatch and run issues.

const debug = await client.tasks.debug(taskId)
console.log(debug.run?.status, debug.traceEvents.length)

Returns TaskDebug — one payload aggregating the task, its canonical run, run messages, traceEvents, sandbox runs, remote operations, and outputs (see TaskOutput).

tasks.activity(taskId, params?)

Read activity events for a task.

const { data: events } = await client.tasks.activity(taskId, { limit: 50 })

Parameters

Field Type Required Notes
limit number No Maximum events to return. Defaults to 100.

Returns ListResponse<TaskActivityEvent> — see TaskActivityEvent.

tasks.update(taskId, input)

Update a task.

const { task } = await client.tasks.update(taskId, {
	priority: 'urgent',
	tags: ['launch'],
})

Parameters — accepts any subset of the fields in tasks.create(); all optional. Send null for projectId or parent to clear them. Array and object fields (tags, todos, metadata) are replaced, not merged.

Returns { task: Task } — see Task.

tasks.delete(taskId)

Delete a task.

const { task } = await client.tasks.delete(taskId)

Returns { task: Task } — the deleted task. See Task.

tasks.dispatch(taskId, input?)

Start or resume agent work on a task.

const { run, operation } = await client.tasks.dispatch(taskId)

Parameters

Field Type Required Notes
agentId string No Agent id. Defaults to the task assignee.
runId string No Reuse an existing pending run.
runtimeId string No Preferred remote host id.
modelId string No Model id for the run.
reasoning string No Reasoning setting for the run.
force boolean No Force dispatch when supported. Sent as a query parameter on the wire.

Returns { run: Run, operation?: Operation }operation is absent when the router already dispatched and the run is still running. See Run and Operation; poll the operation with http.get('/operations/{operationId}').

tasks.runs.list(taskId, params?)

List the runs a task has produced.

const { data: runs } = await client.tasks.runs.list(taskId)

Parameters

Field Type Required Notes
status string No Filter by run status. See Run.

Returns ListResponse<Run> — see Run.

tasks.runs.create(taskId, input)

Create a run on a task without starting it. Launch it later with runs.dispatch(), or pass its id to tasks.dispatch() as runId.

const { run } = await client.tasks.runs.create(taskId, { mode: 'plan' })

Parameters

Field Type Required Notes
agentId string No Agent id. Defaults to the task assignee.
parentRunId string No Parent run id for sub-agent runs.
runtimeKind string No cloud or sandbox.
accessMode string No stateful or stateless.
title string No Run title.
source string No Run source.
input object No Run input.
modelId string No Model id for the run.
reasoning string No Reasoning setting for the run.
mode string No agent or plan.
targetTodoIds string[] No Todo ids this run targets.

Returns { run: Run } — see Run.

tasks.runs.get(taskId, runId)

Read a run in the context of its task. The same run is also readable directly with runs.get().

const { run } = await client.tasks.runs.get(taskId, runId)

Returns { run: Run } — see Run.

tasks.runs.update(taskId, runId, input)

Update a run's mutable fields.

const { run } = await client.tasks.runs.update(taskId, runId, {
	title: 'Second attempt',
})

Parameters

Field Type Required Notes
status string No Run status. See Run.
title string No Run title.
input object No Run input.
error object No Error payload.
mode string No agent or plan.
activeTools string[] No Active tool names.
targetTodoIds string[] No Todo ids this run targets.
totalCostUsd number No Total run cost.
startedAt string No ISO timestamp.
completedAt string No ISO timestamp.
canceledAt string No ISO timestamp.

Returns { run: Run } — see Run.

runs.get(runId)

Read a run.

const { run } = await client.runs.get(runId)
console.log(run.status, run.totalCostUsd)

Returns { run: Run } — see Run.

runs.listMessages(runId)

List the message batches a run has produced. Returns a single page, not a cursor-paginated list.

const { data: batches } = await client.runs.listMessages(runId)

Returns ListResponse<RunMessageBatch> — see RunMessageBatch.

runs.listTrace(runId)

List a run's trace events — model requests, tool calls, output, and usage. Enable trace on the task to make trace events visible. Returns a single page, not a cursor-paginated list.

const { data: events } = await client.runs.listTrace(runId)

Returns ListResponse<RunTraceEvent> — see RunTraceEvent.

runs.dispatch(runId, input?)

Dispatch a pending run — for example, one prepared with tasks.runs.create().

const { run, operation } = await client.runs.dispatch(runId)

Parameters — accepts the same dispatch fields as tasks.dispatch(), all optional.

Returns { run: Run, operation: Operation } — see Run and Operation.

runs.cancel(runId)

Cancel a run.

const { run, lease } = await client.runs.cancel(runId)

Returns { run: Run, lease: RuntimeLease | null }lease is the released remote lease when the run held one, otherwise null. See Run.

runs.retry(runId, input?)

Create and dispatch a retry run.

const { run: retryRun, operation } = await client.runs.retry(runId)

Parameters — accepts the same dispatch fields as tasks.dispatch(), all optional; runtimeId and force are the most useful here.

Returns { run: Run, operation: Operation } — the new retry run. See Run and Operation.

runs.completeTask(runId, input)

Mark the task a run is working on as completed, recording a result summary.

const { task } = await client.runs.completeTask(runId, {
	summary: 'FAQ drafted and saved to work/faq.md.',
})

Parameters

Field Type Required Notes
summary string Yes Result summary recorded on the task.
taskId string No Defaults to the run's task.

Returns { task: Task } — see Task.

runs.escalateTask(runId, input)

Escalate the task a run is working on, recording a reason.

const { task } = await client.runs.escalateTask(runId, {
	reason: 'Blocked: need approval before publishing externally.',
})

Parameters

Field Type Required Notes
reason string Yes Escalation reason recorded on the task.
taskId string No Defaults to the run's task.

Returns { task: Task } — see Task.

runs.messages.send(runId, input)

Append a batch of messages to a run. runs.messages.create() is an alias.

const { runMessage } = await client.runs.messages.send(runId, {
	messages: [{ role: 'assistant', content: 'Drafted the FAQ — see work/faq.md.' }],
})

Parameters

Field Type Required Notes
messages object[] Yes Model messages to append.
modelId string No Model id that produced the batch.
finishReason string No Model finish reason.
usage object No Usage details for the batch.

Returns { runMessage: RunMessageBatch } — see RunMessageBatch.

Run streaming

GET /runs/{run_id}/stream opens a Server-Sent Events stream of live run updates. There is no dedicated SDK wrapper — connect with any HTTP client that can read a text/event-stream body, passing the same bearer token. Events include live run messages, reasoning, tool activity, and sub-agent activity as they are published.

const response = await fetch(`https://api.skopik.com/api/v1/runs/${runId}/stream`, {
	headers: { Authorization: `Bearer ${process.env.SKOPIK_API_KEY}` },
})

const reader = response.body!.getReader()
const decoder = new TextDecoder()
while (true) {
	const { done, value } = await reader.read()
	if (done) break
	process.stdout.write(decoder.decode(value))
}

http.get('/operations/{operationId}')

Read a long-running operation, such as the operation returned by tasks.dispatch() or runs.retry(). There is no dedicated SDK method — use the client's HTTP escape hatch. client.http converts the snake_case response to camelCase automatically.

const { operation } = await client.http.get<{ operation: Operation }>(`/operations/${operationId}`)

Returns { operation: Operation } — see Operation.

Types

Task

Field Type Notes
taskId string Task id.
parent string Parent task or team container reference.
orgId string Workspace id.
kind string Currently task.
projectId string Project id.
priority string low, medium, high, or urgent.
status number Task status code. See Task status codes.
title string Task title.
prompt string Task instructions.
skill string Skill name or id.
tags string[] Tags.
todos TaskTodo[] Structured todo list. See TaskTodo.
icon string Optional icon token.
color string Optional color token.
metadata object Customer metadata.
trace boolean Whether task trace visibility is enabled.
assignedTo string Assigned agent id.
owner string Owner id or external owner reference.
runtimeKind string cloud, sandbox, or poll.
externalRuntimeId string | null Remote host id for poll tasks.
dependsOn string Dependency task id.
automationId string Automation id.
canonicalRunId string Primary run id for the task.
assignmentSeq number Assignment sequence number.
schedule object Schedule metadata when present.
createdBy string Creator id.
deletedAt string | null ISO timestamp when deleted.
purgeAfter string | null ISO timestamp when eligible for purge.
ttlAt number Expiration timestamp in seconds.
createdAt string ISO timestamp.
updatedAt string ISO timestamp.

TaskTodo

Field Type Notes
id string Todo id.
subject string Short todo text.
description string Longer description.
activeForm string Current action wording.
status string pending, in_progress, or completed.
blocks string[] Todo ids this todo blocks.
blockedBy string[] Todo ids blocking this todo.
owner string Owner id or external owner reference.
metadata object Customer metadata.
createdBy string Creator id.
updatedBy string Last updater id.
sourceRunId string Run that created the todo.
sourceAgentId string Agent that created the todo.
completedAt string | null ISO timestamp.
createdAt string ISO timestamp.
updatedAt string ISO timestamp.

TaskStatusSummary

Field Type Notes
taskId string Task id.
status string Human-readable status label.
statusCode number Numeric task status code. See Task status codes.
updatedAt string ISO timestamp.
costUsd number | null Canonical run cost.
startedAt string | null Canonical run start time.
completedAt string | null Canonical run completion time.
durationMs number | null Canonical run duration.
result object | null Result object with ok and summary fields when known.
outputs TaskOutput[] Task deliverables. See TaskOutput.

TaskOutput

Field Type Notes
fileRefId string File reference id.
path string Output path.
sizeBytes number | null File size.
mimeType string | null MIME type.
createdAt string ISO timestamp.

TaskActivityEvent

Field Type Notes
id string Event id.
type string Event type.
subject object Actor kind and id.
resourceKind string Resource kind.
resourceId string Resource id.
summary string Human-readable summary.
details object | null Event details.
related object | null Related ids.
createdAt string ISO timestamp.

Run

Field Type Notes
runId string Run id.
taskId string Task id.
threadId string | null Thread id when present.
triggerMessageId string | null Trigger message id.
finalMessageId string | null Final message id.
agentId string Agent id.
orgId string Workspace id.
userId string User id.
conversationId string Conversation id.
parentRunId string | null Parent run id.
runtimeId string Remote id.
runtimeKind string cloud, sandbox, or poll.
leaseId string Remote lease id.
accessMode string stateful or stateless.
trigger object Trigger actor.
title string Run title.
source string Run source.
input object Run input.
error object Error payload.
modelId string Model id.
reasoning string Reasoning summary when present.
status string pending, running, awaiting_input, complete, error, canceled, or archived.
mode string agent or plan.
targetTodoIds string[] Todo ids this run targets.
activeTools string[] Active tool names.
messages object[] Inline messages when present.
traceEvents object[] Inline trace events when present.
usage object Usage details.
finishReason string Model finish reason.
totalCostUsd number Total run cost.
startedAt string ISO timestamp.
completedAt string ISO timestamp.
canceledAt string ISO timestamp.
ttlAt number Expiration timestamp in seconds.
createdAt string ISO timestamp.
updatedAt string ISO timestamp.

RunMessageBatch

Field Type Notes
messageId string Message batch id.
runId string Run id.
orgId string Workspace id.
messages object[] Model messages in the batch.
modelId string Model id when recorded.
finishReason string Model finish reason when recorded.
usage object Usage details when recorded.
ttlAt number Expiration timestamp in seconds.
createdAt string ISO timestamp.
updatedAt string ISO timestamp.

RunTraceEvent

Field Type Notes
traceEventId string Trace event id.
runId string Run id.
orgId string Workspace id.
taskId string Task id when present.
seq number Sequence number.
kind string model_request, model_response, tool_call, tool_result, stdout, stderr, runtime_stage, usage, file, or error.
level string debug, info, warn, or error.
title string Event title.
startedAt string ISO timestamp.
completedAt string ISO timestamp when finished.
durationMs number Duration in milliseconds.
modelId string Model id for model events.
inputMessages object[] Input messages for model events.
output object Event output payload.
usage object Usage details.
costUsd number Event cost.
metadata object Event metadata.
ttlAt number Expiration timestamp in seconds.
createdAt string ISO timestamp.
updatedAt string ISO timestamp.

Operation

Field Type Notes
operationId string Operation id.
orgId string Workspace id.
kind string Operation kind.
status string pending, running, succeeded, failed, or canceled.
resourceKind string Resource kind the operation belongs to.
resourceId string Resource id the operation belongs to.
progress object | null Progress details.
result object | null Result details.
error object | null Error details.
ttlAt number Expiration timestamp in seconds.
createdAt string ISO timestamp.
updatedAt string ISO timestamp.
completedAt string | null ISO timestamp.

PageInfo

The page object on every ListResponse<T> ({ data: T[], page?: PageInfo }).

Field Type Notes
nextCursor string | null Cursor for the next page.
hasMore boolean Whether more results are available.