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: PR #78 (session resume + Restart & Continue) onto v0.2.7 main
Chaitanya Giri46c000dbda04
diff --cc src/main/index.tsindex d96e3b49,0a0d1282..1f194784--- a/src/main/index.ts+++ b/src/main/index.ts@@@ -19,10 -19,9 +19,10 @@@ import { HookServer } from './hooks'import { CircuitBreaker, type BreakerInput } from './breaker';import type { UsageProvider } from './usage';import { MemoryManager } from './memory';+import { KnowledgeManager } from './knowledge';import { MemoryReflector, type ReflectSettings } from './reflect';import { PersistStore } from './db';- import { readAgentUsage, readContextTokens } from './transcript';+ import { readAgentUsage, readContextTokens, seedSessionTranscript, resolveSessionCwd } from './transcript';import { listIssues, listCIRuns } from './github';import { SlackWebhookServer, SlackReplyServer, postSlackReply, type SlackEventFile } from './slack';import { WebhookServer, type WebhookInbound, type WebhookTaskStatus } from './webhook';@@@ -1341,7 -1197,7 +1341,7 @@@ function installAppMenu(): void}// ─── IPC: pty lifecycle ─────────────────────────────────────────────────────- ipcMain.handle('pty:spawn', async (evt, opts: SpawnOptions & { hive?: AgentMeta; isolate?: boolean; resume?: boolean; provider?: AgentProvider }) => {-ipcMain.handle('pty:spawn', async (_evt, opts: SpawnOptions & { hive?: AgentMeta; isolate?: boolean; resume?: boolean; resumeSessionId?: string; provider?: AgentProvider }) => {++ipcMain.handle('pty:spawn', async (evt, opts: SpawnOptions & { hive?: AgentMeta; isolate?: boolean; resume?: boolean; resumeSessionId?: string; provider?: AgentProvider }) => {if (!opts || typeof opts.id !== 'string' || typeof opts.cwd !== 'string' || typeof opts.command !== 'string') {return { ok: false, error: 'invalid SpawnOptions' };}@@@ -1456,12 -1343,14 +1492,17 @@@if (Object.keys(nonInteractiveEnv).length > 0) {opts.env = { ...(opts.env ?? {}), ...nonInteractiveEnv };}- const res = ptyManager.spawn(opts);+ // Record the spawning window as the PTY's owner so its output (pty:data/exit)+ // routes ONLY back to that floor — never leaking into another window's stream.+ const owner = BrowserWindow.fromWebContents(evt.sender)?.webContents ?? null;+ const res = ptyManager.spawn(opts, owner);syncKeepAwake(); // arm the power-save blocker while ≥1 agent PTY is alive (#18)- return res;+ // Hand the resolved worktree path back to the renderer so it can persist it on+ // the agent (only set when isolation actually provisioned a worktree above).+ // The restore flow re-enters this exact worktree (cwd = worktreePath) so a+ // restored isolated agent resumes in the CORRECT checkout, not the base repo.+ const worktreePath = worktreePaths.get(opts.id);+ return { ...res, ...(worktreePath ? { worktreePath } : {}), ...(resumeNotFound ? { resumeNotFound: true } : {}), ...(didResume ? { resumed: true } : {}) };});ipcMain.handle('pty:write', (_evt, id: string, data: string) => {if (typeof id !== 'string' || typeof data !== 'string') return { ok: false, error: 'invalid args' };diff --cc src/main/pty.tsindex 75e26899,d1c956b5..7bd38f7f--- a/src/main/pty.ts+++ b/src/main/pty.ts@@@ -236,16 -209,29 +236,30 @@@ export class PtyManager} as Record<string, string>});- this.sessions.set(opts.id, { id: opts.id, proc, cwd: opts.cwd, command: resolved, lastOutputAt: Date.now(), owner });+ // Capture THIS session object so the proc's callbacks can tell whether the+ // id still belongs to them. A model change / restart does kill()+spawn()+ // reusing the SAME id: the old process's kill is asynchronous, so its+ // onData/onExit can fire AFTER the replacement session is already in the+ // map. Without the identity guard the dying process would (a) spray its+ // final bytes into the new agent's fresh TUI frame — scattered/overlapping+ // text — and (b) on exit delete the replacement session and emit a false+ // `pty:exit`, killing input to the agent that just started.- const session: PtySession = { id: opts.id, proc, cwd: opts.cwd, command: resolved, lastOutputAt: Date.now() };++ const session: PtySession = { id: opts.id, proc, cwd: opts.cwd, command: resolved, lastOutputAt: Date.now(), owner };+ this.sessions.set(opts.id, session);proc.onData((data) => {- const s = this.sessions.get(opts.id);- if (s) s.lastOutputAt = Date.now();- this.safeSend(`pty:data:${opts.id}`, data, s?.owner);+ // Drop trailing output from a process whose id was already reclaimed by+ // a respawn (or killed) — it would corrupt the new session's screen.+ if (this.sessions.get(opts.id) !== session) return;+ session.lastOutputAt = Date.now();- this.safeSend(`pty:data:${opts.id}`, data);++ // Route to the session's owner window (multi-window owner routing).++ this.safeSend(`pty:data:${opts.id}`, data, session.owner);});proc.onExit(({ exitCode, signal }) => {- const s = this.sessions.get(opts.id);- this.safeSend(`pty:exit:${opts.id}`, { exitCode, signal }, s?.owner);+ // Stale exit from a process whose id was reclaimed (kill()+respawn) — do+ // NOT touch the live session or tell the renderer the new pty died.+ if (this.sessions.get(opts.id) !== session) return;- this.safeSend(`pty:exit:${opts.id}`, { exitCode, signal });++ this.safeSend(`pty:exit:${opts.id}`, { exitCode, signal }, session.owner);this.sessions.delete(opts.id);// Natural exit must run the same lifecycle teardown as an explicit kill.// Guarded so a teardown error can never crash node-pty's exit callback.