Repository navigation
fix(models): allow provider login while the local Gateway is running - #168671
Conversation
|
🦞👀 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 maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +409, Tests +863, Docs +23. Total +1295 across 22 files. Added test files: 4. View PR surface stats
Review metrics
LabelsLabel 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 (8 earlier review cycles)
Reviewed October 11, 2026, 7:34 PM ET / 23:34 UTC (Revision 9). |
8477479 to
663e56b
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
663e56b to
6e8e50a
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
6e8e50a to
6fbf6d5
Compare
…ls-auth-login-via-gateway
…ls-auth-login-via-gateway
Inherited CI failures: pinned A/B evidenceCompared the exact merge-parent The PR diff touches 22 files and no Counts below are passing/failing test cases, except the typecheck rows, which count diagnostics.
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. CommandsBaseline preparation: wt switch --create tmp/ab-168671 --base 43584d99e8a --no-cd
# In the new baseline worktree:
wt step copy-ignored
pnpm install --frozen-lockfileRun 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
Independent CI corroboration and limitsChromium 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. Also inspected recent runs with The Gateway CI failure was |
|
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, |
…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]>
…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.
Related: #168588, #168135
What Problem This Solves
Fixes provider sign-in being refused by
models auth loginandmodels auth login-github-copilotwhile 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
expectedOwnerIdandmodels-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.
--provider,--methodauthChoicetomodels.authLogin.--agentagentId.--device-codedevice-code; conflicting--methodstill refuses.login-github-copilotgithub-copilot, methoddevice.wizard.nexton the same connection.--profile-id,--force,--set-default, Copilot--yesMethods 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"alsosupport 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.pathsfixture 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 sameLoading 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
beforeCommitor 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 buildpassed on the auth-behavior revisionb7468f2f035f147351ad0595266c5ace3f90264band the import-wiring verification revision84774791a74683b65cb351ec615a9f1ad6cf5946. Live commands used the shippednode openclaw.mjslauncher against those frozen builds.On an isolated local Gateway,
models auth login-github-copilotrenderedhttps://github.com/login/deviceand 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 returnedAUTH_OWNER_OKusing 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
InstalledCodexAppServerfinding 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.