Files
Cason Mo b48f2e754f agnes: add the international Agnes AI provider with browser sign-in, usage and balance (#619)
Adds @magpie-community/opencode-agnes-auth 0.1.0 (provider `agnes`): Agnes AI's
international API platform (apihub.agnes-ai.com for models, platform-backend.agnes-ai.com
for keys and usage). Agnes trains and serves its own agnes-* models, so it is a vendor,
not a relay, and a different channel from `agnes-code` (the Agnes Code desktop's
gateway). Sign-in: a private Chromium profile read over loopback CDP (plan, personal or
enterprise key), or an API key plus an optional console token. Usage: a plan key shows
Token Plan and Agent Plan windows; a personal or enterprise key shows the balance only.
By CasonMo (#619).

Since the first review (9242396): the callback's /user/self result no longer shadows the
Chrome session (6ca6f68 broke every browser sign-in); a page exception from CDP is
reported instead of timing out, but only once the same exception has lasted 4s, since
Chrome raises SecurityError on localStorage while the page is still loading; the
platform gets x-user-language en-US; browser sign-ins aren't told to paste a token.

Reviewed head 8a30c65ee88ab432ed7f63f86b81c18d0db3680c, merged onto origin/main 581ca13.
Run on mote, HOME=$(mktemp -d), Bun 1.4.2:
- bun scripts/check.mjs: exit 0 (agnes included)
- bun test packages/agnes: 51 pass, 1 skip, 0 fail
- bun test (whole repo): 4775 pass, 13 skip, 0 fail (main 581ca13 alone: 4741 pass, 0 fail)
- AGNES_BROWSER_TEST=1 with Chrome for Testing 1234 (--use-mock-keychain): the real-browser
  test passed 5 of 5 headed and 5 of 5 with --headless=new; no browser left running.
Broken by hand: making the first page exception final again turned the two new
token-poll tests red, and the real-browser test red 5 of 5 with the same
"SecurityError ... Access is denied for this document" seen at 1eea3f7. Earlier rounds
broke the TDZ fix and the exceptionDetails branch by hand; their tests went red.

Harm check: no dependencies, install scripts, .github or publish changes, or encoded
blobs. The only addresses are agnes-ai.com hosts and 127.0.0.1 CDP; the console token
goes only to platform-backend and the API key only to apihub. The plugin uses its own
browser profile, never the user's.

Not tried: a real Agnes account or the real login page (no account here; tests stay
offline); the Windows and Linux browser paths.
2026-11-02 15:54:08 +08:00

22 lines
1.1 KiB
Plaintext

MIT License
Copyright (c) 2026 magpie-community contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.