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

integrate: Lane B persistence (#3 memory reflect, #8 configurable folder, #4 SQLite Phase A)

Chaitanya Giri9361e8b46c3d
diff --cc src/main/index.ts
index bc7405a4,2034feb8..75af3d56
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@@ -1,6 -1,6 +1,6 @@@
- import { app, BrowserWindow, clipboard, dialog, ipcMain, shell, Notification } from 'electron';
-import { app, BrowserWindow, clipboard, dialog, ipcMain, screen, shell } from 'electron';
++import { app, BrowserWindow, clipboard, dialog, ipcMain, screen, shell, Notification } from 'electron';
import { spawn } from 'node:child_process';
- import { rmSync, existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
-import { rmSync, existsSync, readFileSync, readdirSync, cpSync } from 'node:fs';
++import { rmSync, existsSync, readFileSync, readdirSync, statSync, cpSync } from 'node:fs';
import { join, resolve, sep } from 'node:path';
import { PtyManager, type SpawnOptions } from './pty';
import {
@@@ -14,9 -14,9 +14,11 @@@ import
} from './git';
import { HiveManager, type AgentMeta, type HiveMessage, type HiveTask } from './hive';
import { HookServer } from './hooks';
+import { CircuitBreaker, type BreakerInput } from './breaker';
+import type { UsageProvider } from './usage';
import { MemoryManager } from './memory';
+ import { MemoryReflector, type ReflectSettings } from './reflect';
+ import { PersistStore } from './db';
import { enrichMessage } from './assistant';
import { readAgentUsage } from './transcript';
import { listIssues, listCIRuns } from './github';
@@@ -754,9 -661,10 +916,11 @@@ ipcMain.handle('app:confirmClose', () =
try { clearMissionTimers(); } catch (e) { console.error('[quit] clearMissionTimers:', e); }
try { hive.stopRouter(); } catch (e) { console.error('[quit] stopRouter:', e); }
try { hookServer.stop(); } catch (e) { console.error('[quit] hookServer.stop:', e); }
+ try { telemetry.stop(); } catch (e) { console.error('[quit] telemetry.stop:', e); }
try { stopSlackServer(); } catch (e) { console.error('[quit] slack.stop:', e); }
try { memory.stop(); } catch (e) { console.error('[quit] memory.stop:', e); }
+ try { reflector.stop(); } catch (e) { console.error('[quit] reflector.stop:', e); }
+ try { persist.close(); } catch (e) { console.error('[quit] persist.close:', e); }
try { ptyManager.killAll(); } catch (e) { console.error('[quit] killAll:', e); }
app.quit();
});
@@@ -771,9 -679,10 +935,11 @@@ ipcMain.handle('app:resetAll', () =>
try { clearMissionTimers(); } catch (e) { console.error('[reset] clearMissionTimers:', e); }
try { hive.stopRouter(); } catch (e) { console.error('[reset] stopRouter:', e); }
try { hookServer.stop(); } catch (e) { console.error('[reset] hookServer.stop:', e); }
+ try { telemetry.stop(); } catch (e) { console.error('[reset] telemetry.stop:', e); }
try { stopSlackServer(); } catch (e) { console.error('[reset] slack.stop:', e); }
try { memory.stop(); } catch (e) { console.error('[reset] memory.stop:', e); }
+ try { reflector.stop(); } catch (e) { console.error('[reset] reflector.stop:', e); }
+ try { persist.close(); } catch (e) { console.error('[reset] persist.close:', e); }
try { ptyManager.killAll(); } catch (e) { console.error('[reset] killAll:', e); }
// Erase the hive (Michael's + every agent's memory, inboxes, tasks, board,
// git history) and the semantic-memory palace. Only these harness-created
@@@ -936,26 -794,27 +1102,35 @@@ ipcMain.handle('slack:setConfig', (_evt
return { ok: true };
});
+ /** Start every hive-bound background service against the current harnessHome.
+ * Called on boot, and again to recover in place if a folder-change copy fails
+ * (config:changeHome tears these down before copying). No-op without a home. */
+ function bootstrapHiveServices(): void {
+ if (!hive.enabled()) return;
+ hive.ensureHive();
+ hive.startRouter();
+ ensureDefaultMissions(); // one-time: seed the built-in hourly ops standup
+ syncMissions(); // arm recurring auto-dispatch missions now the router is live
+ hookServer.start();
++ // Bind the telemetry collector BEFORE the renderer spawns any agent, then point
++ // the hive at it so every subsequent spawn is instrumented. Best-effort — a bind
++ // failure just leaves telemetry off (transcript reconciler stays). No breaker.start():
++ // the breaker is POLICY-only, ticked by the heartbeat beat (#1, ships disabled).
++ void telemetry.start().then((r) => {
++ if (r.ok && r.endpoint) { hive.setOtelEndpoint(r.endpoint); console.log('[telemetry] collector listening', r.endpoint); }
++ else console.error('[telemetry] collector failed to start:', r.error);
++ });
+ memory.start(); // init shared palace + mine loop (no-op without mempalace)
+ reflector.start(); // bound oversized memory.md files on a timer (no-op until threshold)
+ }
+
app.whenReady().then(() => {
+ // Open the durable store first — createWindow() reads the saved window bounds.
+ // Guarded: a DB failure (e.g. a bad native build) must degrade to defaults,
+ // never block app startup.
+ try { persist.open(); } catch (e) { console.error('[db] open failed:', e); }
// Bootstrap the hive (if harnessHome is configured) and start the message router.
- if (hive.enabled()) {
- hive.ensureHive();
- hive.startRouter();
- ensureDefaultMissions(); // one-time: seed the built-in hourly ops standup
- syncMissions(); // arm recurring auto-dispatch missions now the router is live
- hookServer.start();
- // Bind the telemetry collector BEFORE the renderer spawns any agent, then
- // point the hive at it so every subsequent spawn is instrumented. Best-effort
- // — a bind failure just leaves telemetry off (transcript reconciler stays).
- void telemetry.start().then((r) => {
- if (r.ok && r.endpoint) { hive.setOtelEndpoint(r.endpoint); console.log('[telemetry] collector listening', r.endpoint); }
- else console.error('[telemetry] collector failed to start:', r.error);
- });
- // No breaker.start() — the breaker is POLICY-only, ticked by the heartbeat
- // beat (#1, ships disabled), so it's dormant until the user opts in. (Lane A
- // #6 replaced Lane C's interim self-polling breaker at integration.)
- memory.start(); // init shared palace + mine loop (no-op without mempalace)
- }
+ bootstrapHiveServices();
createWindow();
// Auto-start the Slack webhook server when configured. Best-effort: a tunnel
// failure (offline) is logged, not fatal. The tunnel URL is ephemeral and
diff --cc src/preload/index.ts
index 21fd6031,933d3703..e9983417
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@@ -159,64 -135,17 +159,73 @@@ export interface AgentUsage
cacheReadTokens: number;
cacheWriteTokens: number;
estimatedCostUsd: number;
+ /** Most-recently-seen model id (normalized), if any priced record was found. */
+ model?: string;
+}
+
+/** Live cumulative cost/token snapshot from the OTel collector (the locked
+ * cross-lane seam). PII-free by construction. Mirrors telemetry.ts. */
+export interface AgentUsageSample {
+ agentId: string;
+ sessionId: string;
+ ts: number;
+ input: number;
+ output: number;
+ cacheRead: number;
+ cacheCreation: number;
+ model: string;
+ usd: number;
+}
+
+/** One tool invocation for the per-agent span waterfall (#7B.2). Ephemeral. */
+export interface ToolSpan {
+ agentId: string;
+ sessionId: string;
+ ts: number;
+ tool: string;
+ success: boolean;
+ durationMs: number;
+ decision?: 'accept' | 'reject';
+ error?: string;
+}
+
+/** Per-agent operator-control state (#7C.1–7C.3). */
+export interface AgentControlSnapshot {
+ paused: boolean;
+ halted: boolean;
+ gatedTools: string[];
+ pendingSteers: number;
+}
+
+/** Circuit-breaker state (Lane A #6 → this lane's avatars/meter). */
+export interface BreakerState {
+ agentId: string;
+ level: 'healthy' | 'steering' | 'constrained' | 'stopped';
+ reason: string;
+ ts: number;
+}
+
+/** Live telemetry push payload (channel `telemetry:event`). */
+export type TelemetryEvent =
+ | { kind: 'usage'; sample: AgentUsageSample }
+ | { kind: 'tool_result'; span: ToolSpan }
+ | { kind: 'api_error'; agentId: string; sessionId: string; ts: number; error: string };
+
+/** Cold-start backfill from the collector. */
+export interface TelemetrySnapshot {
+ usage: AgentUsageSample[];
+ spans: Record<string, ToolSpan[]>;
}
+ /** One captured user prompt from the SQLite command_history table. */
+ export interface CommandHistoryEntry {
+ id: number;
+ agentId: string;
+ cwd: string | null;
+ text: string;
+ ts: number;
+ }
+
/** A GitHub issue, normalized for the renderer (labels/assignees flattened to names). */
export interface GHIssue {
number: number;