@staix/agent-hub 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/docs/adding-an-ai-tool.md +2 -2
- package/docs/agent-notes/README.md +1 -0
- package/docs/agent-notes/adapters.md +3 -3
- package/docs/agent-notes/daemon.md +1 -1
- package/docs/agent-notes/local-worker.md +3 -3
- package/docs/agent-notes/tasks.md +5 -1
- package/docs/design/adapters.md +17 -0
- package/docs/design/cli-output-inventory.md +22 -17
- package/docs/design/roadmap.md +1 -1
- package/docs/design/task-board.md +34 -0
- package/docs/dogfood.md +7 -3
- package/docs/operations.md +49 -3
- package/docs/quickstart.md +18 -1
- package/docs/roadmap.json +20 -20
- package/docs/roadmap.md +2 -2
- package/docs/sdlc.md +3 -2
- package/docs/specs/2026-09-19-agent-hub-design.md +1 -0
- package/docs/verification/2026-11-29-agy-1.5.20.md +33 -0
- package/docs/verification/2026-11-29-claude-profile-hook.md +12 -0
- package/docs/verification/2026-11-29-idle-daemon-footprint.md +75 -0
- package/docs/verification/2026-11-29-kimi-281-reviewer-compat.md +38 -0
- package/docs/verification/2026-11-29-kimi-tui-281.md +12 -0
- package/docs/verification/2026-11-30-0.51.0.md +91 -0
- package/docs/verification/2026-11-30-account-switch-1806.md +445 -0
- package/docs/verified.json +31 -27
- package/package.json +1 -1
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +1329 -24654
- package/plugins/agent-hub/server.js +612 -413
- package/scripts/check-docs.mjs +1 -1
- package/src/adapters/acp.ts +13 -13
- package/src/adapters/agy/definition.ts +2 -2
- package/src/adapters/agy/entry.ts +2 -0
- package/src/adapters/claude-channel-evidence.ts +7 -3
- package/src/adapters/compat.ts +4 -3
- package/src/adapters/definitions/builtin-metadata.ts +2 -2
- package/src/adapters/definitions/native-cli-claude-launch.ts +3 -1
- package/src/adapters/definitions/native-cli-entry-claude.ts +17 -2
- package/src/adapters/definitions/native-cli-entry-codex.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-jcode.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-kimi.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-pi.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-qwen.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-types.ts +3 -1
- package/src/adapters/definitions/native-cli-jcode-home-init.ts +1 -1
- package/src/adapters/definitions/native-cli-preview-common.ts +1 -1
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/jcode.ts +16 -0
- package/src/adapters/native-facts-hooks.ts +12 -0
- package/src/cli/autonomy-offline.ts +1 -1
- package/src/cli/bench.ts +1 -1
- package/src/cli/claude-profile-hook.ts +31 -11
- package/src/cli/commands/releases.ts +82 -0
- package/src/cli/conductor-recovery.ts +1 -1
- package/src/cli/facts-hook.ts +11 -4
- package/src/cli/help.ts +8 -6
- package/src/cli/identity.ts +5 -1
- package/src/cli/init-prompt.ts +1 -1
- package/src/cli/init-settings.ts +4 -35
- package/src/cli/init.ts +1 -1
- package/src/cli/json-text-spans.ts +57 -0
- package/src/cli/launch-check.ts +157 -0
- package/src/cli/launch.ts +19 -1
- package/src/cli/main.ts +44 -3
- package/src/cli/memory.ts +1 -1
- package/src/cli/output.ts +14 -1
- package/src/cli/preview.ts +1 -1
- package/src/cli/recovery-launch.ts +1 -1
- package/src/cli/setup-homes.ts +2 -2
- package/src/cli/start-agents-run.ts +85 -7
- package/src/cli/start-check.ts +28 -0
- package/src/cli/upgrade-runtime.ts +1 -1
- package/src/cli/warn-line.ts +1 -1
- package/src/hub/ci-watch.ts +311 -79
- package/src/hub/config-apply.ts +1 -1
- package/src/hub/config.ts +518 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +76 -513
- package/src/hub/delivery-public.ts +11 -0
- package/src/hub/hub-check.ts +125 -0
- package/src/hub/path-policy.ts +1 -1
- package/src/hub/permission-mode.ts +3 -40
- package/src/hub/permission-paths.ts +41 -0
- package/src/hub/recovery-policy.ts +1 -1
- package/src/hub/releases-inventory.ts +198 -0
- package/src/hub/runtime-capture-prune.ts +25 -3
- package/src/hub/runtime-prune-health.ts +8 -1
- package/src/hub/sdlc-release-authorization.ts +42 -21
- package/src/hub/sdlc-release-diagnostics.ts +5 -0
- package/src/hub/sdlc-release-policy.ts +21 -7
- package/src/hub/sdlc-release.ts +80 -20
- package/src/hub/sdlc.ts +7 -3
- package/src/hub/tasks.ts +138 -36
- package/src/ui/plugin.ts +1 -1
package/scripts/check-docs.mjs
CHANGED
|
@@ -142,7 +142,7 @@ if (process.env.AHUB_CHECK_ROADMAP === "1") {
|
|
|
142
142
|
if (!jsonOutput) for (const report of reports) console.log(`docs: ${report}`);
|
|
143
143
|
if (requireFresh && reports.length) errors.push("release requires fresh documentation stamps");
|
|
144
144
|
if (requireFresh && errors.length) errors.push("release refused: merge the release PR with a merge commit and verify all documentation stamps before tagging");
|
|
145
|
-
if (jsonOutput) console.log(JSON.stringify({ schemaVersion: 1, ...(headId ? { head: headId } : {}), ...(packageVersion ? { version: packageVersion } : {}), documents, errors: errors.length, fresh: !errors.length && !reports.length }));
|
|
145
|
+
if (jsonOutput) console.log(JSON.stringify({ schemaVersion: 1, ...(headId ? { head: headId } : {}), ...(packageVersion ? { version: packageVersion } : {}), documents, errors: errors.length, fresh: !errors.length && !reports.length, ...(committed && errors.length ? { messages: errors.slice(0, 3).map(message => message.slice(0, 300)) } : {}) }));
|
|
146
146
|
else for (const error of errors) console.error(`docs: ERROR ${error}`);
|
|
147
147
|
if (errors.length) process.exitCode = 1;
|
|
148
148
|
else if (!jsonOutput) console.log(`docs: OK (${reports.length} stale document${reports.length === 1 ? "" : "s"})`);
|
package/src/adapters/acp.ts
CHANGED
|
@@ -567,7 +567,7 @@ export class AcpPeer extends BasePeer {
|
|
|
567
567
|
}
|
|
568
568
|
} catch (error) {
|
|
569
569
|
if (error instanceof RpcTimeoutError && current()) {
|
|
570
|
-
if (this.activeDeliveryId) this.delivery({ id: this.activeDeliveryId, state: "failed_safe", reason: "ACP model acknowledgement timed out before a prompt was sent; restart this peer before retrying" });
|
|
570
|
+
if (this.activeDeliveryId) this.delivery({ id: this.activeDeliveryId, state: "failed_safe", reason: "ACP model acknowledgement timed out before a prompt was sent; restart this peer before retrying", failureCause: "timeout" });
|
|
571
571
|
this.activeDeliveryId = undefined; this.activeLegacy = undefined;
|
|
572
572
|
this.modelUnknown = true; this.turn++; this.setState("offline");
|
|
573
573
|
await this.stop();
|
|
@@ -646,7 +646,7 @@ export class AcpPeer extends BasePeer {
|
|
|
646
646
|
// invalidates its generation, while stopping still prevents a drain.
|
|
647
647
|
if (legacy?.turn === this.turn) this.onFailed?.(legacy.envs);
|
|
648
648
|
if (reason !== undefined) this.turn++; // a requested stop cannot escalate or complete the cancelled turn
|
|
649
|
-
if (this.activeDeliveryId) this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason: reason ?? "ACP session stopped before settlement" });
|
|
649
|
+
if (this.activeDeliveryId) this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason: reason ?? "ACP session stopped before settlement", failureCause: "turn aborted" });
|
|
650
650
|
this.settleSteers("needs_review", reason ?? "ACP session stopped before settlement");
|
|
651
651
|
this.activeDeliveryId = undefined;
|
|
652
652
|
const proc = this.proc;
|
|
@@ -669,19 +669,19 @@ export class AcpPeer extends BasePeer {
|
|
|
669
669
|
/** Resolves once the prompt is in flight; the turn result arrives on its own. */
|
|
670
670
|
async deliver(envs: Envelope[], deliveryId?: string): Promise<void> {
|
|
671
671
|
if (this.state !== "idle" || this.stopping) {
|
|
672
|
-
if (deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason: `${this.id} is ${this.state}
|
|
672
|
+
if (deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason: `${this.id} is ${this.state}`, failureCause: this.state === "offline" ? "peer offline" : "adapter refused" });
|
|
673
673
|
throw new Error(`${this.id} is ${this.state}`);
|
|
674
674
|
}
|
|
675
675
|
let selection: ModelOverrideSelection | undefined;
|
|
676
676
|
try { selection = this.opts.getModelOverride?.(); }
|
|
677
677
|
catch {
|
|
678
|
-
if (deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP retained model selection is unavailable; inspect model status, clear the override or restart before retrying" });
|
|
678
|
+
if (deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP retained model selection is unavailable; inspect model status, clear the override or restart before retrying", failureCause: "adapter refused" });
|
|
679
679
|
throw new Error("ACP retained model selection is unavailable; inspect model status, clear the override or restart before retrying");
|
|
680
680
|
}
|
|
681
681
|
const target = selection?.model ?? this.modelBaseline;
|
|
682
682
|
if (selection && (!target || !this.acceptsModelOverride(target))) {
|
|
683
683
|
selection.rejected?.();
|
|
684
|
-
if (deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP model is not advertised by this verified session; inspect model status and retry" });
|
|
684
|
+
if (deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP model is not advertised by this verified session; inspect model status and retry", failureCause: "adapter refused" });
|
|
685
685
|
throw new Error("ACP model is not advertised by this verified session; inspect model status and retry");
|
|
686
686
|
}
|
|
687
687
|
const turn = ++this.turn;
|
|
@@ -709,7 +709,7 @@ export class AcpPeer extends BasePeer {
|
|
|
709
709
|
catch (error) {
|
|
710
710
|
if (turn === this.turn && !this.modelTurn?.sent) {
|
|
711
711
|
selection.rejected?.();
|
|
712
|
-
if (deliveryId && this.activeDeliveryId === deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP model change did not admit a prompt; inspect status and retry" });
|
|
712
|
+
if (deliveryId && this.activeDeliveryId === deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP model change did not admit a prompt; inspect status and retry", failureCause: "adapter refused" });
|
|
713
713
|
this.activeDeliveryId = undefined; this.activeLegacy = undefined; this.modelTurn = undefined;
|
|
714
714
|
this.endActivity("model change refused", true);
|
|
715
715
|
if (!this.stopping && (this.state as PeerState) === "busy") this.setState("idle");
|
|
@@ -744,9 +744,9 @@ export class AcpPeer extends BasePeer {
|
|
|
744
744
|
if (result?.stopReason !== "end_turn") this.reportTurnFailure(envs, `ACP prompt ended without normal completion (${String(result?.stopReason ?? "unknown")})`);
|
|
745
745
|
if (deliveryId && this.activeDeliveryId === deliveryId) {
|
|
746
746
|
this.acceptDelivery();
|
|
747
|
-
this.delivery({ id: deliveryId, state: result?.stopReason === "end_turn" ? "completed" : "needs_review", ...(result?.stopReason === "end_turn" ? {} : { reason: "ACP prompt ended without normal completion" }) });
|
|
747
|
+
this.delivery({ id: deliveryId, state: result?.stopReason === "end_turn" ? "completed" : "needs_review", ...(result?.stopReason === "end_turn" ? {} : { reason: "ACP prompt ended without normal completion", failureCause: "turn aborted" as const }) });
|
|
748
748
|
}
|
|
749
|
-
this.settleSteers(result?.stopReason === "end_turn" ? "completed" : "needs_review", "ACP prompt ended without normal completion");
|
|
749
|
+
this.settleSteers(result?.stopReason === "end_turn" ? "completed" : "needs_review", "ACP prompt ended without normal completion", "turn aborted");
|
|
750
750
|
})
|
|
751
751
|
.catch((e: Error) => {
|
|
752
752
|
if (turn !== this.turn) {
|
|
@@ -756,7 +756,7 @@ export class AcpPeer extends BasePeer {
|
|
|
756
756
|
if (!this.modelTurn?.acknowledged) this.modelTurn?.selection.rejected?.();
|
|
757
757
|
this.endActivity("failed", true);
|
|
758
758
|
const reason = this.nativePolicy !== undefined || this.opts.requireOwnedGroup ? "Configured ACP prompt failed" : sanitize(e.message);
|
|
759
|
-
this.settleSteers("needs_review", reason);
|
|
759
|
+
this.settleSteers("needs_review", reason, "push error");
|
|
760
760
|
this.opts.log?.(this.nativePolicy !== undefined || this.opts.requireOwnedGroup ? "Configured ACP prompt failed; native details withheld" : `[${this.id}] prompt failed: ${reason}`);
|
|
761
761
|
const quota = !this.stopping && this.kimiAgent ? acpQuotaRefusal(e.message) : undefined;
|
|
762
762
|
if (quota) {
|
|
@@ -764,12 +764,12 @@ export class AcpPeer extends BasePeer {
|
|
|
764
764
|
try { paused = this.opts.onQuotaRefusal?.(quota) === true; }
|
|
765
765
|
catch (error) { this.opts.log?.(`[${this.id}] quota pause failed: ${sanitize(error instanceof Error ? error.message : String(error))}`); }
|
|
766
766
|
const safe = paused && !this.deliveryAccepted && !this.promptActivity;
|
|
767
|
-
if (deliveryId && this.activeDeliveryId === deliveryId) this.delivery({ id: deliveryId, state: safe ? "failed_safe" : "needs_review", reason, ...(safe ? { quota: true as const } : {}) });
|
|
767
|
+
if (deliveryId && this.activeDeliveryId === deliveryId) this.delivery({ id: deliveryId, state: safe ? "failed_safe" : "needs_review", reason, failureCause: safe ? "adapter refused" : "push error", ...(safe ? { quota: true as const } : {}) });
|
|
768
768
|
else if (!deliveryId && this.activeLegacy?.turn === turn) { this.activeLegacy = undefined; this.onFailed?.(envs, safe ? { quota: true } : undefined); }
|
|
769
769
|
return; // quota relay owns reassignment, not the ordinary turn-failure path
|
|
770
770
|
}
|
|
771
771
|
this.reportTurnFailure(envs, reason);
|
|
772
|
-
if (deliveryId && this.activeDeliveryId === deliveryId) this.delivery({ id: deliveryId, state: "needs_review", reason });
|
|
772
|
+
if (deliveryId && this.activeDeliveryId === deliveryId) this.delivery({ id: deliveryId, state: "needs_review", reason, failureCause: "push error" });
|
|
773
773
|
else if (!deliveryId && this.activeLegacy?.turn === turn) { this.activeLegacy = undefined; this.onFailed?.(envs); }
|
|
774
774
|
})
|
|
775
775
|
.finally(() => {
|
|
@@ -890,8 +890,8 @@ export class AcpPeer extends BasePeer {
|
|
|
890
890
|
this.opts.log?.(`[${this.id}] ${reason}`);
|
|
891
891
|
for (const p of this.pending.values()) p.reject(new Error(reason));
|
|
892
892
|
this.pending.clear();
|
|
893
|
-
if (this.activeDeliveryId) this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason });
|
|
894
|
-
this.settleSteers("needs_review", reason);
|
|
893
|
+
if (this.activeDeliveryId) this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason, failureCause: "push error" });
|
|
894
|
+
this.settleSteers("needs_review", reason, "push error");
|
|
895
895
|
this.activeDeliveryId = undefined;
|
|
896
896
|
this.setState("offline");
|
|
897
897
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { runAgyEntry } from "./entry.ts";
|
|
2
2
|
import type { AdapterDefinition, LaunchContext, LaunchPlan } from "../registry-types.ts";
|
|
3
3
|
import { AGY_REVIEWER_VARIANT } from "../definitions/reviewer-variants.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { NATIVE_FACTS_HOOKS } from "../native-facts-hooks.ts";
|
|
5
5
|
|
|
6
6
|
const DISPLAY = { palette: { fg: "#6558a6", bg: "#f1effa" } };
|
|
7
7
|
const shellQuote = (value: string): string => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
@@ -57,5 +57,5 @@ export const AGY_DEFINITION: AdapterDefinition = {
|
|
|
57
57
|
routing: { allowedRoles: ["implementer", "verifier"] },
|
|
58
58
|
reviewer: { defaultPool: false, declaration: "automatic", unavailable: "agy is an implementer peer (#485)" },
|
|
59
59
|
reviewerVariant: AGY_REVIEWER_VARIANT,
|
|
60
|
-
hooks: { factsHook:
|
|
60
|
+
hooks: { factsHook: NATIVE_FACTS_HOOKS.agy },
|
|
61
61
|
};
|
|
@@ -5,6 +5,7 @@ import { spawn, spawnSync } from "node:child_process";
|
|
|
5
5
|
import { dirname, resolve } from "node:path";
|
|
6
6
|
import type { NativeCliEntryContext } from "../definitions/native-cli-entry-types.ts";
|
|
7
7
|
import { bundleInStatus, rosterInStatus } from "../../hub/status-roster.ts";
|
|
8
|
+
import { printLaunchCheck } from "../../cli/launch-check.ts";
|
|
8
9
|
import { ensureAgyMcp, cleanupAgyMcp, type AgyMcpOptions } from "../../cli/agy-mcp.ts";
|
|
9
10
|
import { peerChildEnv } from "../../hub/child-process.ts";
|
|
10
11
|
|
|
@@ -68,6 +69,7 @@ export async function runAgyEntry(ctx: NativeCliEntryContext): Promise<void> {
|
|
|
68
69
|
if (!hub.features.includes("native_hook_launch")) fail("running hub lacks the verified native hook launcher; upgrade or restart it before launching agy");
|
|
69
70
|
const status = (await hub.request({ t: "status" })).status;
|
|
70
71
|
if (rosterInStatus(status, "agy") !== true) fail("agy is off roster; add it with ahub roster add agy");
|
|
72
|
+
printLaunchCheck(status, "agy", ctx.definition, "tui");
|
|
71
73
|
const admitted = await hub.request({ t: "native_hook_launch", op: "begin", peer: "agy" });
|
|
72
74
|
if (!admitted.ok || typeof admitted.launchId !== "string" || typeof admitted.instanceId !== "string") fail(admitted.error ?? "native hook launch was not admitted");
|
|
73
75
|
const serverJs = bundleInStatus(status) ?? resolve(cliDir, "../../plugins/agent-hub/server.js");
|
|
@@ -11,14 +11,18 @@ const DISABLING = new Set(["-p", "--print", "--output-format", "--background", "
|
|
|
11
11
|
|
|
12
12
|
// ponytail: current native launches expose only a flattened direct-parent argv row; this does not prove registration or authenticate the host. Replace it with an explicit per-server client opt-in when Claude publishes one.
|
|
13
13
|
/** Classify a flattened `ps` command only when its leading argv tokens are unambiguous. */
|
|
14
|
-
export function classifyClaudeParentCommand(command: string): ClaudeChannelEvidence {
|
|
14
|
+
export function classifyClaudeParentCommand(command: string, rejectedArgument?: (position: number) => void): ClaudeChannelEvidence {
|
|
15
15
|
if (!command || command.length > 4096 || /[\n\r\0]/.test(command)) return "launch-unverified";
|
|
16
16
|
const argv = command.trim().split(/\s+/);
|
|
17
17
|
const executable = argv[0]?.split("/").at(-1);
|
|
18
|
-
|
|
18
|
+
const reject = (position: number): ClaudeChannelEvidence => { rejectedArgument?.(position); return "launch-unverified"; };
|
|
19
|
+
if (executable !== "claude") return reject(0);
|
|
20
|
+
if (argv[1] !== "--dangerously-load-development-channels") return reject(1);
|
|
21
|
+
if (argv.length < 3 || !TARGETS.has(argv[2]!)) return reject(2);
|
|
19
22
|
// The channel flag is ignored by print/background/daemon forms. A later repeated
|
|
20
23
|
// flag can change the selected channels, so those commands fail closed as well.
|
|
21
|
-
|
|
24
|
+
const rejected = argv.slice(3).findIndex(arg => DISABLING.has(arg) || arg.startsWith("--print=") || arg.startsWith("--output-format=") || arg.startsWith("-p") || arg === "--dangerously-load-development-channels" || arg.startsWith("--dangerously-load-development-channels="));
|
|
25
|
+
if (rejected >= 0) return reject(rejected + 3);
|
|
22
26
|
return "development-channel-launch";
|
|
23
27
|
}
|
|
24
28
|
|
package/src/adapters/compat.ts
CHANGED
|
@@ -44,13 +44,14 @@ export const COMPAT = {
|
|
|
44
44
|
parse: out => plain(out.trim().replace(/^codex-cli /, "")),
|
|
45
45
|
trustNote: "Every launch still proves the MCP inventory, Apps/plugins/hooks disabled, sandbox read/write denial and the binary fence; a failed leg still refuses. Trust covers only the source-level claims those probes cannot see (docs/verification/2026-10-19-reviewer-isolation.md).",
|
|
46
46
|
receipt: "docs/verification/2026-11-14-codex-0169-reviewer-isolation.md" },
|
|
47
|
-
// Kimi 2.3.0 / Qwen 0.26.0 receipt: docs/verification/2026-10-22-kimi-qwen-compat.md; Kimi 2.3.1: docs/verification/2026-10-25-kimi-231-reviewer-compat.md; Kimi 2.3.2: docs/verification/2026-10-26-kimi-232-reviewer-compat.md; Kimi 2.4.1: docs/verification/2026-10-31-kimi-241-reviewer-compat.md; Kimi 2.5.1: docs/verification/2026-11-06-kimi-251-reviewer-compat.md; 2.7.2: docs/verification/2026-11-25-kimi-272-reviewer-compat.md
|
|
48
|
-
"kimi-review": { label: "Kimi reviewer (kimi-code)", verified: ["2.2.0", "2.3.0", "2.3.1", "2.3.2", "2.4.1", "2.5.1", "2.7.2"], gate: "isolation", probe: ["kimi", "--version"],
|
|
47
|
+
// Kimi 2.3.0 / Qwen 0.26.0 receipt: docs/verification/2026-10-22-kimi-qwen-compat.md; Kimi 2.3.1: docs/verification/2026-10-25-kimi-231-reviewer-compat.md; Kimi 2.3.2: docs/verification/2026-10-26-kimi-232-reviewer-compat.md; Kimi 2.4.1: docs/verification/2026-10-31-kimi-241-reviewer-compat.md; Kimi 2.5.1: docs/verification/2026-11-06-kimi-251-reviewer-compat.md; 2.7.2: docs/verification/2026-11-25-kimi-272-reviewer-compat.md; 2.8.1: docs/verification/2026-11-29-kimi-281-reviewer-compat.md
|
|
48
|
+
"kimi-review": { label: "Kimi reviewer (kimi-code)", verified: ["2.2.0", "2.3.0", "2.3.1", "2.3.2", "2.4.1", "2.5.1", "2.7.2", "2.8.1"], gate: "isolation", probe: ["kimi", "--version"],
|
|
49
49
|
parse: out => plain(out.trim()),
|
|
50
50
|
trustNote: "Every launch still builds the private config, exact two-tool agent file and task-bound MCP; the native tool allowlist behaviour of an untested version is not re-proven.",
|
|
51
|
-
receipt: "docs/verification/2026-11-
|
|
51
|
+
receipt: "docs/verification/2026-11-29-kimi-281-reviewer-compat.md" },
|
|
52
52
|
// The interactive TUI's native-turn and background readbacks are a separate contract from headless ACP and reviewer isolation.
|
|
53
53
|
// 2.7.2 model-free checks and pending live TUI legs: docs/verification/2026-11-25-kimi-tui-272.md
|
|
54
|
+
// 2.8.1 host checks and pending live TUI legs: docs/verification/2026-11-29-kimi-tui-281.md
|
|
54
55
|
"kimi-tui": { label: "Kimi TUI completion facts", verified: ["2.5.2"], gate: "contract", probe: ["kimi", "--version"],
|
|
55
56
|
parse: out => plain(out.trim()),
|
|
56
57
|
trustNote: "Only 2.5.2 has a live receipt for turn.prompt/turn.ended/prompt completion rows, background task inventory and launcher-bound plugin hooks. Another version keeps completion receipts disabled.",
|
|
@@ -23,7 +23,7 @@ import { CLAUDE_DISPLAY, CODEX_DISPLAY, KIMI_DISPLAY, PI_DISPLAY, LOCAL_DISPLAY,
|
|
|
23
23
|
import { CLAUDE_RECOVERY_SESSION, CODEX_RECOVERY_SESSION, KIMI_RECOVERY_SESSION, PI_RECOVERY_SESSION, LOCAL_RECOVERY_SESSION, JCODE_RECOVERY_SESSION } from "./native-recovery.ts";
|
|
24
24
|
import { claudeWindows, codexWindows } from "./native-quota.ts";
|
|
25
25
|
import { claudeContext, codexContext, acpContextValue, jcodeContextValue, piContext } from "./native-context.ts";
|
|
26
|
-
import {
|
|
26
|
+
import { NATIVE_FACTS_HOOKS } from "../native-facts-hooks.ts";
|
|
27
27
|
import type { AdapterDefinition } from "../registry-types.ts";
|
|
28
28
|
import type { PeerAdapter } from "../../hub/peers.ts";
|
|
29
29
|
|
|
@@ -119,7 +119,7 @@ export const NATIVE_BUILTIN_DEFINITIONS_WITHOUT_QWEN: readonly AdapterDefinition
|
|
|
119
119
|
permission: { grants: { ask: "Kimi asks as it does on its own", "ask-when-needed": "Kimi's yolo mode: it asks only where it judges it must", "never-ask": "Kimi's auto mode: nothing asks" },
|
|
120
120
|
unmanagedForms: Object.freeze(["tui"] as const), unmanagedStatusNote: "Kimi approves tools in its own TUI; no hub permission mode", unmanagedNote: "Kimi approves tools and selects its permission mode in its own TUI; no hub permission mode" },
|
|
121
121
|
session: { idField: "sessionId", currentId: sessionId("sessionId"), freshOnRestore: true, launchKind: "acp", ...KIMI_RECOVERY_SESSION, crashPlan: kimiCrashPlan },
|
|
122
|
-
turnEnd: "adapter", settle: { signal: "prompt-response" }, budget: { account: "kimi", resetSoftTokensOnResume: true, context: { source: "acp_usage_update", read: acpContextValue } }, capabilities: { watch: true }, hooks: { factsHook:
|
|
122
|
+
turnEnd: "adapter", settle: { signal: "prompt-response" }, budget: { account: "kimi", resetSoftTokensOnResume: true, context: { source: "acp_usage_update", read: acpContextValue } }, capabilities: { watch: true }, hooks: { factsHook: NATIVE_FACTS_HOOKS.kimi, recallPlatform: "kimi", recallSource: "kimi" },
|
|
123
123
|
cli: { command: "kimi", entry: { lifecycleAdmission: true, execute: runKimiEntry }, preview: previewKimi, usage: [["ahub kimi [--print-command] [--mode tui|headless] [--model <alias>]", "default: Kimi's own TUI, pull-only via hub_inbox; no push, steer, watchdog, console approvals or automatic quota handoff. Select headless for ACP", "start Kimi in its own TUI, or headless over ACP"]], launchConfigKeys: ["kimi_cmd", "peers.kimi.start_mode"], stopNotice: form => form === "tui" ? "Kimi belongs to its own TUI terminal; end it in that terminal" : "", startWords: form => ["kimi", "--mode", form] }, display: KIMI_DISPLAY,
|
|
124
124
|
},
|
|
125
125
|
{
|
|
@@ -21,7 +21,9 @@ function claudeChannel(userArgs: string[]): string {
|
|
|
21
21
|
return CLAUDE_CHANNEL;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function claudeNativeLaunch(
|
|
24
|
+
export function claudeNativeLaunch(input: LaunchContext): LaunchPlan {
|
|
25
|
+
// #1798 T3: a preview shows what the interactive entry launches, so its hooks carry the session-start check the entry opts in to. A copy, never the caller's object.
|
|
26
|
+
const ctx: LaunchContext = input.preview && input.facts ? { ...input, facts: { ...input.facts, startCheck: true } } : input;
|
|
25
27
|
const { passthrough, unattended } = nativeLaunchArguments("claude", ctx, CLAUDE_LAUNCH_POLICY);
|
|
26
28
|
const build = (): Launch => {
|
|
27
29
|
// `--settings` takes one value, so a user-supplied one wins and Claude has no quota source for that session.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classifyClaudeParentCommand } from "../claude-channel-evidence.ts";
|
|
1
2
|
import { retainedLaunchWarning } from "./native-cli-retained.ts";
|
|
2
3
|
import { readFileSync } from "node:fs";
|
|
3
4
|
import { join } from "node:path";
|
|
@@ -5,6 +6,7 @@ import { randomUUID } from "node:crypto";
|
|
|
5
6
|
import type { ClaudeLaunchRecord } from "../../cli/launch.ts";
|
|
6
7
|
import type { NativeCliEntryContext } from "./native-cli-entry-types.ts";
|
|
7
8
|
import { claudeStateFile, isClaudeSessionUuid } from "../../hub/claude-state.ts";
|
|
9
|
+
import { claudeArgvNextStep, printLaunchCheck, readLaunchCheck } from "../../cli/launch-check.ts";
|
|
8
10
|
|
|
9
11
|
/** Preserve native selectors. A picker, continuation or fork without an explicit id stays unattested. */
|
|
10
12
|
function managedSession(nativeArgs: string[]): string | undefined {
|
|
@@ -21,7 +23,7 @@ function managedSession(nativeArgs: string[]): string | undefined {
|
|
|
21
23
|
if (options.some(arg => ["-c", "--continue", "--from-pr", "--teleport", "--fork-session"].some(flag => arg === flag || arg.startsWith(flag + "=")))) return;
|
|
22
24
|
if (resume.length) return resume.length === 1 && isClaudeSessionUuid(resume[0]) ? resume[0] : undefined;
|
|
23
25
|
const id = randomUUID();
|
|
24
|
-
nativeArgs.
|
|
26
|
+
nativeArgs.splice(options.length, 0, "--session-id", id);
|
|
25
27
|
return id;
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -74,6 +76,7 @@ export async function runClaudeEntry(ctx: NativeCliEntryContext): Promise<void>
|
|
|
74
76
|
}
|
|
75
77
|
// Turn-free facts and opted-in task sweeps share native PreToolUse/PostToolUse/Stop observations.
|
|
76
78
|
const facts = claudeObservationHooks(projectConfig(), { script: join(cliDir, "facts-hook.ts"), stateDir });
|
|
79
|
+
if (facts) facts.startCheck = true; // #1798 T3: the interactive entry alone opts in to the session-start Hub check
|
|
77
80
|
let previousLaunch: unknown;
|
|
78
81
|
try { previousLaunch = JSON.parse(readFileSync(join(stateDir, claudeStateFile("claude-launch", peer)), "utf8")); } catch { /* no previous managed launch */ }
|
|
79
82
|
const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script: join(cliDir, "statusline-tee.ts"), stateDir, ...(original ? { original } : {}) }, ...(facts ? { facts } : {}) });
|
|
@@ -88,10 +91,22 @@ export async function runClaudeEntry(ctx: NativeCliEntryContext): Promise<void>
|
|
|
88
91
|
recordClaudeLaunch(stateDir, launchRecord);
|
|
89
92
|
cleanupStaleClaudeSettings(stateDir, previousLaunch);
|
|
90
93
|
}
|
|
94
|
+
// This foreground path always requests the development channel. Check the final argv after attestation.
|
|
95
|
+
let rejectedPosition: number | undefined;
|
|
96
|
+
const evidence = classifyClaudeParentCommand([launch.cmd, ...launch.args].join(" "), position => { rejectedPosition = position; });
|
|
97
|
+
if (evidence !== "development-channel-launch") {
|
|
98
|
+
const cause = rejectedPosition === undefined ? "command length or control characters" : `argv[${rejectedPosition}]`;
|
|
99
|
+
console.error(`Hub check failed for Claude channel (${evidence} at ${cause}). ${claudeArgvNextStep([launch.cmd, ...launch.args].join(" "), rejectedPosition)}`);
|
|
100
|
+
}
|
|
91
101
|
if (launch.warning) console.error(launch.warning);
|
|
102
|
+
// #1798 T3: the pre-launch Hub check runs inside runClaudeLaunch, just before the spawn. One read, one 3 s total deadline, no retry.
|
|
103
|
+
const beforeSpawn = async () => {
|
|
104
|
+
if (process.stderr.isTTY !== true) return; // nothing would print, so make no connection
|
|
105
|
+
printLaunchCheck({ hubCheck: await readLaunchCheck(timeoutMs => ctx.connectOnce(timeoutMs)) }, peer, ctx.definition, "tui");
|
|
106
|
+
};
|
|
92
107
|
const env = nativeLaunchEnv("claude", childEnv());
|
|
93
108
|
if (ctx.instance) env.AGENTHUB_PEER_ID = peer; // the channel plugin and the statusline tee write for this instance
|
|
94
|
-
result = await runClaudeLaunch(launch, { cwd: executionCwd, stateDir, env: { ...env, AGENTHUB_STATE_DIR: stateDir, AGENTHUB_PROJECT_DIR: cwd }, ...(launchRecord ? { record: launchRecord } : {}) });
|
|
109
|
+
result = await runClaudeLaunch(launch, { cwd: executionCwd, stateDir, env: { ...env, AGENTHUB_STATE_DIR: stateDir, AGENTHUB_PROJECT_DIR: cwd }, ...(launchRecord ? { record: launchRecord } : {}), beforeSpawn });
|
|
95
110
|
} finally {
|
|
96
111
|
cleanupClaudeSettings(stateDir, launch.settingsFile);
|
|
97
112
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { retainedLaunchWarning } from "./native-cli-retained.ts";
|
|
2
|
+
import { printLaunchCheck } from "../../cli/launch-check.ts";
|
|
2
3
|
import type { NativeCliEntryContext } from "./native-cli-entry-types.ts";
|
|
3
4
|
|
|
4
5
|
export async function runCodexEntry(ctx: NativeCliEntryContext): Promise<void> {
|
|
@@ -26,6 +27,7 @@ export async function runCodexEntry(ctx: NativeCliEntryContext): Promise<void> {
|
|
|
26
27
|
const hub = await connect();
|
|
27
28
|
const snapshot = (await hub.request({ t: "status" })).status;
|
|
28
29
|
const warning = retainedLaunchWarning(snapshot, peer, ctx.definition); if (warning) console.error(warning);
|
|
30
|
+
printLaunchCheck(snapshot, peer, ctx.definition, "tui");
|
|
29
31
|
const res = await hub.request({ t: "start", peer, args: { unattended: launch0.unattended === true }, operationId: process.env.AGENTHUB_RECOVERY_OPERATION });
|
|
30
32
|
if (!res.ok) { hub.close(); fail(res.error); }
|
|
31
33
|
if (ctx.instance) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { retainedLaunchWarning } from "./native-cli-retained.ts";
|
|
2
|
+
import { printLaunchCheck } from "../../cli/launch-check.ts";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import type { NativeCliEntryContext } from "./native-cli-entry-types.ts";
|
|
4
5
|
import type { ControlClient } from "../../hub/control-client.ts";
|
|
@@ -104,6 +105,7 @@ export async function runJcodeEntry(ctx: NativeCliEntryContext): Promise<void> {
|
|
|
104
105
|
if (rostered === undefined) fail(`cannot read ${peer}'s roster membership from the running hub; upgrade or restart it, then retry (nothing was started)`);
|
|
105
106
|
if (!rostered) fail(`${peer} is off roster; add it with ahub roster add ${peer}`);
|
|
106
107
|
const warning = retainedLaunchWarning(snapshot, peer, ctx.definition); if (warning) console.error(warning);
|
|
108
|
+
if (mode === "tui" && !print) printLaunchCheck(snapshot, peer, ctx.definition, "tui");
|
|
107
109
|
const options = { model: one["--model"], providerProfile: one["--provider-profile"], sessionId: one["--session-id"] };
|
|
108
110
|
if (print) {
|
|
109
111
|
if (!hub.features.includes("native_tui_launch") || mode !== "tui") return console.log(JSON.stringify(launcherPreview("jcode", args, cwd, stateDir, unattendedEnv), null, 2));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { retainedLaunchWarning } from "./native-cli-retained.ts";
|
|
2
|
+
import { printLaunchCheck } from "../../cli/launch-check.ts";
|
|
2
3
|
import { join, resolve } from "node:path";
|
|
3
4
|
import { homedir } from "node:os";
|
|
4
5
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -69,6 +70,7 @@ export async function runKimiEntry(ctx: NativeCliEntryContext): Promise<void> {
|
|
|
69
70
|
if (rostered === undefined) fail("cannot read kimi's roster membership from the running hub; upgrade or restart it, then retry (nothing was started)");
|
|
70
71
|
if (!rostered) fail("kimi is off roster; add it with ahub roster add kimi");
|
|
71
72
|
const warning = retainedLaunchWarning(snapshot, peer, ctx.definition); if (warning) console.error(warning);
|
|
73
|
+
printLaunchCheck(snapshot, peer, ctx.definition, "tui");
|
|
72
74
|
const owner = snapshot?.peers?.[peer];
|
|
73
75
|
if (owner && !["offline"].includes(owner.state) && !owner.pullOnly) fail("Kimi is running headless; run ahub stop kimi before starting its TUI");
|
|
74
76
|
const admission = await hub.request({ t: "start", peer, args: { mode: "tui" }, operationId: process.env.AGENTHUB_RECOVERY_OPERATION });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { retainedLaunchWarning } from "./native-cli-retained.ts";
|
|
2
|
+
import { printLaunchCheck } from "../../cli/launch-check.ts";
|
|
2
3
|
import { parsePiFlags } from "./native-cli-pi.ts";
|
|
3
4
|
import type { NativeCliEntryContext } from "./native-cli-entry-types.ts";
|
|
4
5
|
|
|
@@ -37,6 +38,7 @@ export async function runPiEntry(ctx: NativeCliEntryContext): Promise<void> {
|
|
|
37
38
|
const hub = await connect();
|
|
38
39
|
const snapshot = (await hub.request({ t: "status" })).status;
|
|
39
40
|
const warning = retainedLaunchWarning(snapshot, peer, ctx.definition); if (warning) console.error(warning);
|
|
41
|
+
if (options.mode === "tui") printLaunchCheck(snapshot, peer, ctx.definition, "tui");
|
|
40
42
|
const res = await hub.request({ t: "start", peer, args: options, operationId: process.env.AGENTHUB_RECOVERY_OPERATION });
|
|
41
43
|
hub.close();
|
|
42
44
|
if (!res.ok) fail(res.error);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { peerChildEnv } from "../../hub/child-process.ts";
|
|
2
2
|
import { retainedLaunchWarning } from "./native-cli-retained.ts";
|
|
3
|
+
import { printLaunchCheck } from "../../cli/launch-check.ts";
|
|
3
4
|
import type { NativeCliEntryContext } from "./native-cli-entry-types.ts";
|
|
4
5
|
|
|
5
6
|
function verifiedLaunch(value: unknown): { cmd: string; args: string[]; env: NodeJS.ProcessEnv } | undefined {
|
|
@@ -29,6 +30,7 @@ export async function runQwenEntry(ctx: NativeCliEntryContext): Promise<void> {
|
|
|
29
30
|
try {
|
|
30
31
|
const snapshot = (await hub.request({ t: "status" })).status;
|
|
31
32
|
const warning = retainedLaunchWarning(snapshot, peer, ctx.definition); if (warning) console.error(warning);
|
|
33
|
+
if (mode === "tui") printLaunchCheck(snapshot, peer, ctx.definition, "tui");
|
|
32
34
|
const reply = await hub.request({ t: "start", peer, args: { mode, ...(one["--model"] ? { model: one["--model"] } : {}), ...(one["--session-id"] ? { sessionId: one["--session-id"] } : {}) }, operationId: process.env.AGENTHUB_RECOVERY_OPERATION }, 35_000);
|
|
33
35
|
if (!reply.ok) fail(reply.error);
|
|
34
36
|
if (mode === "tui") {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HubConfig } from "../../hub/
|
|
1
|
+
import type { HubConfig } from "../../hub/config.ts";
|
|
2
2
|
import type { ControlClient } from "../../hub/control-client.ts";
|
|
3
3
|
import type { AdapterDefinition } from "../registry-types.ts";
|
|
4
4
|
|
|
@@ -11,6 +11,8 @@ export interface NativeCliEntryContext {
|
|
|
11
11
|
args: string[]; cwd: string; stateDir: string; cliDir: string; unattendedEnv: boolean; definition: AdapterDefinition;
|
|
12
12
|
projectConfig(): HubConfig;
|
|
13
13
|
connect(): Promise<ControlClient>;
|
|
14
|
+
/** #1798 T3: one connection attempt as the caller's own identity, no retry, no instance check, no retry message and never the delegated audit connection. */
|
|
15
|
+
connectOnce(timeoutMs: number): Promise<ControlClient>;
|
|
14
16
|
fail(message: string): never;
|
|
15
17
|
exec(bin: string, argv: string[], tool?: "claude" | "codex" | "kimi"): never;
|
|
16
18
|
execWithEnv(bin: string, argv: string[], extra: NodeJS.ProcessEnv): never;
|
|
@@ -11,7 +11,7 @@ import { configRefusal } from "../../hub/config-trust.ts";
|
|
|
11
11
|
import { idFor } from "../../hub/registry.ts";
|
|
12
12
|
import { projectRoot } from "../../hub/project.ts";
|
|
13
13
|
import { startModeOf } from "../../hub/start-mode.ts";
|
|
14
|
-
import type { HubConfig } from "../../hub/
|
|
14
|
+
import type { HubConfig } from "../../hub/config.ts";
|
|
15
15
|
import { shellQuote } from "../../cli/shell-quote.ts";
|
|
16
16
|
|
|
17
17
|
/** Whether init should offer the hub-owned home: jcode is installed or rostered, and `jcode_home` is unset or the person's own. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import type { HubConfig } from "../../hub/
|
|
2
|
+
import type { HubConfig } from "../../hub/config.ts";
|
|
3
3
|
import type { Routing } from "../../hub/routing.ts";
|
|
4
4
|
|
|
5
5
|
/** Preserve the legacy config block order and shallow native merges. */
|
package/src/adapters/jcode.ts
CHANGED
|
@@ -103,6 +103,22 @@ export const JCODE_HEADLESS_AFTER_RECOVERY = "jcode is running headless after re
|
|
|
103
103
|
export function jcodeDetachedNotice(peer: string): { cause: string; command: string } {
|
|
104
104
|
return { cause: "a Jcode server the hub did not start is serving this peer's socket, so its work continues outside the hub", command: peer === "jcode" ? "ahub jcode" : `ahub jcode --as ${peer}` };
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* #1795: a hub-tools hello the hub refused while this peer's owned launch is live and attached (a jcode child session, an older MCP child). It names the
|
|
108
|
+
* process so the person can end it; it never changes the peer's state. Display only: the pid comes from the hello and is not authority, and the command
|
|
109
|
+
* is one bounded `ps` read, control characters removed, never an environment or argument vector beyond that one line.
|
|
110
|
+
*/
|
|
111
|
+
export function refusedHelloProcess(pid: unknown, read: (pid: number) => string | undefined = defaultProcessCommand): { pid?: number; command?: string } {
|
|
112
|
+
const id = typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && pid <= 2_147_483_647 ? pid : undefined;
|
|
113
|
+
if (id === undefined) return {};
|
|
114
|
+
let command: string | undefined;
|
|
115
|
+
try { command = read(id)?.replace(/[\x00-\x1f\x7f]/g, " ").trim().slice(0, 200) || undefined; } catch { command = undefined; }
|
|
116
|
+
return { pid: id, ...(command ? { command } : {}) };
|
|
117
|
+
}
|
|
118
|
+
function defaultProcessCommand(pid: number): string | undefined {
|
|
119
|
+
const result = Bun.spawnSync(["/bin/ps", "-p", String(pid), "-o", "command="], { stdout: "pipe", stderr: "ignore", timeout: 2000 });
|
|
120
|
+
return result.exitCode === 0 ? result.stdout.toString() : undefined;
|
|
121
|
+
}
|
|
106
122
|
const JCODE_OWNED_ENV = { JCODE_DISABLE_CLAUDE_MCP: "1", JCODE_NO_TELEMETRY: "1" } as const;
|
|
107
123
|
/** #691: the verdict lives in `src/adapters/compat.ts` (line, verified versions, the person's trust); never pin here. */
|
|
108
124
|
export const jcodeVersionSupported = (version: unknown): boolean => assessVersion("jcode", version).ok;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AGY_FACTS_HOOK } from "./agy/hooks.ts";
|
|
2
|
+
import { KIMI_TUI_FACTS_HOOK } from "./kimi-tui-facts.ts";
|
|
3
|
+
import type { NativeFactsPort } from "./registry-types.ts";
|
|
4
|
+
|
|
5
|
+
export const NATIVE_FACTS_HOOKS = Object.freeze({
|
|
6
|
+
agy: AGY_FACTS_HOOK,
|
|
7
|
+
kimi: KIMI_TUI_FACTS_HOOK,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export function nativeFactsHook(peer: string): NativeFactsPort | undefined {
|
|
11
|
+
return Object.hasOwn(NATIVE_FACTS_HOOKS, peer) ? NATIVE_FACTS_HOOKS[peer as keyof typeof NATIVE_FACTS_HOOKS] : undefined;
|
|
12
|
+
}
|
|
@@ -3,7 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { planAutonomy, autonomyRemovalKeys, autonomyStatus, autonomyPreset, type AutonomyOperation, type AutonomyPeer, type AutonomyFloorStatus } from "../hub/autonomy.ts";
|
|
4
4
|
import { configFingerprint, configSourceTexts } from "../hub/config-reload.ts";
|
|
5
5
|
import { configRefusal } from "../hub/config-trust.ts";
|
|
6
|
-
import { loadConfig } from "../hub/
|
|
6
|
+
import { loadConfig } from "../hub/config.ts";
|
|
7
7
|
import { validateEffectiveConfig } from "../hub/config-apply.ts";
|
|
8
8
|
import { readInstanceConfigLayers, readInstanceRoleConfig } from "../hub/instance-config.ts";
|
|
9
9
|
import { checkSettingValue, settingDef, settingText, writeAutonomyPreset } from "../hub/settings.ts";
|
package/src/cli/bench.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { taskRecords } from "../hub/research.ts";
|
|
|
10
10
|
import { appendBench, BENCH_SCHEMA, memoryMode, type MemoryMode, parseSuite, suiteHash, type Attempt, type AttemptError, type AttemptMetrics, type Fingerprint, type Outcome, type SuiteTask } from "../hub/bench.ts";
|
|
11
11
|
import { hubHome, realPath } from "../hub/project.ts";
|
|
12
12
|
import { processSignature } from "../pi/process-signature.ts";
|
|
13
|
-
import { loadConfig } from "../hub/
|
|
13
|
+
import { loadConfig } from "../hub/config.ts";
|
|
14
14
|
import { addonState, detectTooling, type Addon, type AddonName } from "../hub/tooling.ts";
|
|
15
15
|
import { VERSION } from "../version.ts";
|
|
16
16
|
import { warnLine } from "./warn-line.ts";
|
|
@@ -2,12 +2,13 @@ import { closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, mkdi
|
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { dirname, isAbsolute, join } from "node:path";
|
|
4
4
|
import { factsHook } from "./facts-hook.ts";
|
|
5
|
+
import { replaceJsonValue } from "./json-text-spans.ts";
|
|
5
6
|
import { shellQuote } from "./shell-quote.ts";
|
|
6
7
|
import { stableBunRuntime, stablePackageRoot } from "./install-paths.ts";
|
|
7
8
|
import type { ClaudeHome } from "./claude-homes.ts";
|
|
8
9
|
|
|
9
10
|
export interface ClaudeProfileHookOptions { script?: string; runtime?: string; instruction?: boolean }
|
|
10
|
-
export interface ClaudeProfileHookCheck { state: "installed" | "missing" | "refused"; reason: string }
|
|
11
|
+
export interface ClaudeProfileHookCheck { state: "installed" | "missing" | "refused"; reason: string; outdated?: true }
|
|
11
12
|
export interface ClaudeProfileHookInstall extends ClaudeProfileHookCheck { changed: boolean }
|
|
12
13
|
const MAX_SETTINGS_BYTES = 1024 * 1024;
|
|
13
14
|
const validPath = (value: unknown): value is string => typeof value === "string" && value.length > 0 && value.length <= 4096 && isAbsolute(value) && !/[\x00-\x1f\x7f]/.test(value);
|
|
@@ -24,10 +25,21 @@ interface HookPlan {
|
|
|
24
25
|
source?: { info: Stats; digest: string };
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
const PROFILE_GUARD = 'if [ -n "${AGENTHUB_STATE_DIR-}" ] && [ -n "${AGENTHUB_PEER_ID-}" ] && [ -z "${AGENTHUB_LAUNCH_ID+x}" ]; then exec ';
|
|
29
|
+
const PROFILE_GUARD_END = "; fi";
|
|
30
|
+
|
|
31
|
+
function profileInvocation(runtime: string, script: string): string {
|
|
32
|
+
return `${shellQuote(runtime)} ${shellQuote(script)} --run`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function profileCommand(runtime: string, script: string): string {
|
|
36
|
+
return `${PROFILE_GUARD}${profileInvocation(runtime, script)}${PROFILE_GUARD_END}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
function hookEntry(options: ClaudeProfileHookOptions): Record<string, unknown> {
|
|
28
40
|
const script = options.script ?? join(stablePackageRoot(join(import.meta.dir, "../..")), "src/cli/claude-profile-hook.ts"), runtime = options.runtime ?? stableBunRuntime();
|
|
29
41
|
if (!validPath(script) || !validPath(runtime)) throw new Error("invalid profile hook command");
|
|
30
|
-
return { matcher: "*", hooks: [{ type: "command", command:
|
|
42
|
+
return { matcher: "*", hooks: [{ type: "command", command: profileCommand(runtime, script), timeout: 5 }] };
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
function instructionEntry(options: ClaudeProfileHookOptions): Record<string, unknown> {
|
|
@@ -53,11 +65,13 @@ function managedProfileHook(candidate: unknown): ManagedProfileHook | undefined
|
|
|
53
65
|
if (!object(candidate) || !Array.isArray(candidate.hooks) || candidate.hooks.length !== 1) return;
|
|
54
66
|
const hook = candidate.hooks[0];
|
|
55
67
|
if (!object(hook) || hook.type !== "command" || typeof hook.command !== "string") return;
|
|
56
|
-
const
|
|
68
|
+
const guarded = hook.command.startsWith(PROFILE_GUARD) && hook.command.endsWith(PROFILE_GUARD_END);
|
|
69
|
+
const invocation = guarded ? hook.command.slice(PROFILE_GUARD.length, -PROFILE_GUARD_END.length) : hook.command;
|
|
70
|
+
const match = /^'((?:[^']|'\\'')*)' '((?:[^']|'\\'')*)' --run$/.exec(invocation);
|
|
57
71
|
if (!match) return;
|
|
58
72
|
const runtime = match[1]!.replace(/'\\''/g, "'"), script = match[2]!.replace(/'\\''/g, "'");
|
|
59
73
|
if (!validPath(runtime) || !validPath(script) || !script.endsWith("/src/cli/claude-profile-hook.ts")
|
|
60
|
-
|| hook.command !==
|
|
74
|
+
|| hook.command !== (guarded ? profileCommand(runtime, script) : profileInvocation(runtime, script))) return;
|
|
61
75
|
return { entry: candidate, hook, runtime, script };
|
|
62
76
|
}
|
|
63
77
|
|
|
@@ -65,7 +79,7 @@ function hookPathPresent(file: string): boolean {
|
|
|
65
79
|
try { return statSync(file).isFile(); } catch { return false; }
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
function settingsSource(file: string): { value: Record<string, unknown>; source?: HookPlan["source"] } {
|
|
82
|
+
function settingsSource(file: string): { value: Record<string, unknown>; text?: string; source?: HookPlan["source"] } {
|
|
69
83
|
let fd: number | undefined;
|
|
70
84
|
try {
|
|
71
85
|
fd = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
@@ -73,9 +87,9 @@ function settingsSource(file: string): { value: Record<string, unknown>; source?
|
|
|
73
87
|
if (!info.isFile() || info.nlink !== 1 || !owned(info) || info.size > MAX_SETTINGS_BYTES) throw new Error("unsafe settings");
|
|
74
88
|
const bytes = Buffer.alloc(MAX_SETTINGS_BYTES + 1), count = readSync(fd, bytes, 0, bytes.length, 0);
|
|
75
89
|
if (count > MAX_SETTINGS_BYTES) throw new Error("oversized settings");
|
|
76
|
-
const content = bytes.subarray(0, count), value: unknown = JSON.parse(
|
|
90
|
+
const content = bytes.subarray(0, count), text = content.toString("utf8"), value: unknown = JSON.parse(text);
|
|
77
91
|
if (!object(value)) throw new Error("invalid settings");
|
|
78
|
-
return { value, source: { info, digest: createHash("sha256").update(content).digest("hex") } };
|
|
92
|
+
return { value, text, source: { info, digest: createHash("sha256").update(content).digest("hex") } };
|
|
79
93
|
} catch (error) {
|
|
80
94
|
if ((error as NodeJS.ErrnoException).code === "ENOENT") return { value: {} };
|
|
81
95
|
throw error;
|
|
@@ -96,7 +110,7 @@ function planClaudeProfileHook(home: ClaudeHome, options: ClaudeProfileHookOptio
|
|
|
96
110
|
parent = lstatSync(dirname(home.path), { throwIfNoEntry: false });
|
|
97
111
|
if (!parent?.isDirectory() || parent.isSymbolicLink() || !owned(parent)) return refuse("The selected Claude home's parent is unsafe or unavailable.");
|
|
98
112
|
}
|
|
99
|
-
const { value, source } = settingsSource(file);
|
|
113
|
+
const { value, text, source } = settingsSource(file);
|
|
100
114
|
if (value.disableAllHooks === true) return refuse("Claude has disableAllHooks enabled; the profile hook cannot be installed.");
|
|
101
115
|
if (value.disableAllHooks !== undefined && typeof value.disableAllHooks !== "boolean") return refuse("Claude's hook enablement setting is malformed.");
|
|
102
116
|
if (value.hooks !== undefined && !object(value.hooks)) return refuse("Claude's hook configuration is malformed.");
|
|
@@ -106,6 +120,8 @@ function planClaudeProfileHook(home: ClaudeHome, options: ClaudeProfileHookOptio
|
|
|
106
120
|
const managed = existing.map(managedProfileHook), first = managed.find(candidate => candidate !== undefined);
|
|
107
121
|
const count = managed.filter(candidate => candidate !== undefined).length;
|
|
108
122
|
const stale = managed.some(candidate => candidate && (!hookPathPresent(candidate.runtime) || !hookPathPresent(candidate.script)));
|
|
123
|
+
const legacy = count === 1 && first !== undefined && first.hook.command === profileInvocation(first.runtime, first.script);
|
|
124
|
+
const outdated = legacy && !stale && profileCommand(first.runtime, first.script) === expectedCommand;
|
|
109
125
|
const configured = count === 1 && first?.hook.command === expectedCommand && !stale;
|
|
110
126
|
const normalized = existing.flatMap((candidate, index) => {
|
|
111
127
|
const owned = managed[index];
|
|
@@ -133,13 +149,17 @@ function planClaudeProfileHook(home: ClaudeHome, options: ClaudeProfileHookOptio
|
|
|
133
149
|
nextHooks[event] = rewritten;
|
|
134
150
|
}
|
|
135
151
|
}
|
|
136
|
-
const next = configured && instructionConfigured ? undefined
|
|
152
|
+
const next = configured && instructionConfigured ? undefined
|
|
153
|
+
: legacy && instructionConfigured && text !== undefined
|
|
154
|
+
? replaceJsonValue(text, ["hooks", "PreToolUse", managed.indexOf(first), "hooks", 0, "command"], expectedCommand)
|
|
155
|
+
: `${JSON.stringify({ ...value, hooks: nextHooks }, null, 2)}\n`;
|
|
137
156
|
if (next !== undefined && Buffer.byteLength(next, "utf8") > MAX_SETTINGS_BYTES) return refuse("Claude's settings would exceed the bounded profile settings size.");
|
|
138
157
|
let reason = "The project-neutral profile hook is not configured for this install; run ahub setup.";
|
|
139
158
|
if (count > 1) reason = "Duplicate managed profile hooks need normalization; run ahub setup.";
|
|
140
159
|
if (stale) reason = "A managed profile hook script or runtime is missing; run ahub setup to refresh the selected home's hook.";
|
|
160
|
+
if (outdated) reason = "The installed project-neutral profile hook is outdated; run ahub setup to add the shell guard.";
|
|
141
161
|
if (configured) reason = "The project-neutral profile hook is configured; this does not prove live permission enforcement.";
|
|
142
|
-
return { file, home: directory, parent, source, next, check: { state: configured && instructionConfigured ? "installed" : "missing", reason } };
|
|
162
|
+
return { file, home: directory, parent, source, next, check: { state: (configured || outdated) && instructionConfigured ? "installed" : "missing", reason, ...(outdated ? { outdated: true as const } : {}) } };
|
|
143
163
|
} catch { return refuse("Claude profile settings could not be safely inspected; no settings were changed."); }
|
|
144
164
|
}
|
|
145
165
|
|
|
@@ -150,7 +170,7 @@ export function checkClaudeProfileHook(home: ClaudeHome, options: ClaudeProfileH
|
|
|
150
170
|
/** Only the selected home is created; unrelated profile directories and settings are never touched. */
|
|
151
171
|
export function installClaudeProfileHook(home: ClaudeHome, options: ClaudeProfileHookOptions = {}): ClaudeProfileHookInstall {
|
|
152
172
|
const plan = planClaudeProfileHook(home, options);
|
|
153
|
-
if (plan.
|
|
173
|
+
if (plan.next === undefined) return { ...plan.check, changed: false };
|
|
154
174
|
const temporary = join(home.path, `.agent-hub-profile-hook-${randomUUID()}.tmp`);
|
|
155
175
|
let created: Stats | undefined;
|
|
156
176
|
try {
|