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
Merge branch 'feature/scheduled-missions' into integration/roadmap
Chaitanya Giri68ab3287062a
diff --cc src/main/index.tsindex bf068937,472abd93..1e3d6f00--- a/src/main/index.ts+++ b/src/main/index.ts@@@ -34,13 -32,37 +34,44 @@@ let mainWindow: BrowserWindow | null =/** When true, skip the quit interceptor (user already confirmed). */let allowQuit = false;+/** Agents spawned with `isolate: true` get a dedicated git worktree; this maps+ * the agent/pty id → the worktree path so we can tear it down on kill. */+const worktreePaths = new Map<string, string>();+/** id → the original repo cwd the worktree was created from (needed to run+ * `git worktree remove` from the parent tree, not the worktree itself). */+const worktreeOrigins = new Map<string, string>();++ /** Active scheduler timers keyed by mission id. */+ const missionTimers = new Map<string, NodeJS.Timeout>();++ /** Rebuild the scheduler from persisted config: clear every existing timer,+ * then arm a fresh interval for each enabled mission. Each tick dispatches the+ * mission to its target agent and stamps lastFiredAt back into config. Called+ * on boot (after the router starts) and after every missions:save. */+ function syncMissions(): void {+ for (const t of missionTimers.values()) clearInterval(t);+ missionTimers.clear();+ const missions = readConfig().missions ?? [];+ for (const m of missions) {+ if (!m.enabled || !(m.intervalMs > 0)) continue;+ const timer = setInterval(() => {+ try {+ if (hive.enabled()) {+ hive.send({ to: m.to, act: 'request', subject: m.label, body: m.body }, 'scheduler');+ }+ const current = readConfig().missions ?? [];+ const next = current.map((x) =>+ x.id === m.id ? { ...x, lastFiredAt: Date.now() } : x+ );+ writeConfig({ missions: next });+ } catch (e) {+ console.error('[scheduler] mission', m.id, e);+ }+ }, m.intervalMs);+ missionTimers.set(m.id, timer);+ }+ }+/** The live renderer webContents, or null if the window is gone/destroyed.* Anything that emits to the renderer from a timer/socket/child callback must* route through here — during quit the window can be destroyed while those@@@ -350,10 -333,14 +381,18 @@@ ipcMain.handle('app:resetAll', () =>app.exit(0);});+// ─── IPC: token telemetry (real usage + est. cost from CC transcripts) ───────+ipcMain.handle('hive:agentUsage', (_evt, cwd: unknown) =>+ typeof cwd === 'string' ? readAgentUsage(cwd) : null);++ // ─── IPC: scheduled missions (recurring auto-dispatch) ──────────────────────+ ipcMain.handle('missions:list', () => readConfig().missions ?? []);+ ipcMain.handle('missions:save', (_evt, missions) => {+ writeConfig({ missions: missions as ScheduledMission[] });+ syncMissions();+ return { ok: true };+ });+app.whenReady().then(() => {// Bootstrap the hive (if harnessHome is configured) and start the message router.if (hive.enabled()) {diff --cc src/preload/index.tsindex 16744eb4,be76bb45..f7dcc5a4--- a/src/preload/index.ts+++ b/src/preload/index.ts@@@ -245,16 -233,10 +257,21 @@@ const api =* into onboarding. The process exits, so this promise never resolves. */resetAll: (): Promise<void> => ipcRenderer.invoke('app:resetAll'),+ // ─── Token telemetry (real usage + est. cost from CC transcripts) ──────────+ /** Sum input/output/cache tokens + estimated USD cost for an agent from its+ * Claude Code transcripts. Returns null for an invalid cwd. */+ agentUsage: (cwd: string): Promise<AgentUsage | null> =>+ ipcRenderer.invoke('hive:agentUsage', cwd),++ // ─── Task kanban (hive/tasks.json) ───────────────────────────────────────+ /** Overwrite the hive task ledger with the full task list and commit it. */+ hiveWriteTasks: (tasks: HiveTask[]): Promise<{ ok: boolean; error?: string }> =>- ipcRenderer.invoke('hive:writeTasks', tasks)++ ipcRenderer.invoke('hive:writeTasks', tasks),+++ // ─── Scheduled missions (recurring auto-dispatch) ──────────────────────────+ listMissions: (): Promise<ScheduledMission[]> => ipcRenderer.invoke('missions:list'),+ saveMissions: (missions: ScheduledMission[]): Promise<{ ok: boolean }> =>+ ipcRenderer.invoke('missions:save', missions)};contextBridge.exposeInMainWorld('cth', api);diff --cc src/renderer/src/components/CommandCenterPanel.tsxindex 76bef3dd,dd9264b6..1544314b--- a/src/renderer/src/components/CommandCenterPanel.tsx+++ b/src/renderer/src/components/CommandCenterPanel.tsx@@@ -17,8 -16,27 +17,27 @@@ import { buildSpawnCommand, AGENT_MODEL* per-agent model + dispatch + assistant access), a memory view, and a live* activity feed / board / usage meter. */-type CCTab = 'terminal' | 'floor' | 'memory' | 'activity' | 'handbook';+type CCTab = 'terminal' | 'floor' | 'tasks' | 'memory' | 'activity' | 'handbook';+ /** A recurring auto-dispatched mission (mirrors the main-process config type). */+ interface ScheduledMission {+ id: string;+ label: string;+ intervalMs: number;+ to: string;+ body: string;+ enabled: boolean;+ lastFiredAt?: number;+ }++ /** Interval presets offered in the SCHEDULES form / shown as badges. */+ const INTERVAL_OPTS: { ms: number; label: string }[] = [+ { ms: 3600000, label: '1h' },+ { ms: 21600000, label: '6h' },+ { ms: 86400000, label: '24h' },+ { ms: 604800000, label: 'weekly' }+ ];+const TABS: { key: CCTab; label: string; icon: Parameters<typeof Icon>[0]['name'] }[] = [{ key: 'terminal', label: 'terminal', icon: 'terminal' },{ key: 'floor', label: 'floor', icon: 'mcp' },@@@ -151,16 -156,41 +170,47 @@@ function FloorTab({ seed }: { seed: { tconst [dispatchText, setDispatchText] = useState('');const [dispatchMsg, setDispatchMsg] = useState<string | null>(null);+ // ── Scheduled missions (recurring auto-dispatch) ──+ const [missions, setMissions] = useState<ScheduledMission[]>([]);+ const [mLabel, setMLabel] = useState('');+ const [mInterval, setMInterval] = useState<string>(String(INTERVAL_OPTS[0].ms));+ const [mTo, setMTo] = useState<string>('god');+ const [mBody, setMBody] = useState('');+useEffect(() => {window.cth.getConfig().then((c) => setRepos(c.registeredRepos ?? [])).catch(() => { /* noop */ });+ window.cth.listMissions().then(setMissions).catch(() => { /* noop */ });}, []);+ // Seed the dispatch box from a task-card "assign" (keyed on seq so repeat+ // assigns re-prefill). seq === 0 is the untouched initial state — skip it.+ useEffect(() => {+ if (seed.seq > 0) setDispatchText(seed.text);+ }, [seed.seq, seed.text]);++ const persistMissions = async (next: ScheduledMission[]) => {+ setMissions(next);+ await window.cth.saveMissions(next).catch(() => { /* noop */ });+ };+ const toggleMission = (id: string) =>+ persistMissions(missions.map((m) => (m.id === id ? { ...m, enabled: !m.enabled } : m)));+ const addMission = () => {+ if (!mLabel.trim() || !mBody.trim()) return;+ const next: ScheduledMission = {+ id: `m_${Date.now().toString(36)}`,+ label: mLabel.trim(),+ intervalMs: Number(mInterval),+ to: mTo,+ body: mBody.trim(),+ enabled: true+ };+ persistMissions([...missions, next]);+ setMLabel(''); setMBody('');+ };+ const targetName = (to: string) =>+ to === 'broadcast' ? 'everyone' : to === 'god' ? 'Michael' : agents.find((a) => a.id === to)?.name ?? to;+ const intervalLabel = (ms: number) => INTERVAL_OPTS.find((o) => o.ms === ms)?.label ?? `${Math.round(ms / 3600000)}h`;+const restartWithModel = async (a: Agent, model: string | undefined) => {if (!a.ptyId) return;setRestarting(a.id);