Operation
Operations: work that outlives a request (a human's answer, a connect
link, an agent turn). op.wait() returns the typed outcome for its kind.
class OperationA long-running piece of work. T is what wait() resolves to.
- Like every live object, it also has hydrate(), refresh() and raw.
| id | string | |
| kind | string | |
| status | OperationStatus | |
| step | OperationStep | null | Where a running operation is: an agent turn on a CLI harness |
| result | unknown | The raw result once succeeded. |
| createdAt | Date | null | |
| updatedAt | Date | null | |
| summaryText | string | null | A short line saying what it is (a message preview, an addressee, a command). |
| userId | string | null | |
| keyId | string | null | The key that started it. |
| agentId | string | null | |
| input | JsonObject | null | What it was started with (on a single operation's view, for account principals). |
| startedAt | Date | null | |
| finishedAt | Date | null | |
| waitMs | number | null | Time queued before it ran. |
| runMs | number | null | Time running. |
| heldMs | number | null | Time waiting on a person. |
| progress | OperationProgress | null | What the work reported as it went (null before it reported anything). An agent that started it hears each
report as an |
| undoable | boolean | null | Whether |
| undoneAt | Date | null | When it was undone, if it was. |
| transitions | OperationTransition[] | Every status change, oldest first (empty for operations recorded before they were kept). |
| consoleUrl | string | null | This operation in the developer console (null off the hosted API). |
| error | NoClickError | null | The failure as a |
| done | boolean | Whether the operation reached a terminal status. |
liststatic
static list(
options?: OperationFilters & { limit?: number },
): Promise<Operation[]>Operations matching the filters, newest first (or the first limit).
Statuses, or "live" for every non-terminal one.
An Agent or agent id.
The requesting key: its id or its prefix (nk_live_ab12).
Rows changed since (for polling).
Return at most this many.
Which users the read covers (user_id query), instead of acting as one (user).
undefined = the ambient user (asUser), null = the account itself.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
Every matching operation, fetched page by page.
listPagestatic
static listPage(
options?: OperationFilters & PageOptions,
): Promise<Page<Operation>>One page of matching operations; pass nextCursor back as cursor.
The next_cursor of the page before; omit it for the first page.
Return at most this many.
Statuses, or "live" for every non-terminal one.
An Agent or agent id.
The requesting key: its id or its prefix (nk_live_ab12).
Rows changed since (for polling).
Which users the read covers (user_id query), instead of acting as one (user).
undefined = the ambient user (asUser), null = the account itself.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
A page whose data holds the operations and whose next_cursor is None on the last page.
summarystatic
static summary(options?: OperationFilters): Promise<OperationSummary>How many operations match, by status.
Statuses, or "live" for every non-terminal one.
An Agent or agent id.
The requesting key: its id or its prefix (nk_live_ab12).
Rows changed since (for polling).
Which users the read covers (user_id query), instead of acting as one (user).
undefined = the ambient user (asUser), null = the account itself.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
The total, and in by_status a count for every status, zeros included.
fromIdstatic
static fromId(operationId: string, options?: CallOptions): Operation<T>A lazy reference to an operation by id.
An operation that loads the first time you read a field. Nothing is sent yet.
wait
wait(options?: { timeoutS?: number }): Promise<T>Wait until the operation finishes and return its outcome (typed per kind:
Connection, Answer, boolean, AgentReply, ...). Throws the
operation's error if it failed, OperationCanceled / Expired, or
OperationTimeout after timeoutS seconds.
The outcome, typed for the operation's kind: an AgentReply from agent.send,
True or False from human.approve, the connected Connection from a
connect link. A kind the client has no type for gives the raw result.
toolCalls
toolCalls(): Promise<ToolCall[]>The tool calls an agent.message turn made, oldest first (none for other kinds).
Each call's tool, arguments, status, duration and a preview of its result.
events
async *events(options?: { intervalMs?: number }): AsyncGenerator<OperationEvent>Yield an event for each status or step change until the operation finishes.
1000The changes, polled every interval seconds: first the status (and step) it has
now, last its final one. An event's result is the raw result, not the typed outcome
wait() returns.
cancel
cancel(): Promise<this>Ask the server to cancel; returns the updated operation.
This operation, now canceled.
undo
undo(): Promise<JsonObject>Take back a reversible write, once: a deletion comes out of the trash, a dict's cleared keys
come back, a migrated database is restored to the moment before. What reached the world (an
email sent, a payment) has no undo: that throws Conflict, as does undoing twice. Returns what
the undo put back, as its own API shows it.
What the undo put back, as its own API shows it (a restore of a database is an operation of its own).
OperationEvent
interface OperationEventA status or step change observed by Operation.events(): step is where a running
operation is (delivering or working for a CLI agent's turn, submitted or scheduled
for a port; None otherwise).
| status | OperationStatus | |
| step | OperationStep | null | Where a running operation is ( |
| updatedAt | Date | null | |
| result | unknown | |
| error | NoClickError | null | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
OperationSummary
interface OperationSummaryHow many operations match, by status.
| total | number | |
| byStatus | Record<OperationStatus, number> | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
OperationTransition
interface OperationTransitionOne status change the server recorded (by names who canceled).
| status | OperationStatus | |
| at | Date | null | |
| by | string | null |