UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

50 lines • 3.06 kB
import type { RpcSessionClosedEvent, RpcSessionClosedReason, RpcSessionParkedEvent } from "./rpc-types.ts"; import { SessionEventWriterPresenters } from "./session-event-writer-presenters.ts"; import { type SessionStatusActor } from "./session-status.ts"; import { type SessionOpenedRecord } from "./session-status-opened.ts"; /** Session lifecycle: `session_opened`, close, seal, close-reply admission and forgetting a handle. */ export declare abstract class SessionEventWriterLifecycle extends SessionEventWriterPresenters { /** Who caused a change: the client whose command is being dispatched, else `fallback`. */ protected changeActor(fallback: SessionStatusActor): SessionStatusActor; /** * Publish `session_opened` for a session this host just created. Interactive sessions broadcast it (the * lifecycle whitelist); a worker's reaches only its attached connections and subscribers that asked for * workers (invariant I4). `context` travels only to subscribers that asked for it. */ publishSessionOpened(record: SessionOpenedRecord): void; /** * Prevent subsequent records for a session and append its terminal response. * Existing records retain FIFO order; this response is therefore that * session's final stdout record. */ closeSession(sessionId: string, response: object, reason?: RpcSessionClosedReason, sessionPath?: string): void; /** * Seal a session whose open rolled back after `session_opened` was published, so subscribers get * its terminal record. The opener's answer is its own failed `open_session`; like a park, no close * response is owed to anyone. */ sealRolledBackOpen(sessionId: string, sessionPath: string | undefined): void; sealLifecycle(sessionId: string, lifecycle: RpcSessionParkedEvent | RpcSessionClosedEvent, attachedOnly?: boolean): void; private sealStatus; /** * Admit reply debt before routing can mutate attachments or await finalization. * Reserve the lifecycle as well: the claimant's role is not known yet. Rejected * closes do not wait, retain their ids, or create per-request stderr output. */ reserveCloseResponse(sessionId: string, response: object, records?: number): { release: () => void; complete: (terminal: boolean, reason?: RpcSessionClosedReason) => void; } | undefined; /** Queue a joined close only after admitting its noncompactable reply. */ enqueueClosedResponse(sessionId: string, response: object): void; private appendClosedResponse; /** * Drops per-session bookkeeping for a handle whose runtime is fully disposed. * Routing handles are unique per process epoch, so nothing can legitimately * emit under this id again; without this every host-closed session would * leave a permanent sealed-handle (and snapshot) entry behind. */ forgetSession(sessionId: string): void; protected abstract settleBeforeSeal(sessionId: string): boolean; } //# sourceMappingURL=session-event-writer-lifecycle.d.ts.map