Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Merge main into codex/share-harness

0xken1531c00b086159
diff --cc cli/package.json
index f12d9b722,648e3d284..f6b019cd7
--- a/cli/package.json
+++ b/cli/package.json
@@@ -12,8 -12,7 +12,9 @@@
"typecheck": "tsc --noEmit",
"start": "node dist/cli.js",
"test": "vitest run",
+ "test:sharing": "vitest run src/sharing --coverage --coverage.include='src/sharing/**' --coverage.thresholds.lines=100 --coverage.thresholds.statements=100 --coverage.thresholds.branches=100 --coverage.thresholds.functions=100",
+ "test:sharing-e2e": "tsx scripts/share-harness-e2e.ts",
+ "test:remote-viewers": "vitest run --config vitest.viewer.config.ts",
"test:cursor-e2e": "RUN_CURSOR_E2E=1 vitest run src/engines/cursor/localE2e.spec.ts",
"test:tmux-real": "RUN_REAL_TMUX_DISCOVERY=1 vitest run src/lib/tmuxAgentDiscovery.real.spec.ts --reporter=verbose",
"test:herdr-real": "RUN_REAL_HERDR=1 vitest run src/lib/herdrBackend.real.spec.ts --reporter=verbose",
diff --cc cli/src/backendSocket.ts
index ec9ff92f9,a7396d4a5..1d626da0c
--- a/cli/src/backendSocket.ts
+++ b/cli/src/backendSocket.ts
@@@ -379,8 -379,19 +381,20 @@@ export class BackendSocket
/** Called on `dsh_remove` — cli.ts uninstalls the harness from this machine. */
onDshRemove: ((id: string) => { ok: true } | { ok: false; error: string; detail: string }) | null = null
/** What the daemon knows about an agent's DSH companions (viewer URL, verdict); null when nothing. */
+ harnessSharing: HarnessShareOwner | null = null
dshFrameProvider: ((session: RegisteredSession) => AgentDshContext | null) | null = null
+ viewerTargetProvider: ((agentId: string) => string | null) | null = null
+ readonly viewerForwarder = new ViewerForwarder({
+ target: (agentId) => this.viewerTargetProvider?.(agentId) ?? null,
+ send: (connId, type, payload) => {
+ if (this.localClients.has(connId)) { this.sendTo(connId, { type, payload }); return true }
+ if (!this.isConnected()) return false
+ const frame = this.e2ee.wrapTarget(connId, type, payload)
+ if (!frame) return false
+ this.sendTo(connId, frame)
+ return true
+ },
+ })
private readonly agentCreations = new AgentCreationReceipts(join(env.ADAPTER_DATA_DIR, 'agent-creations'))
/** Injectable for queue-isolation tests; production uses the machine-local probe. */
engineProbeProvider: typeof probeEngines = probeEngines
@@@ -689,8 -701,8 +704,9 @@@
// default the recap gate to OFF (safe value) instead of holding a stale count — otherwise a turn
// completing during the gap burns a `claude -p` recap that goes nowhere. attachAdapter always
// re-pushes the true count via recomputeAndSendClients on reconnect (and 0→N re-fires the replay).
+ this.harnessSharing?.closeAll()
this.setCommanderCount(0, null) // active count is unknown until the next __clients snapshot
+ this.viewerForwarder.closeAll()
void this.terminalStreams?.closeConnectionsWhere(
(connId) => !isLocalClientId(connId),
'backend disconnected',
@@@ -1175,7 -1179,7 +1193,7 @@@
}
// Client→adapter encrypted frames: chat messages plus trusted web control actions. Plaintext
// passes through for legacy/device transition paths; undecryptable ciphertext is dropped.
- if (!local && (isEncryptedDownType(type) || SHARE_REQUEST_TYPES.has(type))) {
- if (!local && (isEncryptedDownType(type) || VIEWER_DOWN_TYPES.has(type))) {
++ if (!local && (isEncryptedDownType(type) || SHARE_REQUEST_TYPES.has(type) || VIEWER_DOWN_TYPES.has(type))) {
if (type !== 'message' && type !== 'question_response' && !isWrapped(frame.payload)) {
const requestId = (frame.payload as { requestId?: unknown } | undefined)?.requestId
if (requestId !== undefined) this.emitReply(connId, type, requestId, { error: 'E2EE_REQUIRED' })
@@@ -1193,7 -1197,7 +1211,7 @@@
// than as an opaque __e2e envelope.
// Terminal frames contain raw keystrokes, paste text and screen bytes after
// unwrap. Never pass them to the frame logger, even in diagnostic mode.
- if (env.LOG_FRAMES && !type.startsWith('terminal_') && type !== 'agent_read_file' && type !== 'project_preview' && !SHARE_REQUEST_TYPES.has(type)) {
- if (env.LOG_FRAMES && !type.startsWith('terminal_') && !type.startsWith('viewer_') && type !== 'agent_read_file' && type !== 'project_preview') {
++ if (env.LOG_FRAMES && !type.startsWith('terminal_') && !type.startsWith('viewer_') && type !== 'agent_read_file' && type !== 'project_preview' && !SHARE_REQUEST_TYPES.has(type)) {
logFrame('←', connId ? `conn:${sid(connId)}` : 'backend', frame)
}
const reply = (t: string, rid: unknown, p: Record<string, unknown>): void => this.emitReply(connId, t, rid, p)
diff --cc cli/src/lib/e2ee/relayClient.ts
index 2c381d5ce,0273c4387..f984f2655
--- a/cli/src/lib/e2ee/relayClient.ts
+++ b/cli/src/lib/e2ee/relayClient.ts
@@@ -104,7 -107,8 +108,8 @@@ export class RelaySessionCrypto
/** Encrypt an outgoing (local app → remote machine) frame if its type requires it. */
wrapOutgoing(frame: Frame): Frame {
const type = frame.type as string | undefined
- if (!type || !this.c2s || !(C.isEncryptedDownType(type) || SHARE_REQUEST_TYPES.has(type))) return frame
+ // CLI-to-CLI viewer forwarding is a negotiated extension; the shared crypto core stays byte-identical.
- if (!type || !this.c2s || (!C.isEncryptedDownType(type) && !VIEWER_DOWN_TYPES.has(type))) return frame
++ if (!type || !this.c2s || !(C.isEncryptedDownType(type) || SHARE_REQUEST_TYPES.has(type) || VIEWER_DOWN_TYPES.has(type))) return frame
const payload = C.wrapPayload(this.c2s, 'p', this.c2sCounter++, type, undefined, frame.payload)
return { ...frame, payload }
}