Skip to content

fix(models): allow provider login while the local Gateway is running - #168671

Merged
obviyus merged 7 commits into
mainfrom
fix/models-auth-login-via-gateway
Oct 12, 2026
Merged

obviyus merged 7 commits into
mainfrom
fix/models-auth-login-via-gateway

Conversation

@obviyus

@obviyus obviyus commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #168588, #168135

What Problem This Solves

Fixes provider sign-in being refused by models auth login and models auth login-github-copilot while the local Gateway owns the selected state directory.

User Impact

Supported OAuth, device-code, and plugin API-key methods use the running local Gateway. The terminal renders the Gateway's URLs, device codes, protected inputs, and model-access choices. Credentials stay with the Gateway; the CLI never writes around it or retries a failed login locally.

Options the existing login RPC cannot represent fail explicitly before sign-in starts. The current default model remains unchanged.

Why This Change Was Made

The old CLI router treated every interactive login as an offline mutation. The Gateway already owns provider login and wizard sessions, but its start request lacked local-owner binding and the one-shot CLI transport closed the connection immediately after the start response.

Bind login to the discovered owner with an optional expectedOwnerId and models-auth-login-owner-v1. Retain one authenticated connection for the entire wizard, recheck the local owner before follow-up requests, and cancel/settle that session before releasing terminal resources. A disconnect closes the Gateway-owned login rather than reconnecting or replaying it. OAuth loopback callbacks run on the Gateway host, which is the same machine for this local-owner route.

The Gateway revalidates authority at credential, profile-order, and config publication boundaries. Requests without owner binding retain the Control UI behavior. Declared API-key methods run credential-only for the bound CLI request; this does not change administrator requirements or UI discovery.

CLI input Gateway mapping
--provider, --method Select the exact declared plugin login choice; send its authChoice to models.authLogin.
Omitted provider/method Choose the declared login method in the terminal.
--agent Preserve inherited/leaf selection in agentId.
--device-code Select method device-code; conflicting --method still refuses.
login-github-copilot Select provider github-copilot, method device.
URLs, device codes, manual code, selections Render wizard steps and send answers through wizard.next on the same connection.
--profile-id, --force, --set-default, Copilot --yes Refuse before starting: the existing login RPC has no corresponding fields. Offline behavior remains available after stopping the Gateway.

Methods requiring local provider-CLI import/setup or lacking a supported login declaration remain offline. The wizard result confirms saved/applied outcome; it does not return a per-login profile identifier.

Update behavior: no stored-data migration or protocol-version bump. An older Gateway without the method-specific capability receives no login request. Update/restart that Gateway, or stop it and rerun offline. Ambiguous transport outcomes remain OUTCOME_UNKNOWN; no local fallback is attempted.

Explicitly configured loopback Gateways with gateway.auth.mode: "none" also
support delegated login without a token or device identity. This uses the
existing bounded local-backend resolver, not an arbitrary-URL or remote bypass.

