import type { ContextAccessor } from "#context/key.js"; import type { HandleMessageStreamEvent } from "#protocol/message.js"; import type { Runtime } from "#channel/types.js"; import type { SessionAuth } from "#context/keys.js"; /** * Result of starting or delivering to a session. Exposes the session * `id`, its namespaced `continuationToken`, and `getEventStream`, which * resolves to a `ReadableStream` of the session's harness events * (optionally from `startIndex`). Returned by {@link SendFn}, * {@link GetSessionFn}, and a channel's `receive` hook. Unlike the live * {@link SessionHandle} on `ctx.session`, this is an inert result value: * its fields are snapshots and it cannot mutate the continuation token. */ export interface Session { readonly id: string; readonly continuationToken: string; getEventStream(options?: { startIndex?: number; }): Promise>; } /** * Live handle to the current session, exposed on `ctx.session` to * `deliver` and event handlers. The framework hydrates the read-only * fields from the active context at step start. A write through * {@link SessionHandle.setContinuationToken} updates the context so the * runtime can re-key the parked workflow hook at the next step boundary. */ export interface SessionHandle { readonly id: string; readonly continuationToken: string; readonly auth: SessionAuth; setContinuationToken(rawToken: string): void; } export declare function createSession(id: string, continuationToken: string, runtime: Runtime): Session; export declare function createGetSessionFn(runtime: Runtime): (sessionId: string) => Session; /** * Builds a live {@link SessionHandle} backed by the active context * accessor. Read-only fields resolve through getters so they reflect * any updates made by other handlers within the same step (e.g. the * `deliver` hook seeding `AuthKey` before an event handler reads * `session.auth`). * * Used by {@link buildAdapterContext} to populate `ctx.session` on * every adapter handler invocation. */ export declare function buildSessionHandle(accessor: ContextAccessor): SessionHandle;