@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
73 lines • 3.46 kB
TypeScript
import type { AgentSessionLaunchProfile, CreateAgentSessionRuntimeFactory } from "../../core/agent-session-runtime.ts";
import type { HostMcpRegistry } from "../../core/extensions/builtin/mcp/host-registry.ts";
import type { SessionContext, SessionKind } from "../../core/extensions/types.ts";
import type { RpcCommand, RpcResponse } from "./rpc-types.ts";
/** What a runtime factory needs to build a session's services without the session. */
export interface PrepareRuntimeOptions {
cwd: string;
agentDir: string;
mcpRegistry?: HostMcpRegistry;
launchProfile: Readonly<AgentSessionLaunchProfile>;
}
/** A runtime factory that can also build its cwd-bound services alone, for `warm`. */
export type PreparableRuntimeFactory = CreateAgentSessionRuntimeFactory & {
readonly prepare?: (options: PrepareRuntimeOptions) => Promise<void>;
readonly supportsCompact?: (profile?: AgentSessionLaunchProfile) => boolean;
};
/** The launch inputs that decide which extensions load, and so what a warm prepares. */
export interface HostWarmProfile {
cwd: string;
sessionKind?: SessionKind;
sessionContext?: SessionContext;
}
/** `warmed`: this call (or one it joined) loaded the profile. `already_warm`: an earlier one had. */
export type HostWarmState = "warmed" | "already_warm";
export type HostWarm = (profile: HostWarmProfile) => Promise<HostWarmState>;
/** Coalesces concurrent warms of one profile and answers repeats without loading again. */
export declare class HostWarmer {
private readonly warm;
private readonly loading;
private readonly load;
constructor(load: (profile: HostWarmProfile) => Promise<void>);
run(profile: HostWarmProfile): Promise<HostWarmState>;
/**
* Settles once every load of `cwd` in flight NOW has settled; `undefined` when none is. A snapshot: a warm
* that starts later, or one of another cwd, is not part of it.
*/
inFlight(cwd: string): Promise<void> | undefined;
private loadOnce;
}
/**
* The in-process registry's `warm`. The services are built inside their own provider scope, exactly
* like an open's, and the scope closes when they are dropped, so nothing an extension registered
* while loading outlives the warm.
*/
export declare function createRegistryWarm(prepare: NonNullable<PreparableRuntimeFactory["prepare"]>, host: {
agentDir: string;
mcpRegistry?: HostMcpRegistry;
}): {
readonly warm: HostWarm;
readonly inFlight: (cwd: string) => Promise<void> | undefined;
};
/** How an open's wait for the warms of its cwd ended. */
export type WarmWaitOutcome = "settled" | "warm_wait_deadline";
/**
* Waits for `warming` at most `boundMs`. A warm whose extension factory never settles (there is no factory
* timeout) must not stall an open, so past the bound the open proceeds and the reason is reported.
*/
export declare function waitForWarms(warming: Promise<void>, boundMs: number, cwd: string): Promise<WarmWaitOutcome>;
type WarmCommand = Extract<RpcCommand, {
type: "warm";
}>;
/**
* Answers one `warm`. The router calls this OUTSIDE its request accounting: a warm holds no session
* and no path, so neither a drain nor an idle window waits for it.
*/
export declare function answerWarm(command: WarmCommand, host: {
draining: boolean;
warm: HostWarm | undefined;
cwd: string;
hostContext: SessionContext | undefined;
}): Promise<RpcResponse>;
export {};
//# sourceMappingURL=host-warm.d.ts.map