diff --git a/config/scripts/orca-dev b/config/scripts/orca-dev
index 47bdb1c5b..10754fe4c 100755
--- a/config/scripts/orca-dev
+++ b/config/scripts/orca-dev
@@ -25,4 +25,12 @@ case "$(uname -s)" in
esac
export ORCA_USER_DATA_PATH="${ORCA_DEV_USER_DATA_PATH:-$default_data}"
+electron_executable="$REPO_ROOT/node_modules/.bin/electron"
+case "$(uname -s)" in
+ MINGW*|MSYS*) electron_executable="$REPO_ROOT/node_modules/electron/dist/electron.exe" ;;
+esac
+if [ -z "${ORCA_APP_EXECUTABLE:-}" ] && [ -x "$electron_executable" ]; then
+ export ORCA_APP_EXECUTABLE="$electron_executable"
+ export ORCA_APP_EXECUTABLE_NEEDS_APP_ROOT=1
+fi
exec node "$CLI_ENTRY" "$@"
diff --git a/config/scripts/run-electron-vite-dev.mjs b/config/scripts/run-electron-vite-dev.mjs
index 408206b98..c3ac1b049 100644
--- a/config/scripts/run-electron-vite-dev.mjs
+++ b/config/scripts/run-electron-vite-dev.mjs
@@ -23,9 +23,15 @@ function getDevUserDataPath() {
return path.join(process.env.HOME ?? '', 'Library', 'Application Support', 'orca-dev')
}
if (process.platform === 'win32') {
- return path.join(process.env.APPDATA ?? path.join(process.env.USERPROFILE ?? '', 'AppData', 'Roaming'), 'orca-dev')
+ return path.join(
+ process.env.APPDATA ?? path.join(process.env.USERPROFILE ?? '', 'AppData', 'Roaming'),
+ 'orca-dev'
+ )
}
- return path.join(process.env.XDG_CONFIG_HOME ?? path.join(process.env.HOME ?? '', '.config'), 'orca-dev')
+ return path.join(
+ process.env.XDG_CONFIG_HOME ?? path.join(process.env.HOME ?? '', '.config'),
+ 'orca-dev'
+ )
}
function prepareDevCliWrapper() {
@@ -33,18 +39,19 @@ function prepareDevCliWrapper() {
mkdirSync(binDir, { recursive: true })
const userDataPath = getDevUserDataPath()
const cliPath = path.join(repoRoot, 'out', 'cli', 'index.js')
+ const electronBin = getElectronExecutable()
if (process.platform === 'win32') {
writeFileSync(
path.join(binDir, 'orca-dev.cmd'),
- `@echo off\r\nset "ORCA_USER_DATA_PATH=${userDataPath}"\r\nnode "${cliPath}" %*\r\n`,
+ `@echo off\r\nset "ORCA_USER_DATA_PATH=${userDataPath}"\r\nset "ORCA_APP_EXECUTABLE=${electronBin}"\r\nset "ORCA_APP_EXECUTABLE_NEEDS_APP_ROOT=1"\r\nnode "${cliPath}" %*\r\n`,
'utf8'
)
} else {
const wrapperPath = path.join(binDir, 'orca-dev')
writeFileSync(
wrapperPath,
- `#!/usr/bin/env bash\nexport ORCA_USER_DATA_PATH=${JSON.stringify(userDataPath)}\nexec node ${JSON.stringify(cliPath)} "$@"\n`,
+ `#!/usr/bin/env bash\nexport ORCA_USER_DATA_PATH=${JSON.stringify(userDataPath)}\nexport ORCA_APP_EXECUTABLE=${JSON.stringify(electronBin)}\nexport ORCA_APP_EXECUTABLE_NEEDS_APP_ROOT=1\nexec node ${JSON.stringify(cliPath)} "$@"\n`,
'utf8'
)
chmodSync(wrapperPath, 0o755)
@@ -54,6 +61,13 @@ function prepareDevCliWrapper() {
console.log(`[orca-dev] Prepared wrapper in ${binDir}`)
}
+function getElectronExecutable() {
+ if (process.platform === 'win32') {
+ return path.join(repoRoot, 'node_modules', 'electron', 'dist', 'electron.exe')
+ }
+ return path.join(repoRoot, 'node_modules', '.bin', 'electron')
+}
+
if (process.env.ORCA_SKIP_DEV_CLI_PREPARE !== '1') {
prepareDevCliWrapper()
}
@@ -109,7 +123,10 @@ function parseDebugPortEnv(raw) {
// space-separated form. `--remote-debugging-pipe` opts into pipe-based
// debugging — don't fight the user's choice by injecting a port.
const userPassedPort = forwardedRaw.some(
- (a) => a === '--remote-debugging-port' || a.startsWith('--remote-debugging-port=') || a === '--remote-debugging-pipe'
+ (a) =>
+ a === '--remote-debugging-port' ||
+ a.startsWith('--remote-debugging-port=') ||
+ a === '--remote-debugging-pipe'
)
// Why: --help/--version exit immediately; binding a probe socket and printing
// a debug-port line would be noise.
@@ -136,7 +153,9 @@ if (!userPassedPort && !isHelpOrVersion) {
// resolve to ::1 on IPv6-first hosts).
console.error(`[orca-dev] Remote debugging on http://127.0.0.1:${port}`)
} else {
- console.error('[orca-dev] No free debug port found in sweep; starting without --remote-debugging-port.')
+ console.error(
+ '[orca-dev] No free debug port found in sweep; starting without --remote-debugging-port.'
+ )
}
}
const forwardedArgs = ['dev', ...forwardedRaw, ...forwardedExtras]
diff --git a/config/scripts/verify-web-build.mjs b/config/scripts/verify-web-build.mjs
new file mode 100644
index 000000000..cf700129a
--- /dev/null
+++ b/config/scripts/verify-web-build.mjs
@@ -0,0 +1,14 @@
+import { readFile } from 'fs/promises'
+import { resolve } from 'path'
+
+const indexPath = resolve('out/web/web-index.html')
+const html = await readFile(indexPath, 'utf8')
+
+const absoluteAssetReference = /\b(?:src|href)=["']\/assets\//.exec(html)
+
+if (absoluteAssetReference) {
+ console.error(
+ `Web build must use relative asset URLs for reverse-proxy pairing URLs; found ${absoluteAssetReference[0]} in ${indexPath}`
+ )
+ process.exit(1)
+}
diff --git a/package.json b/package.json
index 2c9c6ea5f..18ce227e8 100644
--- a/package.json
+++ b/package.json
@@ -27,14 +27,16 @@
"typecheck": "tsc --noEmit -p config/tsconfig.node.json --composite false && tsc --noEmit -p config/tsconfig.cli.json --composite false && tsc --noEmit -p config/tsconfig.web.json --composite false",
"start": "electron-vite preview",
"dev": "node config/scripts/run-electron-vite-dev.mjs",
+ "dev:web": "vite --config vite.web.config.ts --host 127.0.0.1",
"build:relay": "node config/scripts/build-relay.mjs",
"build:computer-macos": "node config/scripts/build-computer-macos.mjs",
"smoke:computer": "node config/scripts/computer-use-smoke.mjs",
"verify:computer-native": "node config/scripts/verify-computer-native.mjs",
"build:cli": "tsc -p config/tsconfig.cli.json --outDir out --composite false --incremental false && node config/scripts/install-dev-cli.mjs",
"build:electron-vite": "node config/scripts/run-electron-vite-build.mjs",
- "build": "pnpm run typecheck && pnpm run build:relay && pnpm run build:computer-macos && pnpm run build:electron-vite && pnpm run build:cli",
- "build:release": "pnpm run build:relay && pnpm run build:computer-macos && pnpm run verify:computer-native && pnpm run build:electron-vite && pnpm run build:cli",
+ "build:web": "vite build --config vite.web.config.ts && node config/scripts/verify-web-build.mjs",
+ "build": "pnpm run typecheck && pnpm run build:relay && pnpm run build:computer-macos && pnpm run build:electron-vite && pnpm run build:web && pnpm run build:cli",
+ "build:release": "pnpm run build:relay && pnpm run build:computer-macos && pnpm run verify:computer-native && pnpm run build:electron-vite && pnpm run build:web && pnpm run build:cli",
"postinstall": "pnpm rebuild electron && node config/scripts/rebuild-native-deps.mjs",
"rebuild:electron": "node config/scripts/rebuild-native-deps.mjs",
"build:unpack": "pnpm run build && electron-builder --config config/electron-builder.config.cjs --dir",
diff --git a/src/cli/runtime/launch.test.ts b/src/cli/runtime/launch.test.ts
index 807df9dc7..c3cf5b306 100644
--- a/src/cli/runtime/launch.test.ts
+++ b/src/cli/runtime/launch.test.ts
@@ -19,6 +19,7 @@ describe('serveOrcaApp', () => {
afterEach(() => {
delete process.env.ORCA_APP_EXECUTABLE
+ delete process.env.ORCA_APP_EXECUTABLE_NEEDS_APP_ROOT
})
it('pins the Electron child cwd to the app root instead of the caller cwd', async () => {
@@ -85,4 +86,64 @@ describe('serveOrcaApp', () => {
})
)
})
+
+ it('passes the app root before serve flags for dev Electron executables', async () => {
+ process.env.ORCA_APP_EXECUTABLE = '/repo/node_modules/.bin/electron'
+ process.env.ORCA_APP_EXECUTABLE_NEEDS_APP_ROOT = '1'
+ const child = {
+ kill: vi.fn(),
+ once: vi.fn(
+ (event: string, handler: (code: number | null, signal: string | null) => void) => {
+ if (event === 'exit') {
+ queueMicrotask(() => handler(0, null))
+ }
+ return child
+ }
+ )
+ }
+ spawnMock.mockReturnValue(child)
+
+ await expect(serveOrcaApp({ json: true, port: '6768' })).resolves.toBe(0)
+
+ expect(spawnMock).toHaveBeenCalledWith(
+ '/repo/node_modules/.bin/electron',
+ [resolve(__dirname, '../../..'), '--serve', '--serve-json', '--serve-port', '6768'],
+ expect.objectContaining({
+ cwd: resolve(__dirname, '../../..')
+ })
+ )
+ })
+
+ it('uses a shell when a Windows npm command shim is the Electron executable', async () => {
+ const platformDescriptor = Object.getOwnPropertyDescriptor(process, 'platform')
+ Object.defineProperty(process, 'platform', { value: 'win32' })
+ process.env.ORCA_APP_EXECUTABLE = 'C:\\repo\\node_modules\\.bin\\electron.cmd'
+ const child = {
+ kill: vi.fn(),
+ once: vi.fn(
+ (event: string, handler: (code: number | null, signal: string | null) => void) => {
+ if (event === 'exit') {
+ queueMicrotask(() => handler(0, null))
+ }
+ return child
+ }
+ )
+ }
+ spawnMock.mockReturnValue(child)
+
+ try {
+ await expect(serveOrcaApp({ json: true })).resolves.toBe(0)
+ expect(spawnMock).toHaveBeenCalledWith(
+ 'C:\\repo\\node_modules\\.bin\\electron.cmd',
+ ['--serve', '--serve-json'],
+ expect.objectContaining({
+ shell: true
+ })
+ )
+ } finally {
+ if (platformDescriptor) {
+ Object.defineProperty(process, 'platform', platformDescriptor)
+ }
+ }
+ })
})
diff --git a/src/cli/runtime/launch.ts b/src/cli/runtime/launch.ts
index 71de31117..6a7058c98 100644
--- a/src/cli/runtime/launch.ts
+++ b/src/cli/runtime/launch.ts
@@ -1,4 +1,4 @@
-import { spawn as spawnProcess } from 'child_process'
+import { spawn as spawnProcess, type SpawnOptions } from 'child_process'
import { dirname, resolve } from 'path'
import { RuntimeClientError } from './types'
@@ -15,9 +15,10 @@ export function launchOrcaApp(): void {
const overrideExecutable = process.env.ORCA_APP_EXECUTABLE
if (typeof overrideExecutable === 'string' && overrideExecutable.trim().length > 0) {
- spawnProcess(overrideExecutable, [], {
+ spawnProcess(overrideExecutable, getExecutableAppArgs(), {
detached: true,
stdio: 'ignore',
+ ...getExecutableSpawnOptions(overrideExecutable),
env: stripElectronRunAsNode(process.env)
}).unref()
return
@@ -63,7 +64,7 @@ export function serveOrcaApp(
} = {}
): Promise {
const executable = resolveForegroundOrcaExecutable()
- const childArgs = ['--serve']
+ const childArgs = [...getExecutableAppArgs(), '--serve']
if (args.json) {
childArgs.push('--serve-json')
}
@@ -83,6 +84,7 @@ export function serveOrcaApp(
const child = spawnProcess(executable, childArgs, {
cwd: resolveAppRoot(),
stdio: 'inherit',
+ ...getExecutableSpawnOptions(executable),
env: stripElectronRunAsNode(process.env)
})
@@ -119,6 +121,14 @@ export function serveOrcaApp(
})
}
+function getExecutableAppArgs(): string[] {
+ return process.env.ORCA_APP_EXECUTABLE_NEEDS_APP_ROOT === '1' ? [resolveAppRoot()] : []
+}
+
+function getExecutableSpawnOptions(executable: string): Pick {
+ return process.platform === 'win32' && /\.(?:cmd|bat)$/i.test(executable) ? { shell: true } : {}
+}
+
function resolveAppRoot(): string {
// Why: dev-mode resource resolution in the Electron child may consult
// process.cwd(). Pin it to the app root so `orca serve` behaves the same
diff --git a/src/cli/specs/core.ts b/src/cli/specs/core.ts
index f8f6d8ffb..afbb9dcd9 100644
--- a/src/cli/specs/core.ts
+++ b/src/cli/specs/core.ts
@@ -18,7 +18,8 @@ export const CORE_COMMAND_SPECS: CommandSpec[] = [
notes: [
'Runs in the foreground and prints the runtime endpoint. Stop it with Ctrl+C.',
'Use --pairing-address when clients should connect through a LAN, Tailscale, SSH-forward, or public tunnel address.',
- 'Use --mobile-pairing to print a mobile-scoped pairing QR/link instead of the default runtime-environment pairing link.'
+ 'Use --mobile-pairing to print a mobile-scoped pairing QR/link instead of the default runtime-environment pairing link.',
+ 'When the web client bundle is available, the server also prints a browser URL with the pairing data embedded.'
],
examples: [
'orca serve',
diff --git a/src/main/index.ts b/src/main/index.ts
index d16fdb2f1..7da6e4fa7 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -3,6 +3,8 @@
startup. Splitting by line count would fragment tightly coupled startup
logic across files without a cleaner ownership seam. */
import { grantDirAcl } from './win32-utils'
+import { existsSync } from 'fs'
+import { join } from 'path'
import { app, BrowserWindow, nativeImage, nativeTheme } from 'electron'
import { electronApp, is } from '@electron-toolkit/utils'
import * as QRCode from 'qrcode'
@@ -449,6 +451,11 @@ function getServeOptions(argv = process.argv): ServeOptions {
}
}
+function getBundledWebClientRoot(): string | undefined {
+ const root = join(app.getAppPath(), 'out', 'web')
+ return existsSync(join(root, 'web-index.html')) ? root : undefined
+}
+
async function renderTerminalPairingQr(pairingUrl: string): Promise {
try {
return await QRCode.toString(pairingUrl, { type: 'terminal', small: true })
@@ -488,6 +495,7 @@ async function printServeReady(options: ServeOptions): Promise {
url: pairing.pairingUrl,
endpoint: pairing.endpoint,
deviceId: pairing.deviceId,
+ webClientUrl: pairing.webClientUrl,
scope: options.mobilePairing ? 'mobile' : 'runtime',
qr: pairingQr
}
@@ -498,6 +506,9 @@ async function printServeReady(options: ServeOptions): Promise {
}
console.log(`Orca server ready: ${endpoint ?? 'websocket unavailable'}`)
if (pairing.available) {
+ if (pairing.webClientUrl) {
+ console.log(`Web client URL: ${pairing.webClientUrl}`)
+ }
if (options.mobilePairing && pairingQr) {
console.log(`Mobile pairing QR:\n${pairingQr}`)
}
@@ -760,7 +771,8 @@ app.whenReady().then(async () => {
enableWebSocket: true,
...(isE2E ? { wsPort: 0 } : {}),
...(devWsPort !== undefined ? { wsPort: devWsPort } : {}),
- ...(serveOptions?.wsPort !== undefined ? { wsPort: serveOptions.wsPort } : {})
+ ...(serveOptions?.wsPort !== undefined ? { wsPort: serveOptions.wsPort } : {}),
+ webClientRoot: getBundledWebClientRoot()
})
registerMobileHandlers(runtimeRpc)
diff --git a/src/main/ipc/mobile.test.ts b/src/main/ipc/mobile.test.ts
index 5fb11e0b6..585b8aaf1 100644
--- a/src/main/ipc/mobile.test.ts
+++ b/src/main/ipc/mobile.test.ts
@@ -69,4 +69,37 @@ describe('registerMobileHandlers', () => {
]
})
})
+
+ it('generates runtime-scoped pairing urls for web and desktop clients', async () => {
+ const createPairingOffer = vi.fn().mockReturnValue({
+ available: true,
+ pairingUrl: 'orca://pair#runtime',
+ webClientUrl: 'http://100.64.1.20:6768/web-index.html?pairing=runtime',
+ endpoint: 'ws://100.64.1.20:6768',
+ deviceId: 'runtime-1'
+ })
+ const rpcServer = { createPairingOffer }
+
+ registerMobileHandlers(rpcServer as never)
+
+ await expect(
+ handlers.get('mobile:getRuntimePairingUrl')?.(null, {
+ address: '100.64.1.20',
+ rotate: true
+ })
+ ).resolves.toEqual({
+ available: true,
+ pairingUrl: 'orca://pair#runtime',
+ webClientUrl: 'http://100.64.1.20:6768/web-index.html?pairing=runtime',
+ endpoint: 'ws://100.64.1.20:6768',
+ deviceId: 'runtime-1'
+ })
+
+ expect(createPairingOffer).toHaveBeenCalledWith({
+ address: '100.64.1.20',
+ rotate: true,
+ name: expect.stringMatching(/^Runtime /),
+ scope: 'runtime'
+ })
+ })
})
diff --git a/src/main/ipc/mobile.ts b/src/main/ipc/mobile.ts
index 110f16d26..fc0315846 100644
--- a/src/main/ipc/mobile.ts
+++ b/src/main/ipc/mobile.ts
@@ -86,6 +86,36 @@ export function registerMobileHandlers(rpcServer: OrcaRuntimeRpcServer): void {
}
)
+ ipcMain.handle(
+ 'mobile:getRuntimePairingUrl',
+ async (_event, args?: { address?: string; rotate?: boolean }) => {
+ const ip = args?.address ?? getLanAddress()
+ if (!ip) {
+ return { available: false as const }
+ }
+
+ // Why: web/desktop runtime clients need full runtime access, not the
+ // mobile allowlist used by phone QR pairing.
+ const offer = rpcServer.createPairingOffer({
+ address: ip,
+ rotate: args?.rotate,
+ name: `Runtime ${new Date().toLocaleDateString()}`,
+ scope: 'runtime'
+ })
+ if (!offer.available) {
+ return { available: false as const }
+ }
+
+ return {
+ available: true as const,
+ pairingUrl: offer.pairingUrl,
+ webClientUrl: offer.webClientUrl,
+ endpoint: offer.endpoint,
+ deviceId: offer.deviceId
+ }
+ }
+ )
+
ipcMain.handle('mobile:listDevices', () => {
const registry = rpcServer.getDeviceRegistry()
if (!registry) {
diff --git a/src/main/ipc/preflight.ts b/src/main/ipc/preflight.ts
index 865c6d334..db3248091 100644
--- a/src/main/ipc/preflight.ts
+++ b/src/main/ipc/preflight.ts
@@ -114,6 +114,17 @@ export async function refreshShellPathAndDetectAgents(): Promise {
+ const mux = getActiveMultiplexer(args.connectionId)
+ if (!mux || mux.isDisposed()) {
+ throw new Error(`No active SSH connection for "${args.connectionId}"`)
+ }
+ const result = (await mux.request('preflight.detectAgents', {
+ commands: KNOWN_AGENT_COMMANDS
+ })) as { agents: string[] }
+ return result.agents
+}
+
async function isGhAuthenticated(): Promise {
try {
await execFileAsync('gh', ['auth', 'status'], {
@@ -199,14 +210,7 @@ export function registerPreflightHandlers(): void {
ipcMain.handle(
'preflight:detectRemoteAgents',
async (_event, args: { connectionId: string }): Promise => {
- const mux = getActiveMultiplexer(args.connectionId)
- if (!mux || mux.isDisposed()) {
- throw new Error(`No active SSH connection for "${args.connectionId}"`)
- }
- const result = (await mux.request('preflight.detectAgents', {
- commands: KNOWN_AGENT_COMMANDS
- })) as { agents: string[] }
- return result.agents
+ return detectRemoteAgents(args)
}
)
}
diff --git a/src/main/runtime/orca-runtime.ts b/src/main/runtime/orca-runtime.ts
index 00767acf3..9f0277b35 100644
--- a/src/main/runtime/orca-runtime.ts
+++ b/src/main/runtime/orca-runtime.ts
@@ -137,6 +137,7 @@ import {
import {
clearProjectItemFieldValue,
getProjectViewTable,
+ getWorkItemDetailsBySlug,
listAccessibleProjects,
listProjectViews,
resolveProjectRef,
@@ -158,6 +159,7 @@ import type {
ListIssueTypesBySlugArgs,
ListLabelsBySlugArgs,
ListProjectViewsArgs,
+ ProjectWorkItemDetailsBySlugArgs,
ResolveProjectRefArgs,
AddIssueCommentBySlugArgs,
DeleteIssueCommentBySlugArgs,
@@ -4655,6 +4657,12 @@ export class OrcaRuntimeService {
return getProjectViewTable(args)
}
+ async getGitHubProjectWorkItemDetailsBySlug(
+ args: ProjectWorkItemDetailsBySlugArgs
+ ): Promise>> {
+ return getWorkItemDetailsBySlug(args)
+ }
+
async updateGitHubProjectItemField(
args: UpdateProjectItemFieldArgs
): Promise>> {
diff --git a/src/main/runtime/rpc/methods/github.test.ts b/src/main/runtime/rpc/methods/github.test.ts
index bcd322350..cff285234 100644
--- a/src/main/runtime/rpc/methods/github.test.ts
+++ b/src/main/runtime/rpc/methods/github.test.ts
@@ -467,6 +467,37 @@ describe('github RPC methods', () => {
expect(response).toMatchObject({ ok: true, result: { ok: true, data: { rows: [] } } })
})
+ it('fetches GitHub project work item details by slug on the runtime server', async () => {
+ const runtime = {
+ getRuntimeId: () => 'test-runtime',
+ getGitHubProjectWorkItemDetailsBySlug: vi.fn().mockResolvedValue({
+ ok: true,
+ item: { number: 9, title: 'Bug' }
+ })
+ } as unknown as OrcaRuntimeService
+ const dispatcher = new RpcDispatcher({ runtime, methods: GITHUB_METHODS })
+
+ const response = await dispatcher.dispatch(
+ makeRequest('github.project.workItemDetailsBySlug', {
+ owner: 'acme',
+ repo: 'orca',
+ number: 9,
+ type: 'issue'
+ })
+ )
+
+ expect(runtime.getGitHubProjectWorkItemDetailsBySlug).toHaveBeenCalledWith({
+ owner: 'acme',
+ repo: 'orca',
+ number: 9,
+ type: 'issue'
+ })
+ expect(response).toMatchObject({
+ ok: true,
+ result: { ok: true, item: { number: 9, title: 'Bug' } }
+ })
+ })
+
it('updates GitHub project item fields on the runtime server', async () => {
const runtime = {
getRuntimeId: () => 'test-runtime',
diff --git a/src/main/runtime/rpc/methods/github.ts b/src/main/runtime/rpc/methods/github.ts
index 72b32e6cd..137a1d9f6 100644
--- a/src/main/runtime/rpc/methods/github.ts
+++ b/src/main/runtime/rpc/methods/github.ts
@@ -142,6 +142,11 @@ const ProjectViewTable = z.object({
queryOverride: OptionalString
})
+const ProjectWorkItemDetailsBySlug = SlugRepo.extend({
+ number: z.number().int().positive(),
+ type: z.enum(['issue', 'pr'])
+})
+
const ProjectRef = z.object({
input: requiredString('Missing project reference')
})
@@ -399,6 +404,11 @@ export const GITHUB_METHODS: RpcMethod[] = [
params: ProjectViewTable,
handler: async (params, { runtime }) => runtime.getGitHubProjectViewTable(params)
}),
+ defineMethod({
+ name: 'github.project.workItemDetailsBySlug',
+ params: ProjectWorkItemDetailsBySlug,
+ handler: async (params, { runtime }) => runtime.getGitHubProjectWorkItemDetailsBySlug(params)
+ }),
defineMethod({
name: 'github.project.updateItemField',
params: ProjectItemField,
diff --git a/src/main/runtime/rpc/methods/index.ts b/src/main/runtime/rpc/methods/index.ts
index 9cbc55d34..868a3b503 100644
--- a/src/main/runtime/rpc/methods/index.ts
+++ b/src/main/runtime/rpc/methods/index.ts
@@ -9,6 +9,7 @@ import { ORCHESTRATION_METHODS } from './orchestration'
import { NOTIFICATION_METHODS } from './notifications'
import { STATS_METHODS } from './stats'
import { ACCOUNT_METHODS } from './accounts'
+import { PREFLIGHT_METHODS } from './preflight'
import { COMPUTER_METHODS } from './computer'
import { SESSION_TAB_METHODS } from './session-tabs'
import { FILE_METHODS } from './files'
@@ -33,6 +34,7 @@ export const ALL_RPC_METHODS: readonly RpcAnyMethod[] = [
...NOTIFICATION_METHODS,
...STATS_METHODS,
...ACCOUNT_METHODS,
+ ...PREFLIGHT_METHODS,
...COMPUTER_METHODS,
...SESSION_TAB_METHODS,
...FILE_METHODS,
diff --git a/src/main/runtime/rpc/methods/preflight.test.ts b/src/main/runtime/rpc/methods/preflight.test.ts
new file mode 100644
index 000000000..51a1231ca
--- /dev/null
+++ b/src/main/runtime/rpc/methods/preflight.test.ts
@@ -0,0 +1,84 @@
+import { describe, expect, it, vi } from 'vitest'
+import { RpcDispatcher } from '../dispatcher'
+import type { RpcRequest } from '../core'
+import type { OrcaRuntimeService } from '../../orca-runtime'
+import { PREFLIGHT_METHODS } from './preflight'
+
+const {
+ detectInstalledAgentsMock,
+ detectRemoteAgentsMock,
+ refreshShellPathAndDetectAgentsMock,
+ runPreflightCheckMock
+} = vi.hoisted(() => ({
+ detectInstalledAgentsMock: vi.fn(),
+ detectRemoteAgentsMock: vi.fn(),
+ refreshShellPathAndDetectAgentsMock: vi.fn(),
+ runPreflightCheckMock: vi.fn()
+}))
+
+vi.mock('../../../ipc/preflight', () => ({
+ detectInstalledAgents: detectInstalledAgentsMock,
+ detectRemoteAgents: detectRemoteAgentsMock,
+ refreshShellPathAndDetectAgents: refreshShellPathAndDetectAgentsMock,
+ runPreflightCheck: runPreflightCheckMock
+}))
+
+function makeRequest(method: string, params?: unknown): RpcRequest {
+ return { id: 'req-1', authToken: 'tok', method, params }
+}
+
+describe('preflight RPC methods', () => {
+ it('runs the server-side preflight check through runtime RPC', async () => {
+ const status = {
+ git: { installed: true },
+ gh: { installed: true, authenticated: true },
+ glab: { installed: false, authenticated: false },
+ bitbucket: { configured: false, authenticated: false, account: null }
+ }
+ runPreflightCheckMock.mockResolvedValueOnce(status)
+ const runtime = { getRuntimeId: () => 'test-runtime' } as unknown as OrcaRuntimeService
+ const dispatcher = new RpcDispatcher({ runtime, methods: PREFLIGHT_METHODS })
+
+ const response = await dispatcher.dispatch(makeRequest('preflight.check', { force: true }))
+
+ expect(runPreflightCheckMock).toHaveBeenCalledWith(true)
+ expect(response).toMatchObject({ ok: true, result: status })
+ })
+
+ it('detects agents and refreshes PATH on the server through runtime RPC', async () => {
+ detectInstalledAgentsMock.mockResolvedValueOnce(['codex'])
+ refreshShellPathAndDetectAgentsMock.mockResolvedValueOnce({
+ agents: ['codex', 'claude'],
+ addedPathSegments: ['/opt/bin'],
+ shellHydrationOk: true,
+ pathSource: 'shell_hydrate',
+ pathFailureReason: 'none'
+ })
+ const runtime = { getRuntimeId: () => 'test-runtime' } as unknown as OrcaRuntimeService
+ const dispatcher = new RpcDispatcher({ runtime, methods: PREFLIGHT_METHODS })
+
+ const detected = await dispatcher.dispatch(makeRequest('preflight.detectAgents'))
+ const refreshed = await dispatcher.dispatch(makeRequest('preflight.refreshAgents'))
+
+ expect(detectInstalledAgentsMock).toHaveBeenCalled()
+ expect(refreshShellPathAndDetectAgentsMock).toHaveBeenCalled()
+ expect(detected).toMatchObject({ ok: true, result: ['codex'] })
+ expect(refreshed).toMatchObject({
+ ok: true,
+ result: { agents: ['codex', 'claude'], shellHydrationOk: true }
+ })
+ })
+
+ it('detects agents on remote SSH connections through runtime RPC', async () => {
+ detectRemoteAgentsMock.mockResolvedValueOnce(['claude'])
+ const runtime = { getRuntimeId: () => 'test-runtime' } as unknown as OrcaRuntimeService
+ const dispatcher = new RpcDispatcher({ runtime, methods: PREFLIGHT_METHODS })
+
+ const response = await dispatcher.dispatch(
+ makeRequest('preflight.detectRemoteAgents', { connectionId: 'ssh-1' })
+ )
+
+ expect(detectRemoteAgentsMock).toHaveBeenCalledWith({ connectionId: 'ssh-1' })
+ expect(response).toMatchObject({ ok: true, result: ['claude'] })
+ })
+})
diff --git a/src/main/runtime/rpc/methods/preflight.ts b/src/main/runtime/rpc/methods/preflight.ts
new file mode 100644
index 000000000..720a823cc
--- /dev/null
+++ b/src/main/runtime/rpc/methods/preflight.ts
@@ -0,0 +1,38 @@
+import { z } from 'zod'
+import { defineMethod, type RpcMethod } from '../core'
+import {
+ detectRemoteAgents,
+ detectInstalledAgents,
+ refreshShellPathAndDetectAgents,
+ runPreflightCheck
+} from '../../../ipc/preflight'
+
+const PreflightCheck = z.object({
+ force: z.boolean().optional()
+})
+const PreflightDetectRemoteAgents = z.object({
+ connectionId: z.string().min(1)
+})
+
+export const PREFLIGHT_METHODS: RpcMethod[] = [
+ defineMethod({
+ name: 'preflight.check',
+ params: PreflightCheck,
+ handler: async (params) => runPreflightCheck(params.force)
+ }),
+ defineMethod({
+ name: 'preflight.detectAgents',
+ params: null,
+ handler: async () => detectInstalledAgents()
+ }),
+ defineMethod({
+ name: 'preflight.detectRemoteAgents',
+ params: PreflightDetectRemoteAgents,
+ handler: async (params) => detectRemoteAgents(params)
+ }),
+ defineMethod({
+ name: 'preflight.refreshAgents',
+ params: null,
+ handler: async () => refreshShellPathAndDetectAgents()
+ })
+]
diff --git a/src/main/runtime/rpc/static-web-client-handler.ts b/src/main/runtime/rpc/static-web-client-handler.ts
new file mode 100644
index 000000000..650df1be7
--- /dev/null
+++ b/src/main/runtime/rpc/static-web-client-handler.ts
@@ -0,0 +1,139 @@
+import { createReadStream } from 'fs'
+import { stat } from 'fs/promises'
+import type { IncomingMessage, RequestListener, ServerResponse } from 'http'
+import { extname, isAbsolute, posix, relative, resolve } from 'path'
+
+const STATIC_WEB_ALLOWED_PATHS = new Set(['/web-index.html'])
+const STATIC_WEB_ALLOWED_PREFIXES = ['/assets/']
+const STATIC_WEB_CONTENT_TYPES = new Map([
+ ['.css', 'text/css; charset=utf-8'],
+ ['.html', 'text/html; charset=utf-8'],
+ ['.js', 'text/javascript; charset=utf-8'],
+ ['.json', 'application/json; charset=utf-8'],
+ ['.png', 'image/png'],
+ ['.svg', 'image/svg+xml; charset=utf-8'],
+ ['.wasm', 'application/wasm'],
+ ['.webp', 'image/webp'],
+ ['.woff2', 'font/woff2']
+])
+
+export function createStaticWebClientHandler(staticRoot: string): RequestListener {
+ const resolvedRoot = resolve(staticRoot)
+ return (request, response) => {
+ void handleStaticRequest(resolvedRoot, request, response)
+ }
+}
+
+async function handleStaticRequest(
+ staticRoot: string,
+ request: IncomingMessage,
+ response: ServerResponse
+): Promise {
+ if (request.method !== 'GET' && request.method !== 'HEAD') {
+ response.setHeader('Allow', 'GET, HEAD')
+ writeHttpStatus(response, 405)
+ return
+ }
+
+ const pathname = parseStaticPathname(request.url)
+ if (!pathname) {
+ writeHttpStatus(response, 400)
+ return
+ }
+ if (!isAllowedStaticWebPath(pathname)) {
+ writeHttpStatus(response, 404)
+ return
+ }
+
+ const absolutePath = resolve(staticRoot, pathname.slice(1))
+ const relativePath = relative(staticRoot, absolutePath)
+ if (relativePath === '' || relativePath.startsWith('..') || isAbsolute(relativePath)) {
+ writeHttpStatus(response, 404)
+ return
+ }
+
+ let fileStat
+ try {
+ fileStat = await stat(absolutePath)
+ } catch {
+ writeHttpStatus(response, 404)
+ return
+ }
+ if (!fileStat.isFile()) {
+ writeHttpStatus(response, 404)
+ return
+ }
+
+ response.statusCode = 200
+ response.setHeader(
+ 'Content-Type',
+ STATIC_WEB_CONTENT_TYPES.get(extname(absolutePath)) ?? 'application/octet-stream'
+ )
+ response.setHeader('Content-Length', fileStat.size)
+ response.setHeader(
+ 'Cache-Control',
+ pathname.startsWith('/assets/') ? 'public, max-age=31536000, immutable' : 'no-cache'
+ )
+ if (request.method === 'HEAD') {
+ response.end()
+ return
+ }
+
+ const stream = createReadStream(absolutePath)
+ stream.on('error', () => {
+ if (!response.headersSent) {
+ writeHttpStatus(response, 500)
+ return
+ }
+ response.destroy()
+ })
+ stream.pipe(response)
+}
+
+function parseStaticPathname(rawUrl: string | undefined): string | null {
+ if (!rawUrl) {
+ return '/web-index.html'
+ }
+ let pathname: string
+ try {
+ pathname = decodeURIComponent(new URL(rawUrl, 'http://127.0.0.1').pathname)
+ } catch {
+ return null
+ }
+ if (pathname === '/' || pathname === '/index.html') {
+ return '/web-index.html'
+ }
+ if (pathname.includes('\0') || pathname.includes('\\') || pathname.split('/').includes('..')) {
+ return null
+ }
+ if (posix.normalize(pathname) !== pathname) {
+ return null
+ }
+ return mapProxyPrefixedStaticPathname(pathname)
+}
+
+function mapProxyPrefixedStaticPathname(pathname: string): string {
+ if (pathname === '/web-index.html' || pathname.endsWith('/web-index.html')) {
+ return '/web-index.html'
+ }
+ const assetMarker = '/assets/'
+ const assetIndex = pathname.indexOf(assetMarker)
+ if (assetIndex !== -1) {
+ // Why: reverse proxies may forward the external path prefix through to
+ // Orca. Only the bundled /assets subtree is served after the prefix.
+ return pathname.slice(assetIndex)
+ }
+ return pathname
+}
+
+function isAllowedStaticWebPath(pathname: string): boolean {
+ return (
+ STATIC_WEB_ALLOWED_PATHS.has(pathname) ||
+ STATIC_WEB_ALLOWED_PREFIXES.some((prefix) => pathname.startsWith(prefix))
+ )
+}
+
+function writeHttpStatus(response: ServerResponse, statusCode: number): void {
+ response.statusCode = statusCode
+ response.end()
+}
diff --git a/src/main/runtime/rpc/ws-transport-static-web.test.ts b/src/main/runtime/rpc/ws-transport-static-web.test.ts
new file mode 100644
index 000000000..ed321b5c0
--- /dev/null
+++ b/src/main/runtime/rpc/ws-transport-static-web.test.ts
@@ -0,0 +1,91 @@
+import { mkdirSync, mkdtempSync, writeFileSync } from 'fs'
+import { tmpdir } from 'os'
+import { join } from 'path'
+import { afterEach, describe, expect, it } from 'vitest'
+import { WebSocketTransport } from './ws-transport'
+
+describe('WebSocketTransport static web client', () => {
+ const transports: WebSocketTransport[] = []
+
+ afterEach(async () => {
+ await Promise.all(transports.map((t) => t.stop().catch(() => {})))
+ transports.length = 0
+ })
+
+ function createStaticTransport(staticRoot: string): WebSocketTransport {
+ const transport = new WebSocketTransport({
+ host: '127.0.0.1',
+ port: 0,
+ staticRoot
+ })
+ transports.push(transport)
+ return transport
+ }
+
+ it('serves the built web client from the same server', async () => {
+ const staticRoot = mkdtempSync(join(tmpdir(), 'ws-transport-static-'))
+ mkdirSync(join(staticRoot, 'assets'))
+ writeFileSync(join(staticRoot, 'web-index.html'), 'web')
+ writeFileSync(join(staticRoot, 'assets', 'app.js'), 'console.log("web")')
+ const transport = createStaticTransport(staticRoot)
+
+ await transport.start()
+
+ const indexResponse = await fetch(`http://127.0.0.1:${transport.resolvedPort}/web-index.html`)
+ expect(indexResponse.status).toBe(200)
+ expect(indexResponse.headers.get('content-type')).toContain('text/html')
+ await expect(indexResponse.text()).resolves.toBe('web')
+
+ const assetResponse = await fetch(`http://127.0.0.1:${transport.resolvedPort}/assets/app.js`)
+ expect(assetResponse.status).toBe(200)
+ expect(assetResponse.headers.get('cache-control')).toContain('immutable')
+ await expect(assetResponse.text()).resolves.toBe('console.log("web")')
+ })
+
+ it('serves web assets when a reverse-proxy path prefix is forwarded', async () => {
+ const staticRoot = mkdtempSync(join(tmpdir(), 'ws-transport-static-'))
+ mkdirSync(join(staticRoot, 'assets'))
+ writeFileSync(join(staticRoot, 'web-index.html'), '')
+ writeFileSync(join(staticRoot, 'assets', 'app.js'), 'console.log("prefixed")')
+ const transport = createStaticTransport(staticRoot)
+
+ await transport.start()
+
+ const indexResponse = await fetch(
+ `http://127.0.0.1:${transport.resolvedPort}/orca/web-index.html`
+ )
+ expect(indexResponse.status).toBe(200)
+ await expect(indexResponse.text()).resolves.toBe('')
+
+ const assetResponse = await fetch(
+ `http://127.0.0.1:${transport.resolvedPort}/orca/assets/app.js`
+ )
+ expect(assetResponse.status).toBe(200)
+ await expect(assetResponse.text()).resolves.toBe('console.log("prefixed")')
+ })
+
+ it('does not expose arbitrary files from the static root', async () => {
+ const staticRoot = mkdtempSync(join(tmpdir(), 'ws-transport-static-'))
+ writeFileSync(join(staticRoot, 'package.json'), '{}')
+ const transport = createStaticTransport(staticRoot)
+
+ await transport.start()
+
+ const response = await fetch(`http://127.0.0.1:${transport.resolvedPort}/package.json`)
+ expect(response.status).toBe(404)
+ })
+
+ it('rejects encoded Windows separators in static paths', async () => {
+ const staticRoot = mkdtempSync(join(tmpdir(), 'ws-transport-static-'))
+ mkdirSync(join(staticRoot, 'assets'))
+ writeFileSync(join(staticRoot, 'package.json'), '{}')
+ const transport = createStaticTransport(staticRoot)
+
+ await transport.start()
+
+ const response = await fetch(
+ `http://127.0.0.1:${transport.resolvedPort}/assets/..%5Cpackage.json`
+ )
+ expect(response.status).toBe(400)
+ })
+})
diff --git a/src/main/runtime/rpc/ws-transport.test.ts b/src/main/runtime/rpc/ws-transport.test.ts
index 2f3bcf6bd..72af8f185 100644
--- a/src/main/runtime/rpc/ws-transport.test.ts
+++ b/src/main/runtime/rpc/ws-transport.test.ts
@@ -1,3 +1,6 @@
+/* eslint-disable max-lines -- Why: these tests exercise one stateful transport
+ boundary across connection lifecycle, heartbeat, pre-auth timeout, and
+ shutdown behavior; splitting the setup would obscure the shared invariants. */
import { mkdtempSync } from 'fs'
import { tmpdir } from 'os'
import { join } from 'path'
diff --git a/src/main/runtime/rpc/ws-transport.ts b/src/main/runtime/rpc/ws-transport.ts
index 028c3f379..07ccc0952 100644
--- a/src/main/runtime/rpc/ws-transport.ts
+++ b/src/main/runtime/rpc/ws-transport.ts
@@ -1,3 +1,6 @@
+/* eslint-disable max-lines -- Why: the WebSocket transport owns connection
+ admission, heartbeat, pre-auth timeout, and client-id cleanup together; those
+ invariants are easier to audit in one transport boundary. */
// Why: the WebSocket transport enables mobile clients to connect to the Orca
// runtime over the local network. When TLS cert/key are provided it uses wss://
// to prevent passive sniffing; otherwise it falls back to plain ws://. Per-device
@@ -7,6 +10,7 @@ import { createServer as createHttpsServer, type Server as HttpsServer } from 'h
import { createServer as createHttpServer, type Server as HttpServer } from 'http'
import { WebSocketServer, type WebSocket } from 'ws'
import type { RpcTransport } from './transport'
+import { createStaticWebClientHandler } from './static-web-client-handler'
const MAX_WS_MESSAGE_BYTES = 1024 * 1024
const MAX_WS_CONNECTIONS = 32
@@ -41,6 +45,9 @@ export type WebSocketTransportOptions = {
heartbeatIntervalMs?: number
// Why: test-only override. Production uses PRE_AUTH_TIMEOUT_MS.
preAuthTimeoutMs?: number
+ // Why: the pairing server can also serve the browser client, so users do
+ // not need a second dev/static server once the web bundle is built.
+ staticRoot?: string
}
export class WebSocketTransport implements RpcTransport {
@@ -50,6 +57,7 @@ export class WebSocketTransport implements RpcTransport {
private readonly tlsKey: string | undefined
private readonly heartbeatIntervalMs: number
private readonly preAuthTimeoutMs: number
+ private readonly staticRoot: string | undefined
private httpServer: HttpsServer | HttpServer | null = null
private wss: WebSocketServer | null = null
private heartbeatTimer: ReturnType | null = null
@@ -72,7 +80,8 @@ export class WebSocketTransport implements RpcTransport {
tlsCert,
tlsKey,
heartbeatIntervalMs,
- preAuthTimeoutMs
+ preAuthTimeoutMs,
+ staticRoot
}: WebSocketTransportOptions) {
this.host = host
this.port = port
@@ -80,6 +89,7 @@ export class WebSocketTransport implements RpcTransport {
this.tlsKey = tlsKey
this.heartbeatIntervalMs = heartbeatIntervalMs ?? HEARTBEAT_INTERVAL_MS
this.preAuthTimeoutMs = preAuthTimeoutMs ?? PRE_AUTH_TIMEOUT_MS
+ this.staticRoot = staticRoot
}
onMessage(handler: WebSocketMessageHandler): void {
@@ -150,9 +160,12 @@ export class WebSocketTransport implements RpcTransport {
}
private createHttpServer(): HttpServer | HttpsServer {
+ const requestListener = this.staticRoot
+ ? createStaticWebClientHandler(this.staticRoot)
+ : undefined
return this.tlsCert && this.tlsKey
- ? createHttpsServer({ cert: this.tlsCert, key: this.tlsKey })
- : createHttpServer()
+ ? createHttpsServer({ cert: this.tlsCert, key: this.tlsKey }, requestListener)
+ : createHttpServer(requestListener)
}
// Why: the WebSocketServer is attached only after listen succeeds. If we
diff --git a/src/main/runtime/runtime-rpc.test.ts b/src/main/runtime/runtime-rpc.test.ts
index acbbcdaa9..a67388bf1 100644
--- a/src/main/runtime/runtime-rpc.test.ts
+++ b/src/main/runtime/runtime-rpc.test.ts
@@ -255,7 +255,8 @@ describe('OrcaRuntimeRpcServer', () => {
runtime,
userDataPath,
enableWebSocket: true,
- wsPort: 0
+ wsPort: 0,
+ webClientRoot: userDataPath
})
await server.start()
@@ -274,6 +275,63 @@ describe('OrcaRuntimeRpcServer', () => {
await server.stop()
})
+ it('includes a web client URL when the web bundle is served by the runtime', async () => {
+ const userDataPath = mkdtempSync(join(tmpdir(), 'orca-runtime-rpc-'))
+ const runtime = new OrcaRuntimeService()
+ const server = new OrcaRuntimeRpcServer({
+ runtime,
+ userDataPath,
+ enableWebSocket: true,
+ wsPort: 0,
+ webClientRoot: userDataPath
+ })
+
+ await server.start()
+
+ try {
+ const offer = server.createPairingOffer({ address: '100.64.1.20', name: 'Web test' })
+ expect(offer.available).toBe(true)
+ if (offer.available) {
+ expect(offer.webClientUrl).toBeTruthy()
+ const url = new URL(offer.webClientUrl!)
+ expect(url.protocol).toBe('http:')
+ expect(url.hostname).toBe('100.64.1.20')
+ expect(url.pathname).toBe('/web-index.html')
+ expect(url.search).toBe('')
+ expect(url.hash).toBe(`#pairing=${encodeURIComponent(offer.pairingUrl)}`)
+ }
+ } finally {
+ await server.stop()
+ }
+ })
+
+ it('preserves proxy path prefixes in web client URLs', async () => {
+ const userDataPath = mkdtempSync(join(tmpdir(), 'orca-runtime-rpc-'))
+ const runtime = new OrcaRuntimeService()
+ const server = new OrcaRuntimeRpcServer({
+ runtime,
+ userDataPath,
+ enableWebSocket: true,
+ wsPort: 0,
+ webClientRoot: userDataPath
+ })
+
+ await server.start()
+
+ try {
+ const offer = server.createPairingOffer({
+ address: 'wss://runtime.example.com/orca',
+ name: 'Proxy test'
+ })
+ expect(offer.available).toBe(true)
+ if (offer.available) {
+ expect(offer.webClientUrl).toContain('https://runtime.example.com/orca/web-index.html')
+ }
+ } finally {
+ await server.stop()
+ }
+ })
+
it('formats pairing-address overrides for IPv6 and host-port tunnel endpoints', async () => {
const userDataPath = mkdtempSync(join(tmpdir(), 'orca-runtime-rpc-'))
const runtime = new OrcaRuntimeService()
@@ -281,7 +339,8 @@ describe('OrcaRuntimeRpcServer', () => {
runtime,
userDataPath,
enableWebSocket: true,
- wsPort: 0
+ wsPort: 0,
+ webClientRoot: userDataPath
})
await server.start()
@@ -323,7 +382,8 @@ describe('OrcaRuntimeRpcServer', () => {
runtime,
userDataPath,
enableWebSocket: true,
- wsPort: 0
+ wsPort: 0,
+ webClientRoot: userDataPath
})
await server.start()
@@ -340,6 +400,7 @@ describe('OrcaRuntimeRpcServer', () => {
}
expect(server.getDeviceRegistry()?.getDevice(offer.deviceId)?.scope).toBe('mobile')
+ expect(offer.webClientUrl).toBeNull()
const parsed = parsePairingCode(offer.pairingUrl)
expect(parsed?.endpoint).toBe(offer.endpoint)
expect(parsed?.endpoint).toContain('100.64.1.20')
diff --git a/src/main/runtime/runtime-rpc.ts b/src/main/runtime/runtime-rpc.ts
index da555f988..f4687e2a9 100644
--- a/src/main/runtime/runtime-rpc.ts
+++ b/src/main/runtime/runtime-rpc.ts
@@ -35,6 +35,7 @@ type OrcaRuntimeRpcServerOptions = {
platform?: NodeJS.Platform
enableWebSocket?: boolean
wsPort?: number
+ webClientRoot?: string
// Why: test-only overrides for the two time-bound constants below.
// Production callers must not pass these — defaults are set by the design
// doc (§3.1) and changing them in production would weaken the admission
@@ -98,6 +99,24 @@ function formatWebSocketUrl(url: URL): string {
return url.pathname === '/' && !url.search && !url.hash ? formatted.replace(/\/$/, '') : formatted
}
+function createWebClientUrl(endpoint: string, pairingUrl: string): string {
+ const url = new URL(endpoint)
+ url.protocol = url.protocol === 'wss:' ? 'https:' : 'http:'
+ url.pathname = webClientPathForEndpoint(url.pathname)
+ url.search = ''
+ // Why: pairing URLs include full runtime credentials. Keeping them in the
+ // fragment avoids proxy logs and Referer headers while the web app loads.
+ url.hash = `pairing=${encodeURIComponent(pairingUrl)}`
+ return url.toString()
+}
+
+function webClientPathForEndpoint(pathname: string): string {
+ if (!pathname || pathname === '/') {
+ return '/web-index.html'
+ }
+ return `${pathname.replace(/\/$/, '')}/web-index.html`
+}
+
const MOBILE_RPC_METHOD_ALLOWLIST = new Set([
'accounts.list',
'accounts.selectClaude',
@@ -165,6 +184,7 @@ export class OrcaRuntimeRpcServer {
private readonly platform: NodeJS.Platform
private readonly enableWebSocket: boolean
private readonly wsPort: number
+ private readonly webClientRoot: string | undefined
private readonly authToken = randomBytes(24).toString('hex')
private readonly keepaliveIntervalMs: number
private readonly longPollCap: number
@@ -197,6 +217,7 @@ export class OrcaRuntimeRpcServer {
platform = process.platform,
enableWebSocket = false,
wsPort = DEFAULT_WS_PORT,
+ webClientRoot,
keepaliveIntervalMs = KEEPALIVE_INTERVAL_MS,
longPollCap = LONG_POLL_CAP
}: OrcaRuntimeRpcServerOptions) {
@@ -207,6 +228,7 @@ export class OrcaRuntimeRpcServer {
this.platform = platform
this.enableWebSocket = enableWebSocket
this.wsPort = wsPort
+ this.webClientRoot = webClientRoot
this.keepaliveIntervalMs = keepaliveIntervalMs
this.longPollCap = longPollCap
}
@@ -248,7 +270,13 @@ export class OrcaRuntimeRpcServer {
scope?: DeviceScope
}):
| { available: false }
- | { available: true; pairingUrl: string; endpoint: string; deviceId: string } {
+ | {
+ available: true
+ pairingUrl: string
+ endpoint: string
+ deviceId: string
+ webClientUrl: string | null
+ } {
const rawEndpoint = this.getWebSocketEndpoint()
const publicKeyB64 = this.getE2EEPublicKey()
if (!rawEndpoint || !this.deviceRegistry || !publicKeyB64) {
@@ -267,7 +295,14 @@ export class OrcaRuntimeRpcServer {
deviceToken: device.token,
publicKeyB64
})
- return { available: true, pairingUrl, endpoint, deviceId: device.deviceId }
+ return {
+ available: true,
+ pairingUrl,
+ endpoint,
+ deviceId: device.deviceId,
+ webClientUrl:
+ this.webClientRoot && scope === 'runtime' ? createWebClientUrl(endpoint, pairingUrl) : null
+ }
}
private registerBinaryStreamHandler(
@@ -384,7 +419,8 @@ export class OrcaRuntimeRpcServer {
const wsTransport = new WebSocketTransport({
host: '0.0.0.0',
- port: this.wsPort
+ port: this.wsPort,
+ staticRoot: this.webClientRoot
})
this.wsTransport = wsTransport
diff --git a/src/preload/api-types.ts b/src/preload/api-types.ts
index 9eb7f202d..cecd0f29d 100644
--- a/src/preload/api-types.ts
+++ b/src/preload/api-types.ts
@@ -1577,6 +1577,16 @@ export type PreloadApi = {
deviceId: string
}
>
+ getRuntimePairingUrl: (args?: { address?: string; rotate?: boolean }) => Promise<
+ | { available: false }
+ | {
+ available: true
+ pairingUrl: string
+ webClientUrl: string | null
+ endpoint: string
+ deviceId: string
+ }
+ >
listDevices: () => Promise<{
devices: { deviceId: string; name: string; pairedAt: number; lastSeenAt: number }[]
}>
diff --git a/src/preload/index.ts b/src/preload/index.ts
index d26874832..d87d80f2e 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -2618,6 +2618,20 @@ const api = {
}
> => ipcRenderer.invoke('mobile:getPairingQR', args),
+ getRuntimePairingUrl: (args?: {
+ address?: string
+ rotate?: boolean
+ }): Promise<
+ | { available: false }
+ | {
+ available: true
+ pairingUrl: string
+ webClientUrl: string | null
+ endpoint: string
+ deviceId: string
+ }
+ > => ipcRenderer.invoke('mobile:getRuntimePairingUrl', args),
+
listDevices: (): Promise<{
devices: { deviceId: string; name: string; pairedAt: number; lastSeenAt: number }[]
}> => ipcRenderer.invoke('mobile:listDevices'),
diff --git a/src/renderer/src/components/LinearItemDrawer.tsx b/src/renderer/src/components/LinearItemDrawer.tsx
index d4aac63d8..38fa89226 100644
--- a/src/renderer/src/components/LinearItemDrawer.tsx
+++ b/src/renderer/src/components/LinearItemDrawer.tsx
@@ -11,6 +11,7 @@ import { VisuallyHidden } from 'radix-ui'
import CommentMarkdown from '@/components/sidebar/CommentMarkdown'
import { cn } from '@/lib/utils'
import { useAppStore } from '@/store'
+import { createBrowserUuid } from '@/lib/browser-uuid'
import {
useTeamStates,
useTeamLabels,
@@ -447,7 +448,7 @@ function CommentFooter({
if (typed.ok) {
setBody('')
onCommentAdded({
- id: typed.id ?? crypto.randomUUID(),
+ id: typed.id ?? createBrowserUuid(),
body: trimmed,
createdAt: new Date().toISOString()
})
diff --git a/src/renderer/src/components/editor/ipynb-parse.ts b/src/renderer/src/components/editor/ipynb-parse.ts
index ffd2692b8..0415c4171 100644
--- a/src/renderer/src/components/editor/ipynb-parse.ts
+++ b/src/renderer/src/components/editor/ipynb-parse.ts
@@ -1,6 +1,8 @@
/* eslint-disable max-lines -- Why: keeping notebook parse and mutation helpers
in one module makes nbformat preservation easier to audit while the notebook
editor model is still small. */
+import { createBrowserUuid } from '@/lib/browser-uuid'
+
export type IpynbCellKind = 'code' | 'markdown' | 'raw'
export type IpynbOutput =
@@ -288,7 +290,7 @@ export function insertIpynbCell(
const cells = root.cells as unknown[]
const nextCell: Record = {
cell_type: kind,
- id: crypto.randomUUID?.() ?? `cell-${Date.now()}`,
+ id: createBrowserUuid(),
metadata: {},
source: []
}
@@ -307,7 +309,7 @@ export function deleteIpynbCell(content: string, index: number): string {
if (cells.length <= 1) {
cells.splice(0, cells.length, {
cell_type: 'code',
- id: crypto.randomUUID?.() ?? `cell-${Date.now()}`,
+ id: createBrowserUuid(),
metadata: {},
execution_count: null,
outputs: [],
diff --git a/src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx b/src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx
index a83df7ae6..fa472c63e 100644
--- a/src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx
+++ b/src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx
@@ -17,6 +17,7 @@ import { notifyProjectNotesSelectionChanged } from '@/lib/open-project-notes-tab
import { requestProjectNotesTabClose } from '@/lib/project-notes-close-request'
import { linkRuntimeProjectNote, showRuntimeProjectNote } from '@/runtime/runtime-notes-client'
import { useAppStore } from '@/store'
+import { createBrowserUuid } from '@/lib/browser-uuid'
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../shared/constants'
import type { TerminalTab } from '../../../../shared/types'
import { FloatingTerminalOrchestrationDialog } from './FloatingTerminalOrchestrationDialog'
@@ -237,7 +238,7 @@ export function FloatingTerminalPanel({
notifyProjectNotesSelectionChanged()
}
}
- const id = `floating-project-notes:${globalThis.crypto.randomUUID()}`
+ const id = `floating-project-notes:${createBrowserUuid()}`
setNotesTabs((current) => [...current, { id, label, noteId: noteId ?? null, isDirty: false }])
setActiveNotesTabId(id)
setActiveSurface('notes')
diff --git a/src/renderer/src/components/settings/CliSection.tsx b/src/renderer/src/components/settings/CliSection.tsx
index 496f2bab6..b091665a7 100644
--- a/src/renderer/src/components/settings/CliSection.tsx
+++ b/src/renderer/src/components/settings/CliSection.tsx
@@ -65,6 +65,7 @@ export function CliSection({ currentPlatform }: CliSectionProps): React.JSX.Elem
const isEnabled = status?.state === 'installed'
const isSupported = status?.supported ?? false
+ const isBrowserManaged = status?.unsupportedReason === 'launch_mode_unavailable'
const revealLabel = getRevealLabel(currentPlatform)
const canRevealCommandPath =
status?.commandPath != null && ['installed', 'stale', 'conflict'].includes(status.state)
@@ -145,21 +146,23 @@ export function CliSection({ currentPlatform }: CliSectionProps): React.JSX.Elem
-
+ {!isBrowserManaged ? (
+
+ ) : null}
@@ -182,7 +185,7 @@ export function CliSection({ currentPlatform }: CliSectionProps): React.JSX.Elem
) : null}
- {!loading && !isSupported && status?.detail ? (
+ {!loading && !isSupported && !isBrowserManaged && status?.detail ? (
{status.detail}
) : null}
@@ -201,44 +204,46 @@ export function CliSection({ currentPlatform }: CliSectionProps): React.JSX.Elem
) : null}
-
-
-
-
- Install skills so agents know how to use Orca and report status.
-
-
+ {!isBrowserManaged ? (
+
+
+
+
+ Install skills so agents know how to use Orca and report status.
+
+
-
-
-
CLI skill
-
-
- {ORCA_CLI_SKILL_INSTALL_COMMAND}
-
-
-
-
-
-
-
- Copy
-
-
-
+
+
+
CLI skill
+
+
+ {ORCA_CLI_SKILL_INSTALL_COMMAND}
+
+
+
+
+
+
+
+ Copy
+
+
+
+
-
+ ) : null}