Skip to content

fix(anthropic): forward selected profiles to Claude CLI - #112458

Merged
fuller-stack-dev merged 32 commits into
mainfrom
codex/claude-cli-profile-auth
Jul 22, 2026
Merged

fuller-stack-dev merged 32 commits into
mainfrom
codex/claude-cli-profile-auth

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Summary

  • make compatible selected or ordered claude-cli profiles authoritative for turns
  • refresh and materialize the selected profile before process preparation
  • deliver selected OAuth, token, and API-key credentials through Claude Code's fd 3 credential contract
  • clear competing ambient or configured auth only when a selected profile is installed
  • preserve native Claude login and node defaults when no compatible profile exists
  • keep system-agent route verification bound to the selected profile owner

Closes #95612
Closes #107668

Testing

  • 14 focused files / 582 tests passed on the final implementation candidate
  • check:test-types and targeted lint passed
  • git diff --check passed
  • fresh branch autoreview completed with no actionable findings
  • live Claude Code 2.1.217 OAuth fd 3 turn passed
  • exact-head GitHub CI and security checks

Security

Raw selected credentials are absent from the Claude child environment. OpenClaw writes one transient credential buffer to fd 3, Claude consumes and closes it before hooks or tool subprocesses run, and the buffer is zeroized after delivery. Paired-node runs serialize the selected credential only across the authenticated node RPC and convert it to the same fd contract at the node spawn boundary.

CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is intentionally not used because Claude Code 2.1.217 changes bypassPermissions to default when that variable is set.

@fuller-stack-dev
fuller-stack-dev requested a review from a team as a code owner July 22, 2026 00:54
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: anthropic size: M maintainer Maintainer-authored PR labels Jul 22, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Jul 22, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Updated head: 0352893e5f8e3ac1db3e262dd8cbb784f7ffe737.

Latest Claude Code compatibility follow-up:

  • removed CLAUDE_CODE_SUBPROCESS_ENV_SCRUB, which changes permission mode on Claude Code 2.1.217
  • selected OAuth/API-key credentials now reach Claude through its documented fd 3 environment contracts; raw credentials are absent from child env
  • live-session fingerprints restart on access-token rotation while preserving profile-only persisted-session semantics
  • paired-node runs convert forwarded selected credentials to fd input at the node child boundary, while no-profile runs preserve node-native Claude defaults
  • generic supervisor secret input remains { fd, createData }; the process-local fingerprint stays CLI-private

Proof on the pushed candidate: 14 focused files / 582 tests green, targeted lint green, and final branch autoreview clean with no actionable findings. CI and security checks are now running. This does not merge the PR.

@clawsweeper

clawsweeper Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(anthropic): forward selected profiles to Claude CLI This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Maintainer follow-up on the exact-head ClawSweeper artifact (29893241696):

  • Local/live proof: Claude Code 2.1.217 consumed the selected OAuth token through fd 3 in a live turn. The same installed CLI was directly probed for the API-key descriptor contract and confirmed to close fd 3 before SessionStart hooks. The final candidate also passed 14 focused files / 582 tests, including selected-profile and native-login fallback coverage.
  • Paired-node live proof: skipped because this gateway currently reports zero paired nodes (openclaw nodes status --json). The substitute integration proof exercises the full node boundary: command policy and connection/pairing pinning (src/gateway/node-agent-cli-runtime.ts:33, src/gateway/node-agent-cli-runtime.ts:61), direct in-memory WebSocket dispatch to the current authenticated session (src/gateway/node-registry.ts:1031, src/gateway/node-registry.ts:1155), narrow env allowlisting and exactly-one-credential validation (src/node-host/invoke-agent-cli-claude-params.ts:53, src/node-host/invoke-agent-cli-claude-params.ts:277), and conversion to child-only fd 3 with raw auth removal and buffer zeroization (src/node-host/invoke-agent-cli-claude-handler.ts:62, src/node-host/invoke-agent-cli-claude-handler.ts:178). src/node-host/invoke-agent-cli-claude.test.ts:229 proves the forwarded OAuth arrives on fd 3 with neither raw auth nor scrub env present; src/node-host/invoke-agent-cli-claude.test.ts:296 proves no-profile runs retain node-native auth.
  • Boundary decision: approved for this PR. The credential exists transiently in the authenticated node.invoke request, is not written to pending wake/state storage, is pinned to the current connection and pairing generation, is excluded from approval/event output, and is removed before Claude child spawn. preferMacAppExecHost: false prevents forwarding it into the companion exec-host path (src/node-host/invoke-agent-cli-claude-handler.ts:247).

With that constraint recorded, both rank-up moves are addressed and no additional branch update or broad rerun is warranted for unrelated main changes.

@fuller-stack-dev
fuller-stack-dev merged commit 1a42e00 into main Jul 22, 2026
123 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the codex/claude-cli-profile-auth branch July 22, 2026 05:27
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 22, 2026
)

* fix(anthropic): forward Claude CLI auth profiles

* fix(system-agent): inject CLI auth route stores

* fix(claude-cli): pass profile credentials by descriptor

* fix(anthropic): repair selected profile CI coverage

* fix(anthropic): preserve profile owner validation

* test(system-agent): preserve selected profile fixtures

* test(system-agent): narrow selected profile fixture

* test(system-agent): resolve profile store merge

* fix(anthropic): forward profiles to node Claude runs

* fix(system-agent): reconcile profile route projection

* test(system-agent): thread profile store through projection

* fix(anthropic): make selected profile authoritative

* fix(system-agent): type auth setup failures

* fix(system-agent): type setup auth failures

* style: format Claude profile maintenance

* fix(anthropic): keep gateway credentials off nodes

* fix(anthropic): clear ambient auth for selected profiles

* fix(anthropic): secure paired-node Claude auth

* fix(node-host): type Claude fd spawn streams

* style(node-host): satisfy Claude spawn lint

* fix(process): capture exit before secret delivery

* fix(anthropic): preserve node-native Claude auth
@steipete steipete mentioned this pull request Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: anthropic gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

1 participant