Files
plugins/packages/kimi-work/tests
yetone eb54fad5b3 kimi-work 0.1.13: a gone share folder is named, and several Kimi users are served (#444, #440)
#444 (kongbai01203): when the folder daimon-storage.json points to was
moved or deleted, 0.1.12 threw its "sign in again" error with
signIn "expired", so magpie showed "登录已失效" and marked the account,
and signing in again in a running Kimi didn't help. Kimi 3.2.21 makes
<shareDir>/daimon only when it provisions at start, and never falls back
to the default folder while a pointer stands (read from its main
process), so the plugin doesn't fall back either. A missing share folder
is now its own error, kimi_work_share_missing, with signIn "kept": it
names the folder and says to put it back (no new sign-in) or to quit and
reopen Kimi, then sign in to Work. The sign-in callback shows the same
text. A share folder that exists but has no config.json is still the
old missing-sign-in error. The plugin's fetch already fails before any
network call; the ~30s 502 the reporter saw is outside the plugin and
was not looked into here.

#440 (kongbai01203): magpie already keeps a second Kimi user beside the
first (settle tells them apart by uid), but the plugin served only the
user Kimi is signed in to, so the first account failed once Kimi
switched. Kimi 3.2.21 keeps one minted Work key per user in
<daimon>/kimi-code-key.json ({"v":2,"keys":[{userId,apiKey,keyId?}]},
the current user first), keeps an entry when it switches users, reuses
it when it switches back, and drops one only on a 401 (DaimonProvision's
#readKeyStore/#upsertKeyStoreEntry/#resolvePersistedKimiCodeApiKey). An
account Kimi has switched away from now uses its key from that file,
read as Kimi reads it (v 2 only, first entry per user). Its allowance
can't be read (Kimi keeps only the current user's web sign-in), so its
usage card says to switch to it, signIn "kept". No key, or a key the
gateway refuses, is kimi_work_account_not_here, marked signed out. Each
account is named "Kimi Work · <first 6 of its hashed uid>" instead of
the shared "Kimi Work (local)". Not done: rotating between accounts or
falling back on quota, which is magpie's routing, not the plugin's.

Run: bun test in packages/kimi-work (65 pass) and the whole repo with
HOME and TMPDIR in a sandbox under magpie-wt (2879 pass, 3 skip, 3 fail:
cursor upstream-words, commandcode no-magpie and layerfs no-magpie,
which fail because the sandbox path itself contains "magpie"; none of
those packages is touched). bun scripts/check.mjs ok.
Broken by hand: index.mjs at origin/main fails the new share-folder,
reporter's D:\KimiData\daimon-share and two-users tests. In the new
code, dropping the share check reds the two #444 tests; ignoring the
key store reds both #440 tests; taking the last entry per user reds the
key-store test; reading usage for an away account reds the two-users
test.
Not tried: a real Kimi with two users (no Kimi install or Kimi account
on this machine); that a minted key still works server-side after Kimi
switches users is read from Kimi's code (it reuses it after a probe),
not seen. Not tried on Windows.
2026-10-27 23:57:54 +08:00
..