Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion docs/site/content/docs/remote-servers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ orca-ide serve --port 6768 --pairing-address 100.64.1.20

Use only one host mode at a time. If the Orca desktop app is already sharing that computer, do not start a second `orca serve` process for the same setup.

`orca serve` runs on Orca's own Node server (orcad) by default. If orcad can't serve on this computer, it uses the desktop app's server instead and prints one line saying why. On a packaged macOS app it currently always uses the desktop app's server, so paired clients can still update it. To always use the desktop app's server, set `ORCA_SERVE_RUNTIME=electron`.
`orca serve` runs on Orca's own Node server (orcad) by default. If orcad can't serve on this computer, it uses the desktop app's server instead and prints one line saying why. On a packaged macOS app it uses the desktop app's server, so paired clients can still update it, unless you set `ORCA_SERVE_RUNTIME=orcad` (see [A Mac reached only over SSH](#a-mac-reached-only-over-ssh)). To always use the desktop app's server, set `ORCA_SERVE_RUNTIME=electron`.

### Limit terminal memory on a Linux server

Expand Down Expand Up @@ -210,6 +210,27 @@ orca-ide serve --pairing-address 100.64.1.20 --mobile-pairing

Keep the phone on the same tailnet, open Orca Mobile, choose **Pair**, and scan the terminal QR code or paste the printed link.

### Pair without restarting the server

`orca pair` asks the Orca already running on this machine for a new pairing, so you do not have to stop a service or restart `orca serve`. Run it on the server, as the user Orca runs as:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Security & Privacy · Quick win

Supported by static analysis

Script executed:

git diff 93589dc6f8631d59ce115a91fb6c3dc7cd2d33c9 94635fae69ffe0804346f7281f8768ee62e88a83 -- docs/site/content/docs/remote-servers.mdx; nl -ba docs/site/content/docs/remote-servers.mdx | sed -n '195,280p'; rg -n -F -e 'getOrCreatePendingDevice' -e 'rotate' -- src/cli/specs/pair.ts src/main/runtime/rpc/server/pairing

Repository: stablyai/orca

Length of output: 12516


Script executed:

rg -n -F -e 'rotatePendingDevice' -e 'getOrCreatePendingDevice' -e 'pairing.offer' -- src/main src/cli src/shared
nl -ba src/main/runtime/rpc/server/pairing/device-registry.ts | sed -n '1,230p'
nl -ba src/cli/specs/pair.ts | sed -n '1,100p'
rg -n -F -e 'grant-desktop-control' -e 'rotate:' -- src/cli/handlers/pair.ts src/main/runtime/rpc

Repository: stablyai/orca

Length of output: 19220


Script executed:

nl -ba src/cli/handlers/pair.ts | sed -n '1,155p'
nl -ba src/main/runtime/rpc/server/runtime-rpc-pairing.ts | sed -n '1,250p'
nl -ba src/main/runtime/rpc/server/runtime-rpc-mobile-pairing.ts | sed -n '1,175p'
nl -ba src/main/runtime/rpc/server/pairing/pairing-offer-expiry.ts | sed -n '1,190p'
rg -n -F -e 'createPairingOffer' -e 'createMobilePairingOffer' -- src/main/runtime/rpc src/main/orcad

Repository: stablyai/orca

Length of output: 36071


Script executed:

nl -ba src/main/runtime/pairing-offer-requests.ts | sed -n '1,240p'; rg -n -F -e 'PAIRING_CREATE_OFFER_METHOD' -e 'pairingOffers.create' -- src/main/runtime/rpc src/shared/remote-runtime/pairing

Repository: stablyai/orca

Length of output: 8862


Explain when to use --rotate.

Running the command again can reuse an unused link. If someone shared the link with the wrong person, run orca pair --rotate for a runtime link or orca pair --mobile --rotate for a mobile link. Rotation does not revoke clients that already paired.


```bash
orca pair --mobile --address 100.64.1.20 # QR code and link for Orca Mobile
orca pair --address 100.64.1.20 # access link for another Orca
# Linux
orca-ide pair --mobile --address 100.64.1.20
```

It works the same against the desktop app, a foreground `orca serve`, or `orca serve service install`. Only the machine's own user can run it; paired clients and phones cannot create pairings.

### A Mac reached only over SSH

On a packaged macOS app, `orca serve` uses the desktop app's server, which needs a desktop login: started from an SSH session with nobody logged in, it aborts at startup. To serve such a Mac, ask for Orca's Node server instead. It has no in-app updater, so update the app yourself (for example with `brew upgrade --cask stablyai/orca/orca`) and restart the server:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

git diff 93589dc6f8631d59ce115a91fb6c3dc7cd2d33c9 94635fae69ffe0804346f7281f8768ee62e88a83 -- docs/site/content/docs/remote-servers.mdx src/main/orcad/orcad-local-serve-selection.ts
printf '\n--- selector ---\n'
nl -ba src/main/orcad/orcad-local-serve-selection.ts
printf '\n--- documentation ---\n'
nl -ba docs/site/content/docs/remote-servers.mdx | sed -n '215,260p'
printf '\n--- SSH target references in orcad ---\n'
rg -n -i 'ssh.target|ssh host|ssh.host|ssh connection|sshconnection' src/main/orcad src/main/runtime --glob '*.ts' || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 40907


Script executed:

rg -n -F -e 'orcad has no SSH stack' -e 'SshHostNotServedError' -e 'sshHost' -- src/main/runtime/construction src/main/providers src/main/orcad src/orcad || test "$?" -eq 1
printf '\n--- composition parity SSH context ---\n'
rg -n -C 12 -F 'orcad has no SSH stack' src/main/runtime/construction/runtime-composition-parity.test.ts || test "$?" -eq 1
printf '\n--- composition files ---\n'
rg --files src/main/runtime/construction src/main/orcad | rg '(composition|server|provider)'
printf '\n--- SSH refusal implementation ---\n'
nl -ba src/main/providers/ssh-host-not-served-error.ts

Repository: stablyai/orca

Length of output: 3253


Script executed:

printf '%s\n' '--- dispatch ---'
nl -ba src/main/providers/execution-host-provider-dispatch.ts | sed -n '1,150p'
printf '%s\n' '--- production binding ---'
rg -n -F -e 'registerSshHandlers' -e 'ExecutionHostProviderDispatch' -e 'execution-host-provider-dispatch' -- src/main src/server src/cli 2>/dev/null || test "$?" -eq 1
printf '%s\n' '--- composition parity ownership ---'
nl -ba src/main/runtime/construction/runtime-composition-parity.test.ts | sed -n '1,165p'

Repository: stablyai/orca

Length of output: 18245


Script executed:

printf '%s\n' '--- SSH RPC handlers ---'
nl -ba src/main/runtime/rpc/methods/ssh/ssh.ts | sed -n '90,220p'
printf '%s\n' '--- SSH registry ---'
nl -ba src/main/ssh/targets/ssh-target-registry.ts | sed -n '1,200p'
printf '%s\n' '--- parity source roots ---'
rg -n -F -e "orcad:" -e 'headless-serve-ssh-registration' -e 'registerSshHandlers' -- src/main/runtime/construction/runtime-composition-parity.test.ts src/main/startup

Repository: stablyai/orca

Length of output: 10141


State the SSH-target limitation.

If the profile has SSH targets, the command bypasses the fallback to Electron. Orcad cannot serve those targets.

Suggested addition

 ORCA_SERVE_RUNTIME=orcad orca serve --pairing-address 100.64.1.20
 ```
 
+The Node server cannot serve SSH targets in this profile. Workspaces on those targets are unavailable.
+


```bash
ORCA_SERVE_RUNTIME=orcad orca serve --pairing-address 100.64.1.20
```

## Desktop app or `orca serve`?

| | Desktop app on the server | `orca serve` |
Expand Down
5 changes: 5 additions & 0 deletions src/cli/handler-group-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,10 @@ export const HANDLER_GROUPS: readonly HandlerGroup[] = [
name: 'ports',
keys: ['ports'],
load: async () => (await import('./handlers/ports.js')).PORTS_HANDLERS
},
{
name: 'pair',
keys: ['pair'],
load: async () => (await import('./handlers/pair.js')).PAIR_HANDLERS
}
]
65 changes: 65 additions & 0 deletions src/cli/handlers/pair.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import type { CommandHandler } from '../dispatch'
import { getOptionalStringFlag } from '../flags'
import { printResult } from '../format'
import { RuntimeClientError } from '../runtime/types'
import {
PAIRING_CREATE_OFFER_METHOD,
type PairingCreateOfferParams,
type PairingCreateOfferResult
} from '../../shared/pairing-create-offer-contract'

export function formatPairingOffer(offer: PairingCreateOfferResult): string {
if (!offer.available) {
return `Pairing is unavailable (${offer.reason}). ${offer.guidance}`
}
const lines: string[] = []
if (offer.scope === 'mobile') {
if (offer.qr) {
lines.push(offer.qr.trimEnd(), '')
}
lines.push('Scan with Orca Mobile (Pair), or paste this link:', offer.pairingUrl)
} else {
lines.push(
'Paste this link in Orca: Settings → Remote Orca Servers → Add Server.',
offer.pairingUrl
)
if (offer.webClientUrl) {
lines.push('', 'Or open it in a browser:', offer.webClientUrl)
}
}
if (offer.endpoint) {
lines.push('', `The client will connect to ${offer.endpoint}.`)
}
lines.push('Treat the link like a password: it grants access to this Orca.')
return lines.join('\n')
}

export const PAIR_HANDLERS: Record<string, CommandHandler> = {
pair: async ({ client, flags, json }) => {
const mobile = flags.get('mobile') === true
if (flags.get('relay') === true && !mobile) {
throw new RuntimeClientError('invalid_argument', '--relay applies only with --mobile')
}
if (flags.get('grant-desktop-control') === true && mobile) {
throw new RuntimeClientError(
'invalid_argument',
'--grant-desktop-control applies only to an access link, not --mobile'
)
}
const params: PairingCreateOfferParams = {
scope: mobile ? 'mobile' : 'runtime',
address: getOptionalStringFlag(flags, 'address'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

git diff be3b87f3ac6fd767e11a1cf84f249c591166f7af ee863b417e4a6686ac1810512c57665bd439b833 -- src/cli/handlers/pair.ts src/cli/specs/pair.ts
printf '\n--- CLI sources ---\n'
for f in src/cli/handlers/pair.ts src/cli/flags.ts src/cli/args.ts src/cli/specs/pair.ts; do
  if test -f "$f"; then echo "--- $f"; nl -ba "$f" | sed -n '1,240p'; fi
done
printf '\n--- pairing symbols ---\n'
rg -n -F -e 'requestRuntimePairingOffer' -e 'pairingAddress' -e 'resolveAdvertisedPairingEndpoint' -e 'pairing.createOffer' -- src || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 31848


Script executed:

for f in src/main/runtime/pairing-offer-requests.ts src/shared/remote-runtime/pairing/pairing-create-offer-contract.ts src/main/runtime/rpc/server/runtime-rpc-pairing.ts src/main/runtime/pairing-endpoint.ts src/main/runtime/pairing-offer-owner-cli.test.ts; do
  echo "--- $f"; nl -ba "$f" | sed -n '1,260p'
done
printf '\n--- offer context bindings ---\n'
rg -n -F -e 'createPairingOffer' -e 'pairingOffers' -e 'createOffer:' -- src/main/runtime src/main/orcad src/main/server src/main/ipc || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 41396


Script executed:

printf '%s\n' '--- bindings ---'
rg -n -F -e 'ownerPairingOffers' -e 'createOwnerPairingOffer' -- src/main/runtime/rpc src/main/runtime/pairing-offer-requests.ts || test "$?" -eq 1
for f in src/main/runtime/rpc/methods/pairing/pairing.ts src/main/runtime/rpc/server/runtime-rpc-request-admission.ts src/main/runtime/rpc/server/runtime-rpc-network-exposure.ts src/main/runtime/pairing-network-interfaces.ts; do
  echo "--- $f"; nl -ba "$f" | sed -n '1,240p'
done

Repository: stablyai/orca

Length of output: 23835


Reject an explicitly empty pairing address.

--address= is treated as an omitted address. If a default address is available, a runtime offer can widen the listener instead of rejecting the invalid input.

Suggested fix

-import { getOptionalStringFlag } from '../flags'
+import { getPresentStringFlag } from '../flags'
-      address: getOptionalStringFlag(flags, 'address'),
+      address: getPresentStringFlag(flags, 'address'),

relay: flags.get('relay') === true,
grantDesktopControl: flags.get('grant-desktop-control') === true,
rotate: flags.get('rotate') === true
}
const response = await client.call<PairingCreateOfferResult>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

git diff be3b87f3ac6fd767e11a1cf84f249c591166f7af ee863b417e4a6686ac1810512c57665bd439b833 -- src/cli/handlers/pair.ts src/cli/remote-selection-scope.ts src/cli/index.ts src/cli/specs/pair.ts
printf '\n--- remote selection ---\n'
nl -ba src/cli/remote-selection-scope.ts
printf '\n--- pair handler ---\n'
nl -ba src/cli/handlers/pair.ts
printf '\n--- selection and call references ---\n'
rg -n -F -e 'ignoresRemoteSelection' -e 'ORCA_ENVIRONMENT' -e 'ORCA_PAIRING_CODE' -e 'pairing.createOffer' -e 'pairingOffers' -- src/cli src/main/runtime src/shared | head -200

Repository: stablyai/orca

Length of output: 17537


Script executed:

printf '%s\n' '--- CLI index ---'
nl -ba src/cli/index.ts | sed -n '65,195p'
printf '%s\n' '--- client ---'
nl -ba src/cli/runtime/client.ts | sed -n '1,230p'
printf '%s\n' '--- pairing RPC ---'
nl -ba src/main/runtime/rpc/methods/pairing/pairing.ts
printf '%s\n' '--- admission ---'
nl -ba src/main/runtime/rpc/server/runtime-rpc-request-admission.ts | sed -n '1,140p'
printf '%s\n' '--- caller scope construction ---'
rg -n -F -e "kind: 'owner'" -e "kind: 'runtime'" -e 'callerScope:' -- src/main/runtime/rpc/server src/main/runtime/rpc | head -120
printf '%s\n' '--- selector tests ---'
nl -ba src/cli/index.test.ts | sed -n '255,325p'

Repository: stablyai/orca

Length of output: 33491


Script executed:

printf '%s\n' '--- remote connection resolution ---'
nl -ba src/cli/runtime/runtime-remote-pairing.ts | sed -n '1,220p'
printf '%s\n' '--- caller scope and permission ---'
nl -ba src/main/runtime/rpc/rpc-caller-scope.ts
rg -n -F -e 'runtime-paired' -e 'isPermissionAllowed' -e 'pairing-admin' -- src/main/runtime/rpc/server src/main/runtime/rpc/dispatcher.ts src/main/runtime/rpc/rpc-caller-scope.ts src/main/runtime/rpc
printf '%s\n' '--- owner pairing RPC tests ---'
nl -ba src/main/runtime/pairing-offer-owner-cli.test.ts | sed -n '1,110p'

Repository: stablyai/orca

Length of output: 11743


Keep ambient remote selection from redirecting orca pair.

If ORCA_ENVIRONMENT or ORCA_PAIRING_CODE selects a paired server, pair can send pairing.createOffer to that server. The paired connection lacks pairing-admin, so the request fails instead of creating a local offer. Classify pair as local-only and add a routing test.

PAIRING_CREATE_OFFER_METHOD,
params
)
printResult(response, json, formatPairingOffer)
if (!response.result.available) {
process.exitCode = 1
}
}
}
16 changes: 16 additions & 0 deletions src/cli/runtime/serve-orcad-launch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ describe('orca serve asking the app which host to run', () => {
expect(run).not.toHaveBeenCalled()
})

it('asks the app on packaged macOS when orcad is requested explicitly', async () => {
const selection = {
kind: 'orcad' as const,
runtime: '/rt/node',
entry: '/slot/orcad.js',
version: '1'
}
const run = answering(formatServeRuntimeSelection(selection))
expect(
await resolveLocalServeRuntime(
{ ...options, usesMacUpdateHandoff: true, env: { ORCA_SERVE_RUNTIME: 'orcad' } },
run
)
).toEqual(selection)
})

it('selects Electron with a reason when the app gives no answer', async () => {
expect(await resolveLocalServeRuntime(options, answering('', 1))).toEqual({
kind: 'electron',
Expand Down
7 changes: 5 additions & 2 deletions src/cli/runtime/serve-orcad-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ProcessSpec } from '@orca/process-host/process-spec'
import {
ORCAD_LOCAL_SERVE_SELECTION_ENTRY,
ORCAD_LOCAL_SERVE_SELECTION_FLAGS as FLAGS,
SERVE_RUNTIME_ENV,
parseServeRuntimeSelection,
type ServeRuntimeSelection
} from '../../shared/orcad-local-serve-selection'
Expand All @@ -24,11 +25,13 @@ export async function resolveLocalServeRuntime(
appRoot: string
userDataPath: string
usesMacUpdateHandoff: boolean
env?: NodeJS.ProcessEnv
},
run: typeof runProcess = runProcess
): Promise<ServeRuntimeSelection> {
// orcad has no updater; keep Electron for packaged macOS update handoffs.
if (options.usesMacUpdateHandoff) {
// orcad has no updater; keep Electron for packaged macOS update handoffs unless orcad is asked for,
// e.g. over SSH with no desktop login, where Electron cannot start.
if (options.usesMacUpdateHandoff && (options.env ?? process.env)[SERVE_RUNTIME_ENV] !== 'orcad') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

git diff be3b87f3ac6fd767e11a1cf84f249c591166f7af ee863b417e4a6686ac1810512c57665bd439b833 -- src/cli/runtime/serve-orcad-launch.ts
nl -ba src/cli/runtime/serve-orcad-launch.ts | sed -n '1,220p'
nl -ba src/main/orcad/orcad-local-serve-selection.ts | sed -n '1,260p'
rg -n -F -e 'profileSshReason' -e 'resolveLocalServeRuntime(' -e 'SERVE_RUNTIME_ENV' -- src/cli src/main/orcad src/main |  sed -n '1,200p'

Repository: stablyai/orca

Length of output: 16459


Script executed:

git diff be3b87f3ac6fd767e11a1cf84f249c591166f7af ee863b417e4a6686ac1810512c57665bd439b833 -- src/cli/runtime/serve-orcad-launch.ts
nl -ba src/cli/runtime/serve-orcad-launch.ts | sed -n '1,220p'
nl -ba src/main/orcad/orcad-local-serve-selection.ts | sed -n '1,260p'
rg -n -F -e 'profileSshReason' -e 'resolveLocalServeRuntime(' -e 'SERVE_RUNTIME_ENV' -- src/cli src/main/orcad src/main | sed -n '1,200p'

Repository: stablyai/orca

Length of output: 16459


Script executed:

nl -ba src/cli/runtime/launch.ts | sed -n '135,225p'
nl -ba src/main/orcad/serve-profile-ssh-targets.ts
rg -n -i -e 'ORCA_SERVE_RUNTIME' -e 'orcad.{0,80}ssh' -e 'ssh.{0,80}orcad' -- docs src/main/orcad src/cli README.md | sed -n '1,220p'
rg -n -F -e 'profileHasSshTargets' -e 'cannot serve yet' -- src/main/orcad
rg -n -i -e 'ssh.*(unsupported|not supported|unavailable)' -e '(unsupported|not supported|unavailable).*ssh' -- src/orcad src/main/orcad src/server 2>/dev/null | sed -n '1,140p'

Repository: stablyai/orca

Length of output: 9424


Script executed:

nl -ba src/main/orcad/orcad-host-unavailable.ts
rg -n -F -e 'ORCAD_TUNNEL_UNAVAILABLE_REASON' -e 'orcad-host-unavailable' -e 'ssh_tunnel_unavailable' -- src/main src/renderer src/shared
rg -n -i -e 'ssh targets' -e 'ssh target' -- src/main/orcad src/main/runtime | sed -n '1,180p'
nl -ba src/cli/specs/serve.ts | sed -n '1,65p'
nl -ba src/main/orcad/orcad-local-serve-selection-entry.ts | sed -n '1,180p'
rg -n -F -e 'explicit orcad' -e 'SSH targets' -- src/main/orcad/*.test.ts | sed -n '1,140p'

Repository: stablyai/orca

Length of output: 24470


Script executed:

nl -ba src/main/runtime/construction/runtime-composition-parity.test.ts | sed -n '1,95p'
nl -ba src/main/runtime/workspaces/catalog/runtime-visible-catalog.ts | sed -n '1,200p'
rg -n -F -e 'no SSH stack' -e 'SSH is unavailable' -e 'SSH targets are not supported' -e 'SSH target management' -- src/main src/orcad 2>/dev/null | sed -n '1,150p'
rg -n -i -e 'ssh.*(not supported|unavailable|not connected)' -e '(not supported|unavailable).*ssh' -- src/main/runtime/construction src/main/runtime/rpc/methods/ssh src/main/orcad | sed -n '1,160p'

Repository: stablyai/orca

Length of output: 12071


Script executed:

nl -ba src/main/ssh/targets/ssh-target-registry.ts | sed -n '1,220p'
rg -n -F -e 'createUnavailableSshTarget' -e 'SshTargetRegistry' -e 'SSH_TARGET_MANAGEMENT_UNAVAILABLE' -- src/main/ssh/targets src/main/runtime src/main/orcad src/orcad 2>/dev/null | sed -n '1,160p'
rg -n -F -e 'sshTargetRegistry' -e 'sshTargets:' -- src/main/orcad src/main/runtime/construction src/orcad 2>/dev/null | sed -n '1,140p'

Repository: stablyai/orca

Length of output: 5944


Warn when an orcad profile has SSH targets.

An explicit orcad request skips the SSH profile check. On macOS, users can follow the headless serve guidance and lose access to existing SSH worktrees without a startup warning. Warn about the limitation while preserving the explicit override.


Minor · Stability & Availability · Quick win

Supported by static analysis

Script executed:

git diff be3b87f3ac6fd767e11a1cf84f249c591166f7af ee863b417e4a6686ac1810512c57665bd439b833 -- src/cli/runtime/serve-orcad-launch.ts
nl -ba src/cli/runtime/serve-orcad-launch.ts
rg -n -F -e 'resumeInterruptedServeUpdate' -e 'resolveLocalServeRuntime' -e 'install-requested' -e 'serveWithElectron' -- src/cli src/main

Repository: stablyai/orca

Length of output: 11791


Script executed:

nl -ba src/cli/runtime/launch.ts | sed -n '110,300p'
nl -ba src/cli/runtime/serve-update-supervisor.ts | sed -n '1,130p;280,380p'
nl -ba src/cli/runtime/serve-supervisor-policy.ts
nl -ba src/main/updater/serve-update-handoff.ts
rg -n -F -e 'readServeUpdateHandoff' -e 'waitForServeUpdate' -e 'serve-update-handoff' -e 'install-requested' -- src/cli/runtime src/shared src/main/updater

Repository: stablyai/orca

Length of output: 26764


Script executed:

rg -n -F -e 'ORCAD_LOCAL_SERVE_SELECTION_ENTRY' -e 'SERVE_RUNTIME_ORCAD' -e 'SERVE_RUNTIME_ENV' -- src/main src/shared src/cli/runtime
nl -ba src/cli/runtime/serve-update-supervisor.ts | sed -n '130,264p'
nl -ba src/cli/runtime/mac-app-update-bundle.ts
nl -ba src/main/updater/lifecycle/updater-install-execution.ts | sed -n '1,220p'
rg -n -F -e 'function superviseServeService' -e 'function openServeBundlePark' -e 'serve-update-handoff' -- src/cli/runtime/serve-supervisor* src/cli/runtime/serve*park*

Repository: stablyai/orca

Length of output: 21798


Script executed:

nl -ba src/main/orcad/orcad-local-serve-selection.ts
nl -ba src/main/orcad/orcad-local-serve-selection-entry.ts
nl -ba src/shared/orcad-local-serve-selection.ts
rg -n -F -e 'superviseServeService' -e 'openServeBundlePark' -- src/cli/runtime

Repository: stablyai/orca

Length of output: 13808


Preserve interrupted update recovery

If a macOS update is interrupted in install-requested, an explicit ORCA_SERVE_RUNTIME=orcad can start Orcad without waiting for the bundle update. The handoff can remain pending without a completion or failure record.

Handle the pending handoff before selecting Orcad, or refuse startup with a recovery message.

return {
kind: 'electron',
reason:
Expand Down
4 changes: 3 additions & 1 deletion src/cli/specs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { PROFILE_STATE_COMMAND_SPECS } from './profile-state'
import { REFERENCE_COMMAND_SPECS } from './reference'
import { PORTS_COMMAND_SPECS } from './ports'
import { PLUGIN_AUTHORING_COMMAND_SPECS, PLUGIN_RUNTIME_COMMAND_SPECS } from './plugin'
import { PAIR_COMMAND_SPECS } from './pair'

export const COMMAND_SPECS: CommandSpec[] = [
...CORE_COMMAND_SPECS,
Expand Down Expand Up @@ -59,5 +60,6 @@ export const COMMAND_SPECS: CommandSpec[] = [
...PROFILE_STATE_COMMAND_SPECS,
...PORTS_COMMAND_SPECS,
...PLUGIN_AUTHORING_COMMAND_SPECS,
...PLUGIN_RUNTIME_COMMAND_SPECS
...PLUGIN_RUNTIME_COMMAND_SPECS,
...PAIR_COMMAND_SPECS
]
36 changes: 36 additions & 0 deletions src/cli/specs/pair.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { CommandSpec } from '../args'
import { GLOBAL_FLAGS } from '../args'

export const PAIR_COMMAND_SPECS: CommandSpec[] = [
{
path: ['pair'],
summary:
'Pair a phone or another Orca with the Orca already running here, without restarting it',
usage:
'orca pair [--mobile [--relay]] [--address <host>] [--grant-desktop-control] [--rotate] [--json]',
allowedFlags: [
...GLOBAL_FLAGS,
'mobile',
'relay',
'address',
'grant-desktop-control',
'rotate'
],
notes: [
'Asks the Orca running for this profile (desktop app, `orca serve`, or its service) for a pairing offer. Nothing restarts and existing clients stay connected.',
'Without --mobile it prints an access link for another Orca (Settings → Remote Orca Servers → Add Server). --mobile prints a QR code and link for Orca Mobile.',
'--address is the host or IP the client should dial, such as a Tailscale address. Without it Orca picks this machine’s default LAN address.',
'The first network pairing makes a loopback-only Orca listen on every interface, as pairing from the desktop app does.',
'Mobile pairing is LAN-only (same network or tailnet) unless --relay is given; Relay needs a signed-in desktop app.',
'An unused offer is reused until --rotate replaces it. Clients that already paired keep their access.',
"--grant-desktop-control lets the paired Orca drive this machine's desktop (orca computer). It applies only to an access link, not to a phone.",
'Only this machine’s own user can run it: paired clients and phones cannot create pairing offers.'
],
examples: [
'orca pair --mobile',
'orca pair --mobile --address 100.64.1.20',
'orca pair --address 100.64.1.20',
'orca pair --mobile --rotate --json'
]
}
]
5 changes: 3 additions & 2 deletions src/cli/specs/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const SERVE_COMMAND_SPECS: CommandSpec[] = [
'With --port, serve exits with an error when that port is already in use. Without it, serve uses 6768 and moves to another port when 6768 is taken.',
'--pairing-address changes only the client-advertised address; use a reachable LAN, Tailscale, SSH-forward, or reverse-proxy endpoint.',
'Use --recipe-json with --project-root from VM recipes to print the recipe result JSON and leave the server running.',
'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. To pair later without restarting, run `orca pair`.',
'On a packaged macOS app serve runs Electron, which needs a desktop login; over SSH with nobody logged in, set ORCA_SERVE_RUNTIME=orcad to run the Node server instead (it has no in-app updater).',
"A paired client cannot drive this machine's desktop (orca computer) unless the offer was created with --grant-desktop-control.",
'When the web client bundle is available, the server also prints a browser URL with the pairing data embedded.',
'Exits with code 3, without starting anything, when another Orca already serves this profile or cannot be shown to have stopped.',
Expand Down Expand Up @@ -66,7 +67,7 @@ export const SERVE_COMMAND_SPECS: CommandSpec[] = [
allowedFlags: [...LOCAL_COMMAND_FLAGS, 'port', 'pairing-address', 'command', 'dry-run'],
notes: [
'macOS writes a LaunchAgent; Linux writes a systemd user unit. Both run `orca serve --supervise --no-pairing` for this profile, so the server restarts with growing delays and gives up after repeated failures instead of looping.',
'The service never prints a pairing link to its log. Pair clients from the desktop app, or with `orca serve` in a terminal while the service is stopped.',
'The service never prints a pairing link to its log. Pair clients with `orca pair` while it runs, or from the desktop app.',
'On Linux the service stops at logout unless lingering is on (`loginctl enable-linger`); install reports it.',
"Reinstalling replaces the unit and clears a previous give-up. --command defaults to the installed Orca app's `orca` command on PATH (`orca-ide` on Linux) and must not be a launcher tied to one Orca version. --dry-run prints the unit without installing it.",
"Needs the Orca app installed on this machine. The `orca` command in an Orca terminal on an SSH host belongs to that connection's server and cannot install a service.",
Expand Down
101 changes: 23 additions & 78 deletions src/main/ipc/mobile.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { app, ipcMain, shell, type IpcMainInvokeEvent } from 'electron'
import type { RuntimeAccessGrant } from '../../shared/runtime-access-grants'
import type { MobilePairingConnectionMode } from '../../shared/mobile-pairing-connection-mode'
import { classifyRemotePairingHostname } from '../../shared/remote-pairing-address'
import type { RuntimePairingReach } from '../../shared/runtime-pairing-reach'
import type { DeviceEntry } from '../runtime/device-registry'
import { NETWORK_EXPOSURE_FAILED_GUIDANCE } from '../runtime/network-exposure-guidance'
import {
getDefaultPairingAddress,
requestMobilePairingOffer,
requestRuntimePairingOffer
} from '../runtime/pairing-offer-requests'
import {
getPairingNetworkInterfaces,
type DefaultRouteInterfaceLookup,
type NetworkInterface
} from '../runtime/pairing-network-interfaces'
import { resolveAdvertisedPairingHostname } from '../runtime/pairing-endpoint'
import type { OrcaRuntimeRpcServer } from '../runtime/runtime-rpc'
import type { MobileRelayStatusDetail } from '../../shared/mobile-relay-status'
import { encodeMobilePairingQr, type MobilePairingQrResult } from '../runtime/mobile-pairing-qr'
Expand All @@ -23,15 +23,6 @@ import {
type WindowsMobileFirewallEnvironment
} from '../runtime/windows-mobile-firewall'

// Only explicit this-computer intent plus a loopback address avoids widening; custom tunnel endpoints still need remote reach.
function servesThisComputerOnly(reach: RuntimePairingReach | undefined, address: string): boolean {
if (reach !== 'this-computer') {
return false
}
const hostname = resolveAdvertisedPairingHostname(address)
return hostname !== null && classifyRemotePairingHostname(hostname) === 'loopback'
}

function toRuntimeAccessGrant(device: DeviceEntry): RuntimeAccessGrant {
return {
deviceId: device.deviceId,
Expand Down Expand Up @@ -82,30 +73,15 @@ export function registerMobileHandlers(
rotate?: boolean
}
) => {
// Explicit interfaces support overlay networks unreachable through the default LAN candidate.
const ip =
args?.address ??
(await getDefaultPairingAddress(
rpcServer.getNetworkExposureBindHost(),
getDefaultRouteInterfaceNames
))
// Relay works without a direct candidate; LAN-only must refuse when none is usable.
if (!ip && args?.connectionMode === 'local-only') {
return {
available: false as const,
reason: 'invalid_advertised_endpoint',
guidance:
'No reachable network address is available for pairing. Connect to Wi‑Fi or Tailscale, or pick an address manually.'
}
}

// Reuse never-scanned tokens until explicit rotation; authenticated entries remain independent.
const offer = await rpcServer.createMobilePairingOffer({
address: ip,
connectionMode: args?.connectionMode,
rotate: args?.rotate,
name: `Mobile ${new Date().toLocaleDateString()}`
})
const offer = await requestMobilePairingOffer(
rpcServer,
{
address: args?.address,
connectionMode: args?.connectionMode,
rotate: args?.rotate
},
getDefaultRouteInterfaceNames
)
if (!offer.available) {
// Preserve relay mint failures instead of silently presenting a LAN offer under the Relay label.
return {
Expand All @@ -124,8 +100,7 @@ export function registerMobileHandlers(
qrSize: qr.ok ? qr.qrSize : null,
...(!qr.ok ? { qrError: qr.reason } : {}),
pairingUrl: offer.pairingUrl,
// Unadvertised loopback fallback points at the scanning device; omit it from UI endpoints.
endpoint: ip ? offer.endpoint : null,
endpoint: offer.endpoint,
deviceId: offer.deviceId,
connectionMode: offer.connectionMode
}
Expand All @@ -135,46 +110,16 @@ export function registerMobileHandlers(
ipcMain.handle(
'mobile:getRuntimePairingUrl',
async (_event, args?: { address?: string; rotate?: boolean; reach?: RuntimePairingReach }) => {
const ip =
args?.address ??
(await getDefaultPairingAddress(
rpcServer.getNetworkExposureBindHost(),
getDefaultRouteInterfaceNames
))
if (!ip) {
return { available: false as const }
}

// Widen before advertising remote reach; this-computer intent must not trigger the irreversible widening (STA-2370).
const thisComputerOnly = servesThisComputerOnly(args?.reach, ip)
if (!thisComputerOnly) {
try {
await rpcServer.ensureNetworkExposure()
} catch (error) {
console.error(
'[mobile] Network exposure failed while creating a runtime pairing offer:',
error
)
// Preserve actionable widening failure guidance rather than generic unavailability.
return {
available: false as const,
reason: 'network_exposure_failed' as const,
guidance: NETWORK_EXPOSURE_FAILED_GUIDANCE
}
}
}

// Web/desktop runtime clients need full access instead of the phone allow-list.
const offer = rpcServer.createPairingOffer({
address: ip,
rotate: args?.rotate,
name: `Runtime ${new Date().toLocaleDateString()}`,
scope: 'runtime',
// Persist local reach so local authentication cannot expose the next launch to the LAN.
reach: thisComputerOnly ? 'this-computer' : 'network'
})
const offer = await requestRuntimePairingOffer(
rpcServer,
{ address: args?.address, rotate: args?.rotate, reach: args?.reach },
getDefaultRouteInterfaceNames
)
if (!offer.available) {
return { available: false as const }
// Preserve actionable widening failure guidance rather than generic unavailability.
return offer.reason === 'network_exposure_failed'
? { available: false as const, reason: offer.reason, guidance: offer.guidance }
: { available: false as const }
}

return {
Expand Down
Loading