Commit Graph
2 Commits
Author SHA1 Message Date
Joey Shao d51e9e3cad mclaw 0.5.3: fail at authorize when there is no browser or display (#898)
mclaw's authorize now runs a preflight before it returns opened:true. When
no Chromium browser can be found, or Linux has neither DISPLAY nor
WAYLAND_DISPLAY, it returns {type:'failed'} at once instead of claiming a
window opened and failing later in callback (source issue
joey-41/opencode-mclaw-auth#1, the same shape as inkstone #825).
requireBrowser() is now the only place that looks up the browser, and
holds its one error message. It now looks for Edge, Chromium and Brave on
macOS, Edge on Windows, and microsoft-edge and /opt/google/chrome on Linux.
MCLAW_CHROME_PATH is checked first (X_OK, or F_OK on Windows) and a bad
path gets its own error. Headless renewal still goes through requireBrowser
only, with no display check. The cancel test now uses two independent
AbortControllers (#746 follow-up). README and CHANGELOG updated, 0.5.3.

Reviewed head 40784afa76c89285cb039460f55cc0f9fb059e21, on main 89fcfb2e.
Read every line of the diff: it adds no network endpoint, credential read,
install script or obfuscated code.

Run at that head, on mote (macOS), HOME a scratch dir:
- packages/mclaw `bun test`: 41 pass, 0 fail.
- repo `bun test` (HOME=$(mktemp -d), as CI): 7604 pass, 0 fail.
  `bun scripts/check.mjs`: exit 0. (The package has no node:test files;
  every test is bun:test.)
- Broken by hand, each red and restored:
  - no preflight call in authorize: both login preflight tests red;
  - no DISPLAY check: the browser-path and login no-display tests red;
  - MCLAW_CHROME_PATH not validated: the bad-override test red;
  - candidates not access()-checked: the real-executable test red.
- Real env, no seams, in WSL (magpie-desktop): DISPLAY/WAYLAND_DISPLAY
  unset → authorize returns failed with the no-display message, no
  opened. DISPLAY set + MCLAW_CHROME_PATH=/no/such → failed with the
  override message. DISPLAY set, no browser installed → requireBrowser
  throws the no-browser message.
- Candidate tables against real machines: mote finds
  ~/Applications/Google Chrome.app; xiaomi-gpu (Windows 11) finds
  C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe.
- PR CI (ubuntu, headless) test job green.

Not blocking, left for a later version: on Windows, Edge (installed on
every machine) now comes before a LOCALAPPDATA Chromium, so a renewal of
a profile Chromium made would open in Edge. Linux's table has no Brave,
though the README names it.

Not tried: a real MClaw sign-in (no account), or a headed sign-in through
Edge or Brave.
2026-11-09 17:58:05 +08:00
Joey Shao 367e879cab mclaw 0.5.2: China Mobile Cloud's MClaw agent (ai.yun.139.com), with a browser sign-in (#746)
New package @magpie-community/opencode-mclaw-auth 0.5.2 (joey-41): China
Mobile Cloud's MClaw agent (ai.yun.139.com) as a provider. A browser
sign-in in a dedicated Chrome profile per sign-in harvests the yun.139.com
ticket and fetches the llm key and the model multipliers by itself; the
models come from the account's own lists; the usage card reads the
aitokens pool and, through the vip SSO chain (toSourceId 001005), the
records' own endTime as the reset; the ticket is renewed headless from the
account's own profile, and a ticket for another phone number is refused.
Every host is China Mobile's own. registry.json and the README table list
it.

Reviewed at 905e2a6b, 7ed7d0aa and 7304ac15 (0.5.2, edcd9549 plus a
merge of main). The last review's two must-fixes are in the code:
magpie's cancel (callback(undefined, { signal }) and authorize's signal
both call harvesting.abort(); startBrowserHarvest records an abort while
Chrome is still starting and closes it once open), and a failed,
cancelled or timed-out sign-in deletes its signin-* profile dir after
releasing the lock. Re-signing an account leaving its old dir behind is
in the package README as a known limit.

Run at 7304ac15 (origin/main 10a61c2e already in it), sandbox HOME:
- mote, Bun 1.4.2: bun test in packages/mclaw 30 pass, 0 fail;
  bun scripts/check.mjs mclaw and bun scripts/check.mjs (all) ok.
- WSL Ubuntu 24.04, Bun 1.4.2: whole-repo bun test (see the PR).
- The real startBrowserHarvest with Chrome for Testing on mote, aborted
  before Chrome was up and 4s after: both reject "登录已取消", no Chrome
  left on the profile, no signin-* dir left.
- Review test: authorize and callback given separate signals, as
  magpie's host does, only the callback's aborted: closed and released.
  With callback's listener taken out it goes red (5s timeout).
Not tried: a real MClaw sign-in (no account here). The package's own
magpie-style test hands both calls one signal, so it stays green
without callback's listener; that is the only gap seen.
npm: the name is new, so trusted publishing can't create it; magpie
serves it from the dist branch until an owner publishes its first
version.
2026-11-06 10:35:49 +08:00