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
feat(5C): new avatar states — compacting (PreCompact) + looping (breaker)
Chaitanya Giri2f12f8e8c0cf
diff --git a/src/renderer/src/hooks/useHive.ts b/src/renderer/src/hooks/useHive.tsindex 9f7c7a10..2cb79444 100644--- a/src/renderer/src/hooks/useHive.ts+++ b/src/renderer/src/hooks/useHive.ts@@ -96,6 +96,10 @@ export function useHive(config: HarnessConfig | null): void {const assistantSpawning = useRef(false);// Reactive so the assistant bootstrap (effect #1b) re-runs once Michael is ready.const godStatus = useStore((s) => s.godStatus);+ // #5C/#7C.4 — latest circuit-breaker level per agent. When 'constrained'/+ // 'stopped' the avatar is pinned to 'looping' and hook events must NOT flip it+ // back to 'working' (the flicker the spec calls out); only a genuine Stop clears it.+ const breakerLevel = useRef<Record<string, string>>({});// 1) Bootstrap the god agent (source of truth = live PTYs, to dodge restarts).useEffect(() => {@@ -228,25 +232,36 @@ export function useHive(config: HarnessConfig | null): void {const { updateAgent, agents } = useStore.getState();const self = agents.find((a) => a.id === e.agentId);if (!self) return;+ // Breaker precedence (#5C): a constrained/stopped agent stays 'looping'+ // regardless of in-flight tool/prompt/compact events.+ const blevel = breakerLevel.current[e.agentId];+ const breakerArmed = blevel === 'constrained' || blevel === 'stopped';// Hook events are the authoritative status source for real agents (the// pty-stream parser only refines the on-floor action/station).- if (e.event === 'PreToolUse' && e.tool) {+ if (e.event === 'PreCompact') {+ // #5C — agent entered /compact; show it's boxing up context, not frozen.+ if (!breakerArmed) updateAgent(e.agentId, { status: 'compacting', action: 'compacting context', carrying: undefined });+ } else if (e.event === 'PostCompact') {+ if (!breakerArmed) updateAgent(e.agentId, { status: 'working', action: 'resumed', carrying: undefined });+ } else if (e.event === 'PreToolUse' && e.tool) {const m = stationForTool(e.tool);- updateAgent(e.agentId, { status: 'working', currentStation: m.station, carrying: m.carry, action: `using ${e.tool}` });+ if (!breakerArmed) updateAgent(e.agentId, { status: 'working', currentStation: m.station, carrying: m.carry, action: `using ${e.tool}` });useStore.getState().bumpToolCount(e.agentId); // usage proxy for the command center} else if (e.event === 'PostToolUse' || e.event === 'UserPromptSubmit') {// A turn is in progress (prompt submitted / tool just finished) — keep// it working so it doesn't flicker idle between tool calls.- updateAgent(e.agentId, { status: 'working' });+ if (!breakerArmed) updateAgent(e.agentId, { status: 'working' });} else if (e.event === 'Stop' || e.event === 'SubagentStop') {// A blocked Stop means the agent is being re-engaged to process its// inbox — it's NOT idle, so keep it working until it genuinely stops.if (e.blocked) {- updateAgent(e.agentId, { status: 'working', action: 'reading inbox', carrying: undefined });+ if (!breakerArmed) updateAgent(e.agentId, { status: 'working', action: 'reading inbox', carrying: undefined });} else {+ // A genuine stop clears any breaker override — the run is over.+ breakerLevel.current[e.agentId] = 'healthy';updateAgent(e.agentId, { status: 'idle', action: 'idle', carrying: undefined });}- } else if (e.event === 'Notification') {+ } else if (e.event === 'Notification' && !breakerArmed) {// Claude Code fires Notification for two very different situations:// 1. it genuinely needs the human (a permission / approval prompt), or// 2. the prompt has merely gone idle ("Claude is waiting for your@@ -275,6 +290,22 @@ export function useHive(config: HarnessConfig | null): void {});}, []);+ // 2b) Consume circuit-breaker state (#7C.4/#5C). Lane A's breaker policy (#6)+ // pushes BreakerState on `control:breakerState`; this gives it PRECEDENCE+ // over hook-derived status: a constrained/stopped agent is pinned to+ // 'looping' (see the breakerArmed guard above) until it genuinely Stops.+ useEffect(() => {+ return window.cth.onBreakerState((s) => {+ breakerLevel.current[s.agentId] = s.level;+ const { updateAgent, agents } = useStore.getState();+ if (!agents.some((a) => a.id === s.agentId)) return;+ if (s.level === 'constrained' || s.level === 'stopped') {+ updateAgent(s.agentId, { status: 'looping', action: s.reason || 'breaker armed', carrying: undefined });+ }+ // 'healthy'/'steering' clear the pin; the next hook event refreshes status.+ });+ }, []);+// 3) Wake idle agents holding unread inbox messages. The assistant is// send-only (it never receives inbox mail), so it's excluded.useEffect(() => {diff --git a/src/renderer/src/scene/office/Character.ts b/src/renderer/src/scene/office/Character.tsindex f15ebbe9..d79fb159 100644--- a/src/renderer/src/scene/office/Character.ts+++ b/src/renderer/src/scene/office/Character.ts@@ -11,7 +11,7 @@ import { ThoughtBubble } from './ThoughtBubble';// cover our status model.export type CharacterAnimation = 'idle' | 'walk' | 'type' | 'read';-export type StatusGlyph = 'none' | 'blocked' | 'success';+export type StatusGlyph = 'none' | 'blocked' | 'success' | 'compacting' | 'looping';function lerp(a: number, b: number, t: number): number {const tt = Math.min(Math.max(t, 0), 1);@@ -439,6 +439,19 @@ export class Character {g.rect(-0.5, yTop - s, 1, s * 2).fill(0xffd93d);g.rect(-s, yTop - 0.5, s * 2, 1).fill(0xffd93d);if (this.glyphElapsed > 0.9) this.setStatusGlyph('none');+ } else if (this.statusGlyph === 'compacting') {+ // #5C — violet box that rhythmically "packs down" (boxing up context).+ const p = (Math.sin(this.glyphElapsed * 6) + 1) / 2; // 0..1+ const s = 2 + p * 3;+ g.rect(-s, yTop - s, s * 2, s * 2).fill(0x9b7ede);+ } else if (this.statusGlyph === 'looping') {+ // #5C — orange 4-dot warning ring with one lit dot spinning around it.+ const idx = Math.floor(this.glyphElapsed * 8) % 4;+ const pts: [number, number][] = [[-3, yTop - 3], [3, yTop - 3], [3, yTop + 3], [-3, yTop + 3]];+ for (let i = 0; i < 4; i++) {+ const [x, y] = pts[i];+ g.rect(x - 1, y - 1, 2, 2).fill(i === idx ? 0xff9f43 : 0x6b5878);+ }}}diff --git a/src/renderer/src/scene/office/OfficeFloor.tsx b/src/renderer/src/scene/office/OfficeFloor.tsxindex 0b38d4a9..541a72a7 100644--- a/src/renderer/src/scene/office/OfficeFloor.tsx+++ b/src/renderer/src/scene/office/OfficeFloor.tsx@@ -523,6 +523,20 @@ export function OfficeFloor() {c.showThought(liveActivity(agent, 'needs you'));c.walkToTile(rt.waitTile);break;+ case 'compacting':+ // #5C — mid-/compact: stay put at the desk, "boxing up" glyph + thought,+ // so an agent compacting context reads as busy rather than frozen.+ c.setStatusGlyph('compacting');+ c.sitAtDesk(true);+ c.showThought(liveActivity(agent, 'compacting context'));+ break;+ case 'looping':+ // #5C — circuit-breaker armed (#6): hold position with the spinning+ // warning glyph so a runaway agent is visible on the floor.+ c.setStatusGlyph('looping');+ c.sitAtDesk(false);+ c.showThought(liveActivity(agent, 'looping — breaker armed'));+ break;case 'success':c.setStatusGlyph('success');c.hideThought();