Skip to content

@usine/core/attempt/channel

Stops the entire Attempt, including every held or paused session. Used by cancellation and guardrails.

  • Schema.Class

new Cancel(…args): Cancel

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

Cancel


A harness child of the Attempt’s parent, addressed by the id it reports in the normalized event stream.

  • Schema.Class

new ChildTarget(…args): ChildTarget

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

ChildTarget

readonly sessionId: string & Brand<"AgentSessionId">


  • Schema.Class

new Failed(…args): Failed

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

Failed

readonly failure: InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure


  • Schema.Class

new Final(…args): Final

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

Final

readonly result: StepResult


  • Schema.Class

new InboundEnvelope(…args): InboundEnvelope

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

InboundEnvelope

readonly attemptId: string & Brand<"AttemptId">

readonly operator: string

readonly payload: Steer | Interrupt | OperatorMessage | Release | Cancel

readonly sentAt: Utc

readonly sequence: number & Brand<"AttemptChannelSequence">

readonly target: ParentTarget | ChildTarget

The session this envelope addresses; the Pi parent unless a child is named.

readonly version: 7


  • Schema.Class

new Interrupt(…args): Interrupt

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

Interrupt


The Attempt’s parent acknowledged cancellation. Terminal.

  • Schema.Class

new Interrupted(…args): Interrupted

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

Interrupted


Attributed operator input addressed to one live session, never an Event.

  • Schema.Class

new Intervention(…args): Intervention

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

Intervention

readonly action: Steer | Interrupt | OperatorMessage | Release

readonly operator: string

readonly target: ParentTarget | ChildTarget


Acknowledges delivery and records the resulting Hold or pause in the transcript.

  • Schema.Class

new InterventionApplied(…args): InterventionApplied

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

InterventionApplied

readonly inputSequence: number & Brand<"AttemptChannelSequence">

readonly intervention: Intervention

readonly state: InterventionState


A session closed or refused an operator action; the Attempt itself continues.

  • Schema.Class

new InterventionRejected(…args): InterventionRejected

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

InterventionRejected

readonly inputSequence: number & Brand<"AttemptChannelSequence">

readonly intervention: Intervention

readonly message: string


The session’s supervision state after an accepted operator action.

  • Schema.Class

new InterventionState(…args): InterventionState

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

InterventionState

readonly held: boolean

readonly paused: boolean


An operator turn joined to the target session, distinct from a Steer so a takeover can record and hold it (ADR 0018).

  • Schema.Class

new OperatorMessage(…args): OperatorMessage

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

OperatorMessage

readonly message: string


  • Schema.Class

new OutboundEnvelope(…args): OutboundEnvelope

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

OutboundEnvelope

readonly attemptId: string & Brand<"AttemptId">

readonly payload: Started | SessionEvent | Final | Failed | Interrupted | InterventionApplied | InterventionRejected

readonly sentAt: Utc

readonly sequence: number & Brand<"AttemptChannelSequence">

readonly version: 7


The Pi parent, the default recipient of operator input for an Attempt.

  • Schema.Class

new ParentTarget(…args): ParentTarget

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

ParentTarget


Ends a held child’s takeover, letting its idle result return to the awaiting parent (ADR 0018).

  • Schema.Class

new Release(…args): Release

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

Release


Launch input for one Attempt. Worker credentials are never part of it.

  • Schema.Class

new RunSpec(…args): RunSpec

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

RunSpec

readonly agent: Agent

readonly attemptId: string & Brand<"AttemptId">

readonly baseCommit: string & Brand<"CommitSha">

readonly maxChildren: number & Brand<"ChildSessionBudget">

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

readonly parentModel: Option<string & Brand<"ModelId">>

readonly payload: Json

readonly repository: string & Brand<"RepositoryName">

readonly resume: Option<SalvagePushed>

The previous Attempt’s pushed salvage checked out in this workspace; the agent continues from it.

readonly revision: string & Brand<"RepositoryRevision">

readonly task: string & Brand<"AttemptTask">


One normalized parent or child session event, persisted in the Attempt transcript.

  • Schema.Class

new SessionEvent(…args): SessionEvent

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

SessionEvent

readonly event: SessionStarted | TextOutput | ToolStarted | ToolFinished | PoolRateLimitsUpdated | SessionFinished | SessionIdle | SessionResumed | SessionTokensUpdated


The parent model the SDK selected at launch, which the roster may not declare. Child sessions report their own model in SessionStarted events.

  • Schema.Class

new Started(…args): Started

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

Started

readonly parentModel: string & Brand<"ModelId">


  • Schema.Class

new Steer(…args): Steer

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

Steer

readonly message: string

How far one outbound channel has legally progressed.

readonly nextSequence: number

readonly state: "AwaitingStarted" | "Running" | "Terminal"


Where a channel consumer persists envelopes and the executor’s salvage record.

readonly append: (direction, envelope) => Effect<void, InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure>

Parameter Type
direction "inbound" | "outbound"
envelope OutboundEnvelope | InboundEnvelope

Effect<void, InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure>

readonly salvage: (salvage) => Effect<void, InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure>

Records what the executor preserved of the workspace after the Attempt ended without success.

Parameter Type
salvage SalvagePushed | SalvageRetained

Effect<void, InfraFailure | DefectFailure | AgentFailure | RunawayFailure | ChildSessionBudgetFailure>


One protocol violation, described for the infra failure that reports it.

readonly detail: string

readonly message: string

Direction = typeof Direction.Type


Envelope = typeof Envelope.Type


InboundPayload = typeof InboundPayload.Type


OperatorAction = typeof OperatorAction.Type

Nonterminal operator controls; cancellation is an Attempt operation.


OutboundPayload = typeof OutboundPayload.Type


Sequence = typeof Sequence.Type

Per-Attempt, per-direction message sequence, starting at 1. Distinct from the engine’s transcript sequence, which orders persisted rows globally.


SessionTarget = typeof SessionTarget.Type

Which session inside an Attempt an inbound envelope addresses: the Pi parent, or one of its children.

const admit: (progress, attemptId, envelope) => Result.Result<Progress, Violation>

Checks one outbound envelope against the progress so far and returns the next progress, or the violation. Whatever sends outbound envelopes folds each one through it before appending it.

Parameter Type
progress Progress
attemptId AttemptId
envelope OutboundEnvelope

Result.Result<Progress, Violation>


const Direction: Schema.Literals<readonly ["inbound", "outbound"]>


const DIRECTIONS: readonly ["inbound", "outbound"]

Relative to the Attempt’s parent: inbound envelopes carry operator input and Cancel to it, and outbound envelopes carry its activity and outcome.


const Envelope: Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>


const InboundPayload: Schema.Union<readonly [Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>, typeof Cancel]>


const initialProgress: Progress


const OperatorAction: Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>

Nonterminal operator controls; cancellation is an Attempt operation.


const OutboundPayload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted, typeof InterventionApplied, typeof InterventionRejected]>


const PROTOCOL_VERSION: 7


const Sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">

Per-Attempt, per-direction message sequence, starting at 1. Distinct from the engine’s transcript sequence, which orders persisted rows globally.


const SessionTarget: Schema.Union<readonly [typeof ParentTarget, typeof ChildTarget]>

Which session inside an Attempt an inbound envelope addresses: the Pi parent, or one of its children.