kimi-plugin-cc 2.5.2 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/cli-client.js +8 -0
- package/dist/commands/swarm.js +2 -2
- package/dist/hooks/config-safety.js +5 -2
- package/dist/kimi-command.js +1 -0
- package/dist/kimi-engine.js +3 -0
- package/dist/native-v2-preflight.js +138 -30
- package/dist/swarm-activation.js +276 -14
- package/dist/version.js +1 -1
- package/docs/migration.md +4 -4
- package/docs/registry-releases.md +3 -1
- package/docs/safety.md +11 -9
- package/docs/swarm-recovery.md +2 -2
- package/docs/upstream-2.5.0-certification.md +48 -0
- package/docs/upstream-2.5.1-certification.md +43 -0
- package/package.json +3 -1
- package/plugins/kimi-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/kimi-codex/dist/cli-client.js +8 -0
- package/plugins/kimi-codex/dist/commands/swarm.js +2 -2
- package/plugins/kimi-codex/dist/hooks/config-safety.js +5 -2
- package/plugins/kimi-codex/dist/kimi-command.js +1 -0
- package/plugins/kimi-codex/dist/kimi-engine.js +3 -0
- package/plugins/kimi-codex/dist/native-v2-preflight.js +138 -30
- package/plugins/kimi-codex/dist/swarm-activation.js +276 -14
- package/plugins/kimi-codex/dist/version.js +1 -1
- package/plugins/kimi-dsh/dist/cli-client.js +8 -0
- package/plugins/kimi-dsh/dist/commands/swarm.js +2 -2
- package/plugins/kimi-dsh/dist/hooks/config-safety.js +5 -2
- package/plugins/kimi-dsh/dist/kimi-command.js +1 -0
- package/plugins/kimi-dsh/dist/kimi-engine.js +3 -0
- package/plugins/kimi-dsh/dist/native-v2-preflight.js +138 -30
- package/plugins/kimi-dsh/dist/swarm-activation.js +276 -14
- package/plugins/kimi-dsh/dist/version.js +1 -1
- package/plugins/kimi-dsh/package.json +1 -1
package/dist/swarm-activation.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { constants as fsConstants } from "node:fs";
|
|
3
4
|
import { open } from "node:fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
@@ -9,7 +10,7 @@ import { assertExecutionPlanMatchesSpawn, assertNoUnsafeExperimentalSelector, }
|
|
|
9
10
|
import { resolveKimiHome } from "./kimi-home.js";
|
|
10
11
|
import { assertNativeV2Preflight } from "./native-v2-preflight.js";
|
|
11
12
|
import { collectDescendantIdentities, collectProcessGroupsIdentities, probeProcessIdentity, revalidateProcessIdentities, waitForProcessTreeExit, } from "./process-tree.js";
|
|
12
|
-
const PREACTIVATION_VERSIONS = ["2.3.2", "2.3.3", "2.4.0", "2.4.1"];
|
|
13
|
+
const PREACTIVATION_VERSIONS = ["2.3.2", "2.3.3", "2.4.0", "2.4.1", "2.5.0", "2.5.1"];
|
|
13
14
|
const READY_TIMEOUT_MS = 10_000;
|
|
14
15
|
const REST_TIMEOUT_MS = 5_000;
|
|
15
16
|
// Exact 2.4.0 can take longer than 5s to drain session/workspace lifecycle work.
|
|
@@ -18,6 +19,8 @@ const JOURNAL_TIMEOUT_MS = 2_000;
|
|
|
18
19
|
const JOURNAL_POLL_MS = 50;
|
|
19
20
|
const READY_LINE_MAX_CHARS = 65_536;
|
|
20
21
|
const REST_RESPONSE_MAX_BYTES = 1024 * 1024;
|
|
22
|
+
const WEBSOCKET_MAX_FRAMES = 64;
|
|
23
|
+
const WEBSOCKET_RESPONSE_MAX_CHARS = 1024 * 1024;
|
|
21
24
|
const JOURNAL_MAX_BYTES = 64 * 1024 * 1024;
|
|
22
25
|
const DESCENDANT_SNAPSHOT_TIMEOUT_MS = 2_000;
|
|
23
26
|
const DESCENDANT_TRACK_INTERVAL_MS = 50;
|
|
@@ -39,11 +42,12 @@ export async function preactivateSwarmSession(options) {
|
|
|
39
42
|
web = await startWebChild(options, prepared.env, failureCode);
|
|
40
43
|
await verifyMeta(web, prepared.expectedVersion, options.signal, failureCode);
|
|
41
44
|
const model = await resolveProfileModel(web, options, failureCode);
|
|
42
|
-
identity = await createSession(web, options, failureCode);
|
|
45
|
+
identity = await createSession(web, options, prepared.expectedVersion, failureCode);
|
|
46
|
+
await verifyLocalEnvironment(web, identity, options.cwd, prepared.expectedVersion, options.signal, failureCode);
|
|
43
47
|
options.onRecoveryEvent?.({ kind: "session", ...identity });
|
|
44
48
|
profileMutationAttempted = true;
|
|
45
49
|
await postSwarmProfile(web, identity, true, model, options.signal, failureCode);
|
|
46
|
-
await verifySwarmStatus(web, identity, true, model, options.signal, failureCode);
|
|
50
|
+
await verifySwarmStatus(web, identity, true, model, prepared.expectedVersion, options.signal, failureCode);
|
|
47
51
|
await shutdownWeb(web, options.signal, failureCode);
|
|
48
52
|
await requireSwarmJournal(prepared.kimiHome, identity, "enter", options.signal, failureCode);
|
|
49
53
|
throwIfAborted(options.signal, failureCode, "swarm-activation.complete");
|
|
@@ -86,8 +90,9 @@ export async function deactivateSwarmSession(options) {
|
|
|
86
90
|
throwIfAborted(options.signal, failureCode, "swarm-deactivation.pre-spawn");
|
|
87
91
|
web = await startWebChild(options, prepared.env, failureCode);
|
|
88
92
|
await verifyMeta(web, prepared.expectedVersion, options.signal, failureCode);
|
|
93
|
+
await verifyLocalEnvironment(web, options, options.cwd, prepared.expectedVersion, options.signal, failureCode);
|
|
89
94
|
await postSwarmProfile(web, options, false, undefined, options.signal, failureCode);
|
|
90
|
-
await verifySwarmStatus(web, options, false, undefined, options.signal, failureCode);
|
|
95
|
+
await verifySwarmStatus(web, options, false, undefined, prepared.expectedVersion, options.signal, failureCode);
|
|
91
96
|
await shutdownWeb(web, options.signal, failureCode);
|
|
92
97
|
await requireSwarmJournal(prepared.kimiHome, options, "exit", options.signal, failureCode);
|
|
93
98
|
options.onRecoveryEvent?.({ kind: "disabled" });
|
|
@@ -124,6 +129,7 @@ async function prepareWebSpawn(options, failureCode) {
|
|
|
124
129
|
await assertNativeV2Preflight({
|
|
125
130
|
kimiHome,
|
|
126
131
|
env: options.env,
|
|
132
|
+
expectedExecutionRoot: options.cwd,
|
|
127
133
|
stage: "swarm-activation.pre-spawn",
|
|
128
134
|
});
|
|
129
135
|
}
|
|
@@ -329,13 +335,29 @@ async function resolveProfileModel(web, options, failureCode) {
|
|
|
329
335
|
}
|
|
330
336
|
return data.default_model;
|
|
331
337
|
}
|
|
332
|
-
async function createSession(web, options, failureCode) {
|
|
333
|
-
const
|
|
338
|
+
async function createSession(web, options, expectedVersion, failureCode) {
|
|
339
|
+
const request = { metadata: { cwd: options.cwd } };
|
|
340
|
+
if (["2.5.0", "2.5.1"].includes(expectedVersion)) {
|
|
341
|
+
request.environment_id = "local";
|
|
342
|
+
request.environment_cwd = options.cwd;
|
|
343
|
+
}
|
|
344
|
+
const data = await restData(web, "POST", "/api/v1/sessions", request, options.signal, failureCode);
|
|
334
345
|
if (!isRecord(data) || !validPathId(data.id) || !validPathId(data.workspace_id)) {
|
|
335
346
|
throw failure(failureCode, "swarm-activation.create-session", "Kimi web returned an invalid session identity.");
|
|
336
347
|
}
|
|
337
348
|
return { sessionId: data.id, workspaceId: data.workspace_id };
|
|
338
349
|
}
|
|
350
|
+
async function verifyLocalEnvironment(web, identity, expectedCwd, expectedVersion, signal, failureCode) {
|
|
351
|
+
if (!["2.5.0", "2.5.1"].includes(expectedVersion))
|
|
352
|
+
return;
|
|
353
|
+
const data = await restData(web, "GET", `/api/v1/sessions/${encodeURIComponent(identity.sessionId)}/environment`, undefined, signal, failureCode);
|
|
354
|
+
if (!isRecord(data)) {
|
|
355
|
+
throw failure(failureCode, "swarm-activation.environment", "Kimi web /environment returned an invalid payload.");
|
|
356
|
+
}
|
|
357
|
+
if (data.workspace_id !== identity.workspaceId || data.environment_id !== "local" || data.cwd !== expectedCwd) {
|
|
358
|
+
throw failure(failureCode, "swarm-activation.environment", "Kimi web /environment did not confirm the expected local workspace binding.");
|
|
359
|
+
}
|
|
360
|
+
}
|
|
339
361
|
async function postSwarmProfile(web, identity, active, model, signal, failureCode) {
|
|
340
362
|
const agentConfig = {
|
|
341
363
|
swarm_mode: active,
|
|
@@ -345,24 +367,264 @@ async function postSwarmProfile(web, identity, active, model, signal, failureCod
|
|
|
345
367
|
agentConfig.model = model;
|
|
346
368
|
await restData(web, "POST", `/api/v1/sessions/${encodeURIComponent(identity.sessionId)}/profile`, { agent_config: agentConfig }, signal, failureCode);
|
|
347
369
|
}
|
|
348
|
-
async function verifySwarmStatus(web, identity, active, model, signal, failureCode) {
|
|
349
|
-
const data =
|
|
370
|
+
async function verifySwarmStatus(web, identity, active, model, expectedVersion, signal, failureCode) {
|
|
371
|
+
const data = ["2.5.0", "2.5.1"].includes(expectedVersion)
|
|
372
|
+
? await readWebSocketAgentState(web, identity.sessionId, signal, failureCode)
|
|
373
|
+
: await restData(web, "GET", `/api/v1/sessions/${encodeURIComponent(identity.sessionId)}/status`, undefined, signal, failureCode);
|
|
374
|
+
const source = ["2.5.0", "2.5.1"].includes(expectedVersion) ? "agent state" : "/status";
|
|
350
375
|
if (!isRecord(data)) {
|
|
351
|
-
throw failure(failureCode, "swarm-activation.status",
|
|
376
|
+
throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} returned an invalid payload.`);
|
|
352
377
|
}
|
|
353
378
|
if (data.swarm_mode !== active) {
|
|
354
|
-
throw failure(failureCode, "swarm-activation.status", `Kimi web
|
|
379
|
+
throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} did not confirm swarm_mode=${active}.`, { expected_swarm_mode: active });
|
|
355
380
|
}
|
|
356
381
|
if (data.plan_mode !== false) {
|
|
357
|
-
throw failure(failureCode, "swarm-activation.status",
|
|
382
|
+
throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} did not confirm plan mode is off.`);
|
|
358
383
|
}
|
|
359
|
-
if (data.
|
|
360
|
-
throw failure(failureCode, "swarm-activation.status", "Kimi web
|
|
384
|
+
if (["2.5.0", "2.5.1"].includes(expectedVersion) && data.tower_mode !== false) {
|
|
385
|
+
throw failure(failureCode, "swarm-activation.status", "Kimi web agent state did not confirm tower mode is off.");
|
|
386
|
+
}
|
|
387
|
+
const permission = ["2.5.0", "2.5.1"].includes(expectedVersion) ? data.permission_mode : data.permission;
|
|
388
|
+
if (permission !== "auto") {
|
|
389
|
+
throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} did not confirm auto permission mode.`);
|
|
361
390
|
}
|
|
362
391
|
if (active && data.model !== model) {
|
|
363
|
-
throw failure(failureCode, "swarm-activation.status",
|
|
392
|
+
throw failure(failureCode, "swarm-activation.status", `Kimi web ${source} did not confirm the selected model alias.`);
|
|
364
393
|
}
|
|
365
394
|
}
|
|
395
|
+
async function readWebSocketAgentState(web, sessionId, signal, failureCode) {
|
|
396
|
+
throwIfAborted(signal, failureCode, "swarm-activation.status");
|
|
397
|
+
await refreshOwnedDescendants(web);
|
|
398
|
+
throwIfAborted(signal, failureCode, "swarm-activation.status");
|
|
399
|
+
try {
|
|
400
|
+
return await new Promise((resolve, reject) => {
|
|
401
|
+
let socket;
|
|
402
|
+
const bearerProtocol = `kimi-code.bearer.${web.token}`;
|
|
403
|
+
const helloId = `swarm-activation-hello-${randomUUID()}`;
|
|
404
|
+
const subscribeId = `swarm-activation-subscribe-${randomUUID()}`;
|
|
405
|
+
try {
|
|
406
|
+
const url = new URL(web.origin);
|
|
407
|
+
url.protocol = "ws:";
|
|
408
|
+
url.pathname = "/api/v1/ws";
|
|
409
|
+
socket = new WebSocket(url, bearerProtocol);
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
412
|
+
reject(failure(failureCode, "swarm-activation.status", "Could not open the authenticated Kimi web agent-state channel."));
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
let settled = false;
|
|
416
|
+
let serverHello = false;
|
|
417
|
+
let clientHelloAcknowledged = false;
|
|
418
|
+
let subscribeSent = false;
|
|
419
|
+
let subscriptionAcknowledged = false;
|
|
420
|
+
let closeRequested = false;
|
|
421
|
+
let latestState;
|
|
422
|
+
let frames = 0;
|
|
423
|
+
let receivedChars = 0;
|
|
424
|
+
const timer = setTimeout(() => {
|
|
425
|
+
settle(failure(failureCode, "swarm-activation.status", "Kimi web agent-state verification timed out.", { timeout_ms: REST_TIMEOUT_MS }));
|
|
426
|
+
}, REST_TIMEOUT_MS);
|
|
427
|
+
const cleanup = () => {
|
|
428
|
+
clearTimeout(timer);
|
|
429
|
+
signal?.removeEventListener("abort", onAbort);
|
|
430
|
+
socket.removeEventListener("open", onOpen);
|
|
431
|
+
socket.removeEventListener("message", onMessage);
|
|
432
|
+
socket.removeEventListener("error", onError);
|
|
433
|
+
socket.removeEventListener("close", onClose);
|
|
434
|
+
try {
|
|
435
|
+
socket.close();
|
|
436
|
+
}
|
|
437
|
+
catch {
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
const settle = (result) => {
|
|
441
|
+
if (settled)
|
|
442
|
+
return;
|
|
443
|
+
settled = true;
|
|
444
|
+
cleanup();
|
|
445
|
+
if (result instanceof RuntimeError)
|
|
446
|
+
reject(result);
|
|
447
|
+
else
|
|
448
|
+
resolve(result);
|
|
449
|
+
};
|
|
450
|
+
const rejectState = (message) => {
|
|
451
|
+
settle(failure(failureCode, "swarm-activation.status", message));
|
|
452
|
+
};
|
|
453
|
+
const send = (frame) => {
|
|
454
|
+
try {
|
|
455
|
+
socket.send(JSON.stringify(frame));
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
catch {
|
|
459
|
+
rejectState("Could not send a Kimi web agent-state control frame.");
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
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
|
+
}
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
const onOpen = () => {
|
|
479
|
+
if (socket.protocol !== bearerProtocol) {
|
|
480
|
+
rejectState("Kimi web did not authenticate the agent-state channel with the expected subprotocol.");
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
send({
|
|
484
|
+
type: "client_hello",
|
|
485
|
+
id: helloId,
|
|
486
|
+
payload: { client_id: "kimi-plugin-cc-swarm-activation" },
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
const onMessage = (event) => {
|
|
490
|
+
if (settled)
|
|
491
|
+
return;
|
|
492
|
+
if (typeof event.data !== "string") {
|
|
493
|
+
rejectState("Kimi web agent-state channel returned a non-text frame.");
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
frames += 1;
|
|
497
|
+
receivedChars += event.data.length;
|
|
498
|
+
if (frames > WEBSOCKET_MAX_FRAMES || receivedChars > WEBSOCKET_RESPONSE_MAX_CHARS) {
|
|
499
|
+
rejectState("Kimi web agent-state channel exceeded the bounded response limit.");
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
let frame;
|
|
503
|
+
try {
|
|
504
|
+
frame = JSON.parse(event.data);
|
|
505
|
+
}
|
|
506
|
+
catch {
|
|
507
|
+
rejectState("Kimi web agent-state channel returned malformed JSON.");
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
if (!isRecord(frame) || typeof frame.type !== "string") {
|
|
511
|
+
rejectState("Kimi web agent-state channel returned an invalid frame.");
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
if (frame.type === "server_hello") {
|
|
515
|
+
if (serverHello || !isRecord(frame.payload) ||
|
|
516
|
+
frame.payload.protocol_version !== 2 ||
|
|
517
|
+
typeof frame.payload.ws_connection_id !== "string" ||
|
|
518
|
+
!isRecord(frame.payload.capabilities) ||
|
|
519
|
+
frame.payload.capabilities.event_batching !== false ||
|
|
520
|
+
frame.payload.capabilities.compression !== false) {
|
|
521
|
+
rejectState("Kimi web agent-state channel did not provide the expected protocol-v2 hello.");
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
serverHello = true;
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
if (!serverHello) {
|
|
528
|
+
rejectState("Kimi web agent-state channel sent data before its protocol hello.");
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (frame.type === "ack") {
|
|
532
|
+
if (typeof frame.id !== "string" || typeof frame.code !== "number" || !isRecord(frame.payload)) {
|
|
533
|
+
rejectState("Kimi web agent-state channel returned an invalid acknowledgement.");
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
if (frame.id === helloId) {
|
|
537
|
+
if (clientHelloAcknowledged || frame.code !== 0) {
|
|
538
|
+
rejectState("Kimi web agent-state channel rejected the client hello.");
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
clientHelloAcknowledged = true;
|
|
542
|
+
subscribeSent = send({
|
|
543
|
+
type: "subscribe_v2",
|
|
544
|
+
id: subscribeId,
|
|
545
|
+
payload: { session_id: sessionId, transcript: { main: "block" } },
|
|
546
|
+
});
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
if (frame.id === subscribeId) {
|
|
550
|
+
if (subscriptionAcknowledged || !subscribeSent || frame.code !== 0 ||
|
|
551
|
+
!Array.isArray(frame.payload.accepted) ||
|
|
552
|
+
frame.payload.accepted.length !== 1 ||
|
|
553
|
+
frame.payload.accepted[0] !== sessionId ||
|
|
554
|
+
!Array.isArray(frame.payload.not_found) ||
|
|
555
|
+
frame.payload.not_found.length !== 0) {
|
|
556
|
+
rejectState("Kimi web agent-state channel did not accept the exact main-session subscription.");
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
subscriptionAcknowledged = true;
|
|
560
|
+
completeIfReady();
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
rejectState("Kimi web agent-state channel returned an unexpected acknowledgement.");
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
if (frame.type === "agent") {
|
|
567
|
+
if (!subscribeSent || !isAgentStateFrame(frame, sessionId)) {
|
|
568
|
+
rejectState("Kimi web agent-state channel returned invalid or misbound main-agent state.");
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
latestState = frame;
|
|
572
|
+
completeIfReady();
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
if (frame.type === "ping") {
|
|
576
|
+
if (isRecord(frame.payload) && typeof frame.payload.nonce === "string") {
|
|
577
|
+
send({ type: "pong", payload: { nonce: frame.payload.nonce } });
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
const onAbort = () => {
|
|
582
|
+
settle(cancelledFailure(failureCode, "swarm-activation.status"));
|
|
583
|
+
};
|
|
584
|
+
const onError = () => {
|
|
585
|
+
rejectState("Kimi web agent-state channel failed before valid state was received.");
|
|
586
|
+
};
|
|
587
|
+
const onClose = (event) => {
|
|
588
|
+
if (event.wasClean &&
|
|
589
|
+
closeRequested &&
|
|
590
|
+
serverHello &&
|
|
591
|
+
clientHelloAcknowledged &&
|
|
592
|
+
subscriptionAcknowledged &&
|
|
593
|
+
latestState !== undefined) {
|
|
594
|
+
settle(latestState);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
rejectState("Kimi web agent-state channel closed before valid state was received.");
|
|
598
|
+
};
|
|
599
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
600
|
+
socket.addEventListener("open", onOpen);
|
|
601
|
+
socket.addEventListener("message", onMessage);
|
|
602
|
+
socket.addEventListener("error", onError);
|
|
603
|
+
socket.addEventListener("close", onClose);
|
|
604
|
+
if (signal?.aborted === true)
|
|
605
|
+
onAbort();
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
finally {
|
|
609
|
+
await refreshOwnedDescendants(web);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
function isAgentStateFrame(frame, sessionId) {
|
|
613
|
+
return frame.session_id === sessionId &&
|
|
614
|
+
frame.agent_id === "main" &&
|
|
615
|
+
typeof frame.event_created_at === "string" &&
|
|
616
|
+
Number.isFinite(Date.parse(frame.event_created_at)) &&
|
|
617
|
+
(frame.status === "idle" || frame.status === "running") &&
|
|
618
|
+
(frame.model === undefined || typeof frame.model === "string") &&
|
|
619
|
+
(frame.thinking === undefined || typeof frame.thinking === "string") &&
|
|
620
|
+
(frame.permission_mode === undefined ||
|
|
621
|
+
frame.permission_mode === "manual" ||
|
|
622
|
+
frame.permission_mode === "yolo" ||
|
|
623
|
+
frame.permission_mode === "auto") &&
|
|
624
|
+
typeof frame.plan_mode === "boolean" &&
|
|
625
|
+
typeof frame.swarm_mode === "boolean" &&
|
|
626
|
+
typeof frame.tower_mode === "boolean";
|
|
627
|
+
}
|
|
366
628
|
async function shutdownWeb(web, signal, failureCode) {
|
|
367
629
|
await restData(web, "POST", "/api/v1/shutdown", undefined, signal, failureCode);
|
|
368
630
|
const settlement = await waitForChildClose(web, signal, failureCode);
|
package/dist/version.js
CHANGED
package/docs/migration.md
CHANGED
|
@@ -12,13 +12,13 @@ Use the [README installation and update steps](../README.md) for Claude Code or
|
|
|
12
12
|
|
|
13
13
|
Plugin versions advance independently using ordinary SemVer and may deliberately align with a certified CLI release. Plugin 2.5.1 certifies exact CLI 2.4.1; the nearby numbers do not imply version alignment. Published versions and tags are never reused. Every upstream patch requires its own certification. The native-v2 no-plan profile, plugin/marketplace IDs and existing job store are preserved.
|
|
14
14
|
|
|
15
|
-
## CLI 2.3.2, 2.3.3, 2.4.0 and 2.
|
|
15
|
+
## CLI 2.3.2, 2.3.3, 2.4.0, 2.4.1 and 2.5.0/2.5.1 swarm activation
|
|
16
16
|
|
|
17
|
-
Upstream 2.3.2 removes model self-activation of `AgentSwarm` in fresh print sessions. On exact 2.3.2, 2.3.3, 2.4.0 and 2.
|
|
17
|
+
Upstream 2.3.2 removes model self-activation of `AgentSwarm` in fresh print sessions. On exact 2.3.2, 2.3.3, 2.4.0, 2.4.1 and 2.5.0/2.5.1, swarm commands and MCP calls use the same `runSwarm` lifecycle:
|
|
18
18
|
|
|
19
|
-
1. A short-lived `web --no-open --host 127.0.0.1 --port 0 --log-level error` process uses authenticated loopback routes to verify the exact v2 server, choose the explicit or configured default model, create a session, bind the model and auto permission, enable and verify `swarm_mode`, and shut down. The child environment sets `KIMI_CODE_SESSION_IDLE_RECLAIM_MS=0` to disable ambient idle-session reclamation.
|
|
19
|
+
1. A short-lived `web --no-open --host 127.0.0.1 --port 0 --log-level error` process uses authenticated loopback routes to verify the exact v2 server, choose the explicit or configured default model, create a session, bind the model and auto permission, enable and verify `swarm_mode`, and shut down. On exact 2.5.0/2.5.1, creation explicitly selects the local environment and an authenticated `/environment` read proves its cwd before profile mutation; state verification uses protocol-v2 WebSocket main-agent frames because `/status` was removed. The child environment sets `KIMI_CODE_SESSION_IDLE_RECLAIM_MS=0` to disable ambient idle-session reclamation.
|
|
20
20
|
2. One ordinary `kimi -p -r` prompt runner resumes that session. Its recorded session-id source is `preactivated`, and the returned print session must match it.
|
|
21
|
-
3. A second short-lived web lifecycle disables swarm mode, verifies
|
|
21
|
+
3. A second short-lived web lifecycle rechecks the local binding on 2.5.0/2.5.1, disables swarm mode, verifies the version-appropriate state proof and the `swarm_mode.exit` journal record, and shuts down.
|
|
22
22
|
|
|
23
23
|
Activation is inside the job's finite budget. Graceful process close has a bounded 15-second allowance. `runSwarm` solely owns deactivation: normal cleanup uses the remaining budget, while failure recovery has a separate two-second cancellation-aware bound and is never retried. Print/session failures stay primary. The ready token stays in memory and out of logs, and success cannot complete if cleanup fails. Post-mutation identity or process/group uncertainty preserves diagnostics and, for write-swarm, the recovery worktree. Process groups are rechecked after teardown; unknown survivors are unverified and unproven groups are not signalled. Older certified versions still launch swarm directly with `kimi -p`. This narrow lifecycle is not a full RPC transport or a model-driven activation workaround; the managed hook and workspace boundaries still govern every tool call.
|
|
24
24
|
|
|
@@ -8,7 +8,9 @@ no separate CLI.
|
|
|
8
8
|
|
|
9
9
|
## Publishing status
|
|
10
10
|
|
|
11
|
-
Plugin **2.5.2**
|
|
11
|
+
Plugin **2.5.3** certifies exact Kimi Code **2.5.0 and 2.5.1** for all eight operations, adding local-execution/workspace-trust closures and authenticated WebSocket swarm activation with clean-close validation while preserving the no-plan construction and legacy-v1 0.41.x boundary. See the [2.5.0](./upstream-2.5.0-certification.md) and [2.5.1](./upstream-2.5.1-certification.md) certification records. The 2.5.1 source scan passed 18 tests with 153 assertions; candidate and production matrices each passed 24 tests with 167 assertions and no skips. The full check passed 1,412 tests with 18,282 assertions, package validation passed 330 files across all three distributions, isolated consumer security passed, and independent read-only `claude -p` review returned APPROVE. Release-commit CI, OIDC publication, registry artifact identity, and the final Discover timestamp are recorded here after publication.
|
|
12
|
+
|
|
13
|
+
Plugin **2.5.2** hardens setup recovery and DSH dependency ownership. Its real Kimi Code **2.4.1** smoke passed **24 tests and 167 assertions with no skips**; the exact-source audit passed **16 tests and 97 assertions**. Normal npm installation keeps DSH host services optional. DSH use requires explicitly patched host/profile dependencies and both installation audits described below. Exact CLI certification remains unchanged. [Release v2.5.2](https://github.com/linxule/kimi-plugin-cc/releases/tag/v2.5.2) is anchored at `8b303bb6e49c581ad96c72bd031e8fd1643c9121`. [Release-commit CI](https://github.com/linxule/kimi-plugin-cc/actions/runs/41361753223) and [npm publication](https://github.com/linxule/kimi-plugin-cc/actions/runs/41362262009) passed. The 328-file registry tarball has SHA-1 `e620040dd35986a6929be7ad677642729a3126e7`, matches the validated workflow artifact byte-for-byte, and carries provenance (sigstore log index `3636981979`). A fresh registry npm installation has zero production advisories; isolated Claude Code, Codex, and DSH setup/checks pass, and all compiled runtime mirrors match. The Discover timestamp records npm publication at `2026-11-01T23:35:04.270Z`.
|
|
12
14
|
|
|
13
15
|
Plugin **2.5.1** adds DeepSeek Harness through the existing root npm package and its established OIDC workflow. [Release v2.5.1](https://github.com/linxule/kimi-plugin-cc/releases/tag/v2.5.1) is anchored at `afe68ee2f0e7744e1fc97eb0f1e4007585d969d0`; its [CI check](https://github.com/linxule/kimi-plugin-cc/actions/runs/41335810767) and [release-event publishing run](https://github.com/linxule/kimi-plugin-cc/actions/runs/41336273042) passed. The registry tarball has SHA-1 `f0e42febcb14082be6a654b9b0830885242fd92a`, contains 328 files, matches the CI artifact, and carries signed provenance (sigstore log index `3635166158`). A fresh registry installation into an isolated DSH profile composed all seven providers and booted the Web host. DSH users install with `dsh plugin --profile <name> add kimi-plugin-cc`; no second npm package or Trusted Publishing binding is required.
|
|
14
16
|
|
package/docs/safety.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This guide describes the current checkout runtime. Read-only tasks deny file writes and shell commands. Rescue and pursue can edit your workspace. Write-swarm returns a patch from a temporary Git worktree.
|
|
4
4
|
|
|
5
|
-
Native agent-core-v2 is certified at exact CLI versions `0.42.0`, `0.43.0`, `0.43.1`, `2.0.0`, `2.0.1`, `2.0.2`, `2.1.0`, `2.1.1`, `2.2.0`, `2.3.0`, `2.3.1`, `2.3.2`, `2.3.3`, `2.4.0`, and `2.
|
|
5
|
+
Native agent-core-v2 is certified at exact CLI versions `0.42.0`, `0.43.0`, `0.43.1`, `2.0.0`, `2.0.1`, `2.0.2`, `2.1.0`, `2.1.1`, `2.2.0`, `2.3.0`, `2.3.1`, `2.3.2`, `2.3.3`, `2.4.0`, `2.4.1`, `2.5.0`, and `2.5.1`, with plan mode disabled. The [runtime certification table](../runtime/kimi-engine.ts) controls routing. The hook is not an operating-system sandbox.
|
|
6
6
|
|
|
7
7
|
## Why the safety story is hook-based
|
|
8
8
|
|
|
@@ -214,23 +214,23 @@ If another installed host still points to an older hook, that hook may veto thes
|
|
|
214
214
|
|
|
215
215
|
> **Goal-mode entry gate (changed in 0.12.0).** Headless goal mode is reached by a `/goal`-prefixed prompt. On kimi-code 0.8–0.11 it is *additionally* gated by the `goal-command` experimental flag, which `pursue.ts` sets per-spawn (`KIMI_CODE_EXPERIMENTAL_GOAL_COMMAND=1`). kimi-code 0.12.0 (PR #569) **removed that experimental-flag gate**, so the `/goal` prefix alone triggers goal mode. This does not weaken plugin safety: read-only commands (review/challenge/ask/review_gate) hard-prefix an English instruction line, so their trimmed prompt never starts with `/goal` and they cannot enter goal mode on any version; and the managed PreToolUse hook denies every write under a read-only label regardless (see § Native agent-core-v2 for why the hook cannot be pre-empted). The env var `pursue.ts` sets is now redundant on 0.12.0 but harmless, and is kept for 0.8–0.11 compat.
|
|
216
216
|
|
|
217
|
-
- **The hook fires on every tool call in every continuation turn.** On native v2 every tool execution passes `prepareToolCall` → `fireBeforeExecute`, where the external-hooks listener vetoes ahead of any terminal allow (the auto-approve gate uses non-terminal `pass()`; the engine's only `allow()` is the plan-file guard, never armed in a plugin-managed session — see § Native agent-core-v2). (On legacy-v1 ≤ 0.41 the same guarantee came from `PreToolCallHookPermissionPolicy` sitting at policy index 0.) Goal continuation turns are ordinary turns — there is no autonomous-continuation path that bypasses per-tool approval (verified against kimi-code 0.9.0, audit report 58; re-verified through 0.12.0 by the goal-mode real-binary smoke, reports 61-65). A goal-mode run is exactly as write-gated as a single-turn rescue. This is locked by a real-binary smoke (`tests/runtime/real-binary-smoke.test.ts`, run via `KIMI_PLUGIN_CC_SMOKE=1 bun test ... -t "goal mode"`): it runs real headless goal mode under a read-only label
|
|
217
|
+
- **The hook fires on every tool call in every continuation turn.** On native v2 every tool execution passes `prepareToolCall` → `fireBeforeExecute`, where the external-hooks listener vetoes ahead of any terminal allow (the auto-approve gate uses non-terminal `pass()`; the engine's only `allow()` is the plan-file guard, never armed in a plugin-managed session — see § Native agent-core-v2). (On legacy-v1 ≤ 0.41 the same guarantee came from `PreToolCallHookPermissionPolicy` sitting at policy index 0.) Goal continuation turns are ordinary turns — there is no autonomous-continuation path that bypasses per-tool approval (verified against kimi-code 0.9.0, audit report 58; re-verified through 0.12.0 by the goal-mode real-binary smoke, reports 61-65). A goal-mode run is exactly as write-gated as a single-turn rescue. This is locked by a real-binary smoke (`tests/runtime/real-binary-smoke.test.ts`, run via `KIMI_PLUGIN_CC_SMOKE=1 bun test ... -t "goal mode"`): it runs real headless goal mode under a read-only label, asserts that the entire workspace is empty at settlement, and requires same-call managed error denials in at least two distinct turns. It does not prove that no transient file ever existed.
|
|
218
218
|
- **The only new risk is unboundedness, and the plugin bounds it.** Headless goal create sets no token/turn budget, and the managed hook denies `SetGoalBudget`; the plugin's external wall-clock stop is therefore the guaranteed bound. `/kimi:pursue` enforces a **mandatory finite wall-clock ceiling** via its AbortController (`--budget`, default 45m) — the SIGTERM→SIGKILL descendant-reaping cancellation reaps the whole goal process tree. `--turns` is a *soft* instruction injected into the objective, never a request to call the denied `SetGoalBudget` tool; it is not enforceable headless, and stopping at that soft hint is not proof of completion. Treat `--budget` as the real bound.
|
|
219
219
|
- **Loop runaway is now also capped upstream.** kimi-code 0.8.0 (#364) detects repeated identical tool calls and force-stops a turn at a repeat streak. This benefits `/kimi:rescue`, `/kimi:ask`, and `/kimi:pursue` alike: a force-stopped turn ends *normally* (exit 0, flows through the plugin's success path — not a failure), reducing the chance an autonomous run spins against the wall-clock budget. It is a complement to, not a replacement for, the wall-clock ceiling.
|
|
220
220
|
- **Resume is intentionally not exposed yet.** In goal mode `goal.summary` emits a *goalId* distinct from the resume-hint *sessionId*; `kimi -r <sessionId>` re-enters the session but not necessarily the goal continuation. The plugin captures and surfaces the goalId but does not offer `--resume` for pursue until that split is reconciled upstream — exposing it now would be a silent-failure trap. **Re-verified against kimi-code 0.26.0 (2026-07-16):** the headless CLI still has no argv, prompt syntax, or session-resume path that calls `resumeGoal()`. `parseHeadlessGoalCreate` (`apps/kimi-code/src/cli/goal-prompt.ts`) accepts only the `/goal <objective>` *create* shape on both the v1 and experimental-v2 drivers, and upstream's own docs (`docs/en/guides/goals.md`, § "Use goal mode carefully") state that in non-interactive prompt mode *only goal creation is supported* — goal management is a TUI/kimi-web control. PR #552 makes a plain `-r <sessionId>` correctly *restore* the paused goal snapshot, but nothing in the headless path *acts* on it; the real `resumeGoal()` is wired only to the TUI (`/goal resume`) and kimi-web RPC (PR #1693, web-only). Implementing `--resume` would therefore require either prompt-injected model compliance (rejected — the plugin bounds autonomy with hard limits, not model goodwill) or abandoning the subprocess model for kimi-web's RPC. Re-check if upstream ever ships a headless `goal resume` verb.
|
|
221
221
|
- **A model-invocable `kimi-pursue` agent (v1.3) wraps this command.** The main thread can dispatch autonomous goal mode, not just the human-typed `/kimi:pursue` — the same command↔agent mirror as rescue/review/swarm. Auto-dispatch does NOT widen the blast radius: pursue runs under `commandLabel: "rescue"`, so the managed PreToolUse hook + workspace allowlist gate every tool call on every continuation turn (no git mutation), and the mandatory `--budget` wall-clock ceiling bounds the autonomy regardless of who launched it. Because it is write-capable AND autonomous — the plugin's highest blast radius — the agent's description requires an explicit user request for hands-off multi-turn pursuit, steers single bounded tasks to `kimi-rescue`, and never auto-promotes a fix or a question into a goal loop. Like the command, it refuses without the hook and offers no `--resume`.
|
|
222
222
|
|
|
223
|
-
## Swarm activation on CLI 2.3.2, 2.3.3, 2.4.0 and 2.
|
|
223
|
+
## Swarm activation on CLI 2.3.2, 2.3.3, 2.4.0, 2.4.1, 2.5.0 and 2.5.1
|
|
224
224
|
|
|
225
225
|
For interrupted runs, see [durable recovery and its explicit limits](swarm-recovery.md).
|
|
226
226
|
|
|
227
227
|
Upstream 2.3.2 removes model self-activation of `AgentSwarm` in fresh print sessions. A rejected call can therefore coexist with zero child journals and a successful exit; a tool-call record, aggregate denial, or coordinator-produced patch does not prove fan-out. The plugin does not use prompt workarounds or replace its print transport with general RPC.
|
|
228
228
|
|
|
229
|
-
For versions requiring activation (currently exact 2.3.2, 2.3.3, 2.4.0 and 2.
|
|
229
|
+
For versions requiring activation (currently exact 2.3.2, 2.3.3, 2.4.0, 2.4.1, 2.5.0 and 2.5.1), both slash-command and MCP swarm operations use the same `runSwarm` implementation and one ordinary `kimi -p -r` prompt runner per job, bracketed by short-lived host-managed web lifecycles:
|
|
230
230
|
|
|
231
|
-
1. The exact planned CLI starts `web --no-open --host 127.0.0.1 --port 0 --log-level error`. The child environment sets `KIMI_CODE_SESSION_IDLE_RECLAIM_MS=0`, so ambient idle-session reclamation cannot disrupt the plugin-owned lifecycle. The plugin accepts only the expected loopback ready URL, uses a supplied token for authenticated REST requests, and keeps that token in memory, never writing it to logs. `/api/v1/meta` must confirm backend v2, the exact planned version, and no dangerous authentication bypass. The plugin uses the explicit model or environment-model alias, otherwise reading the default alias from `/api/v1/config`; creates a session in the job cwd; binds that model with `permission_mode:auto` and `swarm_mode:true`; verifies those settings and `plan_mode:false` through `/status
|
|
231
|
+
1. The exact planned CLI starts `web --no-open --host 127.0.0.1 --port 0 --log-level error`. The child environment sets `KIMI_CODE_SESSION_IDLE_RECLAIM_MS=0`, so ambient idle-session reclamation cannot disrupt the plugin-owned lifecycle. The plugin accepts only the expected loopback ready URL, uses a supplied token for authenticated REST requests, and keeps that token in memory, never writing it to logs. `/api/v1/meta` must confirm backend v2, the exact planned version, and no dangerous authentication bypass. The plugin uses the explicit model or environment-model alias, otherwise reading the default alias from `/api/v1/config`; creates a session in the job cwd; on exact 2.5.0/2.5.1 explicitly binds `environment_id:"local"` and the job cwd, then verifies that binding through authenticated `/environment` before either profile mutation; binds the selected model with `permission_mode:auto` and `swarm_mode:true`; verifies those settings and `plan_mode:false` through `/status` on earlier versions or protocol-v2 authenticated WebSocket main-agent state on 2.5.0/2.5.1, closing that channel cleanly before validating the latest frame; verifies clean shutdown; and requires the main journal's manual `swarm_mode.enter` record.
|
|
232
232
|
2. The ordinary stream-json print runner resumes that session with `kimi -p -r`. The job records `kimi_session_id_source:"preactivated"`, and the session returned by print must exactly match the preactivated id. Every coordinator and child tool call remains governed by the same managed PreToolUse hook and operation allowlist.
|
|
233
|
-
3. After the print run, a second web lifecycle sets `swarm_mode:false`, verifies
|
|
233
|
+
3. After the print run, a second web lifecycle rechecks the local binding on 2.5.0/2.5.1, sets `swarm_mode:false`, verifies the version-appropriate state proof, shuts down cleanly, and requires `swarm_mode.exit` in the main journal. Activation consumes part of the same finite job budget rather than extending it. `runSwarm` solely owns session deactivation: normal cleanup uses the remaining budget, while failure recovery has a separate two-second cancellation-aware bound and is never retried. Print/session failures stay primary, with exit codes and cleanup diagnostics preserved. Cancellation aborts the owned lifecycle and never starts a fresh cleanup server. Every post-mutation failure retains the session identity; process/group uncertainty is marked without inventing an ID; process groups are rechecked after teardown, unknown survivors are unverified, unproven groups are never signalled, and a same-PID/start-token process that changes PGID remains active but is not a validated signal target. Root loss requires a previously observed matching identity; first-missing roots and actual probe errors/timeouts remain unverified. Reparenting and PGID moves preserve the current verified child identity for revalidation rather than treating it as exited. Unverified cleanup prevents success and preserves raw output, structured diagnostics, and the write worktree for recovery.
|
|
234
234
|
|
|
235
235
|
Older certified versions keep the direct `kimi -p` path. The web processes are narrow, planned lifecycle helpers, not a second model runner and not a general RPC transport.
|
|
236
236
|
|
|
@@ -239,7 +239,7 @@ Older certified versions keep the direct `kimi -p` path. The web processes are n
|
|
|
239
239
|
`/kimi:swarm` (v1.2) fans a **read-only** review out across subagents using kimi-code's `AgentSwarm` tool (kimi-code 0.12.0+). The coordinator launches one subagent per target (file/module/question); each inspects the workspace with read tools and reports findings, which the coordinator consolidates into one markdown report. It opens **zero new write surface**.
|
|
240
240
|
|
|
241
241
|
- **The hook label is `swarm`, and it allows the read-only tool set PLUS `AgentSwarm`.** The coordinator must be allowed to call `AgentSwarm` (else the swarm never launches), but no write/edit/shell tool is allowed. The exact allowed tool name is `AgentSwarm` (verified at 0.42.0 against `packages/agent-core-v2/src/features/swarm/tools/agent-swarm/agentSwarmTool.ts`: `'AgentSwarm'`, strict schema). The singular `Agent` tool is deliberately *not* allowed — swarm is the fan-out surface, not arbitrary delegation.
|
|
242
|
-
- **Every subagent inherits the `swarm` label and fires the same hook.** On native v2 (0.42.0) `AgentSwarm` children run in-process in a child DI scope with their OWN eager external-hooks service, so every child tool call passes the same before-execute channel and the same managed hook — there is no sub-vs-main branch and no deny-all shortcut on the swarm route. So a subagent's `Write`/`Edit`/`Bash` is denied exactly like a single-turn review's. The swarm listener in that channel is non-terminal and nothing auto-approves `AgentSwarm` ahead of the hook. (Legacy-v1 ≤ 0.41 reached the same result by placing the hook policy at index 0 of every agent's permission stack.) **Required for final certification evidence** (`tests/runtime/real-binary-smoke.test.ts`, run via `bun run smoke:real`): distinct child journals must exist, and each assigned Write/Edit `path` must be correlated through its `toolCallId` with the managed denial in that exact tool result; unrelated denials and coordinator-only reports are insufficient. On 2.3.2, 2.3.3, 2.4.0 and 2.
|
|
242
|
+
- **Every subagent inherits the `swarm` label and fires the same hook.** On native v2 (0.42.0) `AgentSwarm` children run in-process in a child DI scope with their OWN eager external-hooks service, so every child tool call passes the same before-execute channel and the same managed hook — there is no sub-vs-main branch and no deny-all shortcut on the swarm route. So a subagent's `Write`/`Edit`/`Bash` is denied exactly like a single-turn review's. The swarm listener in that channel is non-terminal and nothing auto-approves `AgentSwarm` ahead of the hook. (Legacy-v1 ≤ 0.41 reached the same result by placing the hook policy at index 0 of every agent's permission stack.) **Required for final certification evidence** (`tests/runtime/real-binary-smoke.test.ts`, run via `bun run smoke:real`): distinct child journals must exist, and each assigned Write/Edit `path` must be correlated through its `toolCallId` with the managed denial in that exact tool result; unrelated denials and coordinator-only reports are insufficient. On 2.3.2, 2.3.3, 2.4.0, 2.4.1, 2.5.0 and 2.5.1, targeted controls also prove that direct OFF produces no children while the preactivated ON path produces the real child journals and denials.
|
|
243
243
|
- **The managed hook is the read-only boundary; no `explore`-profile second layer is assumed.** Production deliberately omits `subagent_type` for read-only swarm rather than selecting kimi-code's `explore` profile. Every coordinator and subagent tool call is enforced by the same managed hook.
|
|
244
244
|
- **Swarm refuses without the hook, like every model-spawning command.** A swarm makes the reason especially acute: it asks for up to `--cap` subagents, but this total-count hint is advisory, so a missing hook would remove enforcement from all of them at once. `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1` remains an explicit tests/diagnostics escape hatch, not a recovery path.
|
|
245
245
|
- **The only new risk is COST, and the plugin bounds it.** Read-only swarm writes nothing, so the new risk is runaway cost from N parallel model runs (and possible nested `AgentSwarm`). `/kimi:swarm` enforces a **mandatory finite wall-clock ceiling** via its AbortController (`--budget`, default 30m); the SIGTERM→SIGKILL descendant-reaping cancellation reaps the whole subagent process tree. Two **distinct** subagent bounds: `--cap N` is a *soft* prompt-injected hint on TOTAL subagent count (the hook is stateless and cannot enforce a count, so the model may exceed it), and `--max-concurrency N` is a *hard* ceiling on how many subagents kimi-code's `SubagentBatch` runs concurrently — exported as `KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY` (PR #888) on **kimi-code 0.18.0+** (older binaries ignore the unknown env var, so on < 0.18 only the soft hint applies). It **defaults to 4** when the user passes none (`resolveSwarmMaxConcurrency` in swarm.ts), so every swarm run — agent-dispatched or human-typed — carries an enforced peak-parallelism ceiling on 0.18.0+ rather than falling back to kimi-code's internal ramp; pass an explicit value to widen or throttle. **Never merge them into one flag:** concurrency ≠ total count — a hard concurrency cap of N still permits more than N subagents over the life of the run, just never more than N at once. The `--budget` bounds elapsed time, not a dollar amount or total token count; `--max-concurrency` bounds *peak* parallelism (the spike in simultaneous model spend), and `--cap` is only an advisory total-count nudge. Folding both onto one flag would create the "cap-as-total-count illusion" — a user reading `--cap N` would expect a total bound but receive only a peak-parallelism one.
|
|
@@ -298,6 +298,8 @@ worktree. A directory the operator trusted interactively in the Kimi TUI still
|
|
|
298
298
|
has that property; that persisted-trust route is a documented residual, not
|
|
299
299
|
something the plugin can close.
|
|
300
300
|
|
|
301
|
+
Plugin-managed execution must remain local. Unused remote declarations can remain in operator config, but a configured remote default refuses before spawn. Disabling workspace trust through `[workspace] require_trust = false` also refuses, because it would enable project MCP outside the managed hook. Launcher environment selectors are reserved. Fresh exact 2.5.0/2.5.1 print selects `--environment local`; resume instead inspects persisted metadata and every agent journal and refuses nonlocal or wrong-root records against the expected execution root (the isolated worktree for swarm-write); older sessions without environment records do not fail this check merely for lacking them.
|
|
302
|
+
|
|
301
303
|
## Running a newer Kimi than the plugin certifies
|
|
302
304
|
|
|
303
305
|
The plugin refuses any kimi-code version it has not certified, so an operator
|
|
@@ -308,9 +310,9 @@ at it (the runtime resolves that path instead of `kimi` on `PATH`; every spawn
|
|
|
308
310
|
still exports `KIMI_CODE_NO_AUTO_UPDATE=1`, so the pinned copy never drifts).
|
|
309
311
|
|
|
310
312
|
```sh
|
|
311
|
-
PIN=~/.local/share/kimi-plugin-cc/kimi-bin/2.
|
|
313
|
+
PIN=~/.local/share/kimi-plugin-cc/kimi-bin/2.5.1
|
|
312
314
|
mkdir -p "$PIN" && cd "$PIN" && printf '{"name":"kimi-plugin-cc-pin","private":true}\n' > package.json
|
|
313
|
-
npm install @moonshot-ai/kimi-code@2.
|
|
315
|
+
npm install @moonshot-ai/kimi-code@2.5.1
|
|
314
316
|
export KIMI_PLUGIN_CC_KIMI_BIN="$PIN/node_modules/.bin/kimi" # e.g. in ~/.zshenv
|
|
315
317
|
```
|
|
316
318
|
|
package/docs/swarm-recovery.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Normal stop: use `scripts/companion.sh cancel` for a shell-owned run, or the MCP job cancel tool for an MCP-owned run. A hard kill cannot execute cleanup. Cancellation still starts no fresh cleanup server.
|
|
4
4
|
|
|
5
|
-
For exact CLI 2.3.2, 2.3.3, 2.4.0 and 2.
|
|
5
|
+
For exact CLI 2.3.2, 2.3.3, 2.4.0, 2.4.1 and 2.5.0/2.5.1 swarm runs created by this runtime, status includes a durable `swarm_recovery` record. It contains the resolved home/workspace, companion identity, launch intent, verified process identities and session identity. It never contains the web authentication token, credentials, prompt or config contents. Session identity is committed before the request enabling swarm mode.
|
|
6
6
|
|
|
7
7
|
## Preview, then recover
|
|
8
8
|
|
|
@@ -17,7 +17,7 @@ Preview does not signal processes, modify sessions, or capture patches. Apply:
|
|
|
17
17
|
|
|
18
18
|
1. Requires the original companion to be gone and acquires an identity-checked recovery claim. A second recovery cannot race the first; a dead recovery owner can be reclaimed by compare-and-swap.
|
|
19
19
|
2. Revalidates recorded processes and groups. It stops only verified individual identities, never a guessed PID or unproven group. An unknown surviving group member, changed group, incomplete probe or unrecorded launch refuses recovery.
|
|
20
|
-
3. If session cleanup is pending, requires the selected exact certified CLI and valid managed hook. It starts one bounded authenticated web lifecycle, disables the recorded session's swarm mode, verifies
|
|
20
|
+
3. If session cleanup is pending, requires the selected exact certified CLI and valid managed hook. It starts one bounded authenticated web lifecycle, disables the recorded session's swarm mode, verifies the version-appropriate state proof and exit journal, then verifies process quiescence. On 2.5.0/2.5.1 this includes the local environment binding and protocol-v2 WebSocket main-agent state rather than `/status`. It does not resume a prompt, generate model output, install hooks or retry failed cleanup automatically. New recovery web launches are themselves journaled.
|
|
21
21
|
4. Captures a binary patch from a retained write worktree. It does not apply the patch or delete the tree. The result names both paths for inspection.
|
|
22
22
|
|
|
23
23
|
The recovery attempt has a 30-second cancellation signal, with bounded identity probes and normal teardown. Interrupting recovery retains its journal. An already-recovered record is an idempotent no-op. Failed/cancelled/completed job outcomes are immutable; a previously running abandoned job becomes failed, never completed. Recovery status is separate from task success.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Kimi Code 2.5.0 certification evidence — 2026-11-05
|
|
2
|
+
|
|
3
|
+
## Status and exact source
|
|
4
|
+
|
|
5
|
+
**Exact CLI 2.5.0 is certified for all eight operations by the plugin 2.5.2 working tree.** The exact-source audit, non-vacuous plan and swarm controls, local-environment controls, candidate matrix, and production-table matrix passed. Repository and package validation results are recorded below as they complete. Commit, push, tag, publication, installed-host rollout, and operator CLI pin changes are outside this certification slice and were not performed.
|
|
6
|
+
|
|
7
|
+
Candidate: `@moonshot-ai/kimi-code@2.5.0`, release commit `41c341434ae24e45bfe0f2232ec11b80531ac717`, compared with certified 2.4.1 (`2c73f3f50af4fa7f2540ca0d2e33b07a1408e3a7`). The monitor recorded npm publication at 2026-11-04T11:59:13.163Z. A temporary isolated npm installation and its executable both report 2.5.0. The clean exact source checkout was verified at that commit; the seven scoped 2.4.1→2.5.0 diffs are retained under `.claude/kimi-code-research/daily-monitor/2026-11-05-2.5.0-diffs/`.
|
|
8
|
+
|
|
9
|
+
## Source and integration review
|
|
10
|
+
|
|
11
|
+
Four independent source lanes reviewed hooks/plan, CLI/bootstrap, tools/fan-out, and activation adversarially. The hook/plan lane returned COMPAT-PRESERVED. Other lanes identified the removed status route, remote execution defaults/bindings, and the workspace-trust bypass; those findings drove fail-closed repairs rather than certification by assertion. A separate runtime diff review returned APPROVE with no correctness defects.
|
|
12
|
+
|
|
13
|
+
- The expanded exact-tag scan passed **18 tests and 153 assertions across 40 pinned files**, including the SDK, remote-environment implementation, workspace trust/MCP, upgrade authentication, and WebSocket state surfaces. The sole final allow remains active-plan-gated, every model tool execution retains the managed before-execute path, and EnterPlanMode remains removed.
|
|
14
|
+
- Exact 2.5.0 activation uses authenticated protocol-v2 WebSocket main-agent state with unique request IDs, an accepted subscription, and the latest frame through intentional bounded close. Earlier certified versions retain `/status`. Focused activation passed **67 tests with 228 assertions**, including wrong identities, request IDs, optional fields, malformed/oversized frames, contradictory state, timeouts, and local-binding failures.
|
|
15
|
+
- Fresh 2.5.0 print selects `--environment local`; resume never receives that flag. Launcher environment selectors are refused. Remote defaults and disabled workspace trust refuse before spawn. Resume inspection covers persisted metadata and every agent journal, requiring local execution and the expected root, including omitted-metadata-`environmentId` and swarm-write worktrees. Activation and deactivation independently re-read the authenticated local binding before either profile mutation.
|
|
16
|
+
|
|
17
|
+
## Exact-binary controls
|
|
18
|
+
|
|
19
|
+
Controls used a task-authorized Agent Key in process memory/environment and empty isolated homes, except the forced removed-tool control, which used a loopback scripted provider and a dummy key. No personal config or OAuth store was read, copied, or symlinked. Controls ran sequentially; completed evidence homes had credential-bearing config removed afterward. Raw evidence is under `.claude/kimi-code-research/cert-2.5.0-live/`.
|
|
20
|
+
|
|
21
|
+
- **Plan OFF Write:** the exact 2.5.0 marker was first; Write reached the custom deny-all control hook and was denied on the same call ID. No target file or plan state was created.
|
|
22
|
+
- **Plan ON:** authenticated agent state independently proved `plan_mode:true`, auto permission, and the env-model alias before resume. Glob reached the deny hook; a **1,459-byte** plan file was written without a plan-Write hook invocation. The workspace remained empty.
|
|
23
|
+
- **Removed EnterPlanMode:** the offered tools included Write but not EnterPlanMode. A scripted provider forced `call_enter_forced`; the exact binary returned `Tool "EnterPlanMode" not found` on that ID before any hook call and returned the rejection to the provider. No plan state or files appeared.
|
|
24
|
+
- **Environment:** real activation and deactivation passed with the explicit local binding. A configured remote default refused before its command launcher ran, disabled workspace trust refused before spawn, and a resumed remote binding refused before spawn. The implementation also passes focused omitted-id and wrong-root checks.
|
|
25
|
+
- **Swarm OFF:** a real AgentSwarm call returned the inactive-mode result with zero child journals and no probe files.
|
|
26
|
+
- **Swarm ON:** preactivation produced `agent-0` and `agent-1`; each child attempted its assigned Write with a matching managed-denial result under the same toolCallId. No probes landed, and deactivation verified `swarm_mode.exit` with the idle-reclaimer override.
|
|
27
|
+
- **Out-of-root control:** an evidence-preserving run correlated two distinct child Writes with rescue denials on their assigned call IDs, created no files, and verified deactivation.
|
|
28
|
+
|
|
29
|
+
## Candidate and production matrices
|
|
30
|
+
|
|
31
|
+
- Expanded candidate matrix (`candidate-smoke-final.log`): **24 pass, 0 fail, 167 assertions, no skips**, 396.89 seconds. Real `runRescue` landed the confined sentinel and persisted operation/version/engine/session/artifact evidence. The absolute out-of-root Bash.cwd call received its exact same-call denial and created no file. Write-swarm produced a 278-byte child-authored patch, left the user tree clean, removed its worktree, and denied the out-of-root write.
|
|
32
|
+
- Expanded production-table matrix (`production-smoke.log`) with the candidate override explicitly unset: **24 pass, 0 fail, 167 assertions, no skips**, 326.30 seconds. The same confinement, provenance, resume, pursuit, fan-out, patch, and negative-write checks passed.
|
|
33
|
+
- Candidate and production goal controls produced same-call managed denials across distinct turns and left the workspace empty at settlement.
|
|
34
|
+
- The earlier candidate attempt passed 23 of 24 lanes but was rejected as incomplete. The fresh final candidate run above supersedes it. Invalid diagnostic fixtures using relative or symlink-alias cwd were also rejected as control evidence, not counted as product failures.
|
|
35
|
+
|
|
36
|
+
## Repository and package gates
|
|
37
|
+
|
|
38
|
+
Frozen dependency installation made no changes. The literal standard `bun run check` passed **1,404 tests with 33 expected opt-in skips, 0 failures, and 17,999 assertions across 82 files in 336.44 seconds**, including the generated-distribution drift gate. Package validation passed **329 files**, all three compiled distributions, isolated hook setup/check and version refusal, a patched DSH host/profile with seven live providers/tools, and Web boot. An isolated npm consumer-security audit also passed. The certification record is included in the archive. Independent documentation fidelity review identified nine documentation corrections and, after verifying the corrected files, returned **APPROVE** with no remaining must-fix findings. The fresh tag-scan log is retained at `.claude/kimi-code-research/cert-2.5.0-live/tag-scan-final.log`.
|
|
39
|
+
|
|
40
|
+
## Preserved boundaries
|
|
41
|
+
|
|
42
|
+
Certification remains exact and per-operation. Legacy-v1 ends at 0.41.x. Plan mode and unsafe experimental selectors remain refused. Local execution and workspace trust are mandatory, and resumed nonlocal or wrong-root bindings fail closed. Hook verification, trusted-root confinement, concurrency/defaults, one print runner, memory-only web tokens, finite budgets, process/session identity checks, deactivation, and recovery ownership are preserved. Existing Git trust and hook-process failure residuals remain documented; this release does not make the hook an OS sandbox. Publication does not install or re-pin either host.
|
|
43
|
+
|
|
44
|
+
## Release clean-close hardening
|
|
45
|
+
|
|
46
|
+
After the original certification, Linux release CI exposed a platform-specific early WebSocket close event that could be accepted as valid final agent state. The final runtime now requires `CloseEvent.wasClean` before accepting that state, and the mock performs a protocol-correct close handshake while retaining the timeout case. Focused activation validation passed **71 tests with 244 assertions**. On the exact 2.5.0 binary, direct OFF again produced no children, preactivated ON produced two children with correlated managed denials and verified deactivation, and the out-of-root control passed. The final full repository check passed **1,412 tests with 18,282 assertions and zero failures in 378.11 seconds**; 330-file package validation and isolated consumer security also passed. These results supplement the original certification evidence and cover the final release behavior.
|
|
47
|
+
|
|
48
|
+
A subsequent CI attempt showed that native WebSocket close scheduling and `wasClean` semantics vary by platform and cannot supply a deterministic no-close-event precondition. That timeout case now uses a controlled socket which completes the protocol exchange but never emits `close`, and asserts the exact `Kimi web agent-state verification timed out.` message. The refusal is therefore tested without relying on incidental host close timing; production behavior is unchanged by this test-only follow-up.
|