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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(pairing): provision relay for free-tier phones while quota lasts (QR pairing itself stays free)
enesb3b1c76cf174
diff --git a/src/main/index.ts b/src/main/index.tsindex e3ac624f6..81853194b 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -49,7 +49,7 @@ import { initTranscriptIndex, searchTranscripts } from '../core/transcript-indeximport { initTelemetry } from './telemetry'import { initClaudeUsage } from './claude-usage'import { initLicense, isPremium, getStoredEntitlement } from '../core/license'-import { initRelayQuota, broadcastRelayQuota } from '../core/relay-quota'+import { initRelayQuota, broadcastRelayQuota, relayQuotaAvailable } from '../core/relay-quota'import { initClaudeAccounts } from './claude-accounts'import { claudeCliCaps, registerClaudeCliIpc } from '../core/claude-cli'import { claudeConfigDirFor } from '../core/claude-config-dir'@@ -512,6 +512,7 @@ app.whenReady().then(async () => {const pairingService = createPairingService({getSettings: () => settingsStore.get(),isPremium,+ quotaAvailable: relayQuotaAvailable,getEntitlement: getStoredEntitlement,loadHostKeyPair: loadOrCreateKeyPair,relayEndpoint: RELAY_URL,diff --git a/src/main/pairing-service.ts b/src/main/pairing-service.tsindex 18303462e..6837bb552 100644--- a/src/main/pairing-service.ts+++ b/src/main/pairing-service.ts@@ -37,6 +37,7 @@ import {import type { Settings } from '../shared/types'import { publicKeyToB64, deriveSharedKey, encrypt, decrypt, type KeyPair } from './remote/e2ee'import { hostIdFromPublicKeyB64 } from './remote/relay-id'+import { getDeviceId } from '../core/device-id'const execFileAsync = promisify(execFile)@@ -51,6 +52,8 @@ export interface PairingRelayDeps {getSettings(): SettingsisPremium(): booleangetEntitlement(): string | null+ /** Free-tier relay taster: true while the monthly quota could still admit a bridge. */+ quotaAvailable(): booleanloadHostKeyPair(): Promise<KeyPair>/** The relay WebSocket endpoint advertised to the phone. */relayEndpoint: string@@ -69,7 +72,7 @@ interface RelayDeviceResponse {/** Mint a relay device token so a freshly-paired phone can reach this host over the relay. */async function mintRelayDevice(apiBase: string,- body: { entitlement: string; deviceId: string; hostPublicKeyB64: string; label?: string }+ body: { entitlement: string | null; deviceId: string; hostPublicKeyB64: string; label?: string }): Promise<RelayDeviceResponse | null> {const ctrl = new AbortController()const timer = setTimeout(() => ctrl.abort(), 8000)@@ -77,7 +80,11 @@ async function mintRelayDevice(const res = await fetch(`${apiBase}/v1/relay/device`, {method: 'POST',headers: { 'content-type': 'application/json' },- body: JSON.stringify(body),+ body: JSON.stringify(+ body.entitlement+ ? body+ : { deviceId: body.deviceId, hostDeviceId: getDeviceId(), hostPublicKeyB64: body.hostPublicKeyB64, label: body.label }+ ),signal: ctrl.signal})if (!res.ok) return null@@ -93,16 +100,17 @@ async function mintRelayDevice(/*** Compute this host's relay reachability block WITHOUT any network call (just the host key →- * hostId), so the QR renders instantly. Returns null (LAN-only) when phone access is off, not Pro,- * blocked in dev, or no entitlement is stored.+ * hostId), so the QR renders instantly. Returns null (LAN-only) when phone access is off, not Pro+ * and no free quota, blocked in dev, or (on Pro) no entitlement is stored.*/async function buildRelayContext(deps: PairingRelayDeps | undefined-): Promise<{ block: RelayPairingBlock; entitlement: string } | null> {+): Promise<{ block: RelayPairingBlock; entitlement: string | null } | null> {if (!deps || !deps.relayAllowed()) return null- if (!deps.getSettings().phoneAccessEnabled || !deps.isPremium()) return null- const entitlement = deps.getEntitlement()- if (!entitlement) return null+ if (!deps.getSettings().phoneAccessEnabled) return null+ if (!deps.isPremium() && !deps.quotaAvailable()) return null+ const entitlement = deps.getEntitlement() // null on free tier → mint by deviceId+ if (deps.isPremium() && !entitlement) return nulltry {const keys = await deps.loadHostKeyPair()const hostPublicKeyB64 = publicKeyToB64(keys.publicKey)