feat: add optional Codex warm-up scheduler
This commit is contained in:
@@ -53,6 +53,11 @@ function readIntegerAtLeast(
|
||||
return Math.max(minimum, readInteger(key, fallback) || fallback);
|
||||
}
|
||||
|
||||
function readPercent(key: string, fallback: number): number {
|
||||
const value = readInteger(key, fallback);
|
||||
return Math.min(100, Math.max(0, value));
|
||||
}
|
||||
|
||||
function readAgentType(
|
||||
key: string,
|
||||
fallback?: AgentType,
|
||||
@@ -255,6 +260,40 @@ export function loadConfig(): AppConfig {
|
||||
timezone:
|
||||
readText('TZ') ?? Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
},
|
||||
codexWarmup: {
|
||||
enabled: readBoolean('CODEX_WARMUP_ENABLED', false),
|
||||
prompt:
|
||||
readNonEmptyText('CODEX_WARMUP_PROMPT') ??
|
||||
'Reply exactly OK. Do not run tools.',
|
||||
model:
|
||||
readNonEmptyText('CODEX_WARMUP_MODEL') ??
|
||||
readNonEmptyText('CODEX_MODEL') ??
|
||||
'codex',
|
||||
intervalMs: readIntegerAtLeast('CODEX_WARMUP_INTERVAL_MS', 300000, 60000),
|
||||
minIntervalMs: readIntegerAtLeast(
|
||||
'CODEX_WARMUP_MIN_INTERVAL_MS',
|
||||
18300000,
|
||||
60000,
|
||||
),
|
||||
staggerMs: Math.max(0, readInteger('CODEX_WARMUP_STAGGER_MS', 1800000)),
|
||||
maxUsagePct: readPercent('CODEX_WARMUP_MAX_USAGE_PCT', 0),
|
||||
maxD7UsagePct: readPercent('CODEX_WARMUP_MAX_D7_USAGE_PCT', 99),
|
||||
commandTimeoutMs: readIntegerAtLeast(
|
||||
'CODEX_WARMUP_COMMAND_TIMEOUT_MS',
|
||||
120000,
|
||||
10000,
|
||||
),
|
||||
failureCooldownMs: readIntegerAtLeast(
|
||||
'CODEX_WARMUP_FAILURE_COOLDOWN_MS',
|
||||
21600000,
|
||||
60000,
|
||||
),
|
||||
maxConsecutiveFailures: readIntegerAtLeast(
|
||||
'CODEX_WARMUP_MAX_CONSECUTIVE_FAILURES',
|
||||
2,
|
||||
1,
|
||||
),
|
||||
},
|
||||
sessionCommands: {
|
||||
allowedSenders: new Set(
|
||||
(readText('SESSION_COMMAND_ALLOWED_SENDERS') ?? '')
|
||||
|
||||
@@ -78,6 +78,19 @@ export interface AppConfig {
|
||||
usageDashboardEnabled: boolean;
|
||||
timezone: string;
|
||||
};
|
||||
codexWarmup: {
|
||||
enabled: boolean;
|
||||
prompt: string;
|
||||
model: string;
|
||||
intervalMs: number;
|
||||
minIntervalMs: number;
|
||||
staggerMs: number;
|
||||
maxUsagePct: number;
|
||||
maxD7UsagePct: number;
|
||||
commandTimeoutMs: number;
|
||||
failureCooldownMs: number;
|
||||
maxConsecutiveFailures: number;
|
||||
};
|
||||
sessionCommands: {
|
||||
allowedSenders: Set<string>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user