an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
feat(schedules): dedicated persistent auto-compact maintenance mission (maint-1 core)
Chaitanya Giri5d4d38679584
diff --git a/src/main/config.ts b/src/main/config.tsindex b270c32c..96ecd829 100644--- a/src/main/config.ts+++ b/src/main/config.ts@@ -27,7 +27,7 @@ export interface ScheduledMission {* e.g. the ops standup). 'heartbeat' (Lane A #1) is a context-aware beat: it* observes live floor state, re-engages a quiet god, and ticks the circuit* breaker — armed with an adaptive cadence, not a fixed setInterval. */- kind?: 'dispatch' | 'heartbeat';+ kind?: 'dispatch' | 'heartbeat' | 'compact';/** Heartbeat only: a floor is "quiet" when no tracked signal (log.jsonl mtime,* inbox/outbox mtimes, any PTY output) has moved in this many ms. Default* ~5 min. NOT derived from registry.status (which never transitions in main). */@@ -79,6 +79,25 @@ export const HEARTBEAT_MISSION: ScheduledMission = {quietThresholdMs: 300_000};+/** The dedicated auto-compact MAINTENANCE schedule (maint-1). DECOUPLED from the+ * ops standup so editing/replacing a standup can never silently disable+ * compaction again (the bug this fixes). It fires ONLY the auto-compact signal —+ * `kind:'compact'` makes syncMissions skip the hive.send dispatch (empty to/body).+ * Shipped ENABLED: auto-compact is REQUIRED for long-running agents — without it+ * each agent's terminal context grows until it overflows and the agent fails. It+ * is the SINGLE source of truth for compaction (migration drops autoCompact off+ * other missions), and it's persistent: deleting it makes it reappear DISABLED. */+export const COMPACT_MAINTENANCE_MISSION: ScheduledMission = {+ id: 'compact-maintenance',+ label: 'Auto-compact (maintenance)',+ intervalMs: 3_600_000,+ to: '',+ body: '',+ enabled: true,+ autoCompact: true,+ kind: 'compact'+};+/** Circuit-breaker thresholds (Lane A #6.6b). The breaker runs inside the* heartbeat beat, so it only ticks when the heartbeat is enabled. Trip* conditions are behavioral by default; `costCapUsd` is the only $-based one and@@ -156,6 +175,11 @@ export interface HarnessConfig {/** One-time guard for the built-in heartbeat mission (mirrors opsStandupSeeded* so a user who deletes the heartbeat doesn't get it re-added every boot). */heartbeatSeeded?: boolean;+ /** maint-1 guard for the dedicated auto-compact maintenance mission. UNLIKE the+ * two above, this does NOT suppress re-add forever: once seeded (flag set), a+ * later delete makes the mission reappear DISABLED on next boot (compaction is+ * required, so it's never silently lost — only user-disabled). */+ compactMaintenanceSeeded?: boolean;/** Hard dollar ceiling across all active agents before the circuit breaker* trips. UNSET by default (Lane A #6.6b decision): the breaker trips on* behavioral signals; the $-cap is purely opt-in. Legacy — the UI now sets adiff --git a/src/main/index.ts b/src/main/index.tsindex b4acc3ca..5847eaac 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -7,7 +7,7 @@ import { request as httpsRequest } from 'node:https';import { PtyManager, type SpawnOptions } from './pty';import {readConfig, writeConfig, resetConfig, ensureHarnessHome, ensureClaudePermissionsAccepted,- modelForRole, OPS_STANDUP_MISSION, HEARTBEAT_MISSION, type HarnessConfig, type ScheduledMission+ modelForRole, OPS_STANDUP_MISSION, HEARTBEAT_MISSION, COMPACT_MAINTENANCE_MISSION, type HarnessConfig, type ScheduledMission} from './config';import { listDir, readFileText, writeFileText } from './fs';import {@@ -458,14 +458,16 @@ function syncMissions(): void {if (m.kind === 'heartbeat') { armHeartbeat(m); continue; }const fire = (): void => {try {- if (hive.enabled()) {+ // A 'compact' maintenance mission (maint-1) is compaction-ONLY: it carries+ // no dispatch body/target, so skip the hive.send and just fire auto-compact.+ if (m.kind !== 'compact' && m.body && hive.enabled()) {hive.send({ to: m.to, act: 'request', subject: m.label, body: m.body }, 'scheduler');}// Auto-compact: do NOT jam /compact into busy terminals. Hand it to the// renderer, which queues a /compact per agent (deduped — never two at// once) and delivers it only when that agent goes idle (its drain loop),// so a working agent compacts between steps, never mid-step.- if (m.autoCompact) {+ if (m.autoCompact || m.kind === 'compact') {try { liveWebContents()?.send('mission:autoCompact'); } catch { /* window gone */ }}const current = readConfig().missions ?? [];@@ -547,6 +549,34 @@ function ensureDefaultMissions(): void {heartbeatSeeded: true});}++ // maint-1: the dedicated auto-compact maintenance mission. Auto-compact USED to+ // ride solely on the ops standup's autoCompact flag, so replacing the standup+ // silently disabled compaction for all long-running agents. This makes it a+ // first-class, persistent schedule:+ // • FIRST seed (flag unset): add it ENABLED + MIGRATE — drop autoCompact from+ // every OTHER mission so this is the single source of truth (no double+ // /compact whether compaction rode the standup or a stopgapped custom mission).+ // • PERSISTENT (flag set): if the user later deletes it, it reappears DISABLED+ // next boot — never silently lost (only user-disabled, with a UI warning).+ const cfg3 = readConfig();+ const missions3 = cfg3.missions ?? [];+ const hasCompact = missions3.some((m) => m.id === COMPACT_MAINTENANCE_MISSION.id);+ if (!cfg3.compactMaintenanceSeeded) {+ const migrated = missions3.map((m) =>+ m.id === COMPACT_MAINTENANCE_MISSION.id ? m : { ...m, autoCompact: false }+ );+ writeConfig({+ missions: hasCompact+ ? migrated+ : [...migrated, { ...COMPACT_MAINTENANCE_MISSION, lastFiredAt: Date.now() }],+ compactMaintenanceSeeded: true+ });+ } else if (!hasCompact) {+ writeConfig({+ missions: [...missions3, { ...COMPACT_MAINTENANCE_MISSION, enabled: false, lastFiredAt: Date.now() }]+ });+ }}// ─── Heartbeat (Lane A #1) + circuit-breaker beat (#6.6b) ────────────────────