Repository navigation
feat(agents): launch profiles — run one agent under several credential homes or providers at once - #18674
feat(agents): launch profiles — run one agent under several credential homes or providers at once#18674ColorC wants to merge 12 commits into
Conversation
…credential homes at once A launch profile pins one launch of a CLI agent to a credential home and/or process-local overrides, selected per launch instead of through the global managed-account slot. Two panes on the same host can now run Codex (or Claude Code) under different accounts, or against different model providers, side by side. - shared: `agent-launch-profile` contract with two built-ins (`codex-secondary-home`, `claude-secondary-home`) and user-defined `settings.agentLaunchProfiles` (args/env, same shell tokenization as `agentDefaultArgs`); ids are slugs, built-ins cannot be shadowed. - host: `terminal.createAgentSession`, `session.tabs.createTerminal` and `worktree.create` accept an optional `launchProfileId` / `startupLaunchProfileId`; the host resolves it against its own catalog and raises `agent_session_launch_profile_unknown`, `_agent_mismatch` or `_remote_unsupported`. Capability `agent-session.launch-profile.v1`. - execution host: a secondary-home launch carries only a marker (`ORCA_CODEX_HOME_PROFILE` / `ORCA_CLAUDE_CONFIG_DIR_PROFILE`); the daemon spawn turns it into `~/.codex-2` / `~/.claude-2` (WSL: the distro home), overridable with `ORCA_CODEX_SECONDARY_HOME` / `ORCA_CLAUDE_SECONDARY_HOME`. Such launches skip managed Codex home selection, the managed-auth wait and the hook preflight, skip managed Claude credential materialization and auth-env stripping, and are recorded in `codex-pane-accounts.json` as `custom-home` with `launchProfileId` so stale-account prompts never name them. - desktop: the tab-bar agent row becomes a submenu when profiles exist. - paired web: `launchProfileId` rides the structured create; the legacy env-only create is refused on hosts without the capability instead of launching unvalidated. - cli: `orca worktree create --agent <id> --launch-profile <id>`. - e2e: `agent-launch-profile-conformance.spec.ts` asserts the contract over RPC only, so the same expectations hold for any client; the headless host helper gains a `settings` seed. Refs stablyai#2314, stablyai#8770. Related: stablyai#13270-stablyai#13275, stablyai#10394. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…e-read parseRegistry whitelists fields when codex-pane-accounts.json is read back, so the launchProfileId written for a secondary-home launch was dropped on the next restart and the pane could be misattributed again. Validate and carry it; the record validators move to codex-pane-account-record-validation.ts to stay within the file budget. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
Stamp `launchProfileId` onto agent status rows so desktop and paired clients can tell which profile (secondary home, custom provider) a pane is running under. The profile is baked into the PTY env at spawn and the daemon keeps shells alive across restarts, so a small per-pty registry (`agent-launch-profile-panes.json`, mirroring the Codex pane account registry) records it at spawn commit, drops it on real teardown, and both the hook-status listener and the mobile projections read it back by pty id. New optional field only; no wire opcode changes. Also adds an opt-in @headful e2e that captures the quick-launch submenu screenshots. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
… lane too Only the daemon spawn turned a secondary-home marker into a real directory; a fresh spawn routed to the in-process LocalPtyProvider kept the marker and launched on the default home. Resolve it after the host env is built (so it wins over an injected managed home) and export a WSL-resolved home as a Linux path through WSLENV, mirroring the daemon lane. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
Re-detect agents after the golden stub is configured (detection is cached per context before the override exists), force the English catalog, close the root menu fully between captures, and crop to the menu. A baseline mode captures the same menu on the base branch, which has no launch-profile settings. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…rrows isAgentLaunchProfileId is a `value is string` guard, so the rejected branch sees `never` and trips restrict-template-expressions in the type-aware gate. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
The tab strip badges a terminal tab with the launch profile the host stamps on its agent status (built-ins shortened to their distinguishing half, custom ids as-is). The new-tab picker lists each agent's profiles beneath its default launch, but only when the host advertises agent-session.launch-profile.v1, so an older host never silently starts the default launch under a profile's name. A Codex launch with a profile skips the structured chat path, which cannot carry one, and goes through session.tabs.createTerminal. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
The SSH lane ships its env to the relay as a literal map, so nothing there can expand a home. The session already probes the remote home and platform when it connects; the spawn env builder now joins the secondary home from that probe in the remote's path flavor and drops the marker. When the probe is missing the launch fails with agent_session_launch_profile_remote_unsupported instead of silently starting on the remote default home, and the request resolver no longer refuses SSH targets up front. Also tracks docs/reference/agent-launch-profiles.md: docs/** is ignored unless allow-listed, so the reference never made it into the earlier commits. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…poser A Launch profile select sits under the agent picker and only renders when the chosen agent has profiles. The selection is validated during render against the current catalog and reset when the agent changes. The composer already builds the startup command and env itself, so the profile is layered in through the shared launch helper and rides to the host in startupEnv; a stale id that races a settings change falls back to the default launch. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…roof spec Also dismisses the recoverable-error dialog before every interaction and retries opening the composer around it, since the dialog can land between steps on the e2e profile. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
Reviewers flagged the extra submenu and select as UI weight most users never need. A new agentLaunchProfilesEnabled setting (Settings > Agents, off by default, searchable) now decides whether the tab bar, the New Workspace composer and the Orca Mobile picker offer profiles at all; the RPC fields and the CLI flag keep accepting a profile id regardless. The client settings schema is strict and never listed agentLaunchProfiles, so paired clients could not save profiles over RPC; both keys are registered now. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…roof spec The sidebar entry point differs between Orca and downstream builds; the new-workspace-composer modal action is the contract both share. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
|
Update: the official contribution is now stablyai/orca#25066, covering named Claude/Codex profiles with managed-account and existing-home bindings. The earlier ColorC/orca-lite#1 draft is closed and superseded. The official PR documents synthetic integration evidence, current-app screenshots and native-auth limits. The original branch-specific reproduction below remains historical context. I tested an existing-home case while investigating #2284. At head Reproduction added to the existing
The first assertion fails: the PTY receives Validation: unchanged file 27 passed; with this regression 27 passed, 1 failed, in an isolated Linux container with mocked PTY/auth preparation and synthetic paths. No real credentials or native OAuth were exercised. This is AI-assisted testing, not a claim of live-account validation. Would it fit this PR to treat a validated custom Claude home as an explicit external-home launch, alongside built-in home profiles, and share that decision across desktop/runtime preparation? I can contribute the focused regression and fix if this remains the intended landing branch; I'm coordinating against the overlapping profile/auth work in #2284 rather than introducing another catalog. Update: the runtime-controller path reproduces the same failure. I opened a focused draft follow-up against this feature branch: ColorC/orca-lite#1. It records explicit profile-home provenance during composition, so a home inherited from |
ELI5
Today Orca can hold several Codex or Claude accounts, but only one of them is "the" account at a time, and API-key or proxy providers have no seat at all. This PR adds launch profiles: when you start an agent you can say "run this one under my second Codex home" or "run this one against my work proxy", per launch. Two panes on the same host can then run the same CLI under different accounts or providers side by side. Launching without a profile is unchanged.
What Changed
src/shared/agent-launch-profile/: two built-in secondary-home profiles (codex-secondary-home→CODEX_HOME=~/.codex-2,claude-secondary-home→CLAUDE_CONFIG_DIR=~/.claude-2, both overridable withORCA_*_SECONDARY_HOME) plus user-definedsettings.agentLaunchProfilesrows (args+env, tokenized for the launch shell exactly likeagentDefaultArgs). Ids are slugs; built-ins cannot be shadowed.terminal.createAgentSession,session.tabs.createTerminalandworktree.createtake an optionallaunchProfileId/startupLaunchProfileId. The host resolves it against its own catalog and raisesagent_session_launch_profile_unknownor_agent_mismatch;_remote_unsupportedis raised at SSH spawn only when the session never learned the remote home. New capabilityagent-session.launch-profile.v1.ORCA_CODEX_HOME_PROFILE/ORCA_CLAUDE_CONFIG_DIR_PROFILE); the daemon spawn turns it into the real directory (WSL: the distro home) and consumes the marker. Such launches skip managed Codex home selection, the managed-auth wait and the hook preflight; skip managed Claude credential materialization and auth-env stripping; and are recorded incodex-pane-accounts.jsonascustom-homewithlaunchProfileId, so stale-account prompts never name them.Default launch+ one item per profile) when profiles exist for that agent. The New Workspace composer gets aLaunch profileselect under the agent picker, shown only when the chosen agent has profiles; the profile is layered into the startup command/env the renderer already sends, soworktree.createneeds no new field on that path.launchProfileIdrides the structured create; the legacy env-only create is refused on hosts that lack the capability instead of launching unvalidated.orca worktree create --agent codex --launch-profile codex-secondary-home.AgentStatusEntry.launchProfileId(optional) is stamped by main from a small per-pty registry (agent-launch-profile-panes.json, mirroring the Codex pane account registry) so desktop and paired clients can show which profile a pane runs under; it survives daemon reattach across restarts.LocalPtyProviderresolve the home marker too (after the host env, so it wins over an injected managed home) and export a WSL-resolved home through WSLENV, matching the daemon lane.agentLaunchProfilesEnabledsetting (Settings → Agents → Agent launch profiles, off by default, searchable). With it off nothing in the UI changes; the RPC fields and the CLI flag accept a profile id regardless. The strict client settings schema now also listsagentLaunchProfilesso paired clients can save profiles over RPC.docs/reference/agent-launch-profiles.md.Why
CODEX_HOME=~/.codex-2 codex login) and keeps the existing account machinery untouched for plain launches.Relation to open work: this is the per-launch primitive underneath rp0927's pinned-account stack (#13270–#13275) and #10394 (import existing CODEX_HOME); a pinned managed account can later become one more home source of a profile.
Linked Issue
Addresses #8770 (CLI selection via
--launch-profile) and the launch-scoped half of #2314. Refs #9129.Visual Proof
Tab-bar quick-launch menu and the New Workspace composer (below), captured with the setting turned on; with the default (off) setting both surfaces look exactly like the base. Mobile picker/badge screenshots will be added before this leaves draft. Web, CLI and host changes have no visual change.
Composer: the
Launch profileselect appears under the agent picker only when the chosen agent has profiles (before: no such control).An agent with no profiles keeps its flat item and no composer select. Captured with
tests/e2e/agent-launch-profile-quick-launch-screenshot.spec.ts(opt-in viaORCA_LAUNCH_PROFILE_SHOTS; the "before" frame is the same spec in baseline mode on the base commit).Testing
Unit:
src/shared/agent-launch-profile/*.test.ts,src/main/agent-launch-profile/*.test.ts,src/main/codex/codex-pane-account-registry-launch-profile.test.ts,src/main/providers/ssh-pty-spawn-env.test.ts,src/renderer/src/lib/launch-agent-profile.test.ts,src/renderer/src/hooks/composer-state/quick-startup-plan.test.ts,src/renderer/src/components/NewWorkspaceComposerCard.test.tsx(profile picker case),src/cli/handlers/worktree-startup-agent-flags.test.ts; mobile:mobile/src/session/mobile-new-tab-agent-options.test.ts,mobile-new-tab-agent-loader.test.ts,mobile-terminal-tab-agent.test.ts,mobile-launch-profile-labels.test.ts,use-mobile-session-terminal-create-actions.test.ts.E2E:
tests/e2e/agent-launch-profile-conformance.spec.ts— a headless paired host plus an env-echo fake agent; asserts over RPC only that both secondary homes resolve under the host's HOME, the marker is consumed, a plain launch stays profile-free, and the two error codes fire. Passes on Windows (electron-headless).tests/e2e/agent-launch-profile-quick-launch-screenshot.spec.tsis the opt-in @headful capture behind the screenshots above.Static gates from the PR workflow run locally against the base commit and pass:
check:code-quality:changed(incl. type-aware and React Doctor), the max-lines / ts-nocheck / runtime-Electron ratchets, Zustand fan-out, reliability-gate manifest, root-directory guard, and the four localization verifications.pnpm typecheck(node, cli, web) passes. Fullpnpm testandpnpm buildare left to CI.Platforms exercised locally: Windows 10 (daemon spawn, PowerShell). WSL and SSH resolution are unit-tested; macOS/Linux and a live SSH host are not exercised.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Implemented with Claude (Claude Code); reviewed and driven by a human.
Review
path.joinandhomedir(); WSL resolves inside the distro home and is exported through the existing WSLENV path; nothing platform-specific in the renderer.planAgentCliArgsSuffix). Resolution sits in main because the session already holds the probe; the relay is version-locked to the app, so moving this into the relay'sbuildSpawnEnv(which would also honor anORCA_*_SECONDARY_HOMEoverride set on the remote box) is a possible follow-up rather than a compatibility concern.agentDefaultEnv(settings) and never logged; markers are consumed on the execution host so a nested launch cannot re-resolve them.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)