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
fix(realtime): voice-spawned/killed agents now appear/leave the office floor (rt-5 last-mile)
Chaitanya Giriac35c4f74371
diff --git a/src/main/index.ts b/src/main/index.tsindex f850b247..07877228 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -2796,8 +2796,36 @@ registerRealtimeActionIpc({controlSteer: (id, text) => control.steer(id, text),controlHalt: (id) => control.halt(id),controlSnapshot: (id) => control.snapshot(id),- killAgent: (id) => { const r = ptyManager.kill(id); teardownPty(id); return r; },- spawnAgent: (opts) => spawnAgentCore(opts as AgentSpawnOptions, null),+ killAgent: (id) => {+ const r = ptyManager.kill(id);+ teardownPty(id);+ // A voice (MAIN-initiated) kill: the renderer never removed the card itself+ // (unlike a UI kill), so tell the floor to archive it. Mirrors hive:agentSpawned.+ try { liveWebContents()?.send('hive:agentArchived', { id }); } catch { /* window torn down */ }+ return r;+ },+ spawnAgent: async (opts) => {+ const o = opts as AgentSpawnOptions;+ const res = await spawnAgentCore(o, null);+ // The renderer roster is only mutated by renderer-initiated hires (AddAgentModal),+ // so a MAIN-initiated spawn is invisible on the floor until we broadcast it. The+ // renderer (useHive) builds the Agent card from this descriptor; addAgent is+ // idempotent so a renderer-initiated hire is never double-carded.+ if (res.ok) {+ try {+ liveWebContents()?.send('hive:agentSpawned', {+ id: o.id,+ name: o.hive?.name ?? o.id,+ provider: o.provider ?? o.hive?.provider ?? 'claude',+ cwd: res.worktreePath ?? o.cwd,+ command: o.command,+ role: o.hive?.role,+ worktreePath: res.worktreePath+ });+ } catch { /* window torn down */ }+ }+ return res;+ },listMissions: () => readConfig().missions ?? [],// The spec carries lastFiredAt through from listMissions(), so a wholesale write// preserves the scheduler's stamps; edit_schedule is deliberate + rare.diff --git a/src/preload/index.ts b/src/preload/index.tsindex e3e316a2..4becc3f6 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -620,6 +620,25 @@ const api = {ipcRenderer.on('hive:enqueueToAgent', listener);return () => ipcRenderer.removeListener('hive:enqueueToAgent', listener);},+ /** A MAIN-initiated agent spawn (e.g. a voice hire via rt-5) — the renderer adds+ * the floor card from this descriptor since it didn't initiate the hire itself. */+ onHiveAgentSpawned: (+ cb: (rec: {+ id: string; name: string; provider?: string; cwd: string;+ command?: string; role?: string; worktreePath?: string;+ }) => void+ ): (() => void) => {+ const listener = (_e: IpcRendererEvent, payload: Parameters<typeof cb>[0]) => cb(payload);+ ipcRenderer.on('hive:agentSpawned', listener);+ return () => ipcRenderer.removeListener('hive:agentSpawned', listener);+ },+ /** A MAIN-initiated agent kill/archive (e.g. a voice kill via rt-5) — the renderer+ * archives the floor card since it didn't initiate the kill itself. */+ onHiveAgentArchived: (cb: (e: { id: string }) => void): (() => void) => {+ const listener = (_e: IpcRendererEvent, payload: { id: string }) => cb(payload);+ ipcRenderer.on('hive:agentArchived', listener);+ return () => ipcRenderer.removeListener('hive:agentArchived', listener);+ },/** Register a listener for terminal work-order handoffs (#53) — hive mail to a* hookless provider that can't drain an inbox; the renderer types it into the* agent's REPL as a work order. */diff --git a/src/renderer/src/hooks/useHive.ts b/src/renderer/src/hooks/useHive.tsindex c4ff560b..37c85f9a 100644--- a/src/renderer/src/hooks/useHive.ts+++ b/src/renderer/src/hooks/useHive.ts@@ -9,8 +9,13 @@ import {type HarnessConfig} from '@/store/config';import { acquireTerminal, resetTerminal } from '@/components/terminalPool';+import { OFFICE_CAST, DEFAULT_CHARACTER } from '@/scene/office/cast';const GOD_ID = 'god';+/** Accent palette for MAIN-spawned (voice-hired) agents — picked deterministically+ * from the agent id so the same agent always gets the same colour. Mirrors the+ * AddAgentModal palette. */+const SPAWN_ACCENTS = ['coral', 'mint', 'sky', 'lemon', 'lilac', 'peach'] as const;const GOD_PTY = `pty-${GOD_ID}`;// How long to let Claude Code's TUI finish booting before we type the first@@ -698,6 +703,50 @@ export function useHive(config: HarnessConfig | null): void {});}, [config?.onboardingComplete]);+ // 5b) MAIN-initiated roster changes (rt-5 voice spawn/kill). The renderer store is+ // only mutated by renderer-initiated hires (AddAgentModal); a voice hire/kill+ // runs in MAIN (spawnAgentCore / teardownPty, owner=null) and would otherwise+ // be invisible on the floor. Main broadcasts; we build/archive the card here.+ useEffect(() => {+ if (!config?.onboardingComplete) return;+ const offSpawn = window.cth.onHiveAgentSpawned?.((rec) => {+ if (!rec?.id) return;+ // addAgent is idempotent, but bail early if the renderer already carded it.+ if (useStore.getState().agents.some((a) => a.id === rec.id)) return;+ const key = (rec.name || rec.id).toLowerCase();+ const character =+ OFFICE_CAST.find((m) => m.name === key || m.displayName.toLowerCase() === key)?.name ??+ DEFAULT_CHARACTER;+ let h = 0;+ for (const ch of rec.id) h = (h + ch.charCodeAt(0)) % SPAWN_ACCENTS.length;+ const project = (rec.cwd || '').split(/[\\/]/).filter(Boolean).pop() || 'hive';+ const agent: Agent = {+ id: rec.id,+ name: rec.name || rec.id,+ character,+ accent: SPAWN_ACCENTS[h],+ description: rec.role || 'a fresh harness',+ project,+ tmuxTarget: '',+ cwd: rec.cwd,+ status: 'idle',+ action: 'starting up',+ progress: 0,+ currentStation: 'desk',+ ptyId: rec.id,+ command: rec.command,+ provider: rec.provider as Agent['provider'],+ isGod: false,+ recentTextTs: Date.now()+ };+ useStore.getState().addAgent(agent);+ });+ const offArchive = window.cth.onHiveAgentArchived?.((e) => {+ if (e?.id) useStore.getState().archiveAgent(e.id);+ });+ return () => { offSpawn?.(); offArchive?.(); };+ }, [config?.onboardingComplete]);+// 6) Auto-compact (scheduled standup). Main fires this per tick; we queue a// /compact for each live agent so the drain (#4) delivers it only when the// agent is idle — never jamming a working terminal. Deduped: if a /compactdiff --git a/src/renderer/src/store/store.ts b/src/renderer/src/store/store.tsindex 69419287..c876271f 100644--- a/src/renderer/src/store/store.ts+++ b/src/renderer/src/store/store.ts@@ -419,6 +419,11 @@ export const useStore = create<State>((set) => ({set((s) => ({ feeds: { ...s.feeds, [id]: [...(s.feeds[id] ?? []), line] } })),addAgent: (agent) =>set((s) => {+ // Idempotent by id: a MAIN-initiated spawn broadcast (hive:agentSpawned, e.g.+ // a voice hire) and a renderer-initiated hire (AddAgentModal) can both call+ // addAgent for the same id — never render a duplicate card. The first writer+ // (richer local record) wins; the broadcast is a no-op for it.+ if (s.agents.some((a) => a.id === agent.id)) return s;const agents = [...s.agents, agent];// Re-spawning an archived agent un-archives it: an id is active xor archived.const archivedAgents = s.archivedAgents.filter((a) => a.id !== agent.id);