@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
19 lines • 876 B
JavaScript
export function usageShowsCapacity(limits, since, now) {
if (limits.error !== undefined || limits.windows.length === 0)
return false;
if (Date.parse(limits.reportedAt) <= since)
return false;
return limits.windows.every((window) => {
if (window.usedPercent < 100)
return true;
const resetsAt = window.resetsAt === undefined ? Number.NaN : Date.parse(window.resetsAt);
return Number.isFinite(resetsAt) && resetsAt <= now;
});
}
/** The accounts of `provider` whose reported usage, newer than `since`, shows they can serve again. */
export function accountsWithCapacity(snapshot, provider, since, now) {
return snapshot
.filter((limits) => limits.provider === provider && usageShowsCapacity(limits, since, now))
.map((limits) => limits.account);
}
//# sourceMappingURL=usage-capacity.js.map