Skip to content
Developer Preview

SessionFold

The whole client-side session view: items, session state, turns, and the pending approval/user-input sets.

Property Type Stability Presence Description
activeTurnId string | undefined required The turn currently running, if one is.
current boolean required Is this fold current with the session view?
items FoldItems required Items, snapshot-only: the mutators are apply()’s, not the consumer’s.
pendingGap object | undefined required The outstanding delivery hole, or undefined when there is none.
sessionState FoldSessionState required The session-state families, keyed by notification method name. Named sessionState rather than state because the surface contract reserves state for the aggregate that arrives with snapshot ingestion. Snapshot-only, like items.
Method Signature Stability Description
constructor new SessionFold()
apply apply(event: ViewEvent): FoldOutcome Fold one view event.
apply apply(event: object): FoldOutcome Fold one view event.
gapFilled gapFilled(next: string): boolean A recovery filled the hole up to next. Returns whether it cleared.
markEphemeralHostDeath markEphemeralHostDeath(isInProgress: (item: Item) => boolean): readonly TerminalUnknownItemAnnotation[] Discharge the ephemeral host-death obligation over the item half: every item still in progress becomes terminal-unknown and the fold refuses further events.
pendingApprovals pendingApprovals(): readonly object[] Approvals awaiting a durable terminal, in first-observed order.
pendingUserInputs pendingUserInputs(): readonly object[] Prompts awaiting a durable settlement, in first-observed order. The entries ARE the generated request params — the wire shape already carries userInputId, so a wrapper would only duplicate it (unlike PendingApproval, which earns its wrapper with latestUpdate).
resolvedApprovals resolvedApprovals(): readonly object[] The winning durable terminal per approval, in first-observed order.
settledUserInputs settledUserInputs(): readonly object[] The winning durable settlement per prompt, in first-observed order.
turn turn(turnId: string): object | undefined
turns turns(): readonly object[] Turns in first-observed order.
Source

clients/sdk-ts/src/fold/session-fold.ts:383

{
"kind": "Class",
"canonicalPath": "SessionFold"
}