API Reference

Sessions

Session methods, input and event contracts, seeds, recorders, deferred work, and observers.

Session

Access: @nylorun/harnessSession

MemberParameters or typeReturnsDescription
idstringSession identifier.
stateSessionSnapshotCurrent lifecycle state, transcript, pending interaction, and active work.
input(event, options?)SessionInput, optional InputOptionsInputHandleSubmits user text or a correlated approval/response reply.
interrupt(event, options?)MessageInput, optional InputOptionsInputHandleSubmits barge-in text.
continue(options?)optional InputOptionsInputHandleContinues deferred work.
stream()NoneAsyncIterable<SessionEvent>Reads normalized session events.
observe(listener)Observer() => voidSubscribes to live lifecycle observations; returns an unsubscribe function.
stop(reason?)optional stringPromise<void>Stops the session.

InputOptions has an optional signal: AbortSignal. InputHandle has an inputId and a completed promise resolving to InputCompletion with its final status and emitted events.

Run options and seeds

Access: @nylorun/harnessSessionRunOptions, SessionOptions, SeededSessionOptions, SessionSeed

NameTypeRequiredDescription
SessionOptions.idstringNoHost-assigned session id; Harness generates one when omitted.
SessionOptions.userIdstringNoHost-owned user identity.
SessionOptions.contextJsonObjectNoHost-owned JSON session context.
SessionOptions.recorderSessionRecorderNoReceives each canonical session transition.
SeededSessionOptions.seedSessionSeedYesRestores identity, counters, and canonical transcript.
SeededSessionOptions.recorderSessionRecorderNoRecords transitions after reconstruction.

A seed can contain id, userId, context, turnCount, revision, and required transcript. Do not mix seeded options with top-level id, userId, or context.

Inputs, snapshots, and records

Access: @nylorun/harnessSessionInput, MessageInput, InteractionReply, SessionSnapshot, SessionRecord, SessionRecorder

TypeFields or variantsDescription
MessageInputtext string, or text plus optional JSON metadataOrdinary user message.
InteractionReplyapprove or respond input eventCorrelated reply to a required interaction.
SessionSnapshotid, status, turn count, revision, transcript, pending interaction, active workCurrent in-memory state.
SessionRecordversion, revision, transition, session, transcript, optional active recordCanonical persistence record for one transition.
SessionRecorderrecord(value: SessionRecord)Host persistence callback.

Events and active execution

Access: @nylorun/harnessSessionEvent, ObserveEvent, ActiveExecutionRecord, ActiveModelExecutionRecord, ActiveToolsExecutionRecord, ActiveInteractionExecutionRecord

Event or recordDescription
SessionEventNormalized input, candidate, final, interaction-required, tripwire, deferred, queue, rejection, cancellation, and stopped events.
ObserveEventDetailed live lifecycle observations for configuration, model, middleware, tools, interactions, recording, and stopping.
ActiveModelExecutionRecordActive model invocation and the projected call.
ActiveToolsExecutionRecordActive tool-call set and individual settlement state.
ActiveInteractionExecutionRecordPending interaction plus resumable tool execution.

Every active record includes the ids necessary for durable host persistence. Deferred outcomes may add a JSON token that the host uses to correlate external work before calling continue().

On this page