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

feat(voice): Michael gets live floor context + full app control

Chaitanya Girief46d324cd7b
diff --git a/electron-builder.yml b/electron-builder.yml
index c0302a7c..f240b1fb 100644
--- a/electron-builder.yml
+++ b/electron-builder.yml
@@ -31,6 +31,8 @@ directories:
files:
- out/**
- package.json
+ # v0.3.4: shipped so the voice get_app_info tool can read release notes.
+ - CHANGELOG.md
- "!**/*.{md,map,ts,tsx}"
- "!**/{.eslintrc,.prettierrc,tsconfig*.json,electron.vite.config.*}"
diff --git a/src/main/index.ts b/src/main/index.ts
index 85b21a7c..8bd9cca5 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -11,6 +11,7 @@ import { request as httpsRequest } from 'node:https';
import { PtyManager, type SpawnOptions } from './pty';
import { resolveCommand as resolveCliCommand } from './shellEnv';
import { initAutoUpdater } from './updater';
+import { RealtimeFloorWatcher } from './realtimeFloorWatcher';
import {
readConfig, writeConfig, resetConfig, ensureHarnessHome, ensureClaudePermissionsAccepted,
modelForRole, OPS_STANDUP_MISSION, HEARTBEAT_MISSION, COMPACT_MAINTENANCE_MISSION, type HarnessConfig, type ScheduledMission
@@ -3319,13 +3320,57 @@ registerRealtimeActionIpc({
// preserves the scheduler's stamps; edit_schedule is deliberate + rare.
saveMissions: (missions) => { writeConfig({ missions }); },
// rt-12: register each voice dispatch so the watcher can detect its completion.
- trackDispatch: (d) => { try { completionWatcher.track({ ...d, kind: 'dispatch' }); } catch { /* watcher unavailable */ } }
+ trackDispatch: (d) => { try { completionWatcher.track({ ...d, kind: 'dispatch' }); } catch { /* watcher unavailable */ } },
+ // ── v0.3.4 full-control extensions ──
+ controlResume: (id) => control.resume(id),
+ controlAutoDelivery: (id, paused) => control.pauseAutoDelivery(id, paused),
+ controlGateTool: (id, toolName, on) => control.gateTool(id, toolName, on),
+ setArchived: (id, archived) => {
+ if (!hive.enabled()) return { ok: false, error: 'hive disabled' };
+ hive.setArchived(id, archived);
+ try { liveWebContents()?.send(archived ? 'hive:agentArchived' : 'hive:agentSpawned', { id }); } catch { /* window gone */ }
+ return { ok: true };
+ },
+ // clear_context: hand the text to the renderer's queue so delivery rides every
+ // existing gate (idle-only, boot grace, draft/picker safety).
+ enqueueToAgent: (id, text) => {
+ try { liveWebContents()?.send('realtime:enqueue', { agentId: id, text }); } catch { /* window gone */ }
+ },
+ getConfigValue: (key) => (readConfig() as unknown as Record<string, unknown>)[key],
+ patchConfig: (patch) => { writeConfig(patch as Partial<HarnessConfig>); }
});
// rt-12 seam: push detected completions to the live floor; bridge live-flag, queue
// drain (closed-session warm-start), and wait_for over IPC. Then start polling.
completionWatcher.onCompletion((evt) => { try { liveWebContents()?.send('realtime:completion', evt); } catch { /* window gone */ } });
-ipcMain.handle('realtime:setSessionLive', (_e, live: unknown) => { completionWatcher.setSessionLive(live === true); return { ok: true }; });
+// v0.3.4: the floor delta watcher shares the session-live flag — while a voice
+// session is open it pushes coalesced floor updates the renderer injects as
+// silent conversation items (snapshot-at-connect + append-only deltas).
+const floorWatcher = new RealtimeFloorWatcher({
+ enabled: () => hive.enabled(),
+ registry: () => hive.registry(),
+ tasks: () => hive.tasks(),
+ ptys: () => ptyManager.list().map((p) => ({ id: p.id, lastOutputAt: p.lastOutputAt })),
+ push: (text) => { try { liveWebContents()?.send('realtime:floorDelta', { text }); } catch { /* window gone */ } }
+});
+floorWatcher.start();
+ipcMain.handle('realtime:setSessionLive', (_e, live: unknown) => {
+ completionWatcher.setSessionLive(live === true);
+ floorWatcher.setSessionLive(live === true);
+ return { ok: true };
+});
+// v0.3.4: app self-knowledge for the voice get_app_info tool — version + the
+// newest CHANGELOG sections. Read-only; ships CHANGELOG.md with the app.
+ipcMain.handle('app:info', () => {
+ let changelog = '';
+ for (const p of [join(app.getAppPath(), 'CHANGELOG.md'), join(process.cwd(), 'CHANGELOG.md')]) {
+ try { changelog = readFileSync(p, 'utf8'); if (changelog) break; } catch { /* try next */ }
+ }
+ const top = changelog
+ ? changelog.split(/\n## /).slice(1, 3).map((s) => `## ${s}`).join('\n').slice(0, 8000)
+ : '';
+ return { version: app.getVersion(), changelog: top };
+});
ipcMain.handle('realtime:drainCompletions', () => completionWatcher.drainQueuedCompletions());
ipcMain.handle('realtime:waitFor', (_e, taskId: unknown, timeoutMs: unknown) =>
typeof taskId === 'string'
diff --git a/src/main/realtime.ts b/src/main/realtime.ts
index 80b6e142..86840ce3 100644
--- a/src/main/realtime.ts
+++ b/src/main/realtime.ts
@@ -23,8 +23,9 @@ import { getSecret, hasSecret } from './integrations';
* line (rt-1 COORD: Oscar also edits index.ts). */
const OPENAI_KEY_REF = 'apikey:openai';
-/** GA speech-to-speech model for the voice orchestrator (board: GA 2026-05-07). */
-export const REALTIME_MODEL = 'gpt-realtime-2';
+/** GA speech-to-speech model for the voice orchestrator (v0.3.4: bumped to the
+ * July 2026 gpt-realtime-2.1 — 25% p95 latency cut, better interruption handling). */
+export const REALTIME_MODEL = 'gpt-realtime-2.1';
/** GA ephemeral-secret mint endpoint. If an account/tier still answers the legacy
* beta shape, we fall back to /v1/realtime/sessions on a 404 and normalize both
diff --git a/src/main/realtimeActions.ts b/src/main/realtimeActions.ts
index 7f9fa448..3c9a0595 100644
--- a/src/main/realtimeActions.ts
+++ b/src/main/realtimeActions.ts
@@ -69,6 +69,20 @@ export interface RealtimeActionDeps {
/** rt-12: register a voice dispatch with the completion watcher so the engine can
* detect it finishing and speak the notice. Optional — wired in index.ts. */
trackDispatch?(d: { correlationId: string; targetAgentId: string; objective?: string; dispatchedAt: number; dispatchMessageId?: string }): void;
+ // ── v0.3.4 full-control extensions ──
+ controlResume(agentId: string): void;
+ controlAutoDelivery(agentId: string, paused: boolean): void;
+ controlGateTool(agentId: string, tool: string, on: boolean): void;
+ setArchived(agentId: string, archived: boolean): { ok: boolean; error?: string };
+ /** clear_context: push text into the agent's renderer message queue, so
+ * delivery rides EVERY existing gate (idle-only, boot grace, draft/picker
+ * safety, auto-delivery pause). */
+ enqueueToAgent(agentId: string, text: string): void;
+ /** update_setting: non-secret config snapshot + patch. The per-key policy
+ * table in THIS file is the only path from voice to config — never expose a
+ * raw patch. */
+ getConfigValue(key: string): unknown;
+ patchConfig(patch: Record<string, unknown>): void;
}
/** The result every action / confirm / cancel returns to the renderer tool, which
@@ -94,7 +108,50 @@ const VERBS: Record<string, { tier: Tier; confirmWord: string; agentTargeted: bo
kill: { tier: 'destructive', confirmWord: 'kill', agentTargeted: true },
pause: { tier: 'destructive', confirmWord: 'pause', agentTargeted: true },
halt: { tier: 'destructive', confirmWord: 'halt', agentTargeted: true },
- edit_schedule: { tier: 'destructive', confirmWord: 'schedule', agentTargeted: false }
+ edit_schedule: { tier: 'destructive', confirmWord: 'schedule', agentTargeted: false },
+ // ── v0.3.4 full-control extensions ──
+ resume: { tier: 'soft', confirmWord: 'resume', agentTargeted: true },
+ auto_delivery: { tier: 'soft', confirmWord: 'delivery', agentTargeted: true },
+ gate_tool: { tier: 'soft', confirmWord: 'gate', agentTargeted: true },
+ delete_task: { tier: 'soft', confirmWord: 'delete', agentTargeted: false },
+ unarchive: { tier: 'soft', confirmWord: 'unarchive', agentTargeted: true },
+ clear_context: { tier: 'destructive', confirmWord: 'clear', agentTargeted: true },
+ archive: { tier: 'destructive', confirmWord: 'archive', agentTargeted: true },
+ create_schedule: { tier: 'destructive', confirmWord: 'schedule', agentTargeted: false },
+ update_setting: { tier: 'destructive', confirmWord: 'setting', agentTargeted: false }
+};
+
+/** v0.3.4 update_setting policy — the ONLY settings voice can touch, each with
+ * a tier and typed validation. Everything not listed (harnessHome, every
+ * secret-bearing key, provider base URLs, integrations, …) is refused
+ * outright: the raw config carries credentials and dangerous keys, and the
+ * unvalidated config:update IPC must never be reachable from speech. */
+const SETTING_POLICY: Record<string, {
+ tier: 'soft' | 'confirm';
+ type: 'boolean' | 'number' | 'string';
+ min?: number; max?: number; values?: string[];
+}> = {
+ // soft: cosmetic / low-blast, instantly reversible
+ notifications: { tier: 'soft', type: 'boolean' },
+ tvShowOffices: { tier: 'soft', type: 'boolean' },
+ officeTheme: { tier: 'soft', type: 'string', values: ['office', 'friends', 'brooklyn99', 'siliconvalley', 'got', 'hogwarts'] },
+ terminalTheme: { tier: 'soft', type: 'string', values: ['light', 'dark'] },
+ freeflowEnabled: { tier: 'soft', type: 'boolean' },
+ strongKeepalive: { tier: 'soft', type: 'boolean' },
+ autoUpdate: { tier: 'soft', type: 'boolean' },
+ realtimeIdleDisconnectMs: { tier: 'soft', type: 'number', min: 30_000, max: 3_600_000 },
+ // confirm: behavior-changing — echo old→new + distinct token
+ autoMode: { tier: 'confirm', type: 'boolean' },
+ defaultModel: { tier: 'confirm', type: 'string' },
+ godProvider: { tier: 'confirm', type: 'string' },
+ godModel: { tier: 'confirm', type: 'string' },
+ maxConcurrentWorkers: { tier: 'confirm', type: 'number', min: 1, max: 16 },
+ costCapTokens: { tier: 'confirm', type: 'number', min: 0, max: 1_000_000_000 },
+ maxTurns: { tier: 'confirm', type: 'number', min: 1, max: 1000 },
+ slackEnabled: { tier: 'confirm', type: 'boolean' },
+ webhookEnabled: { tier: 'confirm', type: 'boolean' },
+ semanticMemory: { tier: 'confirm', type: 'boolean' },
+ multiWindow: { tier: 'confirm', type: 'boolean' }
};
const PENDING_TTL_MS = 120_000;
@@ -389,6 +446,67 @@ function execUpdateTask(deps: RealtimeActionDeps, a: Record<string, unknown>): A
return { ok: true, spoken: `Updated "${card.title}"${status ? ` to ${status}` : ''}.` };
}
+// ─── v0.3.4 soft executors ──────────────────────────────────────────────────
+
+function execResume(deps: RealtimeActionDeps, a: Record<string, unknown>): ActionResult {
+ const r = resolveAgent(str(a.agentId) || str(a.target) || str(a.name), deps.hiveRegistry());
+ if ('error' in r) return { ok: false, spoken: r.error };
+ deps.controlResume(r.id);
+ attribute(deps, 'resume', r.id);
+ return { ok: true, spoken: `Resumed ${r.name} — tools flow again.` };
+}
+
+function execAutoDelivery(deps: RealtimeActionDeps, a: Record<string, unknown>): ActionResult {
+ const r = resolveAgent(str(a.agentId) || str(a.target) || str(a.name), deps.hiveRegistry());
+ if ('error' in r) return { ok: false, spoken: r.error };
+ const raw = norm(str(a.state) || str(a.action) || (a.paused === true ? 'pause' : a.paused === false ? 'resume' : ''));
+ if (!raw) return { ok: false, spoken: 'Should I pause or resume message delivery?' };
+ const paused = /pause|off|hold|stop/.test(raw);
+ deps.controlAutoDelivery(r.id, paused);
+ attribute(deps, 'auto_delivery', r.id, { action: paused ? 'paused' : 'resumed' });
+ return {
+ ok: true,
+ spoken: paused
+ ? `Paused automatic delivery to ${r.name} — queued messages will wait.`
+ : `Resumed automatic delivery to ${r.name}.`
+ };
+}
+
+function execGateTool(deps: RealtimeActionDeps, a: Record<string, unknown>): ActionResult {
+ const r = resolveAgent(str(a.agentId) || str(a.target) || str(a.name), deps.hiveRegistry());
+ if ('error' in r) return { ok: false, spoken: r.error };
+ const toolName = str(a.tool) || str(a.toolName);
+ if (!toolName || !/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(toolName)) {
+ return { ok: false, spoken: 'Which tool should I gate? Give me its exact name, like Bash or WebFetch.' };
+ }
+ const raw = norm(str(a.state) || str(a.action));
+ const on = !/off|allow|ungate|unblock|enable/.test(raw); // default: gate it
+ deps.controlGateTool(r.id, toolName, on);
+ attribute(deps, 'gate_tool', r.id, { action: `${on ? 'gated' : 'ungated'} ${toolName}` });
+ return { ok: true, spoken: `${on ? 'Gated' : 'Un-gated'} the ${toolName} tool for ${r.name}.` };
+}
+
+function execDeleteTask(deps: RealtimeActionDeps, a: Record<string, unknown>): ActionResult {
+ const ref = str(a.taskId) || str(a.task) || str(a.title);
+ if (!ref) return { ok: false, spoken: 'Which task should I delete?' };
+ const { tasks, card, ambiguous } = findCard(deps, ref);
+ if (ambiguous) return { ok: false, spoken: `Which one — ${ambiguous.map((c) => `"${c.title}"`).join(', or ')}?` };
+ if (!card) return { ok: false, spoken: `I couldn't find a task matching "${ref}".` };
+ deps.hiveWriteTasks(tasks.filter((t) => t.id !== card.id));
+ attribute(deps, 'delete_task', card.id, { title: card.title.slice(0, 120) });
+ return { ok: true, spoken: `Deleted the task "${card.title}". Recreate it any time if that was wrong.` };
+}
+
+function execUnarchive(deps: RealtimeActionDeps, a: Record<string, unknown>): ActionResult {
+ const r = resolveAgent(str(a.agentId) || str(a.target) || str(a.name), deps.hiveRegistry());
+ if ('error' in r) return { ok: false, spoken: r.error };
+ const res = deps.setArchived(r.id, false);
+ attribute(deps, 'unarchive', r.id);
+ return res.ok
+ ? { ok: true, spoken: `Brought ${r.name} back from the archive.` }
+ : { ok: false, spoken: `Couldn't unarchive ${r.name}: ${res.error || 'unknown error'}.` };
+}
+
// ─── destructive commit builders (run AFTER confirm) ────────────────────────
function buildKill(deps: RealtimeActionDeps, r: ResolvedAgent): () => Promise<string> {
@@ -423,6 +541,26 @@ function buildSpawn(deps: RealtimeActionDeps, spec: RealtimeSpawnSpec, label: st
};
}
+function buildClearContext(deps: RealtimeActionDeps, r: ResolvedAgent): () => Promise<string> {
+ return async () => {
+ // Queue '/clear' through the renderer message queue: delivery inherits every
+ // existing safety gate (idle-only, boot grace, draft/picker protection).
+ deps.enqueueToAgent(r.id, '/clear');
+ attribute(deps, 'clear_context', r.id);
+ return `Queued a context clear for ${r.name} — it lands the moment they're idle.`;
+ };
+}
+
+function buildArchive(deps: RealtimeActionDeps, r: ResolvedAgent): () => Promise<string> {
+ return async () => {
+ const res = deps.setArchived(r.id, true);
+ attribute(deps, 'archive', r.id);
+ return res.ok
+ ? `Archived ${r.name} — off the floor, history kept. Say unarchive to bring them back.`
+ : `Couldn't archive ${r.name}: ${res.error || 'unknown error'}.`;
+ };
+}
+
function buildEditSchedule(
deps: RealtimeActionDeps,
mission: ScheduledMission,
@@ -452,18 +590,30 @@ function proposeDestructive(deps: RealtimeActionDeps, verb: string, a: Record<st
return { ok: false, spoken: `${verb} on all agents at once is voice-forbidden. Do it agent by agent, or use the UI.` };
const r = resolveAgent(rawTarget, reg);
if ('error' in r) return { ok: false, spoken: r.error };
- if (r.isGod)
+ // God policy per verb: kill/pause/halt/archive on god stay voice-forbidden.
+ // clear_context on god is ALLOWED behind confirm — it's recoverable
+ // (sessions resume) and "clear Michael's context" is a real operator need.
+ if (r.isGod && verb !== 'clear_context')
return { ok: false, spoken: `${verb} on the god orchestrator is voice-forbidden. That has to be done in the UI.` };
const commit =
- verb === 'kill' ? buildKill(deps, r) : verb === 'pause' ? buildPause(deps, r) : buildHalt(deps, r);
+ verb === 'kill' ? buildKill(deps, r)
+ : verb === 'pause' ? buildPause(deps, r)
+ : verb === 'halt' ? buildHalt(deps, r)
+ : verb === 'clear_context' ? buildClearContext(deps, r)
+ : buildArchive(deps, r);
const breaker = deps.controlSnapshot(r.id);
const note = breaker?.halted ? ' (note: already halted)' : breaker?.paused ? ' (note: already paused)' : '';
pending = { verb, confirmWord: spec.confirmWord, targetLabel: r.name, createdAt: Date.now(), commit };
+ const consequence = verb === 'clear_context'
+ ? `That wipes ${r.name}'s working memory of the current conversation.`
+ : verb === 'archive'
+ ? `That takes ${r.name} off the floor (history kept).`
+ : `That's destructive.`;
return {
ok: true,
needsConfirm: true,
- spoken: `You asked me to ${verb} ${r.name}${note}. That's destructive. To go ahead, say "confirm" or "${spec.confirmWord}". Say "cancel" to stop.`
+ spoken: `You asked me to ${verb.replace('_', ' ')} ${r.name}${note}. ${consequence} To go ahead, say "confirm" or "${spec.confirmWord}". Say "cancel" to stop.`
};
}
@@ -516,6 +666,90 @@ function proposeDestructive(deps: RealtimeActionDeps, verb: string, a: Record<st
};
}
+ // v0.3.4: create a brand-new schedule (edit_schedule only toggles/deletes).
+ if (verb === 'create_schedule') {
+ const label = str(a.label) || str(a.name) || str(a.title);
+ const body = str(a.prompt) || str(a.body) || str(a.message);
+ if (!label || !body) return { ok: false, spoken: 'I need a name for the schedule and what it should tell the agent.' };
+ const minutes = typeof a.intervalMinutes === 'number' && isFinite(a.intervalMinutes)
+ ? Math.min(7 * 24 * 60, Math.max(5, Math.round(a.intervalMinutes)))
+ : 60;
+ const to = str(a.to) || str(a.agentId) || 'god';
+ const target = resolveAgent(to, reg);
+ const targetId = 'error' in target ? 'god' : target.id;
+ const mission: ScheduledMission = {
+ id: `voice-${slug(label)}-${shortId()}`,
+ label,
+ intervalMs: minutes * 60_000,
+ to: targetId,
+ body,
+ enabled: true
+ };
+ pending = {
+ verb, confirmWord: 'schedule', targetLabel: label, createdAt: Date.now(),
+ commit: async () => {
+ deps.saveMissions([...deps.listMissions(), mission]);
+ attribute(deps, 'create_schedule', mission.id, { title: label.slice(0, 120) });
+ return `Created the "${label}" schedule — every ${minutes} minutes to ${targetId}.`;
+ }
+ };
+ return {
+ ok: true,
+ needsConfirm: true,
+ spoken: `You want a new schedule "${label}", every ${minutes} minutes, messaging ${targetId}. To create it, say "confirm" or "schedule". Say "cancel" to stop.`
+ };
+ }
+
+ // v0.3.4: settings, through the policy table ONLY.
+ if (verb === 'update_setting') {
+ const key = str(a.key) || str(a.setting) || str(a.name);
+ const policy = SETTING_POLICY[key];
+ if (!key) return { ok: false, spoken: 'Which setting should I change?' };
+ if (!policy) {
+ return { ok: false, spoken: `The "${key}" setting can't be changed by voice — use the Settings screen for that one.` };
+ }
+ // Coerce + validate the value against the key's declared type.
+ let value: unknown = a.value;
+ if (policy.type === 'boolean') {
+ if (typeof value === 'string') value = /^(true|on|yes|enable|enabled|1)$/i.test(value.trim());
+ if (typeof value !== 'boolean') return { ok: false, spoken: `Should ${key} be on or off?` };
+ } else if (policy.type === 'number') {
+ if (typeof value === 'string') value = parseFloat(value);
+ if (typeof value !== 'number' || !isFinite(value)) return { ok: false, spoken: `What number should ${key} be?` };
+ if (policy.min !== undefined && value < policy.min) return { ok: false, spoken: `${key} can't go below ${policy.min}.` };
+ if (policy.max !== undefined && value > policy.max) return { ok: false, spoken: `${key} can't go above ${policy.max}.` };
+ value = Math.round(value as number);
+ } else {
+ if (typeof value !== 'string' || !value.trim() || value.length > 200) {
+ return { ok: false, spoken: `What should ${key} be set to?` };
+ }
+ value = value.trim();
+ if (policy.values && !policy.values.includes(value as string)) {
+ return { ok: false, spoken: `${key} must be one of: ${policy.values.join(', ')}.` };
+ }
+ }
+ const oldValue = deps.getConfigValue(key);
+ const describe = (v: unknown): string => typeof v === 'boolean' ? (v ? 'on' : 'off') : String(v ?? 'unset');
+ if (describe(oldValue) === describe(value)) {
+ return { ok: true, spoken: `${key} is already ${describe(value)} — nothing to change.` };
+ }
+ const applyNow = (): string => {
+ deps.patchConfig({ [key]: value });
+ attribute(deps, 'update_setting', key, { action: `${describe(oldValue)} → ${describe(value)}` });
+ return `Done — ${key} is now ${describe(value)} (was ${describe(oldValue)}).`;
+ };
+ if (policy.tier === 'soft') {
+ // Low-blast keys apply immediately, like other soft verbs.
+ return { ok: true, spoken: applyNow() };
+ }
+ pending = { verb, confirmWord: 'setting', targetLabel: key, createdAt: Date.now(), commit: async () => applyNow() };
+ return {
+ ok: true,
+ needsConfirm: true,
+ spoken: `${key} is ${describe(oldValue)}; you want it ${describe(value)}. To change it, say "confirm" or "setting". Say "cancel" to stop.`
+ };
+ }
+
return { ok: false, spoken: `I don't know how to ${verb}.` };
}
@@ -535,6 +769,11 @@ function runAction(deps: RealtimeActionDeps, verb: string, a: Record<string, unk
case 'create_task': return execCreateTask(deps, a);
case 'assign_task': return execAssignTask(deps, a);
case 'update_task': return execUpdateTask(deps, a);
+ case 'resume': return execResume(deps, a);
+ case 'auto_delivery': return execAutoDelivery(deps, a);
+ case 'gate_tool': return execGateTool(deps, a);
+ case 'delete_task': return execDeleteTask(deps, a);
+ case 'unarchive': return execUnarchive(deps, a);
default: return { ok: false, spoken: `I don't know how to ${verb}.` };
}
}
diff --git a/src/main/realtimeFloorWatcher.ts b/src/main/realtimeFloorWatcher.ts
new file mode 100644
index 00000000..2009feec
--- /dev/null
+++ b/src/main/realtimeFloorWatcher.ts
@@ -0,0 +1,128 @@
+/**
+ * Realtime Michael — floor delta watcher (v0.3.4).
+ *
+ * The voice session's context strategy is "snapshot at connect + APPEND-ONLY
+ * deltas" (never session.update on instructions — that busts the prompt cache).
+ * This watcher is the delta half: while a voice session is live, it polls the
+ * floor's main-side signals and pushes short coalesced update sentences that
+ * the renderer injects into the conversation as silent items.
+ *
+ * Signals (all owned by main — no renderer trust):
+ * - roster: agents appearing / archiving (hive registry)
+ * - tasks: status transitions on the kanban ledger
+ * - activity: a pty flipping between quiet and streaming (≈ idle ↔ working)
+ * Deltas are debounced (≥ MIN_PUSH_GAP_MS between pushes) and coalesced into
+ * one parenthetical line, capped in length. When no session is live, nothing
+ * is emitted and nothing queues — the next connect takes a fresh snapshot.
+ */
+
+interface RegistryLike {
+ agents: Record<string, { name?: string; archived?: boolean }>;
+ godId?: string | null;
+}
+
+export interface FloorWatcherDeps {
+ enabled(): boolean;
+ registry(): RegistryLike;
+ tasks(): unknown;
+ ptys(): Array<{ id: string; lastOutputAt: number }>;
+ push(text: string): void;
+}
+
+const POLL_MS = 5_000;
+const MIN_PUSH_GAP_MS = 12_000;
+const ACTIVE_WINDOW_MS = 8_000;
+const MAX_PUSH_CHARS = 600;
+
+export class RealtimeFloorWatcher {
+ private deps: FloorWatcherDeps;
+ private timer: ReturnType<typeof setInterval> | null = null;
+ private live = false;
+ private lastPushAt = 0;
+ private buffer: string[] = [];
+ private prevAgents = new Map<string, { archived: boolean; name: string }>();
+ private prevTasks = new Map<string, { status: string; title: string }>();
+ private prevActive = new Map<string, boolean>();
+ private primed = false;
+
+ constructor(deps: FloorWatcherDeps) {
+ this.deps = deps;
+ }
+
+ start(): void {
+ if (this.timer) return;
+ this.timer = setInterval(() => { try { this.tick(); } catch { /* never throw from a timer */ } }, POLL_MS);
+ }
+
+ stop(): void {
+ if (this.timer) clearInterval(this.timer);
+ this.timer = null;
+ }
+
+ setSessionLive(live: boolean): void {
+ this.live = live;
+ // A fresh session starts from a fresh snapshot — old buffered deltas would
+ // duplicate what the snapshot already says.
+ this.buffer = [];
+ this.primed = false; // re-prime so the first tick after connect diffs from NOW
+ }
+
+ private tick(): void {
+ if (!this.deps.enabled()) return;
+
+ const reg = this.deps.registry();
+ const agents = new Map<string, { archived: boolean; name: string }>();
+ for (const [id, m] of Object.entries(reg.agents ?? {})) {
+ agents.set(id, { archived: !!m.archived, name: m.name || id });
+ }
+
+ const tasksRaw = this.deps.tasks() as { tasks?: Array<{ id?: string; status?: string; title?: string }> } | null;
+ const tasks = new Map<string, { status: string; title: string }>();
+ for (const t of Array.isArray(tasksRaw?.tasks) ? tasksRaw!.tasks! : []) {
+ if (typeof t?.id === 'string') tasks.set(t.id, { status: t.status ?? 'todo', title: t.title ?? t.id });
+ }
+
+ const now = Date.now();
+ const active = new Map<string, boolean>();
+ for (const p of this.deps.ptys()) {
+ active.set(p.id.replace(/^pty-/, ''), now - p.lastOutputAt < ACTIVE_WINDOW_MS);
+ }
+
+ if (this.primed && this.live) {
+ // roster changes
+ for (const [id, cur] of agents) {
+ const prev = this.prevAgents.get(id);
+ if (!prev) this.buffer.push(`${cur.name} joined the floor`);
+ else if (!prev.archived && cur.archived) this.buffer.push(`${cur.name} was archived`);
+ else if (prev.archived && !cur.archived) this.buffer.push(`${cur.name} is back from the archive`);
+ }
+ // task transitions
+ for (const [id, cur] of tasks) {
+ const prev = this.prevTasks.get(id);
+ if (!prev) this.buffer.push(`new task "${cur.title.slice(0, 60)}"`);
+ else if (prev.status !== cur.status) this.buffer.push(`task "${cur.title.slice(0, 60)}" moved to ${cur.status}`);
+ }
+ // activity flips (quiet ↔ streaming), named via the registry
+ for (const [id, isActive] of active) {
+ const prev = this.prevActive.get(id);
+ const name = agents.get(id)?.name;
+ if (prev === undefined || !name || agents.get(id)?.archived) continue;
+ if (prev && !isActive) this.buffer.push(`${name} went quiet (likely done or idle)`);
+ else if (!prev && isActive) this.buffer.push(`${name} started producing output`);
+ }
+ }
+
+ this.prevAgents = agents;
+ this.prevTasks = tasks;
+ this.prevActive = active;
+ this.primed = true;
+
+ if (!this.live || this.buffer.length === 0) { if (!this.live) this.buffer = []; return; }
+ if (now - this.lastPushAt < MIN_PUSH_GAP_MS) return;
+
+ const text = this.buffer.join('; ').slice(0, MAX_PUSH_CHARS);
+ this.buffer = [];
+ this.lastPushAt = now;
+ this.deps.push(text);
+ }
+}
diff --git a/src/preload/index.ts b/src/preload/index.ts
index c3d79d7e..064d7c30 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -1150,6 +1150,23 @@ const api = {
timeoutMs?: number
): Promise<{ summary: string; targetAgentId: string; taskId?: string } | { timedOut: true; taskId: string }> =>
ipcRenderer.invoke('realtime:waitFor', taskId, timeoutMs),
+ /** v0.3.4: coalesced floor deltas pushed while a voice session is live — the
+ * renderer injects them into the conversation as silent items. */
+ onRealtimeFloorDelta: (cb: (evt: { text: string }) => void): (() => void) => {
+ const listener = (_e: IpcRendererEvent, payload: { text: string }) => cb(payload);
+ ipcRenderer.on('realtime:floorDelta', listener);
+ return () => ipcRenderer.removeListener('realtime:floorDelta', listener);
+ },
+ /** v0.3.4: main-staged queue insertions (voice clear_context) — the renderer
+ * enqueues so delivery rides every existing safety gate. */
+ onRealtimeEnqueue: (cb: (evt: { agentId: string; text: string }) => void): (() => void) => {
+ const listener = (_e: IpcRendererEvent, payload: { agentId: string; text: string }) => cb(payload);
+ ipcRenderer.on('realtime:enqueue', listener);
+ return () => ipcRenderer.removeListener('realtime:enqueue', listener);
+ },
+ /** v0.3.4: app self-knowledge — version + newest changelog sections. */
+ appInfo: (): Promise<{ version: string; changelog: string }> =>
+ ipcRenderer.invoke('app:info'),
// ─── Roster mirror (agents + notes + queues, shared dev ↔ packaged) ─────────
/** Read the roster file beside the hive. SYNCHRONOUS on purpose: the zustand
* store is created at module load, so an async read would arrive after the
diff --git a/src/renderer/src/hooks/useHive.ts b/src/renderer/src/hooks/useHive.ts
index 21d5091d..8a66af35 100644
--- a/src/renderer/src/hooks/useHive.ts
+++ b/src/renderer/src/hooks/useHive.ts
@@ -858,6 +858,20 @@ export function useHive(config: HarnessConfig | null): void {
return () => { offSpawn?.(); offArchive?.(); };
}, [config?.onboardingComplete]);
+ // 5c) v0.3.4 voice bridge: main stages queue insertions (clear_context) and
+ // pushes them here, so delivery rides EVERY existing gate — idle-only,
+ // boot grace, draft/picker safety, auto-delivery pause. Main owns the
+ // confirm policy; this is just the enqueue.
+ useEffect(() => {
+ if (!config?.onboardingComplete) return;
+ return window.cth.onRealtimeEnqueue?.((evt) => {
+ if (!evt?.agentId || typeof evt.text !== 'string' || !evt.text.trim()) return;
+ const { agents, enqueueMessage } = useStore.getState();
+ if (!agents.some((a) => a.id === evt.agentId)) return;
+ enqueueMessage(evt.agentId, evt.text.trim());
+ });
+ }, [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 /compact
diff --git a/src/renderer/src/realtime/actions.ts b/src/renderer/src/realtime/actions.ts
index 428088ae..57066a57 100644
--- a/src/renderer/src/realtime/actions.ts
+++ b/src/renderer/src/realtime/actions.ts
@@ -249,6 +249,130 @@ export function realtimeActionTools(): ReturnType<typeof tool>[] {
execute: (input) => act('edit_schedule', input)
}),
+ // ── v0.3.4 full-control verbs ─────────────────────────────────────────
+ tool({
+ name: 'resume_agent',
+ description:
+ 'Resume a paused or halted agent so its tools flow again. Soft action — runs immediately. The undo for pause_agent / halt_agent.',
+ parameters: {
+ type: 'object',
+ properties: { agentId: { type: 'string', description: 'Agent name or id to resume.' } },
+ required: ['agentId'],
+ additionalProperties: false
+ },
+ execute: (input) => act('resume', input)
+ }),
+ tool({
+ name: 'set_auto_delivery',
+ description:
+ 'Pause or resume automatic message-queue delivery to one agent. Paused = queued messages wait until resumed. Soft action — runs immediately.',
+ parameters: {
+ type: 'object',
+ properties: {
+ agentId: { type: 'string', description: 'Agent name or id.' },
+ state: { type: 'string', enum: ['pause', 'resume'], description: 'pause holds the queue; resume lets it flow.' }
+ },
+ required: ['agentId', 'state'],
+ additionalProperties: false
+ },
+ execute: (input) => act('auto_delivery', input)
+ }),
+ tool({
+ name: 'gate_tool',
+ description:
+ 'Block (gate) or unblock one named tool for one agent — e.g. gate Bash for Jim. Soft action — runs immediately.',
+ parameters: {
+ type: 'object',
+ properties: {
+ agentId: { type: 'string', description: 'Agent name or id.' },
+ tool: { type: 'string', description: 'Exact tool name, e.g. Bash, WebFetch, Edit.' },
+ state: { type: 'string', enum: ['gate', 'allow'], description: 'gate blocks it; allow removes the block.' }
+ },
+ required: ['agentId', 'tool', 'state'],
+ additionalProperties: false
+ },
+ execute: (input) => act('gate_tool', input)
+ }),
+ tool({
+ name: 'delete_task',
+ description:
+ 'Delete one task card from the board by title or id. Soft action — runs immediately (recreate it if wrong).',
+ parameters: {
+ type: 'object',
+ properties: { taskId: { type: 'string', description: 'Task title or id to delete.' } },
+ required: ['taskId'],
+ additionalProperties: false
+ },
+ execute: (input) => act('delete_task', input)
+ }),
+ tool({
+ name: 'unarchive_agent',
+ description: 'Bring an archived agent back onto the roster. Soft action — runs immediately.',
+ parameters: {
+ type: 'object',
+ properties: { agentId: { type: 'string', description: 'Archived agent name or id.' } },
+ required: ['agentId'],
+ additionalProperties: false
+ },
+ execute: (input) => act('unarchive', input)
+ }),
+ tool({
+ name: 'clear_agent_context',
+ description:
+ "Queue a context clear (/clear) for one agent — wipes its working memory of the current conversation; delivery waits until the agent is idle. DESTRUCTIVE — returns an echo-back and asks for verbal confirmation ('clear' or 'confirm'). After the user confirms, call confirm_action. Allowed on the god orchestrator too (it can resume its session).",
+ parameters: {
+ type: 'object',
+ properties: { agentId: { type: 'string', description: 'Agent name or id whose context to clear.' } },
+ required: ['agentId'],
+ additionalProperties: false
+ },
+ execute: (input) => act('clear_context', input)
+ }),
+ tool({
+ name: 'archive_agent',
+ description:
+ 'Archive an agent — takes it off the floor, history kept (unarchive brings it back). DESTRUCTIVE — returns an echo-back and asks for verbal confirmation. After the user confirms, call confirm_action.',
+ parameters: {
+ type: 'object',
+ properties: { agentId: { type: 'string', description: 'Agent name or id to archive.' } },
+ required: ['agentId'],
+ additionalProperties: false
+ },
+ execute: (input) => act('archive', input)
+ }),
+ tool({
+ name: 'create_schedule',
+ description:
+ 'Create a NEW recurring schedule that messages an agent on an interval. DESTRUCTIVE — returns an echo-back and asks for verbal confirmation. After the user confirms, call confirm_action.',
+ parameters: {
+ type: 'object',
+ properties: {
+ label: { type: 'string', description: 'Short name for the schedule.' },
+ prompt: { type: 'string', description: 'The message the agent receives each time it fires.' },
+ intervalMinutes: { type: 'number', description: 'How often it fires, in minutes (min 5). Default 60.' },
+ to: { type: 'string', description: 'Target agent name or id. Default: the god orchestrator.' }
+ },
+ required: ['label', 'prompt'],
+ additionalProperties: false
+ },
+ execute: (input) => act('create_schedule', input)
+ }),
+ tool({
+ name: 'update_setting',
+ description:
+ "Change one app setting from the voice-allowed list. Cosmetic/low-risk keys (notifications, officeTheme, terminalTheme, freeflowEnabled, strongKeepalive, autoUpdate, tvShowOffices, realtimeIdleDisconnectMs) apply immediately; behavior-changing keys (autoMode, defaultModel, godProvider, godModel, maxConcurrentWorkers, costCapTokens, maxTurns, slackEnabled, webhookEnabled, semanticMemory, multiWindow) return an echo-back with old→new and need verbal confirmation ('setting' or 'confirm') — then call confirm_action. Secrets, folders and anything not listed are refused.",
+ parameters: {
+ type: 'object',
+ properties: {
+ key: { type: 'string', description: 'The exact setting key, e.g. autoMode or notifications.' },
+ value: { type: 'string', description: 'The new value: true/false, a number, or the option name.' }
+ },
+ required: ['key', 'value'],
+ additionalProperties: false
+ },
+ execute: (input) => act('update_setting', input)
+ }),
+
// ── confirm / cancel (drive the two-phase commit) ─────────────────────
tool({
name: 'confirm_action',
diff --git a/src/renderer/src/realtime/session.ts b/src/renderer/src/realtime/session.ts
index 8c7ead55..dd16e5a6 100644
--- a/src/renderer/src/realtime/session.ts
+++ b/src/renderer/src/realtime/session.ts
@@ -80,7 +80,9 @@ const MICHAEL_PERSONA =
VOICE & STYLE. You speak out loud over a live connection. Be concise and natural — like a sharp, calm chief of staff giving a verbal briefing. Lead with the answer in one sentence, then add detail only if it helps. Never read markdown, file paths, or code aloud unless asked. Use plain spoken numbers and names. Brevity is fine; the human can always ask for more.
-WHAT YOU CAN LOOK UP. You have live, read-only awareness of the WHOLE hive through your tools — use them liberally, and ALWAYS call the relevant one before answering a factual question. Your read tools:
+WHAT YOU CAN LOOK UP. You have live awareness of the WHOLE hive: a floor snapshot arrives when the call connects, short "(Floor update: …)" notes arrive as things change — trust those first — and your tools cover everything else. ALWAYS call the relevant tool before answering a factual question you can't answer from the snapshot and updates. Your read tools:
+- get_floor_state — the live floor in one call: every agent's status, context fill, breaker and inbox, plus in-flight tasks, as precise data. Prefer this for "what's everyone doing".
+- get_app_info — the Munder Difflin app itself: its version and the latest release notes. Use for "what version is this" or "what's new in this release".
- get_fleet_status — the live roster: who is active, who the god orchestrator is, and each worker's name, role, and engine.
- list_agents — the FULL roster INCLUDING archived (inactive) agents, with each agent's engine, working directory, context fill, and breaker state. Use it to enumerate everyone, find who is archived, or see who is near their context limit.
- get_agent_detail — everything about ONE agent (by name or id): its engine and model, its WORKING DIRECTORY, whether it's active or archived, live status, how full its context window is, tokens used, breaker state, and whether it has memory.
@@ -97,9 +99,11 @@ NEVER say "I can't access that", "the tool doesn't allow that", or "I don't have
HIVE VOCABULARY. Agents have an id like "creed-mqp3l5wn" and a friendly name like "Creed"; refer to them by name. "god" is the orchestrator whose voice you are. A card's status is todo, doing, blocked, or done. The circuit breaker is healthy, or steering an agent that's looping or idle. Blocked usually means waiting on the human.
-WHAT YOU CAN DO. Beyond reporting, you can now ACT on the hive by voice: ping an agent, dispatch a task as a 4-part work order, steer a running agent, create / assign / update task cards, hire a new agent, and pause / halt / kill agents or edit a schedule. Soft actions — ping, dispatch, steer, and task edits — happen immediately. Destructive or expensive ones — hire, kill, pause, halt, edit schedule — are NEVER done silently: you read the action back and wait for the human to confirm out loud.
+WHAT YOU CAN DO. Beyond reporting, you can ACT on the hive by voice: ping an agent, dispatch a task as a 4-part work order, steer a running agent, create / assign / update / delete task cards, hire a new agent, pause / RESUME / halt / kill agents, pause or resume an agent's message delivery, gate a tool for an agent, archive or unarchive an agent, clear an agent's context, create or edit schedules, and change app settings from the allowed list. Soft actions — ping, dispatch, steer, task edits, resume, delivery pause/resume, tool gating, unarchive, and cosmetic settings — happen immediately. Destructive or expensive ones — hire, kill, pause, halt, archive, clear context, schedule changes, and behavior-changing settings — are NEVER done silently: you read the action back and wait for the human to confirm out loud.
-CONFIRMATION POLICY (safety-critical). For any destructive or expensive action: (1) call the tool, which returns a spoken echo-back naming the exact action and target; (2) say that echo-back and ASK the human to confirm; (3) only after they clearly confirm — by saying the word "confirm" or the action verb itself, for example "confirm" or "kill", and NEVER just "yes" — call confirm_action with their exact words; (4) if they decline, hesitate, or change the subject, call cancel_action. Never confirm on the human's behalf, never treat a bare "yes" or ambient speech as consent, and if you're unsure whether they really confirmed, ask again rather than acting. Killing the god orchestrator and acting on all agents at once are forbidden — if asked, refuse and say why. Every action you take is attributed to you as michael-voice. Never claim to have done something you didn't, and never invent state.
+TOOL LATENCY. Tool calls take a moment. When you're about to call one, first say a short natural filler out loud — "let me check the floor", "one second, pulling that up" — then call it. Never sit silent through a look-up, and never invent the result before the tool returns.
+
+CONFIRMATION POLICY (safety-critical). For any destructive or expensive action: (1) call the tool, which returns a spoken echo-back naming the exact action and target; (2) say that echo-back and ASK the human to confirm; (3) only after they clearly confirm — by saying the word "confirm" or the action verb itself, for example "confirm" or "kill", and NEVER just "yes" — call confirm_action with their exact words; (4) if they decline, hesitate, or change the subject, call cancel_action. Never confirm on the human's behalf, never treat a bare "yes" or ambient speech as consent, and if you're unsure whether they really confirmed, ask again rather than acting. Killing, pausing, halting, or archiving the god orchestrator, and acting on all agents at once, are forbidden — if asked, refuse and say why. Clearing the god's context IS allowed, behind the same confirm. Every action you take is attributed to you as michael-voice. Never claim to have done something you didn't, and never invent state.
SHARED FLOOR (you are not the only orchestrator). god — the typing orchestrator — also acts on this hive, and every action you take is announced to god as michael-voice. The task board is the single source of truth. Before you dispatch work, create or assign tasks, or hire, glance at recent activity (your get_activity tool, and the snapshot you were given) so you don't duplicate or contradict something god just did. If you see god already handled what's asked, say so instead of doing it again.
@@ -126,6 +130,7 @@ let audioEl: HTMLAudioElement | null = null;
let connecting = false;
/** rt-12: unsubscribe handle for the completion push, active only while a session is live. */
let offCompletion: (() => void) | null = null;
+let offFloorDelta: (() => void) | null = null;
/** rt-9 cost guard: periodic tick that auto-disconnects on hard cost cap or after an
* idle open mic (curbs runaway audio spend on a forgotten session). */
let costGuardTimer: ReturnType<typeof setInterval> | null = null;
@@ -339,11 +344,13 @@ export async function connect(): Promise<void> {
} catch {
/* warm-start catch-up is best-effort */
}
+ // v0.3.4: the snapshot is NOT baked into instructions any more — a byte-stable
+ // persona+tools prefix stays fully prompt-cached across turns and sessions
+ // (cached input is ~99% cheaper). The snapshot goes in as the FIRST
+ // conversation item below, and the floor watcher appends deltas mid-call.
const agent = new RealtimeAgent({
name: 'Michael',
- instructions: warmStart
- ? `${MICHAEL_PERSONA}\n\nCURRENT HIVE SNAPSHOT (orientation only — call your tools for live detail):\n${warmStart}`
- : MICHAEL_PERSONA,
+ instructions: MICHAEL_PERSONA,
tools: [...realtimeReadTools(), ...realtimeActionTools()]
});
const s = new RealtimeSession(agent, {
@@ -374,6 +381,33 @@ export async function connect(): Promise<void> {
session = s;
resetRealtimeCost(Date.now()); // rt-9: start the live session cost meter
+ // v0.3.4: SILENT context injection — a raw conversation.item.create with no
+ // response.create, so the model absorbs the item without speaking. (This SDK
+ // version's sendMessage always triggers a response, so we go one level down
+ // to the transport for the silent path.)
+ const injectSilent = (text: string): void => {
+ try {
+ s.transport.sendEvent({
+ type: 'conversation.item.create',
+ item: {
+ type: 'message',
+ role: 'user',
+ content: [{ type: 'input_text', text }]
+ }
+ } as never);
+ } catch { /* injection is best-effort */ }
+ };
+ // The connect snapshot goes in as the FIRST conversation item (the greeting
+ // below opens the conversation; this just grounds it).
+ if (warmStart) {
+ injectSilent(`(Floor snapshot at connect — orientation only, call your tools for detail: ${sanitizeForVoice(warmStart)})`);
+ }
+ // Floor deltas — silent appends that keep Michael's picture live without
+ // touching the cached instructions prefix.
+ offFloorDelta = window.cth.onRealtimeFloorDelta?.((d) => {
+ if (session !== s) return;
+ injectSilent(`(Floor update: ${sanitizeForVoice(d.text)}. Mention it only when relevant — don't interrupt.)`);
+ }) ?? null;
// rt-12: mark the session live (main now pushes completions instead of queuing) and
// subscribe so a detected completion makes Michael speak it unprompted.
void window.cth.realtimeSetSessionLive(true);
@@ -455,6 +489,8 @@ export function disconnect(reason: string = 'user'): void {
// rt-12: stop receiving completion pushes; main will queue them until next connect.
offCompletion?.();
offCompletion = null;
+ offFloorDelta?.();
+ offFloorDelta = null;
void window.cth.realtimeSetSessionLive(false);
// Close the main-process mic gate so the realtime flag doesn't keep the mic permission
// open after we've stopped (fire-and-forget — tracks are already stopped above).
diff --git a/src/renderer/src/realtime/tools.ts b/src/renderer/src/realtime/tools.ts
index f50ce0a3..bea512ab 100644
--- a/src/renderer/src/realtime/tools.ts
+++ b/src/renderer/src/realtime/tools.ts
@@ -565,6 +565,51 @@ export function realtimeReadTools(): ReturnType<typeof tool>[] {
if (!text) return 'The board is empty right now.';
return clip(text, 1800);
}, 'board')
+ }),
+
+ // ── get_floor_state (v0.3.4) ──────────────────────────────────────────
+ tool({
+ name: 'get_floor_state',
+ description:
+ 'The LIVE floor in one call: every active agent with its current status, context fill, breaker state and inbox backlog, plus in-flight tasks. Returns compact JSON plus a one-line spoken summary. Prefer this for "what is everyone doing" style questions.',
+ parameters: { type: 'object', properties: {}, required: [], additionalProperties: false },
+ execute: () =>
+ spoken(async () => {
+ const dir = await window.cth.hiveAgentDirectory();
+ const tasksRaw = (await window.cth.hiveTasks()) as { tasks?: unknown } | null;
+ const tasks = Array.isArray(tasksRaw?.tasks) ? (tasksRaw!.tasks as unknown[]).map(obj) : [];
+ const rows = (Array.isArray(dir?.agents) ? (dir.agents as unknown[]) : [])
+ .map(obj)
+ .filter((a) => !a.archived)
+ .map((a) => ({
+ name: str(a.name) || str(a.id),
+ status: str(a.status) || 'unknown',
+ engine: str(a.provider) || undefined,
+ contextPct: typeof a.contextPct === 'number' ? a.contextPct : undefined,
+ breaker: str(a.breaker) && str(a.breaker) !== 'healthy' ? str(a.breaker) : undefined,
+ inbox: typeof a.inboxBacklog === 'number' && a.inboxBacklog > 0 ? a.inboxBacklog : undefined
+ }));
+ const doing = tasks.filter((t) => str(t.status) === 'doing').map((t) => ({ title: str(t.title), owner: str(t.assignee) || undefined }));
+ const blocked = tasks.filter((t) => str(t.status) === 'blocked').map((t) => ({ title: str(t.title), owner: str(t.assignee) || undefined }));
+ const summary = `${plural(rows.length, 'agent')} on the floor, ${doing.length} in progress, ${blocked.length} blocked.`;
+ // Flagged JSON per the Realtime prompting guidance: precise fields the
+ // model can quote verbatim, with the spoken line separate.
+ return `${summary} DATA: ${JSON.stringify({ agents: rows, doing, blocked })}`;
+ }, 'floor state')
+ }),
+
+ // ── get_app_info (v0.3.4) ─────────────────────────────────────────────
+ tool({
+ name: 'get_app_info',
+ description:
+ 'About the Munder Difflin app itself: the running version and the latest release notes (changelog). Use for "what version is this" or "what is new in this release".',
+ parameters: { type: 'object', properties: {}, required: [], additionalProperties: false },
+ execute: () =>
+ spoken(async () => {
+ const info = await window.cth.appInfo();
+ const notes = despan(info.changelog || '');
+ return `This is Munder Difflin version ${info.version}. ${notes ? `Latest release notes: ${clip(notes, 1600)}` : 'No release notes are bundled with this build.'}`;
+ }, 'app info')
})
];
}
@@ -577,41 +622,42 @@ export function realtimeReadTools(): ReturnType<typeof tool>[] {
*/
export async function realtimeSessionSummary(): Promise<string> {
try {
- // rt-7: also pull the recent hive log so the warm-start carries what the OTHER
- // orchestrator (god) + the floor have just been doing — dual-orchestrator awareness
- // so voice-Michael doesn't duplicate or contradict god's moves.
- const [reg, tasksRaw, logRaw] = await Promise.all([
- window.cth.hiveRegistry(),
- window.cth.hiveTasks(),
- window.cth.hiveLog(20).catch(() => [] as unknown[])
+ // v0.3.4: a COMPACT PER-AGENT TABLE, not just counts — most "what's
+ // happening" questions should be answerable from this alone, with zero
+ // tool round-trips. Injected as the FIRST CONVERSATION ITEM (not into the
+ // instructions), so the cached prompt prefix stays byte-stable.
+ const [dir, tasksRaw] = await Promise.all([
+ window.cth.hiveAgentDirectory(),
+ window.cth.hiveTasks()
]);
- const agents = Object.entries(obj(reg.agents));
- const active = agents.filter(([, a]) => !obj(a).archived).length;
- const godName = reg.godId ? str(obj(obj(reg.agents)[reg.godId]).name) || reg.godId : null;
- const list = Array.isArray(obj(tasksRaw).tasks) ? (obj(tasksRaw).tasks as unknown[]) : [];
- const doing = list.map(obj).filter((t) => str(t.status) === 'doing').length;
- const blocked = list.map(obj).filter((t) => str(t.status) === 'blocked').length;
- // Last few meaningful events (spawns, messages, voice actions), newest first.
- const events = Array.isArray(logRaw) ? logRaw : [];
- const recent = events
- .slice(-6)
- .reverse()
- .map((e) => {
- const o = obj(e);
- const kind = str(o.kind) || str(o.event) || 'event';
- const who = str(o.actor) || str(o.from) || str(o.agentId) || str(o.name);
- return who ? `${kind} by ${who}` : kind;
- })
- .filter(Boolean);
- const activity = recent.length ? ` Recent floor activity: ${recent.join('; ')}.` : '';
+ const rows = (Array.isArray(dir?.agents) ? (dir.agents as unknown[]) : []).map(obj).filter((a) => !a.archived);
+ const godRow = rows.find((a) => a.isGod === true);
+ const lines = rows.slice(0, 20).map((a) => {
+ const bits = [
+ `${str(a.name) || str(a.id)} is ${str(a.status) || 'in an unknown state'}`,
+ str(a.provider) ? `on ${str(a.provider)}` : '',
+ typeof a.contextPct === 'number' ? `context ${Math.round(a.contextPct as number)} percent full` : '',
+ str(a.breaker) && str(a.breaker) !== 'healthy' ? `breaker ${str(a.breaker)}` : '',
+ typeof a.inboxBacklog === 'number' && (a.inboxBacklog as number) > 0 ? `${a.inboxBacklog} unread` : ''
+ ].filter(Boolean);
+ return bits.join(', ');
+ });
+ const list = Array.isArray(obj(tasksRaw).tasks) ? (obj(tasksRaw).tasks as unknown[]).map(obj) : [];
+ const doing = list.filter((t) => str(t.status) === 'doing');
+ const blocked = list.filter((t) => str(t.status) === 'blocked');
+ const taskLine = [
+ doing.length
+ ? `In progress: ${doing.slice(0, 5).map((t) => `"${str(t.title)}"${str(t.assignee) ? ` with ${str(t.assignee)}` : ''}`).join('; ')}.`
+ : 'Nothing is in progress on the board.',
+ blocked.length ? `Blocked: ${blocked.slice(0, 4).map((t) => `"${str(t.title)}"`).join('; ')}.` : ''
+ ].filter(Boolean).join(' ');
return (
- `Current hive snapshot: ${plural(active, 'agent')} active` +
- `${godName ? `, ${godName} orchestrating alongside you` : ''}; ` +
- `${doing} task${doing === 1 ? '' : 's'} in progress` +
- `${blocked ? ` and ${plural(blocked, 'blocked')}` : ''}.` +
- activity +
- ` You share the floor with god (the typing orchestrator) — before you dispatch or create work,` +
- ` glance at recent activity so you don't duplicate what god just did. Use your read-tools for live detail.`
+ `Floor at connect — ${plural(rows.length, 'agent')} active` +
+ `${godRow ? `, ${str(godRow.name)} orchestrating alongside you` : ''}. ` +
+ `Per agent: ${lines.join(' | ') || 'none'}. ` +
+ taskLine +
+ ` You will also receive short "(Floor update: …)" notes as things change mid-call — trust those over this snapshot.` +
+ ` You share the floor with god (the typing orchestrator); the board is the single source of truth.`
);
} catch {
return '';