kimi-desktop 0.1.6: separate reasoning effort and an optional context input budget for the primary and secondary roles.
The change (f07e7f4a..1d14a185, since the round-6 approval):
- The settings page and API save `<role>ReasoningEffort` and `<role>ContextTokens` for each role. Only efforts and context limits the catalog publishes are offered; an unknown limit allows no custom budget.
- Inference drops Kimi's top-level `thinking`, `reasoning` and `reasoning_effort`, and sends the chosen effort, or none for the provider default. Kimi's native menu aliases no longer choose the model.
- A custom budget counts a copy of the request through magpie's `/v1/messages/count_tokens`. Over the budget gives 400 `context_length_exceeded`; a failed count gives fixed 503 `context_count_unavailable`. No generation is sent in either case. Without a budget, nothing extra is sent.
- Role-scoped worker profiles (`v2:[model, role]`) tell primary from secondary even on the same model. Older roleless profiles keep their binding and use defaults.
- 1d14a185 removes blank lines only.
Run at 1d14a1859f63fd4bb512d492d1de419ad3e6c79a on mote (macOS, Bun 1.4.2, HOME/TMPDIR/XDG in the run's own folder):
- `bun test` in packages/kimi-desktop: 626 pass, 0 fail, 29 files.
- `bun scripts/check.mjs kimi-desktop`: exit 0.
- 14 hand breaks, each red in the package suite:
- drop `applyReasoningOptions`;
- strip thinking fields only when an effort is set;
- drop the budget check, or make it `>=`;
- `useFresh` false, or without its model check;
- a legacy roleless profile treated as primary;
- a profile name without its role;
- no `registerRoles`;
- no `optionsMatch` in save;
- no `refreshLiveModelOptions`;
- count with `redirect: 'follow'`, or with no reply size limit;
- a 131072 fallback for an unknown catalog context.
- CI at the head: test and on-npm pass. The PR merges onto main f379bf90+ with no conflicts.
Not blocking, left for a follow-up:
- Each inference now reads connection.json (adapter.mjs:547) with no fallback to the live connection. An unreadable file turns every request into 502, even without a budget.
- The comment above `applyReasoningOptions` ("Preserve the legacy connection untouched…") no longer matches the always-strip policy.
92 lines
3.9 KiB
JavaScript
92 lines
3.9 KiB
JavaScript
// Exercise the real control WebSocket transport against a temporary Kimi peer.
|
|
// No desktop profile, application or external model is used.
|
|
import { test, expect } from 'bun:test';
|
|
import fs from 'node:fs';
|
|
import { isMenuAlias } from './catalog.mjs';
|
|
import { recoveryPeer } from './test-fixtures/control-peer.mjs';
|
|
|
|
const official = 'https://agent-gw.kimi.com/coding/v1';
|
|
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
|
|
for (const [point, after] of [['list', false], ['select', false], ['select', true],
|
|
['menu', false], ['menu', true], ['reload', false], ['reload', true]]) {
|
|
test(`stop preserves retryable recovery when ${point} fails ${after ? 'after' : 'before'} its effect`, async () => {
|
|
const f = recoveryPeer();
|
|
try {
|
|
await f.controller.tick();
|
|
expect(f.controller.status.code).toBe('connected');
|
|
f.selectAlias();
|
|
f.disable();
|
|
f.fail(point, after);
|
|
await f.controller.stop();
|
|
expect(read(f.controller.configFile).model.providers['daimon-kimi-code'].baseUrl).toBe(official);
|
|
expect(read(f.controller.stateFile).active).toBe(true);
|
|
expect(fs.existsSync(f.controller.modelBackupFile)).toBe(true);
|
|
expect(f.controller.status.code).toBe('restored_waiting_kimi');
|
|
f.recover();
|
|
await f.controller.tick();
|
|
expect(f.controller.status.code).toBe('disconnected');
|
|
expect(read(f.controller.stateFile).active).toBe(false);
|
|
expect(read(f.controller.configFile).model.current).toBe('native');
|
|
expect(f.menu.map(row => row.model)).toEqual(['native']);
|
|
expect(f.runtimeBase).toBe(official);
|
|
expect(fs.existsSync(f.controller.modelBackupFile)).toBe(false);
|
|
expect(read(f.controller.configFile).unrelated).toBe('keep');
|
|
} finally { await f.cleanup(); }
|
|
});
|
|
}
|
|
|
|
test('a disabled next start completes native menu and runtime recovery after synchronous exit', async () => {
|
|
const f = recoveryPeer();
|
|
try {
|
|
await f.controller.tick();
|
|
f.selectAlias();
|
|
f.controller.restoreFileOnExit();
|
|
expect(read(f.controller.stateFile).active).toBe(true);
|
|
expect(f.menu.some(row => isMenuAlias(row.model))).toBe(true);
|
|
await f.controller.stop();
|
|
f.disable();
|
|
f.recover();
|
|
await f.controller.tick();
|
|
expect(f.controller.status.code).toBe('disconnected');
|
|
expect(read(f.controller.configFile).model.current).toBe('native');
|
|
expect(f.menu.map(row => row.model)).toEqual(['native']);
|
|
expect(f.runtimeBase).toBe(official);
|
|
expect(fs.existsSync(f.controller.modelBackupFile)).toBe(false);
|
|
} finally { await f.cleanup(); }
|
|
});
|
|
|
|
test('a first apply with an unacknowledged side effect retains recovery for disconnect', async () => {
|
|
const f = recoveryPeer();
|
|
try {
|
|
f.fail('select', true);
|
|
await f.controller.tick();
|
|
expect(f.runtimeBase).toBe(f.controller.bridgeURL);
|
|
expect(read(f.controller.configFile).model.providers['daimon-kimi-code'].baseUrl).toBe(official);
|
|
expect(read(f.controller.stateFile).active).toBe(true);
|
|
f.disable();
|
|
await f.controller.stop();
|
|
f.recover();
|
|
await f.controller.tick();
|
|
expect(read(f.controller.stateFile).active).toBe(false);
|
|
expect(f.runtimeBase).toBe(official);
|
|
expect(f.controller.status.code).toBe('disconnected');
|
|
} finally { await f.cleanup(); }
|
|
});
|
|
|
|
for (const [message, code, expected] of [
|
|
['kimi_config_changed', undefined, 'kimi_config_changed'],
|
|
['secondary_model_unsupported_runtime', undefined, 'secondary_model_unsupported_runtime'],
|
|
['missing file', 'ENOENT', 'secondary_model_unavailable'],
|
|
]) {
|
|
test(`stop retains the classified pool restore error ${expected}`, async () => {
|
|
const f = recoveryPeer();
|
|
try {
|
|
await f.controller.tick();
|
|
f.controller.restoreModelPoolOnExit = () => { throw Object.assign(Error(message), { code }); };
|
|
await f.controller.stop();
|
|
expect(f.controller.status.code).toBe(expected);
|
|
} finally { await f.cleanup(); }
|
|
});
|
|
}
|