Evidence

  • Review repair at d0b9c83a53d6e785c1dae0f97ea315718b1e1016: 208 focused tests passed in 91.6 seconds with one worker. Scoped type-aware lint, production types, and the command/Gateway-method test type shards passed.

  • A real plugins.load.paths fixture is discovered from the selected read-only config; disabling it or excluding it from the allowlist removes it. The discovery read creates no state database.

  • Real Gateway/SQLite/config controls prove: an owner-bound login saves its credential and provider config; a non-admin caller is rejected without starting the provider; revoking the actual requester after asynchronous persistence-lock preparation leaves both credentials and config unchanged. Instrumentation calls the original handler and persistence function; no writer result is mocked.

  • Discriminating negative controls fail when the selected config is omitted (provider disappears) or the pre-write authority callback is omitted (the real store receives the synthetic credential after revocation). Both controls were restored before the passing run.

  • The unrelated transcript-library CI timeout also reproduces on clean main 4e3818bab0febf3ce265aafab07b0c98b7cf7f16: two cases pass and the same Loading meetings… assertion at line 252 fails. No UI workaround or assertion change is included.

  • On the latest input-guidance base, 26 focused tests pass, including real-stream empty/whitespace input checks and registered auth-none login through the real resolver.

  • The two new CLI delegation regressions fail against the base CLI with OWNER_UNAVAILABLE, then pass with the owner route.

  • Focused CLI, Gateway, transport, terminal-wizard, and auth tests pass, including wrong-owner refusal, old-Gateway capability rejection without a request, browser/manual-input races, disconnect cleanup, cancellation, and saved-versus-applied reporting.

  • Late-effect negative controls demonstrate that removing config beforeCommit or profile-order worker authority allows the forbidden write. The guarded cases preserve the prior state.

  • Production TypeScript and the touched command/CLI/Gateway/agent test type shards pass.

  • pnpm build passed on the auth-behavior revision b7468f2f035f147351ad0595266c5ace3f90264b and the import-wiring verification revision 84774791a74683b65cb351ec615a9f1ad6cf5946. Live commands used the shipped node openclaw.mjs launcher against those frozen builds.

  • On an isolated local Gateway, models auth login-github-copilot rendered https://github.com/login/device and a one-time code in the terminal. Repeating this on the final build exercised both lazy imports. Each flow was cancelled without authorizing an account; no Copilot credential was saved, and the Gateway PID remained unchanged.

  • models auth login --provider openai --method api-key, with a real key supplied only on stdin, changed the isolated Gateway's available OpenAI models from 0 to 16. A real turn returned AUTH_OWNER_OK using a saved credential profile. The configured default and listener PID were unchanged; no restart was used.

  • At the import-wiring verification revision, 20 focused CLI import/owner tests and the production typecheck passed. The production dead-export scan had no new findings; its remaining InstalledCodexAppServer finding also occurred on the repaired fix(models): allow API-key setup while the Gateway runs #168588 base. No baseline suppressions were added.

  • After integrating the updated auth-none base, all 94 focused login tests pass. The new login case drives the registered command through the real auth resolver and verifies backend identity with deviceIdentity: null.

No overlap with protected maintainer changes was found on the touched paths.

Merge danger: reversible code change; credentials intentionally saved by users remain saved after a revert. The affected surface is system/agent provider login with a running local Gateway and the optional multi-request CLI transport lifetime.

@obviyus
obviyus requested a review from steipete October 10, 2026 22:16
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling size: XL labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR delegates supported provider logins to the running local Gateway and renders its authentication wizard in the terminal.

Example: Run openclaw models auth login --provider openai --method api-key while the local Gateway owns the state directory.

  • Before: The CLI refuses the login and requires stopping the Gateway.
  • After: The Gateway saves the credential and refreshes model authentication while the CLI presents the wizard.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Useful, focused ownership repair with shipped-command evidence and discriminating authority controls; pending CI remains a landing gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied shipped-CLI record exercises Copilot device-code rendering/cancellation and OpenAI credential use without restart; inspected production-path controls and their passing-run record cover administrator success, non-admin rejection before provider I/O, and revocation before persistence, with additional final-effect negative controls reported.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Terminal provider sign-in requires stopping an otherwise healthy local Gateway.
Reason: The bounded repair restores supported login flows without introducing another credential writer; maintainer authorship establishes direction, and unsupported options are explicitly preserved offline.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it restores useful terminal sign-in through the existing Gateway owner, and no actionable correctness or security defect was found; exact-head CI is still pending.

Priority: P2
Reviewed head: fd68d3b3509606393de6dbbfd44712ac1734cbf8

Before merge

None.

Findings

None.

Agent review details

How this fits together

The models CLI selects the physical state owner, sends an authenticated login request, and exchanges wizard steps on one connection; existing Gateway persistence owners save credentials and publish configuration.

flowchart TD
  A[Models CLI] --> B[Local state owner router]
  B --> C[Authenticated Gateway connection]
  C --> D[Provider login wizard]
  D --> E[Credential and config writers]
  E --> F[Model authentication refresh]
  D --> A
Loading

