kimi-plugin-cc 3.0.0 → 3.1.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 +2 -2
- package/.claude-plugin/plugin.json +3 -14
- package/README.md +428 -572
- package/assets/logo.svg +6 -0
- package/cordis.patch.yml +18 -0
- package/dist/background-spawn.js +4 -2
- package/dist/cli-client.js +105 -66
- package/dist/commands/ask.js +27 -12
- package/dist/commands/cancel.js +4 -13
- package/dist/commands/cli-helpers.js +1 -1
- package/dist/commands/pursue.js +3 -2
- package/dist/commands/registry.js +7 -26
- package/dist/commands/repair-sessions.js +7 -4
- package/dist/commands/replay.js +4 -3
- package/dist/commands/rescue.js +17 -5
- package/dist/commands/review.js +18 -5
- package/dist/commands/setup.js +277 -262
- package/dist/commands/swarm.js +20 -7
- package/dist/companion.js +142 -18
- package/dist/help.js +11 -7
- package/dist/hook-escape.js +7 -16
- package/dist/hooks/approval-hook.js +1762 -124
- package/dist/hooks/approval-policy.js +15 -10
- package/dist/hooks/config-safety.js +15 -24
- package/dist/hooks/hook-timing.js +1 -1
- package/dist/hooks/install-paths.js +179 -107
- package/dist/hooks/install.js +44 -166
- package/dist/hooks/managed-block.js +44 -95
- package/dist/job-store.js +117 -49
- package/dist/jobs.js +53 -1
- package/dist/kimi-engine.js +68 -92
- package/dist/kimi-errors.js +1 -1
- package/dist/kimi-journal.js +3 -2
- package/dist/kimi-releases.js +28 -49
- package/dist/kimi-timeouts.js +1 -15
- package/dist/kimi-version-probe.js +24 -72
- package/dist/logging.js +12 -7
- package/dist/mcp/binding.js +13 -4
- package/dist/mcp/job-control.js +386 -89
- package/dist/mcp/launcher.js +1 -1
- package/dist/mcp/operations.js +387 -193
- package/dist/mcp/protocol.js +116 -27
- package/dist/mcp/skills.js +130 -0
- package/dist/mcp/stdio.js +15 -2
- package/dist/native-v2-preflight.js +127 -35
- package/dist/parsing.js +45 -11
- package/dist/paths.js +20 -10
- package/dist/plugin-data.js +28 -83
- package/dist/read-scope.js +2 -2
- package/dist/render.js +13 -38
- package/dist/session-references.js +216 -0
- package/dist/session-title.js +1 -1
- package/dist/surface-routing.js +92 -5
- package/dist/swarm-activation.js +26 -137
- package/dist/version.js +1 -1
- package/docs/migration.md +45 -227
- package/docs/models.md +24 -66
- package/docs/safety.md +195 -400
- package/docs/session-visibility.md +24 -14
- package/docs/swarm-recovery.md +26 -20
- package/dsh/index.json +54 -0
- package/mcp_config.json +10 -0
- package/package.json +23 -82
- package/plugin.json +19 -0
- package/plugins/kimi-codex/.codex-plugin/plugin.json +7 -7
- package/plugins/kimi-codex/.mcp.json +2 -3
- package/plugins/kimi-codex/dist/background-spawn.js +4 -2
- package/plugins/kimi-codex/dist/cli-client.js +105 -66
- package/plugins/kimi-codex/dist/commands/ask.js +27 -12
- package/plugins/kimi-codex/dist/commands/cancel.js +4 -13
- package/plugins/kimi-codex/dist/commands/cli-helpers.js +1 -1
- package/plugins/kimi-codex/dist/commands/pursue.js +3 -2
- package/plugins/kimi-codex/dist/commands/registry.js +7 -26
- package/plugins/kimi-codex/dist/commands/repair-sessions.js +7 -4
- package/plugins/kimi-codex/dist/commands/replay.js +4 -3
- package/plugins/kimi-codex/dist/commands/rescue.js +17 -5
- package/plugins/kimi-codex/dist/commands/review.js +18 -5
- package/plugins/kimi-codex/dist/commands/setup.js +277 -262
- package/plugins/kimi-codex/dist/commands/swarm.js +20 -7
- package/plugins/kimi-codex/dist/companion.js +142 -18
- package/plugins/kimi-codex/dist/help.js +11 -7
- package/plugins/kimi-codex/dist/hook-escape.js +7 -16
- package/plugins/kimi-codex/dist/hooks/approval-hook.js +1762 -124
- package/plugins/kimi-codex/dist/hooks/approval-policy.js +15 -10
- package/plugins/kimi-codex/dist/hooks/config-safety.js +15 -24
- package/plugins/kimi-codex/dist/hooks/hook-timing.js +1 -1
- package/plugins/kimi-codex/dist/hooks/install-paths.js +179 -107
- package/plugins/kimi-codex/dist/hooks/install.js +44 -166
- package/plugins/kimi-codex/dist/hooks/managed-block.js +44 -95
- package/plugins/kimi-codex/dist/job-store.js +117 -49
- package/plugins/kimi-codex/dist/jobs.js +53 -1
- package/plugins/kimi-codex/dist/kimi-engine.js +68 -92
- package/plugins/kimi-codex/dist/kimi-errors.js +1 -1
- package/plugins/kimi-codex/dist/kimi-journal.js +3 -2
- package/plugins/kimi-codex/dist/kimi-releases.js +28 -49
- package/plugins/kimi-codex/dist/kimi-timeouts.js +1 -15
- package/plugins/kimi-codex/dist/kimi-version-probe.js +24 -72
- package/plugins/kimi-codex/dist/logging.js +12 -7
- package/plugins/kimi-codex/dist/mcp/binding.js +13 -4
- package/plugins/kimi-codex/dist/mcp/job-control.js +386 -89
- package/plugins/kimi-codex/dist/mcp/launcher.js +1 -1
- package/plugins/kimi-codex/dist/mcp/operations.js +387 -193
- package/plugins/kimi-codex/dist/mcp/protocol.js +116 -27
- package/plugins/kimi-codex/dist/mcp/skills.js +130 -0
- package/plugins/kimi-codex/dist/mcp/stdio.js +15 -2
- package/plugins/kimi-codex/dist/native-v2-preflight.js +127 -35
- package/plugins/kimi-codex/dist/parsing.js +45 -11
- package/plugins/kimi-codex/dist/paths.js +20 -10
- package/plugins/kimi-codex/dist/plugin-data.js +28 -83
- package/plugins/kimi-codex/dist/read-scope.js +2 -2
- package/plugins/kimi-codex/dist/render.js +13 -38
- package/plugins/kimi-codex/dist/session-references.js +216 -0
- package/plugins/kimi-codex/dist/session-title.js +1 -1
- package/plugins/kimi-codex/dist/surface-routing.js +92 -5
- package/plugins/kimi-codex/dist/swarm-activation.js +26 -137
- package/plugins/kimi-codex/dist/version.js +1 -1
- package/plugins/kimi-codex/scripts/companion.sh +4 -15
- package/plugins/kimi-codex/skills/kimi/SKILL.md +77 -0
- package/plugins/kimi-codex/skills/kimi/agents/openai.yaml +6 -0
- package/scripts/companion.sh +4 -15
- package/skills/kimi/SKILL.md +77 -0
- package/skills/kimi/agents/openai.yaml +6 -0
- package/CHANGELOG.md +0 -1402
- package/agents/kimi-pursue.md +0 -93
- package/agents/kimi-review.md +0 -86
- package/agents/kimi-swarm.md +0 -88
- package/agents/kimi-task.md +0 -93
- package/commands/README.md +0 -14
- package/commands/cancel.md +0 -17
- package/commands/pursue.md +0 -41
- package/commands/replay.md +0 -13
- package/commands/result.md +0 -13
- package/commands/review.md +0 -40
- package/commands/setup.md +0 -25
- package/commands/status.md +0 -13
- package/commands/swarm.md +0 -45
- package/commands/task.md +0 -40
- package/dist/commands/review-gate.js +0 -391
- package/dist/config.js +0 -22
- package/dist/dsh/companion.js +0 -177
- package/dist/dsh/index.js +0 -167
- package/dist/hooks/review-gate-stop.js +0 -19
- package/dist/schemas/review-gate-output.js +0 -41
- package/docs/registry-releases.md +0 -228
- package/docs/upstream-2.4.1-certification.md +0 -54
- package/docs/upstream-2.5.0-certification.md +0 -52
- package/docs/upstream-2.5.1-certification.md +0 -47
- package/docs/upstream-2.5.2-certification.md +0 -40
- package/docs/upstream-2.5.3-certification.md +0 -73
- package/docs/upstream-2.6.0-certification.md +0 -65
- package/docs/upstream-2.6.2-certification.md +0 -144
- package/docs/upstream-2.6.3-certification.md +0 -100
- package/docs/upstream-2.7.2-certification.md +0 -113
- package/docs/upstream-2.7.3-certification.md +0 -95
- package/docs/windows-validation.md +0 -39
- package/hooks/README.md +0 -9
- package/hooks/hooks.json +0 -16
- package/plugins/kimi-codex/dist/commands/review-gate.js +0 -391
- package/plugins/kimi-codex/dist/config.js +0 -22
- package/plugins/kimi-codex/dist/dsh/companion.js +0 -177
- package/plugins/kimi-codex/dist/dsh/index.js +0 -167
- package/plugins/kimi-codex/dist/hooks/review-gate-stop.js +0 -19
- package/plugins/kimi-codex/dist/schemas/review-gate-output.js +0 -41
- package/plugins/kimi-codex/scripts/review-gate-hook.sh +0 -32
- package/plugins/kimi-codex/skills/kimi-cancel/SKILL.md +0 -25
- package/plugins/kimi-codex/skills/kimi-cancel/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +0 -32
- package/plugins/kimi-codex/skills/kimi-pursue/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-replay/SKILL.md +0 -25
- package/plugins/kimi-codex/skills/kimi-replay/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-result/SKILL.md +0 -25
- package/plugins/kimi-codex/skills/kimi-result/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-review/SKILL.md +0 -35
- package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +0 -35
- package/plugins/kimi-codex/skills/kimi-setup/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-status/SKILL.md +0 -25
- package/plugins/kimi-codex/skills/kimi-status/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +0 -37
- package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-task/SKILL.md +0 -37
- package/plugins/kimi-codex/skills/kimi-task/agents/openai.yaml +0 -6
- package/plugins/kimi-dsh/LICENSE +0 -201
- package/plugins/kimi-dsh/README.md +0 -84
- package/plugins/kimi-dsh/cordis.patch.yml +0 -45
- package/plugins/kimi-dsh/dist/background-spawn.js +0 -209
- package/plugins/kimi-dsh/dist/cli-cancellation.js +0 -43
- package/plugins/kimi-dsh/dist/cli-client.js +0 -1097
- package/plugins/kimi-dsh/dist/commands/ask.js +0 -269
- package/plugins/kimi-dsh/dist/commands/cancel.js +0 -177
- package/plugins/kimi-dsh/dist/commands/cli-helpers.js +0 -302
- package/plugins/kimi-dsh/dist/commands/models.js +0 -139
- package/plugins/kimi-dsh/dist/commands/pursue.js +0 -293
- package/plugins/kimi-dsh/dist/commands/recover-swarm.js +0 -140
- package/plugins/kimi-dsh/dist/commands/registry.js +0 -74
- package/plugins/kimi-dsh/dist/commands/repair-sessions.js +0 -266
- package/plugins/kimi-dsh/dist/commands/replay.js +0 -124
- package/plugins/kimi-dsh/dist/commands/rescue.js +0 -277
- package/plugins/kimi-dsh/dist/commands/result.js +0 -72
- package/plugins/kimi-dsh/dist/commands/review-gate.js +0 -391
- package/plugins/kimi-dsh/dist/commands/review.js +0 -217
- package/plugins/kimi-dsh/dist/commands/setup.js +0 -1465
- package/plugins/kimi-dsh/dist/commands/status.js +0 -27
- package/plugins/kimi-dsh/dist/commands/swarm.js +0 -823
- package/plugins/kimi-dsh/dist/commands/worker.js +0 -24
- package/plugins/kimi-dsh/dist/companion.js +0 -99
- package/plugins/kimi-dsh/dist/config.js +0 -22
- package/plugins/kimi-dsh/dist/dsh/companion.js +0 -177
- package/plugins/kimi-dsh/dist/dsh/index.js +0 -167
- package/plugins/kimi-dsh/dist/errors.js +0 -40
- package/plugins/kimi-dsh/dist/git.js +0 -216
- package/plugins/kimi-dsh/dist/help.js +0 -43
- package/plugins/kimi-dsh/dist/hook-escape.js +0 -71
- package/plugins/kimi-dsh/dist/hooks/approval-hook.js +0 -145
- package/plugins/kimi-dsh/dist/hooks/approval-policy.js +0 -295
- package/plugins/kimi-dsh/dist/hooks/config-safety.js +0 -641
- package/plugins/kimi-dsh/dist/hooks/hook-timing.js +0 -48
- package/plugins/kimi-dsh/dist/hooks/install-paths.js +0 -428
- package/plugins/kimi-dsh/dist/hooks/install.js +0 -405
- package/plugins/kimi-dsh/dist/hooks/managed-block.js +0 -729
- package/plugins/kimi-dsh/dist/hooks/review-gate-stop.js +0 -19
- package/plugins/kimi-dsh/dist/job-id.js +0 -12
- package/plugins/kimi-dsh/dist/job-store.js +0 -631
- package/plugins/kimi-dsh/dist/jobs.js +0 -212
- package/plugins/kimi-dsh/dist/kimi-command.js +0 -144
- package/plugins/kimi-dsh/dist/kimi-engine.js +0 -770
- package/plugins/kimi-dsh/dist/kimi-errors.js +0 -205
- package/plugins/kimi-dsh/dist/kimi-home.js +0 -15
- package/plugins/kimi-dsh/dist/kimi-journal.js +0 -41
- package/plugins/kimi-dsh/dist/kimi-releases.js +0 -144
- package/plugins/kimi-dsh/dist/kimi-timeouts.js +0 -52
- package/plugins/kimi-dsh/dist/kimi-version-probe.js +0 -198
- package/plugins/kimi-dsh/dist/logging.js +0 -22
- package/plugins/kimi-dsh/dist/mcp/binding.js +0 -58
- package/plugins/kimi-dsh/dist/mcp/job-control.js +0 -343
- package/plugins/kimi-dsh/dist/mcp/launcher.js +0 -263
- package/plugins/kimi-dsh/dist/mcp/operations.js +0 -333
- package/plugins/kimi-dsh/dist/mcp/protocol.js +0 -277
- package/plugins/kimi-dsh/dist/mcp/server.js +0 -8
- package/plugins/kimi-dsh/dist/mcp/stdio.js +0 -79
- package/plugins/kimi-dsh/dist/mcp/supervised-child.js +0 -15
- package/plugins/kimi-dsh/dist/mcp/tool-result.js +0 -7
- package/plugins/kimi-dsh/dist/mcp/workspace.js +0 -34
- package/plugins/kimi-dsh/dist/model-command.js +0 -34
- package/plugins/kimi-dsh/dist/native-v2-preflight.js +0 -596
- package/plugins/kimi-dsh/dist/package.json +0 -1
- package/plugins/kimi-dsh/dist/parsing.js +0 -554
- package/plugins/kimi-dsh/dist/paths.js +0 -35
- package/plugins/kimi-dsh/dist/plugin-data.js +0 -98
- package/plugins/kimi-dsh/dist/process-tree.js +0 -597
- package/plugins/kimi-dsh/dist/prompt-size.js +0 -18
- package/plugins/kimi-dsh/dist/read-scope.js +0 -435
- package/plugins/kimi-dsh/dist/render.js +0 -214
- package/plugins/kimi-dsh/dist/rescue-approval.js +0 -1242
- package/plugins/kimi-dsh/dist/schemas/review-gate-output.js +0 -41
- package/plugins/kimi-dsh/dist/session-recovery.js +0 -202
- package/plugins/kimi-dsh/dist/session-title.js +0 -313
- package/plugins/kimi-dsh/dist/stream-json.js +0 -344
- package/plugins/kimi-dsh/dist/surface-routing.js +0 -21
- package/plugins/kimi-dsh/dist/swarm-activation.js +0 -1194
- package/plugins/kimi-dsh/dist/swarm-policy.js +0 -74
- package/plugins/kimi-dsh/dist/swarm-recovery.js +0 -166
- package/plugins/kimi-dsh/dist/swarm-tool-policy.js +0 -146
- package/plugins/kimi-dsh/dist/types.js +0 -1
- package/plugins/kimi-dsh/dist/util.js +0 -28
- package/plugins/kimi-dsh/dist/vendor/shell-quote/LICENSE +0 -24
- package/plugins/kimi-dsh/dist/vendor/shell-quote/index.js +0 -1
- package/plugins/kimi-dsh/dist/vendor/shell-quote/parse.js +0 -229
- package/plugins/kimi-dsh/dist/vendor/smol-toml/LICENSE +0 -24
- package/plugins/kimi-dsh/dist/vendor/smol-toml/date.js +0 -156
- package/plugins/kimi-dsh/dist/vendor/smol-toml/error.js +0 -67
- package/plugins/kimi-dsh/dist/vendor/smol-toml/extract.js +0 -293
- package/plugins/kimi-dsh/dist/vendor/smol-toml/parse.js +0 -164
- package/plugins/kimi-dsh/dist/vendor/smol-toml/primitive.js +0 -151
- package/plugins/kimi-dsh/dist/vendor/smol-toml/struct.js +0 -156
- package/plugins/kimi-dsh/dist/vendor/smol-toml/util.js +0 -57
- package/plugins/kimi-dsh/dist/version.js +0 -7
- package/plugins/kimi-dsh/package.json +0 -78
- package/plugins/kimi-dsh/scripts/companion.sh +0 -37
- package/plugins/kimi-dsh/scripts/review-gate-hook.sh +0 -32
- package/scripts/review-gate-hook.sh +0 -32
package/dist/mcp/operations.js
CHANGED
|
@@ -1,255 +1,430 @@
|
|
|
1
1
|
import { RuntimeError } from "../errors.js";
|
|
2
2
|
import { kimiVersionsWith } from "../kimi-releases.js";
|
|
3
|
-
import { parseDurationMs, validateThinkingEffort } from "../parsing.js";
|
|
3
|
+
import { MAX_SESSION_REFERENCES, parseDurationMs, SESSION_REFERENCE_ID_MAX, validateThinkingEffort } from "../parsing.js";
|
|
4
|
+
const DEFAULT_WAIT_TIMEOUT_MIN_MS = 1_000;
|
|
5
|
+
const MAX_WAIT_TIMEOUT_MS = 86_400_000;
|
|
4
6
|
const WORKSPACE_PROPERTY = {
|
|
5
7
|
type: "string",
|
|
6
|
-
description: "Absolute workspace directory. Required when the host does not configure a default
|
|
8
|
+
description: "Absolute workspace directory. Required when the host does not configure a default.",
|
|
7
9
|
};
|
|
8
10
|
const MODEL_PROPERTY = {
|
|
9
11
|
type: "string",
|
|
10
|
-
description: "
|
|
12
|
+
description: "Configured Kimi model alias. Omit to use the default model; never guess an alias.",
|
|
11
13
|
};
|
|
12
14
|
const THINKING_PROPERTY = {
|
|
13
15
|
type: "string",
|
|
14
|
-
description: "Per-run thinking-effort request
|
|
16
|
+
description: "Per-run thinking-effort request (off, low, medium, high). Not observable on the wire.",
|
|
15
17
|
};
|
|
16
18
|
const BUDGET_PROPERTY = {
|
|
17
19
|
type: "string",
|
|
18
|
-
description: "Finite duration such as 30m, 1h, or 90s; bare numbers mean minutes. Maximum 24h.
|
|
20
|
+
description: "Finite duration such as 30m, 1h, or 90s; bare numbers mean minutes. Maximum 24h.",
|
|
21
|
+
};
|
|
22
|
+
const WAIT_PROPERTIES = {
|
|
23
|
+
wait: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
description: "Wait for completion and return the result directly (default true on standard calls; set false to get job_id immediately for parallel fan-out).",
|
|
26
|
+
},
|
|
27
|
+
wait_timeout_ms: {
|
|
28
|
+
type: "integer",
|
|
29
|
+
minimum: DEFAULT_WAIT_TIMEOUT_MIN_MS,
|
|
30
|
+
maximum: MAX_WAIT_TIMEOUT_MS,
|
|
31
|
+
description: "Maximum milliseconds this call waits before returning a running handle (job keeps running in background; poll with kimi_job).",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const REFERENCE_PROPERTIES = {
|
|
35
|
+
referenced_sessions: {
|
|
36
|
+
type: "array",
|
|
37
|
+
items: { type: "string" },
|
|
38
|
+
description: "Up to 8 earlier job IDs or Kimi session IDs whose main logs Kimi may consult.",
|
|
39
|
+
},
|
|
19
40
|
};
|
|
20
41
|
const COMMON_PROPERTIES = {
|
|
21
42
|
workspace: WORKSPACE_PROPERTY,
|
|
22
43
|
model: MODEL_PROPERTY,
|
|
23
44
|
thinking: THINKING_PROPERTY,
|
|
24
45
|
budget: BUDGET_PROPERTY,
|
|
46
|
+
...WAIT_PROPERTIES,
|
|
25
47
|
};
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
type: "
|
|
29
|
-
|
|
48
|
+
const READ_SCHEMA = schema({
|
|
49
|
+
mode: {
|
|
50
|
+
type: "string",
|
|
51
|
+
enum: ["ask", "review", "challenge", "swarm"],
|
|
52
|
+
description: "ask (default): explain/investigate; review: defect review of diff; challenge: adversarial design critique; swarm: read-only parallel fan-out.",
|
|
30
53
|
},
|
|
31
|
-
|
|
54
|
+
prompt: {
|
|
32
55
|
type: "string",
|
|
33
|
-
description: "
|
|
56
|
+
description: "User question, review focus, or swarm objective, preserved verbatim. Required for ask (unless resume is set) and swarm.",
|
|
34
57
|
},
|
|
35
|
-
|
|
58
|
+
...COMMON_PROPERTIES,
|
|
59
|
+
base: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "Git base ref for review/challenge (committed branch diff; incompatible with uncommitted=true).",
|
|
62
|
+
},
|
|
63
|
+
uncommitted: {
|
|
36
64
|
type: "boolean",
|
|
37
|
-
description: "
|
|
65
|
+
description: "Review uncommitted/untracked working-tree changes (default for review/challenge; incompatible with base).",
|
|
66
|
+
},
|
|
67
|
+
resume: {
|
|
68
|
+
type: "string",
|
|
69
|
+
description: "Resume session for ask: \"last\" (latest repo session, may pair with prompt) or a job/session ID (no prompt).",
|
|
38
70
|
},
|
|
39
|
-
};
|
|
40
|
-
const PROMPT_PROPERTY = {
|
|
41
|
-
type: "string",
|
|
42
|
-
description: "The complete user request, preserved verbatim. Required except when resume or resume_latest supplies the continuation context.",
|
|
43
|
-
};
|
|
44
|
-
const OBJECTIVE_PROPERTY = {
|
|
45
|
-
type: "string",
|
|
46
|
-
description: "The complete objective, preserved verbatim.",
|
|
47
|
-
};
|
|
48
|
-
const SCOPE_PROPERTIES = {
|
|
49
71
|
read_roots: {
|
|
50
72
|
type: "array",
|
|
51
73
|
items: { type: "string" },
|
|
52
|
-
description: "
|
|
74
|
+
description: "Additional absolute directories Kimi may read outside workspace.",
|
|
53
75
|
},
|
|
54
76
|
network: {
|
|
55
77
|
type: "boolean",
|
|
56
|
-
description: "Enable web search and URL fetch
|
|
78
|
+
description: "Enable web search and URL fetch (file reads remain confined to workspace + read_roots). Default false.",
|
|
57
79
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
type: "string",
|
|
70
|
-
description: "Optional Git base ref. The committed branch diff is authoritative; dirty current files are not treated as committed snapshots.",
|
|
71
|
-
};
|
|
72
|
-
const TURNS_PROPERTY = {
|
|
73
|
-
type: "integer",
|
|
74
|
-
minimum: 1,
|
|
75
|
-
description: "Soft turn-count hint included in the objective. The finite budget is the hard bound.",
|
|
76
|
-
};
|
|
77
|
-
const CAP_PROPERTY = {
|
|
78
|
-
type: "integer",
|
|
79
|
-
minimum: 1,
|
|
80
|
-
description: "Soft hint for total subagent count, not a hook-enforced limit.",
|
|
81
|
-
};
|
|
82
|
-
const MAX_CONCURRENCY_PROPERTY = {
|
|
83
|
-
type: "integer",
|
|
84
|
-
minimum: 1,
|
|
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.`,
|
|
86
|
-
};
|
|
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.";
|
|
88
|
-
function schema(properties, required = []) {
|
|
89
|
-
return { type: "object", properties, required, additionalProperties: false };
|
|
90
|
-
}
|
|
91
|
-
const OPERATION_SPECS = {
|
|
92
|
-
kimi_ask: {
|
|
93
|
-
kind: "ask",
|
|
94
|
-
command: ["ask"],
|
|
95
|
-
write: false,
|
|
96
|
-
summary: "Start an independent read-only Kimi repository explanation.",
|
|
97
|
-
inputSchema: schema({ ...COMMON_PROPERTIES, ...SCOPE_PROPERTIES, prompt: PROMPT_PROPERTY, ...RESUME_PROPERTIES }),
|
|
80
|
+
cap: {
|
|
81
|
+
type: "integer",
|
|
82
|
+
minimum: 1,
|
|
83
|
+
maximum: 25,
|
|
84
|
+
description: "Soft hint for total swarm subagent count.",
|
|
85
|
+
},
|
|
86
|
+
max_concurrency: {
|
|
87
|
+
type: "integer",
|
|
88
|
+
minimum: 1,
|
|
89
|
+
maximum: 16,
|
|
90
|
+
description: `Maximum simultaneous swarm workers on Kimi Code ${kimiVersionsWith("bounded-swarm").join("/")}+ (1 runs directly).`,
|
|
98
91
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
...REFERENCE_PROPERTIES,
|
|
93
|
+
});
|
|
94
|
+
const WRITE_SCHEMA = schema({
|
|
95
|
+
mode: {
|
|
96
|
+
type: "string",
|
|
97
|
+
enum: ["rescue", "pursue", "swarm_patch"],
|
|
98
|
+
description: "rescue (default): bounded workspace edit/fix; pursue: autonomous multi-turn goal; swarm_patch: parallel edits in isolated worktree returning a git patch without modifying the real tree.",
|
|
105
99
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
write: true,
|
|
110
|
-
summary: "Start a bounded write-capable Kimi investigation or fix inside the validated workspace. Review the resulting changes; no commit is made.",
|
|
111
|
-
inputSchema: schema({ ...COMMON_PROPERTIES, prompt: PROMPT_PROPERTY, ...RESUME_PROPERTIES }),
|
|
100
|
+
prompt: {
|
|
101
|
+
type: "string",
|
|
102
|
+
description: "Task objective or edit instruction, preserved verbatim. Never mutates Git.",
|
|
112
103
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
summary: "Start explicitly autonomous Kimi goal mode with a finite hard budget and workspace write limits. Use only for hands-off objectives, not a single bounded fix.",
|
|
118
|
-
inputSchema: schema({ ...COMMON_PROPERTIES, objective: OBJECTIVE_PROPERTY, turns: TURNS_PROPERTY }, ["objective"]),
|
|
104
|
+
...COMMON_PROPERTIES,
|
|
105
|
+
resume: {
|
|
106
|
+
type: "string",
|
|
107
|
+
description: "Resume session for rescue: \"last\" or a job/session ID.",
|
|
119
108
|
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
inputSchema: schema({ ...COMMON_PROPERTIES, ...SCOPE_PROPERTIES, objective: OBJECTIVE_PROPERTY, cap: CAP_PROPERTY, max_concurrency: MAX_CONCURRENCY_PROPERTY }, ["objective"]),
|
|
109
|
+
cap: {
|
|
110
|
+
type: "integer",
|
|
111
|
+
minimum: 1,
|
|
112
|
+
maximum: 25,
|
|
113
|
+
description: "Soft hint for total swarm_patch subagent count.",
|
|
126
114
|
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
115
|
+
max_concurrency: {
|
|
116
|
+
type: "integer",
|
|
117
|
+
minimum: 1,
|
|
118
|
+
maximum: 16,
|
|
119
|
+
description: "Maximum simultaneous swarm_patch workers (default 1 runs directly).",
|
|
120
|
+
},
|
|
121
|
+
...REFERENCE_PROPERTIES,
|
|
122
|
+
});
|
|
123
|
+
const JOB_SCHEMA = schema({
|
|
124
|
+
action: {
|
|
125
|
+
type: "string",
|
|
126
|
+
enum: ["list", "status", "result", "wait", "cancel", "replay", "recover_swarm"],
|
|
127
|
+
description: "Job lifecycle action to run in this workspace.",
|
|
128
|
+
},
|
|
129
|
+
job_id: {
|
|
130
|
+
type: "string",
|
|
131
|
+
description: "Job UUID. Required for replay and recover_swarm; optional for status/result/wait/cancel (defaults to latest repo job).",
|
|
132
|
+
},
|
|
133
|
+
workspace: WORKSPACE_PROPERTY,
|
|
134
|
+
status_filter: {
|
|
135
|
+
type: "string",
|
|
136
|
+
enum: ["running", "completed", "failed", "cancelled"],
|
|
137
|
+
description: "Filter jobs returned by action=list.",
|
|
138
|
+
},
|
|
139
|
+
limit: {
|
|
140
|
+
type: "integer",
|
|
141
|
+
minimum: 1,
|
|
142
|
+
maximum: 100,
|
|
143
|
+
description: "Maximum jobs to return for action=list (default 20).",
|
|
144
|
+
},
|
|
145
|
+
wait_ms: {
|
|
146
|
+
type: "integer",
|
|
147
|
+
minimum: 100,
|
|
148
|
+
maximum: 600_000,
|
|
149
|
+
description: "Poll duration in ms for action=wait (default 30000).",
|
|
150
|
+
},
|
|
151
|
+
apply: {
|
|
152
|
+
type: "boolean",
|
|
153
|
+
description: "Apply cleanup and patch capture during recover_swarm (default false previews only).",
|
|
154
|
+
},
|
|
155
|
+
}, ["action"]);
|
|
156
|
+
const SETUP_SCHEMA = schema({
|
|
157
|
+
action: {
|
|
158
|
+
type: "string",
|
|
159
|
+
enum: ["check", "models", "install", "install_kimi", "repair_sessions"],
|
|
160
|
+
description: "check (default): verify PreToolUse hook & binary; models: list configured model aliases; install: write/repair hook; install_kimi: install newest certified CLI; repair_sessions: preview/repair Kimi session titles.",
|
|
133
161
|
},
|
|
134
|
-
};
|
|
135
|
-
const JOB_CONTROL_SCHEMA = schema({
|
|
136
162
|
workspace: WORKSPACE_PROPERTY,
|
|
137
|
-
|
|
138
|
-
|
|
163
|
+
apply: {
|
|
164
|
+
type: "boolean",
|
|
165
|
+
description: "Write repaired session previews during repair_sessions (default false previews only).",
|
|
166
|
+
},
|
|
167
|
+
all: {
|
|
168
|
+
type: "boolean",
|
|
169
|
+
description: "Scope repair_sessions across all repositories.",
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
function schema(properties, required = []) {
|
|
173
|
+
return { type: "object", properties, required, additionalProperties: false };
|
|
174
|
+
}
|
|
139
175
|
export const MCP_TOOL_DEFINITIONS = [
|
|
140
|
-
|
|
141
|
-
name:
|
|
142
|
-
description:
|
|
143
|
-
inputSchema:
|
|
176
|
+
{
|
|
177
|
+
name: "kimi_read",
|
|
178
|
+
description: "Run a read-only Kimi operation (ask, review, challenge, or parallel read-only swarm). Waits for prose by default on standard tool calls; set wait=false to return job_id immediately.",
|
|
179
|
+
inputSchema: READ_SCHEMA,
|
|
144
180
|
annotations: {
|
|
145
|
-
title:
|
|
146
|
-
readOnlyHint:
|
|
147
|
-
destructiveHint:
|
|
181
|
+
title: "kimi read",
|
|
182
|
+
readOnlyHint: true,
|
|
183
|
+
destructiveHint: false,
|
|
148
184
|
idempotentHint: false,
|
|
149
185
|
openWorldHint: true,
|
|
150
186
|
},
|
|
151
|
-
}
|
|
187
|
+
},
|
|
152
188
|
{
|
|
153
|
-
name: "
|
|
154
|
-
description: "
|
|
155
|
-
inputSchema:
|
|
156
|
-
annotations: {
|
|
189
|
+
name: "kimi_write",
|
|
190
|
+
description: "Run a workspace-confined write operation: rescue (single-turn edit/test), pursue (autonomous multi-turn goal), or swarm_patch (isolated worktree producing a git patch without modifying the working tree).",
|
|
191
|
+
inputSchema: WRITE_SCHEMA,
|
|
192
|
+
annotations: {
|
|
193
|
+
title: "kimi write",
|
|
194
|
+
readOnlyHint: false,
|
|
195
|
+
destructiveHint: true,
|
|
196
|
+
idempotentHint: false,
|
|
197
|
+
openWorldHint: true,
|
|
198
|
+
},
|
|
157
199
|
},
|
|
158
200
|
{
|
|
159
|
-
name: "
|
|
160
|
-
description: "
|
|
161
|
-
inputSchema:
|
|
162
|
-
annotations: {
|
|
201
|
+
name: "kimi_job",
|
|
202
|
+
description: "Inspect, await, cancel, replay, or recover Kimi jobs in the workspace.",
|
|
203
|
+
inputSchema: JOB_SCHEMA,
|
|
204
|
+
annotations: {
|
|
205
|
+
title: "kimi job",
|
|
206
|
+
readOnlyHint: false,
|
|
207
|
+
destructiveHint: false,
|
|
208
|
+
idempotentHint: false,
|
|
209
|
+
openWorldHint: false,
|
|
210
|
+
},
|
|
163
211
|
},
|
|
164
212
|
{
|
|
165
|
-
name: "
|
|
166
|
-
description: "
|
|
167
|
-
inputSchema:
|
|
168
|
-
annotations: {
|
|
213
|
+
name: "kimi_setup",
|
|
214
|
+
description: "Verify or install the Kimi PreToolUse safety hook, list configured models, install a certified Kimi CLI binary, or repair session titles.",
|
|
215
|
+
inputSchema: SETUP_SCHEMA,
|
|
216
|
+
annotations: {
|
|
217
|
+
title: "kimi setup",
|
|
218
|
+
readOnlyHint: false,
|
|
219
|
+
destructiveHint: false,
|
|
220
|
+
idempotentHint: true,
|
|
221
|
+
openWorldHint: true,
|
|
222
|
+
},
|
|
169
223
|
},
|
|
170
224
|
];
|
|
171
225
|
export function isMcpModelToolName(name) {
|
|
172
|
-
return
|
|
226
|
+
return name === "kimi_read" || name === "kimi_write";
|
|
173
227
|
}
|
|
174
228
|
export function buildMcpOperationInvocation(name, input) {
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
const args = readArguments(input, Object.keys(properties));
|
|
229
|
+
const allowedKeys = Object.keys((name === "kimi_read" ? READ_SCHEMA : WRITE_SCHEMA).properties);
|
|
230
|
+
const args = readArguments(input, allowedKeys);
|
|
178
231
|
const workspace = optionalString(args, "workspace");
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
232
|
+
const wait = optionalBoolean(args, "wait") ?? true;
|
|
233
|
+
const waitTimeoutMs = optionalBoundedInteger(args, "wait_timeout_ms", DEFAULT_WAIT_TIMEOUT_MIN_MS, MAX_WAIT_TIMEOUT_MS);
|
|
234
|
+
if (name === "kimi_read") {
|
|
235
|
+
const mode = readMode(args);
|
|
236
|
+
const kind = mode;
|
|
237
|
+
const argv = mode === "ask" ? ["ask"] : mode === "review" ? ["review"] : ["task", mode];
|
|
238
|
+
appendCommonOptions(argv, args, mode === "swarm" ? "safety" : "response");
|
|
239
|
+
appendScopeOptions(argv, args);
|
|
240
|
+
appendReferenceOptions(argv, args);
|
|
241
|
+
const base = args.base === undefined ? undefined : requiredNonEmptyString(args, "base");
|
|
242
|
+
const uncommitted = optionalBoolean(args, "uncommitted");
|
|
243
|
+
const resume = args.resume === undefined ? undefined : requiredNonEmptyString(args, "resume");
|
|
244
|
+
const cap = optionalBoundedInteger(args, "cap", 1, 25);
|
|
245
|
+
const maxConcurrency = optionalBoundedInteger(args, "max_concurrency", 1, 16);
|
|
246
|
+
const prompt = optionalString(args, "prompt");
|
|
247
|
+
if (mode !== "review" && mode !== "challenge" && (base !== undefined || uncommitted !== undefined)) {
|
|
248
|
+
throw invalidArguments(`base and uncommitted are only valid for mode "review" or "challenge" (got ${mode}).`);
|
|
249
|
+
}
|
|
250
|
+
if (base !== undefined && uncommitted === true) {
|
|
251
|
+
throw invalidArguments("base and uncommitted=true are mutually exclusive.");
|
|
252
|
+
}
|
|
253
|
+
if ((mode === "review" || mode === "challenge") && uncommitted === false && base === undefined) {
|
|
254
|
+
throw invalidArguments('uncommitted=false requires a base ref for mode "review" or "challenge".');
|
|
255
|
+
}
|
|
256
|
+
if (mode !== "ask" && resume !== undefined) {
|
|
257
|
+
throw invalidArguments(`resume is only valid for mode "ask" (got ${mode}).`);
|
|
258
|
+
}
|
|
259
|
+
if (mode !== "swarm" && (cap !== undefined || maxConcurrency !== undefined)) {
|
|
260
|
+
throw invalidArguments(`cap and max_concurrency are only valid for mode "swarm" (got ${mode}).`);
|
|
261
|
+
}
|
|
262
|
+
switch (mode) {
|
|
263
|
+
case "ask": {
|
|
264
|
+
const cleanPrompt = prompt === undefined ? undefined : requiredNonEmptyString(args, "prompt");
|
|
265
|
+
if (resume === "last") {
|
|
266
|
+
argv.push("-r");
|
|
267
|
+
if (cleanPrompt !== undefined)
|
|
268
|
+
argv.push("--", cleanPrompt);
|
|
269
|
+
}
|
|
270
|
+
else if (resume !== undefined) {
|
|
271
|
+
if (cleanPrompt !== undefined) {
|
|
272
|
+
throw invalidArguments('resume with a job/session ID uses the continuation prompt and cannot include prompt; use resume="last" to pair with a new prompt.');
|
|
273
|
+
}
|
|
274
|
+
argv.push("--resume", resume);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
argv.push("--", requiredNonEmptyString(args, "prompt"));
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
196
280
|
}
|
|
197
|
-
|
|
198
|
-
|
|
281
|
+
case "review":
|
|
282
|
+
case "challenge": {
|
|
283
|
+
if (base !== undefined)
|
|
284
|
+
argv.push("--base", base);
|
|
285
|
+
if (prompt !== undefined && prompt.trim().length > 0)
|
|
286
|
+
argv.push("--", prompt);
|
|
287
|
+
break;
|
|
199
288
|
}
|
|
200
|
-
|
|
201
|
-
|
|
289
|
+
case "swarm": {
|
|
290
|
+
if (cap !== undefined)
|
|
291
|
+
argv.push("--cap", String(cap));
|
|
292
|
+
if (maxConcurrency !== undefined)
|
|
293
|
+
argv.push("--max-concurrency", String(maxConcurrency));
|
|
294
|
+
argv.push("--", requiredNonEmptyString(args, "prompt"));
|
|
295
|
+
break;
|
|
202
296
|
}
|
|
203
|
-
if (fresh)
|
|
204
|
-
argv.push("--fresh");
|
|
205
|
-
if (resumeLatest)
|
|
206
|
-
argv.push("-r");
|
|
207
|
-
if (resume !== undefined)
|
|
208
|
-
argv.push("--resume", resume);
|
|
209
|
-
if (prompt !== undefined)
|
|
210
|
-
argv.push("--", prompt);
|
|
211
|
-
break;
|
|
212
297
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
298
|
+
return {
|
|
299
|
+
operationKind: kind,
|
|
300
|
+
...(workspace !== undefined ? { workspace } : {}),
|
|
301
|
+
wait,
|
|
302
|
+
...(waitTimeoutMs !== undefined ? { waitTimeoutMs } : {}),
|
|
303
|
+
argv,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
// kimi_write
|
|
307
|
+
const mode = writeMode(args);
|
|
308
|
+
const kind = mode === "swarm_patch" ? "swarm-write" : mode;
|
|
309
|
+
const argv = mode === "swarm_patch" ? ["task", "swarm"] : ["task", mode];
|
|
310
|
+
appendCommonOptions(argv, args, mode === "rescue" ? "response" : "safety");
|
|
311
|
+
const resume = args.resume === undefined ? undefined : requiredNonEmptyString(args, "resume");
|
|
312
|
+
const cap = optionalBoundedInteger(args, "cap", 1, 25);
|
|
313
|
+
const maxConcurrency = optionalBoundedInteger(args, "max_concurrency", 1, 16);
|
|
314
|
+
const prompt = optionalString(args, "prompt");
|
|
315
|
+
if (mode === "pursue" && args.referenced_sessions !== undefined) {
|
|
316
|
+
throw invalidArguments('referenced_sessions is not supported for mode "pursue".');
|
|
317
|
+
}
|
|
318
|
+
appendReferenceOptions(argv, args);
|
|
319
|
+
if (mode !== "rescue" && resume !== undefined) {
|
|
320
|
+
throw invalidArguments(`resume is only valid for mode "rescue" (got ${mode}).`);
|
|
321
|
+
}
|
|
322
|
+
if (mode !== "swarm_patch" && (cap !== undefined || maxConcurrency !== undefined)) {
|
|
323
|
+
throw invalidArguments(`cap and max_concurrency are only valid for mode "swarm_patch" (got ${mode}).`);
|
|
324
|
+
}
|
|
325
|
+
if (mode === "rescue") {
|
|
326
|
+
const cleanPrompt = prompt === undefined ? undefined : requiredNonEmptyString(args, "prompt");
|
|
327
|
+
if (resume === "last") {
|
|
328
|
+
argv.push("-r");
|
|
329
|
+
if (cleanPrompt !== undefined)
|
|
330
|
+
argv.push("--", cleanPrompt);
|
|
222
331
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
argv.push("--",
|
|
228
|
-
break;
|
|
332
|
+
else if (resume !== undefined) {
|
|
333
|
+
if (cleanPrompt !== undefined) {
|
|
334
|
+
throw invalidArguments('resume with a job/session ID cannot include prompt; use resume="last" to pair with a new prompt.');
|
|
335
|
+
}
|
|
336
|
+
argv.push("--resume", resume);
|
|
229
337
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const cap = optionalPositiveInteger(args, "cap");
|
|
233
|
-
const maxConcurrency = optionalPositiveInteger(args, "max_concurrency");
|
|
234
|
-
if (cap !== undefined)
|
|
235
|
-
argv.push("--cap", String(cap));
|
|
236
|
-
if (maxConcurrency !== undefined)
|
|
237
|
-
argv.push("--max-concurrency", String(maxConcurrency));
|
|
238
|
-
if (kind === "swarm-write")
|
|
239
|
-
argv.push("--write");
|
|
240
|
-
argv.push("--", requiredNonEmptyString(args, "objective"));
|
|
241
|
-
break;
|
|
338
|
+
else {
|
|
339
|
+
argv.push("--fresh", "--", requiredNonEmptyString(args, "prompt"));
|
|
242
340
|
}
|
|
243
341
|
}
|
|
244
|
-
|
|
342
|
+
else if (mode === "pursue") {
|
|
343
|
+
argv.push("--", requiredNonEmptyString(args, "prompt"));
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
if (cap !== undefined)
|
|
347
|
+
argv.push("--cap", String(cap));
|
|
348
|
+
if (maxConcurrency !== undefined)
|
|
349
|
+
argv.push("--max-concurrency", String(maxConcurrency));
|
|
350
|
+
argv.push("--write", "--", requiredNonEmptyString(args, "prompt"));
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
operationKind: kind,
|
|
354
|
+
...(workspace !== undefined ? { workspace } : {}),
|
|
355
|
+
wait,
|
|
356
|
+
...(waitTimeoutMs !== undefined ? { waitTimeoutMs } : {}),
|
|
357
|
+
argv,
|
|
358
|
+
};
|
|
245
359
|
}
|
|
246
360
|
export function readJobControlArguments(input) {
|
|
247
|
-
const args = readArguments(input,
|
|
361
|
+
const args = readArguments(input, Object.keys(JOB_SCHEMA.properties));
|
|
362
|
+
const action = requiredEnum(args, "action", ["list", "status", "result", "wait", "cancel", "replay", "recover_swarm"]);
|
|
363
|
+
const workspace = optionalString(args, "workspace");
|
|
364
|
+
const jobId = args.job_id === undefined ? undefined : requiredNonEmptyString(args, "job_id");
|
|
365
|
+
const statusFilter = args.status_filter === undefined
|
|
366
|
+
? undefined
|
|
367
|
+
: requiredEnum(args, "status_filter", ["running", "completed", "failed", "cancelled"]);
|
|
368
|
+
const limit = optionalBoundedInteger(args, "limit", 1, 100);
|
|
369
|
+
const waitMs = optionalBoundedInteger(args, "wait_ms", 100, 600_000);
|
|
370
|
+
const apply = optionalBoolean(args, "apply");
|
|
371
|
+
if (action !== "list" && (statusFilter !== undefined || limit !== undefined)) {
|
|
372
|
+
throw invalidArguments('status_filter and limit are only valid for action "list".');
|
|
373
|
+
}
|
|
374
|
+
if (action !== "wait" && waitMs !== undefined) {
|
|
375
|
+
throw invalidArguments('wait_ms is only valid for action "wait".');
|
|
376
|
+
}
|
|
377
|
+
if (action !== "recover_swarm" && apply !== undefined) {
|
|
378
|
+
throw invalidArguments('apply is only valid for action "recover_swarm".');
|
|
379
|
+
}
|
|
380
|
+
if ((action === "replay" || action === "recover_swarm") && jobId === undefined) {
|
|
381
|
+
throw invalidArguments(`job_id is required for action "${action}".`);
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
action,
|
|
385
|
+
...(workspace !== undefined ? { workspace } : {}),
|
|
386
|
+
...(jobId !== undefined ? { jobId } : {}),
|
|
387
|
+
...(statusFilter !== undefined ? { statusFilter } : {}),
|
|
388
|
+
...(limit !== undefined ? { limit } : {}),
|
|
389
|
+
...(waitMs !== undefined ? { waitMs } : {}),
|
|
390
|
+
...(apply !== undefined ? { apply } : {}),
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
export function readSetupArguments(input) {
|
|
394
|
+
const args = readArguments(input, Object.keys(SETUP_SCHEMA.properties));
|
|
395
|
+
const actionRaw = optionalString(args, "action") ?? "check";
|
|
396
|
+
const validActions = ["check", "models", "install", "install_kimi", "repair_sessions"];
|
|
397
|
+
if (!validActions.includes(actionRaw)) {
|
|
398
|
+
throw invalidArguments(`action must be one of ${validActions.join(", ")}.`);
|
|
399
|
+
}
|
|
400
|
+
const action = actionRaw;
|
|
401
|
+
const workspace = optionalString(args, "workspace");
|
|
402
|
+
const apply = optionalBoolean(args, "apply");
|
|
403
|
+
const all = optionalBoolean(args, "all");
|
|
404
|
+
if (action !== "repair_sessions" && (apply !== undefined || all !== undefined)) {
|
|
405
|
+
throw invalidArguments('apply and all are only valid for action "repair_sessions".');
|
|
406
|
+
}
|
|
248
407
|
return {
|
|
249
|
-
|
|
250
|
-
|
|
408
|
+
action,
|
|
409
|
+
...(workspace !== undefined ? { workspace } : {}),
|
|
410
|
+
...(apply !== undefined ? { apply } : {}),
|
|
411
|
+
...(all !== undefined ? { all } : {}),
|
|
251
412
|
};
|
|
252
413
|
}
|
|
414
|
+
function readMode(args) {
|
|
415
|
+
const raw = optionalString(args, "mode") ?? "ask";
|
|
416
|
+
if (raw !== "ask" && raw !== "review" && raw !== "challenge" && raw !== "swarm") {
|
|
417
|
+
throw invalidArguments('kimi_read mode must be one of "ask", "review", "challenge", "swarm".');
|
|
418
|
+
}
|
|
419
|
+
return raw;
|
|
420
|
+
}
|
|
421
|
+
function writeMode(args) {
|
|
422
|
+
const raw = optionalString(args, "mode") ?? "rescue";
|
|
423
|
+
if (raw !== "rescue" && raw !== "pursue" && raw !== "swarm_patch") {
|
|
424
|
+
throw invalidArguments('kimi_write mode must be one of "rescue", "pursue", "swarm_patch".');
|
|
425
|
+
}
|
|
426
|
+
return raw;
|
|
427
|
+
}
|
|
253
428
|
function appendCommonOptions(argv, args, budgetKind) {
|
|
254
429
|
const budget = optionalString(args, "budget");
|
|
255
430
|
const model = optionalString(args, "model");
|
|
@@ -265,12 +440,6 @@ function appendCommonOptions(argv, args, budgetKind) {
|
|
|
265
440
|
argv.push("--thinking", thinking);
|
|
266
441
|
}
|
|
267
442
|
}
|
|
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
443
|
/** Type checks only: the companion parser and read-scope resolver own every scope rule. */
|
|
275
444
|
function appendScopeOptions(argv, args) {
|
|
276
445
|
const readRoots = args.read_roots;
|
|
@@ -284,6 +453,23 @@ function appendScopeOptions(argv, args) {
|
|
|
284
453
|
if (optionalBoolean(args, "network") === true)
|
|
285
454
|
argv.push("--network");
|
|
286
455
|
}
|
|
456
|
+
function appendReferenceOptions(argv, args) {
|
|
457
|
+
const references = args.referenced_sessions;
|
|
458
|
+
if (references === undefined)
|
|
459
|
+
return;
|
|
460
|
+
if (!Array.isArray(references) || references.some((reference) => typeof reference !== "string")) {
|
|
461
|
+
throw invalidArguments("referenced_sessions must be an array of strings.");
|
|
462
|
+
}
|
|
463
|
+
const unique = [...new Set(references)];
|
|
464
|
+
if (unique.length > MAX_SESSION_REFERENCES) {
|
|
465
|
+
throw invalidArguments(`referenced_sessions accepts at most ${MAX_SESSION_REFERENCES} distinct sessions; got ${unique.length}.`);
|
|
466
|
+
}
|
|
467
|
+
if (unique.some((reference) => reference.length > SESSION_REFERENCE_ID_MAX)) {
|
|
468
|
+
throw invalidArguments(`referenced_sessions ids are at most ${SESSION_REFERENCE_ID_MAX} characters.`);
|
|
469
|
+
}
|
|
470
|
+
for (const reference of unique)
|
|
471
|
+
argv.push("--reference-session", reference);
|
|
472
|
+
}
|
|
287
473
|
function readArguments(input, allowedKeys) {
|
|
288
474
|
if (input === undefined)
|
|
289
475
|
return {};
|
|
@@ -298,6 +484,13 @@ function readArguments(input, allowedKeys) {
|
|
|
298
484
|
}
|
|
299
485
|
return args;
|
|
300
486
|
}
|
|
487
|
+
function requiredEnum(args, key, values) {
|
|
488
|
+
const value = args[key];
|
|
489
|
+
if (typeof value !== "string" || !values.includes(value)) {
|
|
490
|
+
throw invalidArguments(`${key} must be one of ${values.join(", ")}.`);
|
|
491
|
+
}
|
|
492
|
+
return value;
|
|
493
|
+
}
|
|
301
494
|
function optionalString(args, key) {
|
|
302
495
|
const value = args[key];
|
|
303
496
|
if (value === undefined)
|
|
@@ -320,12 +513,13 @@ function optionalBoolean(args, key) {
|
|
|
320
513
|
throw invalidArguments(`${key} must be a boolean.`);
|
|
321
514
|
return value;
|
|
322
515
|
}
|
|
323
|
-
function
|
|
516
|
+
function optionalBoundedInteger(args, key, min, max) {
|
|
324
517
|
const value = args[key];
|
|
325
518
|
if (value === undefined)
|
|
326
519
|
return undefined;
|
|
327
|
-
if (!Number.isSafeInteger(value) || value
|
|
328
|
-
throw invalidArguments(`${key} must be
|
|
520
|
+
if (!Number.isSafeInteger(value) || value < min || value > max) {
|
|
521
|
+
throw invalidArguments(`${key} must be an integer between ${min} and ${max}.`);
|
|
522
|
+
}
|
|
329
523
|
return value;
|
|
330
524
|
}
|
|
331
525
|
function invalidArguments(message) {
|