7b42e404f5f656d7bfb4aa5c7ddbcd1031264a86
13
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
00642d4c6b |
kimi-work 0.1.17: Work's fast output speed, as K3.1 Pro Fast and a Fast switch (#728)
Kimi Work's "High" output speed is a speedOption of a model in the signed-in Work menu. A model whose option has `speedValue: "fast"` and `available: true` gets a `-fast` row ("K3.1 Pro Fast") and magpie's Fast switch (`service_tier: priority`). A request on either goes out with `X-Kimi-Model-Speed: fast`, the header Kimi's own desktop client sends. The menu is now read with the membership sign-in magpie renews, and the unsigned menu never offers fast. A `-fast` suffix comes off only ids the plugin listed itself.
Header checked against the vendor's client. Kimi 3.2.24 macOS was downloaded from kimi.com's own download link, a Developer ID build from Beijing Moonshot Technology (2J9472RW75); dmg sha256 e40df5954aacdfe69f5e56f9d679ef86a7d25f9134769ffe1b7ea382c77ca8fd. In its app.asar:
- `out/renderer/assets/common-DLYgMFK1.js` builds request headers with `x&&(a[uy]=x),t&&(a[fy]=t)`, where `uy="X-Kimi-Context-Length"` and `fy=c(2634)`.
- Decoded with a decoder of our own (the string table is read as data and rotated to the bundle's checksum; no vendor function was run): `c(2634)="X-Kimi-Model-Speed"`.
- The value comes from `DM`: the chosen speedOption's `speedValue` (`c(1967)`), from options the account can select (`"select"`).
- `kimi-agent-Dw2t9ioO.js` passes it as `modelSpeedHeaderValue` into `llmRequestHeaders`, and the daimon bundle carries `llmRequestHeaders` into the turn.
- No wire capture: not taken by the author or by the review.
Run at 69adea99 on a macOS box:
- `bun test packages/kimi-work`: 103 pass, 0 fail.
- `bun scripts/check.mjs kimi-work`: ok.
Broken by hand, each red:
- header value "fast" changed to "high": 1 fail;
- `available===true` dropped: 4 fail;
- header name changed: 1 fail.
The six breaks from the earlier round, at 45dd499 (code unchanged since, comments only), were each red too.
Not tried: a real request from this review's side (no Kimi Work account here), a lower-tier account's menu, and what a fast request costs.
|
||
|
|
280d522830 |
kimi-work 0.1.15: renew membership tokens and keep existing accounts (#218)
Explicit sign-in now imports Kimi desktop's membership access/refresh pair when the desktop has one, and magpie renews it through the host's auth.refresh (conditional commit under the auth-store lock). Accounts saved through 0.1.14 (reference-only, no pair) keep reading the desktop's web token for usage, with no reconnect, no import and no refresh spent. The usage card is one monthly meter, with Code's share as text. Request-body reads follow the caller's abort signal. Kept from main (0.1.11 to 0.1.14): callback errors split into no session / Work 401 / HTTP-timeout-network (#425), per-uid account ids `Kimi Work · <uid6>` (#440), share-folder-missing as kept (#444), spent-quota 403 -> 429 (#465). Reviewed head 96f7f52501082e4747ef649d836d955a8ece3f4c, merged onto origin/main |
||
|
|
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. |
||
|
|
a9779ef864 |
kimi-work 0.1.12, kimi-desktop 0.1.4: Kimi's sign-in is read where daimon-storage.json points (#425)
Kimi 3.2.21 on Windows, installed on another drive than %APPDATA%'s,
keeps daimon-share at <install drive>\KimiData\daimon-share and writes
%APPDATA%\kimi-desktop\daimon-storage.json ({"version":1,"shareDir":...})
to point there. It writes the same pointer on any system when the user
moves its storage. Both packages read only
%APPDATA%\kimi-desktop\daimon-share, so the sign-in was "not found".
Read from Kimi's own code: Kimi-Setup-3.2.21.exe's app.asar,
out/main/index.js (string table decoded): the shareDir getter is
readPointer(userData) ?? join(userData, "daimon-share"); the pointer
reader takes an absolute shareDir and otherwise the default; the
"install-drive seed" writes the pointer on win32 when installRoot's drive
differs from userData's; driveDataDirName is "KimiData".
Both packages now follow the pointer the same way (unreadable, non-JSON
or non-absolute -> default, as Kimi does). kimi-work's sign-in failure
names the file it looked for, and a failed Work check (network, HTTP)
no longer says no sign-in was found.
Run at this tree (base
|
||
|
|
1fbe22b3ad |
kimi-work 0.1.11: a usage read that fails says why on the card and keeps the Work sign-in
泠夜Soul (Discord), latest magpie and kimi-work 0.1.10: the Kimi Work
usage card says only "暂时无法获取额度", with no error anywhere.
Cause: auth.usage threw on every failure. magpie puts a plugin's reason
on the card only when usage returns it as `error` (quotaOfPlugin sets
PluginError; app.js quotaError then says "暂时无法获取额度:<why>"). A
thrown error reaches the card as the bare text, with the reason in a
tooltip. The read uses Kimi's web sign-in (credentials.kimiWeb.accessToken),
not the Work token chat uses. Kimi desktop 3.2.20 rewrites that token in
daimon config.json only while it runs (its token-change sync). Once the
desktop is closed, www.kimi.com answers it 401 "Session expired"
(REASON_INVALID_AUTH_TOKEN), the same stale token 0.1.10 found on the
menu. That 401 was thrown as expired() with signIn "expired", so magpie
also marked the Work account signed out while chat still worked. The
header changes in 0.1.8-0.1.10 aren't the cause: signed out or with a
bad token, GetSubscriptionStats answers the same 401 with or without the
x-msh headers. Their effect with a valid token wasn't seen.
What changed:
- usage never throws on a failed read. It returns
{windows: [], error, signIn: "kept"}. A 401 says
"Kimi 网页登录已过期,打开一次 Kimi 桌面版即可刷新额度(对话不受影响)",
in words that magpie's signInGone doesn't take for a lapsed sign-in.
Other statuses keep their HTTP code. Each failure is logged without the
token.
- subscriptionBalance is read in camelCase or snake_case. A balance
whose amountUsedRatio Connect JSON left out (zero) reads 0% used.
Before, that gave no window at all. A reply with no balance says so.
Field names are from the desktop's membership.v2 descriptor:
subscription_balance is optional in GetSubscriptionStatsResponse.
Run at this tree (origin/main
|
||
|
|
8d687ad519 |
kimi-work 0.1.10: a menu the web sign-in can't get is asked again without it, so K3.1 Pro stays listed
泠夜Soul (Discord) is on 0.1.9 and still has no K3.1 Pro (k3d1-agent),
with no error and nothing in the log. 0.1.9 was checked only against
the menu signed out.
What was found: provider.models asks the menu (DescribeKimiWorkConfig,
with credentials.kimiWeb.accessToken from Kimi's file) and agent-gw's
/models together, and a failed menu ask was dropped without a word:
the list was then /models' alone, k3-agent and k2d8-preview, which is
exactly the report, on 0.1.7 to 0.1.9 alike. www.kimi.com answers a web
sign-in it doesn't take with 401 "unauthenticated", "invalid user
token" (REASON_INVALID_AUTH_TOKEN), seen on 10-24 with a malformed and
a badly signed token; signed out it answers 200 with the desktop menu.
So a stale kimiWeb token in Kimi's file (the desktop closed, or it
renewed it elsewhere) takes K3.1 Pro away silently. That this is the
reporter's case is not proven: no signed-in account here.
What changed:
- The menu, when the signed-in ask fails (any HTTP status, a timeout,
or a reply with no models), is asked again without Authorization, as
the desktop asks it before signing in, with the same x-msh-* headers.
That reply is the desktop menu, K3.1 Pro first. agent-gw requests and
usage are unchanged; nothing is retried there.
- Each failure is written to the log (console.warn, so magpie's plugin
stderr): which ask, and its status or reason, never the token.
- jsonRequest's errors carry the HTTP status, and leaves Authorization
out when given no token.
- no-magpie.test's fake menu is now the captured desktop menu: an
empty one is asked twice now, which its request count would miss.
Run at this tree (origin/main
|
||
|
|
df552949e1 |
kimi-work 0.1.9: the menu is asked with the desktop's headers, so K3.1 Pro (k3d1-agent) is listed
泠夜Soul (Discord) has a Kimi Work membership whose desktop picks
K3.1 Pro, model id k3d1-agent, and magpie's Kimi Work list leaves it
out, on 0.1.7/0.1.8 too, which read DescribeKimiWorkConfig for this.
Cause, seen on the live endpoint (it answers without a sign-in):
DescribeKimiWorkConfig chooses the menu by the caller's x-msh-* headers.
Asked with none, as the plugin asked it (only User-Agent kimi-code-cli),
it answers with the web menu: k3-agent, k3-agent-swarm, k2d8-preview.
Asked as the desktop asks it (x-msh-platform mac or windows, as Kimi's
Connect interceptor sends from the desktop, with x-msh-version), it
answers k3d1-agent "K3.1 Pro", k2d8-preview, k3-agent. Five tries each,
stable. So the menu code was right and its reply was the web's.
What changed:
- www.kimi.com/apiv2 calls (the menu and GetSubscriptionStats, as the
desktop's interceptor puts them on every apiv2 call) carry
x-msh-platform (mac on macOS, windows on Windows, web elsewhere, as the
desktop's own rule), x-msh-version 3.2.20 (the desktop build 0.1.8's
headers came from) and R-Timezone. agent-gw's headers are unchanged.
- A menu row's reply limit is its requestParams.maxTokens (32768 for
every model listed today, the value that was hard-coded).
- tests/fixtures/work-config.mac.json and work-config.web.json are the
two literal replies, captured signed out on 10-24. The new tests have a
fake that answers as the server does (desktop menu only for mac or
windows) and check that k3d1-agent is listed as "K3.1 Pro" with
low/high/max, 262144 context and 32768 output, on darwin and win32.
Run at this tree (origin/main
|
||
|
|
8310fd2e77 |
kimi-work 0.1.8: Kimi gets the headers its own Work client sends, not "Magpie Kimi Work provider" (#353)
Every request to agent-gw and kimi.com carried the User-Agent "Magpie Kimi Work provider/<version>". Kimi 3.2.20's daimon 0.6.10 (the desktop component that holds the Work credential in daimon-share/daimon/config.json) builds its agent-gw headers in createDaimonKimiCodeRequestHeaders: User-Agent kimi-code-cli/<Kimi Code version> (0.36.0, from its kimi-code.vendor.json; no caller passes a suffix), X-Msh-Device-Id, X-Msh-Device-Model, X-Msh-Device-Name, X-Msh-Os-Version, X-Msh-Platform "kimi-code-cli", X-Msh-Version and X-Msh-Daimon-Version 0.6.10. The plugin sends the same on /models and /chat/completions. The device id is the daimon's own: a randomUUID it writes once to <daimon>/runtime/kimi-code/home/device_id. The plugin reads that file and never writes it (it never writes the desktop app's files); when it is missing the header is left out. The www.kimi.com reads (membership, and 0.1.7's DescribeKimiWorkConfig menu) get the kimi-code-cli User-Agent only: those calls are made by Kimi's web page, whose own headers weren't read. The test also found magpie's x-magpie-* hint headers going through to agent-gw on chat requests; they are now dropped. Run: - no-magpie.test.mjs: models, the Work menu, chat (with a magpie User-Agent and an x-magpie-work-dir coming in) and membership hold no "magpie"; agent-gw gets the daimon's headers; the device id is read and never written. Both tests red on |
||
|
|
0a9415f4ef |
kimi-work 0.1.7: models come from Work's own menu (DescribeKimiWorkConfig) as well as /models, so K3.1 Pro on the 99 plan is listed
泠夜Soul (Discord #help, 10-24) is on Kimi's 99 membership and the official Kimi Work desktop has "Kimi K3.1 Pro" picked in its composer, but magpie's Kimi Work list (0.1.6) leaves it out. Cause, read from Kimi desktop 3.2.20's main bundle (decoded): the desktop does not build its Work model menu from agent-gw's /models. It calls the Connect RPC kimi.gateway.config.v1.ConfigService/DescribeKimiWorkConfig on https://www.kimi.com/apiv2 with the web sign-in, takes models plus moreModels, and hands each entry's requestParams.modelId to its agent (conversations.updateKimiModelList), which sends it to agent-gw as the model. The plugin listed /models only, so a tier model the menu has and /models doesn't was never offered. That /models leaves K3.1 Pro out is inferred from the report (0.1.6 already lists /models in full), not seen on an account. What changed: - provider.models asks both lists at once. Menu entries come first, under display.displayName, with id requestParams.modelId; reasoning levels are requestParams.reasoningEffortOptions, else daimonModelConfig's supportEfforts ("off" is REASONING_EFFORT_NONE there, sent as none); image input from its "image_in" capability. Context is capped at the standard 262,144 as before: XL is an X-Kimi-Context-Length header the desktop sends only when the user picks extended, and this doesn't send it. - An id both list keeps /models' row under the menu's name. Either list failing leaves the other; both failing, or the menu empty with /models failing, throws, so magpie keeps the last good list. - The reply is read in camelCase and in the proto's snake_case names. The fixture (tests/fixtures/work-config.shape.json) is the reply's shape from the proto descriptor and the desktop's mapping code. No reply was captured from an account; k3d1-pro in it is a placeholder id, and the fixture says so. Run: bun test packages/kimi-work (46 pass, 0 fail); with the menu call turned off by hand in index.mjs the two new list tests go red (44 pass, 2 fail); bun scripts/check.mjs kimi-work ok; git diff --check clean. Not tried: a real Work account (none on this machine or the Windows box), so neither the menu's reply nor a chat request with K3.1 Pro's id through agent-gw has been seen. The model-speed header (X-Kimi-Model-Speed) is not sent either. |
||
|
|
663ce131cb |
kimi-work 0.1.6: one model's unreadable effort list no longer drops the whole catalog; K2.8 Preview in the fallback
泠夜Soul (Discord #help, 10-24) sees only "K3 · Work" in magpie, while the Kimi app lists K3.1 Pro and K2.8 Preview for the same membership. "K3 · Work" is the name of this plugin's static fallback; the live /models catalog names k3-agent "K3". So the account's live list was not used: the models hook threw or fell back, and magpie kept the config's one model. The plugin already lists models from agent-gw's /models, so a model Kimi adds to the account shows under its own id with no hard-coded list. What changed: - modelRows no longer throws the whole catalog away when one model's reasoningEffortOptions isn't an array, or an option has no string effort or one that isn't a plain word: that model keeps the levels that can be read (only levels Kimi lists, none guessed). A non-object entry is skipped like an id that can't be used. K3.1 Pro went live on 2026-10-23, the day before the report, so a new entry in a shape not seen before is one way the catalog could have failed. It is not the confirmed cause: the user's provider.models error line has not been seen. - The fallback (shown before the list is read, and kept when it can't be) offers k2d8-preview beside k3-agent. Both ids come from Work's own /models: tests/fixtures/work-models.redacted.json and the 10-17 macOS record in COMPATIBILITY.md, and #350 ran real Work requests on both. Not added: a K3.1 Pro id. Kimi Code's docs name it k3.1-pro, but that is api.kimi.com/coding's catalog (where K2.8 Preview is kimi-for-coding and K3 is k3, not k3-agent), not the Work gateway's. Work's id for K3.1 Pro is not in any vendor source found, so none is invented; the live catalog will show it once read. Run: bun test packages/kimi-work (43 pass, 0 fail); the two new tests fail on origin/main's index.mjs (41 pass, 2 fail) and pass with this one; bun scripts/check.mjs kimi-work ok; git diff --check clean. Not tried: a real Work account (none on this machine), so the live catalog with K3.1 Pro has not been seen. |
||
|
|
327ec8bc9d |
kimi-desktop: a model that can't turn thinking off is declared always_thinking (#350)
A model whose catalog lists every reasoning level magpie knows, none of them "none", is declared always_thinking to Kimi desktop, in its runtime entry and its menu. Kimi then stops sending an old Off choice to a model that can't turn thinking off. A model that offers none, lists no levels or lists an unknown one keeps its old declaration. Run at the reviewed head fa08b22: bun test packages/kimi-desktop packages/kimi-work, 65 pass. catalog-thinking.test.mjs against main's catalog.mjs: 4 of 9 fail (the always_thinking cases), so the test holds the change. The author's real Kimi 3.2.18.13 runs on Windows are in the PR; not tried on macOS here. |
||
|
|
d324a96e1a |
kimi-work 0.1.5: tool schemas Kimi's moonshot check refuses go in a shape it takes (#287)
chai-j: every Codex message on Kimi Work failed, 400 "tools.function.
parameters is not a valid moonshot flavored json schema, details: <At
path '$defs.__schema20': when using $ref, type should be defined in the
referenced schema instead of the parent schema>". The plugin passed the
body through as sent. Codex's MCP and app tools are zod's toJSONSchema
with reused schemas as $defs, and zod 4 writes a schema derived from a
reused one as a $ref beside what it changed: z.number().min(0) reused,
then .int() and reused itself, is $defs.__schema1 =
{"type":"integer","maximum":…,"$ref":"#/$defs/__schema0"}. Reproduced
with zod 4.6.7; the fixture is its output.
magpie's own Kimi rewrites (kimiToolEnumTypes, kimiToolRefTypes) are
scoped to api.kimi.com/moonshot hosts and presets, so a plugin's
agent-gw.kimi.com requests never got them. moonshotTools does the class
in the plugin, on tools[].function.parameters only:
- $ref beside a type: a target with no $ref of its own is written in its
place with the parent's keywords over it (what zod's derived schema
means: .int() of min(0) is {type:integer,minimum:0,maximum}); otherwise
the parent's type is left out.
- type beside anyOf is left out (Kimi: "type should be defined in anyOf
items instead of the parent schema", measured in magpie 129d8b08a).
- enum/const with no type gets its values' type, [T,"null"] with a null
(magpie #886).
- an untyped $ref target gets the type its keywords or branches say
(magpie 129d8b08a). Unlike magpie's kimiToolRefTypes, a target that is
itself a $ref with keywords beside it (Codex App's
{"format":"uuid","$ref":…}) is left alone, so no type is put beside a
$ref.
A body with none of these goes byte for byte; a rewrite is deterministic,
so a cached prefix stays one. A Request or byte body is read as text.
Tests: tests/schema.test.mjs, with the zod fixture and Codex App's
automation_update parameters (magpie testdata) checked against the
refusal rules; 4 of its 7 tests fail on 0.1.4's index.mjs (the other
three guard the fixtures and pass-through). Package: 25 pass. Whole repo
the way CI runs it, HOME=$(mktemp -d) bun test at this head: 2056 pass,
0 fail. bun scripts/check.mjs kimi-work: ok.
Not tried: a real Kimi Work account (none here), so the rewritten tools
were never sent to agent-gw.kimi.com's validator, and the reporter's
literal __schema20 wasn't captured; the shape comes from zod's output
and the error text.
|
||
|
|
adcc7252d0 |
kimi-work: a Kimi desktop Work subscription through the desktop's own sign-in (#171)
Adds kimi-work 0.1.3 (kupakupar): a provider for the Kimi desktop's Work
subscription, using the desktop app's own local sign-in. It stores only
a hashed account reference, rereads the desktop's tokens on each call,
writes nothing to disk and logs nothing.
Re-reviewed at d9fe48d against the last review at fc3e395:
- (1) the desktop credential: decided acceptable (same as WorkBuddy,
Qoder, ZCode: each user's own allowance).
- (2) macOS record: COMPATIBILITY.md, macOS 26.6.2 arm64, Kimi 3.2.17
(3.2.17.4), magpie 0.1.1276 (released 2026-10-16 17:11Z, before the
20:09Z run), Bun 1.4.3. The path and four field names match readDesktop.
- expireTime: resetsAt dropped, window renamed 会员共享额度.
- efforts: every advertised level is kept (redacted real catalog fixture).
- kimi-work-opencode overlap: the README credits it and says not to
enable both.
- Request input: handled; body, headers and signal are kept, and the
desktop credential replaces any caller Authorization or Cookie.
- Icon is shipped once (package.json); the UA reads the package version.
Run at d9fe48d, and merged onto origin/main
|