@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
68 lines • 4.27 kB
TypeScript
import type { RpcHostLifecycleEvent, RpcOpenQueuedEvent } from "./rpc-types.ts";
import type { SecretInputRoute } from "./secret-input-requests.ts";
import { SessionEventWriterDestinations } from "./session-event-writer-destinations.ts";
export type { SessionEventWriterConnection } from "./session-event-connection.ts";
export { MAX_SHARED_STDIO_QUEUE_BYTES, MAX_SHARED_STDIO_QUEUE_RECORDS } from "./session-event-writer-lanes.ts";
/**
* Process-wide stdout scheduler for multi-session RPC mode.
*
* Each queue contains complete structured JSONL records for one routing handle.
* Draining takes one record per queue in round-robin order and waits for stdout
* backpressure before selecting the next one. A record is deliberately written
* by itself: coalescing records from different sessions would obscure the
* scheduling boundary and violate D9.
*/
export declare class SessionEventWriter extends SessionEventWriterDestinations {
secretInputRoute(sessionId: string, sealed?: boolean): SecretInputRoute;
setSoleSecretCapabilities(capabilities: readonly string[]): void;
/** Queue a session record. Content events target connections attached to the session. */
enqueue(sessionId: string, value: object): boolean;
/**
* One `loaded_surfaces_changed` per connection per inventory transition: sessions moving from the
* same digest to the same new one share a single event, tagged with the first session that
* reported it; a session converging from a different start still announces its own change.
*/
publishLoadedSurfacesChanged(sessionId: string, previous: string | undefined, digest: string): void;
/** Queue one untagged host-control response for the given connection (defaults to the current one). */
enqueueControl(value: object, targetOverride?: string): Promise<void>;
/**
* Queue one HOST-level lifecycle record for every registered connection, or the
* shared stdio lane when none is registered. Unlike session records it is not tagged
* with a routing handle by the writer: `host_stalled` carries the handle it blames,
* and `host_memory_pressure` belongs to the process, not to a session.
*/
/**
* Tell ONE opener where it sits in the open queue, before its open reaches the loop.
*
* Sent to the opening connection only: a queue position is about that caller's request, not
* about the host. If the connection is gone the record is dropped rather than queued - a
* position is worthless to a client that already left.
*/
sendOpenQueued(connection: string, record: RpcOpenQueuedEvent): void;
broadcastHostRecord(record: RpcHostLifecycleEvent): void;
/**
* Seal a session the host PARKED and publish `session_parked`.
*
* Parking is the idle sweep putting a RETAINED session back on disk: the routing
* handle ends exactly as a close ends it, but the session survives and reopens with
* `open_session { sessionPath }`, so the record a client dispatches on must say so
* instead of claiming the session ended. Delivery follows the `session_closed` rule -
* a worker session's record reaches only its attached connections, an interactive
* session's reaches every connection. No client asked for this teardown, so there is
* no close response to answer.
*/
parkSession(sessionId: string, sessionPath: string, reason: "idle" | "unloaded" | "host_shutdown"): void;
/**
* Seal a session `release_session` handed to a runtime outside this host and publish
* `session_closed { reason: "released", sessionPath }`. Unlike a park the file must NOT be reopened
* here - another process now writes it. Delivered like a park; the releasing caller's own answer is
* the `release_session` response, so there is no close response either.
*/
releaseSession(sessionId: string, sessionPath: string): void;
/**
* Publishes the settles a seal would strand (session-open-turns.ts) while the session can still write;
* false when the session is sealed already, or became sealed by a settle that overflowed the stdio lane.
*/
protected settleBeforeSeal(sessionId: string): boolean;
}
//# sourceMappingURL=session-event-writer.d.ts.map