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: enhance HookServer with standing goal functionality

George Burchell44d5f8835773
diff --git a/src/main/hooks.ts b/src/main/hooks.ts
index 52195d84..4f16e677 100644
--- a/src/main/hooks.ts
+++ b/src/main/hooks.ts
@@ -67,7 +67,10 @@ export class HookServer {
private control?: ControlRegistry,
/** Circuit breaker (Lane A #6.6b) — fed the hook-derived signals (session id,
* repeated identical tool calls). Optional so the server still runs without it. */
- private breaker?: CircuitBreaker
+ private breaker?: CircuitBreaker,
+ /** Standing goal text for an agent (from the durable roster). Optional so
+ * tests can omit it; when set, injected on SessionStart / UserPromptSubmit. */
+ private getStandingGoal?: (agentId: string) => string | null
) {}
start(): void {
@@ -258,12 +261,22 @@ export class HookServer {
&& !!agentId && this.hive.isGod(agentId);
const roster = wantsRoster ? this.hive.rosterContext() : null;
- if (steer || roster) {
+ // Standing goal (hire Briefing) — durable roster field, re-read every cycle so
+ // an Edit Agent save is picked up on the next SessionStart / UserPromptSubmit
+ // without restarting the worker. Kept out of --append-system-prompt (volatile-
+ // free cache invariant); lives on the live hook channel instead.
+ const wantsGoal = (event === 'SessionStart' || event === 'UserPromptSubmit') && !!agentId;
+ const goalRaw = wantsGoal ? (this.getStandingGoal?.(agentId) ?? null) : null;
+ const goal = goalRaw
+ ? `<goal>\n${goalRaw}\n</goal>`
+ : null;
+
+ if (steer || roster || goal) {
this.emit(agentId, event, p);
return {
hookSpecificOutput: {
hookEventName: event,
- additionalContext: [roster, steer].filter(Boolean).join('\n\n')
+ additionalContext: [roster, goal, steer].filter(Boolean).join('\n\n')
}
};
}
diff --git a/src/main/index.ts b/src/main/index.ts
index cb30da18..14468dd4 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -258,9 +258,30 @@ let breakerBeatTimer: ReturnType<typeof setInterval> | null = null;
// Feed the breaker's api_error-storm trip from Oscar's OTel api_error spans —
// Jim's one breaker input with no on-branch source (telemetry.onApiError seam).
telemetry.onApiError((agentId) => breaker.recordError(agentId));
+// Shared roster on disk — created early so HookServer can re-read standing goals
+// on every UserPromptSubmit (Edit Agent saves land here via persistAgents).
+const roster = new RosterStore(() => readConfig().harnessHome);
+function standingGoalFromRoster(agentId: string): string | null {
+ const snap = roster.read();
+ if (!snap || !Array.isArray(snap.agents)) return null;
+ for (const entry of snap.agents) {
+ if (!entry || typeof entry !== 'object') continue;
+ const a = entry as { id?: unknown; goal?: unknown };
+ if (a.id !== agentId) continue;
+ return typeof a.goal === 'string' && a.goal.trim() ? a.goal.trim() : null;
+ }
+ return null;
+}
// HookServer needs BOTH: Oscar's control registry (HITL pause/gate/steer/halt via
// hook returns) AND Jim's breaker (feed recordToolUse on each PostToolUse).
-const hookServer = new HookServer(hive, () => liveWebContents(), () => readConfig(), control, breaker);
+const hookServer = new HookServer(
+ hive,
+ () => liveWebContents(),
+ () => readConfig(),
+ control,
+ breaker,
+ standingGoalFromRoster
+);
const memory = new MemoryManager(
() => readConfig().harnessHome,
() => { const c = readConfig(); return { enabled: c.semanticMemory !== false, model: c.embeddingModel ?? 'minilm' }; }
@@ -3053,7 +3074,7 @@ ipcMain.handle('git:checkout', async (_evt, cwd: unknown, ref: unknown, detach:
// IPC could resolve, so the read is `ipcMain.on` + `returnValue` — one blocking
// round trip at boot, in exchange for the roster being correct on first paint
// instead of flashing an empty floor and then filling in.
-const roster = new RosterStore(() => readConfig().harnessHome);
+// (`roster` itself is constructed earlier so HookServer can read standing goals.)
ipcMain.on('roster:readSync', (evt) => { evt.returnValue = roster.read(); });
ipcMain.handle('roster:read', () => roster.read());
ipcMain.handle('roster:write', (_evt, snap: unknown) => roster.write(snap));
diff --git a/src/renderer/src/components/AgentDetailPanel.tsx b/src/renderer/src/components/AgentDetailPanel.tsx
index b1b73ed8..8933e1a2 100644
--- a/src/renderer/src/components/AgentDetailPanel.tsx
+++ b/src/renderer/src/components/AgentDetailPanel.tsx
@@ -12,6 +12,7 @@ import { SidebarTabs } from './SidebarTabs';
import { ThreadsPanel } from './ThreadsPanel';
import { ToolWaterfall } from './ToolWaterfall';
import { AgentControlStrip } from './AgentControlStrip';
+import { EditAgentModal } from './EditAgentModal';
import { GitTab } from './GitTab';
import { Icon } from './Icon';
import { useStore, type Agent } from '@/store/store';
@@ -24,6 +25,7 @@ export interface AgentDetailPanelProps {
export function AgentDetailPanel({ agent }: AgentDetailPanelProps) {
const [openTerminalState, setOpenTerminalState] = useState<'idle' | 'opening' | 'ok' | 'error'>('idle');
const [openTerminalError, setOpenTerminalError] = useState<string | undefined>();
+ const [editOpen, setEditOpen] = useState(false);
const archiveAgent = useStore(s => s.archiveAgent);
const updateAgent = useStore(s => s.updateAgent);
const setFullscreen = useStore(s => s.setFullscreen);
@@ -117,6 +119,14 @@ export function AgentDetailPanel({ agent }: AgentDetailPanelProps) {
}}>{agent.project}</span>
</div>
</div>
+ <PixelButton
+ variant="secondary"
+ size="sm"
+ onClick={() => setEditOpen(true)}
+ title="Edit identity, engine, and briefing"
+ >
+ edit
+ </PixelButton>
{/* v0.3.4: the IDE lives at agent level (replaces the old files tab) —
opens the full-window Monaco editor rooted at this agent's workspace. */}
<PixelButton variant="secondary" size="sm" onClick={() => useStore.getState().setIdeOpen(true)}>
@@ -201,6 +211,10 @@ export function AgentDetailPanel({ agent }: AgentDetailPanelProps) {
<ToolWaterfall agentId={agent.id} />
)}
</div>
+
+ {editOpen && (
+ <EditAgentModal agent={agent} onClose={() => setEditOpen(false)} />
+ )}
</PixelPanel>
);
}
diff --git a/src/renderer/src/components/EditAgentModal.tsx b/src/renderer/src/components/EditAgentModal.tsx
new file mode 100644
index 00000000..bc92f105
--- /dev/null
+++ b/src/renderer/src/components/EditAgentModal.tsx
@@ -0,0 +1,329 @@
+import { useEffect, useState, type CSSProperties } from 'react';
+import { PixelPanel } from './PixelPanel';
+import { PixelButton } from './PixelButton';
+import { SpritePortrait } from './SpritePortrait';
+import { ProviderLogo } from './ProviderLogo';
+import { useStore, type Agent } from '@/store/store';
+import { OFFICE_CAST, type OfficeCharacterName } from '@/scene/office/cast';
+import { type AccentColorName } from '@/design/tokens';
+import {
+ type AgentProvider,
+ type HarnessConfig,
+ AGENT_PROVIDER_PRESETS,
+ buildSpawnCommand,
+ modelsForProvider,
+ inferAgentProvider,
+ providerPreset,
+ isClaudeProvider
+} from '@/store/config';
+
+const ACCENTS: AccentColorName[] = ['coral', 'mint', 'sky', 'lemon', 'lilac', 'peach'];
+
+export interface EditAgentModalProps {
+ agent: Agent;
+ onClose: () => void;
+}
+
+/**
+ * Compact post-hire editor for Identity / Engine / Briefing. Mirrors the Add
+ * Agent fields that matter after spawn; save only patches the durable roster
+ * via updateAgent (engine changes apply on the next restart).
+ */
+export function EditAgentModal({ agent, onClose }: EditAgentModalProps) {
+ const updateAgent = useStore((s) => s.updateAgent);
+ const [config, setConfig] = useState<HarnessConfig | null>(null);
+
+ const [name, setName] = useState(agent.name);
+ const [character, setCharacter] = useState<OfficeCharacterName>(agent.character);
+ const [accent, setAccent] = useState<AccentColorName>(agent.accent);
+ const [provider, setProvider] = useState<AgentProvider>(
+ inferAgentProvider(agent.command, agent.provider)
+ );
+ const [model, setModel] = useState<string | undefined>(agent.model);
+ const [description, setDescription] = useState(agent.description);
+ const [goal, setGoal] = useState(agent.goal ?? '');
+
+ useEffect(() => {
+ void window.cth.getConfig().then(setConfig).catch(() => setConfig(null));
+ }, []);
+
+ // Keep form in sync when the selected agent changes while the modal is open.
+ useEffect(() => {
+ setName(agent.name);
+ setCharacter(agent.character);
+ setAccent(agent.accent);
+ setProvider(inferAgentProvider(agent.command, agent.provider));
+ setModel(agent.model);
+ setDescription(agent.description);
+ setGoal(agent.goal ?? '');
+ }, [agent.id]);
+
+ const pickProvider = (id: AgentProvider) => {
+ setProvider(id);
+ if (!config) {
+ setModel(undefined);
+ return;
+ }
+ const nextModel = isClaudeProvider(id) ? config.defaultModel : config.providerDefaultModels?.[id];
+ setModel(nextModel);
+ };
+
+ const preset = providerPreset(provider);
+
+ const save = () => {
+ const trimmedName = name.trim() || agent.name;
+ const trimmedDescription = description.trim() || 'a fresh harness';
+ const trimmedGoal = goal.trim();
+ const command = config
+ ? buildSpawnCommand(config, model, provider)
+ : agent.command;
+
+ updateAgent(agent.id, {
+ name: trimmedName,
+ character,
+ accent,
+ provider,
+ model,
+ command,
+ description: trimmedDescription,
+ goal: trimmedGoal || undefined
+ });
+ onClose();
+ };
+
+ return (
+ <div
+ onClick={onClose}
+ style={{
+ position: 'fixed', inset: 0,
+ background: 'rgba(26, 19, 32, 0.6)',
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
+ zIndex: 500
+ }}
+ >
+ <div onClick={(e) => e.stopPropagation()} style={{ width: 520, maxWidth: '94vw' }}>
+ <PixelPanel variant="dialog" title="EDIT AGENT" style={{ padding: 16 }} noPadding>
+ <div style={{
+ display: 'flex', flexDirection: 'column', gap: 14,
+ padding: 16, maxHeight: '82vh', overflowY: 'auto'
+ }}>
+ <Section label="Identity" hint="name · character · color">
+ <Row label="Name">
+ <input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="Stanley"
+ style={inputStyle}
+ autoFocus
+ />
+ </Row>
+
+ <Row label="Character">
+ <div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
+ {OFFICE_CAST.map((c) => {
+ const active = character === c.name;
+ return (
+ <button
+ key={c.name}
+ type="button"
+ onClick={() => { setCharacter(c.name); setName(c.displayName); }}
+ title={c.blurb}
+ style={{
+ padding: 4,
+ background: active ? `var(--cth-${accent}-light)` : 'var(--cth-cream-100)',
+ boxShadow: active
+ ? 'inset 0 0 0 1.5px var(--cth-ink-500)'
+ : 'inset 0 0 0 1px var(--cth-ink-100)',
+ cursor: 'pointer', border: 'none', width: 52,
+ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2
+ }}
+ >
+ <div style={{
+ width: 40, height: 48,
+ display: 'flex', alignItems: 'flex-end', justifyContent: 'center',
+ overflow: 'hidden'
+ }}>
+ <SpritePortrait character={c.name} scale={1.5} />
+ </div>
+ <span style={{ fontSize: 10, color: 'var(--cth-ink-700)' }}>{c.displayName}</span>
+ </button>
+ );
+ })}
+ </div>
+ </Row>
+
+ <Row label="Color">
+ <div style={{ display: 'flex', gap: 6 }}>
+ {ACCENTS.map((a) => (
+ <button
+ key={a}
+ type="button"
+ onClick={() => setAccent(a)}
+ title={a}
+ style={{
+ width: 28, height: 28,
+ background: `var(--cth-${a})`,
+ boxShadow: accent === a
+ ? 'inset 0 0 0 1.5px var(--cth-ink-500), 0 0 0 2px var(--cth-ink-900)'
+ : 'inset 0 0 0 1px var(--cth-ink-300)',
+ cursor: 'pointer', border: 'none'
+ }}
+ />
+ ))}
+ </div>
+ </Row>
+ </Section>
+
+ <Section label="Engine" hint="provider · model · next restart">
+ <Row label="Provider">
+ <div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
+ {AGENT_PROVIDER_PRESETS.map((p) => {
+ const active = provider === p.id;
+ return (
+ <button
+ key={p.id}
+ type="button"
+ onClick={() => pickProvider(p.id)}
+ title={p.label}
+ style={{
+ padding: '3px 8px 1px',
+ background: active ? `var(--cth-${accent}-light)` : 'var(--cth-cream-100)',
+ boxShadow: active
+ ? 'inset 0 0 0 1.5px var(--cth-ink-500)'
+ : 'inset 0 0 0 1px var(--cth-ink-100)',
+ fontFamily: 'var(--cth-font-ui)', fontSize: 12,
+ color: 'var(--cth-ink-900)', cursor: 'pointer', border: 'none',
+ display: 'inline-flex', alignItems: 'center', gap: 6
+ }}
+ >
+ <ProviderLogo provider={p.id} size={14} />
+ {p.label}
+ </button>
+ );
+ })}
+ </div>
+ </Row>
+
+ {preset.supportsModel && (
+ <Row label="Model">
+ <div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
+ {(() => {
+ const known = modelsForProvider(provider);
+ return model && !known.some((m) => m.id === model)
+ ? [...known, { id: model, label: `${model} (current)` }]
+ : known;
+ })().map((m) => {
+ const active = (model ?? '') === (m.id ?? '');
+ return (
+ <button
+ key={m.label}
+ type="button"
+ onClick={() => setModel(m.id)}
+ title={m.id ?? 'CLI default model'}
+ style={{
+ padding: '3px 8px 1px',
+ background: active ? `var(--cth-${accent}-light)` : 'var(--cth-cream-100)',
+ boxShadow: active
+ ? 'inset 0 0 0 1.5px var(--cth-ink-500)'
+ : 'inset 0 0 0 1px var(--cth-ink-100)',
+ fontFamily: 'var(--cth-font-ui)', fontSize: 12,
+ color: 'var(--cth-ink-900)', cursor: 'pointer', border: 'none'
+ }}
+ >
+ {m.label}
+ </button>
+ );
+ })}
+ </div>
+ </Row>
+ )}
+
+ <span style={{ fontSize: 12, color: 'var(--cth-ink-500)', lineHeight: '16px' }}>
+ Engine changes are saved for the next restart. Use Command Center → Floor to restart a live session onto a new provider/model now.
+ </span>
+ </Section>
+
+ <Section label="Briefing" hint="description · goal">
+ <Row label="Description">
+ <input
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ placeholder="what is this agent for"
+ style={inputStyle}
+ />
+ </Row>
+
+ <Row label="Goal (optional)">
+ <textarea
+ value={goal}
+ onChange={(e) => setGoal(e.target.value)}
+ placeholder="long-running directive injected on every prompt"
+ rows={4}
+ style={{ ...inputStyle, fontFamily: 'var(--cth-font-ui)', resize: 'vertical', minHeight: 72 }}
+ />
+ </Row>
+ </Section>
+
+ <div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 4 }}>
+ <PixelButton variant="ghost" size="md" onClick={onClose}>cancel</PixelButton>
+ <div style={{ flex: 1 }} />
+ <PixelButton variant="primary" size="md" onClick={save}>save changes</PixelButton>
+ </div>
+ </div>
+ </PixelPanel>
+ </div>
+ </div>
+ );
+}
+
+const inputStyle: CSSProperties = {
+ width: '100%',
+ padding: '6px 8px 4px',
+ background: 'var(--cth-paper-100)',
+ border: 'none',
+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-100)',
+ fontFamily: 'var(--cth-font-ui)',
+ fontSize: 16,
+ color: 'var(--cth-ink-900)',
+ outline: 'none',
+ boxSizing: 'border-box'
+};
+
+function Section({
+ label,
+ hint,
+ children
+}: {
+ label: string;
+ hint: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
+ <div style={{ display: 'flex', alignItems: 'baseline', gap: 8 }}>
+ <span style={{
+ fontFamily: 'var(--cth-font-display)',
+ fontSize: 9, lineHeight: '12px',
+ color: 'var(--cth-ink-900)',
+ textTransform: 'uppercase'
+ }}>{label}</span>
+ <span style={{ fontSize: 11, color: 'var(--cth-ink-500)' }}>{hint}</span>
+ </div>
+ {children}
+ </div>
+ );
+}
+
+function Row({ label, children }: { label: string; children: React.ReactNode }) {
+ return (
+ <label style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
+ <span style={{
+ fontFamily: 'var(--cth-font-display)',
+ fontSize: 8, lineHeight: '12px',
+ color: 'var(--cth-ink-700)',
+ textTransform: 'uppercase'
+ }}>{label}</span>
+ {children}
+ </label>
+ );
+}
diff --git a/src/renderer/src/hooks/useHive.ts b/src/renderer/src/hooks/useHive.ts
index c7b10fd3..96e31ec4 100644
--- a/src/renderer/src/hooks/useHive.ts
+++ b/src/renderer/src/hooks/useHive.ts
@@ -16,6 +16,7 @@ import {
} from '../../../shared/providerAutomation';
import { DEFAULT_CONTEXT_TRIGGER, type ContextRule } from '../../../shared/triggers';
import type { AgentProvider } from '../../../shared/agentProvider';
+import { bridgeOf, providerPreset } from '../../../shared/agentProvider';
import { acquireTerminal, resetTerminal, isTerminalAutomationSafe } from '@/components/terminalPool';
import { deliverWithAcknowledgement } from './queueDelivery';
import { OFFICE_CAST, DEFAULT_CHARACTER } from '@/scene/office/cast';
@@ -46,6 +47,26 @@ const BOOT_GRACE_MS = 35_000;
// submitToPty additionally waits for the terminal's readiness handshake.
const SEED_BOOT_MS = 12_000;
+/** Hive-aware / hooks-bridge engines get standing goals via HookServer
+ * (SessionStart + UserPromptSubmit). Cursor and other no-hook engines need the
+ * goal prepended onto queued PTY deliveries so an Edit Agent save still lands
+ * on the next drain cycle without a restart. */
+function usesHookStandingGoal(agent: Agent): boolean {
+ const provider = inferAgentProvider(agent.command, agent.provider);
+ const preset = providerPreset(provider);
+ if (preset.hiveAware) return true;
+ return bridgeOf(provider)?.kind === 'hooks';
+}
+
+/** Prepend `<goal>…</goal>` for engines that cannot inject via hooks. Reads the
+ * live store field, so a just-saved goal is picked up on the next queue flush. */
+function withStandingGoal(agent: Agent, text: string): string {
+ const goal = agent.goal?.trim();
+ if (!goal || usesHookStandingGoal(agent)) return text;
+ if (text.includes('<goal>')) return text;
+ return `<goal>\n${goal}\n</goal>\n\n${text}`;
+}
+
// The first thing Michael (god) is told on a fresh spawn — orient him and put
// him to work running the floor. Kept terse and action-oriented.
const INITIAL_GOD_PROMPT = [
@@ -657,7 +678,11 @@ export function useHive(config: HarnessConfig | null): void {
useStore.getState().updateAgent(a.id, { seedPrompt: seed });
return;
}
- submitToPty(ptyId, seed, inferAgentProvider(live.command, live.provider))
+ submitToPty(
+ ptyId,
+ withStandingGoal(live, seed),
+ inferAgentProvider(live.command, live.provider)
+ )
.catch(() => { /* pty may have died */ });
}, SEED_BOOT_MS);
}
@@ -717,7 +742,10 @@ export function useHive(config: HarnessConfig | null): void {
// the PTY; UI/card surfaces continue to show the readable `text`.
() => submitToPty(
target.ptyId!,
- wrap ? wrap(next) : (next.instruction ?? next.text),
+ withStandingGoal(
+ target,
+ wrap ? wrap(next) : (next.instruction ?? next.text)
+ ),
inferAgentProvider(target.command, target.provider)
),
() => {