Skip to content

feat(models): add credential-only provider sign-in - #142943

Closed
obviyus wants to merge 1 commit into
mainfrom
feat/models-credential-only-login
Closed

obviyus wants to merge 1 commit into
mainfrom
feat/models-credential-only-login

Conversation

@obviyus

@obviyus obviyus commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

Settings → Models has no credential-only provider sign-in action, and a second authenticated connection can inspect an existing setup wizard. Add manifest-owned sign-in choices for the selected agent and run only the chosen plugin/provider/method through the existing login writer. Saving credentials preserves the default model and model restrictions. Explicit setup activation keeps its existing entry point and result handling.

Wizard prompts, answers and cancellation belong to the starting connection. Disconnect ends input before persistence; an effect already being saved can finish. Models waits for the prior wizard's admission to release and ignores completion from an old agent or connection.

Verification status

This pull request is an unverified CI input. The pinned baseline reproduced the socket ownership defect through the ordinary compiled Gateway and default setup wizard. Both clients and the Gateway stopped, and no prompt answer or credential write occurred.

Candidate tests, the matching compiled Gateway/UI proof, independent acceptance and final code review remain required before landing. The normal required CI includes the new real-Gateway Models sign-in case, with cancellation, peer refusal, credential readback and unchanged-default/restriction controls. Automatic platform jobs remain part of that normal CI.

The change preserves the existing shared refresh interface and personal-account boundary. It does not implement a new credential storage or publication protocol. Mechanical generated-client alignment is included with the core change.

Add manifest-owned Models sign-in through the canonical login flow while
preserving configured defaults and model restrictions. Bind shared wizard
access to its starting connection and retain explicit setup activation.
@obviyus
obviyus requested a review from a team as a code owner September 9, 2026 07:43
@obviyus obviyus self-assigned this Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 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: android App: android app: web-ui App: web-ui gateway Gateway runtime commands Command implementations size: XL maintainer Maintainer-authored PR labels Sep 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 9, 2026, 3:52 AM ET / 07:52 UTC.

ClawSweeper review

What this changes

Adds provider sign-in to Models settings without changing model defaults, and binds setup wizard access and cancellation to the initiating connection.

Merge readiness

⛔ Blocked before merge - 9 items remain

This PR remains useful and is protected from automated closure, but four correctness findings and missing after-fix authority proof prevent a merge-ready verdict.

Priority: P2
Reviewed head: 33e24025d64d42434e42638502a5ce87c2dd0118

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation has useful scope and focused coverage, but lifecycle defects and absent after-fix authority evidence limit readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: Authority-chain proof required: the captured body supplies baseline-only evidence, while the new Gateway login and writer lack observed after-fix allowed, peer-denied, and revoked-during-lock final-write results. The added real-Gateway test is useful coverage source, but no execution evidence is supplied and it does not exercise revocation during persistence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Authority-chain proof required: the captured body supplies baseline-only evidence, while the new Gateway login and writer lack observed after-fix allowed, peer-denied, and revoked-during-lock final-write results. The added real-Gateway test is useful coverage source, but no execution evidence is supplied and it does not exercise revocation during persistence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 11 items Pinned patch and merge ownership: Reviewed merge-base bb63053 to head 33e2402. The raw test-merge record has fetched main first and this exact head second; its changed paths match the introduced surface.
Current main still lacks the requested boundary: Current main retrieves wizards by session ID alone. Its Models documentation describes config API-key editing and separate Model Setup; the credential-only endpoint is absent from the searched current-main surfaces.
Release check: The latest published release remains v2026.9.3. Its wizard tracker also has no connection-owner binding; no merged replacement fixing this request was established.
Findings 4 actionable findings [P1] Revalidate authority after acquiring credential write locks
[P1] Reject wizard admission for an already-disconnected owner
[P2] Exclude starter-model work from credential-only sign-in
Security Needs attention Revoked authority can reach delayed credential writes: Connection authority is checked before asynchronous persistence locks, then cancellation is locked. Revocation during that interval is not rechecked at the protected-secret or auth-profile write boundary.

How this fits together

Models settings discovers sign-in choices from plugin manifests and sends the selected choice to the Gateway. The Gateway runs provider authentication through the shared wizard and existing credential writer, then refreshes the UI.

flowchart TD
  A[Models settings] --> B[Manifest sign-in choices]
  B --> C[Gateway authorization]
  C --> D[Connection-owned wizard]
  D --> E[Provider authentication]
  E --> F[Credential and config writer]
  F --> G[Refreshed provider status]
  C --> H[Reject unavailable or unauthorized requests]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Authority-chain proof required: the captured body supplies baseline-only evidence, while the new Gateway login and writer lack observed after-fix allowed, peer-denied, and revoked-during-lock final-write results. The added real-Gateway test is useful coverage source, but no execution evidence is supplied and it does not exercise revocation during persistence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Revalidate authority after acquiring credential write locks (P1) - The new guard runs before persistProviderAuthResult, but persistence awaits acquireProviderAuthLocks and, for OAuth, additional profile locks before writing. If the initiating device is revoked while waiting, the write still proceeds: the callback is not forwarded to either write boundary, and lockCancellation() has already disabled cancellation. Carry the authority assertion into the synchronous pre-write boundary after those waits; entering an async writer is not a committed effect.
  • Reject wizard admission for an already-disconnected owner (P1) - createAdmittedWizardSession yields while acquiring the setup-target lock. If the socket closes during that wait, disconnect cleanup sees no registered session; this line subsequently registers a wizard under the dead connection without checking its connection signal. The new ownership check prevents replacement connections from cancelling or continuing it. Classic setup has no timeout, so its pending prompt can retain global setup admission indefinitely. Check owner liveness after admission and settle late-created sessions, including the shared start helper.
  • Exclude starter-model work from credential-only sign-in (P2) - Treating every appGuidedAuth choice as credential-only also exposes Copilot's device methods. Those methods call resolveInteractiveCopilotStarterModel, which exchanges runtime credentials, fetches the model catalog, and selects a starter before returning. Removing defaultModel afterward cannot prevent that work, so saving credentials still waits on model discovery despite the new flow's stated contract. Keep such choices on setup until their provider-owned auth path can skip starter selection.
  • Preserve the saved outcome when cancellation is refused (P2) - Cancel remains available while submission is busy. Once the server locks cancellation, it returns running and may subsequently save successfully, but reset() has already cleared the card and invalidated the mutation. The cancellation runner waits for termination without returning that outcome, so finish() is skipped and no terminal provider refresh or saved/error message is shown. Separate explicit cancellation from owner teardown and retain the dialog/result when saving must finish.
  • Resolve security concern: Revoked authority can reach delayed credential writes - Connection authority is checked before asynchronous persistence locks, then cancellation is locked. Revocation during that interval is not rechecked at the protected-secret or auth-profile write boundary.
  • Resolve merge risk (P1) - Credential writes after authority revocation during lock contention have no after-fix final-effect proof.
  • Resolve merge risk (P1) - Existing setup and channel wizards now stop being resumable across connections; fresh-install and upgrade recovery evidence for those consumers is not supplied.
  • Complete next step (P2) - Resolve the four findings, obtain security-owner review, and supply after-fix authority and wizard recovery evidence before merge.

Findings

  • [P1] Revalidate authority after acquiring credential write locks — src/commands/models/auth.ts:614-617
  • [P1] Reject wizard admission for an already-disconnected owner — src/gateway/server-methods/wizard.ts:140-145
  • [P2] Exclude starter-model work from credential-only sign-in — src/plugins/provider-login-options.ts:52-56
  • [high] Revoked authority can reach delayed credential writes — src/commands/models/auth.ts:614
Agent review details

Security

Needs attention: The new credential-writing RPC checks authority too early; no unrelated supply-chain or workflow-permission expansion was found.

PR surface

Source +859, Tests +1028, Docs +4, Config +1, Other +23. Total +1915 across 57 files.

View PR surface stats
Area Files Added Removed Net
Source 34 1104 245 +859
Tests 19 1078 50 +1028
Docs 1 4 0 +4
Config 1 1 0 +1
Generated 0 0 0 0
Other 2 23 0 +23
Total 57 2210 295 +1915

Review metrics

Metric Value Why it matters
Public protocol addition 1 admin RPC; 2 required parameters and 1 optional parameter The new credential-writing entry point needs authority and generated-client validation.
Production versus test growth Production net +882; tests and test support net +1028 Growth supports the new UI and shared lifecycle boundary while retaining the existing credential writer.

