kimi-plugin-cc 2.7.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +3 -5
- package/CHANGELOG.md +78 -1
- package/README.md +505 -448
- package/agents/kimi-pursue.md +6 -6
- package/agents/kimi-review.md +22 -22
- package/agents/kimi-swarm.md +25 -23
- package/agents/{kimi-ask.md → kimi-task.md} +34 -30
- package/commands/README.md +4 -6
- package/commands/pursue.md +1 -1
- package/commands/review.md +8 -3
- package/commands/setup.md +4 -2
- package/commands/swarm.md +6 -5
- package/commands/{rescue.md → task.md} +13 -11
- package/dist/background-spawn.js +10 -17
- package/dist/cli-client.js +65 -46
- package/dist/commands/ask.js +22 -89
- package/dist/commands/cancel.js +7 -46
- package/dist/commands/cli-helpers.js +102 -1
- package/dist/commands/models.js +2 -3
- package/dist/commands/pursue.js +5 -19
- package/dist/commands/repair-sessions.js +118 -12
- package/dist/commands/rescue.js +12 -82
- package/dist/commands/result.js +7 -1
- package/dist/commands/review-gate.js +1 -0
- package/dist/commands/review.js +12 -15
- package/dist/commands/setup.js +606 -270
- package/dist/commands/status.js +2 -2
- package/dist/commands/swarm.js +93 -119
- package/dist/commands/worker.js +1 -2
- package/dist/companion.js +3 -1
- package/dist/dsh/index.js +15 -17
- package/dist/git.js +1 -9
- package/dist/help.js +3 -3
- package/dist/hooks/approval-hook.js +41 -0
- package/dist/hooks/approval-policy.js +72 -10
- package/dist/hooks/config-safety.js +19 -42
- package/dist/hooks/hook-timing.js +48 -0
- package/dist/hooks/install.js +206 -11
- package/dist/hooks/managed-block.js +78 -33
- package/dist/job-store.js +100 -128
- package/dist/jobs.js +14 -19
- package/dist/kimi-command.js +74 -1
- package/dist/kimi-engine.js +170 -74
- package/dist/kimi-errors.js +14 -69
- package/dist/kimi-home.js +6 -0
- package/dist/kimi-journal.js +41 -0
- package/dist/kimi-releases.js +144 -0
- package/dist/kimi-timeouts.js +1 -1
- package/dist/kimi-version-probe.js +12 -48
- package/dist/mcp/job-control.js +4 -6
- package/dist/mcp/launcher.js +12 -6
- package/dist/mcp/operations.js +50 -18
- package/dist/mcp/protocol.js +16 -14
- package/dist/mcp/stdio.js +3 -2
- package/dist/model-command.js +5 -3
- package/dist/native-v2-preflight.js +139 -68
- package/dist/parsing.js +171 -237
- package/dist/paths.js +8 -0
- package/dist/process-tree.js +35 -24
- package/dist/read-scope.js +435 -0
- package/dist/render.js +46 -9
- package/dist/rescue-approval.js +461 -84
- package/dist/schemas/review-gate-output.js +3 -5
- package/dist/session-title.js +25 -5
- package/dist/stream-json.js +1 -3
- package/dist/surface-routing.js +21 -0
- package/dist/swarm-activation.js +74 -77
- package/dist/swarm-policy.js +2 -1
- package/dist/swarm-recovery.js +2 -1
- package/dist/util.js +28 -0
- package/dist/version.js +1 -1
- package/docs/migration.md +27 -6
- package/docs/models.md +2 -2
- package/docs/registry-releases.md +3 -1
- package/docs/safety.md +131 -81
- package/docs/session-visibility.md +5 -3
- package/docs/swarm-recovery.md +4 -4
- package/docs/upstream-2.7.2-certification.md +16 -2
- package/docs/upstream-2.7.3-certification.md +95 -0
- package/package.json +2 -1
- package/plugins/kimi-codex/.codex-plugin/plugin.json +3 -3
- package/plugins/kimi-codex/.mcp.json +1 -0
- package/plugins/kimi-codex/dist/background-spawn.js +10 -17
- package/plugins/kimi-codex/dist/cli-client.js +65 -46
- package/plugins/kimi-codex/dist/commands/ask.js +22 -89
- package/plugins/kimi-codex/dist/commands/cancel.js +7 -46
- package/plugins/kimi-codex/dist/commands/cli-helpers.js +102 -1
- package/plugins/kimi-codex/dist/commands/models.js +2 -3
- package/plugins/kimi-codex/dist/commands/pursue.js +5 -19
- package/plugins/kimi-codex/dist/commands/repair-sessions.js +118 -12
- package/plugins/kimi-codex/dist/commands/rescue.js +12 -82
- package/plugins/kimi-codex/dist/commands/result.js +7 -1
- package/plugins/kimi-codex/dist/commands/review-gate.js +1 -0
- package/plugins/kimi-codex/dist/commands/review.js +12 -15
- package/plugins/kimi-codex/dist/commands/setup.js +606 -270
- package/plugins/kimi-codex/dist/commands/status.js +2 -2
- package/plugins/kimi-codex/dist/commands/swarm.js +93 -119
- package/plugins/kimi-codex/dist/commands/worker.js +1 -2
- package/plugins/kimi-codex/dist/companion.js +3 -1
- package/plugins/kimi-codex/dist/dsh/index.js +15 -17
- package/plugins/kimi-codex/dist/git.js +1 -9
- package/plugins/kimi-codex/dist/help.js +3 -3
- package/plugins/kimi-codex/dist/hooks/approval-hook.js +41 -0
- package/plugins/kimi-codex/dist/hooks/approval-policy.js +72 -10
- package/plugins/kimi-codex/dist/hooks/config-safety.js +19 -42
- package/plugins/kimi-codex/dist/hooks/hook-timing.js +48 -0
- package/plugins/kimi-codex/dist/hooks/install.js +206 -11
- package/plugins/kimi-codex/dist/hooks/managed-block.js +78 -33
- package/plugins/kimi-codex/dist/job-store.js +100 -128
- package/plugins/kimi-codex/dist/jobs.js +14 -19
- package/plugins/kimi-codex/dist/kimi-command.js +74 -1
- package/plugins/kimi-codex/dist/kimi-engine.js +170 -74
- package/plugins/kimi-codex/dist/kimi-errors.js +14 -69
- package/plugins/kimi-codex/dist/kimi-home.js +6 -0
- package/plugins/kimi-codex/dist/kimi-journal.js +41 -0
- package/plugins/kimi-codex/dist/kimi-releases.js +144 -0
- package/plugins/kimi-codex/dist/kimi-timeouts.js +1 -1
- package/plugins/kimi-codex/dist/kimi-version-probe.js +12 -48
- package/plugins/kimi-codex/dist/mcp/job-control.js +4 -6
- package/plugins/kimi-codex/dist/mcp/launcher.js +12 -6
- package/plugins/kimi-codex/dist/mcp/operations.js +50 -18
- package/plugins/kimi-codex/dist/mcp/protocol.js +16 -14
- package/plugins/kimi-codex/dist/mcp/stdio.js +3 -2
- package/plugins/kimi-codex/dist/model-command.js +5 -3
- package/plugins/kimi-codex/dist/native-v2-preflight.js +139 -68
- package/plugins/kimi-codex/dist/parsing.js +171 -237
- package/plugins/kimi-codex/dist/paths.js +8 -0
- package/plugins/kimi-codex/dist/process-tree.js +35 -24
- package/plugins/kimi-codex/dist/read-scope.js +435 -0
- package/plugins/kimi-codex/dist/render.js +46 -9
- package/plugins/kimi-codex/dist/rescue-approval.js +461 -84
- package/plugins/kimi-codex/dist/schemas/review-gate-output.js +3 -5
- package/plugins/kimi-codex/dist/session-title.js +25 -5
- package/plugins/kimi-codex/dist/stream-json.js +1 -3
- package/plugins/kimi-codex/dist/surface-routing.js +21 -0
- package/plugins/kimi-codex/dist/swarm-activation.js +74 -77
- package/plugins/kimi-codex/dist/swarm-policy.js +2 -1
- package/plugins/kimi-codex/dist/swarm-recovery.js +2 -1
- package/plugins/kimi-codex/dist/util.js +28 -0
- package/plugins/kimi-codex/dist/version.js +1 -1
- package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-review/SKILL.md +8 -7
- package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +1 -1
- package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +2 -1
- package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +8 -6
- package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +1 -1
- package/plugins/kimi-codex/skills/{kimi-ask → kimi-task}/SKILL.md +11 -9
- package/plugins/kimi-codex/skills/kimi-task/agents/openai.yaml +6 -0
- package/plugins/kimi-dsh/README.md +3 -2
- package/plugins/kimi-dsh/dist/background-spawn.js +10 -17
- package/plugins/kimi-dsh/dist/cli-client.js +65 -46
- package/plugins/kimi-dsh/dist/commands/ask.js +22 -89
- package/plugins/kimi-dsh/dist/commands/cancel.js +7 -46
- package/plugins/kimi-dsh/dist/commands/cli-helpers.js +102 -1
- package/plugins/kimi-dsh/dist/commands/models.js +2 -3
- package/plugins/kimi-dsh/dist/commands/pursue.js +5 -19
- package/plugins/kimi-dsh/dist/commands/repair-sessions.js +118 -12
- package/plugins/kimi-dsh/dist/commands/rescue.js +12 -82
- package/plugins/kimi-dsh/dist/commands/result.js +7 -1
- package/plugins/kimi-dsh/dist/commands/review-gate.js +1 -0
- package/plugins/kimi-dsh/dist/commands/review.js +12 -15
- package/plugins/kimi-dsh/dist/commands/setup.js +606 -270
- package/plugins/kimi-dsh/dist/commands/status.js +2 -2
- package/plugins/kimi-dsh/dist/commands/swarm.js +93 -119
- package/plugins/kimi-dsh/dist/commands/worker.js +1 -2
- package/plugins/kimi-dsh/dist/companion.js +3 -1
- package/plugins/kimi-dsh/dist/dsh/index.js +15 -17
- package/plugins/kimi-dsh/dist/git.js +1 -9
- package/plugins/kimi-dsh/dist/help.js +3 -3
- package/plugins/kimi-dsh/dist/hooks/approval-hook.js +41 -0
- package/plugins/kimi-dsh/dist/hooks/approval-policy.js +72 -10
- package/plugins/kimi-dsh/dist/hooks/config-safety.js +19 -42
- package/plugins/kimi-dsh/dist/hooks/hook-timing.js +48 -0
- package/plugins/kimi-dsh/dist/hooks/install.js +206 -11
- package/plugins/kimi-dsh/dist/hooks/managed-block.js +78 -33
- package/plugins/kimi-dsh/dist/job-store.js +100 -128
- package/plugins/kimi-dsh/dist/jobs.js +14 -19
- package/plugins/kimi-dsh/dist/kimi-command.js +74 -1
- package/plugins/kimi-dsh/dist/kimi-engine.js +170 -74
- package/plugins/kimi-dsh/dist/kimi-errors.js +14 -69
- package/plugins/kimi-dsh/dist/kimi-home.js +6 -0
- package/plugins/kimi-dsh/dist/kimi-journal.js +41 -0
- package/plugins/kimi-dsh/dist/kimi-releases.js +144 -0
- package/plugins/kimi-dsh/dist/kimi-timeouts.js +1 -1
- package/plugins/kimi-dsh/dist/kimi-version-probe.js +12 -48
- package/plugins/kimi-dsh/dist/mcp/job-control.js +4 -6
- package/plugins/kimi-dsh/dist/mcp/launcher.js +12 -6
- package/plugins/kimi-dsh/dist/mcp/operations.js +50 -18
- package/plugins/kimi-dsh/dist/mcp/protocol.js +16 -14
- package/plugins/kimi-dsh/dist/mcp/stdio.js +3 -2
- package/plugins/kimi-dsh/dist/model-command.js +5 -3
- package/plugins/kimi-dsh/dist/native-v2-preflight.js +139 -68
- package/plugins/kimi-dsh/dist/parsing.js +171 -237
- package/plugins/kimi-dsh/dist/paths.js +8 -0
- package/plugins/kimi-dsh/dist/process-tree.js +35 -24
- package/plugins/kimi-dsh/dist/read-scope.js +435 -0
- package/plugins/kimi-dsh/dist/render.js +46 -9
- package/plugins/kimi-dsh/dist/rescue-approval.js +461 -84
- package/plugins/kimi-dsh/dist/schemas/review-gate-output.js +3 -5
- package/plugins/kimi-dsh/dist/session-title.js +25 -5
- package/plugins/kimi-dsh/dist/stream-json.js +1 -3
- package/plugins/kimi-dsh/dist/surface-routing.js +21 -0
- package/plugins/kimi-dsh/dist/swarm-activation.js +74 -77
- package/plugins/kimi-dsh/dist/swarm-policy.js +2 -1
- package/plugins/kimi-dsh/dist/swarm-recovery.js +2 -1
- package/plugins/kimi-dsh/dist/util.js +28 -0
- package/plugins/kimi-dsh/dist/version.js +1 -1
- package/plugins/kimi-dsh/package.json +1 -1
- package/agents/kimi-challenge.md +0 -86
- package/agents/kimi-rescue.md +0 -92
- package/agents/kimi-swarm-write.md +0 -96
- package/commands/ask.md +0 -38
- package/commands/challenge.md +0 -35
- package/dist/commands/not-implemented.js +0 -4
- package/plugins/kimi-codex/dist/commands/not-implemented.js +0 -4
- package/plugins/kimi-codex/skills/kimi-ask/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-challenge/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-rescue/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +0 -36
- package/plugins/kimi-codex/skills/kimi-swarm-write/agents/openai.yaml +0 -6
- package/plugins/kimi-dsh/dist/commands/not-implemented.js +0 -4
package/dist/kimi-home.js
CHANGED
|
@@ -7,3 +7,9 @@ export function resolveKimiHome(env, baseCwd = process.cwd()) {
|
|
|
7
7
|
}
|
|
8
8
|
return path.join(os.homedir(), ".kimi-code");
|
|
9
9
|
}
|
|
10
|
+
export function kimiCodeConfigPath(kimiHome) {
|
|
11
|
+
return path.join(kimiHome, "config.toml");
|
|
12
|
+
}
|
|
13
|
+
export function resolveKimiCodeConfigPath(env, baseCwd = process.cwd()) {
|
|
14
|
+
return kimiCodeConfigPath(resolveKimiHome(env, baseCwd));
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Marker for a framed journal line that is not valid JSON. */
|
|
2
|
+
export const UNPARSEABLE_JOURNAL_LINE = Symbol("unparseable-journal-line");
|
|
3
|
+
/**
|
|
4
|
+
* kimi-code's append-log framing (appendLogStore.read/parseLine, identical at
|
|
5
|
+
* 2.4.0 and 2.7.3): one TextDecoder over the stream, split on "\n" only, strip
|
|
6
|
+
* ONE trailing "\r", skip only a zero-length line, else JSON.parse. A
|
|
7
|
+
* terminated line that fails to parse is corruption and wire replay stops
|
|
8
|
+
* there; an unparseable unterminated last line is dropped as truncated.
|
|
9
|
+
*/
|
|
10
|
+
export async function* kimiJournalRecords(chunks) {
|
|
11
|
+
const decoder = new TextDecoder();
|
|
12
|
+
let pending = "";
|
|
13
|
+
const frame = (raw, terminated) => {
|
|
14
|
+
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
15
|
+
if (line.length === 0)
|
|
16
|
+
return undefined;
|
|
17
|
+
try {
|
|
18
|
+
return { line, parsed: JSON.parse(line), terminated };
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return { line, parsed: UNPARSEABLE_JOURNAL_LINE, terminated };
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
for await (const chunk of chunks) {
|
|
25
|
+
pending += decoder.decode(chunk, { stream: true });
|
|
26
|
+
let newline = pending.indexOf("\n");
|
|
27
|
+
while (newline !== -1) {
|
|
28
|
+
const framed = frame(pending.slice(0, newline), true);
|
|
29
|
+
pending = pending.slice(newline + 1);
|
|
30
|
+
if (framed !== undefined)
|
|
31
|
+
yield framed;
|
|
32
|
+
newline = pending.indexOf("\n");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
pending += decoder.decode();
|
|
36
|
+
if (pending.length > 0) {
|
|
37
|
+
const framed = frame(pending, false);
|
|
38
|
+
if (framed !== undefined)
|
|
39
|
+
yield framed;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact kimi-code releases certified for native v2: one row per release.
|
|
3
|
+
*
|
|
4
|
+
* Certifying a release adds one row here (plus its evidence document, its
|
|
5
|
+
* tag-scan row and the hash-pinned host surfaces). Every version-gated branch
|
|
6
|
+
* in the runtime asks this table through `resolveKimiRelease` (directly or via
|
|
7
|
+
* `kimiReleaseHas`); none spells a version list of its own.
|
|
8
|
+
*
|
|
9
|
+
* Certification is by exact version string: upstream ships behavioural changes
|
|
10
|
+
* in patch releases, so a new release is certified for nothing until its row
|
|
11
|
+
* exists. `resolveKimiRelease` lets an unlisted plain 2.x borrow the argv
|
|
12
|
+
* mechanics of the highest row below it for read-only operations; it never
|
|
13
|
+
* borrows the hook schema, a swarm capability or a per-release relaxation.
|
|
14
|
+
*
|
|
15
|
+
* This module imports nothing. The per-tool-call hook and the config verifier
|
|
16
|
+
* load it, and neither may pull in the engine.
|
|
17
|
+
*/
|
|
18
|
+
// Rows share these arrays, so each is frozen: a mutated preset would change every row using it.
|
|
19
|
+
const preset = (...capabilities) => Object.freeze(capabilities);
|
|
20
|
+
const NONE = preset();
|
|
21
|
+
const HOOK_SCHEMA = preset("hook-schema");
|
|
22
|
+
const WEB = preset(...HOOK_SCHEMA, "web-preactivation");
|
|
23
|
+
const WEB_CANCEL = preset(...WEB, "print-cancels-plan");
|
|
24
|
+
const LOCAL = preset(...WEB_CANCEL, "local-environment", "agent-state");
|
|
25
|
+
const MODERN_WS = preset(...LOCAL, "modern-ws-control");
|
|
26
|
+
const BOUNDED = preset(...MODERN_WS, "bounded-swarm");
|
|
27
|
+
const JSON_READY = preset(...BOUNDED, "web-json-ready");
|
|
28
|
+
/** Ascending. Order is visible in error messages and in the exported version arrays. */
|
|
29
|
+
export const KIMI_V2_RELEASES = Object.freeze([
|
|
30
|
+
{ version: "0.42.0", commit: "6954d2c8", scope: "all", capabilities: NONE },
|
|
31
|
+
{ version: "0.43.0", commit: "ffa94fae", scope: "all", capabilities: NONE },
|
|
32
|
+
{ version: "0.43.1", commit: "75ac010b", scope: "all", capabilities: NONE },
|
|
33
|
+
{ version: "2.0.0", commit: "1b89e4b0", scope: "all", capabilities: HOOK_SCHEMA },
|
|
34
|
+
{ version: "2.0.1", commit: "caf7d4e2", scope: "all", capabilities: HOOK_SCHEMA },
|
|
35
|
+
{ version: "2.0.2", commit: "9d07f634", scope: "all", capabilities: HOOK_SCHEMA },
|
|
36
|
+
{ version: "2.1.0", commit: "52437299", scope: "all", capabilities: HOOK_SCHEMA },
|
|
37
|
+
{ version: "2.1.1", commit: "f67e6398", scope: "all", capabilities: HOOK_SCHEMA },
|
|
38
|
+
{ version: "2.2.0", commit: "472192c3", scope: "all", capabilities: HOOK_SCHEMA },
|
|
39
|
+
{ version: "2.3.0", commit: "b5e28fd6", scope: "all", capabilities: HOOK_SCHEMA },
|
|
40
|
+
{ version: "2.3.1", commit: "684bae9e", scope: "all", capabilities: HOOK_SCHEMA },
|
|
41
|
+
{ version: "2.3.2", commit: "b8dd3a13", scope: "all", capabilities: WEB },
|
|
42
|
+
{ version: "2.3.3", commit: "ec495f0c", scope: "all", capabilities: WEB },
|
|
43
|
+
{ version: "2.4.0", commit: "f26e4d91", scope: "all", capabilities: WEB_CANCEL },
|
|
44
|
+
{ version: "2.4.1", commit: "2c73f3f5", scope: "all", capabilities: WEB_CANCEL },
|
|
45
|
+
{ version: "2.5.0", commit: "41c34143", scope: "all", capabilities: LOCAL },
|
|
46
|
+
{ version: "2.5.1", commit: "1b02030d", scope: "all", capabilities: LOCAL },
|
|
47
|
+
{ version: "2.5.2", commit: "1c142a00", scope: "all", capabilities: LOCAL },
|
|
48
|
+
{ version: "2.5.3", commit: "5af9942e", scope: "all", capabilities: LOCAL },
|
|
49
|
+
// Swarm is refused on 2.6.0; its web flags support candidate integration only.
|
|
50
|
+
{ version: "2.6.0", commit: "740d6c0b", scope: "non-swarm", capabilities: MODERN_WS },
|
|
51
|
+
{ version: "2.6.2", commit: "6a8493df", scope: "all", capabilities: BOUNDED },
|
|
52
|
+
{ version: "2.6.3", commit: "b0de2fbd", scope: "all", capabilities: BOUNDED },
|
|
53
|
+
{ version: "2.7.2", commit: "56145f84", scope: "all", capabilities: JSON_READY },
|
|
54
|
+
{ version: "2.7.3", commit: "a8f643ad", scope: "all", capabilities: JSON_READY },
|
|
55
|
+
]);
|
|
56
|
+
/**
|
|
57
|
+
* Mechanics an uncertified release borrows from its row: only the fresh-print
|
|
58
|
+
* argv (`--environment local`, which can only narrow where it runs).
|
|
59
|
+
* Everything else (hook schema, swarm, web lifecycle, and every per-release
|
|
60
|
+
* relaxation) stays exact, because each rests on behaviour proven for that
|
|
61
|
+
* release only.
|
|
62
|
+
*/
|
|
63
|
+
const BORROWABLE_CAPABILITIES = new Set([
|
|
64
|
+
"local-environment",
|
|
65
|
+
]);
|
|
66
|
+
const PLAIN_VERSION = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
67
|
+
function versionTriple(version) {
|
|
68
|
+
const match = PLAIN_VERSION.exec(version);
|
|
69
|
+
return match === null ? null : [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
70
|
+
}
|
|
71
|
+
function compareTriples(left, right) {
|
|
72
|
+
for (let index = 0; index < 3; index += 1) {
|
|
73
|
+
if (left[index] !== right[index])
|
|
74
|
+
return left[index] - right[index];
|
|
75
|
+
}
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The single answer to "which row's mechanics apply, and is it certified".
|
|
80
|
+
* An exact row resolves to itself. Otherwise only a plain `2.y.z` newer than
|
|
81
|
+
* the lowest 2.x row borrows the highest row at or below it; pre-release and
|
|
82
|
+
* build-suffixed versions, other majors and `strict` resolve to null.
|
|
83
|
+
*/
|
|
84
|
+
export function resolveKimiRelease(version, options = {}) {
|
|
85
|
+
if (typeof version !== "string")
|
|
86
|
+
return null;
|
|
87
|
+
const exact = KIMI_V2_RELEASES.find((release) => release.version === version);
|
|
88
|
+
if (exact !== undefined)
|
|
89
|
+
return { release: exact, certified: true };
|
|
90
|
+
if (options.strict === true)
|
|
91
|
+
return null;
|
|
92
|
+
const triple = versionTriple(version);
|
|
93
|
+
if (triple === null || triple[0] !== 2)
|
|
94
|
+
return null;
|
|
95
|
+
let borrowed;
|
|
96
|
+
let lowest;
|
|
97
|
+
for (const release of KIMI_V2_RELEASES) {
|
|
98
|
+
const row = versionTriple(release.version);
|
|
99
|
+
if (row === null || row[0] !== 2)
|
|
100
|
+
continue;
|
|
101
|
+
if (lowest === undefined || compareTriples(row, lowest) < 0)
|
|
102
|
+
lowest = row;
|
|
103
|
+
if (compareTriples(row, triple) <= 0 &&
|
|
104
|
+
(borrowed === undefined || compareTriples(row, versionTriple(borrowed.version)) > 0)) {
|
|
105
|
+
borrowed = release;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (lowest === undefined || borrowed === undefined || compareTriples(triple, lowest) <= 0)
|
|
109
|
+
return null;
|
|
110
|
+
return { release: borrowed, certified: false };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* True when the version's resolved row has the capability: exact rows report
|
|
114
|
+
* their own list; an uncertified version only the borrowable mechanics.
|
|
115
|
+
*/
|
|
116
|
+
export function kimiReleaseHas(version, capability) {
|
|
117
|
+
const resolved = resolveKimiRelease(version);
|
|
118
|
+
if (resolved === null)
|
|
119
|
+
return false;
|
|
120
|
+
if (!resolved.certified && !BORROWABLE_CAPABILITIES.has(capability))
|
|
121
|
+
return false;
|
|
122
|
+
return resolved.release.capabilities.includes(capability);
|
|
123
|
+
}
|
|
124
|
+
/** True only when this exact certified row has the capability; borrowed rows never qualify. */
|
|
125
|
+
export function kimiCertifiedReleaseHas(version, capability) {
|
|
126
|
+
const resolved = resolveKimiRelease(version);
|
|
127
|
+
return resolved !== null && resolved.certified && resolved.release.capabilities.includes(capability);
|
|
128
|
+
}
|
|
129
|
+
/** Exact versions with the capability, ascending. */
|
|
130
|
+
export function kimiVersionsWith(capability) {
|
|
131
|
+
return KIMI_V2_RELEASES
|
|
132
|
+
.filter((release) => release.capabilities.includes(capability))
|
|
133
|
+
.map((release) => release.version);
|
|
134
|
+
}
|
|
135
|
+
/** Exact versions certified with the scope, ascending. */
|
|
136
|
+
export function kimiVersionsInScope(scope) {
|
|
137
|
+
return KIMI_V2_RELEASES.filter((release) => release.scope === scope).map((release) => release.version);
|
|
138
|
+
}
|
|
139
|
+
/** "a, b, c or d": the wording refusal and setup messages use to offer a choice of versions. */
|
|
140
|
+
export function formatVersionChoice(versions) {
|
|
141
|
+
if (versions.length <= 1)
|
|
142
|
+
return versions.join("");
|
|
143
|
+
return `${versions.slice(0, -1).join(", ")} or ${versions.at(-1)}`;
|
|
144
|
+
}
|
package/dist/kimi-timeouts.js
CHANGED
|
@@ -23,7 +23,7 @@ export const KIMI_PURSUE_DEFAULT_BUDGET_MS = 2_700_000; // 45 minutes
|
|
|
23
23
|
* Swarm (read-only parallel fan-out) DEFAULT wall-clock ceiling when the user
|
|
24
24
|
* passes no `--budget`. Read-only swarm opens no write surface, so the only new
|
|
25
25
|
* risk is cost/runaway from repeated model work. This AbortController bounds
|
|
26
|
-
* the whole job; `--cap` remains a soft lifetime-count hint.
|
|
26
|
+
* the whole job; `--cap` remains a soft lifetime-count hint. A bounded-swarm release also
|
|
27
27
|
* bounds wave cardinality and prevents child timeouts from overlapping waves;
|
|
28
28
|
* a requested concurrency of one runs a direct worker. Sized like the single-turn
|
|
29
29
|
* review budget — a swarm fans review work out in parallel within one process,
|
|
@@ -14,57 +14,18 @@
|
|
|
14
14
|
// - Not a license to infer historical versions. Old job rows remain unknown
|
|
15
15
|
// unless their saved logs contain positive evidence.
|
|
16
16
|
import { spawn } from "node:child_process";
|
|
17
|
+
import { resolveKimiRelease } from "./kimi-releases.js";
|
|
17
18
|
const KIMI_VERSION_PROBE_TIMEOUT_MS = 5_000;
|
|
18
19
|
/**
|
|
19
20
|
* Legacy-v1 kimi-code minors tested for plugin use. Membership is by
|
|
20
21
|
* `{major, minor}`; every patch within a listed minor is accepted.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
* Exact
|
|
23
|
+
* The table is 0.1 through 0.41 and never gains 0.42, which removed legacy v1.
|
|
24
|
+
* Exact native-v2 certification lives in `kimi-releases.ts` (rows) and
|
|
25
|
+
* `kimi-engine.ts` (per operation).
|
|
24
26
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{ major: 0, minor: 2 },
|
|
28
|
-
{ major: 0, minor: 3 },
|
|
29
|
-
{ major: 0, minor: 4 },
|
|
30
|
-
{ major: 0, minor: 5 },
|
|
31
|
-
{ major: 0, minor: 6 },
|
|
32
|
-
{ major: 0, minor: 7 },
|
|
33
|
-
{ major: 0, minor: 8 },
|
|
34
|
-
{ major: 0, minor: 9 },
|
|
35
|
-
{ major: 0, minor: 10 },
|
|
36
|
-
{ major: 0, minor: 11 },
|
|
37
|
-
{ major: 0, minor: 12 },
|
|
38
|
-
{ major: 0, minor: 13 },
|
|
39
|
-
{ major: 0, minor: 14 },
|
|
40
|
-
{ major: 0, minor: 15 },
|
|
41
|
-
{ major: 0, minor: 16 },
|
|
42
|
-
{ major: 0, minor: 17 },
|
|
43
|
-
{ major: 0, minor: 18 },
|
|
44
|
-
{ major: 0, minor: 19 },
|
|
45
|
-
{ major: 0, minor: 20 },
|
|
46
|
-
{ major: 0, minor: 21 },
|
|
47
|
-
{ major: 0, minor: 22 },
|
|
48
|
-
{ major: 0, minor: 23 },
|
|
49
|
-
{ major: 0, minor: 24 },
|
|
50
|
-
{ major: 0, minor: 25 },
|
|
51
|
-
{ major: 0, minor: 26 },
|
|
52
|
-
{ major: 0, minor: 27 },
|
|
53
|
-
{ major: 0, minor: 28 },
|
|
54
|
-
{ major: 0, minor: 29 },
|
|
55
|
-
{ major: 0, minor: 30 },
|
|
56
|
-
{ major: 0, minor: 31 },
|
|
57
|
-
{ major: 0, minor: 32 },
|
|
58
|
-
{ major: 0, minor: 33 },
|
|
59
|
-
{ major: 0, minor: 34 },
|
|
60
|
-
{ major: 0, minor: 35 },
|
|
61
|
-
{ major: 0, minor: 36 },
|
|
62
|
-
{ major: 0, minor: 37 },
|
|
63
|
-
{ major: 0, minor: 38 },
|
|
64
|
-
{ major: 0, minor: 39 },
|
|
65
|
-
{ major: 0, minor: 40 },
|
|
66
|
-
{ major: 0, minor: 41 },
|
|
67
|
-
];
|
|
27
|
+
const LEGACY_V1_LAST_MINOR = 41;
|
|
28
|
+
export const KIMI_TESTED_MINORS = Array.from({ length: LEGACY_V1_LAST_MINOR }, (_, index) => ({ major: 0, minor: index + 1 }));
|
|
68
29
|
/**
|
|
69
30
|
* Spawn `<kimi-bin> --version` and parse the output. Never throws;
|
|
70
31
|
* failures resolve to `{kind: "failed", reason}` so callers can decide
|
|
@@ -206,8 +167,9 @@ function compareVersions(a, b) {
|
|
|
206
167
|
}
|
|
207
168
|
/**
|
|
208
169
|
* Format a user-facing warning line for an out-of-range version probe.
|
|
209
|
-
* Setup itself may complete
|
|
210
|
-
*
|
|
170
|
+
* Setup itself may complete. An uncertified 2.x runs read-only operations
|
|
171
|
+
* with a warning; everything else refuses at the execution-plan gate until the
|
|
172
|
+
* operator installs or selects a certified binary or updates the plugin.
|
|
211
173
|
* `nativeV2Certified` is the exact native-v2 table; both engines are named so
|
|
212
174
|
* the newest certified version is not misreported as the legacy-v1 bound.
|
|
213
175
|
*/
|
|
@@ -229,6 +191,8 @@ export function formatVersionOutOfRangeWarning(probe, pluginVersion, nativeV2Cer
|
|
|
229
191
|
// Commonly out-of-band auto-upgrade drift past the last certification.
|
|
230
192
|
lines.push(` This is NEWER than the newest certified version (${newestNative ?? `${max.major}.${max.minor}.x`}) and is not yet certified for model execution.`);
|
|
231
193
|
}
|
|
232
|
-
lines.push(
|
|
194
|
+
lines.push(resolveKimiRelease(probeRaw)?.certified === false
|
|
195
|
+
? ` Read-only commands (ask, review, challenge, review gate) run on it with a warning; rescue, pursue and swarm refuse until the version is certified.`
|
|
196
|
+
: ` Setup can complete, but model-spawning commands will refuse before Kimi starts rather than run an unreviewed engine/version route.`, ` Run setup --install-kimi to give the plugin its own copy of the newest certified kimi-code, update kimi-plugin-cc to a release that certifies this version, or point KIMI_PLUGIN_CC_KIMI_BIN at a certified binary.`, ` KIMI_PLUGIN_CC_SKIP_VERSION_PROBE is a test/smoke seam, not a production compatibility override.`);
|
|
233
197
|
return lines.join("\n");
|
|
234
198
|
}
|
package/dist/mcp/job-control.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { formatError, RuntimeError } from "../errors.js";
|
|
2
2
|
import { markJobFailed, STALE_SWEEP_GRACE_MS } from "../jobs.js";
|
|
3
|
-
import { JobStore, parseHookEscapes, renderBudgetSource, } from "../job-store.js";
|
|
3
|
+
import { JobStore, parseHookEscapes, parseJobWarnings, renderBudgetSource, } from "../job-store.js";
|
|
4
4
|
import { ensurePluginPaths, resolvePluginPaths } from "../paths.js";
|
|
5
5
|
import { readProcessIdentity, revalidateProcessIdentities, revalidateProcessIdentity, } from "../process-tree.js";
|
|
6
6
|
import { readArtifact, renderTerminalJobArtifact } from "../render.js";
|
|
7
7
|
import { runCancel } from "../commands/cancel.js";
|
|
8
|
+
import { sleep } from "../util.js";
|
|
8
9
|
import { assertMcpJobBinding, mcpCompanionIdentity, mcpKimiIdentity } from "./binding.js";
|
|
9
10
|
import { readJobControlArguments } from "./operations.js";
|
|
10
11
|
import { textResult } from "./tool-result.js";
|
|
@@ -63,7 +64,6 @@ export async function getMcpTaskView(env, input) {
|
|
|
63
64
|
case "running":
|
|
64
65
|
return taskView(task, job, "working", undefined, `${task.operation_kind}: ${job.phase ?? "running"}`);
|
|
65
66
|
case "completed":
|
|
66
|
-
return taskView(task, job, "completed", await terminalJobResult(task, job), job.summary);
|
|
67
67
|
case "failed":
|
|
68
68
|
return taskView(task, job, "completed", await terminalJobResult(task, job), job.summary);
|
|
69
69
|
case "cancelled":
|
|
@@ -325,10 +325,11 @@ function mcpJobMetadata(task, job) {
|
|
|
325
325
|
kimi_session_id: job.kimi_session_id,
|
|
326
326
|
kimi_session_id_source: job.kimi_session_id_source,
|
|
327
327
|
hook_escapes: parseHookEscapes(job.hook_escapes),
|
|
328
|
+
...(parseJobWarnings(job.warnings).length > 0 ? { warnings: parseJobWarnings(job.warnings) } : {}),
|
|
328
329
|
error: job.error,
|
|
329
330
|
};
|
|
330
331
|
}
|
|
331
|
-
function taskView(task, job, status, result, statusMessage) {
|
|
332
|
+
export function taskView(task, job, status, result, statusMessage) {
|
|
332
333
|
return {
|
|
333
334
|
taskId: task.task_id,
|
|
334
335
|
status,
|
|
@@ -340,6 +341,3 @@ function taskView(task, job, status, result, statusMessage) {
|
|
|
340
341
|
...(result ? { result: { resultType: "complete", ...result } } : {}),
|
|
341
342
|
};
|
|
342
343
|
}
|
|
343
|
-
function sleep(ms) {
|
|
344
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
345
|
-
}
|
package/dist/mcp/launcher.js
CHANGED
|
@@ -11,6 +11,7 @@ import { markJobFailed } from "../jobs.js";
|
|
|
11
11
|
import { resolveKimiHome } from "../kimi-home.js";
|
|
12
12
|
import { ensurePluginPaths, resolvePluginPaths } from "../paths.js";
|
|
13
13
|
import { readProcessIdentity, revalidateProcessIdentities, } from "../process-tree.js";
|
|
14
|
+
import { sleep } from "../util.js";
|
|
14
15
|
import { assertMcpJobBinding, mcpCompanionIdentity } from "./binding.js";
|
|
15
16
|
import { resolveMcpWorkspace } from "./workspace.js";
|
|
16
17
|
const compiled = import.meta.url.endsWith(".js");
|
|
@@ -71,7 +72,7 @@ export async function launchMcpOperation(invocation, env, options) {
|
|
|
71
72
|
for (;;) {
|
|
72
73
|
if (spawnError)
|
|
73
74
|
throw await markLaunchFailure(store, task, spawnError);
|
|
74
|
-
|
|
75
|
+
let job = store.getJob(taskId);
|
|
75
76
|
if (job && (job.status !== "running" || job.phase === "turn-running" || job.phase === "worker-running")) {
|
|
76
77
|
const currentTask = store.getMcpTask(taskId) ?? task;
|
|
77
78
|
await assertMcpJobBinding(currentTask, job);
|
|
@@ -86,11 +87,19 @@ export async function launchMcpOperation(invocation, env, options) {
|
|
|
86
87
|
preserveStartingTask = true;
|
|
87
88
|
throw new RuntimeError("MCP_PROCESS_IDENTITY_UNAVAILABLE", "The attachment identity probe was inconclusive; the launch record was preserved.", "mcp.launch", { details: { job_id: taskId, operation_kind: invocation.operationKind } });
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
+
// A companion that finished between the job read and the probe
|
|
91
|
+
// has no process left; its terminal row explains the absence.
|
|
92
|
+
const settled = validation.identities.length === 0 ? store.getJob(taskId) : null;
|
|
93
|
+
if (settled && settled.status !== "running") {
|
|
94
|
+
job = settled;
|
|
95
|
+
}
|
|
96
|
+
else if (validation.identities.length === 0) {
|
|
90
97
|
preserveStartingTask = true;
|
|
91
98
|
throw new RuntimeError("MCP_PROCESS_IDENTITY_MISMATCH", "The recorded companion process identity changed before attachment; no process was adopted and the launch record was preserved.", "mcp.launch", { details: { job_id: taskId, operation_kind: invocation.operationKind } });
|
|
92
99
|
}
|
|
93
|
-
|
|
100
|
+
else {
|
|
101
|
+
identity = validation.identities[0];
|
|
102
|
+
}
|
|
94
103
|
}
|
|
95
104
|
else if (child.pid !== undefined) {
|
|
96
105
|
identity = await readIdentity(child.pid);
|
|
@@ -252,6 +261,3 @@ async function readTail(filePath, maximum = 8_000) {
|
|
|
252
261
|
return "";
|
|
253
262
|
}
|
|
254
263
|
}
|
|
255
|
-
function sleep(ms) {
|
|
256
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
257
|
-
}
|
package/dist/mcp/operations.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RuntimeError } from "../errors.js";
|
|
2
|
+
import { kimiVersionsWith } from "../kimi-releases.js";
|
|
2
3
|
import { parseDurationMs, validateThinkingEffort } from "../parsing.js";
|
|
3
4
|
const WORKSPACE_PROPERTY = {
|
|
4
5
|
type: "string",
|
|
@@ -44,6 +45,22 @@ const OBJECTIVE_PROPERTY = {
|
|
|
44
45
|
type: "string",
|
|
45
46
|
description: "The complete objective, preserved verbatim.",
|
|
46
47
|
};
|
|
48
|
+
const SCOPE_PROPERTIES = {
|
|
49
|
+
read_roots: {
|
|
50
|
+
type: "array",
|
|
51
|
+
items: { type: "string" },
|
|
52
|
+
description: "Absolute directories Kimi may also read. Omit for the default read scope.",
|
|
53
|
+
},
|
|
54
|
+
network: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Enable web search and URL fetch; file reads are then confined to the workspace plus read_roots. Default false.",
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
const REVIEW_MODE_PROPERTY = {
|
|
60
|
+
type: "string",
|
|
61
|
+
enum: ["defects", "challenge"],
|
|
62
|
+
description: "defects (default) reviews for bugs and regressions; challenge questions assumptions, design choices, and tradeoffs instead.",
|
|
63
|
+
};
|
|
47
64
|
const FOCUS_PROPERTY = {
|
|
48
65
|
type: "string",
|
|
49
66
|
description: "Optional review focus or adversarial framing, preserved verbatim.",
|
|
@@ -65,7 +82,7 @@ const CAP_PROPERTY = {
|
|
|
65
82
|
const MAX_CONCURRENCY_PROPERTY = {
|
|
66
83
|
type: "integer",
|
|
67
84
|
minimum: 1,
|
|
68
|
-
description:
|
|
85
|
+
description: `Concurrent worker limit on exact Kimi Code ${kimiVersionsWith("bounded-swarm").join("/")}: one runs directly; larger values bound each native swarm wave. Older certified versions limit normal launches only and recovery can exceed it. Distinct from the soft total cap.`,
|
|
69
86
|
};
|
|
70
87
|
const START_RESULT_GUIDANCE = "Task-capable clients receive an MCP task. Other clients receive a job ID immediately after launch; use kimi_job_status and kimi_job_result until terminal, and kimi_job_cancel to stop. Do not present a launch handle as the finished answer.";
|
|
71
88
|
function schema(properties, required = []) {
|
|
@@ -77,21 +94,14 @@ const OPERATION_SPECS = {
|
|
|
77
94
|
command: ["ask"],
|
|
78
95
|
write: false,
|
|
79
96
|
summary: "Start an independent read-only Kimi repository explanation.",
|
|
80
|
-
inputSchema: schema({ ...COMMON_PROPERTIES, prompt: PROMPT_PROPERTY, ...RESUME_PROPERTIES }),
|
|
97
|
+
inputSchema: schema({ ...COMMON_PROPERTIES, ...SCOPE_PROPERTIES, prompt: PROMPT_PROPERTY, ...RESUME_PROPERTIES }),
|
|
81
98
|
},
|
|
82
99
|
kimi_review: {
|
|
83
100
|
kind: "review",
|
|
84
101
|
command: ["review"],
|
|
85
102
|
write: false,
|
|
86
|
-
summary: "Start an independent read-only Kimi review of working-tree changes, including untracked files, or a committed base diff.",
|
|
87
|
-
inputSchema: schema({ ...COMMON_PROPERTIES, base: BASE_PROPERTY, focus: FOCUS_PROPERTY }),
|
|
88
|
-
},
|
|
89
|
-
kimi_challenge: {
|
|
90
|
-
kind: "challenge",
|
|
91
|
-
command: ["task", "challenge"],
|
|
92
|
-
write: false,
|
|
93
|
-
summary: "Start a read-only Kimi challenge of assumptions, design choices, and tradeoffs rather than a defect-only review.",
|
|
94
|
-
inputSchema: schema({ ...COMMON_PROPERTIES, base: BASE_PROPERTY, focus: FOCUS_PROPERTY }),
|
|
103
|
+
summary: "Start an independent read-only Kimi review of working-tree changes, including untracked files, or a committed base diff. Mode challenge questions the approach instead of hunting defects.",
|
|
104
|
+
inputSchema: schema({ ...COMMON_PROPERTIES, ...SCOPE_PROPERTIES, mode: REVIEW_MODE_PROPERTY, base: BASE_PROPERTY, focus: FOCUS_PROPERTY }),
|
|
95
105
|
},
|
|
96
106
|
kimi_rescue: {
|
|
97
107
|
kind: "rescue",
|
|
@@ -112,7 +122,7 @@ const OPERATION_SPECS = {
|
|
|
112
122
|
command: ["task", "swarm"],
|
|
113
123
|
write: false,
|
|
114
124
|
summary: "Start a read-only parallel Kimi fan-out across many independent review targets.",
|
|
115
|
-
inputSchema: schema({ ...COMMON_PROPERTIES, objective: OBJECTIVE_PROPERTY, cap: CAP_PROPERTY, max_concurrency: MAX_CONCURRENCY_PROPERTY }, ["objective"]),
|
|
125
|
+
inputSchema: schema({ ...COMMON_PROPERTIES, ...SCOPE_PROPERTIES, objective: OBJECTIVE_PROPERTY, cap: CAP_PROPERTY, max_concurrency: MAX_CONCURRENCY_PROPERTY }, ["objective"]),
|
|
116
126
|
},
|
|
117
127
|
kimi_swarm_write: {
|
|
118
128
|
kind: "swarm-write",
|
|
@@ -166,9 +176,12 @@ export function buildMcpOperationInvocation(name, input) {
|
|
|
166
176
|
const properties = spec.inputSchema.properties;
|
|
167
177
|
const args = readArguments(input, Object.keys(properties));
|
|
168
178
|
const workspace = optionalString(args, "workspace");
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
179
|
+
const challenge = name === "kimi_review" && reviewMode(args) === "challenge";
|
|
180
|
+
const kind = challenge ? "challenge" : spec.kind;
|
|
181
|
+
const argv = challenge ? ["task", "challenge"] : [...spec.command];
|
|
182
|
+
appendCommonOptions(argv, args, kind === "pursue" || kind === "swarm" || kind === "swarm-write" ? "safety" : "response");
|
|
183
|
+
appendScopeOptions(argv, args);
|
|
184
|
+
switch (kind) {
|
|
172
185
|
case "ask":
|
|
173
186
|
case "rescue": {
|
|
174
187
|
const prompt = args.prompt === undefined ? undefined : requiredNonEmptyString(args, "prompt");
|
|
@@ -185,7 +198,7 @@ export function buildMcpOperationInvocation(name, input) {
|
|
|
185
198
|
throw invalidArguments("resume uses the standard continuation instruction and cannot include prompt. Use resume_latest with a new prompt instead.");
|
|
186
199
|
}
|
|
187
200
|
if (prompt === undefined && !resumeLatest && resume === undefined) {
|
|
188
|
-
throw invalidArguments(`${
|
|
201
|
+
throw invalidArguments(`${kind} requires prompt unless resume or resume_latest is selected.`);
|
|
189
202
|
}
|
|
190
203
|
if (fresh)
|
|
191
204
|
argv.push("--fresh");
|
|
@@ -222,13 +235,13 @@ export function buildMcpOperationInvocation(name, input) {
|
|
|
222
235
|
argv.push("--cap", String(cap));
|
|
223
236
|
if (maxConcurrency !== undefined)
|
|
224
237
|
argv.push("--max-concurrency", String(maxConcurrency));
|
|
225
|
-
if (
|
|
238
|
+
if (kind === "swarm-write")
|
|
226
239
|
argv.push("--write");
|
|
227
240
|
argv.push("--", requiredNonEmptyString(args, "objective"));
|
|
228
241
|
break;
|
|
229
242
|
}
|
|
230
243
|
}
|
|
231
|
-
return { operationKind:
|
|
244
|
+
return { operationKind: kind, ...(workspace !== undefined ? { workspace } : {}), argv };
|
|
232
245
|
}
|
|
233
246
|
export function readJobControlArguments(input) {
|
|
234
247
|
const args = readArguments(input, ["workspace", "job_id"]);
|
|
@@ -252,6 +265,25 @@ function appendCommonOptions(argv, args, budgetKind) {
|
|
|
252
265
|
argv.push("--thinking", thinking);
|
|
253
266
|
}
|
|
254
267
|
}
|
|
268
|
+
function reviewMode(args) {
|
|
269
|
+
const mode = optionalString(args, "mode") ?? "defects";
|
|
270
|
+
if (mode !== "defects" && mode !== "challenge")
|
|
271
|
+
throw invalidArguments('mode must be "defects" or "challenge".');
|
|
272
|
+
return mode;
|
|
273
|
+
}
|
|
274
|
+
/** Type checks only: the companion parser and read-scope resolver own every scope rule. */
|
|
275
|
+
function appendScopeOptions(argv, args) {
|
|
276
|
+
const readRoots = args.read_roots;
|
|
277
|
+
if (readRoots !== undefined) {
|
|
278
|
+
if (!Array.isArray(readRoots) || readRoots.some((root) => typeof root !== "string")) {
|
|
279
|
+
throw invalidArguments("read_roots must be an array of strings.");
|
|
280
|
+
}
|
|
281
|
+
for (const root of readRoots)
|
|
282
|
+
argv.push("--read-root", root);
|
|
283
|
+
}
|
|
284
|
+
if (optionalBoolean(args, "network") === true)
|
|
285
|
+
argv.push("--network");
|
|
286
|
+
}
|
|
255
287
|
function readArguments(input, allowedKeys) {
|
|
256
288
|
if (input === undefined)
|
|
257
289
|
return {};
|
package/dist/mcp/protocol.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { formatError, RuntimeError } from "../errors.js";
|
|
2
|
+
import { isRecord } from "../util.js";
|
|
2
3
|
import { KIMI_PLUGIN_CC_VERSION } from "../version.js";
|
|
3
|
-
import { cancelMcpJob, getMcpJobResult, getMcpJobStatus, getMcpTaskView } from "./job-control.js";
|
|
4
|
+
import { cancelMcpJob, getMcpJobResult, getMcpJobStatus, getMcpTaskView, taskView } from "./job-control.js";
|
|
4
5
|
import { launchMcpOperation } from "./launcher.js";
|
|
5
6
|
import { buildMcpOperationInvocation, isMcpModelToolName, MCP_TOOL_DEFINITIONS, } from "./operations.js";
|
|
6
7
|
import { textResult } from "./tool-result.js";
|
|
@@ -11,6 +12,15 @@ const CLIENT_INFO_META = "io.modelcontextprotocol/clientInfo";
|
|
|
11
12
|
const CLIENT_CAPABILITIES_META = "io.modelcontextprotocol/clientCapabilities";
|
|
12
13
|
const TASKS_EXTENSION = "io.modelcontextprotocol/tasks";
|
|
13
14
|
const SERVER_INFO_META = "io.modelcontextprotocol/serverInfo";
|
|
15
|
+
// Every supported version permits `instructions`: InitializeResult since 2024-11-05, DiscoverResult in 2026-07-28.
|
|
16
|
+
export const MCP_SERVER_INSTRUCTIONS = [
|
|
17
|
+
"Prefer these tools for detached or long-running Kimi work.",
|
|
18
|
+
"Each model tool starts a durable job that keeps running if this connection drops; reconnect and look it up by job_id.",
|
|
19
|
+
"Where the host supports MCP tasks, completion arrives as a task notification; otherwise poll kimi_job_status and kimi_job_result with the returned job_id, and stop a job with kimi_job_cancel.",
|
|
20
|
+
"kimi_ask, kimi_review and kimi_swarm are read-only. kimi_rescue and kimi_pursue edit the workspace, never git; kimi_swarm_write edits a disposable worktree and returns a patch it never applies.",
|
|
21
|
+
"Use a write tool only when the user asked for edits, and kimi_pursue only for an explicitly autonomous objective.",
|
|
22
|
+
"A result may carry warnings, such as an uncertified Kimi release or workspace trust being off; relay them to the user.",
|
|
23
|
+
].join(" ");
|
|
14
24
|
export function createMcpMessageHandler(env) {
|
|
15
25
|
let mode;
|
|
16
26
|
return async (message) => {
|
|
@@ -31,6 +41,7 @@ export function createMcpMessageHandler(env) {
|
|
|
31
41
|
resultType: "complete",
|
|
32
42
|
supportedVersions: [MODERN_VERSION],
|
|
33
43
|
capabilities: { tools: {}, extensions: { [TASKS_EXTENSION]: {} } },
|
|
44
|
+
instructions: MCP_SERVER_INSTRUCTIONS,
|
|
34
45
|
_meta: { [SERVER_INFO_META]: { name: "kimi-plugin-cc", version: KIMI_PLUGIN_CC_VERSION } },
|
|
35
46
|
ttlMs: 0,
|
|
36
47
|
cacheScope: "private",
|
|
@@ -46,6 +57,7 @@ export function createMcpMessageHandler(env) {
|
|
|
46
57
|
protocolVersion: requested,
|
|
47
58
|
capabilities: { tools: {} },
|
|
48
59
|
serverInfo: { name: "kimi-plugin-cc", version: KIMI_PLUGIN_CC_VERSION },
|
|
60
|
+
instructions: MCP_SERVER_INSTRUCTIONS,
|
|
49
61
|
});
|
|
50
62
|
}
|
|
51
63
|
if (method === "notifications/initialized")
|
|
@@ -167,16 +179,9 @@ function launchResult(launched) {
|
|
|
167
179
|
return textResult(`Started ${task.operation_kind} job ${task.task_id}. This is a launch handle, not the finished answer. Use kimi_job_status and kimi_job_result with this job_id until the job is terminal; use kimi_job_cancel to stop it.`, metadata);
|
|
168
180
|
}
|
|
169
181
|
function taskHandle({ task, job }) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
status: job.status === "running" ? "working" : job.status === "cancelled" ? "cancelled" : "completed",
|
|
174
|
-
...(job.status === "running" ? { statusMessage: `${task.operation_kind}: ${job.phase ?? "running"}` } : job.summary ? { statusMessage: job.summary } : {}),
|
|
175
|
-
createdAt: task.created_at,
|
|
176
|
-
lastUpdatedAt: job.updated_at,
|
|
177
|
-
ttlMs: null,
|
|
178
|
-
pollIntervalMs: 2_000,
|
|
179
|
-
};
|
|
182
|
+
const status = job.status === "running" ? "working" : job.status === "cancelled" ? "cancelled" : "completed";
|
|
183
|
+
const statusMessage = job.status === "running" ? `${task.operation_kind}: ${job.phase ?? "running"}` : job.summary;
|
|
184
|
+
return { resultType: "task", ...taskView(task, job, status, undefined, statusMessage) };
|
|
180
185
|
}
|
|
181
186
|
function parseRequest(message) {
|
|
182
187
|
if (!isRecord(message))
|
|
@@ -270,6 +275,3 @@ class McpJsonRpcError extends Error {
|
|
|
270
275
|
function isRpcError(error) {
|
|
271
276
|
return error instanceof McpJsonRpcError || (error instanceof Error && "code" in error && typeof error.code === "number");
|
|
272
277
|
}
|
|
273
|
-
function isRecord(value) {
|
|
274
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
275
|
-
}
|
package/dist/mcp/stdio.js
CHANGED
|
@@ -37,11 +37,12 @@ export async function serveMcpStdio(input, output, handle) {
|
|
|
37
37
|
buffer = buffer.subarray(newline + 1);
|
|
38
38
|
if (line.length > MAX_MESSAGE_BYTES)
|
|
39
39
|
throw new Error("MCP frame exceeds 8 MiB");
|
|
40
|
-
|
|
40
|
+
const text = line.toString("utf8");
|
|
41
|
+
if (text.trim().length === 0)
|
|
41
42
|
continue;
|
|
42
43
|
let parsed;
|
|
43
44
|
try {
|
|
44
|
-
parsed = JSON.parse(
|
|
45
|
+
parsed = JSON.parse(text);
|
|
45
46
|
}
|
|
46
47
|
catch {
|
|
47
48
|
track(write({ jsonrpc: "2.0", id: null, error: { code: -32_700, message: "Parse error" } }));
|
package/dist/model-command.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { runAsk } from "./commands/ask.js";
|
|
2
|
-
import { notImplementedCompanionCommand } from "./commands/not-implemented.js";
|
|
3
2
|
import { runPursue } from "./commands/pursue.js";
|
|
4
3
|
import { runRescue } from "./commands/rescue.js";
|
|
5
4
|
import { runReview } from "./commands/review.js";
|
|
6
5
|
import { runSwarm } from "./commands/swarm.js";
|
|
6
|
+
import { RuntimeError } from "./errors.js";
|
|
7
7
|
export async function runModelCommand(argv, context) {
|
|
8
8
|
const [command, ...rest] = argv;
|
|
9
9
|
switch (command) {
|
|
@@ -22,8 +22,10 @@ export async function runModelCommand(argv, context) {
|
|
|
22
22
|
return runPursue(taskArgs, context);
|
|
23
23
|
case "swarm":
|
|
24
24
|
return runSwarm(taskArgs, context);
|
|
25
|
-
default:
|
|
26
|
-
|
|
25
|
+
default: {
|
|
26
|
+
const label = taskType ? `task ${taskType}` : "task";
|
|
27
|
+
throw new RuntimeError("NOT_IMPLEMENTED", `Companion subcommand ${label} is not implemented.`, label);
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
default:
|