Class: WorkflowsClient
@kortexya/reasoninglayer / WorkflowsClient
Class: WorkflowsClient
Section titled “Class: WorkflowsClient”Defined in: src/resources/workflows.ts:96
Workflows: a start step and a map of steps joined by next (a condition
branches with then/else), each step calling an engine capability with
{{input.<name>}} and {{steps.<id>.…}} placeholders.
Remarks
Section titled “Remarks”The engine checks a definition when it is written (every edge names a step,
the start exists, every step is reachable, a placeholder reads a declared
input or a step that runs before it) and bumps the version on each replace.
A run follows the version it started on, step by step, as the principal who
started it; an approval step waits for a decision in the action-review
queue, a wait step parks the run, and the tenant’s emergency stop parks it
before its next step. With a database, definitions and runs are rows every
engine serves, and a run whose engine stopped is taken over by another.
Methods
Section titled “Methods”cancelRun()
Section titled “cancelRun()”cancelRun(
runId,requestOptions?):Promise<WorkflowRun>
Defined in: src/resources/workflows.ts:475
Cancel a run that is running or waiting. A running run stops before its next step; a waiting one is never resumed.
Parameters
Section titled “Parameters”string
The run’s id.
requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<WorkflowRun>
The run, cancelled.
Throws
Section titled “Throws”NotFoundError 404 when the tenant has no run with that id.
Throws
Section titled “Throws”ApiError 409 when the run already settled.
Remarks
Section titled “Remarks”POST /api/v1/workflow-runs/{run_id}/cancel.
capture()
Section titled “capture()”capture(
id,request,requestOptions?):Promise<WorkflowCaptureResponse>
Defined in: src/resources/workflows.ts:158
Persist source-save and processing intent on one native durable run.
Parameters
Section titled “Parameters”string
Private procedure id.
request
Section titled “request”Reviewed version, stable event id, source identity and bindings.
requestOptions?
Section titled “requestOptions?”Per-call options; retries retain the supplied event id.
Returns
Section titled “Returns”Promise<WorkflowCaptureResponse>
A receipt distinguishing source persistence from processing status.
Throws
Section titled “Throws”ApiError 409 for changed versions/inputs, 503 without persistence.
Remarks
Section titled “Remarks”POST /api/v1/workflows/{id}/capture; source features use tagged values.
Envelope keys map to snake_case; feature names and nested inputs retain their case.
Example
Section titled “Example”`await client.workflows.capture(id, { eventId, expectedVersion: 1, source });`completeBrowserRead()
Section titled “completeBrowserRead()”completeBrowserRead(
runId,request,requestOptions?):Promise<WorkflowRun>
Defined in: src/resources/workflows.ts:450
Commit the selected browser’s actual observation and resume the native graph once.
Parameters
Section titled “Parameters”string
Run that waits for this command and session.
request
Section titled “request”Stable command/session ids and bounded literal page data.
requestOptions?
Section titled “requestOptions?”Per-call options; automatic retries are disabled.
Returns
Section titled “Returns”Promise<WorkflowRun>
The native receipt, whose graph may still be running.
Throws
Section titled “Throws”NotFoundError 404 for another principal or tenant.
Throws
Section titled “Throws”ApiError 409 for a changed command, session or authority, 422 for wrong origins or unbounded data.
Remarks
Section titled “Remarks”POST /api/v1/workflow-runs/{run_id}/browser-read; scalar keys use snake_case on the wire. An identical acknowledged observation is idempotent; inspect the native run after a lost response.
Example
Section titled “Example”`await client.workflows.completeBrowserRead(runId, { commandId, sessionId, url, title, content });`create()
Section titled “create()”create(
definition,requestOptions?):Promise<Workflow>
Defined in: src/resources/workflows.ts:220
Create a workflow.
Parameters
Section titled “Parameters”definition
Section titled “definition”Its name, inputs, start and steps.
requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<Workflow>
The workflow, version 1.
Throws
Section titled “Throws”ApiError 409 when this owner has a private procedure of that name.
Throws
Section titled “Throws”ApiError 422 for a definition a run could not follow, with the reason.
Remarks
Section titled “Remarks”POST /api/v1/workflows.
Example
Section titled “Example”const watch = await client.workflows.create({ name: 'pump-watch', inputs: ['site'], start: 'find', steps: { find: { kind: 'query', rlql: 'MATCH pump(site: {{input.site}}, status: "stopped", name: ?N);', next: 'any' }, any: { kind: 'condition', left: '{{steps.find.count}}', op: 'gt', right: 0, then: 'tell' }, tell: { kind: 'send_message', adapter: 'ops', channelId: 'C-1', content: '{{steps.find.count}} pumps stopped' }, },});delete()
Section titled “delete()”delete(
id,requestOptions?):Promise<void>
Defined in: src/resources/workflows.ts:291
Delete a workflow. Runs in flight finish on their own copy.
Parameters
Section titled “Parameters”string
The workflow’s id.
requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”NotFoundError 404 when the tenant has no workflow with that id.
Remarks
Section titled “Remarks”DELETE /api/v1/workflows/{id}.
draft()
Section titled “draft()”draft(
request,requestOptions?):Promise<DraftWorkflowResponse>
Defined in: src/resources/workflows.ts:115
Draft a native procedure through the configured model without executing it.
Parameters
Section titled “Parameters”request
Section titled “request”Original goal, exact inputs, untrusted observations and explicit caller answers.
requestOptions?
Section titled “requestOptions?”Per-call timeout, headers and cancellation.
Returns
Section titled “Returns”Promise<DraftWorkflowResponse>
A validated graph to review, or clarification questions.
Throws
Section titled “Throws”ApiError 503 when no model is configured, 422 after invalid generation.
Remarks
Section titled “Remarks”POST /api/v1/workflows/draft; opaque JSON keys retain their case.
Caller answers use clarifications; source observations remain in context.
Example
Section titled “Example”`await client.workflows.draft({ description: 'Check the saved source', inputs: { source: {} } });`enableTrigger()
Section titled “enableTrigger()”enableTrigger(
triggerId,requestOptions?):Promise<EnabledWorkflowTrigger>
Defined in: src/resources/workflows.ts:489
Arm a trigger for the task template version its owner reviewed.
Parameters
Section titled “Parameters”triggerId
Section titled “triggerId”string
The trigger.
requestOptions?
Section titled “requestOptions?”Per-call cancellation, timeout and request options.
Returns
Section titled “Returns”Promise<EnabledWorkflowTrigger>
The trigger as enabling left it: the version it runs and what an edit must not change.
Throws
Section titled “Throws”404 when the caller has no such trigger; 409 when the task template changed since the pinned version; 422 when a condition, an input binding or the template does not fit a triggered run.
Remarks
Section titled “Remarks”Uses POST /api/v1/workflow-triggers/{id}/enable.
Example
Section titled “Example”const trigger = await client.workflows.enableTrigger(triggerId);get(
id,requestOptions?):Promise<Workflow>
Defined in: src/resources/workflows.ts:251
Read a workflow.
Parameters
Section titled “Parameters”string
The workflow’s id.
requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<Workflow>
The workflow at its current version.
Throws
Section titled “Throws”NotFoundError 404 when the tenant has no workflow with that id.
Remarks
Section titled “Remarks”GET /api/v1/workflows/{id}.
getBrowserRead()
Section titled “getBrowserRead()”getBrowserRead(
runId,requestOptions?):Promise<BrowserReadCommand>
Defined in: src/resources/workflows.ts:431
Read the pending command for the run’s explicitly selected browser session.
Parameters
Section titled “Parameters”string
Private native run waiting at a browser-read step.
requestOptions?
Section titled “requestOptions?”Per-call timeout, headers and cancellation.
Returns
Section titled “Returns”Promise<BrowserReadCommand>
The persisted command identity, selected session and exact origin.
Throws
Section titled “Throws”NotFoundError 404 for a run of another principal or tenant.
Throws
Section titled “Throws”ApiError 409 when not waiting or current authority changed.
Remarks
Section titled “Remarks”GET /api/v1/workflow-runs/{run_id}/browser-read; snake_case fields are mapped to camelCase. Reading a command does not perform a page action.
Example
Section titled “Example”`const command = await client.workflows.getBrowserRead(runId);`getRun()
Section titled “getRun()”getRun(
runId,requestOptions?):Promise<WorkflowRun>
Defined in: src/resources/workflows.ts:416
Read a run: its status, the context of inputs and step outputs, its log.
Parameters
Section titled “Parameters”string
The run’s id.
requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<WorkflowRun>
The run.
Throws
Section titled “Throws”NotFoundError 404 when the tenant has no run with that id.
Remarks
Section titled “Remarks”GET /api/v1/workflow-runs/{run_id}.
getRunDefinition()
Section titled “getRunDefinition()”getRunDefinition(
runId,requestOptions?):Promise<Workflow>
Defined in: src/resources/workflows.ts:383
Read the exact private graph snapshot retained by a native run.
Parameters
Section titled “Parameters”string
The private run’s identity.
requestOptions?
Section titled “requestOptions?”Per-call namespace, timeout, signal and causal options.
Returns
Section titled “Returns”Promise<Workflow>
The executed graph, even when it was never saved as a procedure.
Throws
Section titled “Throws”409 when the initiating principal’s authority changed.
Remarks
Section titled “Remarks”GET /api/v1/workflow-runs/{run_id}/definition. Snake_case envelope fields map to camelCase while step identities and nested request data retain their case.
Example
Section titled “Example”`const definition = await client.workflows.getRunDefinition(runId);`list()
Section titled “list()”list(
requestOptions?):Promise<WorkflowListResponse>
Defined in: src/resources/workflows.ts:236
List this owner’s private procedures in the selected tenant, by name.
Parameters
Section titled “Parameters”requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<WorkflowListResponse>
The native envelope containing the workflows.
Remarks
Section titled “Remarks”GET /api/v1/workflows.
listRecentRuns()
Section titled “listRecentRuns()”listRecentRuns(
requestOptions?):Promise<WorkflowRun[]>
Defined in: src/resources/workflows.ts:367
List the current principal’s latest 100 private runs in the same authority scope.
Parameters
Section titled “Parameters”requestOptions?
Section titled “requestOptions?”Per-call namespace, timeout, signal and causal options.
Returns
Section titled “Returns”Promise<WorkflowRun[]>
Recent native receipts, including unsaved one-off graphs.
Throws
Section titled “Throws”When a native receipt is malformed.
Remarks
Section titled “Remarks”GET /api/v1/workflow-runs. Snake_case receipt fields map to camelCase; context data keeps its original keys. Does not inherit another actor’s outputs.
Example
Section titled “Example”`const runs = await client.workflows.listRecentRuns();`listRuns()
Section titled “listRuns()”listRuns(
id,requestOptions?):Promise<WorkflowRunListResponse>
Defined in: src/resources/workflows.ts:401
List a workflow’s runs, newest first.
Parameters
Section titled “Parameters”string
The workflow’s id.
requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<WorkflowRunListResponse>
The native envelope containing the runs.
Throws
Section titled “Throws”NotFoundError 404 when the tenant has no workflow with that id.
Remarks
Section titled “Remarks”GET /api/v1/workflows/{id}/runs.
rehearse()
Section titled “rehearse()”rehearse(
request,requestOptions?):Promise<RehearseWorkflowResponse>
Defined in: src/resources/workflows.ts:136
Rehearse real reads and branch decisions, stopping before the first effect.
Parameters
Section titled “Parameters”request
Section titled “request”The graph and explicitly bound inputs.
requestOptions?
Section titled “requestOptions?”Per-call options.
Returns
Section titled “Returns”Promise<RehearseWorkflowResponse>
Read outputs, selected branches and the unexecuted next effect.
Throws
Section titled “Throws”ApiError 422 for an invalid graph or missing inputs.
Remarks
Section titled “Remarks”POST /api/v1/workflows/rehearse; camelCase envelope keys map to snake_case,
while graph identities and nested input/effect data retain their case. No durable run or write is created.
Example
Section titled “Example”`await client.workflows.rehearse({ definition, inputs: { source } });`replace()
Section titled “replace()”replace(
id,definition,requestOptions?):Promise<Workflow>
Defined in: src/resources/workflows.ts:269
Replace a workflow’s definition; its version goes up by one.
Parameters
Section titled “Parameters”string
The workflow’s id.
definition
Section titled “definition”The new definition.
requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<Workflow>
The workflow at its new version.
Throws
Section titled “Throws”NotFoundError 404 when the tenant has no workflow with that id.
Throws
Section titled “Throws”ApiError 409 when another of the tenant’s workflows has that name.
Throws
Section titled “Throws”ApiError 422 for a definition a run could not follow.
Remarks
Section titled “Remarks”PUT /api/v1/workflows/{id}. Runs in flight keep the version they started on.
replanRun()
Section titled “replanRun()”replanRun(
runId,request?,requestOptions?):Promise<ReplanWorkflowResponse>
Defined in: src/resources/workflows.ts:182
Continue a failed goal with a revised remaining native plan.
Parameters
Section titled “Parameters”string
Failed run of this principal.
request?
Section titled “request?”New observations and explicit caller answers within the original goal and effects.
requestOptions?
Section titled “requestOptions?”Per-call options.
Returns
Section titled “Returns”Promise<ReplanWorkflowResponse>
A continuation with persisted provenance, or clarification questions.
Throws
Section titled “Throws”ApiError 409 for changed authority, settled state or exhausted budget.
Remarks
Section titled “Remarks”POST /api/v1/workflow-runs/{run_id}/replan; repeated calls reuse one child run.
Caller answers are serialized at the root; observations remain opaque untrusted JSON with unchanged keys.
Example
Section titled “Example”`await client.workflows.replanRun(runId, { observations: 'The source was updated.' });`runOnce()
Section titled “runOnce()”runOnce(
request,requestOptions?):Promise<WorkflowRun>
Defined in: src/resources/workflows.ts:343
Execute a reviewed personal graph once on the native durable runner.
Parameters
Section titled “Parameters”request
Section titled “request”The graph, inputs, stable event UUID and reviewing account UUID.
requestOptions?
Section titled “requestOptions?”Per-call namespace, timeout, signal and causal options.
Returns
Section titled “Returns”Promise<WorkflowRun>
The private native receipt. No reusable procedure is registered.
Throws
Section titled “Throws”When the event or reviewing account is not a UUID.
Throws
Section titled “Throws”409 for a changed account, authority, graph or input under the same event.
Remarks
Section titled “Remarks”POST /api/v1/workflow-runs. Performs one HTTP attempt; retain the event across an unknown response and explicitly inspect or retry its original intent. Envelope keys map to snake_case while graph identities and nested inputs retain their case.
Example
Section titled “Example”`await client.workflows.runOnce({ definition, eventId, expectedOwnerId, inputs });`saveAndFireTriggers()
Section titled “saveAndFireTriggers()”saveAndFireTriggers(
request,requestOptions?):Promise<WorkflowTriggerSaveResponse>
Defined in: src/resources/workflows.ts:510
Save a source and fire the triggers that watch where it is saved.
Parameters
Section titled “Parameters”request
Section titled “request”The save: its event id, kind, where it is saved and the source term.
requestOptions?
Section titled “requestOptions?”Per-call cancellation, timeout and request options.
Returns
Section titled “Returns”Promise<WorkflowTriggerSaveResponse>
The saved source and each matching trigger’s firing.
Throws
Section titled “Throws”409 when the event id already names a different save; 422 for an invalid save; 503 when persistent storage is unavailable.
Remarks
Section titled “Remarks”Uses POST /api/v1/workflow-triggers/saves (202). Retrying with the same
eventId fires nothing twice.
Example
Section titled “Example”await client.workflows.saveAndFireTriggers({ eventId, kind: 'on_save', projectId, source });startRun()
Section titled “startRun()”startRun(
id,request?,requestOptions?):Promise<WorkflowRun>
Defined in: src/resources/workflows.ts:313
Start a run of a workflow.
Parameters
Section titled “Parameters”string
The workflow’s id.
request?
Section titled “request?”A value for each declared input; wait: true answers once the
run settled or waits (an approval, a wait step, the emergency stop), up to two
minutes.
requestOptions?
Section titled “requestOptions?”Per-call options (timeout, retries, signal, headers).
Returns
Section titled “Returns”Promise<WorkflowRun>
The run.
Throws
Section titled “Throws”NotFoundError 404 when the tenant has no workflow with that id.
Throws
Section titled “Throws”ApiError 422 when an input is missing or not declared.
Remarks
Section titled “Remarks”POST /api/v1/workflows/{id}/runs. Envelope keys map to snake_case;
nested input keys and explicit null event/version fields are preserved. The run acts as the caller.
A null or absent event id disables automatic retries.
Example
Section titled “Example”`await client.workflows.startRun(id, { expectedVersion: 3, eventId, inputs });`