Merge-risk options

Maintainer options:

  1. Repair and prove the lifecycle boundaries (recommended)
    Move authority checks past storage waits, close late-admitted disconnected sessions, and demonstrate safe credential writes and reconnect recovery with security-owner review.
  2. Hold the broader wizard change
    Keep the PR open until shared setup and channel consumers have recovery evidence if those lifecycle changes cannot be validated together.

Technical review

Best possible solution:

Keep the canonical credential writer, enforce authority at its actual write boundaries, retain visible terminal outcomes, and verify reconnect recovery before adopting the shared wizard change.

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

Yes, the introduced failures have concrete source-backed triggers: revoke authority during storage-lock waits, disconnect during admission, use Copilot sign-in, or cancel after saving starts. These paths were inspected, not executed.

Is this the best way to solve the issue?

No, not yet: reusing the writer is appropriate, but filtering its result does not remove provider-side setup work, and ownership must survive asynchronous admission and persistence correctly.

Full review comments:

  • [P1] Revalidate authority after acquiring credential write locks — src/commands/models/auth.ts:614-617
    The new guard runs before persistProviderAuthResult, but persistence awaits acquireProviderAuthLocks and, for OAuth, additional profile locks before writing. If the initiating device is revoked while waiting, the write still proceeds: the callback is not forwarded to either write boundary, and lockCancellation() has already disabled cancellation. Carry the authority assertion into the synchronous pre-write boundary after those waits; entering an async writer is not a committed effect.
    Confidence: 0.97
  • [P1] Reject wizard admission for an already-disconnected owner — src/gateway/server-methods/wizard.ts:140-145
    createAdmittedWizardSession yields while acquiring the setup-target lock. If the socket closes during that wait, disconnect cleanup sees no registered session; this line subsequently registers a wizard under the dead connection without checking its connection signal. The new ownership check prevents replacement connections from cancelling or continuing it. Classic setup has no timeout, so its pending prompt can retain global setup admission indefinitely. Check owner liveness after admission and settle late-created sessions, including the shared start helper.
    Confidence: 0.96
  • [P2] Exclude starter-model work from credential-only sign-in — src/plugins/provider-login-options.ts:52-56
    Treating every appGuidedAuth choice as credential-only also exposes Copilot's device methods. Those methods call resolveInteractiveCopilotStarterModel, which exchanges runtime credentials, fetches the model catalog, and selects a starter before returning. Removing defaultModel afterward cannot prevent that work, so saving credentials still waits on model discovery despite the new flow's stated contract. Keep such choices on setup until their provider-owned auth path can skip starter selection.
    Confidence: 0.94
  • [P2] Preserve the saved outcome when cancellation is refused — ui/src/pages/model-providers/login-controller.ts:78-87
    Cancel remains available while submission is busy. Once the server locks cancellation, it returns running and may subsequently save successfully, but reset() has already cleared the card and invalidated the mutation. The cancellation runner waits for termination without returning that outcome, so finish() is skipped and no terminal provider refresh or saved/error message is shown. Separate explicit cancellation from owner teardown and retain the dialog/result when saving must finish.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 27f0e3a0a4a1.

Labels

Label changes:

  • add P2: This is a bounded Models settings improvement with pre-merge correctness blockers, not evidence of an urgent deployed regression.
  • add merge-risk: 🚨 compatibility: Binding every wizard to one socket changes existing reconnect behavior across setup consumers.
  • add merge-risk: 🚨 security-boundary: The new remote login can reach credential writes after its last connection-authority check has become stale.
  • add merge-risk: 🚨 availability: Disconnect during admission can strand an unbounded classic wizard and retain global setup admission.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: the captured body supplies baseline-only evidence, while the new Gateway login and writer lack observed after-fix allowed, peer-denied, and revoked-during-lock final-write results. The added real-Gateway test is useful coverage source, but no execution evidence is supplied and it does not exercise revocation during persistence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a bounded Models settings improvement with pre-merge correctness blockers, not evidence of an urgent deployed regression.
  • merge-risk: 🚨 security-boundary: The new remote login can reach credential writes after its last connection-authority check has become stale.
  • merge-risk: 🚨 availability: Disconnect during admission can strand an unbounded classic wizard and retain global setup admission.
  • merge-risk: 🚨 compatibility: Binding every wizard to one socket changes existing reconnect behavior across setup consumers.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: the captured body supplies baseline-only evidence, while the new Gateway login and writer lack observed after-fix allowed, peer-denied, and revoked-during-lock final-write results. The added real-Gateway test is useful coverage source, but no execution evidence is supplied and it does not exercise revocation during persistence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [high] Revoked authority can reach delayed credential writes — src/commands/models/auth.ts:614
    Connection authority is checked before asynchronous persistence locks, then cancellation is locked. Revocation during that interval is not rechecked at the protected-secret or auth-profile write boundary.
    Confidence: 0.97

