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.
This commit is contained in:
@@ -17,7 +17,7 @@ Version 0.1.4 preserves the calling agent's shared instructions, prompts, histor
|
||||
|
||||
An inference HTTP 401 marks the provider sign-in as expired (`kimi_work_login_expired`). Sign in to desktop Work if needed, then **reconnect Kimi Work in Magpie** (or run `magpie plugin login kimi-work`); signing in to the desktop alone does not reconnect the provider. Other HTTP errors, including 429 and 5xx, pass through unchanged with Kimi's status, headers, body and Retry-After. This preserves the distinction between concurrency limits and exhausted allowance, including any upstream reset details. Network failures use `kimi_work_connection_failed` and retain the underlying cause code or fetch error message for diagnosis. Rate limits and service failures do not invalidate the desktop sign-in. Cancellation stays cancellation. No automatic retry sends a conversation twice or falls back to Code.
|
||||
|
||||
Models use standard context, capped at 262,144 tokens, rather than silently enabling the higher-priced XL context. The fallback model is `kimi-work/k3-agent`; the signed-in account's live catalog replaces it.
|
||||
Models use standard context, capped at 262,144 tokens, rather than silently enabling the higher-priced XL context. Until the signed-in account's live catalog is read, and when it can't be, the models offered are `kimi-work/k3-agent` and `kimi-work/k2d8-preview`, the two ids Work's `/models` has listed; the live catalog replaces them, so a model Kimi adds to the account (such as K3.1 Pro) shows under its own id. Since 0.1.6 a model whose reasoning levels come in a shape not seen before keeps the levels that can be read, rather than the whole catalog failing over to the fallback.
|
||||
|
||||
Usage comes from Kimi's membership `GetSubscriptionStats` endpoint and is labelled **shared membership allowance**, not a separate free Work allowance. No reset time is reported: `subscriptionBalance.expireTime` and `upcomingExpiration.timestamp` are expiration fields, and have not been verified to describe allowance resets. An observed Windows request was classified by Kimi as `FEATURE_WORK` while the Code five-hour and weekly ratios stayed unchanged. This is an observation, not a promise about future quota accounting: Kimi controls billing, shared allowances, access and rate limits.
|
||||
|
||||
|
||||
@@ -200,13 +200,15 @@ function modelRows(payload) {
|
||||
if(!Array.isArray(payload?.data)||payload.has_more||payload.data.length>100) throw Error('Kimi Work 模型目录暂不可用。');
|
||||
const out={};
|
||||
for(const m of payload.data) {
|
||||
if(typeof m.id!=='string'||!m.id||m.id.length>256||/[\x00-\x20/]/.test(m.id)) continue;
|
||||
if(!isObj(m)||typeof m.id!=='string'||!m.id||m.id.length>256||/[\x00-\x20/]/.test(m.id)) continue;
|
||||
// One model's effort list in a shape not seen before costs that model
|
||||
// its unreadable levels, not the account its whole catalog: a throw
|
||||
// here left only the fallback k3-agent listed. Only levels Kimi lists
|
||||
// are kept, so none is guessed.
|
||||
const variants=Object.create(null);
|
||||
if(m.reasoningEffortOptions!==undefined&&!Array.isArray(m.reasoningEffortOptions))throw Error('Kimi Work 思考档位格式无效。');
|
||||
for(const x of m.reasoningEffortOptions||[]) {
|
||||
const effort=String(x.effort||'').replace(/^REASONING_EFFORT_/,'').toLowerCase();
|
||||
if(!/^[a-z][a-z0-9_-]{0,63}$/.test(effort))throw Error('Kimi Work 思考档位格式无效。');
|
||||
variants[effort]={reasoningEffort:effort};
|
||||
for(const x of Array.isArray(m.reasoningEffortOptions)?m.reasoningEffortOptions:[]) {
|
||||
const effort=String(isObj(x)&&typeof x.effort==='string'?x.effort:'').replace(/^REASONING_EFFORT_/,'').toLowerCase();
|
||||
if(/^[a-z][a-z0-9_-]{0,63}$/.test(effort))variants[effort]={reasoningEffort:effort};
|
||||
}
|
||||
out[m.id]={id:m.id,name:m.display_name||m.id,
|
||||
api:{id:m.id,url:BASE,npm:'@ai-sdk/openai-compatible'},
|
||||
@@ -243,7 +245,10 @@ function createPlugin({readSession=readDesktop,fetchImpl=globalThis.fetch}={}) {
|
||||
config:async cfg=>{
|
||||
cfg.provider??={};
|
||||
cfg.provider[ID]??={name:'Kimi Work',npm:'@ai-sdk/openai-compatible',api:BASE,
|
||||
models:{'k3-agent':{name:'K3 · Work',limit:{context:262144,output:32768},tool_call:true,reasoning:true}}};
|
||||
// Shown until the account's own list is read, and kept when it can't
|
||||
// be: the two ids Work's /models has listed (tests/fixtures).
|
||||
models:{'k3-agent':{name:'K3 · Work',limit:{context:262144,output:32768},tool_call:true,reasoning:true},
|
||||
'k2d8-preview':{name:'K2.8 Preview · Work',limit:{context:262144,output:32768},tool_call:true,reasoning:true}}};
|
||||
},
|
||||
auth:{
|
||||
provider:ID,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-kimi-work-auth",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
"files": [
|
||||
|
||||
@@ -112,3 +112,25 @@ test('Request inputs preserve body, safe headers and cancellation while replacin
|
||||
await expect(loader.fetch(new Request(I.BASE+'/chat/completions',{method:'GET'}))).rejects.toThrow();
|
||||
expect(calls).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('one model with effort levels in an unseen shape does not cost the account its catalog',()=>{
|
||||
const payload=JSON.parse(fs.readFileSync(new URL('./fixtures/work-models.redacted.json',import.meta.url),'utf8'));
|
||||
const odd=[
|
||||
{...payload.data[0],id:'synthetic-no-effort',reasoningEffortOptions:[{displayName:'Max'},null,{effort:'REASONING_EFFORT_MAX'}]},
|
||||
{...payload.data[0],id:'synthetic-object-efforts',reasoningEffortOptions:{low:true}},
|
||||
null,'k3-agent',
|
||||
];
|
||||
const rows=I.modelRows({data:[...payload.data,...odd]});
|
||||
expect(Object.keys(rows)).toEqual(['k3-agent','k2d8-preview','synthetic-no-effort','synthetic-object-efforts']);
|
||||
expect(rows['synthetic-no-effort'].variants).toEqual({max:{reasoningEffort:'max'}});
|
||||
expect(rows['synthetic-object-efforts'].variants).toEqual({});
|
||||
expect(Object.keys(rows['k2d8-preview'].variants)).toEqual(['low','high','max']);
|
||||
});
|
||||
|
||||
test('before the account list is read, both models Work has listed are offered',async()=>{
|
||||
const p=I.createPlugin({readSession:()=>session,fetchImpl:async()=>{throw Error('no network in tests');}});
|
||||
const cfg={};await p.config(cfg);
|
||||
expect(Object.keys(cfg.provider['kimi-work'].models)).toEqual(['k3-agent','k2d8-preview']);
|
||||
const payload=JSON.parse(fs.readFileSync(new URL('./fixtures/work-models.redacted.json',import.meta.url),'utf8'));
|
||||
expect(Object.keys(cfg.provider['kimi-work'].models)).toEqual(payload.data.map(m=>m.id));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user