kimi-plugin-cc 2.5.7 → 2.5.8

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.
Files changed (46) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +9 -0
  4. package/README.md +8 -8
  5. package/agents/kimi-swarm-write.md +3 -3
  6. package/agents/kimi-swarm.md +3 -3
  7. package/commands/swarm.md +2 -2
  8. package/dist/cli-client.js +3 -3
  9. package/dist/commands/recover-swarm.js +2 -1
  10. package/dist/commands/setup.js +7 -7
  11. package/dist/commands/swarm.js +40 -35
  12. package/dist/hooks/config-safety.js +5 -3
  13. package/dist/kimi-engine.js +45 -12
  14. package/dist/mcp/operations.js +1 -1
  15. package/dist/stream-json.js +2 -2
  16. package/dist/swarm-activation.js +73 -32
  17. package/dist/version.js +1 -1
  18. package/docs/migration.md +2 -2
  19. package/docs/registry-releases.md +2 -0
  20. package/docs/safety.md +12 -9
  21. package/docs/swarm-recovery.md +3 -1
  22. package/docs/upstream-2.5.3-certification.md +2 -0
  23. package/docs/upstream-2.6.0-certification.md +52 -0
  24. package/package.json +2 -1
  25. package/plugins/kimi-codex/.codex-plugin/plugin.json +1 -1
  26. package/plugins/kimi-codex/dist/cli-client.js +3 -3
  27. package/plugins/kimi-codex/dist/commands/recover-swarm.js +2 -1
  28. package/plugins/kimi-codex/dist/commands/setup.js +7 -7
  29. package/plugins/kimi-codex/dist/commands/swarm.js +40 -35
  30. package/plugins/kimi-codex/dist/hooks/config-safety.js +5 -3
  31. package/plugins/kimi-codex/dist/kimi-engine.js +45 -12
  32. package/plugins/kimi-codex/dist/mcp/operations.js +1 -1
  33. package/plugins/kimi-codex/dist/stream-json.js +2 -2
  34. package/plugins/kimi-codex/dist/swarm-activation.js +73 -32
  35. package/plugins/kimi-codex/dist/version.js +1 -1
  36. package/plugins/kimi-dsh/dist/cli-client.js +3 -3
  37. package/plugins/kimi-dsh/dist/commands/recover-swarm.js +2 -1
  38. package/plugins/kimi-dsh/dist/commands/setup.js +7 -7
  39. package/plugins/kimi-dsh/dist/commands/swarm.js +40 -35
  40. package/plugins/kimi-dsh/dist/hooks/config-safety.js +5 -3
  41. package/plugins/kimi-dsh/dist/kimi-engine.js +45 -12
  42. package/plugins/kimi-dsh/dist/mcp/operations.js +1 -1
  43. package/plugins/kimi-dsh/dist/stream-json.js +2 -2
  44. package/plugins/kimi-dsh/dist/swarm-activation.js +73 -32
  45. package/plugins/kimi-dsh/dist/version.js +1 -1
  46. package/plugins/kimi-dsh/package.json +1 -1
@@ -2,7 +2,7 @@ import { resolveKimiHome } from "../kimi-home.js";
2
2
  import { probeProcessIdentity } from "../process-tree.js";
3
3
  import { recordRecoveryEvent, finishRecoveryRecord } from "../swarm-recovery.js";
4
4
  import { allocateJobId } from "../job-id.js";
5
- import { mkdir, writeFile } from "node:fs/promises";
5
+ import { mkdir, realpath, writeFile } from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import { createCliCancellationHandlers } from "../cli-cancellation.js";
8
8
  import { ResponseTimeoutError, runCliPromptWithBudget } from "../cli-client.js";
