Skip to content

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

Merge #175: main-process watchdog wakes idle workers on undrained inbox

Chaitanya Girif045408820dd
diff --cc src/main/hooks.ts
index 4f16e677,745d0edf..e0cfca95
--- a/src/main/hooks.ts
+++ b/src/main/hooks.ts
@@@ -68,9 -68,10 +68,13 @@@ export class HookServer
/** Circuit breaker (Lane A #6.6b) — fed the hook-derived signals (session id,
* repeated identical tool calls). Optional so the server still runs without it. */
private breaker?: CircuitBreaker,
+ /** Standing goal text for an agent (from the durable roster). Optional so
+ * tests can omit it; when set, injected on SessionStart / UserPromptSubmit. */
- private getStandingGoal?: (agentId: string) => string | null
++ private getStandingGoal?: (agentId: string) => string | null,
+ /** Optional observer of every hook boundary (agentId, event, message). The
+ * worker inbox-wake watchdog (workerWake.ts) feeds on this to learn when an
+ * agent is parked on a permission/HITL prompt so it never types into it. */
+ private onEvent?: (agentId: string | undefined, event: string, message: string | undefined) => void
) {}
start(): void {
diff --cc src/main/index.ts
index bfba50d0,a2d06b6a..3ff9004e
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@@ -58,9 -58,9 +58,10 @@@ import { IntegrationBroker } from './in
import * as integrations from './integrations';
import { validateBaseUrl, buildAuthHeaders, resolveUpstreamUrl, secretRefFor, INTEGRATION_TEMPLATES } from '../shared/integrations';
import { RosterStore } from './roster';
+import { buildWorkerLaunch } from './workerLaunch';
import { ControlRegistry } from './control';
+ import { WorkerWakeWatchdog, WORKER_WAKE_NUDGE, type WorkerWakeFacts } from './workerWake';
-import { fetchHireManifest, readHireManifestFile } from './hire';
+import { fetchHireManifest, readHireManifestFiles } from './hire';
import { parseHireDeepLink, type HireManifest } from '../shared/hire';
import { ClosingTimeController } from './closingTime';
import {
@@@ -267,30 -263,15 +268,36 @@@ let breakerBeatTimer: ReturnType<typeo
// Feed the breaker's api_error-storm trip from Oscar's OTel api_error spans —
// Jim's one breaker input with no on-branch source (telemetry.onApiError seam).
telemetry.onApiError((agentId) => breaker.recordError(agentId));
+// Shared roster on disk — created early so HookServer can re-read standing goals
+// on every UserPromptSubmit (Edit Agent saves land here via persistAgents).
+const roster = new RosterStore(() => readConfig().harnessHome);
+function standingGoalFromRoster(agentId: string): string | null {
+ const snap = roster.read();
+ if (!snap || !Array.isArray(snap.agents)) return null;
+ for (const entry of snap.agents) {
+ if (!entry || typeof entry !== 'object') continue;
+ const a = entry as { id?: unknown; goal?: unknown };
+ if (a.id !== agentId) continue;
+ return typeof a.goal === 'string' && a.goal.trim() ? a.goal.trim() : null;
+ }
+ return null;
+}
+ // Worker inbox-wake watchdog (#151): finds idle workers with undrained inbox mail
+ // and types the same guarded nudge the renderer would have (so a throttled
+ // background window can't leave a worker parked on an unread inbox forever).
+ // HookServer feeds it the hook stream so a permission/HITL prompt blocks nudges.
+ const workerWake = new WorkerWakeWatchdog();
// HookServer needs BOTH: Oscar's control registry (HITL pause/gate/steer/halt via
// hook returns) AND Jim's breaker (feed recordToolUse on each PostToolUse).
-const hookServer = new HookServer(hive, () => liveWebContents(), () => readConfig(), control, breaker,
- (agentId, event, message) => workerWake.noteHook(agentId, event, message));
+const hookServer = new HookServer(
+ hive,
+ () => liveWebContents(),
+ () => readConfig(),
+ control,
+ breaker,
- standingGoalFromRoster
++ standingGoalFromRoster,
++ (agentId, event, message) => workerWake.noteHook(agentId, event, message)
+);
const memory = new MemoryManager(
() => readConfig().harnessHome,
() => { const c = readConfig(); return { enabled: c.semanticMemory !== false, model: c.embeddingModel ?? 'minilm' }; }