Technical review

Best possible solution:

Use the existing Gateway login and persistence owners for supported terminal flows while retaining exclusive offline ownership for unsupported options.

Do we have a high-confidence way to reproduce the issue?

Pinned main explicitly refuses interactive login under a live owner, and the supplied baseline record reports both registered CLI delegation regressions failing with OWNER_UNAVAILABLE.

Is this the best way to solve the issue?

The patch addresses the ownership boundary directly, reuses the existing wizard and writers, and avoids replaying uncertain credential mutations.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 43584d99e8a1.

Provenance checked

  • CLI credential ownership changes intended behavior with a stated reason (510255d: Prevent separate CLI credential writes from leaving the live Gateway's state stale.)
  • Credential-only Gateway login keeps the original intent (b342541: Separate sign-in from model activation and preserve current settings, caller authority, and cancellation behavior.)
  • Local state owner routing keeps the original intent (1b08795: Route mutations through the physically held owner and never replay uncertain outcomes locally.)
  • Actionable transport diagnostics keeps the original intent (ec9135b: Provide actionable Gateway connection errors at the shared transport boundary.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still refuses interactive login: The pinned main router permits owner-routed paste-api-key but selects onForeignOwner refusal for interactive login. (src/cli/models-cli.ts:44, 43584d99e8a1)
  • Introduced owner route: The introduced diff binds models.authLogin to the discovered owner, requires its method-specific capability, retains one connection, and refuses unrepresentable options before starting. (src/cli/models-cli.ts:52, fd68d3b35096)
  • Final-effect authority: The handler requires administrator scope and current owner/requester authority; credential persistence, profile-order promotion, and config publication receive the live assertion. (src/commands/models/auth.ts:369, fd68d3b35096)
  • Production-path authority controls: The supplied passing-run record corresponds to inspected tests using the real registered handler, credential writer, SQLite state, and config writer: administrator success, non-admin rejection before provider I/O, and requester revocation before credential publication. (src/gateway/server-methods/models-auth-login.owner.integration.test.ts:189, fd68d3b35096)
  • Supplied shipped-command proof: The full PR body records shipped-launcher Copilot device-code rendering and cancellation, plus an OpenAI API-key login that exposed 16 models and produced AUTH_OWNER_OK without changing the default model or restarting the Gateway. (fd68d3b35096)
  • Intentional ownership policy preserved: fix: protect provider and MCP credentials from concurrent CLI writes #168135 deliberately prohibited outside credential writers because existing RPCs could not preserve all CLI options; this PR delegates the supported subset and retains explicit offline handling for the rest. (src/cli/models-cli.ts:87, 510255d58fa5)

PR surface

Source +409, Tests +863, Docs +23. Total +1295 across 22 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 13 497 88 +409
Tests 8 933 70 +863
Docs 1 31 8 +23
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 1461 166 +1295

Review metrics

Metric Value Why it matters
Production versus tests Production +497/-88; tests and support +933/-70 Growth supplies the terminal wizard adapter and connection lifetime, with substantial coverage of persistence, authority, and cleanup.
Contract additions 1 optional RPC field, 1 server capability, 2 optional SDK callbacks Owner-bound login is additive and capability-gated; no user configuration key, default, or storage schema is added.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Extends the SDK-exported owner router with optional lifetime callbacks; the maintainer-authored direction accepts this additive contract, and existing callers remain source-compatible.

Label justifications:

  • P2: Restores a bounded CLI authentication workflow while existing online Models and offline login paths remain available.
  • merge-risk: 🚨 compatibility: Extends the SDK-exported owner router with optional lifetime callbacks; the maintainer-authored direction accepts this additive contract, and existing callers remain source-compatible.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (8 earlier review cycles)
  • reviewed 2026-10-10T22:21:27.020Z sha 84774791a74683b65cb351ec615a9f1ad6cf5946 :: needs changes before merge. :: none
  • reviewed 2026-10-11T00:30:40.277Z sha 663e56b :: needs changes before merge. :: [P2] Pass the selected plugin configuration into login discovery
  • reviewed 2026-10-11T01:49:20.498Z sha 6e8e50a :: needs real behavior proof before merge. :: [P2] Pass the selected plugin configuration into login discovery
  • reviewed 2026-10-11T15:37:47.145Z sha 6fbf6d5 :: needs real behavior proof before merge. :: [P2] Pass the selected plugin configuration into login discovery
  • reviewed 2026-10-11T18:58:03.250Z sha ff09dc2 :: needs real behavior proof before merge. :: [P2] Pass the selected plugin configuration into login discovery
  • reviewed 2026-10-11T19:44:51.598Z sha d0b9c83 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T20:22:39.253Z sha 622004f :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T21:25:50.085Z sha 2406e94 :: needs changes before merge. :: none

Reviewed October 11, 2026, 7:34 PM ET / 23:34 UTC (Revision 9).

@obviyus
obviyus force-pushed the fix/models-auth-login-via-gateway branch from 8477479 to 663e56b Compare October 11, 2026 00:23
@obviyus

obviyus commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 11, 2026
@obviyus
obviyus force-pushed the fix/models-auth-login-via-gateway branch from 663e56b to 6e8e50a Compare October 11, 2026 01:42
@obviyus

obviyus commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@obviyus
obviyus force-pushed the fix/models-auth-login-via-gateway branch from 6e8e50a to 6fbf6d5 Compare October 11, 2026 15:32
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Oct 11, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 11, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 11, 2026
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

Inherited CI failures: pinned A/B evidence

Compared the exact merge-parent 43584d99e8a15c9cbb1280e19be098ba9ca7e6b7 with PR head fd68d3b3509606393de6dbbfd44712ac1734cbf8 using direct local commands (macOS arm64, Node 24.21.0, pnpm 12.9.0). The baseline was a fresh worktree with a frozen-lockfile install; the PR used its existing ready installation. No source changes or pushes were made.

The PR diff touches 22 files and no ui/ files. Eight UI e2e files reproduce the same 37 failed cases on the pinned main parent and PR. The two MCP component type errors also reproduce identically. No PR-only failure was observed. The Gateway timeout and the CI-only boot-module failure remain flaky/inconclusive, not proven inherited.

Counts below are passing/failing test cases, except the typecheck rows, which count diagnostics.

Item main 43584d99e8a PR fd68d3b3509 Verdict
src/gateway/session-message-events.test.ts 29 pass / 1 fail: enforces session-scoped chat delivery on real gateway connections timed out 30 pass / 0 fail flaky/inconclusive; the CI identity-only-turn timeout did not reproduce on either side
ui/src/components/mcp-app-unmount.test.ts 1 diagnostic: TS2345, SourceAccessor<Node[]> is not Element at 40:5 Same diagnostic and location identical-on-main (inherited)
ui/src/components/mcp-app-view.test.ts 3 diagnostics: TS2339, updateComplete missing on Element at 801:19, 804:19, 815:19 Same diagnostics and locations identical-on-main (inherited)
board-mcp-app.e2e.test.ts 4 pass / 1 fail: retained dashboard note becomes empty 4 pass / 1 fail, same case/assertion identical-on-main (inherited)
boot-module-boundaries.e2e.test.ts 15 pass / 0 fail 15 pass / 0 fail flaky/inconclusive; CI failure not reproduced
chat-markdown-table-interactions.e2e.test.ts 10 pass / 1 fail: retained table identity is false 10 pass / 1 fail, same case/assertion identical-on-main (inherited)
chat-nested-tool-presentation.e2e.test.ts 1 pass / 1 fail: child diagnostic disclosure locator times out 1 pass / 1 fail, same locator identical-on-main (inherited)
lazy-custom-element-recovery.e2e.test.ts 16 pass / 5 fail: missing built debug-overlay.ts chunk 16 pass / 5 fail, same cases/error identical-on-main (inherited)
meetings.e2e.test.ts 3 pass / 1 fail: Summary locator times out after tab switch 3 pass / 1 fail, same locator identical-on-main (inherited)
settings-prefs-reconnect.e2e.test.ts 7 pass / 1 fail: offline theme replay expects 3 requests, gets 2 7 pass / 1 fail, same assertion identical-on-main (inherited)
theme-muted-contrast.e2e.test.ts 1 pass / 26 fail: config request count expects 2, gets 1 1 pass / 26 fail, same assertions identical-on-main (inherited)
tool-titles.e2e.test.ts 0 pass / 1 fail: running child tool locator times out 0 pass / 1 fail, same locator identical-on-main (inherited)

Totals: UI e2e: 57 pass / 37 fail, 1 passing file / 8 failing files, identically on both sides. Component type graph: 4 diagnostics in 2 files, identically on both sides (exit 2). Completed Gateway runs: main 29/1, PR 30/0. An initial PR Gateway invocation hit a 600-second outer execution deadline after 19 passing cases and no failing cases; a subsequent complete invocation supplied the 30/0 count. No test assertions, timeouts, or retry settings were changed.

Commands

Baseline preparation:

wt switch --create tmp/ab-168671 --base 43584d99e8a --no-cd
# In the new baseline worktree:
wt step copy-ignored
pnpm install --frozen-lockfile

Run from each pinned worktree:

node scripts/run-vitest.mjs run src/gateway/session-message-events.test.ts

node scripts/run-tsgo.mjs \
  -p test/tsconfig/tsconfig.core.test.ui-components.json \
  --incremental \
  --tsBuildInfoFile .artifacts/tsgo-cache/ab-168671-ui-components.tsbuildinfo

node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner \
  ui/src/e2e/board-mcp-app.e2e.test.ts \
  ui/src/e2e/boot-module-boundaries.e2e.test.ts \
  ui/src/e2e/chat-markdown-table-interactions.e2e.test.ts \
  ui/src/e2e/chat-nested-tool-presentation.e2e.test.ts \
  ui/src/e2e/lazy-custom-element-recovery.e2e.test.ts \
  ui/src/e2e/meetings.e2e.test.ts \
  ui/src/e2e/settings-prefs-reconnect.e2e.test.ts \
  ui/src/e2e/theme-muted-contrast.e2e.test.ts \
  ui/src/e2e/tool-titles.e2e.test.ts

check-test-types-core-2 identifies test/tsconfig/tsconfig.core.test.ui-components.json as the failing graph; its other five core graphs and root tooling graph pass in the original CI job. The local command above isolates that same failing graph rather than claiming the entire stripe ran locally.

Independent CI corroboration and limits

Chromium launched and completed all 94 selected cases on both sides. The eight failing UI files had matching cases and assertion/locator failures; this was not a browser-launch failure. boot-module-boundaries passed locally on both sides, so its CI failure remains unclassified.

Also inspected recent runs with gh run list --repo openclaw/openclaw --workflow CI --limit 60 and gh run view <id> --repo openclaw/openclaw --log-failed. Independent main-targeting PR #168632, head d2039c95a421d15b37dbaefd72d2dc5e281a9720, has the same retained-board-note and tool-title locator failures plus the same four MCP type diagnostics in run 38184888770. Run 38184482969 independently contains the same four MCP type diagnostics. These contemporaneous runs corroborate the pinned A/B evidence; they are not substitutes for the exact baseline.

The Gateway CI failure was invalidates the selected web and TUI transcript once for an identity-only committed turn timing out in onceMessage; that case passed in both local checkouts. The baseline instead timed out in a different websocket test. This is evidence of timing instability, not proof that the original Gateway CI failure is inherited. No merge was performed.

@obviyus
obviyus merged commit 653b1d8 into main Oct 12, 2026
158 of 168 checks passed
@obviyus
obviyus deleted the fix/models-auth-login-via-gateway branch October 12, 2026 00:18
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 653b1d8 with maintainer approval to merge past red CI that this PR did not cause. The diff touches no ui/ files. Pinned A/B evidence (#168671 (comment)): every UI e2e and type-check failure reproduces identically on main 43584d9; the one Gateway test failure is flaky on both sides; ClawSweeper was ready on this exact head. While a local Gateway owns state, openclaw models auth login (API-key, device-code and plugin methods, plus login-github-copilot) now runs through that Gateway's sign-in wizard instead of refusing; options the RPC can't carry still refuse with a clear next step.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…w#169309)

## What Problem This Solves

Fixes the transcript-library E2E timing out when returning from Meeting capture settings to the library.

Related: openclaw#168671. The same failure is visible in [checks-ui-e2e](https://github.com/openclaw/openclaw/actions/runs/38165598345).

## User Impact

No product behavior changes. The test now deterministically exercises the loading state instead of waiting for an unheld response to remain pending.

## Why This Change Was Made

`deferredMethods` defers the first matching request only. The initial library read consumes that deferral; the return-navigation assertion added in openclaw#145367 waits for another loading state and resolves another deferred read without arming it. Re-arm `transcripts.list` immediately before returning to the library. Keep every existing loading, transcript, search, export, configuration-write, mobile, and access-denial assertion unchanged.

No overlap with the checked maintainer-owned changes. No runtime or public contracts change.

## Evidence

- Latest main `c5029c5631d37c72df8c96007ccc29bc7db006f9`: exact focused command reproduced 2 passing / 1 failing, with the 30-second loading wait timing out at line 252.
- With the one-line fixture correction: the same command passed all 3 tests, including the full navigation/read/search/download/edit flow (20.22 seconds total).
- `pnpm exec oxfmt --check ui/src/e2e/transcript-library.e2e.test.ts`: passed.
- `git diff --check`: passed.

Command: `node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/transcript-library.e2e.test.ts`.

Merge risk: two-way door; reverting only restores the flaky test. Blast radius is this mocked-Gateway E2E fixture, with no production changes.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…penclaw#168671)

Related: openclaw#168588, openclaw#168135

## What Problem This Solves

Fixes provider sign-in being refused by `models auth login` and `models auth login-github-copilot` while the local Gateway owns the selected state directory.

## User Impact

Supported OAuth, device-code, and plugin API-key methods use the running local Gateway. The terminal renders the Gateway's URLs, device codes, protected inputs, and model-access choices. Credentials stay with the Gateway; the CLI never writes around it or retries a failed login locally.

Options the existing login RPC cannot represent fail explicitly before sign-in starts. The current default model remains unchanged.

## Why This Change Was Made

The old CLI router treated every interactive login as an offline mutation. The Gateway already owns provider login and wizard sessions, but its start request lacked local-owner binding and the one-shot CLI transport closed the connection immediately after the start response.

Bind login to the discovered owner with an optional `expectedOwnerId` and `models-auth-login-owner-v1`. Retain one authenticated connection for the entire wizard, recheck the local owner before follow-up requests, and cancel/settle that session before releasing terminal resources. A disconnect closes the Gateway-owned login rather than reconnecting or replaying it. OAuth loopback callbacks run on the Gateway host, which is the same machine for this local-owner route.

The Gateway revalidates authority at credential, profile-order, and config publication boundaries. Requests without owner binding retain the Control UI behavior. Declared API-key methods run credential-only for the bound CLI request; this does not change administrator requirements or UI discovery.

| CLI input | Gateway mapping |
| --- | --- |
| `--provider`, `--method` | Select the exact declared plugin login choice; send its `authChoice` to `models.authLogin`. |
| Omitted provider/method | Choose the declared login method in the terminal. |
| `--agent` | Preserve inherited/leaf selection in `agentId`. |
| `--device-code` | Select method `device-code`; conflicting `--method` still refuses. |
| `login-github-copilot` | Select provider `github-copilot`, method `device`. |
| URLs, device codes, manual code, selections | Render wizard steps and send answers through `wizard.next` on the same connection. |
| `--profile-id`, `--force`, `--set-default`, Copilot `--yes` | Refuse before starting: the existing login RPC has no corresponding fields. Offline behavior remains available after stopping the Gateway. |

Methods requiring local provider-CLI import/setup or lacking a supported login declaration remain offline. The wizard result confirms saved/applied outcome; it does not return a per-login profile identifier.

**Update behavior:** no stored-data migration or protocol-version bump. An older Gateway without the method-specific capability receives no login request. Update/restart that Gateway, or stop it and rerun offline. Ambiguous transport outcomes remain `OUTCOME_UNKNOWN`; no local fallback is attempted.

Explicitly configured loopback Gateways with `gateway.auth.mode: "none"` also
support delegated login without a token or device identity. This uses the
existing bounded local-backend resolver, not an arbitrary-URL or remote bypass.

## Evidence

- Review repair at `d0b9c83a53d6e785c1dae0f97ea315718b1e1016`: 208 focused tests passed in 91.6 seconds with one worker. Scoped type-aware lint, production types, and the command/Gateway-method test type shards passed.
- A real `plugins.load.paths` fixture is discovered from the selected read-only config; disabling it or excluding it from the allowlist removes it. The discovery read creates no state database.
- Real Gateway/SQLite/config controls prove: an owner-bound login saves its credential and provider config; a non-admin caller is rejected without starting the provider; revoking the actual requester after asynchronous persistence-lock preparation leaves both credentials and config unchanged. Instrumentation calls the original handler and persistence function; no writer result is mocked.
- Discriminating negative controls fail when the selected config is omitted (provider disappears) or the pre-write authority callback is omitted (the real store receives the synthetic credential after revocation). Both controls were restored before the passing run.
- The unrelated transcript-library CI timeout also reproduces on clean main `c5029c5631d37c72df8c96007ccc29bc7db006f9`: two cases pass and the same `Loading meetings…` assertion at line 252 fails. No UI workaround or assertion change is included.

- On the latest input-guidance base, 26 focused tests pass, including real-stream empty/whitespace input checks and registered auth-none login through the real resolver.

- The two new CLI delegation regressions fail against the base CLI with `OWNER_UNAVAILABLE`, then pass with the owner route.
- Focused CLI, Gateway, transport, terminal-wizard, and auth tests pass, including wrong-owner refusal, old-Gateway capability rejection without a request, browser/manual-input races, disconnect cleanup, cancellation, and saved-versus-applied reporting.
- Late-effect negative controls demonstrate that removing config `beforeCommit` or profile-order worker authority allows the forbidden write. The guarded cases preserve the prior state.
- Production TypeScript and the touched command/CLI/Gateway/agent test type shards pass.
- `pnpm build` passed on the auth-behavior revision `b7468f2f035f147351ad0595266c5ace3f90264b` and the import-wiring verification revision `84774791a74683b65cb351ec615a9f1ad6cf5946`. Live commands used the shipped `node openclaw.mjs` launcher against those frozen builds.
- On an isolated local Gateway, `models auth login-github-copilot` rendered `https://github.com/login/device` and a one-time code in the terminal. Repeating this on the final build exercised both lazy imports. Each flow was cancelled without authorizing an account; no Copilot credential was saved, and the Gateway PID remained unchanged.
- `models auth login --provider openai --method api-key`, with a real key supplied only on stdin, changed the isolated Gateway's available OpenAI models from 0 to 16. A real turn returned `AUTH_OWNER_OK` using a saved credential profile. The configured default and listener PID were unchanged; no restart was used.
- At the import-wiring verification revision, 20 focused CLI import/owner tests and the production typecheck passed. The production dead-export scan had no new findings; its remaining `InstalledCodexAppServer` finding also occurred on the repaired openclaw#168588 base. No baseline suppressions were added.
- After integrating the updated auth-none base, all 94 focused login tests pass. The new login case drives the registered command through the real auth resolver and verifies backend identity with `deviceIdentity: null`.

No overlap with protected maintainer changes was found on the touched paths.

**Merge danger:** reversible code change; credentials intentionally saved by users remain saved after a revert. The affected surface is system/agent provider login with a running local Gateway and the optional multi-request CLI transport lifetime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant