@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
48 lines • 3 kB
TypeScript
/**
* `session_relocation` (docs/rpc.md "Continuing a session on another computer"): the session asks the connection that
* offers relocation with `host_request`, only that connection's `host_response` counts, and an accepted move is
* announced to it with `relocation_due` once the run that asked for it settles. The engine never interrupts that run and
* never moves anything itself: the host runs the existing `release_session` reason `move` and `move_session` steps.
*/
import type { AgentSession } from "../../core/agent-session.ts";
import { type RelocationRequest, type RelocationRequestResult, type RelocationTargetsResult, type SessionRelocationHost } from "../../core/session-relocation.ts";
import type { RpcHostResponse } from "./rpc-types.ts";
import type { HostResponseOutcome, RelocationChannel } from "./session-relocation-channel.ts";
/** Longest the session waits for the host's answer before refusing the request itself. */
export declare const HOST_ANSWER_TIMEOUT_MS = 60000;
export interface RpcSessionRelocationDeps {
readonly session: Pick<AgentSession, "sessionFile" | "subscribe" | "isStreaming" | "currentAbortSource" | "sendCustomMessage" | "agent">;
/** `prompt` calls not yet returned; `release_session` counts them as a running turn (`busy: ["prompt"]`). */
readonly pendingPrompts: () => readonly Promise<unknown>[];
readonly channel: RelocationChannel;
}
export declare class RpcSessionRelocation implements SessionRelocationHost {
private readonly deps;
private readonly pending;
private readonly unsubscribe;
private scheduled;
private requesting;
private disposed;
private settling;
constructor(deps: RpcSessionRelocationDeps);
offered(): boolean;
targets(signal?: AbortSignal): Promise<RelocationTargetsResult>;
request(request: RelocationRequest, signal?: AbortSignal): Promise<RelocationRequestResult>;
/** Settles one `host_response`; only the connection the request went to may answer it. */
respond(frame: RpcHostResponse): HostResponseOutcome;
/** The connection `connectionId` left the session: what it accepted or was asked ends here, never later. */
connectionDetached(connectionId: string): void;
/**
* Refuses what is still waiting and resolves once every relocation tool call the run is executing has handed its
* answer to the agent. The session teardown aborts the run only after this resolves, so an answer that exists - a
* refusal from the client that left, or this `session_closed` - is the tool's result by construction, never
* `Tool execution aborted`, however many hops either path takes (senpi#5811).
*/
dispose(): Promise<void>;
private dropScheduled;
private settleRequest;
/** After the run settled, waits out the prompt calls behind it, so a `release_session` answering the notice finds the session quiet. */
private announceWhenReleasable;
private ask;
}
//# sourceMappingURL=session-relocation.d.ts.map