@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
42 lines • 2.43 kB
TypeScript
import type { RpcCommand, RpcResponse } from "./rpc-types.ts";
import type { RpcSessionBinding } from "./session-binding.ts";
import type { RouterContext } from "./session-router-context.ts";
import type { CloseClaimOptions } from "./session-router-types.ts";
/**
* Releases one attachment (or every attachment when draining) and reports
* whether this caller became the finalizer. The join token is installed inside
* the registry callback, before any await, so a close that lands between the
* claim and finalizeClose() always finds a token to wait on instead of
* answering ahead of the terminal records.
*/
export declare function claimClose(host: RouterContext, sessionId: string, options: CloseClaimOptions): {
finalizer: boolean;
};
/** claimClose() for lifecycle paths that treat a lost race as "nothing to do". */
export declare function tryClaimClose(host: RouterContext, sessionId: string, options: CloseClaimOptions): {
finalizer: boolean;
} | undefined;
export declare function close(host: RouterContext, command: Extract<RpcCommand, {
type: "close_session";
}>): Promise<RpcResponse | undefined>;
/**
* Runs the finalizer side of a close for a handle whose beginClose() made this
* caller the owner: dispose the binding, complete the registry teardown, emit
* the terminal records, then release joiners. Every step is guarded so the join
* token always resolves and a failing binding yields one logged line, never a
* second response or an escaped rejection.
*/
export declare function finalizeClose(host: RouterContext, sessionId: string, binding: RpcSessionBinding | undefined, terminal?: () => void): Promise<void>;
export declare function createFinalization(): {
promise: Promise<void>;
resolve: () => void;
};
/**
* The park teardown of `evictIdleSession`, claimed synchronously and sealed as released: every
* attachment is drained, the runtime disposed and the path reservation freed before this resolves.
*/
export declare function tearDownReleased(host: RouterContext, sessionId: string, sessionPath: string): Promise<boolean>;
/** The idle park on request: every attachment drained, sealed `session_parked { reason: "unloaded" }`. */
export declare function tearDownUnloaded(host: RouterContext, sessionId: string, sessionPath: string): Promise<boolean>;
export declare function dispose(host: RouterContext): Promise<void>;
//# sourceMappingURL=session-router-close.d.ts.map