Repository navigation
feat: use your existing Claude Code sign-in with an isolated native Gateway - #2394
Fly-onlyone wants to merge 2 commits into
Conversation
…tive Gateway An isolated native Gateway runs under its own agent account, so Claude Code installed and signed in for the Windows user is invisible to it and the "Anthropic Claude CLI" choice fails with "claude was not found on PATH". When the user picks a Claude CLI route on an isolated Gateway, Companion now copies the user's claude.exe and .credentials.json through a one-time folder in the agent's shared folder and has `clawctl pwsh` place them in the agent account, in a folder the running Gateway already has on its PATH. The one-time folder is removed afterwards, leftovers of an interrupted share are swept on the next one, and a failed share never blocks the choice. Nothing is shared for other providers, for a Gateway that runs as the user, or when the user has no native Claude Code install with a saved sign-in. Related: openclaw#2112
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR copies the Windows user's Claude Code executable and saved sign-in into an isolated native Gateway account during explicit Claude CLI setup. Example: Claude Code 2.1.332 is installed and signed in for the Windows user, but absent from the isolated Gateway account.
Review scores
ProductKind: Feature · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⛔ Blocked before merge - 3 items remain Keep this draft open for a maintainer decision on credential sharing; the previous account-replacement finding is fixed, but a new cleanup defect remains. Reviewed head: Decision needed
Before merge
Findings
Tests
Agent review detailsHow this fits togetherCompanion's native setup session invokes the installed Gateway package's clawctl commands to provision the isolated agent profile before Gateway-owned provider activation. flowchart LR
User[Windows user] --> Setup[Companion AI setup]
Setup --> Bridge[Claude CLI bridge]
Bridge --> Shared[Shared staging folder]
Shared --> Shell[Packaged clawctl shell]
Shell --> Agent[Isolated agent profile]
Agent --> Gateway[Gateway provider activation]
Technical reviewBest possible solution: Prefer package-owned Claude installation and agent-owned sign-in unless maintainers approve a supported credential-import contract with explicit consent and reliable staging cleanup. Do we have a high-confidence way to reproduce the issue? The isolated-account ownership contract and inspected failure screenshot support the host-install visibility mismatch; no target code was executed during this read-only review. Is this the best way to solve the issue? The proposal explains the mismatch, but copying credentials through Companion is premature while package ownership, consent, and credential lifecycle remain undecided. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b762c8dc12a8. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 28, 2026, 9:34 PM ET / November 29, 2026, 02:34 UTC (Revision 2). |
…Claude Code Picking the Gateway's already detected Claude Code candidate ran the share step too, and the agent step always overwrote the agent account's .credentials.json with the Windows user's. An agent signed in to another Claude account silently lost that sign-in. - Share only for the explicit "reuse the host's Claude Code login" sign-in choice, never for a detected candidate. - Probe the agent account first and share nothing when it already has a Claude sign-in. - The agent step itself no longer overwrites an existing sign-in, so a sign-in that appears between the probe and the copy is kept too. Related: openclaw#2112
|
@clawsweeper re-review Changes since the last review at
|
|
🦞👀 Re-review progress:
|
Related: #2112
Update after review (head
a85bae93). The review found that picking the Gateway's already detected Claude Code choice also ran the share step and replaced the agent account's own Claude sign-in. Fixed in a second commit: the share step now runs only for the explicit "Anthropic Claude CLI" sign-in choice, shares nothing when the agent account already has a Claude sign-in, and the agent-side step no longer overwrites one. The ownership and consent questions below are unchanged and still need a maintainer decision. No new guest run was made for this commit.Draft: this is a design proposal. It deliberately crosses the isolated agent boundary, so it needs a maintainer decision before it is worth polishing further. The plain bug fixes for #2112 are in #2393 (fix: show why AI provider setup failed and let it be run again) and do not depend on this.
What Problem This Solves
On a native Store Gateway, the setup choice "Anthropic Claude CLI: Keep using an existing Claude Code CLI login on this host" cannot work. The Gateway runs under its own isolated agent account with its own profile and PATH, so Claude Code that is installed and signed in for the Windows user is invisible to it. The Gateway answers "Claude CLI (
claude) was not found on PATH" even though the user did everything the option asks for. The only way through today is to openclawctl pwshand install and sign in Claude Code by hand inside the agent account.User Impact
User impact: with Claude Code installed and signed in for the Windows user, choosing "Anthropic Claude CLI" in Companion setup on an isolated native Gateway now works on the first click. Nothing changes for other providers, for a Gateway that runs as the user, when the user has no native Claude Code install with a saved sign-in, or when the agent account already has a Claude sign-in of its own.
Risks and limits that a reviewer and a user should know:
.credentials.json, nothing is shared and that account keeps its sign-in. Switching the agent to another Claude account is not offered here..credentials.jsoninto the agent profile. That is what "keep using an existing Claude Code CLI login" means on this Gateway, but it is a real widening of what the isolated account holds.claude.exeinstall is found. An npm install is not shared.Why This Change Was Made
ClaudeCliAgentBridge(new, inOpenClaw.SetupEngine) runs only when the user explicitly picks the Gateway's Claude CLI sign-in choice (anthropic-cli, or its deprecated idclaude-cli) on an isolated session. It does not run for a detectedclaude-clicandidate, which already works on the agent's own sign-in:claude.exe(%USERPROFILE%\.local\bin, then PATH) and.credentials.json(CLAUDE_CONFIG_DIRor%USERPROFILE%\.claude). If either is missing, do nothing.clawctl status --jsonfor the agent's shared folder, andclawctl pwsh --commandfor the size of the agent's copy and whether the agent already has a sign-in. If it has one, stop here.clawctl pwsh --commandcopies them into the agent account (the sign-in only if none is there): the program into the agent's%LOCALAPPDATA%\Microsoft\WindowsApps, which is already on the running Gateway's PATH, so no Gateway restart is needed. An agent without that PATH entry falls back to.local\bin, a user PATH update, and a Gateway restart.A failed share never blocks the choice: the Gateway then reports what it is missing, as before.
Open questions for maintainers:
clawctlor the Gateway offer a supported "use the host's Claude Code" operation that Companion calls? The packaging guide says the agent account owns its PATH, and this change writes into that account throughclawctl pwsh.claude auth loginthere) be preferred over copying the user's sign-in? It avoids two holders of one token at the cost of an extra step for the user.Evidence
Real behavior proof. Clean Hyper-V guest restored from a checkpoint, Windows 11 Pro 26H2 build 26300.9974, Gateway
OpenClawFoundation.OpenClawGateway_2026.11.11081.0from the Store (isolated session), Claude Code 2.1.332 installed and signed in for the Windows user only. Unsigned local installers. The final-build screenshots come from one build with this PR and #2393 together (installer sha256986A70A7...2E21BE22).openclaw.setup.verifycalls, each withcli turn: provider=claude-cli model=claude-opus-5-5.In the run that reached "All set", the agent's shared folder afterwards contained no one-time folder and no sign-in file, and the guest event log showed no Companion crash. Those two checks were not captured for the final-build run.
Tests (
ClaudeCliAgentBridgeTests): the bridge applies to the sign-in choice and never to a detected candidate; first share stages program and sign-in and leaves nothing behind; an agent that already has this program receives only the sign-in; an agent with its own sign-in keeps it and nothing is staged; restart requirement is passed on; nothing is shared andclawctlis never called without a user program or sign-in; program found on PATH and relocated config directory; a failed agent step and an interrupted earlier share both leave no sign-in in the shared folder; unusable shared-folder reports stop before any copy; PowerShell literal quoting for all four quote characters. One test runs the real agent-side scripts in Windows PowerShell against a throwaway profile and checks that the program replaces the old one, the sign-in lands in the profile, the probe then reports that sign-in, and a second agent step with another account's file leaves the first sign-in in place.Validation at head
a85bae93(this branch alone, clean tree, Windows 11 x64):./build.ps1dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restoredotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restoredotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restoredotnet test ./tests/OpenClaw.Tray.UITests/OpenClaw.Tray.UITests.csproj -r win-x64 --no-restore --filter "(FullyQualifiedName~OnboardingAiPageTests|FullyQualifiedName~NativeSharedFlowTests)&<CI lane category exclusions>"On the previous head
78621a9dthe first Shared run had two failures that passed on a rerun of the whole suite:ExecApprovalsStoreTests.Changed_TwoOriginFilteredSubscribers_ReceiveOtherWriterExactlyOnce(IOException:exec-approvals.jsonin use by another process) andOpenClawGatewayClientTests.AuthenticatedSigningIdentity_ComesFromConnectNotOptionalHelloEcho(spoofEcho: False, useManagedWebSocket: False)(TimeoutExceptionafter 15 s). This branch does not touchOpenClaw.Shared. The host was under memory pressure at the time. I did not investigate them further. They did not recur on this head.Independent review. A separate review agent read the diff and its owners. Its findings are addressed in this revision: quoting covers every character that ends a PowerShell single-quoted string, the sign-in is copied last and swept on the next share, the program is replaced by copy-then-move so a program in use keeps its old file, file probes run off the UI thread, and a failed share no longer blocks the choice.
Not verified / blocked
a85bae93. The keep-existing-sign-in behavior is covered by tests only, including the real PowerShell script run, not by a guest run.openclaw config set gateway.nodes.commands.allow ...) was refused by the Gateway CLI with "Gateway lock owner identity could not be verified. No local mutation was attempted."clawctl pwshinvolved, so it is not caused by this change, but it does stand between this feature and a finished setup on a slow machine. It is not addressed here.Required proof pools
windows-winui-interactive: first-run AI setup behavior changed for the Claude CLI choices. Screenshots from a clean Windows 11 guest are under Evidence.