UNPKG

@code-yeongyu/senpi

Version:

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

58 lines • 3.06 kB
/** * What stands between a parsed command and the session router on a multi-session host: the * conditional idle handover's own request (`begin_handover`), the admission gate it closes on new * work, the per-session in-flight count the idle judgement reads, and the runtime identity * `get_protocol_info` reports. A host without hooks routes every command exactly as before. */ import { HostIdleHandover, type HostIdleHandoverOptions } from "./host-idle-handover.ts"; import type { RpcCommand, RpcResponse } from "./rpc-types.ts"; import type { RpcSessionRegistry } from "./session-registry.ts"; export interface HostCoreHooks { /** The runtime this host loaded at startup, reported by `get_protocol_info`. */ readonly runtimeBuildId?: string; /** Present on a host that can hand over at its next idle point (a POSIX socket host). */ readonly handover?: Omit<HostIdleHandoverOptions, "isIdle">; /** This host's agent dir and public socket: a `begin_handover` naming another agent dir is refused (#3560). */ readonly endpoint?: { readonly agentDir: string; readonly socket: string; }; /** Called with the in-process registry's session count after every open and close. */ readonly onSessionCountChange?: (size: number) => void; /** * Gate on the handover-parked reopen watch: returns false once this host is draining, so a * predecessor never reopens into its own registry a session it just parked for its successor * (senpi#3282). When omitted the watch always reopens. */ readonly shouldReopenParked?: () => boolean; /** * Work outside the session registry (`machine_op` ops and terminals, senpi#6752): it keeps the host from being idle, * and is held from the idle check that starts a handover's switch until that handover is blocked. */ readonly machineWork?: MachineWorkGate; } export interface MachineWorkGate { busy(): boolean; hold(): void; release(): void; } export declare class HostCoreGate { readonly handover: HostIdleHandover | undefined; private readonly runtimeBuildId; private readonly endpoint; private readonly inFlight; private readonly answering; private readonly route; constructor(registry: Pick<RpcSessionRegistry, "list" | "peek">, route: (command: RpcCommand) => Promise<RpcResponse | undefined>, hooks: HostCoreHooks); /** Answers a `begin_handover` record through `deliver` and returns true, or returns false for anything else. */ intercept(parsed: unknown, deliver: (answer: object) => Promise<void>): Promise<boolean>; private answerBegin; /** * Settles once every `begin_handover` being answered has its answer. A host idle at once drains * the moment its successor takes the socket, and its shutdown waits here so the caller that asked * is told the outcome instead of reading a closed connection. */ answered(): Promise<void>; dispatch(command: RpcCommand): Promise<object | undefined>; } //# sourceMappingURL=host-core-gate.d.ts.map