What I checked:

  • Pinned patch and merge ownership: Reviewed merge-base bb63053 to head 33e2402. The raw test-merge record has fetched main first and this exact head second; its changed paths match the introduced surface. (2b11e619b507)
  • Current main still lacks the requested boundary: Current main retrieves wizards by session ID alone. Its Models documentation describes config API-key editing and separate Model Setup; the credential-only endpoint is absent from the searched current-main surfaces. (src/gateway/server-methods/wizard.ts:88, 27f0e3a0a4a1)
  • Release check: The latest published release remains v2026.9.3. Its wizard tracker also has no connection-owner binding; no merged replacement fixing this request was established. (src/gateway/server-wizard-sessions.ts:9, 1391f7cd2d40)
  • Authority check precedes yielding persistence: The new guard runs before persistProviderAuthResult. That writer awaits provider-auth locks, and OAuth profile persistence awaits further locks before its transaction. No connection-authority callback reaches those write boundaries; the Gateway callback has already locked cancellation. (src/commands/models/auth.ts:614, 33e24025d64d)
  • Actual credential storage boundary: stageProviderAuthProfilesForPersistence awaits acquireProviderAuthLocks before materializing protected credentials. Its caller subsequently invokes persistAuthProfileBatch, which acquires OAuth locks before writing profiles. (src/plugins/provider-auth-persistence.ts:312, 33e24025d64d)
  • Disconnect can precede wizard registration: wizard.start awaits setup admission before registering its owner. Disconnect cleanup only visits already-registered sessions, and the classic wizard has no timeout. The new owner comparison prevents another connection from recovering a late-registered session. (src/gateway/server-methods/wizard.ts:145, 33e24025d64d)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • jesse-merhi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • openclaw/openclaw-secops: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve all four findings, including provider-side starter discovery and visible completion after refused cancellation.
  • Provide redacted real-Gateway evidence showing allowed writes, peer rejection, revocation during storage waits, and admission-disconnect cleanup; logs or terminal traces should show final storage effects.
  • Add fresh-install and upgrade recovery evidence for existing wizard consumers, with UI captures where useful. Redact credentials, IP addresses, phone numbers, and private endpoints; update the PR body for re-review, or ask a maintainer for @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@obviyus

obviyus commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #144329, rebuilt from current main for credential-only provider sign-in and the shared /login menu.

@obviyus obviyus closed this Sep 10, 2026
obviyus added a commit that referenced this pull request Sep 10, 2026
## Problem

Models sign-in also runs model setup, which can activate a provider's starter model. Bare `/login` starts OpenAI device authentication before the user chooses a provider.

## Solution

Add credential-only provider login in Models and one shared provider menu for chat. Plugins declare optional login choices in their manifests. Core resolves provider and method choices and produces existing command buttons or copyable commands. Bare `/login` always asks for a provider, even when only one is available. API-key and local setup methods remain available through explicit provider commands. `/login codex` retains its device-code flow.

The credential-only flow uses the shared persistence and auth-refresh owner from merged #144181. It preserves the selected model, restrictions, concurrent settings and existing account pins. Models publishes the saved credential through the current Gateway context. Cancellation locks at the real persistent-effect boundary; confirmed saves remain visible through later errors. Caller authority is checked at credential and session commits, and disconnected clients cannot finish pending login. Qualified choices reject stale or ambiguous plugin owners. Leaving Models closes its wizard input through the existing close operation and waits for admission to settle. This uses optional `closeInput` on `wizard.cancel`; ordinary cancellation still refuses to interrupt a protected save. Separate pending requests keep page disposal independent of an outstanding Cancel response.

