Commit Graph
13 Commits
Author SHA1 Message Date
yetone 8f4a8ec496 raccoon 0.1.10: a balance a little over the listed grants keeps the Credits window (#936)
The reporter's income bills, pasted after 0.1.9, have no expired grant:
3000 + 300 + 3000 + 300 + 3000 = 9,600, while the balance is 9,623. So
0.1.9's count-back of expired grants added nothing and the card stayed
balance-only. The extra 23 comes back outside income bills.

A balance at most 10% over the listed grants now becomes the window's
limit (0 / 9623 here). A balance far over them (5,270 against 600 in the
existing test) stays balance-only, since the bills don't explain it.

Run: win-run bun test packages/raccoon (52 pass; the new test uses the
reporter's bills as pasted, with the expiry years moved ahead so it
holds after 11-15). Broken by hand: with the 10% branch made false, the
new test goes red (51 pass, 1 fail). bun scripts/check.mjs green.
Not tried: a real Raccoon account.

Reported-by: ULTIMATE215
2026-11-10 22:27:04 +08:00
yetone 4a063646cc raccoon 0.1.9: a grant past expire_at the balance still holds keeps the Credits window (#936)
ULTIMATE215's card (0.1.8) showed one account as "9623 credits" with no
bar, beside two accounts with Credits windows (47 / 11,600, 0 / 9,300).
queryUsage builds the window only when the unexpired grant bills cover
the balance, and skips every grant whose expire_at has passed. The
vendor takes an expired grant's remainder some time after expire_at, so
for a while the balance (9,623) is more than the unexpired grants
(9,600 from 9,000 reward + daily 300s) and the card fell back to
balance only.

Now the expired grants are counted back in, the most recently expired
first, only until they cover the balance. runsOutAt/runsOut still come
from unexpired grants only. When even the expired grants cannot make up
the balance, the card stays balance-only as before.

Run on xiaohuanxiong.com-shaped fixtures (bill rows with expire_at, as
in the existing tests and #223's live bills), on the Windows box
(win-run at this tree, Bun; mote refused SSH and WSL failed to start):
bun test packages/raccoon 51 pass, 0 fail; bun scripts/check.mjs
raccoon ok.
Broken by hand: with the count-back line removed, "a grant past
expire_at the balance still holds keeps the Credits window" goes red.
Not tried: a real Raccoon account (none here, and the browser is not
signed in to xiaohuanxiong.com). That the vendor's balance lags expiry
is inferred from the reporter's numbers, not seen in a raw bills reply;
the issue asks the reporter to confirm.

Reported-by: ULTIMATE215
2026-11-10 20:34:25 +08:00
我是一条没有名字的区 087c36123d inkstone 0.1.3: image-caps preflight, a zero-prompt browser sign-in, key calls on the session cookie (#832)
inkstone 0.1.3 (#832, yunwang2442-creator):

- Image requests are prechecked before they leave: 8 images, 10MB each, 40MB in all.
  - A request over a cap gets a local 400 shape refusal, so magpie asks the next account and rests none.
  - The plan's invalid_media / media_fetch_failed / unsupported_media_type errors become the same kind of refusal.
- The body rewrite strips the reasoning fields and sets image detail to auto.
- A zero-prompt browser sign-in comes first, and a second browser method reuses a pasted key.
  - Neither browser method is offered when no Chromium-family browser is found (#825).
- The /keys calls ride the session cookie, without the pagination query. Key creation retries the console's -15100 "refresh page and retry".
- The #826 metadata token read is kept, and its test is back.
- The fake browser is built once per user and source hash (#824), and the title wait reads only on Windows.
- maxConcurrency is 4.
- The doubled comment line is dropped from every opencode2.mjs copy, agy-cli's included.

Reviewed at 88e66bde, on mote (macOS, Bun 1.4.2) with a temp HOME:
- full bun test: 6853 pass / 0 fail; both checks exit 0
- bun scripts/check.mjs and bun scripts/check.mjs inkstone: exit 0
- 21 hand breaks: 20 red, 1 not caught (the /keys pagination test calls protocol.listKeys directly; follow-up filed)

Not tried: a real InkStone account or sign-in, Windows and Linux runs.
2026-11-07 22:24:56 +08:00
我是一条没有名字的区 e7004d9354 inkstone 0.1.0: Intern InkStone (书生·端砚) Token Plan, browser sign-in, credit card and ink-* key chat (#775)
New package @magpie-community/opencode-inkstone-auth 0.1.0 for Intern
InkStone (书生·端砚, Shanghai AI Lab) Token Plan, provider id
`intern-inkstone`. Community package by yunwang2442-creator.

What it does:
- Browser sign-in (Edge/Chrome, its own profile under
  $XDG_CONFIG_HOME or ~/.config/magpie/inkstone-browser, or
  %LOCALAPPDATA%\magpie\inkstone-browser). The login window has no
  debugging port. A headless CDP read takes the uaa-token cookie, and the
  same read renews it silently later.
- Usage card: ink-credit balance, 5-hour and 7-day windows, credit packs.
- Chat: a pasted ink-* API key, or one the sign-in creates, named
  ink-<host4>-<acct4>-<rand4> (18 of the console's 20 characters). An
  idempotency clash (-15109) retries with a fresh name, up to three times.
  Pruning is on by default. It only touches this machine's and account's
  prefix, keeps the newest two and the key this sign-in created, and never
  deletes manual keys or keys of unknown age.
- Closing on Unix: SIGTERM, then SIGKILL only after a 15s grace. Leftover
  browsers are matched by --user-data-dir=<escaped profile>, and Windows
  uses .Contains().
- The login wait comes from an injected waitForLogin in tests. No env
  hook is left in production code.
- Hosts: discovery.intern-ai.org.cn, discovery-api.intern-ai.org.cn,
  127.0.0.1 (CDP).

Outside the package: scripts/opencode2.mjs lets a prompt with
`required: false` stay optional (`p.required !== false`). Every package's
copy is synced byte for byte, so all 39 copies in the merged tree are blob
afe074cb. No other package sets `required: false` on a prompt, so this
changes nothing for them. Also a root README row and a registry entry.

Review at 36412a15, on mote, HOME=$(mktemp -d), Bun 1.4.2:
- bun test packages/inkstone: 68 pass, 0 fail in Asia/Shanghai, UTC,
  America/Los_Angeles and Pacific/Kiritimati.
- bun scripts/check.mjs inkstone and bun scripts/check.mjs: ok.
- bun test (repo), on 36412a15 merged with origin/main e7cb9dc5:
  6743 pass, 20 skip, 0 fail. main has since moved by cline 0.1.14 and
  zcode 0.1.55 only, and none of the adapter copies changed.
- Broken by hand, each red: no protectName protection; prune_keys default
  off; no post-sign-in prune; no SIGTERM on close; the -15109 retry keeping
  its name.

Not tried: a real InkStone account sign-in on macOS, Linux or Windows (no
account here); a live chat request; magpie end to end with the plugin.
2026-11-07 15:07:06 +08:00
狗带带子 c9bbfd89ff raccoon 0.1.8: read grant bills with type=income so a busy account keeps its Credits window (#789)
raccoon 0.1.8: allBills asks the bills endpoint for type=income first, so a busy account's grants are no longer pushed out of the newest 100-row page by spends. The old unfiltered 1000/5000 read is kept as a fallback when the filter is refused.

Reviewed at 34402598 on mote (HOME=$(mktemp -d), Bun 1.4.2): bun test packages/raccoon 49 pass; bun scripts/check.mjs raccoon ok. Removing the type=income read by hand turns the new test red (balance only, no Credits window). 0.1.8 is the next version after dist's 0.1.7. Not tried: a real Raccoon account. PR CI green.

Reported-by: RedFlagRF, nglsk (#520)
2026-11-06 18:53:28 +08:00
yetone 749e9dd12a raccoon 0.1.7: the balance comes from setting_info when points/v1/balance answers 403 (#520)
xiaohuanxiong.com's /api/web/points/v1/balance now answers 403 to a
signed-in account, the vendor's own web page included (RedFlagRF's
screenshots on #520), and usage threw on it: every account showed an
error and routing read its remaining quota as unknown. RedFlagRF found
that /api/web/office/v3/setting_info still carries data.available_points.

- usage asks balance first and reads available_points from setting_info
  when balance fails or has no number. Balance stays first because
  setting_info is the call the clients make on opening and can hand out
  the day's credits; a usage poll shouldn't do that while balance answers.
- an expired sign-in on balance is still said as expired (and renewed),
  not read again from setting_info.
- if neither carries a number, usage says the error instead of the
  "0 credits" the old `|| 0` would have given.
- entitlement_info answers 403 too (#520): an unread plan is now left
  unsaid instead of reported as Free.

Not changed: the 413 on #520. The plugin passes the vendor's 413 through
untouched, and magpie already treats a 413 as the request's (no account
rests, the next group member is asked, the agent is told
request_too_large to compact; gateway.go's overflow branch). The
vendor's words for it were never captured, so nothing more is known.

Run (mote, bun): packages/raccoon `bun test` 48 pass; `bun
scripts/check.mjs` exit 0. Red on the old index.mjs: the two 403 tests
fail. Broken by hand: dropping the expired rethrow, the `throw first`
and the unread-plan check turns the expired, neither-readable and 403
tests red.
Not tried: a real Raccoon account (we have none). Unauthenticated, all
three endpoints answer 401, so the 403 is per signed-in account.

Reported-by: nglsk
Reported-by: RedFlagRF
2026-11-06 15:43:47 +08:00
yetone 17e5ef7457 all: load on OpenCode 2.x through a default {id, setup} (#657)
nbczw8750 (#657): trae 0.2.26 on OpenCode 2.2.5 fails with "Plugin
must export a default definition with an id and an effect or setup
function. (cause: SchemaError(Missing key at ["default"]))". 2.x
imports a package's exports["."] (a plugin dir and an npm install
alike) and has no V1 path at all, so every package here that serves
models failed the same way, not only trae.

Every one of the 32 model packages now has:
- opencode2.mjs, exports["."]: a copy of scripts/opencode2.mjs, an
  adapter that runs the package's V1 plugins inside 2.x's promise
  API. Config providers become 2.x providers (package pinned so the
  aisdk sdk hook runs), V1 auth methods become integration methods
  (oauth auto/code with forms; api without authorize as a key method),
  V1 credentials are kept in metadata.v1, the loader's baseURL,
  apiKey, headers and fetch are applied through the sdk hook, an
  auth.set renewal is stored per credential, and credential.switched
  /updated reload the account's own model list.
- opencode.mjs, main: re-exports the V1 plugin functions only.
  OpenCode 1.x and magpie's host.js take main. On 1.x, trae 0.2.26's
  main exported a non-plugin (_internal) and 1.19.5 refused it ("Plugin
  export is not a function"); the new main fixes that too.
- both files in "files"; patch version bumped. devin already had 2.x
  and is unchanged.

scripts/check.mjs fails a model package whose 2.x entry has no default
{id, setup}, whose opencode2.mjs differs from the canonical one, whose
entry is missing from files, or whose main exports a non-plugin.

Run at this head (mote):
- HOME=$(mktemp -d) bun test, as CI runs it: 4900 pass, 0 fail
  (4914 tests, 374 files). A first run set globalThis.fetch for the
  whole process from opencode2.test and failed 528 tests in other
  packages; the block is now set and put back around that file's tests.
- bun scripts/check.mjs: every package passes. With the network
  blocked cloudflare-workers-ai fails on its fetched catalog, the same
  on origin/main.
- Real OpenCode 2.2.5 (npm opencode-ai), sandbox HOME, packed trae
  0.2.27: loads with no error; /api/integration lists trae-cn "Trae CN"
  and trae-global "Trae Global" with their browser sign-ins; `auth
  login` starts the trae.cn authorization and waits (cancelled there);
  with a fake credential POSTed to /api/credential, `opencode models`
  lists trae-cn's six models.
- Real 2.2.5 with a fake V1 key plugin through the same adapter
  against a local fake server: `auth login` with a key, `models`,
  `opencode run` reached /real/v1/chat/completions with the loader's
  "Bearer loader-sk-fake" and header, and printed the fake's reply;
  with @ai-sdk/anthropic it reached /real/v1/messages with x-api-key
  from the loader. This run found the key method missing after 2.x's
  second integration transform (a once-only flag outside the
  transform); fixed, and opencode2.test checks a rebuild.
- Real OpenCode 1.19.5, sandbox HOME, trae 0.2.27: `opencode models`
  lists trae-cn and trae-global models; 0.2.26 failed there.

Broken by hand (scratch copy, bun test scripts/ and check.mjs):
- trae's exports back to "./index.mjs": the trae 2.x test fails
  (default.id undefined), check fails trae with "OpenCode 2.x:
  ./index.mjs has no default {id, setup} (plugins#657)".
- zed's opencode2.mjs changed: the copies test fails, check fails zed
  "differs from scripts/opencode2.mjs".
- the key flag back outside the transform: the 1.x plugin test fails
  on the rebuilt sign-ins (key missing).

Not tried: a real sign-in with a real account on 2.x; Windows (the
reporter's OS); chat.headers, chat.params, usage and tool hooks, which
the adapter doesn't carry to 2.x; the tools/pages packages (calc,
goanyapi, layerfs, search1api, aelios, agent-console, chat,
fingerprint, nowledge-mem, kimi-desktop), which still load only on 1.x.
2026-11-03 13:54:26 +08:00
MYCF711 04b4438955 raccoon 0.1.5: the card names the account by its phone, not by Raccoon-pu-<uuid> (#486)
The card names a Raccoon account by its masked phone (cardName), read from
user_info, instead of Raccoon-pu-<uuid>; accountId stays the identity, and a
desktop seat is named by its phone too. A renewal never changes accountId, and
a desktop seat's refresh still gives nothing, as on main.

Reviewed at ac0d84e (round 4). Run on mote (macOS, Bun 1.4.2) in a sandbox
HOME, at that head:
- bun test packages/raccoon: 43 pass / 0 fail
- bun scripts/check.mjs raccoon: ok
Broken by hand: dropping `|| auth.source === "desktop"` from refresh's guard
(index.mjs:1047) turns "a desktop seat's refresh gives nothing, even when
user_info answers a phone" red (42/1), now that its record carries
refresh: "D1". Earlier rounds' breaks (usage's cardName, 0.1.4 record) were
red too.
CI (test, on-npm) green at ac0d84e. Version 0.1.4 -> 0.1.5.
Not changed: a test for the desktop seat picking up a new phone when the
app's token changes (index.mjs:337), optional in the review.
Not tried: a real Raccoon account.
2026-10-29 21:35:33 +08:00
wky114 c00f40eb01 raccoon 0.1.4: read the desktop auth.json in the client profile on macOS and Windows (#459, wky114)
Current Raccoon desktop builds keep the session in a client profile, not in
~/.box-agent, so desktop sign-in answered "not detected" while the app was
signed in (wky114). Raccoon desktop 1.1.3's app.asar (clientProfile.ts)
puts it at <profile>/agent/config/auth.json, the profile being
~/Library/Application Support/office-raccoon on macOS and
%USERPROFILE%\.office-raccoon on Windows. The plugin now reads the Windows
profile, the appData profile, then ~/.box-agent, first file found wins; the
RACCOON_BOX_AGENT_CONFIG_DIR / BOX_AGENT_CONFIG_DIR overrides still come
first. Labels and the not-found error no longer name one path.

Review fixup (cb46111): the PR had only ~/.office-raccoon, which is the
Windows layout, and its test was red at f55d949 (Bun reads homedir() once,
so setting HOME did nothing). desktopAuthCandidates takes home/platform/env
and the tests pass them per OS. Version 0.1.4.

Run at cb46111: bun test in packages/raccoon on mote (38 pass) and on
Windows (38 pass); whole repo bun test on mote (2999 pass, 8 skip);
bun scripts/check.mjs ok. Broken by hand: without the appData profile
both desktop tests are red. Not tried: a real signed-in Raccoon desktop.

Co-authored-by: wky114 <38514103+wky114@users.noreply.github.com>
2026-10-28 15:27:33 +08:00
moxuanchen 1b06308fad raccoon 0.1.3: a desktop seat keeps its own account after the app switches (#320, moxuanchen)
A desktop seat keeps the token it was signed in with, saved on its own record through client.auth.set. It reads the app only to pick up a newer token for the same account. sameAccount requires the read token to carry the seat's uid, so a token without a uid, or with another account's uid, is never used for the seat. Before this, a seat could be billed to the app's current account, and report that account's credits, without anything saying so (#166). The README says what the change guarantees, and that the vendor revokes the previous account's session when the app signs in to another (#166's measurement). The registry summary is back to main's text. Version 0.1.3.

Run at the reviewed head 639da69 (origin/main 532e738):
- packages/raccoon: HOME=<temp> bun test gave 36 pass, 0 fail. bun scripts/check.mjs: all 21 packages pass.
- Broken by hand at b64dc95, each turning a test red: a uid-less read token agreeing (1), desktopSignIn storing access "" (3), no write-back (1), using the app's token for another account (5), ignoring the seat's own expiry (1).
- Broken by hand at 639da69, for the revoked-seat test: the loader retrying a desktop 401 with the app's token (red), and a desktop 401 reported as kept (red). With usage falling back to the app's token on a 401, it stays green, because the stub refuses every token. Other tests cover usage on the normal path (user=AccountA).

Not tried: a real Raccoon desktop app with two accounts. No real accounts were used.
2026-10-22 23:27:46 +08:00
yetone d34f78b69a raccoon 0.1.2: usage reads the whole bill history, not the newest 200 rows (plugins #223)
The bills endpoint ignores paging.offset and always reports total 0, so
it can only be asked for the newest N rows. 200 rows covered under a day
of an active account and left out the large grants a balance is made
of, so the usage card's limit was far too small. queryUsage now asks
for 1000 rows, then 5000 if the first page came back full.

Run: bun test packages/raccoon (30 pass); the new test fails on the old
index.mjs (1 fail); bun scripts/check.mjs raccoon ok; full bun test
1833 pass, 0 fail. Not tried against a real Raccoon account.
2026-10-19 20:46:11 +08:00
lokic7123-star 24b08da95c raccoon 0.1.1: the browser sign-in comes back through a 127.0.0.1 listener (#242, lokic7123-star)
On Windows, with no office-raccoon:// handler registered, confirming the
browser authorization never finished the sign-in: the method was "code" and
asked for a callback URL the browser never reached. The browser method now
uses the authorize page's desktop_callback=loopback contract (checked
against the live page's validator: login_source=desktop, 64-hex state,
http://127.0.0.1:<port>/auth/callback, port >= 1024). A listener on
127.0.0.1 and a random port takes one GET with the exact Host, path and
state, and exchanges the code once. It closes on success, denial, exchange
failure or the 10-minute timeout. The authorize URL is built before
listening, so a bad RACCOON_MAIN_SITE_URL leaves no listener. The pasted
callback/token way stays as method 3; the desktop session stays method 1.

Run at the reviewed head f84c6d0 (merged with origin/main cdf4513), bun 1.4.2, macOS:
- bun test packages/raccoon/: 29 pass, 0 fail; bun scripts/check.mjs: all ok
- HOME=$TMPDIR/pr242home bun test: 1823 pass, 0 fail (1824 tests, 167 files)
- broken by hand, each turns a test red: replay guard (409), Host check,
  state check, URL built after listen. Removing clearTimeout turns nothing
  red; the timer is unref'd and finish() is idempotent, so it has no
  observable effect.
- RACCOON_MAIN_SITE_URL="not a URL" and "http://[bad": browserSignIn
  rejects, lsof shows no listener in the process
- magpie 0.1.1290 plugin host, sandbox HOME, fake `open`: `magpie plugin
  login raccoon` method 1 gives the loopback URL and offers the paste
  fallback. The listener is on 127.0.0.1 only. Wrong Host gives 404, wrong
  state 400, POST 405. A correct-state callback with a made-up code reached
  the real vendor (200035). The CLI failed with "授权码已失效" and the
  listener closed.
- Not tried: a full real sign-in with an account (needs the owner's login).
  The author reports a live Windows round trip in the PR.
2026-10-19 18:06:13 +08:00
yijiemaooo-ux 118cf2edcc raccoon 0.1.0: SenseTime Raccoon (商汤小浣熊) provider plugin (#88, yijiemaooo-ux)
Adds packages/raccoon, @magpie-community/opencode-raccoon-auth, for SenseTime Raccoon (商汤小浣熊, xiaohuanxiong.com).
- Sign-in: through the browser, or reusing Raccoon desktop's live sign-in.
- Lists the models and makes chat requests.
- Reads account credits (balance and bills).
- Runs the daily check-in through auth.checkin, plus the desktop's first-login grant. The grant is marked settled only when the vendor gives a definite answer.

What was run, at the reviewed head 6078f92 merged onto origin/main 4e64f26:
- HOME=$(mktemp -d) bun test packages/raccoon: 21 pass, 0 fail.
- bun scripts/check.mjs: every package ✓, raccoon included.
- Whole repo, HOME=$(mktemp -d) bun test: 1575 pass, 1 fail.
  - The failure was grok's "a login's link is still handed on", a 5s timeout. Another full suite was running on the machine at the same time.
  - The test passed 5 of 5 when run alone.
  - It is filed separately.
- The raccoon code is byte-identical to c068cc5. That head was reviewed line by line on the PR, and every fix was broken by hand to check that its test goes red. 6078f92 only merges main.
- The package isn't on npm yet. magpie serves it from the dist branch until an owner publishes 0.1.0 (scripts/new-to-npm.sh).

Not verified: a real Raccoon account. Only the reply bytes the author captured were used.
2026-10-16 15:00:23 +08:00