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
Merge branch 'feat/p4-worker-hardening'
Chaitanya Giri600bf500148f
diff --cc src/main/config.tsindex 91b3234e,c02738d3..16a3ec25--- a/src/main/config.ts+++ b/src/main/config.ts@@@ -171,11 -170,14 +171,19 @@@ export interface HarnessConfig* — idle-based, never wall-clock, so an actively-working worker is never reaped.* Default 20. */workerIdleTimeoutMinutes?: number;+ /** Registered integrations (Phase 2) — labeled REST endpoints workers reach through+ * the loopback secret broker. METADATA ONLY: each record carries a `secretRef`+ * handle, never the secret value (secrets live encrypted in a separate file via+ * Electron safeStorage — see src/main/integrations.ts). Default []. */+ integrations?: IntegrationRecord[];+ /** Default per-worker TOTAL-token cap (input+output+cache) applied to every+ * god-triggered ephemeral worker; a worker's own spawn-request `tokenCap`+ * overrides it. When the effective cap is exceeded the worker is reaped (its+ * committed work preserved) and god is informed. This is PLUMBING for a later+ * budget feature: per the human directive there is NO per-worker cap today, so+ * the default is 0 = UNLIMITED — the mechanism is wired but never throttles+ * unless someone explicitly sets a positive cap (per request or here). */+ defaultWorkerTokenCap?: number;/** Circuit-breaker thresholds (Lane A #6.6b). Unset = conservative defaults. */circuitBreaker?: CircuitBreakerConfig;/** Enterprise Knowledge Graph (multimodal context for agents). Default OFF. */@@@ -271,7 -273,7 +279,8 @@@ const DEFAULTS: HarnessConfig =mcpDefaults: defaultMcpDefaults(),maxConcurrentWorkers: 4,workerIdleTimeoutMinutes: 20,+ integrations: [],+ defaultWorkerTokenCap: 0, // 0 = unlimited (human directive: NO per-worker cap)semanticMemory: true,embeddingModel: 'minilm',missions: [OPS_STANDUP_MISSION],diff --cc src/main/index.tsindex 11f7d062,b4f452b2..ca091f29--- a/src/main/index.ts+++ b/src/main/index.ts@@@ -174,15 -175,23 +178,32 @@@ interface WorkerRec* force-removed) when it holds unintegrated work — god is the sole integrator. */const liveWorkers = new Map<string, WorkerRec>();+/** The loopback secret broker (Phase 2). Workers reach registered integrations through+ * it without ever seeing a credential. getRecord/getSecret are injected so the broker+ * stays electron-free + unit-testable. Started in bootstrapHiveServices; each worker is+ * granted a per-worker capability token at spawn (revoked in teardownPty). */+const integrationBroker = new IntegrationBroker({+ getRecord: integrations.getRecord,+ getSecret: integrations.getSecret+});++ /** A worker worktree that teardown PRESERVED because it held unintegrated work.+ * Tracked so the GC sweep can reclaim it (+ its scratch dir) once the work lands+ * in base or the worktree is removed by hand — see gcPreservedWorktrees(). */+ interface PreservedWorktree {+ workerId: string;+ wtPath: string;+ origCwd: string; // the parent repo to run `git worktree remove` from+ baseBranch: string; // re-checked against this for "integrated yet?"+ scratchDir: string | null; // HIVE_ROOT/agents/<workerId> — removed alongside the worktree+ slack?: { channel: string; thread_ts: string };+ preservedAt: number; // epoch ms+ }+ /** Preserved worker worktrees awaiting integration, keyed by worktree path. The GC+ * sweep drains this: an entry is removed (worktree + scratch GC'd) only when the+ * work is provably integrated, or when the worktree is already gone from disk. */+ const preservedWorktrees = new Map<string, PreservedWorktree>();+/*** Tear down everything tied to a PTY id: archive its hive agent, remove its* isolated git worktree, and drop the bookkeeping-map entries. Runs on BOTH an@@@ -2726,10 -2717,13 +2786,13 @@@ async function processSpawnRequest(file} catch (e) {res = { ok: false, error: String(e) };}- if (!res.ok) { fail(`spawn failed — ${res.error ?? 'unknown error'}`); return; }+ if (!res.ok) { integrationBroker.revoke(workerId); fail(`spawn failed — ${res.error ?? 'unknown error'}`); return; }- // Register for done-scan / idle-reap / safe teardown (pty id == workerId).- liveWorkers.set(workerId, { workerId, reqId, slack, baseBranch, spawnedAt: Date.now() });+ // Register for done-scan / idle-reap / token-cap / safe teardown (pty id == workerId).+ // tokenCap is optional plumbing (default unlimited) — only a positive finite cap is kept.+ const tokenCap = typeof raw.tokenCap === 'number' && Number.isFinite(raw.tokenCap) && raw.tokenCap > 0+ ? raw.tokenCap : undefined;+ liveWorkers.set(workerId, { workerId, reqId, name: meta.name, slack, baseBranch, spawnedAt: Date.now(), tokenCap });// Dispatch the objective via the standard inbox path (zero new transport),// reusing the autonomous-request preamble so the worker gets the exact Slack