The final conflict resolution also preserves the shared refresh outcomes from merged #144436: rejected or unreachable refresh reports saved credentials with recovery guidance. One shared error module carries saved-credential and settings-write failure facts, and the provider-neutral runtime owns completion/failure wording for both chat paths.

Channels render core-owned command actions. Provider-neutral recovery replaces the old OpenAI-specific recovery path. OpenAI, MiniMax and xAI declare their supported credential-only choices; methods requiring starter discovery retain setup.

## Impact

- No new configuration keys or database schema.
- Optional metadata preserves setup for plugins that omit it.
- Connecting a provider does not activate its default model.
- Chat selection rechecks current owner permission and availability.

## Evidence

Original baseline: `d35cefd9b7013e2a2fced8cf16b631a6ee476d45`. Integrated base after #144181: `7d2296e3339d1a9689ee020b102ba7c9a765e229`. The later required conflict resolution integrates #144436 at `39b671dc74158f088adde3b4415de4547a0c902b`.

- Real Telegram Test Server baseline: bare `/login` issued a device code before selection. Candidate: provider buttons, second method menu, synthetic device code, saved result and rejection of a stale qualified selection. Telegram transport and user actions are real; provider credentials are synthetic.
- Real Gateway baseline: `models.authLogin` was unknown. Candidate: saved fixture credential with the same default model and restrictions.
- Independent public-client checks cover singleton webchat selection, wrong-connection denial, unavailable choices, disconnect rejection and positive connected-owner completion. An existing CLI setup flow with omitted metadata still saves credentials and honors explicit `--set-default`.
- Integrated public-client cancellation proof: cancelling before save leaves no credential; cancelling after profile visibility while a provider note is pending returns running, and acknowledging the note produces the saved terminal result. A public settings edit during login survives; the saved profile appears without restarting the Gateway.
- Browser captures show Connect, explicit provider selection, the sign-in URL/code and saved result with the selected model unchanged. Captures were inspected.
- Current integrated focused Vitest: 243 passing tests across the auth producer and choice resolution, shared login runtime, core chat, native Telegram, Gateway wizard ownership, Models UI and the CLI sibling. Earlier retained checks cover method ordering, setup, MiniMax/xAI and provider recovery. The Telegram fixture cleanup preserves all test names, parameter rows and assertions; its 25 cases pass after cleanup.
- Page-disposal regression: the original Gateway kept waiting after a saved note, and the original Models page left the wizard unsettled on removal. The correction passes 33 Gateway and 49 UI tests, including disposal during a pending Cancel and a second login on the same connection. Fresh real-Gateway proof rejects a peer disposal, preserves the saved credential, returns truthful closure status, and immediately admits the same owner’s next login.
- Focused lint, assertion safety, runtime build and whitespace checks pass. Full typechecking and full CI run on GitHub.

This extracts Auth C+E from #136257 and replaces closed #142943. Auth A was merged before integration; its implementation was not copied into this branch.

## Deletion and rewrite ledger

`src/auto-reply/codex-login-recovery.ts` moved to `src/auto-reply/provider-login-recovery.ts`. Its `buildCodexLoginRecovery`, `CodexLoginRecoveryEvidence`, and `CodexLoginRecovery` symbols moved to `buildProviderLoginRecovery` (`:23`), `ProviderLoginRecoveryEvidence` (`:5`), and `ProviderLoginRecovery` (`:11`). The fixed OpenAI/Codex recovery action is replaced by the shared provider menu. No recovery test definition was deleted; the nine renamed or parameterized definitions are mapped below against head `73cfa4b319b9640a6711b2dc8e871d9ff4aea035`.

