UNPKG

@code-yeongyu/senpi

Version:

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

94 lines • 4.29 kB
export declare const TURN_DEADLINE_ENTRY_TYPE = "deadline-stop"; export interface TurnDeadlineSettings { readonly inactivityMs: number; readonly maxRuntimeMs: number; } /** Milliseconds the abort is given to terminalize before the lease forces settlement. */ export declare const TURN_DEADLINE_GRACE_MS = 10000; export declare const DEFAULT_TURN_INACTIVITY_MS = 3600000; export declare const MIN_TURN_INACTIVITY_MS = 60000; export declare const DEFAULT_TURN_MAX_RUNTIME_MS = 21600000; export type TurnDeadlineKind = "inactivity" | "max_runtime"; export interface TurnDeadline { readonly kind: TurnDeadlineKind; readonly limitMs: number; readonly elapsedMs: number; } /** * The recorded form of a deadline stop, durable on the session branch so a config reload * or session reopen keeps suppressing goal continuations until admitted user input. */ export interface DeadlineStopData { readonly kind: TurnDeadlineKind; readonly limitMs: number; readonly elapsedMs: number; readonly at: number; } interface DeadlineStopEntry { readonly type: string; readonly customType?: string; readonly data?: unknown; readonly message?: { readonly role?: string; }; } /** * The latest deadline stop on the branch, or undefined when none is pending. A * deadline-stopped session suppresses every automatic continuation until admitted user * input starts a new turn; the entry is read fresh so the hold survives reload and reopen. * Only a user message releases the hold: the aborted assistant message of the stopped * turn is persisted after the stop entry and must not clear it. */ export declare function deadlineStopPendingSinceLastTurn(entries: readonly DeadlineStopEntry[]): DeadlineStopData | undefined; export declare function resolveTurnDeadlineSettings(configured: { readonly turn_inactivity_ms?: unknown; readonly turn_max_runtime_ms?: unknown; }): TurnDeadlineSettings; /** * The narrow AgentSession surface the tracker needs, declared here so the tracker lives * with the rest of the deadline contract instead of inside agent-session.ts. */ export type TurnDeadlineWarning = "turn_deadline_record_failed" | "turn_deadline_abort_failed" | "turn_deadline_unsettled" | "turn_deadline_failed"; export interface DeadlineSessionOwner { _recordDeadlineStop(deadline: TurnDeadline): void; /** End the turn through the normal system abort (tools see the abort signal); resolves once the session is idle. */ abortTurnForDeadline(): Promise<void>; /** Stop waiting on extension handlers that still hold the turn; returns how many were released (senpi#3650). */ releaseHeldExtensionHandlers(): number; /** True while a provider retry is in flight; the engine is actively recovering the turn. */ readonly isRetryInFlight: boolean; readonly isIdle: boolean; /** A deadline stop that could not complete (the entry write failed, or the turn outlived the grace). */ _warnDeadline(event: TurnDeadlineWarning, detail: string): void; } /** * Owns the inactivity lease and the hard max-runtime cap for one turn. Armed at prompt * accept, renewed only by tool execution progress and admitted user input, never by text * deltas. On expiry it records the durable stop entry and ends the run through the normal * system-abort path. This is the single implementation of senpi#3227 for every surface. */ export declare class AgentDeadlineTracker { private inactivityTimer; private maxRuntimeTimer; private deadlineValue; private startedAtMs; private readonly session; private readonly settings; private readonly now; get current(): TurnDeadline | undefined; constructor(session: DeadlineSessionOwner, settings: () => TurnDeadlineSettings, now?: () => number); arm(): void; renew(): void; disarm(): void; /** * Admitted user input releases the deadline-stopped hold. Input steered into a live run counts as * activity (the inactivity lease restarts) but never resets the max-runtime clock of that run. */ clearHold(): void; private clearTimers; private fire; private expire; } export declare function buildDeadlineStopNotice(deadline: TurnDeadline): string; export {}; //# sourceMappingURL=turn-deadline.d.ts.map