Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

refactor(core): move agent hook server + installers into src/core

enesd7619c0ee982
diff --git a/src/main/agents/hook-server.ts b/src/core/agents/hook-server.ts
similarity index 98%
rename from src/main/agents/hook-server.ts
rename to src/core/agents/hook-server.ts
index 3a1b18fa2..c5bb9cb88 100644
--- a/src/main/agents/hook-server.ts
+++ b/src/core/agents/hook-server.ts
@@ -2,7 +2,7 @@ import { createServer, type IncomingMessage, type Server, type ServerResponse }
import { randomUUID, timingSafeEqual } from 'crypto'
import { writeFileSync, mkdirSync } from 'fs'
import path from 'path'
-import { app } from 'electron'
+import { platform } from '../platform'
import { canControlCanvas, type AgentId } from '../../shared/agents/config'
import { normalizeFor, type NormalizedAgentEvent } from '../../shared/agents/normalize'
@@ -54,7 +54,7 @@ class HookServer {
private endpointPath = ''
endpointFilePath(): string {
- if (!this.endpointPath) this.endpointPath = path.join(app.getPath('userData'), 'hook-endpoint.env')
+ if (!this.endpointPath) this.endpointPath = path.join(platform().userDataDir, 'hook-endpoint.env')
return this.endpointPath
}
diff --git a/src/main/agents/hooks/claude.ts b/src/core/agents/hooks/claude.ts
similarity index 100%
rename from src/main/agents/hooks/claude.ts
rename to src/core/agents/hooks/claude.ts
diff --git a/src/main/agents/hooks/codex-trust.ts b/src/core/agents/hooks/codex-trust.ts
similarity index 100%
rename from src/main/agents/hooks/codex-trust.ts
rename to src/core/agents/hooks/codex-trust.ts
diff --git a/src/main/agents/hooks/codex.ts b/src/core/agents/hooks/codex.ts
similarity index 98%
rename from src/main/agents/hooks/codex.ts
rename to src/core/agents/hooks/codex.ts
index 9de321307..97917dddd 100644
--- a/src/main/agents/hooks/codex.ts
+++ b/src/core/agents/hooks/codex.ts
@@ -26,7 +26,7 @@ import {
unlinkSync
} from 'fs'
import { randomUUID } from 'crypto'
-import { app } from 'electron'
+import { platform } from '../../platform'
import { buildManagedScript } from './managed-script'
import {
computeTrustedHash,
@@ -84,7 +84,7 @@ function configTomlPath(): string {
}
function scriptPath(): string {
- return path.join(app.getPath('userData'), 'agent-hooks', SCRIPT_FILE_NAME)
+ return path.join(platform().userDataDir, 'agent-hooks', SCRIPT_FILE_NAME)
}
// Why: match managed entries by the `agent-hooks/codex.sh` path segment (not
diff --git a/src/main/agents/hooks/gemini.ts b/src/core/agents/hooks/gemini.ts
similarity index 100%
rename from src/main/agents/hooks/gemini.ts
rename to src/core/agents/hooks/gemini.ts
diff --git a/src/main/agents/hooks/index.ts b/src/core/agents/hooks/index.ts
similarity index 100%
rename from src/main/agents/hooks/index.ts
rename to src/core/agents/hooks/index.ts
diff --git a/src/main/agents/hooks/install-helper.test.ts b/src/core/agents/hooks/install-helper.test.ts
similarity index 100%
rename from src/main/agents/hooks/install-helper.test.ts
rename to src/core/agents/hooks/install-helper.test.ts
diff --git a/src/main/agents/hooks/install-helper.ts b/src/core/agents/hooks/install-helper.ts
similarity index 97%
rename from src/main/agents/hooks/install-helper.ts
rename to src/core/agents/hooks/install-helper.ts
index 6b26b9a4d..2f014e5b0 100644
--- a/src/main/agents/hooks/install-helper.ts
+++ b/src/core/agents/hooks/install-helper.ts
@@ -10,7 +10,7 @@
// - fail open: a missing/unparseable settings.json defaults to {} (install) / returns
// early (remove); a write error is caught + warned, never thrown.
import path from 'path'
-import { app } from 'electron'
+import { platform } from '../../platform'
import { readFileSync, writeFileSync, mkdirSync, chmodSync } from 'fs'
import { buildManagedScript } from './managed-script'
@@ -21,7 +21,7 @@ type Settings = { hooks?: Record<string, HookDef[]>; [k: string]: unknown }
export type HookSettings = Settings
function scriptPathFor(scriptFileName: string): string {
- return path.join(app.getPath('userData'), 'agent-hooks', scriptFileName)
+ return path.join(platform().userDataDir, 'agent-hooks', scriptFileName)
}
// The marker identifying OUR entry: the `agent-hooks/<scriptFile>` tail of the managed
diff --git a/src/main/agents/hooks/managed-script.test.ts b/src/core/agents/hooks/managed-script.test.ts
similarity index 100%
rename from src/main/agents/hooks/managed-script.test.ts
rename to src/core/agents/hooks/managed-script.test.ts
diff --git a/src/main/agents/hooks/managed-script.ts b/src/core/agents/hooks/managed-script.ts
similarity index 100%
rename from src/main/agents/hooks/managed-script.ts
rename to src/core/agents/hooks/managed-script.ts
diff --git a/src/main/claude-accounts.ts b/src/main/claude-accounts.ts
index c57159f7e..4ff154bef 100644
--- a/src/main/claude-accounts.ts
+++ b/src/main/claude-accounts.ts
@@ -9,7 +9,7 @@ import { promisify } from 'util'
import { app, ipcMain } from 'electron'
import { IPC } from '../shared/ipc'
import { accountConfigDir, isSupportedClaudeVersion, parseLoginCapture } from '../core/claude-accounts-core'
-import { installClaudeHooksInto } from './agents/hooks/claude'
+import { installClaudeHooksInto } from '../core/agents/hooks/claude'
import { installCanvasSkillInto } from './canvas-control'
import { findInLoginPath } from './pty-manager'
import type { SshProjectManager } from './remote-ssh/ssh-project'
diff --git a/src/main/index.ts b/src/main/index.ts
index 90682a802..8e589bb71 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -12,11 +12,11 @@ import { GitService } from './git-service'
import { generateCommitMessage, generateGroupName, generateTerminalName } from './commit-message'
import { initUpdater } from './updater'
import { fetchCheck } from '../core/check'
-import { hookServer } from './agents/hook-server'
+import { hookServer } from '../core/agents/hook-server'
import { setMainWindow, getMainWindow, sendToMain, shouldHideOnClose } from './main-window'
import { initAgentStatusMirror, recordAgentEvent } from '../core/agent-status-mirror'
import { retainUntilDismissed } from './notifications'
-import { installManagedAgentHooks } from './agents/hooks'
+import { installManagedAgentHooks } from '../core/agents/hooks'
import { createSubagentTail } from './subagent-tail'
import { createContextTail, type TaskNotification } from './context-tail'
import { isAsyncSubagentLaunch, type NormalizedAgentEvent } from '../shared/agents/normalize'
@@ -45,7 +45,7 @@ import { initClaudeUsage } from './claude-usage'
import { initLicense } from './license'
import { initClaudeAccounts, claudeConfigDirFor } from './claude-accounts'
import { isSafeLocalTranscriptPath } from '../core/claude-accounts-core'
-import { installClaudeHooksInto } from './agents/hooks/claude'
+import { installClaudeHooksInto } from '../core/agents/hooks/claude'
import { createPairingService } from './pairing-service'
import { initRemoteHost } from './remote/host-service'
import { initRemoteClient } from './remote/client-service'
diff --git a/src/main/pty-manager.ts b/src/main/pty-manager.ts
index a41d9d8fd..f710242d8 100644
--- a/src/main/pty-manager.ts
+++ b/src/main/pty-manager.ts
@@ -12,7 +12,7 @@ import {
type PtyCreateResult,
type Settings
} from '../shared/types'
-import { hookServer } from './agents/hook-server'
+import { hookServer } from '../core/agents/hook-server'
import {
remoteHookEnvArgs,
remoteTmuxHasSessionArgs,
diff --git a/src/main/remote-ssh/remote-hooks.ts b/src/main/remote-ssh/remote-hooks.ts
index 7b99c1d1d..7a2e2994d 100644
--- a/src/main/remote-ssh/remote-hooks.ts
+++ b/src/main/remote-ssh/remote-hooks.ts
@@ -5,8 +5,8 @@
// agent simply runs without hooks. Takes an INJECTED runner so the flow is unit-testable
// without real ssh/electron.
import { childArgs, hookForwardArgs, hookForwardCancelArgs, remoteEndpointFileContents } from './control-master'
-import { buildManagedScript } from '../agents/hooks/managed-script'
-import { mergeManagedHook, type HookSettings } from '../agents/hooks/install-helper'
+import { buildManagedScript } from '../../core/agents/hooks/managed-script'
+import { mergeManagedHook, type HookSettings } from '../../core/agents/hooks/install-helper'
import { posixQuote, type SshConnection } from '../../shared/ssh'
export interface RemoteRunner {
diff --git a/src/main/remote-ssh/ssh-project.ts b/src/main/remote-ssh/ssh-project.ts
index 78ac447e9..ddd9baccb 100644
--- a/src/main/remote-ssh/ssh-project.ts
+++ b/src/main/remote-ssh/ssh-project.ts
@@ -19,7 +19,7 @@ import {
RMT_TMUX_SOCKET
} from './control-master'
import { RemoteHooks } from './remote-hooks'
-import { hookServer } from '../agents/hook-server'
+import { hookServer } from '../../core/agents/hook-server'
import { sessionName } from '../../core/tmux-naming'
interface Runners {