@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
37 lines • 1.93 kB
TypeScript
import type { AbandonedWorkerCount } from "./path-identity-breaker.ts";
import type { ResolverReply, ResolverSnapshotMessage } from "./path-identity-protocol.ts";
import type { ResolverTransport } from "./path-identity-transport.ts";
interface WorkerHandle {
readonly transport: ResolverTransport;
live: boolean;
started: boolean;
}
export interface WorkerLifecycleDeps {
readonly spawn: () => ResolverTransport;
readonly abandoned: AbandonedWorkerCount;
onSnapshot(message: ResolverSnapshotMessage): void;
onReply(reply: ResolverReply): void;
/** Every pending request is rejected with this detail when the serving worker is gone. */
rejectAll(detail: string): void;
/** Called once when a worker fails before it ever started; the lifecycle is then permanently unavailable. */
onUnavailable(detail: string): void;
}
export interface WorkerLifecycle {
readonly unavailable: string | undefined;
readonly live: ResolverTransport | undefined;
/** The live transport, spawning one when none is live and the cap and the unavailable state allow it. */
ensure(): ResolverTransport | undefined;
/** Rejects every pending request, drops the worker and tracks its termination as possibly abandoned. */
retire(detail: string): void;
/** Drops every worker and marks the lifecycle unavailable, once. */
markUnavailable(detail: string): void;
drop(): WorkerHandle | undefined;
}
/**
* A worker that fails before publishing its first snapshot never started: a missing or broken module,
* not a wedge. That is permanent, so it is reported once and every request is answered at once with
* EUNAVAILABLE instead of waiting out a deadline; the service then keeps path rules on their literal routes.
*/
export declare function createWorkerLifecycle(deps: WorkerLifecycleDeps): WorkerLifecycle;
export {};
//# sourceMappingURL=path-identity-worker-lifecycle.d.ts.map