@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
44 lines • 2.5 kB
TypeScript
/**
* The tool child's main loop (senpi#3566, plan todo 4). It reaches its server only through the private channel, runs
* each `job` frame through the handler registered for its kind, and exits when the server goes away (parent-watch),
* so a child can never outlive the session that owns it. It loads no session, provider, extension or MCP scope: the
* server is the single writer of every session file.
*/
import { type ToolChildChannel } from "./channel.ts";
import { type HostCallTarget } from "./host-calls-child.ts";
import { LaunchGate } from "./launch-gate.ts";
export declare const TOOL_CHILD_GENERATION_ENV = "SENPI_TOOL_CHILD_GENERATION";
/** 2: `hello` carries the child's `jobKinds` manifest. */
export declare const TOOL_CHILD_PROTOCOL_VERSION = 2;
export interface ToolChildJobContext {
readonly jobId: string;
readonly signal: AbortSignal;
readonly channel: ToolChildChannel;
readonly gate: LaunchGate;
/**
* A call to the server for this job (reverse bridge); settles with its reply, refusal or the job's cancel. A call made
* with `survivesCancel` is not settled by the cancel (a lock must be released after the job's writes stop, not when
* the cancel arrives); it still settles by its reply, its refusal or the channel closing.
*/
readonly hostCall: (target: HostCallTarget, options?: {
readonly survivesCancel?: boolean;
}) => Promise<unknown>;
/** Streams a partial result to the server in order; waits for credit when too many are unacknowledged. */
readonly update: (value: unknown) => Promise<void>;
/** This child's generation (the server's count of its spawns). */
readonly generation: number;
/**
* Tells the server something happened on this child outside any job's lifetime (a background session exited). The
* server hands it to the job definition whose kind is `source`. Never dropped: past the pending budget it waits.
*/
readonly wake: (source: string, value: unknown) => Promise<void>;
}
export type ToolChildJobHandler = (args: unknown, context: ToolChildJobContext) => Promise<unknown>;
export interface ToolChildEntryOptions {
readonly handlers: Readonly<Record<string, ToolChildJobHandler>>;
readonly env?: NodeJS.ProcessEnv;
readonly exit?: (code: number) => never;
}
export { ToolChildJobError } from "./entry-error.ts";
export declare function runToolChild(options: ToolChildEntryOptions): Promise<void>;
//# sourceMappingURL=entry.d.ts.map