Skip to content

Feat: headless paste login for bigmodel OAuth (--paste, TUI L key) - #42

Merged
TriDefender merged 1 commit into
TriDefender:masterfrom
B1anYu:feat/headless-paste-login
Sep 6, 2026
Merged

TriDefender merged 1 commit into
TriDefender:masterfrom
B1anYu:feat/headless-paste-login

Conversation

@B1anYu

@B1anYu B1anYu commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

CLI: auth login bigmodel --paste or ZCODE_OAUTH_PASTE=1 — paste the redirected 127.0.0.1 callback URL back instead of waiting on a callback the browser can never reach inside a container. The normal flow prints a headless hint pointing at --paste.

TUI: While waiting for browser callback, press L to switch to paste mode (races against the callback, cleanly cleans up the losing waiter, and ensures the client closes only once).

runtime/paste-login.ts (new): banner instructions with a bracketed URL example using the real callback port (ANSI-free when piped) + readline with timeout. open-browser.ts: fix ENOENT crash on headless boxes (async spawn error had no listener).

Tests: 14 new cases (parser incl. authorize↔exchange redirect_uri round-trip, IO helpers). bun test 732 pass; bun x tsc --noEmit clean. README: headless/Docker login section, TUI key table, env var table.

CLI: `auth login bigmodel --paste` or ZCODE_OAUTH_PASTE=1 — paste the redirected 127.0.0.1 callback URL back instead of waiting on a callback the browser can never reach inside a container (gcloud/gh-style). The normal flow prints a headless hint pointing at --paste.

TUI: single OAuth Login entry as before; while a login waits, a yellow highlight row offers `L` to switch it to paste mode (Promise.race with the callback waiter, losing branch's timeout swallowed, client closed exactly once). Idle `L` starts a paste login directly.

parsePastedCallbackUrl (auth/oauth.ts): query-only parsing, copy-artifact tolerant (quotes/brackets, & entities), accepts both authCode and code params, strict CSRF state check.

runtime/paste-login.ts (new): banner instructions with a bracketed URL example using the real callback port (ANSI-free when piped) + readline with timeout. open-browser.ts: fix ENOENT crash on headless boxes (async spawn error had no listener).

Tests: 14 new cases (parser incl. authorize↔exchange redirect_uri round-trip, IO helpers). bun test 732 pass; bun x tsc --noEmit clean. README: headless/Docker login section, TUI key table, env var table.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@TriDefender

Copy link
Copy Markdown
Owner

LGTM

@TriDefender
TriDefender merged commit 1e4dddd into TriDefender:master Sep 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants