refactor(auth-profiles): reuse cooldown timestamp resolver

This commit is contained in:
Peter Steinberger
2026-02-18 17:13:47 +00:00
parent 818419b4c4
commit 28d49b8d44
3 changed files with 25 additions and 16 deletions

View File

@@ -2,20 +2,11 @@ import type { OpenClawConfig } from "../../config/config.js";
import { findNormalizedProviderValue, normalizeProviderId } from "../model-selection.js";
import { dedupeProfileIds, listProfilesForProvider } from "./profiles.js";
import type { AuthProfileStore } from "./types.js";
import { clearExpiredCooldowns, isProfileInCooldown } from "./usage.js";
function resolveProfileUnusableUntil(stats: {
cooldownUntil?: number;
disabledUntil?: number;
}): number | null {
const values = [stats.cooldownUntil, stats.disabledUntil]
.filter((value): value is number => typeof value === "number")
.filter((value) => Number.isFinite(value) && value > 0);
if (values.length === 0) {
return null;
}
return Math.max(...values);
}
import {
clearExpiredCooldowns,
isProfileInCooldown,
resolveProfileUnusableUntil,
} from "./usage.js";
export function resolveAuthProfileOrder(params: {
cfg?: OpenClawConfig;