| Removed test name | Disposition | New test name and location |
| --- | --- | --- |
| `adds Codex login recovery to raw forwarded refresh failures` | **behavior moved** | `adds provider login recovery to raw forwarded refresh failures` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:51` |
| `keeps Codex login recovery actionable on Control UI turns` | **behavior moved** | `keeps provider login recovery actionable on Control UI turns` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:72` |
| `preserves Codex login recovery in known failure payloads` | **behavior moved** | `preserves provider login recovery in known failure payloads` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:118` |
| `keeps disabled OpenAI OAuth profiles actionable on later turns` | **behavior moved**; original OpenAI row retained, xAI and MiniMax rows added | `keeps disabled %s OAuth profiles actionable on later turns` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:228` |
| `does not offer Codex login for $label` | **behavior moved**; API-key and transient OAuth negative rows retained, provider-name-only negative row added | `does not offer provider login for $label` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:277` |
| `keeps non-OpenAI OAuth refresh failures on provider-specific terminal guidance` | **behavior moved and expanded**; terminal guidance retained, shared login action added | `adds provider login while retaining non-OpenAI terminal guidance` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:289` |
| `turns returned OpenAI refresh failures into Codex login recovery` | **behavior moved**; original OpenAI row retained, xAI and MiniMax rows added | `turns returned %s refresh failures into provider login recovery` — `src/agents/embedded-agent-runner/run/payloads.errors.test.ts:121` |
| `adds Codex login recovery to OpenAI OAuth refresh failures` | **behavior moved** | `adds provider login recovery to OpenAI OAuth refresh failures` — `src/cron/service.failure-alert.test.ts:845` |
| `does not offer Codex login for non-OAuth authentication failures` | **behavior moved** | `does not offer provider login for non-OAuth authentication failures` — `src/cron/service.failure-alert.test.ts:884` |

The obsolete provider restriction in `buildCodexLoginRecovery` is intentionally removed: typed non-OpenAI OAuth failures now receive the shared action while keeping their provider-specific terminal repair command. The old `/login codex` recovery presentation becomes `/login`; explicit `/login codex` remains supported. Typed OAuth evidence, negative authentication cases, private profile handling, and complete recovery-presentation assertions remain covered.

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

## Problem

Models sign-in also runs model setup, which can activate a provider's starter model. Bare `/login` starts OpenAI device authentication before the user chooses a provider.

## Solution

Add credential-only provider login in Models and one shared provider menu for chat. Plugins declare optional login choices in their manifests. Core resolves provider and method choices and produces existing command buttons or copyable commands. Bare `/login` always asks for a provider, even when only one is available. API-key and local setup methods remain available through explicit provider commands. `/login codex` retains its device-code flow.

The credential-only flow uses the shared persistence and auth-refresh owner from merged openclaw#144181. It preserves the selected model, restrictions, concurrent settings and existing account pins. Models publishes the saved credential through the current Gateway context. Cancellation locks at the real persistent-effect boundary; confirmed saves remain visible through later errors. Caller authority is checked at credential and session commits, and disconnected clients cannot finish pending login. Qualified choices reject stale or ambiguous plugin owners. Leaving Models closes its wizard input through the existing close operation and waits for admission to settle. This uses optional `closeInput` on `wizard.cancel`; ordinary cancellation still refuses to interrupt a protected save. Separate pending requests keep page disposal independent of an outstanding Cancel response.

The final conflict resolution also preserves the shared refresh outcomes from merged openclaw#144436: rejected or unreachable refresh reports saved credentials with recovery guidance. One shared error module carries saved-credential and settings-write failure facts, and the provider-neutral runtime owns completion/failure wording for both chat paths.

Channels render core-owned command actions. Provider-neutral recovery replaces the old OpenAI-specific recovery path. OpenAI, MiniMax and xAI declare their supported credential-only choices; methods requiring starter discovery retain setup.

## Impact

- No new configuration keys or database schema.
- Optional metadata preserves setup for plugins that omit it.
- Connecting a provider does not activate its default model.
- Chat selection rechecks current owner permission and availability.

## Evidence

Original baseline: `f1881c4f376edf3229e669c189cbd2f4a453a3ea`. Integrated base after openclaw#144181: `872107b561da08e74f1402e03d724136fc521ae6`. The later required conflict resolution integrates openclaw#144436 at `1f2227f786967da4b4bd3662501df6ea0003d2c3`.

