UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

40 lines • 2.54 kB
/** * Waits on the device route (row CK9; custody design 2.3 "Pause = tracked local work", 4.2 live digests, 4.4). A wait * is never a thrown value: it is bracketed by the host's `onWait`/`onWaitEnd` (W7, `step.waiting`) and held in the * stream's `trackLocalWork`, so the loop's idle watchdog re-arms instead of failing the step. A user abort releases the * wait at once. */ import type { DeviceId, EgressHostHooks, EgressWait, ProviderId, StepRef, WaitCondition } from "@earendil-works/pi-agent-core"; import type { AssistantMessageEventStream } from "@earendil-works/pi-ai"; import type { HandPresence } from "./wire.ts"; export interface EgressClock { now(): number; /** Resolves after `ms`, or rejects with the signal's reason once it aborts. */ sleep(ms: number, signal: AbortSignal): Promise<void>; } export interface WaitConditionSource { /** Resolves once any of `waitFor` holds (device online, user choice made, ...), or rejects when `signal` aborts. */ until(waitFor: readonly WaitCondition[], signal: AbortSignal): Promise<void>; } /** A promise that rejects with the abort reason as soon as `signal` aborts; it never resolves. */ export type Abortion = (signal: AbortSignal) => Promise<never>; /** * One promise (and one listener) per signal, however many waits race it: an indefinite key backoff must not pile up * abort listeners. The registry belongs to its owner (one egress, one board), never to the module. */ export declare function createAbortion(): Abortion; export interface StepWaits { /** Holds `work` as a tracked wait of the current step until it settles. */ hold<T>(wait: Omit<EgressWait, "call">, work: Promise<T>): Promise<T>; } export declare function stepWaits(stream: AssistantMessageEventStream, host: EgressHostHooks, step: StepRef, signal: AbortSignal, abortion: Abortion): StepWaits; /** Registry-key backoff while the hand cannot check the key: 5 s doubling to a 5 minute cap, indefinitely (4.6). */ export declare const nextKeyBackoffMs: (previous: number | undefined) => number; export interface LiveDigestBoard { report(presence: HandPresence): void; digest(deviceId: DeviceId, providerId: ProviderId): string | undefined; /** Resolves with the new digest the next time the device reports a value DIFFERENT from its last one (4.2). */ changed(deviceId: DeviceId, providerId: ProviderId, signal: AbortSignal): Promise<string>; } export declare function createLiveDigestBoard(): LiveDigestBoard; //# sourceMappingURL=device-proxy-waits.d.ts.map