UNPKG

@code-yeongyu/senpi

Version:

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

38 lines • 2.08 kB
import type { OpenAiRemoteCompactionModel } from "./openai-remote-model.ts"; /** * Budget for one remote compaction request, sized to the context it carries (senpi#2434). * * The request sends the whole conversation, so its latency grows with it: the subscription lane * measured ~1.06 ms/token and a 383k-token compaction took 257 s. Like the local summarizer's * budget (#1068) it grows by {@link SUMMARIZATION_MAX_DURATION_PER_TOKEN_MS} per token above a * per-lane floor, so a hung request on a small context is still abandoned quickly, and it is * clamped to {@link SUMMARIZATION_TOTAL_BUDGET_MS}. Every attempt of one compaction also shares * that bound (see {@link createRemoteCompactionDeadline}). */ export declare function openAiRemoteCompactionTimeoutMs(model: OpenAiRemoteCompactionModel, compactionTokens: number): number; /** What the compaction does after a remote attempt runs out of its budget. */ export type RemoteCompactionTimeoutNextStep = "websocket" | "compact-endpoint" | "local-summary"; /** * One deadline for every remote attempt of a compaction: a lane that falls through v2, WebSocket * and the compact endpoint never holds the session longer than {@link SUMMARIZATION_TOTAL_BUDGET_MS} * in total before the local summary starts. Each attempt keeps its own size-scaled budget, clamped * to what is left. */ export declare function createRemoteCompactionDeadline(attemptBudgetMs: number, now?: () => number): { remainingMs: () => number; nextAttemptMs: () => number; }; export type RemoteCompactionTimeout = { /** Measured wait of the attempt that timed out. */ waitedMs: number; tokens: number; next: RemoteCompactionTimeoutNextStep; }; export declare function formatRemoteCompactionTimeoutNotice(timeout: RemoteCompactionTimeout): string; export declare function runWithRemoteTimeout<T>(options: { signal: AbortSignal; timeoutMs: number; run: (signal: AbortSignal) => Promise<T>; onTimeout: (waitedMs: number) => void; }): Promise<T | undefined>; //# sourceMappingURL=openai-remote-timeout.d.ts.map