Skip to content

@usine/core/agent/session

A coding session delegated by the Attempt’s parent; children cannot delegate to further children.

  • Schema.Class

new ChildSession(…args): ChildSession

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

ChildSession

readonly agent: string & Brand<"AgentName">

readonly brain: BrainSpec

readonly id: string & Brand<"AgentSessionId">

readonly parentId: string & Brand<"AgentSessionId">


A saved harness conversation and the worker checkout from which it can be resumed.

  • Schema.Class

new HarnessSession(…args): HarnessSession

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

HarnessSession

readonly cwd: string

readonly id: string & Brand<"HarnessSessionId">


The session coordinating an Attempt and delegating work to its coding children.

  • Schema.Class

new ParentSession(…args): ParentSession

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

ParentSession

readonly agent: string & Brand<"AgentName">

readonly brain: BrainSpec

readonly id: string & Brand<"AgentSessionId">


The latest rate windows observed for a billing pool during one session.

  • Schema.Class

new PoolRateLimitsUpdated(…args): PoolRateLimitsUpdated

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

PoolRateLimitsUpdated

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

readonly rateLimits: RateLimitsSnapshot

readonly session: ChildSession | ParentSession


The allowance windows reported together by a provider; omitted windows remain unknown.

  • Schema.Class

new RateLimitsSnapshot(…args): RateLimitsSnapshot

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

RateLimitsSnapshot

readonly limitId: Option<string>

readonly limitName: Option<string>

readonly primary: Option<RateLimitWindow>

readonly secondary: Option<RateLimitWindow>


A billing pool’s observed usage for one allowance window.

  • Schema.Class

new RateLimitWindow(…args): RateLimitWindow

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

RateLimitWindow

readonly resetsAt: Option<Utc>

When the allowance resets; absent when the provider omits it.

readonly usedPercent: number

Percentage of the allowance already consumed, including usage outside this Attempt.

readonly windowDurationMinutes: Option<number>

Length of the allowance window; absent when the provider omits it.


Marks the end of a session’s activity in the transcript; the Attempt’s outcome is recorded separately.

  • Schema.Class

new SessionFinished(…args): SessionFinished

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

SessionFinished

readonly session: ChildSession | ParentSession


A supervised session finished a turn and remains available for further operator messages.

  • Schema.Class

new SessionIdle(…args): SessionIdle

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

SessionIdle

readonly session: ChildSession | ParentSession


A live session is processing another user turn in the same conversation.

  • Schema.Class

new SessionResumed(…args): SessionResumed

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

SessionResumed

readonly session: ChildSession | ParentSession


Records the session identity and brain actually selected at launch.

  • Schema.Class

new SessionStarted(…args): SessionStarted

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

SessionStarted

readonly harnessSession: Option<HarnessSession>

Absent for older transcripts and harnesses without a saved conversation.

readonly session: ChildSession | ParentSession


Cumulative TokenCount consumed by this session so far, including its later operator turns.

  • Schema.Class

new SessionTokensUpdated(…args): SessionTokensUpdated

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

SessionTokensUpdated

readonly session: ChildSession | ParentSession

readonly totalTokens: number & Brand<"TokenCount">


Completed assistant text emitted during the session, which may precede its final result.

  • Schema.Class

new TextOutput(…args): TextOutput

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

TextOutput

readonly session: ChildSession | ParentSession

readonly text: string


A tool call returned its output; a tool error does not by itself close the session.

  • Schema.Class

new ToolFinished(…args): ToolFinished

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

ToolFinished

readonly callId: string

readonly isError: boolean

readonly output: Json

readonly session: ChildSession | ParentSession

readonly tool: string


A session began a tool call; callId pairs it with the corresponding result.

  • Schema.Class

new ToolStarted(…args): ToolStarted

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

ToolStarted

readonly callId: string

readonly input: Json

readonly session: ChildSession | ParentSession

readonly tool: string

AgentSession = typeof AgentSession.Type

A participant in an Attempt, with its role, Agent, and effective brain recorded.


AgentSessionEvent = typeof AgentSessionEvent.Type

Session activity and billing observations recorded in an Attempt’s transcript.


AgentSessionId = typeof AgentSessionId.Type

Identity usine assigns to a parent or child session within an Attempt.


BillingPool = typeof BillingPool.Type

The billing source whose meter produced a usage or rate-limit observation.


ChildSessionBudget = typeof ChildSessionBudget.Type

Maximum child sessions one Attempt may spawn over its lifetime, including sequential spawns.


ChildSessionCount = typeof ChildSessionCount.Type

The 1-based child spawn request number within an Attempt, including requests rejected by the budget.


HarnessSessionId = typeof HarnessSessionId.Type

The identity assigned by a harness to its saved conversation, distinct from usine’s session id.


TokenCount = typeof TokenCount.Type

Tokens a session consumed: output tokens plus uncached input tokens (new prompt text and cache writes). Cache reads are excluded, so the count grows with work done rather than with the length of the conversation re-read on every turn. Each harness computes it from its own usage report.

const AgentSession: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>

A participant in an Attempt, with its role, Agent, and effective brain recorded.


const AgentSessionEvent: Schema.Union<readonly [typeof SessionStarted, typeof TextOutput, typeof ToolStarted, typeof ToolFinished, typeof PoolRateLimitsUpdated, typeof SessionFinished, typeof SessionIdle, typeof SessionResumed, typeof SessionTokensUpdated]>

Session activity and billing observations recorded in an Attempt’s transcript.


const AgentSessionId: Schema.brand<Schema.NonEmptyString, "AgentSessionId">

Identity usine assigns to a parent or child session within an Attempt.


const BillingPool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>

The billing source whose meter produced a usage or rate-limit observation.


const ChildSessionBudget: Schema.brand<Schema.Int, "ChildSessionBudget">

Maximum child sessions one Attempt may spawn over its lifetime, including sequential spawns.


const ChildSessionCount: Schema.brand<Schema.Int, "ChildSessionCount">

The 1-based child spawn request number within an Attempt, including requests rejected by the budget.


const HarnessSessionId: Schema.brand<Schema.NonEmptyString, "HarnessSessionId">

The identity assigned by a harness to its saved conversation, distinct from usine’s session id.


const TokenCount: Schema.brand<Schema.Int, "TokenCount">

Tokens a session consumed: output tokens plus uncached input tokens (new prompt text and cache writes). Cache reads are excluded, so the count grows with work done rather than with the length of the conversation re-read on every turn. Each harness computes it from its own usage report.