@@ -23,46 +23,47 @@ import { assertCliResultSuccess, reassembleProseFromRecords, warnIfSessionIdMiss
23
23
  import { buildKimiSessionTitle, syncKimiSessionTitle } from "../session-title.js";
24
24
  // /kimi:swarm — parallel fan-out, read-only by default and runtime-foreground-only.
25
25
  // A finite wall-clock budget bounds the whole run. --cap is a SOFT total-count
26
- // prompt hint; --max-concurrency is a HARD peak ceiling enforced on kimi-code
27
- // 0.18.0+. The plugin always exports that setting; older read-only swarms retain
28
- // only the wall-clock hard bound. Read/write modes reuse review/rescue lineage,
29
- // and the mandatory PreToolUse hook enforces read-only policy or trusted-worktree
30
- // write confinement on the coordinator and every subagent. Write mode requires
31
- // kimi-code 0.18.0+. Exact 2.3.2, 2.3.3, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.5.2
32
- // and 2.5.3 additionally activate a same-job session through a bounded loopback
33
- // web lifecycle, then resume it through the normal print path. The production
34
- // certification table controls whether each exact version is reachable.
26
+ // prompt hint; --max-concurrency caps normal launches on kimi-code 0.18.0+.
27
+ // Reviewed 2.5.3/2.6.0 schedulers can exceed that cap during rate-limit recovery.
28
+ // The plugin always exports the setting; older read-only swarms retain only the
29
+ // wall-clock hard bound. Read/write modes reuse review/rescue lineage, and the
30
+ // mandatory PreToolUse hook enforces read-only policy or trusted-worktree write
31
+ // confinement on the coordinator and every subagent. Write mode requires
32
+ // kimi-code 0.18.0+. Exact 2.3.2, 2.3.3, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.5.2,
33
+ // and certified 2.5.3 activate a same-job session through a bounded loopback
34
+ // web lifecycle, then resume it through the normal print path. Candidate-only
35
+ // 2.6.0 activation uses that lifecycle too; production 2.6.0 is non-swarm
36
+ // certified and refuses both modes before model spawn. The certification table
37
+ // controls whether each exact version is reachable.
35
38
  const SWARM_SUMMARY_MAX = 120;
36
39
  const SWARM_AGENT_PROFILE = "<swarm>";
37
40
  const SWARM_WRITE_AGENT_PROFILE = "<swarm-write>";
38
41
  /**
39
- * Default concurrency setting when the user passes no `--max-concurrency`.
40
- * The plugin always exports KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY; kimi-code
41
- * 0.18.0+ enforces it as a hard peak ceiling, while older read-only swarms
42
- * ignore it and retain only the wall-clock hard bound. Conservative by design;
43
- * override with an explicit `--max-concurrency N`.
42
+ * Default normal-launch concurrency setting when the user passes no
43
+ * `--max-concurrency`. The plugin always exports
44
+ * KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY; older read-only swarms ignore it and
45
+ * retain only the wall-clock hard bound. Rate-limit recovery can exceed it on
46
+ * reviewed 2.5.3/2.6.0 sources; this is not an unconditional peak guarantee.
44
47
  */
45
48
  export const SWARM_DEFAULT_MAX_CONCURRENCY = 4;
46
49
  /**
47
- * Resolve the effective hard concurrency ceiling: an explicit `--max-concurrency`
48
- * wins; otherwise fall back to SWARM_DEFAULT_MAX_CONCURRENCY so the ceiling is
49
- * never unset. Pure + exported for unit testing (the parser leaves the value
50
- * undefined; swarm.ts owns the default, mirroring `budgetMs`).
50
+ * Resolve the requested normal-launch concurrency: an explicit
51
+ * `--max-concurrency` wins; otherwise use SWARM_DEFAULT_MAX_CONCURRENCY so the
52
+ * setting is never unset. Pure + exported for unit testing (the parser leaves
53
+ * the value undefined; swarm.ts owns the default, mirroring `budgetMs`).
51
54
  */
52
55
  export function resolveSwarmMaxConcurrency(requested) {
53
56
  return requested ?? SWARM_DEFAULT_MAX_CONCURRENCY;
54
57
  }
55
58
  /**
56
- * Default HARD concurrency ceiling for WRITE mode — 1 (serialized) vs read's 4.
57
- * Writes are riskier than reads: disjoint-target partitioning is prompt-only and
58
- * unenforceable (the hook is stateless), so two concurrent `coder` subagents
59
- * racing the same file in the shared worktree would corrupt the patch. Serialize
60
- * by default until a real-binary smoke proves clean concurrent disjoint writes;
61
- * override with an explicit `--max-concurrency N`. Effective only on kimi-code
62
- * 0.18.0+ (the write-mode version gate), so the ceiling is always enforced.
59
+ * Default normal-launch concurrency for WRITE mode — 1 (serialized) vs read's 4.
60
+ * Disjoint-target partitioning is prompt-only, so normal writes serialize by
61
+ * default. Rate-limit recovery can still exceed the requested cap on reviewed
62
+ * 2.5.3/2.6.0 sources; this is not an unconditional serialization guarantee.
63
+ * Override with an explicit `--max-concurrency N`.
63
64
  */
64
65
  export const SWARM_WRITE_DEFAULT_MAX_CONCURRENCY = 1;
65
- /** Resolve the write-mode concurrency ceiling: explicit wins, else default 1. */
66
+ /** Resolve the write-mode normal-launch concurrency: explicit wins, else default 1. */
66
67
  export function resolveSwarmWriteMaxConcurrency(requested) {
67
68
  return requested ?? SWARM_WRITE_DEFAULT_MAX_CONCURRENCY;
68
69
  }
@@ -76,9 +77,10 @@ export function resolveSwarmWriteMaxConcurrency(requested) {
76
77
  * Read-only is NOT enforced by this prose — the PreToolUse hook (swarm label) at
77
78
  * policy index 0 denies every write/edit/shell for the coordinator AND every
78
79
  * subagent, so slimming this text does not move the safety boundary. The optional
79
- * `cap` is a SOFT subagent-count hint (the hook cannot enforce a count). The HARD
80
- * concurrency ceiling is separate: --max-concurrency →
80
+ * `cap` is a SOFT subagent-count hint (the hook cannot enforce a count). The
81
+ * normal-launch concurrency setting is separate: --max-concurrency →
81
82
  * KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY (see executeSwarmJob / cli-client buildKimiCliEnvironment).
83
+ * Reviewed 2.5.3/2.6.0 sources can exceed it during rate-limit recovery.
82
84
  * The --budget wall-clock ceiling is the always-on hard bound on the whole run.
83
85
  */
84
86
  export function buildSwarmPrompt(objective, cap) {
@@ -211,7 +213,7 @@ async function runReadSwarm(parsed, objective, context) {
211
213
  await markJobFailed(store, paths, job, classified, "Swarm failed.", { phase: "failed" });
212
214
  throw classified;
213
215
  }
214
- const completed = await executeSwarmJob(job.job_id, prompt, objective, job.budget_ms, resolveSwarmMaxConcurrency(parsed.maxConcurrency), context);
216
+ const completed = await executeSwarmJob(job.job_id, prompt, objective, job.budget_ms, resolveSwarmMaxConcurrency(parsed.maxConcurrency), context, undefined, await realpath(context.cwd));
215
217
  if (!completed.final_output_path) {
216
218
  throw new RuntimeError("SWARM_RESULT_MISSING", "Swarm finished without a rendered result.", "swarm.result");
217
219
  }
@@ -321,7 +323,7 @@ async function runWriteSwarm(parsed, objective, context) {
321
323
  onPatchCaptureFailure: () => {
322
324
  preserveWorktree = true;
323
325
  },
324
- });
326
+ }, await realpath(worktreePath));
325
327
  if (preserveWorktree && completed.error) {
326
328
  throw new RuntimeError(completed.error.code, completed.error.message, completed.error.stage, {
327
329
  details: completed.error.details,
@@ -391,8 +393,11 @@ async function executeSwarmJob(jobId, prompt, objective, budgetMs, maxConcurrenc
391
393
  * (`spawnCwd`), the hook label is "swarm-write", and `workspaceRoot` (the same
392
394
  * worktree) is exported as the trusted allowlist root + used to capture the
393
395
  * patch. Undefined ⇒ read-only swarm (label "swarm", spawn cwd = job.cwd).
396
+ * Real command paths supply the canonical execution cwd for activation/resume,
397
+ * trusted-root checks, read-mode preflight, and the print spawn. Virtual test
398
+ * doubles may omit the canonical path and retain their original spawn spelling.
394
399
  */
395
- writeMode) {
400
+ writeMode, executionCwd) {
396
401
  const paths = resolvePluginPaths(context.env);
397
402
  await ensurePluginPaths(paths);
398
403
  const store = new JobStore(paths);
@@ -467,7 +472,7 @@ writeMode) {
467
472
  store.saveSwarmRecovery(job.job_id, recovery);
468
473
  }
469
474
  activationOptions = {
470
- cwd: writeMode?.spawnCwd ?? job.cwd,
475
+ cwd: executionCwd ?? writeMode?.spawnCwd ?? job.cwd,
471
476
  env: context.env,
472
477
  command: executionPlan.command,
473
478
  prefixArgs: executionPlan.prefixArgs,
@@ -476,7 +481,7 @@ writeMode) {
476
481
  model: job.model ?? undefined,
477
482
  thinkingEffort: job.thinking_effort ?? undefined,
478
483
  swarmMaxConcurrency: maxConcurrency,
479
- trustedWorkspaceRoot: writeMode?.workspaceRoot,
484
+ trustedWorkspaceRoot: executionCwd ?? writeMode?.workspaceRoot,
480
485
  expectedVersion: executionPlan.kimiVersion ?? undefined,
481
486
  onRecoveryEvent: recovery ? (event) => recordRecoveryEvent(store, recovery, event) : undefined,
482
487
  };
@@ -556,7 +561,7 @@ writeMode) {
556
561
  prompt,
557
562
  commandLabel,
558
563
  swarmMaxConcurrency: maxConcurrency,
559
- trustedWorkspaceRoot: writeMode?.workspaceRoot,
564
+ trustedWorkspaceRoot: executionCwd ?? writeMode?.workspaceRoot,
560
565
  model: job.model ?? undefined,
561
566
  thinkingEffort: job.thinking_effort ?? undefined,
562
567
  resumeSessionId: preactivated?.sessionId,
@@ -596,8 +596,9 @@ function validateVersionSensitiveEvents(events, version) {
596
596
  // 2.0.2 (9d07f634), 2.1.0 (52437299), 2.1.1 (f67e6398), 2.2.0 (472192c3),
597
597
  // 2.3.0 (b5e28fd6), 2.3.1 (684bae9e), 2.3.2 (b8dd3a13), 2.3.3 (ec495f0c),
598
598
  // 2.4.0 (f26e4d91), 2.4.1 (2c73f3f5), 2.5.0 (41c34143), 2.5.1 (1b02030d),
599
- // 2.5.2 (1c142a00), and 2.5.3 (5af9942e):
600
- // the additive events and HookDefSchema are unchanged.
599
+ // 2.5.2 (1c142a00), 2.5.3 (5af9942e), and 2.6.0 (740d6c0b):
600
+ // the additive events and HookDefSchema are unchanged. Exact 2.6.0 schema acceptance
601
+ // covers the narrowed non-swarm production certification, not swarm operations.
601
602
  // Require the full version string AND matching components; no inferred 2.x compatibility.
602
603
  if (version.major === 2 && ((version.minor === 0 && ((version.version === "2.0.0" && version.patch === 0) ||
603
604
  (version.version === "2.0.1" && version.patch === 1) ||
@@ -614,7 +615,8 @@ function validateVersionSensitiveEvents(events, version) {
614
615
  (version.minor === 5 && ((version.version === "2.5.0" && version.patch === 0) ||
615
616
  (version.version === "2.5.1" && version.patch === 1) ||
616
617
  (version.version === "2.5.2" && version.patch === 2) ||
617
- (version.version === "2.5.3" && version.patch === 3))))) {
618
+ (version.version === "2.5.3" && version.patch === 3))) ||
619
+ (version.minor === 6 && ((version.version === "2.6.0" && version.patch === 0))))) {
618
620
  return { valid: true };
619
621
  }
620
622
  if (version.major !== 0) {
@@ -50,14 +50,29 @@ export const NATIVE_V2_CERTIFIED_VERSIONS = Object.freeze([
50
50
  "2.5.2",
51
51
  "2.5.3",
52
52
  ]);
53
+ /**
54
+ * Exact releases certified only for review, challenge, ask, rescue, review_gate
55
+ * and pursue. Their upstream rate-limit recovery can exceed AgentSwarm's
56
+ * configured maximum, so both swarm operations refuse before model spawn.
57
+ */
58
+ export const NATIVE_V2_NON_SWARM_VERSIONS = Object.freeze(["2.6.0"]);
59
+ /**
60
+ * Any-operation union used by setup and engine selection. The older
61
+ * NATIVE_V2_CERTIFIED_VERSIONS export stays all-operation-only for consumers
62
+ * that choose a full-swarm pin automatically.
63
+ */
64
+ export const NATIVE_V2_ANY_OPERATION_VERSIONS = Object.freeze([
65
+ ...NATIVE_V2_CERTIFIED_VERSIONS,
66
+ ...NATIVE_V2_NON_SWARM_VERSIONS,
67
+ ]);
53
68
  /** Per-operation native-v2 certification. One green operation never certifies another. */
54
69
  export const NATIVE_V2_CERTIFIED = new Map([
55
- ["review", NATIVE_V2_CERTIFIED_VERSIONS],
56
- ["challenge", NATIVE_V2_CERTIFIED_VERSIONS],
57
- ["ask", NATIVE_V2_CERTIFIED_VERSIONS],
58
- ["rescue", NATIVE_V2_CERTIFIED_VERSIONS],
59
- ["review_gate", NATIVE_V2_CERTIFIED_VERSIONS],
60
- ["pursue", NATIVE_V2_CERTIFIED_VERSIONS],
70
+ ["review", NATIVE_V2_ANY_OPERATION_VERSIONS],
71
+ ["challenge", NATIVE_V2_ANY_OPERATION_VERSIONS],
72
+ ["ask", NATIVE_V2_ANY_OPERATION_VERSIONS],
73
+ ["rescue", NATIVE_V2_ANY_OPERATION_VERSIONS],
74
+ ["review_gate", NATIVE_V2_ANY_OPERATION_VERSIONS],
75
+ ["pursue", NATIVE_V2_ANY_OPERATION_VERSIONS],
61
76
  ["swarm", NATIVE_V2_CERTIFIED_VERSIONS],
62
77
  ["swarm-write", NATIVE_V2_CERTIFIED_VERSIONS],
63
78
  ]);
@@ -77,16 +92,17 @@ export function isNativeV2CertifiedVersion(version) {
77
92
  const normalized = parseVersionLine(version)?.raw;
78
93
  if (normalized === undefined)
79
94
  return false;
80
- return NATIVE_V2_CERTIFIED_VERSIONS.includes(normalized);
95
+ return NATIVE_V2_ANY_OPERATION_VERSIONS.includes(normalized);
81
96
  }
82
97
  /**
83
- * Engine selection for a probed binary: native v2 when the exact version is
84
- * certified for this operation, else legacy-v1 (whose own tested-range check
85
- * still applies). kimi-code 0.42.0 removed the v1 engine, so a v1 plan on a
86
- * ≥0.42 binary is refused by the legacy range rather than silently run on v2.
98
+ * Select native v2 for an exactly certified version or a test-only operation
99
+ * admission, then enforce scope in assertCertifiedCapability. A narrowed
100
+ * release must not fall back to legacy-v1 for an excluded operation.
87
101
  */
88
102
  export function selectIntendedEngine(operationKind, probe) {
89
- return isNativeV2Certified(operationKind, probe.version) ? "native-v2" : "legacy-v1";
103
+ return isNativeV2CertifiedVersion(probe.version) || isNativeV2Certified(operationKind, probe.version)
104
+ ? "native-v2"
105
+ : "legacy-v1";
90
106
  }
91
107
  const UNSAFE_EXPERIMENTAL_VALUES = new Set(["1", "true", "yes", "on"]);
92
108
  /**
@@ -547,6 +563,23 @@ function assertExecutionPlanShape(plan) {
547
563
  }
548
564
  function nativeV2NotCertified(operationKind, version) {
549
565
  const certified = NATIVE_V2_CERTIFIED.get(operationKind) ?? [];
566
+ const normalized = version === null ? undefined : parseVersionLine(version)?.raw;
567
+ if (normalized !== undefined &&
568
+ NATIVE_V2_NON_SWARM_VERSIONS.includes(normalized) &&
569
+ (operationKind === "swarm" || operationKind === "swarm-write")) {
570
+ return new RuntimeError("KIMI_CAPABILITY_NOT_CERTIFIED", `Refusing ${operationKind}: kimi-code ${normalized} is certified only for non-swarm operations (review, challenge, ask, rescue, review_gate, pursue). Its upstream rate-limit recovery can exceed AgentSwarm's configured maximum, so this plugin refuses AgentSwarm before model spawn. Use a non-swarm operation on ${normalized}, or select a version explicitly certified for ${operationKind}.`, "kimi-engine.capability", {
571
+ details: {
572
+ refusal_kind: "v2-swarm-not-certified",
573
+ certification_scope: "non-swarm",
574
+ retryable_after_setup: false,
575
+ operation_kind: operationKind,
576
+ intended_engine: "native-v2",
577
+ kimi_version: normalized,
578
+ certified_versions: [...certified],
579
+ certified_operations: ["review", "challenge", "ask", "rescue", "review_gate", "pursue"],
580
+ },
581
+ });
582
+ }
550
583
  const observed = version === null ? "an unprobed version" : `kimi-code ${version}`;
551
584
  return new RuntimeError("KIMI_CAPABILITY_NOT_CERTIFIED", `Refusing ${operationKind} on native v2: ${observed} is not in this operation's exactly certified set [${certified.join(", ")}]. Update kimi-plugin-cc to a release that certifies this kimi-code 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 repair path.`, "kimi-engine.capability", {
552
585
  details: {
@@ -65,7 +65,7 @@ const CAP_PROPERTY = {
65
65
  const MAX_CONCURRENCY_PROPERTY = {
66
66
  type: "integer",
67
67
  minimum: 1,
68
- description: "Hard peak subagent concurrency on supported Kimi Code versions. Distinct from the soft total cap.",
68
+ description: "Requested normal-launch subagent concurrency on supported Kimi Code versions. Rate-limit recovery can exceed it on reviewed 2.5.3/2.6.0 sources. Distinct from the soft total cap.",
69
69
  };
70
70
  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
71
  function schema(properties, required = []) {
@@ -23,8 +23,8 @@
23
23
  // stream, not on a separate channel.
24
24
  // - thinking.delta events are silently discarded by the CLI's
25
25
  // PromptJsonWriter (`writeThinkingDelta(): void {}`).
26
- // - tool.progress events are written to stderr only, never entering
27
- // stream-json.
26
+ // - tool.updated output/status events are written to stderr only, never
27
+ // entering stream-json.
28
28
  // - assistant messages are only emitted when content OR tool_calls are
29
29
  // non-empty; we still defend against the empty case for resilience.
30
30
  export const MAX_STREAM_JSON_LINE_BYTES = 1_048_576;
@@ -10,7 +10,8 @@ import { assertExecutionPlanMatchesSpawn, assertNoUnsafeExperimentalSelector, }
10
10
  import { resolveKimiHome } from "./kimi-home.js";
11
11
  import { assertNativeV2Preflight } from "./native-v2-preflight.js";
12
12
  import { collectDescendantIdentities, collectProcessGroupsIdentities, probeProcessIdentity, revalidateProcessIdentities, waitForProcessTreeExit, } from "./process-tree.js";
13
- const PREACTIVATION_VERSIONS = ["2.3.2", "2.3.3", "2.4.0", "2.4.1", "2.5.0", "2.5.1", "2.5.2", "2.5.3"];
13
+ // Exact 2.6.0 is an integration candidate, not a production-certified version.
14
+ const PREACTIVATION_VERSIONS = ["2.3.2", "2.3.3", "2.4.0", "2.4.1", "2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0"];
14
15
  const READY_TIMEOUT_MS = 10_000;
15
16
  const REST_TIMEOUT_MS = 5_000;
16
17
  // Exact 2.4.0 can take longer than 5s to drain session/workspace lifecycle work.
@@ -337,7 +338,7 @@ async function resolveProfileModel(web, options, failureCode) {
337
338
  }
338
339
  async function createSession(web, options, expectedVersion, failureCode) {
339
340
  const request = { metadata: { cwd: options.cwd } };
340
- if (["2.5.0", "2.5.1", "2.5.2", "2.5.3"].includes(expectedVersion)) {
341
+ if (["2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0"].includes(expectedVersion)) {
341
342
  request.environment_id = "local";
342
343
  request.environment_cwd = options.cwd;
343
344
  }
@@ -348,7 +349,7 @@ async function createSession(web, options, expectedVersion, failureCode) {
348
349
  return { sessionId: data.id, workspaceId: data.workspace_id };
349
350
  }
350
351
  async function verifyLocalEnvironment(web, identity, expectedCwd, expectedVersion, signal, failureCode) {
351
- if (!["2.5.0", "2.5.1", "2.5.2", "2.5.3"].includes(expectedVersion))
352
+ if (!["2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0"].includes(expectedVersion))
352
353
  return;
353
354
  const data = await restData(web, "GET", `/api/v1/sessions/${encodeURIComponent(identity.sessionId)}/environment`, undefined, signal, failureCode);
354
355
  if (!isRecord(data)) {
@@ -368,10 +369,10 @@ async function postSwarmProfile(web, identity, active, model, signal, failureCod
368
369
  await restData(web, "POST", `/api/v1/sessions/${encodeURIComponent(identity.sessionId)}/profile`, { agent_config: agentConfig }, signal, failureCode);
369
370
  }
370
371
  async function verifySwarmStatus(web, identity, active, model, expectedVersion, signal, failureCode) {
371
- const data = ["2.5.0", "2.5.1", "2.5.2", "2.5.3"].includes(expectedVersion)
372
- ? await readWebSocketAgentState(web, identity.sessionId, signal, failureCode)
372
+ const data = ["2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0"].includes(expectedVersion)
373
+ ? await readWebSocketAgentState(web, identity.sessionId, expectedVersion, signal, failureCode)
373
374
  : await restData(web, "GET", `/api/v1/sessions/${encodeURIComponent(identity.sessionId)}/status`, undefined, signal, failureCode);
374
- const source = ["2.5.0", "2.5.1", "2.5.2", "2.5.3"].includes(expectedVersion) ? "agent state" : "/status";
375
+ const source = ["2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0"].includes(expectedVersion) ? "agent state" : "/status";
375
376
  if (!isRecord(data)) {
376
377
  throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} returned an invalid payload.`);
377
378
  }
@@ -381,10 +382,10 @@ async function verifySwarmStatus(web, identity, active, model, expectedVersion,
381
382
  if (data.plan_mode !== false) {
382
383
  throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} did not confirm plan mode is off.`);
383
384
  }
384
- if (["2.5.0", "2.5.1", "2.5.2", "2.5.3"].includes(expectedVersion) && data.tower_mode !== false) {
385
+ if (["2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0"].includes(expectedVersion) && data.tower_mode !== false) {
385
386
  throw failure(failureCode, "swarm-activation.status", "Kimi web agent state did not confirm tower mode is off.");
386
387
  }
387
- const permission = ["2.5.0", "2.5.1", "2.5.2", "2.5.3"].includes(expectedVersion) ? data.permission_mode : data.permission;
388
+ const permission = ["2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0"].includes(expectedVersion) ? data.permission_mode : data.permission;
388
389
  if (permission !== "auto") {
389
390
  throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} did not confirm auto permission mode.`);
390
391
  }
@@ -392,7 +393,7 @@ async function verifySwarmStatus(web, identity, active, model, expectedVersion,
392
393
  throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} did not confirm the selected model alias.`);
393
394
  }
394
395
  }
395
- async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
396
+ async function readWebSocketAgentState(web, sessionId, expectedVersion, signal, failureCode) {
396
397
  throwIfAborted(signal, failureCode, "swarm-activation.status");
397
398
  await refreshOwnedDescendants(web);
398
399
  throwIfAborted(signal, failureCode, "swarm-activation.status");
@@ -400,6 +401,7 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
400
401
  return await new Promise((resolve, reject) => {
401
402
  let socket;
402
403
  const bearerProtocol = `kimi-code.bearer.${web.token}`;
404
+ const legacyControl = expectedVersion !== "2.6.0";
403
405
  const helloId = `swarm-activation-hello-${randomUUID()}`;
404
406
  const subscribeId = `swarm-activation-subscribe-${randomUUID()}`;
405
407
  try {
@@ -418,6 +420,7 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
418
420
  let subscribeSent = false;
419
421
  let subscriptionAcknowledged = false;
420
422
  let closeRequested = false;
423
+ let closeTimer;
421
424
  let latestState;
422
425
  let frames = 0;
423
426
  let receivedChars = 0;
@@ -426,6 +429,8 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
426
429
  }, REST_TIMEOUT_MS);
427
430
  const cleanup = () => {
428
431
  clearTimeout(timer);
432
+ if (closeTimer !== undefined)
433
+ clearTimeout(closeTimer);
429
434
  signal?.removeEventListener("abort", onAbort);
430
435
  socket.removeEventListener("open", onOpen);
431
436
  socket.removeEventListener("message", onMessage);
@@ -460,30 +465,46 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
460
465
  return false;
461
466
  }
462
467
  };
468
+ const handshakeComplete = () => !legacyControl || (serverHello && clientHelloAcknowledged);
469
+ const closeForValidation = () => {
470
+ closeRequested = true;
471
+ try {
472
+ socket.close();
473
+ }
474
+ catch {
475
+ rejectState("Could not close the Kimi web agent-state channel for final validation.");
476
+ }
477
+ };
463
478
  const completeIfReady = () => {
464
- if (serverHello &&
465
- clientHelloAcknowledged &&
466
- subscriptionAcknowledged &&
467
- latestState !== undefined &&
468
- !closeRequested) {
469
- closeRequested = true;
470
- try {
471
- socket.close();
472
- }
473
- catch {
474
- rejectState("Could not close the Kimi web agent-state channel for final validation.");
475
- }
479
+ if (!handshakeComplete() || !subscriptionAcknowledged || latestState === undefined || closeRequested)
480
+ return;
481
+ if (legacyControl) {
482
+ closeForValidation();
483
+ return;
476
484
  }
485
+ closeTimer ??= setTimeout(() => {
486
+ closeTimer = undefined;
487
+ closeForValidation();
488
+ }, 0);
477
489
  };
478
490
  const onOpen = () => {
479
491
  if (socket.protocol !== bearerProtocol) {
480
492
  rejectState("Kimi web did not authenticate the agent-state channel with the expected subprotocol.");
481
493
  return;
482
494
  }
483
- send({
484
- type: "client_hello",
485
- id: helloId,
486
- payload: { client_id: "kimi-plugin-cc-swarm-activation" },
495
+ if (legacyControl) {
496
+ send({
497
+ type: "client_hello",
498
+ id: helloId,
499
+ payload: { client_id: "kimi-plugin-cc-swarm-activation" },
500
+ });
501
+ return;
502
+ }
503
+ subscribeSent = send({
504
+ type: "subscribe",
505
+ request_id: subscribeId,
506
+ session_id: sessionId,
507
+ agent_ids: ["main"],
487
508
  });
488
509
  };
489
510
  const onMessage = (event) => {
@@ -511,7 +532,7 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
511
532
  rejectState("Kimi web agent-state channel returned an invalid frame.");
512
533
  return;
513
534
  }
514
- if (frame.type === "server_hello") {
535
+ if (legacyControl && frame.type === "server_hello") {
515
536
  if (serverHello || !isRecord(frame.payload) ||
516
537
  frame.payload.protocol_version !== 2 ||
517
538
  typeof frame.payload.ws_connection_id !== "string" ||
@@ -524,11 +545,11 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
524
545
  serverHello = true;
525
546
  return;
526
547
  }
527
- if (!serverHello) {
548
+ if (legacyControl && !serverHello) {
528
549
  rejectState("Kimi web agent-state channel sent data before its protocol hello.");
529
550
  return;
530
551
  }
531
- if (frame.type === "ack") {
552
+ if (legacyControl && frame.type === "ack") {
532
553
  if (typeof frame.id !== "string" || typeof frame.code !== "number" || !isRecord(frame.payload)) {
533
554
  rejectState("Kimi web agent-state channel returned an invalid acknowledgement.");
534
555
  return;
@@ -563,8 +584,26 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
563
584
  rejectState("Kimi web agent-state channel returned an unexpected acknowledgement.");
564
585
  return;
565
586
  }
587
+ if (!legacyControl && frame.type === "response") {
588
+ if (typeof frame.request_id !== "string" || !Number.isInteger(frame.code)) {
589
+ rejectState("Kimi web agent-state channel returned an invalid subscription response.");
590
+ return;
591
+ }
592
+ if (frame.request_id !== subscribeId) {
593
+ rejectState("Kimi web agent-state channel returned an unexpected subscription response.");
594
+ return;
595
+ }
596
+ if (subscriptionAcknowledged || !subscribeSent || frame.code !== 0) {
597
+ rejectState("Kimi web agent-state channel did not accept the exact main-session subscription.");
598
+ return;
599
+ }
600
+ subscriptionAcknowledged = true;
601
+ completeIfReady();
602
+ return;
603
+ }
566
604
  if (frame.type === "agent") {
567
- if (!subscribeSent || !isAgentStateFrame(frame, sessionId)) {
605
+ if (!subscribeSent || (!legacyControl && !subscriptionAcknowledged) ||
606
+ !isAgentStateFrame(frame, sessionId)) {
568
607
  rejectState("Kimi web agent-state channel returned invalid or misbound main-agent state.");
569
608
  return;
570
609
  }
@@ -573,9 +612,12 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
573
612
  return;
574
613
  }
575
614
  if (frame.type === "ping") {
576
- if (isRecord(frame.payload) && typeof frame.payload.nonce === "string") {
615
+ if (legacyControl && isRecord(frame.payload) && typeof frame.payload.nonce === "string") {
577
616
  send({ type: "pong", payload: { nonce: frame.payload.nonce } });
578
617
  }
618
+ else if (!legacyControl) {
619
+ send({ type: "pong" });
620
+ }
579
621
  }
580
622
  };
581
623
  const onAbort = () => {
@@ -586,8 +628,7 @@ async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
586
628
  };
587
629
  const onClose = () => {
588
630
  if (closeRequested &&
589
- serverHello &&
590
- clientHelloAcknowledged &&
631
+ handshakeComplete() &&
591
632
  subscriptionAcknowledged &&
592
633
  latestState !== undefined) {
593
634
  settle(latestState);
@@ -4,4 +4,4 @@
4
4
  // and AGENTS.md on every release. A future improvement would read this from
5
5
  // package.json at build time, but that adds a build-step dependency we
6
6
  // don't want yet.
7
- export const KIMI_PLUGIN_CC_VERSION = "2.5.7";
7
+ export const KIMI_PLUGIN_CC_VERSION = "2.5.8";
@@ -115,8 +115,8 @@ export async function runCliPrompt(opts) {
115
115
  const records = [];
116
116
  const malformed = [];
117
117
  // Rolling stderr tail — keep only the trailing STDERR_TAIL_BYTES so a
118
- // long-running kimi process emitting megabytes of stderr (tool.progress,
119
- // thinking deltas) doesn't grow our RSS unboundedly.
118
+ // long-running kimi process emitting megabytes of stderr (tool.updated
119
+ // output/status, thinking deltas) doesn't grow our RSS unboundedly.
120
120
  let stderrTail = "";
121
121
  let announcedSessionId;
122
122
  let announcedGoalSummary;
@@ -786,7 +786,7 @@ function buildArgs(opts) {
786
786
  ? opts.env.KIMI_PLUGIN_CC_SMOKE_V2_CANDIDATE
787
787
  : undefined;
788
788
  if (opts.resumeSessionId === undefined &&
789
- ["2.5.0", "2.5.1", "2.5.2", "2.5.3"].includes(opts.executionPlan.kimiVersion ?? smokeCandidate ?? "")) {
789
+ ["2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0"].includes(opts.executionPlan.kimiVersion ?? smokeCandidate ?? "")) {
790
790
  args.push("--environment", "local");
791
791
  }
792
792
  if (opts.resumeSessionId !== undefined) {
@@ -103,7 +103,8 @@ export async function runRecoverSwarm(argv, context) {
103
103
  if (current.command !== plan.command || current.kimiVersion !== plan.kimiVersion || JSON.stringify(current.prefixArgs) !== JSON.stringify(plan.prefixArgs))
104
104
  throw recoveryError("The exact recorded CLI is not selected. Restore that certified binary before session cleanup.");
105
105
  signal.throwIfAborted();
106
- await deactivateSwarmSession({ cwd: record.cwd, env: context.env, command: current.command,
106
+ const recoveryExecutionCwd = await realpath(record.cwd);
107
+ await deactivateSwarmSession({ cwd: recoveryExecutionCwd, env: context.env, command: current.command,
107
108
  prefixArgs: current.prefixArgs, executionPlan: current, commandLabel: expectedRoot ? "swarm-write" : "swarm",
108
109
  trustedWorkspaceRoot: expectedRoot ?? undefined, ...record.session, signal,
109
110
  onRecoveryEvent: (event) => recordRecoveryEvent(store, record, event) });
@@ -28,7 +28,7 @@ import { normalizeTopLevelInlineHooks, validateKimiHookSetForEnvironment, withKi
28
28
  import { buildHookShellCommand, hostIdFromHookCommand, resolveHookScriptPath, resolveHostId, resolveNodeBinary, } from "../hooks/install-paths.js";
29
29
  import { decodeManagedCommandLine, effectiveHost, evaluateInstalled, findUnmanagedApprovalHookBlocks, markerCommentLines, MARKERS, ORPHAN_MARKER_REMEDY, parseManagedBlock, } from "../hooks/managed-block.js";
30
30
  import { formatVersionOutOfRangeWarning, probeKimiVersion, } from "../kimi-version-probe.js";
31
- import { isNativeV2CertifiedVersion, NATIVE_V2_CERTIFIED_VERSIONS } from "../kimi-engine.js";
31
+ import { isNativeV2CertifiedVersion, NATIVE_V2_ANY_OPERATION_VERSIONS, NATIVE_V2_NON_SWARM_VERSIONS, } from "../kimi-engine.js";
32
32
  import { resolveKimiHome } from "../kimi-home.js";
33
33
  import { ensurePluginPaths, resolvePluginPaths } from "../paths.js";
34
34
  import { KIMI_PLUGIN_CC_VERSION } from "../version.js";
@@ -973,13 +973,13 @@ async function collectKimiVersionWarnings(env, warnings) {
973
973
  // clearer message. Avoid double-noise.
974
974
  return;
975
975
  }
976
- // Certified for EITHER engine is "in range": the legacy tested minors, or an
977
- // exact native-v2 certified version (which is deliberately outside
978
- // KIMI_TESTED_MINORS — that table never gains 0.42). Without this, setup on a
979
- // v2-certified binary would wrongly warn "not certified, commands will refuse".
980
- if (probe.inTestedRange || isNativeV2CertifiedVersion(probe.version))
976
+ if (!probe.inTestedRange && !isNativeV2CertifiedVersion(probe.version)) {
977
+ warnings.push(formatVersionOutOfRangeWarning(probe, KIMI_PLUGIN_CC_VERSION, NATIVE_V2_ANY_OPERATION_VERSIONS));
981
978
  return;
982
- warnings.push(formatVersionOutOfRangeWarning(probe, KIMI_PLUGIN_CC_VERSION, NATIVE_V2_CERTIFIED_VERSIONS));
979
+ }
980
+ if (NATIVE_V2_NON_SWARM_VERSIONS.includes(probe.version)) {
981
+ warnings.push(`NOTE: kimi-code ${probe.version} is certified for review, challenge, ask, rescue, review gate, and pursue only. Read-only swarm and write swarm refuse before model spawn because upstream rate-limit recovery can exceed maxConcurrency.`);
982
+ }
983
983
  }
984
984
  /**
985
985
  * Non-blocking notice for kimi-code's own enabled plugins from