real-jacket (#330): one DSH task on qoder/dfmodel made 265 calls in 55
minutes, then Qoder answered 429 "Billing daily count exceeded". qoderBody
made every call a task of its own: request_set_id = chat_record_id =
request_id, a new business.id, begin_at = the call's own time and stage
"start" on every call.
What Qoder's client does, read (read-only) from the installed Qoder.app's
qoder-agent-sdk worker (dist/_worker/qoder-worker-runtime.obf.mjs):
- AgentLifecycle.create runs once per user prompt (driveQuery), with
requestSetId = the prompt's requestSetId, else a preallocated one, else
randomUUID(); business = {product, version, type, id: the prompt's
requestSetId || randomUUID(), name, begin_at: Date.now(), stage: "init"}.
- changeBusinessState() moves init -> "start" right after create, so the
first call goes with "start", and start -> "processing" after each
answered call (it runs after the error check of a model reply).
- The chat body per call: request_id = chat_record_id = a new id,
request_set_id = the lifecycle's requestSetId, business = the
lifecycle's businessInfo. A retry renews request_id/chat_record_id only.
The plugin now keeps a task per session and last user turn (taskOf): one
UUID for request_set_id and business.id, one begin_at, stage "start" until
a call of it is answered, "processing" after; request_id/chat_record_id
stay new per call. A new user prompt is a new task. Tasks are an LRU map
held to 512 entries, each dropped 2h after its last call.
session_id: the plugin now has a chat.headers hook (as cursor and trae
do) that passes the session magpie hands it (provider.ConversationHeader,
which is DSH's x-deepseek-harness-session-id when DSH sends it, or another
agent's own session header; OpenCode's session in OpenCode) to its fetch
in x-magpie-qoder-session, which never goes to Qoder. session_id is its
hash; magpie's "magpie-<hash>" fallback names no session and the old hash
(prompt_cache_key, user, system + first user turn) stays the fallback, so
a DSH system prompt changing mid-task (yetone/magpie#3298) no longer
splits the session. The hook acts on its own site's provider only.
Run: in packages/qoder, TMPDIR=$H HOME=$H/home bun test: 201 pass, 0 fail
(task.test.mjs 6 new). Repo root, same sandbox: 2311 pass, 0 fail.
bun scripts/check.mjs qoder ok. Broken by hand, task.test.mjs red each
time: per-call request_set_id/business.id/begin_at (2 red), session_id
ignoring the named session (2), stage always "start" (2), no LRU/TTL
eviction (1), the hook unscoped to its provider (1); on origin/main's
index.mjs all 6 are red.
Not tried: a real Qoder account (none used) or a capture of the official
client's wire bytes. Whether Qoder's "Billing daily count" counts by
business.id / request_set_id is not known: the change makes the calls
look as the official client's do, it does not prove the count drops.
Not changed: Qoder's client also reports the end of its prompt to
/api/v2/service/ask/finish and sends a shorter model_config; the plugin
still doesn't.
witt-bit (yetone/magpie#2911, 10-22): after Qoder CN's update moved its
daily 100 Credits into the desktop's 权益中心, magpie's Qoder CN check-in
stopped working; Andrew0767 (#304) sees the same with Qoder desktop
installed. The plugin sent Qoder CN's campaigns pages no device identity
at all ("Qoder CN does not need this local helper").
What Qoder CN's clients do, read from their own packages:
- Qoder CN desktop 0.4.9 (the .deb's out/main): its requests carry
Cosy-ClientType 10 and, through createAuthorizedHeaders, the identity
from <resources>/umid/runtime-info run with environment
`regionCode === "global" ? 3 : 0`, i.e. 0 for Qoder CN, the uid on
stdin (--account-stdin) on macOS and Windows. Campaigns are found
through GET /sash/api/v1/me/notifications (hasClaimableCampaign,
campaignPopupUrl). When the identity can't be read it sends the
request without it (resolveMachineIdentity's catch returns null).
- qoderclicn (@qodercn-ai/qoderclicn 1.1.64, 1.1.70, 1.1.73):
campaigns.list is GET /sash/api/v1/me/campaigns, needing the UMID from
1.1.64 and requireMachineIdentity() from 1.1.70, UMID environment
ONLINE = 0; its config dir is QODERCN_CONFIG_DIR, else QODERCN_CLI_HOME
(or home) + QODERCN_CONFIG_DIR_NAME (or .qoder-cn), and it caches the
helper in <config>/.bin/runtime-info-<platform>-<arch>-<hash>.
- Install places: Qoder CN.app/Contents/Resources/umid/runtime-info
(seen inside Qoder-CN-Installer-mac-arm64.zip's payload, 0.4.9),
/opt/Qoder-CN/resources/umid/runtime-info (the .deb), and on Windows
umid/runtime-info.exe among Qoder-CN-win-x64-user.exe's owned files,
with "Uninstall Qoder CN.exe" (electron-builder's
%LOCALAPPDATA%\Programs\<productName>; the folder itself not seen).
The plugin now keeps a runtime per site (RUNTIMES): Qoder CN reads its own
helper (those paths, its CLI's folders, QODERCN_RUNTIME_INFO, never the
international Qoder's) with environment 0, and sends Cosy-MachineToken and
Cosy-MachineType on the list, the claim and the campaigns proxy. As the
desktop does, a Qoder CN request without a readable identity still goes
out, so an account that was claiming without Qoder CN installed (0.2.21's
live PAT claim) keeps doing so. When such a list offers no daily claim,
the check-in is ineligible for the day, saying to install Qoder CN desktop
or sign in to its CLI (no helper), or failed and asked again (a helper that
didn't answer), instead of "inactive". International Qoder is unchanged.
Run: in packages/qoder, TMPDIR=$H HOME=$H/home bun test: 195 pass, 0 fail.
On the old index.mjs the new tests are 9 red (checkin.test.mjs 5 lookup
tests and the env-0 proxy test, native-checkin.test.mjs the env-0 claim,
the ineligible and the failed cases). Repo root at this commit
(rebased on 26e3e5f): 2151 pass, 1 skip, 0 fail; bun scripts/check.mjs ok.
Not tried: a real Qoder CN account (none available) or a real Qoder CN
install, so whether Qoder CN now hides the daily claim from a request
without the identity is inferred from its clients, not seen on the wire;
the Windows install folder is electron-builder's default, not seen; the
desktop's own claim happens in a remote page (campaignPopupUrl) whose
calls weren't seen, so the list/claim pages stay those of 0.2.21;
Cosy-MachineCode, which both Qoder CN clients send, is not sent.
Version 0.2.29 is open PR #319's (QwenWork).
wallance (Discord, magpie latest, qoder 0.2.27): Qoder's free deepseek
flash (dfmodel) through magpie ended in 503 "Qoder queued the request for
dfmodel (this plan's queue: p3); try again in 30s" after 27s, while Qoder's
own client answered the same model, slowly. magpie's gateway retries a
Retry-After of 8s at most, so the 30s was the agent's error.
What Qoder's client does, read from Qoder.app 0.4.3's
qoder-agent-sdk/dist/_worker/qoder-worker-runtime.obf.mjs ("[ModelQueue]"):
on a 10605 or a queue state it asks
GET <api>/algo/api/v2/service/ask/queue/status?requestSetId=&modelKey=&queueType=
(signed as any GET, X-Request-ID and X-Session-ID), at once and then every
retryAfterSeconds held to 0.5..30s (30s unsaid), while isQueued is true or
serviceAvailable false. Once isQueued is false it waits that state's
retryAfterSeconds and sends the same chatAsk again (same request_set_id),
up to 10 times; 3 failed status asks in a row, a 404 or a state with
neither field end it. It waits up to an hour (QODER_MODEL_QUEUE_MAX_WAIT_MS),
and tells /api/v2/service/ask/finish at the end of its turn, best effort
("server TTL will release the lease").
The plugin now does that, under a 4-minute budget from the request's
start: nothing reaches the agent meanwhile, and magpie keeps a stream's
agent alive with SSE comments for 5 minutes of silence (keepQuiet,
keepaliveLongest). Past it, the 503 with Retry-After as before, so magpie
may ask another account. A cancelled request stops the wait and sends
nothing more. The status path's /algo prefix follows the client's other
paths (it signs "/api/v2/model/list", the plugin calls
"/algo/api/v2/model/list").
Run: HOME=$(mktemp -d) bun test in packages/qoder, 185 pass; at the repo
root, 2114 pass, 0 fail, at 7fdc07f plus this change; bun
scripts/check.mjs ok. queue.test.mjs (10 tests) is 10 of 10 red on the old
index.mjs. busy.test.mjs now pins the budget to 0: its cases are Qoder
still queued once the wait is over.
Not tried: a real Qoder account (no credentials used), so the status
endpoint's reply and its /algo path are taken from the client's code, not
seen on the wire. Not done: the finish call (its body goes through the
client's wasm signer, which the plugin can't confirm), and request_set_id
is still per request where Qoder's client keeps one per turn, so each
request of an agent's turn may queue on its own.
On a machine that never had Qoder desktop or Qoder CLI, the international
daily check-in failed with "device identity runtime not found" and magpie
showed "签到失败,magpie 稍后重试", asking again every 30 minutes all day.
It can't succeed: Qoder lists the daily CLAIM_BENEFIT only on a request
carrying Cosy-MachineToken/Cosy-MachineType, and those come from Qoder's
own signed runtime-info helper (#49 showed the list without them has no
claim). The plugin never computes or invents that identity, so without
the helper there is nothing to send.
What changed:
- campaignRuntime throws RuntimeMissing when no helper is found anywhere;
auth.checkin answers it with outcome "ineligible" (settled for the
Beijing day by magpie, asked again the next day) and a message that says
to install Qoder desktop, or install Qoder CLI and sign in once, or set
QODER_RUNTIME_INFO. "ineligible" is the plugin hook word Trae's 9074
already uses for "check in in the vendor's app"; own-app is not a hook
outcome (magpie's provider-plugins.md).
- A helper that exists but fails or gives an invalid identity is still
"failed" and retried. The fetch path (campaign) keeps its 502, now with
the clearer message. Qoder CN is unchanged (it needs no helper).
- README: the daily check-in section says the above.
What was run (at bb020ce, origin/main fetched just before; no new commits):
- HOME=<temp> bun test in packages/qoder: 175 pass, 0 fail (15 files).
- bun scripts/check.mjs qoder: ok. node --check, git diff --check: ok.
- New test "no Qoder on this machine is ineligible…": with main's
index.mjs put back by hand it fails (Expected "ineligible", Received
"failed"); with this change it passes. The second new test pins that a
present-but-unreadable helper stays "failed".
Not tried: a real account on a machine without Qoder (this Mac has
Qoder.app; the test hides every path through a stat spy instead). Not
tried: fetching Qoder's helper the way qodercli caches it into
~/.qoder/.bin, which would let check-in work without the user installing
anything; that needs qodercli's download source, not read here.
#290 (Codex side session on Ultimate read 0% from cache). Qoder's own
client (qoder-agent-sdk in Qoder.app 0.4.3, qodercli 1.1.75) sends, on
every agent_chat_generation request:
- cache_control {type: ephemeral} on the last non-thinking, non-tool
block of the last message when it is a user turn (none when the last
turn is tool results);
- each user turn's blocks as `contents` beside `content`;
- request_id / chat_record_id / request_set_id per request and a stable
session_id per conversation.
The plugin sent none of that, and gave a tool call without an id a new
random id on each request, so the prefix changed every turn. Now:
- cacheMarked() marks as above, without touching the caller's turns;
- session_id is a UUID-shaped sha256 of prompt_cache_key (Codex's
thread, which magpie forwards) or else of the system text and first
user turn; the key itself never goes out;
- an id-less call's id is sha256(turn, place, name, arguments).
Check-in (accomplish on Discord, 10-21: Qoder intl can't check in, CN
can). Only the international site needs Qoder's runtime-info helper;
on Windows only %LOCALAPPDATA%\Programs\Qoder was searched. A
machine-wide install under %ProgramFiles%\Qoder is now found too. This
is one possible cause, not a confirmed one: the reporter's error text
and OS are unknown.
Run at this tree (rebased on 15d536a):
- HOME=$(mktemp -d) bun test in packages/qoder: 173 pass, 0 fail.
- Red on the old index.mjs: 3 of 5 cache.test.mjs tests (marker,
session, stable call ids) and the new Program Files test.
- cn.test.mjs's exact-shape assertion updated to the marked last turn.
Not tried: a real Qoder account (no hit-rate measurement on Ultimate
or Fast), a real Windows machine-wide install, accomplish's account.
SITES.qoder asked qoder.com's device page for redirect_uri=qoder-app://,
the desktop app's own scheme (Qoder.app's Info.plist registers qoder and
qoder-app). On a Mac with Qoder.app installed the page's last hop opened
the desktop app instead of staying in the tab, while the plugin polls
openapi.qoder.sh for the device token and needs no callback at all.
Qoder's own clients treat the parameter as optional: Qoder.app's
app.asar adds redirect_uri only when its config has one
(authRedirectUris: stable qoder-app://, canary qoder-canary://), and
Qoder's CLI (@qoder-ai/qodercli 1.1.75, bundle/qodercli.js) builds
/device/selectAccounts from challenge, challenge_method, nonce,
machine_id and client_id alone, then polls /api/v1/deviceToken/poll.
qoder.com now gets the same: no redirect_uri, as qoder-cn already does.
cn.test.mjs's "qoder.com's sign-in is as it was" pinned the bug
(redirect_uri == qoder-app://); it now checks there is none.
Run:
- packages/qoder: HOME=<scratch> bun test: 167 pass, 0 fail.
- Broke it by hand (redirect back to "qoder-app://"): the #276 test in
cn.test.mjs fails (Expected false, Received true), 11 pass 1 fail.
- Repo root, as CI: TMPDIR=<scratch> HOME=<scratch>/home2 bun test:
1919 pass, 1 skip, 0 fail across 173 files; bun scripts/check.mjs ok.
Not tried against a real Qoder account here. The reporter (asuan-dev)
says the same one-line change on 0.2.21 signed in three accounts and
left the page on "Sign in success".
SlouchyQuill507 (Discord, qoder-cn) reported Qoder failures of the model's
own vendor, "Error in upstream response", reaching magpie as a 400 invalid
request: the client's fault, never asked again or of another account.
failure() now maps a message saying "Error in upstream response" to a 502
(no X-Magpie-Sign-In, the account untouched), after the queue, quota and
request codes, so a 400 with one of Qoder's request codes (406, 416, ...)
and any other 400 stay 400. It covers an HTTP 400 and a 400 in the
stream's statusCodeValue envelope, JSON or plain text. magpie still tells
an overflow that fails this way apart by its size (tooLongUnsaid takes 502
as well as 400).
Test: usage.test.mjs "Qoder's 400 \"Error in upstream response\" is a
502" - fixtures from the reported literal text, four shapes through the
loader's fetch, plus genuine 400s kept. Red on the old index.mjs (400 for
each), green with the change.
Run on origin/main 6fd976a: TMPDIR=<scratch> HOME=<scratch>/home bun test
(whole repo) 1919 pass 0 fail across 173 files; bun scripts/check.mjs ok.
Qoder CN offers the PAT sign-in too (its /api/v1/jobToken/exchange takes a
personal_token as qoder.com's does; the prompt names qoder.cn's console),
and a PAT account, which has no device token, signs the campaigns pages and
the daily check-in with its job token instead of rotating a device token it
doesn't have. The account keeps the name its browser sign-in takes
(email || uid), so a renewed PAT sign-in replaces its lapsed row.
Run at d7db9f2b987c46cbf100cda9d89a8a546e374fb6:
- bun test packages/qoder: 155 pass, 0 fail; bun scripts/check.mjs passes.
- The PR's check-in tests go through the loader's campaigns fetch, not
auth.checkin. Two local tests calling auth.checkin with a PAT account
(qoder and qoder-cn: claimed on the job token, no deviceToken refresh;
a 403 is "failed", not rotated) pass on this head and both fail with the
checkin hook's change reverted by hand. They follow on main.
- Probe: POST openapi.qoder.com.cn/api/v1/jobToken/exchange with an
invalid pt- token answers 400 BadRequest, as openapi.qoder.sh does (an
unknown path answers 401), so the endpoint exists on CN and a bad PAT
maps to "refused the PAT". qoder.cn/account/integrations redirects to
sign-in, as qoder.com's does.
- Not tried: a live qoder.cn PAT exchange, chat or claim; that rests on
the author's live run.
README sections for WorkBuddy and Qoder on why a request can be refused
while the account still shows credits. They cover:
- the exact model id versus the display name;
- WorkBuddy 5.6+'s encrypted desktop sign-in and the browser route around it;
- 11140, the restricted account (magpie#1849);
- Qoder's 10605, a queue answer, not a lapsed sign-in (#185, 0.2.18);
- a CLAIMED check-in that is not a new grant (magpie#2696).
This is docs only. Reviewed at 76cfb6d: two README files, +66 lines,
no code. Checked each claim against the source:
- packages/qoder/busy.test.mjs exists;
- workbuddy usage.test.mjs covers sign-in, usage and chat against a sealed
desktop file, and asserts the file is unchanged;
- magpie's `plugin use` and `plugin list` exist (internal/cli/plugins_cli.go);
- magpie#2696 is the open native-check-in cache issue.
bun scripts/check.mjs qoder and workbuddy both pass. No version bump.
Adds auth.checkin to Qoder and Qoder CN. It lists the account's campaigns and claims a CLAIMABLE CLAIM_BENEFIT campaign, and the list and the claim go through the plugin's own campaigns path: device token, one rotation on 401/403, VPC host and native machine identity. The outcomes match magpie's built-in qoder_checkin.go:
- a CLAIMED campaign is done only while its startAt/endAt window is open;
- a daily campaign that is neither claimable nor active-claimed is failed, so it is asked again later;
- no daily campaign at all is inactive;
- a list or claim reply that can't be read is failed, never inactive or claimed.
The credit is the claim's own benefit.amount, else the campaign's. Bumps the package to 0.2.17.
Reviewed head 128ed2a. Ran at that head:
- bun test in packages/qoder, sandbox HOME/TMPDIR: 127 pass, 0 fail
- git merge-tree onto origin/main: clean
- PR CI: test and on-npm pass
- read every line of the checkin hook against magpie's internal/provider/qoder_checkin.go. The campaign shape and its seconds-based startAt/endAt match the real campaign JSON in qoder_checkin_test.go.
A <tool_call> block whose JSON wasn't whole ({"path":}) was reprinted as
text, and one the stream ended inside was flushed as text; either way the
turn finished "stop" with a 200, the call lost and nothing to fail over on.
Mirrors trae since 0.2.5 (#38): a block on its way to being a call (its
content starts with "{" or holds "<function=") that can't be read, or is
cut short at the end, ends the turn as an error: the stream with the error
frame and no finish, a request not streamed (or one with nothing before the
block) a 502. A block whose JSON (or XML function) is whole when the stream
ends without its close is still the call. A tag in a code fence or inline
code, or one that isn't call-shaped (<tool_call>incomplete), stays text.
Siblings: only trae (already fixed) and qoder parse calls out of the text;
grep for tool_call/function=/invoke/DSML across packages/*/index.mjs finds
no other parser.
Run at this head:
- textcall.test.mjs (new, the issue's literal frames: closed with bad JSON,
stream ends inside, readable control, whole JSON without its close, XML
form, look-alike text; streamed whole and 3 chars per frame, and not
streamed): 7 of 9 red on the 0.2.15 code (the control and look-alike
tests passed there), all green after.
- packages/qoder: 118 pass, 0 fail.
- Whole repo as CI runs it: HOME/TMPDIR in a scratch dir, bun test:
1320 pass, 0 fail; bun scripts/check.mjs: ok.
Not tried against a real Qoder account; the frames are the reporter's.
failure() turned every 401/403 into "the sign-in lapsed — sign in again".
Qoder answered every chat on a real trial account (2026-10-12) with
403 {"code":"10605","message":"{...\"retryAfterSeconds\":30,
\"serviceAvailable\":false...}"}: its queue for the model, while the same
token read the models and usage.
Codes are now read as Qoder's own client reads them (the QoderErrorCode
table in Qoder.app's qoder-agent-sdk worker), whatever the HTTP status:
- 10605, or a queue state with isQueued or serviceAvailable false: 503
with Retry-After from retryAfterSeconds (30 when absent), no
X-Magpie-Sign-In. magpie's gateway counts a 503 as busy and asks again
after Retry-After (patience.go busy/noteBusy).
- 110, 112-119, 122 (usage/credits used up): 429.
- 406, 416, 430, 80411, 80412, 100400-100403 (refusals of the request): 400.
- 105 (loginExpired) or no code: the 401 as before.
Both the HTTP status path and the in-stream statusCodeValue path go
through failure(); errorResponse sends Retry-After.
Run: bun test (sandbox HOME) 1137 pass 0 fail; bun scripts/check.mjs ok.
busy.test.mjs uses the literal body as testdata; its 4 tests all fail
against the previous index.mjs and pass with this one. Not tried: a real
10605 after the change (the account's queue was open again by then: a
real chat on fast answered "ok"); the quota and request codes' HTTP
status from Qoder is not seen, only their meaning from Qoder's client.
Qoder's model listing (/algo/api/v2/model/list) has a list per scene. The
plugin read only "chat", while its requests are sent as Qoder's app
(product and session_type "app"). On 2026-10-12 the app scene lists Fast
(key fast, 0.8×) where chat still lists Performance (1.1×), so magpie
showed Performance and never Fast, which Qoder's app shows (yygutn, #97).
The models hook now lists the app scene in its order and adds each model
only chat still lists after the model it follows there, so a pick of
Performance stays served. Each key once; the app's entry wins. A listing
with one scene gives that one. New app models show from the account's
own listing without a plugin release. The fallback list gains Fast.
Verified:
- The real listing read through the plugin on the owner's Qoder account
(sandbox HOME, credential copied in memory, nothing written, no token
renewed): fast "Fast" rate 0.8 and performance rate 1.1 both listed.
- models.test.mjs runs on that real listing (testdata/listing.json, the
chat and app scenes); all 4 tests fail with modelInfos put back to
listing.chat, and pass with the change.
- bun test (sandbox HOME/TMPDIR): 1133 pass, 0 fail. bun scripts/check.mjs ok.
Not verified: a real chat on fast. Every model on that account (fast,
performance, efficient, qfmodel) was refused with 403 code 10605
(serviceAvailable false, queueType p3, retryAfterSeconds 30) though the
trial has 143/300 credits; the plugin reports that as a lapsed sign-in,
filed separately. Qoder CN's listing wasn't read (no CN account).
0.2.9 (#49) looked for the CLI's cached runtime in ~/.qoder/.bin/umid-<platform>-<arch>-*/ on every platform. qodercli 1.1.66 (npm) and the worker in Qoder desktop 0.4.3 (extractBinary) make that folder only on Windows (umid-win32-<arch>-<hash>\runtime-info.exe with sgsdk.dll); on macOS and Linux they write a file, ~/.qoder/.bin/runtime-info-<platform>-<arch>-<hash>. And the Linux desktop installs to /opt/Qoder/resources/umid/runtime-info (Qoder 0.4.3's .deb and .rpm), which wasn't looked at. So a macOS user with only the CLI, and every Linux user, got HTTP 502 on the international check-in, while Qoder CN (which needs no runtime) checked in.
campaignRuntime now looks at /opt/Qoder on Linux, reads the CLI's cache as the CLI writes it (the newest matching file, a .tmp being written skipped), and follows the CLI's own folder settings (QODER_CONFIG_DIR, QODER_CLI_HOME, QODER_CONFIG_DIR_NAME). Windows and macOS desktop lookup is unchanged.
checkin.test.mjs lays out the CLI cache as qodercli writes it on win32/x64, darwin arm64/x64 and linux x64/arm64, plus /opt/Qoder and the config-folder variables: 6 of the new tests fail on 0.2.9 (the Windows case passes on both, as 0.2.9 had it right), all pass now. bun test packages/qoder (87 pass) and scripts/check.mjs qoder under a temp HOME pass. On this Mac the real lookup returns /Applications/Qoder.app/Contents/Resources/umid/runtime-info. Not run: the runtime itself against a real account, or on Linux/Windows.
A new method, Sign in with Qoder CN Enterprise (VPC), asks for the
instance (its name or <instance>.vpc.qoder.com.cn) and serves the account
from the instance's own hosts: <i>.vpc.qoder.com.cn for the sign-in page,
<i>-openapi.vpc.qoder.com.cn for poll, tokens, user info and usage, and
<i>-gateway.vpc.qoder.com.cn for models and chat, the paths unchanged, as
@qodercn-ai/qoderclicn 1.1.64 rewrites the public origins once a VPC
instance is set. The instance is kept on the account; an account with
none is served as before, and one with an instance that names none is
asked to sign in again rather than sent to the public hosts.
Not tried with a real VPC account. vpc.test.mjs builds its fixtures from
AwadYoo's redacted shapes on #312; 12 of its 13 tests fail on 0.2.7 (the
one that passes is the public sign-in staying as it was). bun test
packages/qoder: 67 pass; HOME=$(mktemp -d) bun test: 864 pass; bun
scripts/check.mjs: all pass.
auth.refresh with refreshLead 10 minutes (in-fetch: 5) for qoder and
qoder-cn: the job token through refreshJob, or a qoder-cn device-token chat
through refreshDevice (both pairs given). Under the request path's lock; a
spent map lets a request holding the old pair use the new one. 401/403 is
signIn "expired" as on the request path; anything else is retried.
The check before each request stays for OpenCode, which doesn't call the
hook (magpie 0.1.684+ does). refresh.test.mjs fails without the change;
HOME=$(mktemp -d) bun test passes (396 across the repo).
Hosts, client id and paths read from Qoder CN's own CLI (@qodercn-ai/qoderclicn 1.1.65): sign-in on qoder.cn, accounts on openapi.qoder.com.cn, models and chat on gateway.qoder.com.cn, client id e883ade2-…; signing unchanged. The same as magpie's built-in Qoder CN. When qoder.cn refuses a job token the account chats on its device token, renewed through /api/v1/deviceToken/refresh, as the CN CLI does. cn.test.mjs (12 tests, a local server standing in for every host) covers sign-in, polling, both tokens' refresh, a chat, models, usage and qoder.com unchanged; 6 fail with the CN chat host pointed back at api3.qoder.sh or the fallback off. Version 0.2.0.