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.

feat(codex): thread remote Codex runtime paths through sshConn (S6 PR 6, Task 6.3)

enes82f8a6ac37c3
diff --git a/docs/superpowers/probes/2026-08-codex-ssh-remote.md b/docs/superpowers/probes/2026-08-codex-ssh-remote.md
new file mode 100644
index 000000000..776ebd3b0
--- /dev/null
+++ b/docs/superpowers/probes/2026-08-codex-ssh-remote.md
@@ -0,0 +1,63 @@
+# Probe — S6 PR 6 remote leg (U6, U7) on a live SSH host
+
+**Date:** 2026-08-19 · **Host:** niova (Linux, x86_64) · **Transport:** real `ssh`/`scp` to
+`localhost` over a dedicated ed25519 key, scratch `CODEX_HOME` under `$HOME`, never touching any
+other user's live nodeterm/codex state. **Codex:** `codex-cli 0.146.0` (`/usr/bin/codex`,
+npm-managed at `/usr/lib/node_modules/@openai/codex`). **Node:** v22.22.2 (`/usr/bin/node`).
+`curl` present. All three resolve through `readlink -f`, which is the gate
+`installRemoteCodexRuntime` requires.
+
+The uploaded relay is an esbuild standalone bundle of `src/main/codex-relay-daemon.ts` (ws bundled
+in, CJS, node22) — the exact artifact `scripts/build-codex-relay.mjs` produces and
+`codexRelaySource()` uploads. 176 KB, parses and runs under the host's own `node`.
+
+## U6 — the uploaded relay launches and answers over the host's own Node — VERIFIED
+
+Ran each subcommand as `node ~/.nodeterm-.../codex-relay.js <cmd>` **over SSH** (the remote host's
+own node, not the local process):
+
+| Subcommand | Target | Result |
+| --- | --- | --- |
+| `account-read <sock>` | a LIVE `codex app-server --listen unix://<sock>` (0.146.0) | `{"email":null}`, exit 0 — full `initialize`→`initialized`→`account/read` round-trip against a real app-server; `null` because that scratch home is not logged in (fail-closed, not a fabricated identity) |
+| `thread-check <sock> <id>` | fake app-server returning that thread | exit 0 |
+| `thread-check <sock> <missing>` | live app-server / fake without the thread | exit 69 (fail-closed) |
+| `expose-thread <sock> <id> <sock>` | target already holds the thread natively | exit 0 (native early return) |
+| `expose-thread <sock> <ghost> <sock>` | thread absent across every catalog | exit 69 (ambiguous/unavailable ⇒ REFUSE) |
+
+`serve`/`register` self-spawn was already proven runnable under plain `node` by the merged
+child-process test (`codex-relay-daemon.test.ts`); this probe adds the missing leg — the **uploaded
+bundle** running under the **remote host's own node over a real SSH transport**.
+
+### Load-bearing correction to the Task 4.0 record
+
+Task 4.0 recorded the app-server as "NOT runnable headless … needs the curl-managed standalone
+install." That is only true of `codex app-server daemon start` (which refuses without
+`<CODEX_HOME>/packages/standalone/current/codex`). The **fallback path** —
+`codex app-server --listen "unix://<sock>"` — **binds the control socket on a plain npm install**,
+which is exactly the branch `remoteCodexAppServerStartCommand` takes after `daemon start` fails. So
+the remote account/app-server leg is live-runnable on an ordinary `npm i -g @openai/codex` host, not
+only on a standalone install. The `account/read`→`{email}` and `thread/read`→`{path,cwd}` RPC shapes
+are confirmed against a real 0.146.0 app-server (U4, previously headless-unverified, now verified for
+the `--listen` path).
+
+## U7 — home layout `dirname(dirname(socket)) === home`, sibling `sessions/` — VERIFIED
+
+- A real logged-in `/root/.codex` install: control socket at
+ `/root/.codex/app-server-control/app-server-control.sock` ⇒ `dirname(dirname(socket)) ===
+ /root/.codex === CODEX_HOME`. Sibling `sessions/` present, holding rollouts at
+ `sessions/YYYY/MM/DD/rollout-<ts>-<uuid>.jsonl` — the exact `sessions/<rel>` shape
+ `remoteCodexImportThread` validates and the traversal guard confines writes under.
+- `codex app-server daemon version` against a fresh scratch home reports the same
+ `<CODEX_HOME>/app-server-control/app-server-control.sock` path, and `--listen` binds precisely
+ there. `auth.json` is a real `0600` file (identity gate: `test -f && test ! -L`).
+- Note: `sessions/` only materialises once a conversation exists; the import path `mkdir -p`s the
+ dated target dir before the atomic `mv`, so a brand-new account home is handled.
+
+## Owed device-verification (not blocking)
+
+- U1 (running app-server surfaces a freshly `mv`d rollout without a reindex) and U2 (conversation id
+ survives copy+switch under a second login) still need a logged-in second account + a live daemon —
+ the atomic import's verify-before-recycle (`remoteCodexThreadExists` after install, rollback on
+ miss) degrades a false U1 to a refused copy, never a silent one.
+- The full desktop→host account add / device-login / import against a **standalone** install over a
+ real WAN link (not loopback) is owed on a Mac + a real remote host.
diff --git a/src/renderer/state/sshConn.test.ts b/src/renderer/state/sshConn.test.ts
index 11535a225..ce2d71d69 100644
--- a/src/renderer/state/sshConn.test.ts
+++ b/src/renderer/state/sshConn.test.ts
@@ -184,3 +184,39 @@ describe('useSshConn — host attachments', () => {
expect(useSshConn.getState().attachmentScopesOf('local-1')).toEqual([])
})
})
+
+// The remote Codex runtime paths (launcher + relay bundle + node) ride the connect result so a
+// Codex node's launch/import can route to the SSH host. Absent when the host has no managed Codex
+// runtime (node/codex/curl missing) or the scope isn't connected — never a partial guess.
+describe('useSshConn — remote Codex runtime (getCodexRuntime)', () => {
+ it('returns the three codex paths from a connected scope, all-undefined otherwise', () => {
+ const s = useSshConn.getState()
+ // never connected → all undefined (not a throw, not a partial)
+ expect(s.getCodexRuntime('p1')).toEqual({
+ codexLauncherPath: undefined,
+ codexRelayScriptPath: undefined,
+ codexRelayRuntimePath: undefined
+ })
+ s.setConn('p1', {
+ controlPath: '/cm.sock',
+ codexLauncherPath: '/home/u/.nodeterm/bin/nodeterm-codex',
+ codexRelayScriptPath: '/home/u/.nodeterm/bin/codex-relay.js',
+ codexRelayRuntimePath: '/usr/bin/node'
+ })
+ expect(useSshConn.getState().getCodexRuntime('p1')).toEqual({
+ codexLauncherPath: '/home/u/.nodeterm/bin/nodeterm-codex',
+ codexRelayScriptPath: '/home/u/.nodeterm/bin/codex-relay.js',
+ codexRelayRuntimePath: '/usr/bin/node'
+ })
+ })
+
+ it('a host with no managed Codex runtime keeps every codex path undefined', () => {
+ const s = useSshConn.getState()
+ s.setConn('p2', { controlPath: '/cm2.sock', remoteHome: '/home/u' })
+ expect(useSshConn.getState().getCodexRuntime('p2')).toEqual({
+ codexLauncherPath: undefined,
+ codexRelayScriptPath: undefined,
+ codexRelayRuntimePath: undefined
+ })
+ })
+})
diff --git a/src/renderer/state/sshConn.ts b/src/renderer/state/sshConn.ts
index 378c74036..4956aa825 100644
--- a/src/renderer/state/sshConn.ts
+++ b/src/renderer/state/sshConn.ts
@@ -24,6 +24,16 @@ export interface SshConnInfo {
/** The probed remote `claude --version` output (`null` = probe ran, claude not found). Feeds
* the tab menu's Auto hint; only present on a reused (already probed) connection. */
remoteClaudeVersion?: string | null
+ /** Absolute remote path of the uploaded `nodeterm-codex` launcher (`chmod 700`). Present only
+ * when `installRemoteCodexRuntime` found node+codex+curl and staged the runtime. Absent ⇒ this
+ * host cannot host managed Codex accounts (the renderer keeps Codex nodes on the system login). */
+ codexLauncherPath?: string
+ /** Absolute remote path of the uploaded standalone relay bundle (`codex-relay.js`, `chmod 700`).
+ * Only executable code is ever uploaded — never a credential (§2.1 / Property 1). */
+ codexRelayScriptPath?: string
+ /** Absolute remote path of the host's own Node (`readlink -f $(command -v node)`), the interpreter
+ * the relay bundle and app-server run under. Absent ⇒ no managed Codex runtime on this host. */
+ codexRelayRuntimePath?: string
}
/**
@@ -85,6 +95,12 @@ interface SshConnState {
getHookEndpointPath(projectId: string): string | undefined
getTmuxConfPath(projectId: string): string | undefined
getRemoteHome(projectId: string): string | undefined
+ /** The remote Codex runtime paths for a connection scope (launcher + relay bundle + node), or
+ * all-undefined when the host has no managed Codex runtime (node/codex/curl missing, or the
+ * scope isn't connected). Read where a Codex node's launch/import routes to the SSH host. */
+ getCodexRuntime(
+ projectId: string
+ ): Pick<SshConnInfo, 'codexLauncherPath' | 'codexRelayScriptPath' | 'codexRelayRuntimePath'>
/**
* Record how to reach an attachment scope. Call this BEFORE dialing, not after: a first connect
* that FAILS is exactly the case the reconnect coordinator exists for, and it has nowhere else
@@ -160,6 +176,14 @@ export const useSshConn = create<SshConnState>((set, get) => ({
getRemoteHome(projectId) {
return get().byProject[projectId]?.remoteHome
},
+ getCodexRuntime(projectId) {
+ const info = get().byProject[projectId]
+ return {
+ codexLauncherPath: info?.codexLauncherPath,
+ codexRelayScriptPath: info?.codexRelayScriptPath,
+ codexRelayRuntimePath: info?.codexRelayRuntimePath
+ }
+ },
registerAttachment(scopeId, attachment) {
set((s) => ({ attachments: { ...s.attachments, [scopeId]: attachment } }))
},