kimi-plugin-cc 2.0.7
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/.agents/plugins/marketplace.json +20 -0
- package/.claude-plugin/marketplace.json +16 -0
- package/.claude-plugin/plugin.json +32 -0
- package/CHANGELOG.md +1096 -0
- package/LICENSE +201 -0
- package/README.md +772 -0
- package/agents/kimi-ask.md +82 -0
- package/agents/kimi-challenge.md +82 -0
- package/agents/kimi-pursue.md +91 -0
- package/agents/kimi-rescue.md +85 -0
- package/agents/kimi-review.md +82 -0
- package/agents/kimi-swarm-write.md +92 -0
- package/agents/kimi-swarm.md +83 -0
- package/commands/README.md +16 -0
- package/commands/ask.md +32 -0
- package/commands/cancel.md +17 -0
- package/commands/challenge.md +29 -0
- package/commands/pursue.md +37 -0
- package/commands/replay.md +13 -0
- package/commands/rescue.md +32 -0
- package/commands/result.md +13 -0
- package/commands/review.md +29 -0
- package/commands/setup.md +23 -0
- package/commands/status.md +13 -0
- package/commands/swarm.md +38 -0
- package/dist/background-spawn.js +224 -0
- package/dist/cli-cancellation.js +43 -0
- package/dist/cli-client.js +845 -0
- package/dist/commands/ask.js +327 -0
- package/dist/commands/cancel.js +178 -0
- package/dist/commands/cli-helpers.js +112 -0
- package/dist/commands/models.js +140 -0
- package/dist/commands/not-implemented.js +4 -0
- package/dist/commands/pursue.js +311 -0
- package/dist/commands/registry.js +87 -0
- package/dist/commands/repair-sessions.js +159 -0
- package/dist/commands/replay.js +123 -0
- package/dist/commands/rescue.js +333 -0
- package/dist/commands/result.js +58 -0
- package/dist/commands/review-gate.js +393 -0
- package/dist/commands/review.js +218 -0
- package/dist/commands/setup.js +1132 -0
- package/dist/commands/status.js +27 -0
- package/dist/commands/swarm.js +576 -0
- package/dist/commands/worker.js +31 -0
- package/dist/companion.js +114 -0
- package/dist/config.js +22 -0
- package/dist/errors.js +40 -0
- package/dist/git.js +215 -0
- package/dist/hooks/approval-hook.js +112 -0
- package/dist/hooks/approval-policy.js +254 -0
- package/dist/hooks/config-safety.js +637 -0
- package/dist/hooks/install-paths.js +504 -0
- package/dist/hooks/install.js +281 -0
- package/dist/hooks/managed-block.js +745 -0
- package/dist/hooks/review-gate-stop.js +19 -0
- package/dist/job-store.js +559 -0
- package/dist/jobs.js +202 -0
- package/dist/kimi-command.js +72 -0
- package/dist/kimi-engine.js +624 -0
- package/dist/kimi-errors.js +220 -0
- package/dist/kimi-home.js +9 -0
- package/dist/kimi-timeouts.js +68 -0
- package/dist/kimi-version-probe.js +1410 -0
- package/dist/logging.js +22 -0
- package/dist/native-v2-preflight.js +417 -0
- package/dist/package.json +1 -0
- package/dist/parsing.js +553 -0
- package/dist/paths.js +27 -0
- package/dist/plugin-data.js +98 -0
- package/dist/process-tree.js +448 -0
- package/dist/render.js +159 -0
- package/dist/rescue-approval.js +951 -0
- package/dist/schemas/review-gate-output.js +43 -0
- package/dist/session-title.js +293 -0
- package/dist/stream-json.js +498 -0
- package/dist/types.js +1 -0
- package/dist/vendor/shell-quote/LICENSE +24 -0
- package/dist/vendor/shell-quote/index.js +1 -0
- package/dist/vendor/shell-quote/parse.js +229 -0
- package/dist/vendor/smol-toml/LICENSE +24 -0
- package/dist/vendor/smol-toml/date.js +127 -0
- package/dist/vendor/smol-toml/error.js +63 -0
- package/dist/vendor/smol-toml/extract.js +100 -0
- package/dist/vendor/smol-toml/parse.js +148 -0
- package/dist/vendor/smol-toml/primitive.js +179 -0
- package/dist/vendor/smol-toml/struct.js +184 -0
- package/dist/vendor/smol-toml/util.js +113 -0
- package/dist/version.js +7 -0
- package/docs/migration.md +215 -0
- package/docs/models.md +82 -0
- package/docs/registry-releases.md +70 -0
- package/docs/safety.md +318 -0
- package/docs/session-visibility.md +32 -0
- package/hooks/README.md +9 -0
- package/hooks/hooks.json +16 -0
- package/package.json +67 -0
- package/plugins/kimi-codex/.codex-plugin/plugin.json +39 -0
- package/plugins/kimi-codex/dist/background-spawn.js +224 -0
- package/plugins/kimi-codex/dist/cli-cancellation.js +43 -0
- package/plugins/kimi-codex/dist/cli-client.js +845 -0
- package/plugins/kimi-codex/dist/commands/ask.js +327 -0
- package/plugins/kimi-codex/dist/commands/cancel.js +178 -0
- package/plugins/kimi-codex/dist/commands/cli-helpers.js +112 -0
- package/plugins/kimi-codex/dist/commands/models.js +140 -0
- package/plugins/kimi-codex/dist/commands/not-implemented.js +4 -0
- package/plugins/kimi-codex/dist/commands/pursue.js +311 -0
- package/plugins/kimi-codex/dist/commands/registry.js +87 -0
- package/plugins/kimi-codex/dist/commands/repair-sessions.js +159 -0
- package/plugins/kimi-codex/dist/commands/replay.js +123 -0
- package/plugins/kimi-codex/dist/commands/rescue.js +333 -0
- package/plugins/kimi-codex/dist/commands/result.js +58 -0
- package/plugins/kimi-codex/dist/commands/review-gate.js +393 -0
- package/plugins/kimi-codex/dist/commands/review.js +218 -0
- package/plugins/kimi-codex/dist/commands/setup.js +1132 -0
- package/plugins/kimi-codex/dist/commands/status.js +27 -0
- package/plugins/kimi-codex/dist/commands/swarm.js +576 -0
- package/plugins/kimi-codex/dist/commands/worker.js +31 -0
- package/plugins/kimi-codex/dist/companion.js +114 -0
- package/plugins/kimi-codex/dist/config.js +22 -0
- package/plugins/kimi-codex/dist/errors.js +40 -0
- package/plugins/kimi-codex/dist/git.js +215 -0
- package/plugins/kimi-codex/dist/hooks/approval-hook.js +112 -0
- package/plugins/kimi-codex/dist/hooks/approval-policy.js +254 -0
- package/plugins/kimi-codex/dist/hooks/config-safety.js +637 -0
- package/plugins/kimi-codex/dist/hooks/install-paths.js +504 -0
- package/plugins/kimi-codex/dist/hooks/install.js +281 -0
- package/plugins/kimi-codex/dist/hooks/managed-block.js +745 -0
- package/plugins/kimi-codex/dist/hooks/review-gate-stop.js +19 -0
- package/plugins/kimi-codex/dist/job-store.js +559 -0
- package/plugins/kimi-codex/dist/jobs.js +202 -0
- package/plugins/kimi-codex/dist/kimi-command.js +72 -0
- package/plugins/kimi-codex/dist/kimi-engine.js +624 -0
- package/plugins/kimi-codex/dist/kimi-errors.js +220 -0
- package/plugins/kimi-codex/dist/kimi-home.js +9 -0
- package/plugins/kimi-codex/dist/kimi-timeouts.js +68 -0
- package/plugins/kimi-codex/dist/kimi-version-probe.js +1410 -0
- package/plugins/kimi-codex/dist/logging.js +22 -0
- package/plugins/kimi-codex/dist/native-v2-preflight.js +417 -0
- package/plugins/kimi-codex/dist/package.json +1 -0
- package/plugins/kimi-codex/dist/parsing.js +553 -0
- package/plugins/kimi-codex/dist/paths.js +27 -0
- package/plugins/kimi-codex/dist/plugin-data.js +98 -0
- package/plugins/kimi-codex/dist/process-tree.js +448 -0
- package/plugins/kimi-codex/dist/render.js +159 -0
- package/plugins/kimi-codex/dist/rescue-approval.js +951 -0
- package/plugins/kimi-codex/dist/schemas/review-gate-output.js +43 -0
- package/plugins/kimi-codex/dist/session-title.js +293 -0
- package/plugins/kimi-codex/dist/stream-json.js +498 -0
- package/plugins/kimi-codex/dist/types.js +1 -0
- package/plugins/kimi-codex/dist/vendor/shell-quote/LICENSE +24 -0
- package/plugins/kimi-codex/dist/vendor/shell-quote/index.js +1 -0
- package/plugins/kimi-codex/dist/vendor/shell-quote/parse.js +229 -0
- package/plugins/kimi-codex/dist/vendor/smol-toml/LICENSE +24 -0
- package/plugins/kimi-codex/dist/vendor/smol-toml/date.js +127 -0
- package/plugins/kimi-codex/dist/vendor/smol-toml/error.js +63 -0
- package/plugins/kimi-codex/dist/vendor/smol-toml/extract.js +100 -0
- package/plugins/kimi-codex/dist/vendor/smol-toml/parse.js +148 -0
- package/plugins/kimi-codex/dist/vendor/smol-toml/primitive.js +179 -0
- package/plugins/kimi-codex/dist/vendor/smol-toml/struct.js +184 -0
- package/plugins/kimi-codex/dist/vendor/smol-toml/util.js +113 -0
- package/plugins/kimi-codex/dist/version.js +7 -0
- package/plugins/kimi-codex/scripts/companion.sh +37 -0
- package/plugins/kimi-codex/scripts/review-gate-hook.sh +32 -0
- package/plugins/kimi-codex/skills/kimi-ask/SKILL.md +31 -0
- package/plugins/kimi-codex/skills/kimi-ask/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-cancel/SKILL.md +25 -0
- package/plugins/kimi-codex/skills/kimi-cancel/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +31 -0
- package/plugins/kimi-codex/skills/kimi-challenge/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +30 -0
- package/plugins/kimi-codex/skills/kimi-pursue/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-replay/SKILL.md +25 -0
- package/plugins/kimi-codex/skills/kimi-replay/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +30 -0
- package/plugins/kimi-codex/skills/kimi-rescue/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-result/SKILL.md +25 -0
- package/plugins/kimi-codex/skills/kimi-result/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-review/SKILL.md +31 -0
- package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +32 -0
- package/plugins/kimi-codex/skills/kimi-setup/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-status/SKILL.md +25 -0
- package/plugins/kimi-codex/skills/kimi-status/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +31 -0
- package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +6 -0
- package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +32 -0
- package/plugins/kimi-codex/skills/kimi-swarm-write/agents/openai.yaml +6 -0
- package/scripts/companion.sh +37 -0
- package/scripts/review-gate-hook.sh +32 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { RuntimeError, formatError } from "./errors.js";
|
|
2
|
+
export function classifyManagedCommandFailure(error, commandType, jobId, options) {
|
|
3
|
+
const classification = classifyKimiAvailability(error);
|
|
4
|
+
if (!classification) {
|
|
5
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
6
|
+
}
|
|
7
|
+
const label = formatCommandLabel(commandType);
|
|
8
|
+
const stage = options?.preserveStage && error instanceof RuntimeError
|
|
9
|
+
? error.stage
|
|
10
|
+
: `${commandType}.runtime`;
|
|
11
|
+
// Thread the cause's code and message into `details` so the underlying
|
|
12
|
+
// failure survives the wrap on every channel (formatError renders details
|
|
13
|
+
// as a JSON line; normalizeJobError persists them in the job row). Without
|
|
14
|
+
// this, a CLI_NONZERO_EXIT whose message embeds kimi's stderr tail (e.g.
|
|
15
|
+
// `auth.login_required` on 2026-08-08) was reduced to the generic
|
|
16
|
+
// "run /kimi:setup" advice with the real cause reachable only as `cause`,
|
|
17
|
+
// which no output channel serializes — an LLM caller could not diagnose it.
|
|
18
|
+
const details = { availability: classification.kind };
|
|
19
|
+
if (error instanceof RuntimeError) {
|
|
20
|
+
details.cause_code = error.code;
|
|
21
|
+
}
|
|
22
|
+
if (error instanceof Error && error.message.length > 0) {
|
|
23
|
+
details.cause_message = truncateCauseMessageForDetails(error.message);
|
|
24
|
+
}
|
|
25
|
+
return new RuntimeError(mapAvailabilityCode(classification.kind, commandType), `${label} could not run because ${classification.summary} ${classification.nextStep} Job ${jobId} was persisted as failed.`, stage, error instanceof Error ? { cause: error, details } : { details });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Cap the cause message carried in `details` so a large stderr tail cannot
|
|
29
|
+
* bloat the SQLite job row or the rendered details JSON line. Keep the TAIL
|
|
30
|
+
* end: for a crashed subprocess the informative lines (kimi's own `error:`
|
|
31
|
+
* output) are the trailing bytes of stderr, which cli-helpers appends last.
|
|
32
|
+
*/
|
|
33
|
+
const CAUSE_MESSAGE_DETAILS_MAX = 2000;
|
|
34
|
+
function truncateCauseMessageForDetails(message) {
|
|
35
|
+
if (message.length <= CAUSE_MESSAGE_DETAILS_MAX) {
|
|
36
|
+
return message;
|
|
37
|
+
}
|
|
38
|
+
return `…${message.slice(-CAUSE_MESSAGE_DETAILS_MAX)}`;
|
|
39
|
+
}
|
|
40
|
+
export function summarizeKimiAvailabilityWarning(error, commandType) {
|
|
41
|
+
const classification = classifyKimiAvailability(error);
|
|
42
|
+
if (!classification) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (classification.kind === "auth_unavailable") {
|
|
46
|
+
return `Kimi ${formatCommandLabel(commandType).toLowerCase()} is not configured for model access; allowing stop.`;
|
|
47
|
+
}
|
|
48
|
+
if (classification.kind === "binary_unavailable") {
|
|
49
|
+
return `Kimi ${formatCommandLabel(commandType).toLowerCase()} could not find the Kimi CLI; allowing stop.`;
|
|
50
|
+
}
|
|
51
|
+
if (classification.kind === "startup_failed") {
|
|
52
|
+
return `Kimi ${formatCommandLabel(commandType).toLowerCase()} could not start a usable Kimi subprocess; allowing stop.`;
|
|
53
|
+
}
|
|
54
|
+
switch (classification.kind) {
|
|
55
|
+
case "startup_timeout":
|
|
56
|
+
return `Kimi ${formatCommandLabel(commandType).toLowerCase()} did not respond during startup; allowing stop.`;
|
|
57
|
+
case "initialize_timeout":
|
|
58
|
+
return `Kimi ${formatCommandLabel(commandType).toLowerCase()} did not complete session initialization; allowing stop.`;
|
|
59
|
+
case "response_timeout":
|
|
60
|
+
return `Kimi ${formatCommandLabel(commandType).toLowerCase()} did not return a final response; allowing stop.`;
|
|
61
|
+
case "max_steps_reached":
|
|
62
|
+
return `Kimi ${formatCommandLabel(commandType).toLowerCase()} exhausted its step budget; allowing stop.`;
|
|
63
|
+
case "timeout":
|
|
64
|
+
return `Kimi ${formatCommandLabel(commandType).toLowerCase()} timed out; allowing stop.`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function classifySetupFailure(error) {
|
|
68
|
+
return classifyKimiAvailability(error);
|
|
69
|
+
}
|
|
70
|
+
function classifyKimiAvailability(error) {
|
|
71
|
+
const message = formatError(error);
|
|
72
|
+
// kimi-code's managed OAuth store emits `auth.login_required: OAuth
|
|
73
|
+
// provider "managed:kimi-code" requires login…` on stderr when the token
|
|
74
|
+
// is missing or expired (observed on 0.34.0 after an out-of-band binary
|
|
75
|
+
// upgrade invalidated the token). The line reaches us inside the
|
|
76
|
+
// CLI_NONZERO_EXIT message because cli-helpers embeds the stderr tail.
|
|
77
|
+
// This MUST precede the code-based CLI_NONZERO_EXIT branch below, which
|
|
78
|
+
// would otherwise misclassify a logged-out CLI as startup_failed and
|
|
79
|
+
// point the user at /kimi:setup — which cannot fix auth.
|
|
80
|
+
if (message.includes("auth.login_required")) {
|
|
81
|
+
return {
|
|
82
|
+
kind: "auth_unavailable",
|
|
83
|
+
summary: "the local Kimi CLI is logged out (its OAuth login is missing or expired).",
|
|
84
|
+
nextStep: "Run `kimi login` to re-authenticate, then retry. `/kimi:setup` does not repair auth.",
|
|
85
|
+
runtimeProbe: "ok",
|
|
86
|
+
authProbe: "failed",
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (message.includes("LLM is not set") || message.includes("LLM service error")) {
|
|
90
|
+
return {
|
|
91
|
+
kind: "auth_unavailable",
|
|
92
|
+
summary: "local Kimi authentication or model configuration is not usable.",
|
|
93
|
+
nextStep: "Run `/kimi:setup`, then `kimi login` or fix the local Kimi model configuration and retry.",
|
|
94
|
+
runtimeProbe: "ok",
|
|
95
|
+
authProbe: "failed",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (error instanceof RuntimeError && error.code === "CLI_SPAWN_FAILED") {
|
|
99
|
+
return {
|
|
100
|
+
kind: "binary_unavailable",
|
|
101
|
+
summary: "the Kimi CLI is missing from PATH or not executable in this environment.",
|
|
102
|
+
nextStep: "Run `/kimi:setup` to verify the install, then expose `kimi` on PATH and retry.",
|
|
103
|
+
runtimeProbe: "failed",
|
|
104
|
+
authProbe: "failed",
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// v1.0 cli-client surfaces async ENOENT (Bun) as CLI_PROCESS_ERROR with
|
|
108
|
+
// "spawn ... ENOENT" in the message. Map that to binary_unavailable so
|
|
109
|
+
// the failure message points users at /kimi:setup.
|
|
110
|
+
if (error instanceof RuntimeError &&
|
|
111
|
+
error.code === "CLI_PROCESS_ERROR" &&
|
|
112
|
+
/\bENOENT\b/.test(message)) {
|
|
113
|
+
return {
|
|
114
|
+
kind: "binary_unavailable",
|
|
115
|
+
summary: "the Kimi CLI is missing from PATH or not executable in this environment.",
|
|
116
|
+
nextStep: "Run `/kimi:setup` to verify the install, then expose `kimi` on PATH and retry.",
|
|
117
|
+
runtimeProbe: "failed",
|
|
118
|
+
authProbe: "failed",
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// v1.0 cli-client surfaces non-ENOENT process errors and non-zero
|
|
122
|
+
// exits as CLI_PROCESS_ERROR / CLI_NONZERO_EXIT. Treat both as
|
|
123
|
+
// startup-failed for classifier purposes — the next step is the same
|
|
124
|
+
// (run /kimi:setup) and the distinction between "kimi crashed during
|
|
125
|
+
// init" vs "kimi exited with status 1" is post-hoc.
|
|
126
|
+
if (error instanceof RuntimeError &&
|
|
127
|
+
(error.code === "CLI_PROCESS_ERROR" || error.code === "CLI_NONZERO_EXIT")) {
|
|
128
|
+
return {
|
|
129
|
+
kind: "startup_failed",
|
|
130
|
+
summary: "the Kimi CLI exited before completing the requested operation.",
|
|
131
|
+
nextStep: "Run `/kimi:setup` to verify local Kimi health, then retry.",
|
|
132
|
+
runtimeProbe: "failed",
|
|
133
|
+
authProbe: "failed",
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (error instanceof RuntimeError && error.code === "MAX_STEPS_REACHED") {
|
|
137
|
+
return {
|
|
138
|
+
kind: "max_steps_reached",
|
|
139
|
+
summary: "Kimi exhausted its step budget before finalizing the turn.",
|
|
140
|
+
nextStep: "Retry with a more focused prompt or a higher step budget.",
|
|
141
|
+
runtimeProbe: "ok",
|
|
142
|
+
authProbe: "ok",
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (error instanceof RuntimeError) {
|
|
146
|
+
// STARTUP_TIMEOUT and INITIALIZE_TIMEOUT predate the v1.0 subprocess
|
|
147
|
+
// transport (the v0.4 Wire client had a three-phase startup). The
|
|
148
|
+
// v1.0 cli-client only emits RESPONSE_TIMEOUT, so these branches are
|
|
149
|
+
// defensive — callers that synthesize the old codes (or load v0.4
|
|
150
|
+
// job rows from SQLite) still get a useful classification.
|
|
151
|
+
if (error.code === "STARTUP_TIMEOUT") {
|
|
152
|
+
return {
|
|
153
|
+
kind: "startup_timeout",
|
|
154
|
+
summary: "the Kimi CLI did not respond during startup.",
|
|
155
|
+
nextStep: "Run `/kimi:setup` to verify local Kimi health, then retry.",
|
|
156
|
+
runtimeProbe: "failed",
|
|
157
|
+
authProbe: "failed",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (error.code === "INITIALIZE_TIMEOUT") {
|
|
161
|
+
return {
|
|
162
|
+
kind: "initialize_timeout",
|
|
163
|
+
summary: "the Kimi session started but did not finish initializing in time.",
|
|
164
|
+
nextStep: "Run `/kimi:setup` to verify local Kimi configuration and retry.",
|
|
165
|
+
runtimeProbe: "failed",
|
|
166
|
+
authProbe: "failed",
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (error.code === "RESPONSE_TIMEOUT") {
|
|
170
|
+
return {
|
|
171
|
+
kind: "response_timeout",
|
|
172
|
+
summary: "Kimi started and accepted the prompt but never returned a final response.",
|
|
173
|
+
nextStep: "Reduce the prompt scope (or for /kimi:ask and /kimi:rescue, retry with --background to detach). If the response still hangs after a fresh run, check local Kimi version and report upstream.",
|
|
174
|
+
runtimeProbe: "ok",
|
|
175
|
+
authProbe: "ok",
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (message.includes("timed out")) {
|
|
180
|
+
return {
|
|
181
|
+
kind: "timeout",
|
|
182
|
+
summary: "the Kimi runtime did not become ready within the expected time budget.",
|
|
183
|
+
nextStep: "Run `/kimi:setup` to check local Kimi auth and network health, then retry.",
|
|
184
|
+
runtimeProbe: "failed",
|
|
185
|
+
authProbe: "failed",
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
function mapAvailabilityCode(kind, commandType) {
|
|
191
|
+
const prefix = commandType.toUpperCase();
|
|
192
|
+
switch (kind) {
|
|
193
|
+
case "auth_unavailable":
|
|
194
|
+
return `${prefix}_KIMI_AUTH_UNAVAILABLE`;
|
|
195
|
+
case "binary_unavailable":
|
|
196
|
+
return `${prefix}_KIMI_BINARY_UNAVAILABLE`;
|
|
197
|
+
case "startup_failed":
|
|
198
|
+
return `${prefix}_KIMI_STARTUP_FAILED`;
|
|
199
|
+
case "startup_timeout":
|
|
200
|
+
return `${prefix}_KIMI_STARTUP_TIMEOUT`;
|
|
201
|
+
case "initialize_timeout":
|
|
202
|
+
return `${prefix}_KIMI_INITIALIZE_TIMEOUT`;
|
|
203
|
+
case "response_timeout":
|
|
204
|
+
return `${prefix}_KIMI_RESPONSE_TIMEOUT`;
|
|
205
|
+
case "timeout":
|
|
206
|
+
return `${prefix}_KIMI_TIMEOUT`;
|
|
207
|
+
case "max_steps_reached":
|
|
208
|
+
return `${prefix}_KIMI_MAX_STEPS_REACHED`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function formatCommandLabel(commandType) {
|
|
212
|
+
switch (commandType) {
|
|
213
|
+
case "challenge":
|
|
214
|
+
return "challenge";
|
|
215
|
+
case "review_gate":
|
|
216
|
+
return "review gate";
|
|
217
|
+
default:
|
|
218
|
+
return commandType.replaceAll("_", " ");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export function resolveKimiHome(env, baseCwd = process.cwd()) {
|
|
4
|
+
const override = env.KIMI_CODE_HOME?.trim();
|
|
5
|
+
if (override) {
|
|
6
|
+
return path.resolve(baseCwd, override);
|
|
7
|
+
}
|
|
8
|
+
return path.join(os.homedir(), ".kimi-code");
|
|
9
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Per-command response-budget constants for the v1.0 cli-client path.
|
|
2
|
+
//
|
|
3
|
+
// v0.4 also exposed startup / initialize timeouts plus a generic
|
|
4
|
+
// `withTimeout` helper. Those existed because the Wire transport had a
|
|
5
|
+
// three-phase lifecycle (spawn → initialize → prompt). The v1.0
|
|
6
|
+
// subprocess transport collapses spawn + prompt into a single
|
|
7
|
+
// `runCliPromptWithBudget` call (see `runtime/cli-client.ts`), and
|
|
8
|
+
// startup failures surface as CLI_SPAWN_FAILED / CLI_PROCESS_ERROR —
|
|
9
|
+
// not as separate timeouts. So only the per-command response budgets
|
|
10
|
+
// remain.
|
|
11
|
+
// Budgets are sized for thinking-on workflow (the default since v1.0).
|
|
12
|
+
// kimi-code spends real wallclock on extended reasoning before emitting
|
|
13
|
+
// the first assistant record; pre-alpha.4 budgets (300s/600s) were sized
|
|
14
|
+
// against the non-thinking path and timed out in production smoke
|
|
15
|
+
// testing under default flags. Raised to 900/1800/1800 so a real
|
|
16
|
+
// thinking-on review/rescue session has headroom; review-gate stays at
|
|
17
|
+
// 8s because it fires inside Claude Code's Stop hook and is forced to
|
|
18
|
+
// thinking-off in its own caller.
|
|
19
|
+
/** Ask budget. Conversational; thinking-on free-form reasoning. */
|
|
20
|
+
export const KIMI_ASK_PROMPT_TIMEOUT_MS = 900_000;
|
|
21
|
+
/** Review/challenge budget. Thinking-on single-turn analysis over the workspace. */
|
|
22
|
+
export const KIMI_REVIEW_PROMPT_TIMEOUT_MS = 1_800_000;
|
|
23
|
+
/** Rescue budget. Thinking-on multi-step apply/test/verify loops. */
|
|
24
|
+
export const KIMI_RESCUE_PROMPT_TIMEOUT_MS = 1_800_000;
|
|
25
|
+
/**
|
|
26
|
+
* Pursue (autonomous goal mode) DEFAULT wall-clock ceiling when the user
|
|
27
|
+
* passes no `--budget`. This is the ONLY hard bound on an autonomous goal —
|
|
28
|
+
* headless goal create sets no token/turn budget (only the model, via
|
|
29
|
+
* SetGoalBudget, or this AbortController stops the loop). Larger than the
|
|
30
|
+
* single-turn rescue budget (a goal spans multiple continuation turns) but
|
|
31
|
+
* deliberately finite. Overridable per-job via `--budget` (parsed to ms in
|
|
32
|
+
* parsePursueArgs). See runtime/commands/pursue.ts and docs/safety.md.
|
|
33
|
+
*/
|
|
34
|
+
export const KIMI_PURSUE_DEFAULT_BUDGET_MS = 2_700_000; // 45 minutes
|
|
35
|
+
/**
|
|
36
|
+
* Swarm (read-only parallel fan-out) DEFAULT wall-clock ceiling when the user
|
|
37
|
+
* passes no `--budget`. Read-only swarm opens no write surface, so the only new
|
|
38
|
+
* risk is COST/runaway from N parallel model runs (plus possible nested
|
|
39
|
+
* AgentSwarm). This AbortController is the hard bound on that; the `--cap`
|
|
40
|
+
* subagent count is a soft prompt-injected hint (not hook-enforceable —
|
|
41
|
+
* the hook is stateless and can't count subagents). Sized like the single-turn
|
|
42
|
+
* review budget — a swarm fans review work out in parallel within one process,
|
|
43
|
+
* so 30m of wall-clock is generous headroom. Overridable per-job via `--budget`
|
|
44
|
+
* (parsed to ms in parseSwarmArgs). See runtime/commands/swarm.ts and
|
|
45
|
+
* docs/safety.md.
|
|
46
|
+
*/
|
|
47
|
+
export const KIMI_SWARM_DEFAULT_BUDGET_MS = 1_800_000; // 30 minutes
|
|
48
|
+
/**
|
|
49
|
+
* Review-gate budget. Fires inside Claude Code's Stop hook so any value
|
|
50
|
+
* above the user's perceptible wait makes the gate feel broken.
|
|
51
|
+
*
|
|
52
|
+
* kimi-code 0.1.1 has no per-spawn CLI flag for thinking control
|
|
53
|
+
* (Round 2 multi-agent review caught this — emitting `--no-thinking`
|
|
54
|
+
* triggers an unknown-option crash). The 8s budget assumes the user
|
|
55
|
+
* has either `default_thinking = false` or `[thinking].mode = "off"`
|
|
56
|
+
* in `~/.kimi-code/config.toml`, OR a non-thinking-capable model
|
|
57
|
+
* selected for review-gate (via KIMI_PLUGIN_CC_REVIEW_GATE_MODEL).
|
|
58
|
+
* Under thinking-on the gate will time out — the gate is fail-open on
|
|
59
|
+
* timeout by design, so the worst case is the gate becomes
|
|
60
|
+
* always-allow. See docs/safety.md.
|
|
61
|
+
*/
|
|
62
|
+
export const KIMI_REVIEW_GATE_TIMEOUT_MS = 8_000;
|
|
63
|
+
export function isTimeoutCode(code) {
|
|
64
|
+
return (code === "TIMEOUT" ||
|
|
65
|
+
code === "STARTUP_TIMEOUT" ||
|
|
66
|
+
code === "INITIALIZE_TIMEOUT" ||
|
|
67
|
+
code === "RESPONSE_TIMEOUT");
|
|
68
|
+
}
|