- Real Telegram Test Server baseline: bare `/login` issued a device code before selection. Candidate: provider buttons, second method menu, synthetic device code, saved result and rejection of a stale qualified selection. Telegram transport and user actions are real; provider credentials are synthetic.
- Real Gateway baseline: `models.authLogin` was unknown. Candidate: saved fixture credential with the same default model and restrictions.
- Independent public-client checks cover singleton webchat selection, wrong-connection denial, unavailable choices, disconnect rejection and positive connected-owner completion. An existing CLI setup flow with omitted metadata still saves credentials and honors explicit `--set-default`.
- Integrated public-client cancellation proof: cancelling before save leaves no credential; cancelling after profile visibility while a provider note is pending returns running, and acknowledging the note produces the saved terminal result. A public settings edit during login survives; the saved profile appears without restarting the Gateway.
- Browser captures show Connect, explicit provider selection, the sign-in URL/code and saved result with the selected model unchanged. Captures were inspected.
- Current integrated focused Vitest: 243 passing tests across the auth producer and choice resolution, shared login runtime, core chat, native Telegram, Gateway wizard ownership, Models UI and the CLI sibling. Earlier retained checks cover method ordering, setup, MiniMax/xAI and provider recovery. The Telegram fixture cleanup preserves all test names, parameter rows and assertions; its 25 cases pass after cleanup.
- Page-disposal regression: the original Gateway kept waiting after a saved note, and the original Models page left the wizard unsettled on removal. The correction passes 33 Gateway and 49 UI tests, including disposal during a pending Cancel and a second login on the same connection. Fresh real-Gateway proof rejects a peer disposal, preserves the saved credential, returns truthful closure status, and immediately admits the same owner’s next login.
- Focused lint, assertion safety, runtime build and whitespace checks pass. Full typechecking and full CI run on GitHub.

This extracts Auth C+E from openclaw#136257 and replaces closed openclaw#142943. Auth A was merged before integration; its implementation was not copied into this branch.

## Deletion and rewrite ledger

`src/auto-reply/codex-login-recovery.ts` moved to `src/auto-reply/provider-login-recovery.ts`. Its `buildCodexLoginRecovery`, `CodexLoginRecoveryEvidence`, and `CodexLoginRecovery` symbols moved to `buildProviderLoginRecovery` (`:23`), `ProviderLoginRecoveryEvidence` (`:5`), and `ProviderLoginRecovery` (`:11`). The fixed OpenAI/Codex recovery action is replaced by the shared provider menu. No recovery test definition was deleted; the nine renamed or parameterized definitions are mapped below against head `73cfa4b319b9640a6711b2dc8e871d9ff4aea035`.

| Removed test name | Disposition | New test name and location |
| --- | --- | --- |
| `adds Codex login recovery to raw forwarded refresh failures` | **behavior moved** | `adds provider login recovery to raw forwarded refresh failures` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:51` |
| `keeps Codex login recovery actionable on Control UI turns` | **behavior moved** | `keeps provider login recovery actionable on Control UI turns` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:72` |
| `preserves Codex login recovery in known failure payloads` | **behavior moved** | `preserves provider login recovery in known failure payloads` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:118` |
| `keeps disabled OpenAI OAuth profiles actionable on later turns` | **behavior moved**; original OpenAI row retained, xAI and MiniMax rows added | `keeps disabled %s OAuth profiles actionable on later turns` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:228` |
| `does not offer Codex login for $label` | **behavior moved**; API-key and transient OAuth negative rows retained, provider-name-only negative row added | `does not offer provider login for $label` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:277` |
| `keeps non-OpenAI OAuth refresh failures on provider-specific terminal guidance` | **behavior moved and expanded**; terminal guidance retained, shared login action added | `adds provider login while retaining non-OpenAI terminal guidance` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:289` |
| `turns returned OpenAI refresh failures into Codex login recovery` | **behavior moved**; original OpenAI row retained, xAI and MiniMax rows added | `turns returned %s refresh failures into provider login recovery` — `src/agents/embedded-agent-runner/run/payloads.errors.test.ts:121` |
| `adds Codex login recovery to OpenAI OAuth refresh failures` | **behavior moved** | `adds provider login recovery to OpenAI OAuth refresh failures` — `src/cron/service.failure-alert.test.ts:845` |
| `does not offer Codex login for non-OAuth authentication failures` | **behavior moved** | `does not offer provider login for non-OAuth authentication failures` — `src/cron/service.failure-alert.test.ts:884` |

The obsolete provider restriction in `buildCodexLoginRecovery` is intentionally removed: typed non-OpenAI OAuth failures now receive the shared action while keeping their provider-specific terminal repair command. The old `/login codex` recovery presentation becomes `/login`; explicit `/login codex` remains supported. Typed OAuth evidence, negative authentication cases, private profile handling, and complete recovery-presentation assertions remain covered.

Co-authored-by: Ayaan Zaidi <[email protected]>
@RomneyDa
RomneyDa deleted the feat/models-credential-only-login branch October 22, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant