feat(primer): add usage-window alignment primer on GitHub-main base

Port the local primer subsystem onto the upstream base by intent:
- add src/usage-primer.ts (KST-slot primer firing Claude + Codex signals)
- extend codex-warmup with the ignoreZeroUsageWindow runtime option used
  by the primer so a slot is never skipped just because Codex is partway
  through its weekly window
- Codex primer fires unconditionally (maxUsagePct/maxD7UsagePct=100),
  mirroring the Claude primer, refreshing usage before selection
- wire startUsagePrimer() into the runtime bootstrap

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
claude-bot
2026-06-01 17:25:34 +09:00
parent 1ff6b3434f
commit 5b16bb6694
5 changed files with 373 additions and 6 deletions

View File

@@ -54,6 +54,7 @@ import { createMessageRuntime } from './message-runtime.js';
import { nudgeSchedulerLoop, startSchedulerLoop } from './task-scheduler.js';
import { startUnifiedDashboard } from './unified-dashboard.js';
import { startWebDashboardServer } from './web-dashboard-server.js';
import { startUsagePrimer } from './usage-primer.js';
import { Channel, NewMessage, RegisteredGroup } from './types.js';
import { logger } from './logger.js';
import { initCodexTokenRotation } from './codex-token-rotation.js';
@@ -575,6 +576,7 @@ async function main(): Promise<void> {
queue.enqueueMessageCheck(chatJid, resolveGroupIpcPath(groupFolder)),
nudgeScheduler: nudgeSchedulerLoop,
});
startUsagePrimer();
leaseRecoveryTimer = setInterval(() => {
const failover = getGlobalFailoverInfo();