Files
orca/src/relay
0b52d593b8 Detect agents in the serve user's package-manager bins; don't pin empty remote-detect results (#6029)
* Detect agents in the serve user's package-manager bins; don't pin empty remote-detect results

Two defects prevent the desktop client from detecting agents installed on a
remote `orca serve`:

D1 (src/relay/relay-command-env.ts): the relay probes agents with a login shell
(`/bin/sh -lc`), which sources ~/.profile but not the interactive ~/.bashrc that
real PTY sessions source. Per-user package-manager bins added to PATH only in
~/.bashrc are therefore invisible to detection. Resolve the serve user's
package-manager bins from $HOME (.local/bin, .npm-global/bin, .cargo/bin,
.bun/bin, go/bin, .deno/bin, .local/share/pnpm), honor npm_config_prefix, append
to the POSIX fallback set, dedupe against inherited PATH; win32 unchanged.

D2 (src/renderer/src/store/slices/detected-agents.ts): an empty detection result
([], truthy in JS) was pinned by the `if (existing)` short-circuit, so detection
never retried after the server env was fixed. Changed to `if (existing?.length)`;
in-flight dedup still prevents re-detect storms; failures stay uncached.

No new transport, no PowerShell/bash bridge. D1 and D2 are independent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Also patch the runtime (orca serve) detection path against the empty-pin bug

The D2 fix guarded only ensureRemoteDetectedAgents (the SSH path). The
desktop client's headline scenario — pairing to a remote `orca serve` —
routes through ensureRuntimeDetectedAgents (kind: 'runtime'), which had
the identical bug: an empty detection result ([], truthy in JS) was pinned
by the `if (existing)` short-circuit, so a later install / PATH fix was
never picked up without a reconnect.

Change the runtime guard to `if (existing?.length)`, mirroring the remote
path. In-flight dedup still collapses concurrent re-detects; failed
requests stay uncached. Add a runtime regression test proving detection
re-runs after an empty result (fails on the pre-fix guard).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Honor package-manager relocation env vars in relay PATH detection

Extend the existing npm_config_prefix precedence to cargo, bun, deno, go,
and pnpm so relocated installs (CARGO_HOME, BUN_INSTALL, DENO_INSTALL,
GOBIN/GOPATH, PNPM_HOME/XDG_DATA_HOME) are detected, falling back to the
$HOME defaults. Mirrors the remote-node probe's NVM_DIR handling (#6037).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Tighten remote agent detection retries

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: LesleyMurfin <260182349+LesleyMurfin@users.noreply.github.com>
Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
Co-authored-by: Orca <help@stably.ai>
2026-06-22 18:49:21 -07:00
..