Skip to content

@usine/agents/runtime

The session finished and reported that the work itself failed.

  • Schema.Class

new AgentResultError(…args): AgentResultError

Parameter Type
…args [props: object, options?: MakeOptions]

AgentResultError

readonly message: string

readonly sessionId: Option<string & Brand<"AgentSessionId">>


Runs the coding work delegated by an Attempt’s parent.

  • Context.ServiceClass

readonly Service: ChildBackendService

The service’s operations: what yield* ChildBackend returns.


Work delegated to one child, with its assigned identity and the checkout it shares with the parent.

  • Schema.Class

new ChildRequest(…args): ChildRequest

Parameter Type
…args [props: object, options?: MakeOptions]

ChildRequest

readonly cwd: string & Brand<"AgentWorkingDirectory">

The checkout, on the machine host names.

readonly environment: object

The complete environment of the child’s process and every command it runs: the Worker’s allowlisted variables plus the Attempt’s credential configuration. Nothing is inherited from the process that launches the child (ADR 0011). On a RemoteShell host they are exported on top of the remote machine’s own environment, which holds no orchestrator secret.

[key: string]: string

readonly host: LocalProcess | RemoteShell

Where the child’s process runs.

readonly prompt: string

readonly session: ChildSession


The Pi parent asked for one more child than this Attempt’s budget allows.

  • Schema.Class

new ChildSessionBudgetExceededError(…args): ChildSessionBudgetExceededError

Parameter Type
…args [props: object, options?: MakeOptions]

ChildSessionBudgetExceededError

readonly attemptedChildren: number & Brand<"ChildSessionCount">

readonly maxChildren: number & Brand<"ChildSessionBudget">

readonly message: string


Runs delegated coding work with Claude Code.

  • Context.ServiceClass

readonly Service: ChildBackendService

The service’s operations: what yield* ClaudeChildBackend returns.


Runs delegated coding work with Codex.

  • Context.ServiceClass

readonly Service: ChildBackendService

The service’s operations: what yield* CodexChildBackend returns.


Runs delegated coding work with Pi.

  • Context.ServiceClass

readonly Service: ChildBackendService

The service’s operations: what yield* PiChildBackend returns.


The credential cannot spend from the billing pool this session needs.

  • Schema.Class

new PoolUnavailableError(…args): PoolUnavailableError

Parameter Type
…args [props: object, options?: MakeOptions]

PoolUnavailableError

readonly harness: "claude" | "codex" | "pi"

readonly message: string

readonly model: string & Brand<"ModelId">

readonly pool: "apiKeys" | "claudePlan" | "chatgptPlan"


The SDK or its process failed after the model and harness were validated.

  • Schema.Class

new SessionOperationError(…args): SessionOperationError

Parameter Type
…args [props: object, options?: MakeOptions]

SessionOperationError

readonly cause: unknown

readonly message: string

readonly operation: "launch" | "stream" | "steer" | "interrupt"

readonly sessionId: Option<string & Brand<"AgentSessionId">>


The final message a parent or child session returns.

  • Schema.Class

new SessionResult(…args): SessionResult

Parameter Type
…args [props: object, options?: MakeOptions]

SessionResult

readonly message: string


The rostered model id is well-formed but the SDK’s registry does not list it.

  • Schema.Class

new UnknownModelError(…args): UnknownModelError

Parameter Type
…args [props: object, options?: MakeOptions]

UnknownModelError

readonly harness: "claude" | "codex" | "pi"

readonly message: string

readonly model: string & Brand<"ModelId">


The model exists but does not support the rostered reasoning effort.

  • Schema.Class

new UnsupportedEffortError(…args): UnsupportedEffortError

Parameter Type
…args [props: object, options?: MakeOptions]

UnsupportedEffortError

readonly effort: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"

readonly harness: "claude" | "codex" | "pi"

readonly message: string

readonly model: string & Brand<"ModelId">

Launches coding sessions for tasks delegated by an Attempt’s parent.

readonly launch: (request) => Effect<RunningSession, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError, Scope>

Starts the assigned child and returns its controls; its result is awaited separately.

Parameter Type
request ChildRequest

Effect<RunningSession, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError, Scope>


A live parent or child session whose activity can be observed while its work continues.

readonly events: Stream<SessionStarted | TextOutput | ToolStarted | ToolFinished | PoolRateLimitsUpdated | SessionFinished | SessionIdle | SessionResumed | SessionTokensUpdated, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError>

Activity to record in the Attempt transcript while waiting for the result.

readonly interrupt: Effect<void, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError>

Requests that this session stop its current work.

readonly intervene: (action) => Effect<InterventionState, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError>

Applies a nonterminal operator action; child messages hold completion until release.

Parameter Type
action Steer | Interrupt | OperatorMessage | Release

Effect<InterventionState, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError>

readonly result: Effect<SessionResult, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError>

Waits for the final message or the failure that ends this session’s work.

readonly session: ChildSession | ParentSession

readonly steer: (message) => Effect<void, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError>

Adds operator guidance to the running session without creating a new Attempt.

Parameter Type
message string

Effect<void, UnknownModelError | PoolUnavailableError | UnsupportedEffortError | AgentResultError | ChildSessionBudgetExceededError | SessionOperationError>

AgentSessionError = typeof AgentSessionError.Type

A session could not start, continue, or finish its work; the failure determines whether retry needs an operator.


SessionOperation = typeof SessionOperation.Type


WorkingDirectory = typeof WorkingDirectory.Type

The checkout directory one Attempt runs in.

const AgentSessionError: Schema.Union<readonly [typeof UnknownModelError, typeof PoolUnavailableError, typeof UnsupportedEffortError, typeof AgentResultError, typeof ChildSessionBudgetExceededError, typeof SessionOperationError]>

A session could not start, continue, or finish its work; the failure determines whether retry needs an operator.


const BLOCKED_MARKER: "[usine:blocked]" = "[usine:blocked]"

The reserved opening of a final answer that reports an unresolved blocker. Text after the marker is the blocker; the session fails with AgentResultError.


const SESSION_OPERATIONS: readonly ["launch", "stream", "steer", "interrupt"]


const SessionOperation: Schema.Literals<readonly ["launch", "stream", "steer", "interrupt"]>


const toAttemptFailure: (error) => AttemptFailure

Maps session errors onto the retry taxonomy: an SDK or process failure is retryable infrastructure, while a bad roster spec or the agent failing its own work waits for the operator (ADR 0002).

Parameter Type
error AgentSessionError

AttemptFailure


const WorkingDirectory: Schema.brand<Schema.NonEmptyString, "AgentWorkingDirectory">

The checkout directory one Attempt runs in.