@tigorhutasuhut/claude-retry 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/monitor.js +13 -17
- package/package.json +1 -1
package/dist/monitor.js
CHANGED
|
@@ -47,33 +47,29 @@ async function stepState(state, screenText, now, injectContinue, marginSeconds,
|
|
|
47
47
|
const limited = match(screenText).limited;
|
|
48
48
|
const { usage } = await resolveAccountUsage(snapshot, resolvePaneAccount, target);
|
|
49
49
|
const marginMs = (marginSeconds ?? 60) * 1000;
|
|
50
|
-
//
|
|
50
|
+
// Banner absent → claude exited / user already continued / pane id reused → nothing to continue.
|
|
51
51
|
if (!limited) {
|
|
52
52
|
state.status = 'monitoring';
|
|
53
53
|
state.waitUntil = 0;
|
|
54
54
|
logger(`${label} wait abandoned (banner gone)`);
|
|
55
55
|
return 'monitoring';
|
|
56
56
|
}
|
|
57
|
-
//
|
|
58
|
-
if (usage !== undefined && !usage.limited) {
|
|
59
|
-
state.status = 'monitoring';
|
|
60
|
-
state.waitUntil = 0;
|
|
61
|
-
logger(`${label} wait abandoned (account not limited)`);
|
|
62
|
-
return 'monitoring';
|
|
63
|
-
}
|
|
64
|
-
// 3. Account known, still limited, with a fresh resetsAtMs → refresh waitUntil
|
|
57
|
+
// Account still limited with a known reset → keep waitUntil aligned to the live reset time.
|
|
65
58
|
if (usage !== undefined && usage.limited && usage.resetsAtMs !== null) {
|
|
66
59
|
state.waitUntil = usage.resetsAtMs + marginMs;
|
|
67
60
|
}
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
// The limit is over when the account quota has cleared (early/real reset) OR the timer elapsed.
|
|
62
|
+
const accountCleared = usage !== undefined && !usage.limited;
|
|
63
|
+
const timerElapsed = now >= state.waitUntil;
|
|
64
|
+
if (accountCleared || timerElapsed) {
|
|
65
|
+
await injectContinue();
|
|
66
|
+
state.status = 'monitoring';
|
|
67
|
+
state.waitUntil = 0;
|
|
68
|
+
logger(`${label} reset reached — injected continue`);
|
|
69
|
+
return 'retried';
|
|
71
70
|
}
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
state.status = 'monitoring';
|
|
75
|
-
state.waitUntil = 0;
|
|
76
|
-
return 'retried';
|
|
71
|
+
// Still limited, before reset → keep waiting.
|
|
72
|
+
return 'rate-limited';
|
|
77
73
|
}
|
|
78
74
|
// state.status === 'monitoring'
|
|
79
75
|
const result = match(screenText);
|