hupeak (#1196): ZCode 3.18 writes credentials.json's values as
"enc:v2:os:<…>:<…>". decrypt reads enc:v1 alone, so the jwt read as
null and the card said "this sign-in has no ZCode session: sign in
again", which signing in again can't fix: ZCode writes enc:v2 again.
The new form looks bound to the system's own key store (the "os"
part); this change doesn't try to read it.
- A ZCode app sign-in that finds values in an enc: form other than v1
fails with "ZCode 3.18 keeps its sign-in in a new form this plugin
can't read yet: add the account with a Z.ai or BigModel sign-in",
instead of "ZCode isn't signed in on this computer".
- An account signed in "as ZCode" before has the same words on its
card's gift line. A browser sign-in, or enc:v1, keeps the old words.
Run (mote, HOME=$(mktemp -d)):
- bun test packages/zcode: 272 pass, 0 fail.
- bun scripts/check.mjs zcode: ok.
Broken by hand: origin/main's index.mjs (with giftSignIn exported) and
the new test: 1 fail, the sign-in says "ZCode isn't signed in on this
computer".
Not tried: ZCode 3.18 itself (not installed here); the stored values
are the shape the reporter showed. Reading enc:v2 is not done; #1196
stays open for it.
ZCode's app sign-in reads oauth:active_provider and includes zai_cn, so
a China-channel account keeps its name and user id, follows renewal for
the same user, and stays on its own session when the app switches to
another user with the same display name. Unreadable active_provider
falls back to the old order with zai_cn added.
Reviewed at 5d6e923e3. Run (mica, sandbox HOME): bun test packages/zcode
260 pass; scripts/check.mjs zcode ok. Broken by hand: main's index.mjs
with this PR's tests fails 3 of own.test.mjs (China identity, active
zai_cn, active bigmodel).
Co-authored-by: Lucentio-Huang <Lucentio-Huang@users.noreply.github.com>
provider.models read the "as ZCode" sign-in without located(). ZCode
3.16 keeps only where the coding plan key is (project-key-location:v1,
#410), so the state had no key, plansOf took it for a Start Plan
sign-in, and the list was account:zai-start-plan's: GLM-5.3 left out
and delisted, while requests and usage (which call located) worked.
models() now reads the key first, as the request path does. A key that
can't be read throws, so magpie keeps the list it had instead of being
told the Start Plan's.
Reported, with the cause and this fix, by dinghao-8.
Run (TMPDIR/HOME sandboxed, Bun 1.4.2):
- bun test in packages/zcode: 135 pass, 0 fail; bun scripts/check.mjs
exit 0.
- Broken by hand: the new own.test.mjs case against main's index.mjs
fails with exactly the reporter's list, [GLM-5.3-Flash, GLM-5.2,
GLM-5-Turbo].
- npm had 0.1.32; this is 0.1.33.
Not tried: a real ZCode 3.16 account (reading ZCode's credentials needs
the Keychain secret); the reporter ran the same one-line patch end to
end against BigModel.
ZCode 3.16.3 on a Mac keeps no coding plan key in credentials.json or
config.json, only a project-key-location:v1 record
({organizationId, projectId, apiKeyId}, encrypted like the rest). With no
key, plansOf sent the account to the gift and the BigModel GLM Coding Plan
never showed (meraki7304).
ownSignIn now reads that record (the account's own: team null, coding
plan, the profile's user id, the family ZCode is on first), and located()
reads the named key's secret from api_keys/copy/{apiKeyId} with the OAuth
token, as ZCode lists keys (BigModel bare, Z.ai as a Bearer). Only GET:
nothing is created. The record's origin is used only when it is an https
z.ai / bigmodel.cn host, else the site's own API. A 404 leaves the sign-in
as before; another failure says sign in again. Request fetch and usage
resolve it before plansOf.
Record format and auth forms read from ZCode 3.16.3's own app.asar
(ProjectAccessTokenClient / project-key-location:v1).
Run: HOME=$(mktemp -d) bun test in packages/zcode, 119 pass;
bun scripts/check.mjs ok.
Red on old code: the new own.test.mjs case fails with the old index.mjs
(key "" and start true).
Not tried: a real ZCode 3.16 account (no vendor credentials used); the
reporter's read-only check of the same endpoints is the evidence.
wakkana on Discord reported WorkBuddy accounts of one name collapsing
into one. WorkBuddy's plugin already keeps a uid, which magpie's plugin
host tells same-name accounts apart by. ZCode names an account by email,
else by its name, and gave no uid, so two ZCode accounts with no email
and one name were one account in the host. Both sign-ins (browser and
the ZCode app's) now give uid: user_id. The app's entry also follows
ZCode only while ZCode is signed in to the same user id, not another
account of that name.
Run: HOME=<scratch> TMPDIR=<scratch> bun test in packages/zcode, 112
pass. Both new tests (own.test.mjs, team.test.mjs) fail with index.mjs
from HEAD (uid undefined). bun scripts/check.mjs green.
Not tried: a real ZCode sign-in; whether ZCode's poll user carries
user_id is read from who(), which already reads it.
What changed: ZCode 3.15 keeps no coding plan key in credentials.json any
more. The key it uses is in config.json, at provider["builtin:bigmodel-
coding-plan" / "builtin:zai-coding-plan"].options.apiKey; ZCode 3.15.3's
host reads that value as it is. ownSignIn found no key, so a signed-in
GLM Coding Plan account fell to the Start Plan and read as having no plan.
ownSignIn now falls back to config.json (configKey) when credentials.json
has no key: Z.ai's first, then BigModel. It also takes the provider ids
3.15 normalizes to (account:*-individual-coding-plan) and a value written
encrypted. A value that isn't a key, such as "{env:...}", is skipped. A key
in credentials.json and a team switch still come first. This matches
magpie's built-in (magpie 1d8e83a79, zcodeOwn/zcodeConfigKey).
What was run:
- The new own.test.mjs case uses the reporter's layout (BigModel sign-in,
no key in credentials.json, key in config.json). It fails without the
fallback ("j1" in place of "bm.secret").
- Every packages/zcode test file passes under a scratch HOME/TMPDIR:
dual 25, gift 20, models 1, moved 1, own 6, signin 3, start 10, usage 15.
- bun scripts/check.mjs passes.
Not tried: a real ZCode 3.15 account.
The app's sign-in stores the account ZCode is signed in to, and stateOf
read ~/.zcode/v2 again for every request. After ZCode switched to account
B and the app's sign-in was added again, both entries read B's
credentials: A's sent B's requests and its usage card showed B.
stateOf now follows ZCode's own credentials only when ZCode's user is the
entry's accountId. Otherwise (ZCode signed out, or on another account) it
uses the snapshot saved at sign-in, which holds the coding plan key, the
Start Plan JWT, the team project and the device. A snapshot whose JWT has
run out says EXPIRED (sign in again), as a lapsed sign-in already did,
instead of borrowing B's session.
own.test.mjs: two app sign-ins (A, then B) with ZCode on B; A's request
carries A's key and no request (messages, plan, usage) carries B's key or
JWT; and A with only an expired JWT says sign in again without sending
B's. Both fail on 0.1.15 (A sent idB.secretB; the expired case was served
with B's JWT). The first test now keeps the account's user_info as ZCode
signs in again. HOME=$(mktemp -d) bun test packages/zcode: 79 pass.
bun scripts/check.mjs zcode passes.
- workbuddy: 'Illegal API invocation from an unapproved channel' ends in the hint magpie's built-in added (provider.WBRefusedHint), where magpie's routing page finds it; models with credits x0.00 carry free: true
- zcode: a new sign-in, "ZCode app's sign-in", reads ~/.zcode/v2 (credentials decrypted as ZCode keeps them, setting.json's team plan) for every request, as magpie's built-in did; magpie moves ZCode's own account marked source: zcode