@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
46 lines • 2.88 kB
TypeScript
import type { HostCallHandler } from "../../modes/rpc/tool-child/host-calls-server.ts";
import type { ToolChildModuleJob } from "./tool-dispatcher.ts";
/** What `InProcessToolDispatcher` gives every in-process module run. */
export interface InProcessModuleRuntime {
/** The session's host-call handler; unset, every host call fails `tool_runtime_unavailable`. */
readonly hostCalls?: HostCallHandler;
/** How long past its deadline a module may keep running before it is reported stuck (default 10 s). */
readonly stuckGraceMs?: number;
/**
* Told when a module is stuck (past its deadline and grace: it keeps its locks, and every waiter on them fails fast),
* or still running a grace after its session closed (its locks were released with the session).
*/
readonly onStuck?: (notice: StuckModuleNotice) => void;
/** The live runs; the dispatcher ends them all (cancelled, host calls refused, locks released) when the session is closed or replaced. */
readonly live?: Set<InProcessRun>;
}
export interface StuckModuleNotice {
readonly modulePath: string;
readonly export: string;
readonly deadlineMs: number;
/** The files whose locks it still holds (as the module named them). */
readonly files: readonly string[];
/** What to show the user. */
readonly notice: string;
}
/** A live in-process run, as the dispatcher sees it. */
export interface InProcessRun {
/**
* The session is closed or replaced. A run still loading its module never starts its body. A running module is
* cancelled and every further host call it makes is refused (`host_call_session_closed`); this settles once its locks
* are released - when its body settles, at once if it is already stuck, or after the grace (then reported).
*/
close(): Promise<void>;
}
/**
* The in-process path: imports the module and runs its export with `(args, host)`, awaited - the same host the tool
* child's worker builds, its calls answered by the session's host-call handler. Its deadline is the child's (the
* caller's value, at most `OFFLOAD_MAX_MS`). Code in this process cannot be stopped, so past the deadline the module
* keeps its locks - releasing one could let a second writer interleave with a write still in flight - and after a grace
* it is reported stuck: every waiter on its locks fails fast, until it finishes or the session is closed. The run is
* registered with the session before its module loads, so a close during the load leaves the body unstarted. The
* dynamic import is the feature itself (a registered module is loaded on first use), the documented exception to
* top-level imports.
*/
export declare function runModuleInProcess(job: ToolChildModuleJob, signal: AbortSignal | undefined, runtime?: InProcessModuleRuntime): Promise<unknown>;
//# sourceMappingURL=in-process-module.d.ts.map