diff --git a/packages/runner/src/limits.ts b/packages/runner/src/limits.ts index 0a49047b..703601f9 100644 --- a/packages/runner/src/limits.ts +++ b/packages/runner/src/limits.ts @@ -16,13 +16,14 @@ export const limitAutoResumeEnabled = () => process.env.PEPPA_LIMIT_AUTORESUME ! /** * Reset time from a limit message: "resets 5pm", "resets at 3:10 AM", "reset at 15:00", - * "try again at 5:00 PM", "resets in 2h 15m". A clock time without a date is the nearest + * "try again at 5:00 PM", "resets in 2h 15m", and Claude Code's newer banner + * "Usage limit reached · continuing automatically at 6pm" (PEP-166). A clock time without a date is the nearest * future one (local time of this machine). Null when there is no time in the text. */ export function parseResetTime(text: string, now: Date): Date | null { const rel = /reset[s]?\s+in\s+(?:(\d+)\s*h(?:ours?)?)?\s*(?:(\d+)\s*m(?:in(?:utes?)?)?)?/i.exec(text); if (rel && (rel[1] || rel[2])) return new Date(now.getTime() + (Number(rel[1] ?? 0) * 60 + Number(rel[2] ?? 0)) * 60_000); - const abs = /(?:reset[s]?|try again)(?:\s+at)?\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\b/i.exec(text); + const abs = /(?:reset[s]?|try again|continu(?:e|es|ing)(?:\s+automatically)?)(?:\s+at)?\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\b/i.exec(text); if (!abs) return null; let h = Number(abs[1]); const m = Number(abs[2] ?? 0); diff --git a/packages/testkit/test/limits.test.ts b/packages/testkit/test/limits.test.ts index 11ebd45c..f5e7b900 100644 --- a/packages/testkit/test/limits.test.ts +++ b/packages/testkit/test/limits.test.ts @@ -19,6 +19,11 @@ describe("Время сброса лимита", () => { ["resets at 3:10 AM", "2026-11-13T03:10:00"], ["resets in 2h 15m", "2026-11-13T00:55:00"], ["try again at 23:30", "2026-11-12T23:30:00"], + // PEP-166: Claude Code's newer banner — the time was not read, a 30-minute probe made the + // subscription look free again while it stayed limited until the evening. + ["⏺ Usage limit reached · continuing automatically at 6pm · esc to cancel", "2026-11-13T18:00:00"], + ["continuing automatically at 9:30 AM", "2026-11-13T09:30:00"], + ["continuing work on the task", null], ["limit reached", null], ] as const) { test(`Форматы времени сброса: «${text}»`, () => {