UNPKG

@code-yeongyu/senpi

Version:

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

33 lines • 1.35 kB
const ERROR_CHARS = 200; // The same 429-class markers the retry tier routing reads, plus usage and quota limits. const RATE_LIMITED = /rate.?limit|usage.?limit|quota|too many requests|resource.?exhausted|(?:^|\b(?:HTTP\/1\.[01]|HTTP|status(?: code)?|error|code)\s+)429\b/i; export function nextRetryWait(previous, event, now) { if ("errorMessage" in event && event.type === "auto_retry_start") { const error = event.errorMessage.slice(0, ERROR_CHARS); return { kind: RATE_LIMITED.test(event.errorMessage) ? "rate_limit" : "retry", attempt: event.attempt, maxAttempts: event.maxAttempts, delayMs: event.delayMs, until: new Date(now + event.delayMs).toISOString(), ...(error === "" ? {} : { error }), }; } if (event.type === "agent_start" || event.type === "auto_retry_end") return undefined; return previous; } /** * The wait as a listing publishes it: the typed kind and its timing, never the provider's error text, which * stays on `get_state` and on `session_status`. */ export function redactedRetryWait(wait) { return { kind: wait.kind, attempt: wait.attempt, maxAttempts: wait.maxAttempts, delayMs: wait.delayMs, until: wait.until, }; } //# sourceMappingURL=retry-wait.js.map