Commit Graph
28 Commits
Author SHA1 Message Date
yetone a30aed0162 provider: the WorkBuddy mover tells two accounts of one nickname apart by uid
wakkana on Discord: WorkBuddy accounts with one display name collapse
into one, deduped by name (wbWho's nickname, addSideLogin's EqualFold).

Where that runs today: WorkBuddy's built-in sign-in is gone, so
addSideLogin no longer writes WorkBuddy accounts. A sign-in through the
plugin goes to the plugin host, whose settle already keeps two accounts
of one name with different uids apart and lets the same uid replace
itself (#413, TestPluginSameNameOtherUID, passes at this head). What was
left by name is the mover, for accounts not moved yet:
- wbLogins dropped WorkBuddy desktop's account when an account magpie
  signed in had the same nickname, whatever its uid (the generic "one of
  magpie's stands for the agent's own" rule). Now it stands for it only
  when the uid matches; one removed in magpie stays out.
- renewedSince matched by name, so the desktop's marker read as the
  other "Me" renewed and the move would never commit. Moving and
  movedAccount carry the vendor's id (WorkBuddy's uid), matched by it
  where both have one; the agent's own is never compared; putBack skips
  by plugin key, not name.
Other movers have no id set, so they match by name as before; their
built-ins name accounts by email or login. The live addSideLogin callers
(Copilot, Google, ChatGPT API) name accounts by login or email too.
Sibling plugin: zcode 0.1.29 (plugins 5c9b7a4) now gives a uid, its
min is raised in a separate commit.

Run on origin/main 1dfa28484 plus this change; rebased onto 180cfb565,
whose two commits touch only internal/redact and the GUI:
go test -timeout 45m -count=1 ./internal/provider ./internal/plugin: ok.
GOOS=linux and GOOS=windows go vet ./internal/provider, gofmt -l: clean.
Broken by hand: TestWorkBuddyMoverSameNameOtherUID is red with
workbuddy.go from HEAD (one account moved) and, separately, with
same() by name only (the other account read as renewed).
Not tried: a real move with two same-name WorkBuddy accounts. Accounts
the old built-in already collapsed are gone; nothing brings them back.
Not run: the whole suite.
2026-10-25 17:42:37 +08:00
yetone 7034378669 zcode: the Start Plan's 405 code 3012 says ZCode blocked the account, and rests it as restricted (plugins#348)
Since 10-24 many ZCode Start Plan accounts get 405 {"code":3012,"msg":
"request has been blocked due to unusual activity."} on every request.
On several of them ZCode's own app (3.16.3) gets the same 405, and
ZCode's support bot calls 3012 risk control on the account. magpie said
"though magpie sends it as the ZCode app does; it can be a network block
of this IP", rested the account as an unknown failure, and asked it again
soon after.

- provider.ZCodeRestrictedHint: the words @magpie-community/opencode-
  zcode-auth 0.1.27 puts after ZCode's own ("ZCode's risk control blocked
  this account for unusual activity (code 3012); it rests, and the
  group's other providers are used. If the ZCode app fails on this
  account too, only ZCode support can lift the block").
- gateway: restrictedSaid reads those words as failRestricted, as
  WorkBuddy's 11140: the account rests restrictedRest (2h), the next
  member is asked, and the Routing page's lift button brings it back.
- Routing page: the hint replaces the old one, in zh, zh-TW, ja and de.
- zcode mover min 0.1.27 (npm view --prefer-online: 0.1.27).

Not proven: why ZCode flags these accounts. Diffed against ZCode 3.16.3's
glm/zcode.cjs: the Start Plan goes unsigned there too (client request
signing is off for zhipu-account start-plan), and the headers match the
plugin's. Not tried with a real blocked account.

Run (sandbox HOME, at this tree): go test ./internal/provider ok;
go test -tags nogui ./internal/gui/... ok; go test ./internal/gateway
-run 'ZCode|Restricted|Blocked|EdgeBlocked|Moved' ok, and the new
TestZCodeStartPlanBlockRestsRestricted is red with routing.go reverted;
go vet darwin, linux, windows on provider and gateway ok; gofmt clean.
GUI (Playwright 1.62.0, chromium + webkit): routing-zcode-blocked,
i18n-keys, routing-blocked, routing-wb-restricted, gui-de, gui-ja,
gui-zh-tw: 41 pass, 0 fail. Not run: the full ./... suite (the machine
had a queue of full suites at load ~120).
2026-10-24 23:42:50 +08:00
yetone b7ceb53fe4 provider: WorkBuddy's built-in is retired; its plugin serves it
workbuddy and workbuddy-ai join retiredBuiltins, as Zed did in c0605abc2
and Qoder in 43cc3171d. @magpie-community/opencode-workbuddy-auth serves
both, moved or not.

Removed (built-in only):
- provider: workbuddy_models.go (the model list); in workbuddy.go the
  sign-in, token renewal, usage/credits reading, request signing and the
  site's model fetch; the WorkBuddy cases in account.go (Accounts),
  logins_on.go, logins.go (list/switch/forget), login_usage.go,
  subscription_usage.go and signin.go; WorkBuddyBaseForTest, now unused.
- The built-in tests: workbuddy_test, workbuddy_signin_test,
  workbuddy_accounts_test, workbuddy_ai_test, workbuddy_body_test,
  workbuddy_enterprise_test, workbuddy_free_test, workbuddy_names_test,
  workbuddy_spare_free_test, workbuddy_refused_test (provider), and
  gateway/workbuddy_refused_test.

Kept, and why:
- migrate_workbuddy.go (the mover) with what it reads: wbSite, wbCreds,
  wbOwn/wbAuthPath (the desktop's file, sent as a marker), wbLogins,
  wbTokens (back drops a renewed pair).
- workbuddy_checkin.go: the daily check-in now walks the plugin's
  accounts only and sends through the plugin's fetch (a.via); wbCallVia,
  wbNum and the site's api() serve it, and plugin_usage's host.
- WBRestricted/WBRestrictedHint: the gateway reads the plugin's 11140 by
  them. textOnly: applied to the plugin's lists.
- draw_workbuddy and search_workbuddy in the gateway: they serve the
  plugin's provider. The PLUGIN-SERVED notice in workbuddy.go.
- The WorkBuddy agent target (internal/agent) is untouched.

Tests changed in meaning:
- TestFetchNewAccount, TestFetchNewRetriedSoon and
  TestFetchingNewOnceStarted used WorkBuddy as the built-in signed in;
  they use Codex now (codexSignedIn, codexListedAt), same assertions.
- TestFetchPlanWithoutList uses local models; TestWorkBuddyFetchModels,
  TestWorkBuddyAIGLMIsTextOnly and TestOwnStoreSignInAgainDropsTheReading
  (WorkBuddy case) are gone with the code.
- Check-in: TestWorkBuddyCheckinSignedIn is gone; the fixture's account
  is a plugin account signing through via; PluginUnderItsOwnID became
  TestWorkBuddyCheckinPluginAccounts (plugin accounts listed, a built-in
  login left out). TestCheckinAccountsListed reads a moved plugin.
- TestWorkBuddyMover seeds the desktop's logins.json row: retired, the
  built-in no longer writes it, and an existing user's row is what moves
  (red without the row).
- Gateway: the WorkBuddy draw and search tests run through the fake
  plugin (besideFake), without the built-in's header checks;
  TestWorkBuddySearchesForItsModels folded into
  TestWorkBuddyPluginSearches (refusal and search-off checks kept);
  TestLoopEndsWorkBuddysReply is the plugin route only;
  TestWorkBuddyRestrictedRestsHours lost its built-in translation case.

Run:
- gofmt -l internal: empty
- go vet -tags nogui ./...; GOOS=linux and GOOS=windows the same: clean
- go test -tags nogui -count=1 -timeout 45m -run 'WorkBuddy|workbuddy|Checkin|CheckIn|FetchNew|FetchingNew|FetchPlan|Migrat|migrat|Mover|Moved|Retired|Retire|SignIn|Plugin|Draw|Search|Loop|Redact|Restricted|Images|TextOnly|Qoder|BuiltinsSay|AsksOwn|Loopback' ./internal/provider ./internal/gateway ./internal/cli ./internal/gui ./internal/qoder
  first run: gateway, cli, gui ok; provider red on TestWorkBuddyMover
  (above); after the fix provider ok (99s).
- Not run: whole packages, the full suite, the GUI node suite.
2026-10-17 23:11:00 +08:00
yetone bbf901570e provider: a WorkBuddy account's spent credits leave its free models counted out, as the plugin does (plugins#138)
hheei (magpie-community/plugins#138): an account at 560 / 560 credits
was ranked spent for deepseek-v4.1-flash too, which WorkBuddy serves at
x0.00 and which draws no credits. The plugin was fixed in 0.1.23
(notModels) and the mover min is 0.1.24 already; the built-in, which
users who haven't moved still run, had the same fault. wbQuota's
personal Credits window and the enterprise window now pass through
wbSpareFree, which scopes them (QuotaWindow.matches) to the models not
marked Free in the provider's last fetched list (catalog.Live). With no
list read, every model counts, as before. The 14018 "Credits exhausted"
rest already rests only the paid model (PaidBesideFree).

Run:
- TestWorkBuddyCreditsSpareFreeModels (new): with no live list the free
  model reads 100%; with one, deepseek-v4.1-flash (either case) reads 0
  while -sg (x0.03) and gpt-5.5 read 100. Broken by hand (wbSpareFree
  returning early): red, "deepseek-v4.1-flash: 100% used, want 0".
- gofmt -l clean; go vet -tags nogui ./... for darwin, linux, windows: 0.
- Full suite: go test -timeout 45m ./... in a sandbox HOME, twice: every
  package ok except internal/gui's TestPanelJoinsFullScreenSpaces ("the
  panel shown doesn't take the keyboard"), which is red the same way
  alone on a fresh origin/main be1030ece worktree; filed as #2450.
2026-10-16 05:21:09 +08:00
yetone 40df6dbd38 provider: a subscription sign-in canceled while its token is fetched adds no account (#2054)
A sign-in checked canceled/finished only when its callback was claimed.
The token exchange after that went on to addLogin / addGoogleLogin /
addSideLogin and only then called finish, a no-op after CancelSignIn, so
a sign-in the user canceled while its token was in flight still added
the account, or replaced an existing account's tokens. Sibling of #1750
(mcpauth's flow.keep, 1a7aa76b4).

Every built-in sign-in's write of its account now goes through one gate:
keepLogin(ctx, store), which finds the flow s.via put on the sign-in's
context and runs store under the flow's lock only while the flow is
live (signInFlow.keep). The CLI-run sign-ins (Claude, Grok, Cursor),
whose context isn't the flow's, call s.keep directly. Cancel takes the
same lock in finish, so either it comes first and nothing is written
(the flow stays "canceled"), or the account is kept and a cancel after
that is too late (kept): the flow then goes on to "done", matching the
account list.

Routed through it: Codex and Devin callbacks (Devin's own credentials
file and its side home), Gemini/Antigravity, ChatGPT API, Claude Code,
Copilot, Command Code (callback and pasted key), Factory, Kiro, MiMo,
Qoder, WorkBuddy, Zed, ZCode, and runCLISignIn's identity (Grok's second
account). Plugin sign-ins are kept by the plugin host and aren't
covered here.

Run:
- TestCanceledSignInAddsNoAccount (Codex: browser callback and pasted
  address, the token endpoint's reply held until CancelSignIn) and
  TestCanceledDeviceSignInAddsNoAccount (Copilot device code, GitHub's
  answer held, read whole, until after the cancel). On the old code all
  three FAIL: "the canceled sign-in wrote ~/.codex/auth.json", "the
  canceled sign-in added cx@example.com", "the canceled sign-in added
  late-user". With the fix they pass, -race -count=5.
- go test -tags nogui -timeout 45m ./internal/provider/... ok (sandbox
  HOME, private GOCACHE).
- gofmt -l clean; go vet ./internal/provider (darwin), GOOS=linux and
  GOOS=windows go vet -tags nogui ./internal/provider ok.
Rerun after rebasing on origin/main f71155591 (#2052, which touches
provider/models.go): gofmt and the three vets ok; the provider suite
(-timeout 45m) ended once in a bare FAIL with no test named, then passed
3 runs in a row (one -v). Filed as #2061. Rebased again on 8da304767:
gofmt, the three vets and the provider suite ok.
Not tried against a real vendor's sign-in.
2026-10-14 08:39:37 +08:00
yetone 7565d93c8b provider: an enterprise WorkBuddy account's card shows its credits, from the enterprise meter WorkBuddy's usage page reads (#1904, CnsMaple)
An enterprise seat's /billing/meter/get-user-resource-summary answers with
no packages, so the card showed no quota. WorkBuddy's own usage page reads
/billing/meter/get-enterprise-user-usage (credit / limitNum, with the cycle's
start and reset in Beijing time). When the summary gives no credits, wbQuota
now asks that meter and shows a Credits window ("196.13 / 2000", resetting at
cycleResetTime). A personal account's refusal there (400 10001 "uid or
enterpriseID is empty", seen on a real WorkBuddy AI Pro account on
2026-10-13) is ignored and the card stays as before. A paid account with
packages never asks it.

Moved users get the same from @magpie-community/opencode-workbuddy-auth
0.1.19 (plugins 169e4e6, on npm); the mover's min is raised to 0.1.19.

Run: workbuddy_enterprise_test.go, built from the reporter's literal
response bytes. TestWorkBuddyEnterpriseCredits and
TestWorkBuddyPersonalNotEnterprise pass, and both fail with the fallback
taken out. go test -run TestWorkBuddy ./internal/provider passes. Not tried
with a real enterprise account; "credit" is read as used, which the
reporter is asked to confirm.

Also run, rebased on e1b70c13d: go test -tags nogui ./internal/provider
(the whole package, 430s) and go test ./internal/gateway -run WorkBuddy
pass under a sandbox HOME; gofmt clean; go vet for darwin, linux and
windows (-tags nogui) pass. The reporter's follow-up (04:27Z) saw
"Credits 218.67 / 2000" on the same enterprise account after reinstalling,
while get-user-resource-summary still answered empty Packages: the
reinstall installed the plugin's 0.1.19, which carries this fallback.
2026-10-13 13:00:04 +08:00
yetone 091593f7d3 gateway, gui: a WorkBuddy account the vendor restricted (403 11140) rests 2 hours as restricted, and Routing names the appeal as the way back (#1849)
WorkBuddy answers an account it restricted for unusual activity with
403 {"code":11140,"msg":"request illegal","displayMsg":{"en":"Your
account has been restricted due to unusual activity",...}}. failure()
read it as an unknown failure, so the account rested 1-10 minutes and
was asked again, refused, all day.

What changed:
- provider: WBRestricted knows the refusal by code 11140 (top level,
  data or error; number or string; whole, so 111400 isn't it) or by its
  displayMsg words. wbExplain ends the built-in's error with
  WBRestrictedHint.
- gateway: a new failRestricted ("restricted") rests restrictedRest, 2h:
  one refused request per account per 2h, and a lifted restriction (or a
  misread refusal) comes back the same afternoon; Unrest lifts it at
  once. It is read from the hint in the error (restrictedSaid; both the
  built-in and the plugin translate the vendor's body before failure()
  sees it, so the raw JSON never reaches it in a chat try), or from the
  raw body only for a WorkBuddy candidate (restrictedRefused,
  isWorkBuddy), since another vendor's 11140 is its own. Bare "request
  illegal" is not matched. 11128 stays promptRefused and rests nobody.
  The stale-allowance shortcut skips it, as it does model refusals.
  drawsWorkBuddy now uses isWorkBuddy.
- plugin: @magpie-community/opencode-workbuddy-auth 0.1.17 (plugins
  caf3908) ends the error with the same hint; the mover's min is 0.1.17
  so keepMovedCurrent brings moved users to it.
- gui: Routing labels the try "account restricted by the vendor", says it
  rests because only the vendor lifting it brings it back and to appeal,
  shows the hint translated, and the account's row has "The restriction
  is lifted — try it again" (POST /api/gateway/unrest). en, zh, zh-TW, ja,
  de.
- docs/subsystems/gateway-routing.md says the above.

Run: gofmt -l (clean); go vet darwin, GOOS=linux -tags nogui, GOOS=windows
on gateway, provider, gui; go test ./internal/gateway ./internal/provider
./internal/gui (ok). New Go tests use the reporter's literal body through
the vendor's shape, the built-in's and the plugin's, a string code and the
words alone; another vendor's 11140, a non-WorkBuddy account with the same
body, 11128/14018/111400 not restricted; an e2e through the fake plugin
host where the restricted account is skipped by the next request.
Broken by hand, each went red: rest case removed, restrictedSaid removed,
the match unscoped, the raw match removed, the provider hint removed.
GUI: routing-wb-restricted (chromium and webkit x en/zh/zh-TW/ja/de x
1100/420px, 20 pass), routing-wb-refused, i18n-keys; after the rebase
every GUI test of the Routing page (107 files, both engines): 103 green.
The 4 red ones fail the same in WebKit on origin/main 689edbd6b run
alone and are filed: group-member-info (#1745), routing-sessions
(#1307, #1672), routing-steady (#1804, passed on this head on a rerun),
routing-group-fold's group-of-eight (#1672).
Rebased onto 2c30e5cee (with #1672's test fixes) and run again: vet x3,
go test ./internal/gateway ./internal/provider ok. On the final base
5756651e3 (only GUI assets and READMEs changed since): routing-wb-restricted
20/20, routing-wb-refused, i18n-keys, routing-held-dot, mono-icon-redraw,
routing-sessions 38/38, routing-group-fold 40/40; routing-steady's WebKit
case red again, the flake filed as #1804.
 Not tried against a real restricted account;
plugin users on <0.1.17 rest by minutes until their plugin updates.
2026-10-13 04:32:09 +08:00
yetone fd03592331 provider: WorkBuddy AI's GLM models are text-only, so magpie's image-describing model reads their images; the plugin to 0.1.16 (Yirasumi on Discord)
What: for workbuddy-ai alone, a model whose id starts with glm- is listed
with ImageInput false (wbSite.textOnly), whatever /v3/config's
supportsImages says: in the list fetched, in the built-in list shown
before it, and in a list saved before this change (Provider.available).
The workbuddy movers' min goes to 0.1.16, where the plugin does the same
(magpie-community/plugins cb90931).

Why: checked on 2026-10-13 with the owner's real WorkBuddy AI account.
www.workbuddy.ai/v3/config marks every model supportsImages: true, but
its server takes the image out of a chat to glm-5.3-flash, glm-5.3 or
glm-5.2 and puts "[System reminder: the current model does not support
images. Content filtered. ...]" in its place. Its other models read
images, and WorkBuddy (China)'s glm-5.3-flash does too, so China and the
other families are left as the config says. A user's own answer in
Settings (ModelImages) still wins: entryFor applies it over the list.

Run:
- go test ./internal/provider (full, ok); go test ./internal/gateway
  -run 'WorkBuddy|WB|Vision|Describ|Image' (ok).
- TestWorkBuddyAIGLMIsTextOnly fails with textOnly turned off by hand;
  TestWorkBuddyAISavedGLMIsTextOnly fails without the models.go case.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- Sandbox gateway (own HOME, port 3486, built-in WorkBuddy AI login from
  the owner's migration backup, nothing live written): /v1/models lists
  glm-5.3-flash, glm-5.3, glm-5.2 as text, deepseek, kimi, gemini, gpt,
  grok with image. A blue|yellow split PNG sent to glm-5.3-flash was
  described by workbuddy-ai/deepseek-v4.1-flash (Routing kind "vision"),
  and glm-5.3-flash answered "left: blue, right: yellow". With
  modelImages {"workbuddy-ai/glm-5.3": true} in the sandbox settings,
  glm-5.3 listed image again and glm-5.3-flash stayed text.

Not run: the moved (plugin) path through a sandbox app; the plugin's own
bun tests cover its list, and magpie maps its input.image as ImageInput.
2026-10-13 02:03:25 +08:00
yetone 3a53d06d99 provider, plugin: a subscription's sign-in goes through the proxy its account's requests use, not always the global one (#1663, demystify0137)
What changed: every sign-in started in magpie now leaves through the
account's own proxy (ProxyOfLogin: the account's, else the
subscription's, else the global one). Before, the sign-in's token
exchange and checks went through the global proxy while the account's
later refresh and usage calls went through its own (ViaLogin), so the
vendor saw one account come from two exits.

- signin.go: SignInOptions{Site, Proxy, User}, StartSignInWith; the flow
  picks its proxy (pickProxy, validated with settings.CheckProxy) and
  every request goes through s.via. Each built-in sign-in (Claude,
  Codex/ChatGPT, Grok, Zed, WorkBuddy, Copilot, ZCode, Factory, MiMo,
  Qoder, Command Code, Kiro) uses s.via; Claude Code's own login gets the
  proxy as *_PROXY (netproxy.EnvWith).
- proxy.go keepSignInProxy: a proxy picked for the sign-in is kept as
  the subscription's when the account is its only one, else as that
  account's own entry. "" (global) is refused while the subscription has
  a proxy and other accounts, since nothing could keep it.
- plugin host: authorize and callback run under via.run(proxy), so a
  plugin's sign-in fetches go through the same proxy; plugins_cli.go
  does the same for `magpie plugins login`. PluginAPIKey goes through Via.
- gui: POST /api/signin and /api/plugin-signin take proxy and user.

What was run:
- go test -tags nogui ./... (sandbox HOME), all packages ok.
- gofmt -l, GOOS=linux and GOOS=windows go vet -tags nogui on the
  touched packages.
- Red without the change (each broken by hand, then restored):
  TestSignInGoesThroughItsProxy, TestDeviceSignInGoesThroughItsProxy,
  TestPluginSignInGoesThroughItsProxy, TestClaudeSignInGoesThroughItsProxy
  (internal/provider) and TestPluginSignInProxy (internal/plugin) each
  fail with the s.via / EnvWith / via.run / keepSignInProxy removed.

Not tried: a real vendor account through a real proxy. The browser's own
leg of an OAuth sign-in goes through the browser's network, not magpie's.
Devin's CLI probes still use the global proxy.
2026-10-12 02:47:08 +08:00
yetone e90f30d99c provider: a built-in account signed in again is read afresh, not answered by the reading kept from the refused sign-in (8c0ffcc6's siblings)
8c0ffcc6 dropped a plugin account's kept usage reading when it signs in
again. The built-ins had the same bug: every sign-in and import keeps its
account through addLogin (Claude, Codex), addSideLogin (Copilot,
Gemini/Antigravity, Kiro, Devin, Grok, ZCode, Zed, Factory, MiMo, Command
Code, ChatGPT API), wbKeepSignIn (WorkBuddy, WorkBuddy AI) or qoderSave
(Qoder, Qoder CN), and none of them touched loginUsageCache.
forgetAccountCaches drops only the Usage page's cards, which are read
again through the same per-account cache, so for up to a minute both
LoginUsage and the Usage page showed the old sign-in's refusal for the
renewed account.

Those four store points now call StaleAllowance for the account under the
name it is kept by (codexName's, WorkBuddy's uid-suffixed name), after
loginsMu is let go, so every sign-in path and import is covered.

Tests, each red on origin/main and each red again with only its own store
point reverted:
- TestCodexSignInAgainReadsUsageAfresh: the browser sign-in twice,
  /wham/usage 401 then 200 ("signed in again, but the usage is the old
  sign-in's: ... Error:Unauthorized")
- TestFactoryKeyAgainReadsUsageAfresh: a key import, then a new key for
  the same account ("... Error:Factory: Invalid API key")
- TestOwnStoreSignInAgainDropsTheReading/{workbuddy,qoder}

Run: the new tests at -count=3 and -race -count=3; go test -tags nogui
./... under a temp HOME with pinned caches, all ok; go vet and
GOOS=linux/windows go vet -tags nogui ./internal/provider.
2026-10-08 14:11:24 +08:00
yetone 1d3ad6ad78 provider: WorkBuddy's check-in reaches the plugin signed in under its own id, workbuddy-plugin (#694, Dazzle-sys: 0.1.774 签到没看到)
The check-in only took the built-in's sign-ins, or the plugin's once WorkBuddy was moved onto it. A user who installed @magpie-community/opencode-workbuddy-auth while also signed in to the built-in (or who moved back) keeps the plugin under "workbuddy-plugin", which HandOver leaves as it is. Those accounts were never checked in, and their Usage card ("workbuddy-plugin") never got a check-in row, because withCheckins answered only for the card "workbuddy".

wbCheckinAccounts now adds the accounts of a plugin signed in under its own id, and each one remembers its card. withCheckins labels any card whose accounts it holds, by account name, or an unnamed card when it holds just one. An account signed in through both the built-in and the plugin (same uid) is checked in once and listed once.

Qoder has no check-in in magpie. It is a moved plugin subscription, so a check-in would have to come from the plugin, not the built-in.

TestWorkBuddyCheckinPluginUnderItsOwnID fails on the old code (only the built-in's Cat is checked in) and passes. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried with real WorkBuddy accounts.
2026-10-04 00:56:37 +08:00
yetone 0d78acd62a gateway: WorkBuddy's plans draw with the image models their config lists (freecss on Discord: let WorkBuddy's subscription image models be magpie's image models) — Settings › Models › image model, the Magpie Image MCP and /v1/images/* now offer a WorkBuddy plan's image models, for the China build (workbuddy) and WorkBuddy AI (workbuddy-ai), built-in or moved onto @magpie-community/opencode-workbuddy-auth. Which models are taken from GET <site>/v3/config, signed as a chat is, by their tags (text-to-image, image-to-image), with no ids written in: today the China desktop sign-in lists hunyuan-image-v3.0-art, WorkBuddy AI gpt-image-2.5-sunburst (which edits too). The list is kept an hour per account (5 min after a failed ask); Drawers answers at once and asks in the background. A drawing goes as WorkBuddy's CLI sends it, to <site>/v2/images/generations or /v2/images/edits in JSON: GPT Image with quality, background, output_format and b64_json; Hunyuan with model, prompt, n and size only; an edit's images as data URLs, to the model itself when it takes images or to its -edit beside it, else a 400 that says the model draws from a prompt only. WorkBuddy's {code, msg, data} is unwrapped (a non-zero code is a 502 with its msg); Hunyuan's COS URL is passed on as the other URL drawers' are. These models are never AutoDrawer's pick, since each image costs the plan's credits. For a moved plan the plugin's fetch signs and sends it: pluginFetch now also takes an absolute URL, only to the plugin base's own host, and Provider.Origin gives a provider's site. TestWorkBuddyDrawsWithItsConfigsModels, TestWorkBuddyAIDrawsGPTImage and TestWorkBuddyPluginDraws (fake upstream: config, generation, edit, envelope error, plugin path, foreign host refused) fail on the old code. Against the owner's real accounts (moved onto the plugin) in a sandbox gateway under a temp HOME: workbuddy/hunyuan-image-v3.0-art drew a 1024x1024 PNG (URL), workbuddy-ai/gpt-image-2.5-sunburst one in b64, an edit of it with gpt-image-2.5-sunburst turned the bird red, and an edit asked of hunyuan-image-v3.0-art got the 400 without a call; no token rotated. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. The GUI's model picker wasn't looked at (nogui sandbox). 2026-10-03 19:55:07 +08:00
yetone 37809ac722 usage: WorkBuddy's credits are said beside their share — on the Routing page, the Usage page and the menu bar, used or left as the share is (#659)
Moody-Sin: the Routing page showed a WorkBuddy account as "已用 71%" only, which for a plan counted in credits says little. A quota window now carries its own count when the vendor counts in amounts — amount of limit, in unit (QuotaWindow, QuotaSpan for quota --json and /v1/magpie/quotas, and the routing trace's Weighed, from the window its share is of: Allowance.Count). WorkBuddy's built-in fills it from the resource summary, and @magpie-community/opencode-workbuddy-auth 0.1.8 tells it from auth.usage (amount / limit / unit, passed through host.js); the workbuddy mover's min is 0.1.8. The Routing page's stage and its list of what each account did, the Usage page's meter, the menu bar's tooltip and the TUI say "3,550 / 5,000 credits · 71% used", or "1,450 / 5,000 credits · 29% left" with Left on (积分 in Chinese); a window counted in shares alone reads as before.

quota-credits.test.cjs (WebKit, en/zh, used/left, Routing and Usage pages) fails on the old assets and passes; TestQuotaWindowCount, TestAllowanceCount, TestTraceTellsTheCount, TestPluginUsage (the count through the host) and TestWorkBuddyAccounts cover the Go side. Tried with the real WorkBuddy and WorkBuddy AI accounts in a sandbox magpie: moved onto the local plugin, /api/usage/quotas gives 33.29 / 3900 and 13.47 / 2250 credits and the Usage page reads "33.29 / 3,900 积分 · 已用 0.9%", "3,866.71 / 3,900 积分 · 剩余 99.1%" after a click on the count; not moved, the built-in gives the same for WorkBuddy. The Routing page with two real accounts of one provider wasn't tried (one account each). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass.
2026-10-03 16:45:48 +08:00
yetone fa9daa6945 docs: every built-in subscription a plugin serves once moved says so in its code, and AGENTS.md says where a fix for it goes (user: 对内置的订阅 provider 在代码层面和文档层面加上注释,防止又有别的 agent 在改内置订阅 provider 的代码而不知道生效的其实是对应的插件代码) — a moved Cursor, Devin, Grok, Command Code plan, Kiro, Zed, Qoder, Factory, Xiaomi MiMo, ZCode or WorkBuddy (provider.Moved; since v0.1.642 also the default for a new sign-in, provider.Adopt) is signed in, listed, requested and metered by its @magpie-community plugin, and none of the built-in's code in internal/provider/<name>*.go, internal/gateway/<name>.go, internal/zed or internal/qoder serves it; a fix made there alone never reaches those users. Each of those files now opens with a PLUGIN-SERVED notice naming the subscription's id, its plugin package, where the plugin lives (magpie-community/plugins, packages/<name>) and the mover whose min to raise so moved users get the fixed plugin (keepMovedCurrent); Qoder's adds that Qoder CN isn't moved and still runs there. AGENTS.md (CLAUDE.md imports it) lists the moved built-ins with their packages and movers, how to tell whether a user's is moved (move.state "plugin", onPlugins), the order a fix goes in (the plugin, publish, raise min, the built-in only for those not moved), the magpie code that does run for a moved one (internal/plugin, plugins.go, plugin_usage.go, pluginsignin.go, migrate*.go, app.js's subOf/pluginSubs/startPluginSignIn), and the parity tests. movers in migrate.go and SUBS in app.js point there too. TestMovedBuiltinsSayTheirPlugin fails for a mover whose code carries no PLUGIN-SERVED notice naming its id and package (it failed while a wrapped package name was split). Comments and docs only, no behaviour changed. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass (TestProvidersAnswerWhileListsComeIn and TestClaudeSignedOut failed once on their timing under load, pass alone; untouched). 2026-10-02 19:37:02 +08:00
yetone 2a6ba1a20f workbuddy: an added account is told from the others by its uid, and the one WorkBuddy is signed in to stays once WorkBuddy moves on (#413: 添加已提前登录的 WorkBuddy 账号会顶掉默认第一个账号) — magpie matched a new sign-in to a listed account by its name, the nickname: another account of the same nickname replaced the one listed, or was taken for WorkBuddy's own and let go with "signed in". And WorkBuddy's own account is only read from WorkBuddy's file, so signing WorkBuddy in to the next account (to pick it on WorkBuddy's page from magpie) renamed that row, the last account gone, and the one picked, being WorkBuddy's own, was let go: one account at a time. A WorkBuddy or WorkBuddy AI sign-in is now matched by its uid (one of the same name whose uid isn't known is still taken to be it, #155); another account of the same name is added as "name (end of uid)"; the same account renews its sign-in where it is listed, and the one WorkBuddy is signed in to becomes magpie's own sign-in of it, first as it was, so it stays when WorkBuddy signs in to another. The sign-in says so: "该账号已在列表中,已更新登录" in the app, "is already listed — its sign-in was renewed" from magpie accounts add. On the plugin, the host no longer takes two sign-ins of one account id for one account when their uids differ. No request header or user agent changes. TestWorkBuddyAddSameNicknameAsOwn, TestWorkBuddyAddSameNicknameTwice, TestWorkBuddyAddWhatWorkBuddyIsSignedInTo, TestPluginSameNameOtherUID and signin-again.test.cjs fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; signin-again, click-scroll, old-webkit pass. 2026-10-01 19:38:36 +08:00
yetone 4a0fbc332c plugins: a built-in moved onto its plugin looks and works as it did (你确保插件版的订阅 provider 和其对应的内置的…都保持一模一样了吗?) — moved onto its plugin, a built-in lost pieces: its tile's name, icon, plans and risk note went to the plugin's own, "Add account" still opened the built-in's sign-in (in the app, on the server and in magpie accounts add), an agent's own sign-in the built-in still found showed a second usage card of the same account, the account's plan badge went, WorkBuddy's daily check-in stopped, the provider's icon and site were the plugin's, WorkBuddy AI's card was named WorkBuddy, and Devin, which had no card of its own, lost the plugin's. Now a moved built-in keeps its tile and risk sheet and signs in through its plugin; its cards take the built-in's place and name, and it has none of its own; the plan the plugin tells stays with the account; WorkBuddy checks in through the plugin, which signs the call; a card is left out only where its built-in's slot showed it. TestMovedBuiltinQuiet, TestWorkBuddyCheckinThroughPlugin, TestMoveToPlugin (Devin-like card) and TestPluginUsage (plan kept) fail without the change. Command Code and Devin moved and back in a sandbox HOME: one card each, plan, name. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; plugin-move, plugin-signin, commandcode-risk, old-webkit pass; click-scroll's WebKit fails the same on origin/main under this load. 2026-10-01 00:40:22 +08:00
yetone 6168bd1a18 workbuddy: its "Illegal API invocation from an unapproved channel" says what to do (QuentinHsu on Discord, deepseek-v4-flash on WorkBuddy from Codex) — WorkBuddy, both builds, refuses a chat whose system prompt is Codex's or Claude Code's (#182), whatever the headers, and magpie does not rewrite that prompt. The refusal now carries "WorkBuddy refuses chats from Codex and Claude Code (their system prompt); use it from Hermes, OpenCode or Pi, or add another provider to this group", to the agent and on the Routing page (apart from the vendor's words, in the page's language); a group still passes the request on to its next member. workbuddy_refused_test (provider, gateway) and routing-wb-refused.test.cjs (Chromium, WebKit, en/zh) fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; click-scroll, old-webkit and the routing tests pass. 2026-09-30 17:41:16 +08:00
yetone 6546033109 kiro: removing kiro-cli's or the Kiro IDE's own sign-in hides it in magpie, and it shows again when Kiro signs in anew (Discord 碳碳双键: 本机没安装 kiro,但旧的 Kiro 数据还在,magpie 列出一个"Kiro account"(登录已失效,请重新添加此账号),添加新账号并设为首位后,旧的数据无法移除) — magpie reads Kiro's own sign-in from kiro-cli's database or ~/.aws/sso/cache and lists it among the accounts it signed in; Remove on it said "that is kiro-cli's or the Kiro IDE's own sign-in; run kiro-cli logout or sign out in the IDE", which with neither installed left a dead account there for good. The same refusal was shared by every agent whose own sign-in magpie only reads (forgetSideLogin: Kiro, Devin, Grok, Copilot, ZCode, WorkBuddy and WorkBuddy AI, Command Code, Gemini CLI, Antigravity). Now Remove on the agent's own sign-in hides it: logins.json's entry for it keeps a Hidden mark, and it is left out of the account list and so of the gateway's tries (the first and the ones behind it both come from that list); the agent's files are never deleted or written. It shows again when that sign-in changes: for Kiro, by a mark that is a digest of where the sign-in is (kiro-cli's row or the IDE's file) and its refresh token (never the token itself), so a new kiro-cli login or IDE sign-in, to any account, brings it back; for the others, which have no such mark, when it is another account. Removing it while it is first is allowed now, the next account being put first (saved, so it stays first when the own one comes back); removed when it was the only one, the agent has no account left. One of magpie's own accounts is removed with its home as before, and still can't be while it is first. The error and its per-agent sign-out hints are gone. Logins carry own, and the accounts list shows Remove on the agent's own sign-in also while it is first, its title "magpie stops showing and using Kiro's own sign-in; its files are left as they are, and it shows again when Kiro signs in anew" (magpie 不再显示和使用 Kiro 自己的登录;它的文件保持原样,Kiro 重新登录后会再次出现). Tested with a new internal/provider/side_logins_hide_test.go in a sandbox HOME: an expired kiro-cli sign-in ("Kiro account") behind a Google one magpie signed in is removed, stays gone across reads, isn't the account used nor among AlsoOn, kiro-cli's database byte-for-byte and mtime as it was, the refresh token nowhere in magpie's files; a new kiro-cli sign-in brings it back behind the one first; put first and removed, the next is first; one of magpie's removed takes its home and leaves the other's; the only account removed leaves Kiro with none; Grok's CLI sign-in hidden with auth.json untouched, back once it is another account. The agents' tests that expected the refusal (Command Code, Copilot, Devin, Grok, WorkBuddy, ZCode) no longer do. A new internal/gui/tests/own-signin-remove.test.cjs in Chromium and WebKit, en and zh: kiro-cli's sign-in behind another and alone first both have Remove with that title and post login/forget, magpie's first account has none. go build -tags nogui (and GOOS=linux, GOOS=windows), go test -tags nogui ./... and the whole GUI suite (138) pass. Not tried with a real Kiro, kiro-cli or the Kiro IDE. 2026-09-29 23:52:33 +08:00
yetone c348903159 workbuddy: a chat with no system prompt is sent with one (Jerry lee on Discord: 没有 system 消息时报 first message is not system prompt) — WorkBuddy refuses a chat whose first message isn't the system prompt, which scripts and plain chat clients often send; such a chat now starts with a neutral "You are a helpful assistant.", the rest of the body kept as it was, and one that already starts with a system prompt goes as it is. The comment on WorkBuddy AI's client headers no longer says they fixed "unapproved channel": that answer comes from Claude Code's and Codex's own system prompts (#182). Tested on the account's request body, through the provider as signed in 2026-09-29 11:40:00 +08:00
yetone 2715696138 workbuddy: WorkBuddy AI chats carry the rest of the headers its own client sends (lightyear, Jerry lee on Discord: deepseek flash 提示 API error:400 workbuddy AI : illegal API invocation from an unapproved channel) — on the international build deepseek-v4.1-flash was refused as "from an unapproved channel" while GPT and Claude answered. WorkBuddy AI's desktop app lists what its /v2/chat/completions gateway needs ("x-requested-with 是网关的准入约定"), and its CLI sends the same on every chat: X-Requested-With: XMLHttpRequest, X-Agent-Intent: craft, X-Agent-Type: main, X-IDE-Name and X-IDE-Version, and conversation, message and request ids; magpie sent none of them. WorkBuddy AI chats now carry them; the China build, which serves that model already, is left as it was. Tested against a fake gateway that the headers and ids go out; not yet checked against WorkBuddy AI itself 2026-09-29 10:43:22 +08:00
yetone 93d74d2b81 workbuddy: requests are streamed to it, Test's too (#124: 测试 400 · Non-stream chat request is currently not supported, 对话正常的) — WorkBuddy refuses any request that doesn't stream, so its Test, a small non-streaming request, failed with 400 while agents, which stream, answered. A WorkBuddy account is now a backend that only streams: Test sends it stream:true, and the gateway streams it a client's non-streaming request and gives the client one answer, as it does Codex's and Google's. Tested: Test's request to such a backend streams on each endpoint, and a non-streaming chat request through the gateway to a fake upstream that refuses one comes back as one chat.completion 2026-09-29 10:01:21 +08:00
yetone 44fd12dfe8 subscription: WorkBuddy AI, the international build, is its own subscription (Workbuddy国际版的Subscription是否也要支持呀?… 你应该新加一个Subscription Provider叫做Workbuddy国际版) — workbuddy-ai, "WorkBuddy 国际版 (WorkBuddy AI)" under 订阅. From WorkBuddy AI.app 5.6.2's product config: the same API as the Chinese build at its own endpoint, https://www.workbuddy.ai (isOversea, externalDomain www.codebuddy.ai / www.workbuddy.ai), signed in with platform=workbuddy-ai; its own account is read, never changed, from workbuddy-desktop-ai.info beside workbuddy-desktop.info in CodeBuddyExtension's auth folder, others kept in logins.json apart from the Chinese build's. Its models are its own (the Fast/Balanced/Primary/Deep tiers, GPT-5.5/5.4/5.3-Codex, Gemini 3.1 Pro/3.5 Flash, GLM-5.3/5.2, Hy3, Kimi-K3/K2.6, MiniMax-M3) until /v3/config is read; credits from the same resource summary. workbuddy.go is now parametrised by a wbSite (CN, AI); token cache keyed by site and uid. Checked live: auth/state at www.workbuddy.ai answers and magpie opens https://www.workbuddy.ai/login?platform=workbuddy-ai (200); chat and usage not tried against a real international account. 2026-09-29 00:31:45 +08:00
yetone bb7ce5ec31 provider: an account signed in from magpie is listed even when the agent's own sign-in of it can't be read (tinysnake: workbuddy 登录以后,对应的 provider 并未出现) — once WorkBuddy's own account had been seen, logins.json remembered it as WorkBuddy's own (no secrets). With WorkBuddy then signed out, or its tokens kept encrypted ({"$wbEncrypted":…}), that entry is hidden, and signing the same account in from magpie was taken for a duplicate of it and dropped (addSideLogin): the sign-in said done, the toast showed, and no WorkBuddy provider appeared. addSideLogin is now told who the agent is signed in to right now; only when that is the same account is the new sign-in a duplicate, otherwise the remembered entry takes the new sign-in, and sideLogins doesn't add the own account twice once it's back. Copilot, Grok, ZCode and Gemini had the same flaw through the same code and are fixed with it. The window no longer says "added" when a finished sign-in isn't in the Providers list: it says so as an error. Tested with a fake WorkBuddy sign-in server in a sandbox HOME (own account remembered, then signed out or encrypted, then signed in from magpie: listed and signing with the new token; WorkBuddy readable again: still one account); not tested against the real WorkBuddy, and whether the reporter's WorkBuddy was signed out or encrypted isn't known 2026-09-28 21:38:02 +08:00
yetone 9eccb96a51 provider: ZCode's and WorkBuddy's models take the reasoning levels their apps offer them (当然要做) — ZCode's from its modelRules' reasoningLevel (disabled is none; enabled, GLM-5-Turbo's one level, is high): GLM-5.3 low/high/max, GLM-5.2 none/high/max; WorkBuddy's from its config's reasoning.supportedEfforts, with none only where its CLI offers thinking off (deepseek-v4-pro): hy3 low/high, glm-5.2 high/xhigh, kimi-k3-1 low/high/xhigh, and a model it gives no levels still takes any. The written-in lists carry them too. gateway: Z.ai's GLM-5.2 and GLM-5.3 are asked their effort in output_config.effort beside thinking on, as ZCode asks them, built or passed through and fitted to their levels — a budget alone left them at their default: tested live, budget_tokens 4096 thought 4.8k–7.6k chars, output_config low 0.9k 2026-09-28 18:56:04 +08:00
yetone e8eb7078db provider: ZCode's and WorkBuddy's plans list the models their apps offer now, not a list written into magpie (我觉得一定有API来查询动态的模型列表) — ZCode's come from its built-in provider config, which zcode.z.ai names (/api/v1/client/configs → a release on cdn-zcode.z.ai) and ZCode also ships and caches: the later revision of those is read, as ZCode does, the coding plan's models taken from its providerRules and builtinProviderModelRules (bigmodel.cn's plan its own), and each one's context, output limit and images from the modelRules that match it; WorkBuddy's come from its product config, GET /v3/config signed as a chat, asked with the CLI's User-Agent (CLI/<v> WorkBuddy/<v>; a bare WorkBuddy/<v> gets CodeBuddy IDE's config), its cli agent's models with their names, input and output limits and images — Kimi-K2.8-Preview is there now, and Auto is 256k. The written-in lists are what shows before the first read. Tested live against both with the accounts signed in here 2026-09-28 18:26:07 +08:00
yetone 6294dd0ac5 provider: WorkBuddy usage shows up — send a WorkBuddy User-Agent and read string capacities (workbuddy 订阅的usage能显示出来吗)
copilot.tencent.com's gateway answers 10085 '请求不合法' to a request whose
User-Agent it doesn't know, so the resource-summary meter came back rejected
and the credits window stayed empty; every call to it — chat sign included,
not only billing — now goes out as WorkBuddy/<version>. And the meter sends
its capacities as JSON strings ('3300', '438.88000002'), which wouldn't
unmarshal into float64, so a wbNum type parses either a string or a number.
Verified against the live API (GET /console/accounts + POST
/billing/meter/get-user-resource-summary both 200 with the account's real
credits) from app.asar 5.5.6.
2026-09-28 17:40:12 +08:00
yetone 5741e3fc95 provider: WorkBuddy credits are at /billing/meter/... — not /v2
The get-user-resource-summary meter, unlike the older /v2/billing meters,
has no /v2 gateway prefix; WorkBuddy's own client asks it at
/billing/meter/get-user-resource-summary on both desktop and web. magpie
was asking under /v2 and would have gotten nothing, so no credits showed.
2026-09-28 17:30:39 +08:00
yetone 9687f3d297 provider: WorkBuddy is a subscription — Tencent's CodeBuddy plan, signed in as WorkBuddy does, its own account read too
WorkBuddy (CodeBuddy Code's desktop app) keeps its signed-in session in
<shared data>/auth/workbuddy-desktop.info, plain JSON while credential
protection is off (its default); magpie reads that account, never writes
it, and skips it when the tokens are encrypted at rest. Further accounts
are signed in with WorkBuddy's own external-link flow (auth/state, then
auth/token polled until ready, then login/account) and kept in
logins.json. The plan is served OpenAI-compatibly at copilot.tencent.com
/v2 under the account's access token, with its id and domain in headers
(X-User-Id, X-Domain), exactly as WorkBuddy sends them; a near-expired
JWT is refreshed as WorkBuddy does, and a magpie-signed-in one's refresh
is written back beside it while WorkBuddy's own file is left untouched.
The models are its CLI agent's coding picks, and the credits come from
its resource summary as one window.

A card in Providers' subscription list signs in and shows the accounts;
the Provider is one of the account ids and joins the usage rollup.
2026-09-28 16:31:11 +08:00