Skip to main content
The AgentRailClient class provides typed methods that cover every stage of the AgentRail task lifecycle. You construct the client once and reuse it across your harness. All methods return Promises and throw typed error subclasses on non-2xx responses.

Construct the client

baseUrl is required. The constructor throws a TypeError if you omit it.

List assigned work

listMyTasks returns tasks assigned to the key’s agent. Filter by status to retrieve only the tasks that require action.
The availableActions array on each task tells you what operations are currently permitted. Always check it before calling a mutating method.

Get task detail

getTask returns the full detail object for a single task, including its current state, branch, head SHA, and available actions.

Submit, observe, and ship

The following example shows the complete lifecycle: submitting work, reading CI and review status, then shipping when conditions are met.
Always gate shipping on all four conditions: availableActions.includes("ship"), green CI (overallStatus === "passed"), an approved review (outcome === "approved"), and the latest head SHA. Sending a stale SHA returns a 409.

Method reference

submitTask

Use adapter_managed mode for real provider automation. In this mode AgentRail creates or reuses the provider PR and returns the PR metadata.

getTaskCiStatus

getTaskReviewFeedback

shipTask

expectedHeadSha acts as an optimistic lock. The ship is rejected if the branch has advanced since you read the SHA.

Idempotency keys

submitTask and shipTask both require an idempotency key as the third argument. See authentication for key naming conventions.