@staix/agent-hub 0.49.1 → 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.
Files changed (99) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +1 -1
  3. package/docs/adding-an-ai-tool.md +2 -2
  4. package/docs/agent-notes/README.md +1 -0
  5. package/docs/agent-notes/adapters.md +3 -3
  6. package/docs/agent-notes/daemon.md +1 -1
  7. package/docs/agent-notes/local-worker.md +3 -3
  8. package/docs/agent-notes/tasks.md +5 -1
  9. package/docs/design/adapters.md +17 -0
  10. package/docs/design/agent-hub.md +1 -1
  11. package/docs/design/cli-output-inventory.md +24 -19
  12. package/docs/design/cli-output.md +1 -1
  13. package/docs/design/roadmap.md +2 -2
  14. package/docs/design/task-board.md +34 -0
  15. package/docs/dogfood.md +8 -3
  16. package/docs/operations.md +53 -4
  17. package/docs/quickstart.md +26 -2
  18. package/docs/roadmap.json +20 -20
  19. package/docs/roadmap.md +2 -2
  20. package/docs/sdlc.md +3 -2
  21. package/docs/specs/2026-09-19-agent-hub-design.md +1 -0
  22. package/docs/verification/2026-11-29-0.50.0.md +54 -0
  23. package/docs/verification/2026-11-29-agy-1.5.20.md +33 -0
  24. package/docs/verification/2026-11-29-claude-profile-hook.md +12 -0
  25. package/docs/verification/2026-11-29-idle-daemon-footprint.md +75 -0
  26. package/docs/verification/2026-11-29-kimi-281-reviewer-compat.md +38 -0
  27. package/docs/verification/2026-11-29-kimi-tui-281.md +12 -0
  28. package/docs/verification/2026-11-30-0.51.0.md +91 -0
  29. package/docs/verification/2026-11-30-account-switch-1806.md +445 -0
  30. package/docs/verified.json +31 -27
  31. package/package.json +1 -1
  32. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  33. package/plugins/agent-hub/kimi-hook.js +1329 -24629
  34. package/plugins/agent-hub/server.js +638 -414
  35. package/scripts/check-docs.mjs +1 -1
  36. package/src/adapters/acp.ts +13 -13
  37. package/src/adapters/agy/definition.ts +2 -2
  38. package/src/adapters/agy/entry.ts +2 -0
  39. package/src/adapters/claude-channel-evidence.ts +7 -3
  40. package/src/adapters/compat.ts +4 -3
  41. package/src/adapters/definitions/builtin-metadata.ts +2 -2
  42. package/src/adapters/definitions/native-cli-claude-launch.ts +3 -1
  43. package/src/adapters/definitions/native-cli-entry-claude.ts +17 -2
  44. package/src/adapters/definitions/native-cli-entry-codex.ts +2 -0
  45. package/src/adapters/definitions/native-cli-entry-jcode.ts +2 -0
  46. package/src/adapters/definitions/native-cli-entry-kimi.ts +2 -0
  47. package/src/adapters/definitions/native-cli-entry-pi.ts +2 -0
  48. package/src/adapters/definitions/native-cli-entry-qwen.ts +2 -0
  49. package/src/adapters/definitions/native-cli-entry-types.ts +3 -1
  50. package/src/adapters/definitions/native-cli-jcode-home-init.ts +1 -1
  51. package/src/adapters/definitions/native-cli-preview-common.ts +1 -1
  52. package/src/adapters/definitions/native-config-defaults.ts +1 -1
  53. package/src/adapters/jcode.ts +16 -0
  54. package/src/adapters/native-facts-hooks.ts +12 -0
  55. package/src/cli/autonomy-offline.ts +1 -1
  56. package/src/cli/bench.ts +1 -1
  57. package/src/cli/claude-profile-hook.ts +31 -11
  58. package/src/cli/commands/releases.ts +82 -0
  59. package/src/cli/conductor-recovery.ts +1 -1
  60. package/src/cli/facts-hook.ts +11 -4
  61. package/src/cli/help.ts +12 -10
  62. package/src/cli/identity.ts +5 -1
  63. package/src/cli/init-prompt.ts +1 -1
  64. package/src/cli/init-settings.ts +4 -35
  65. package/src/cli/init.ts +1 -1
  66. package/src/cli/json-text-spans.ts +57 -0
  67. package/src/cli/launch-check.ts +157 -0
  68. package/src/cli/launch.ts +19 -1
  69. package/src/cli/main.ts +63 -10
  70. package/src/cli/memory.ts +1 -1
  71. package/src/cli/output.ts +14 -1
  72. package/src/cli/preview.ts +1 -1
  73. package/src/cli/recovery-launch.ts +1 -1
  74. package/src/cli/setup-homes.ts +2 -2
  75. package/src/cli/start-agents-run.ts +85 -7
  76. package/src/cli/start-check.ts +28 -0
  77. package/src/cli/upgrade-runtime.ts +1 -1
  78. package/src/cli/warn-line.ts +1 -1
  79. package/src/hub/ci-watch.ts +311 -79
  80. package/src/hub/config-apply.ts +1 -1
  81. package/src/hub/config.ts +518 -0
  82. package/src/hub/control-client.ts +1 -1
  83. package/src/hub/daemon.ts +76 -513
  84. package/src/hub/delivery-public.ts +11 -0
  85. package/src/hub/hub-check.ts +125 -0
  86. package/src/hub/path-policy.ts +1 -1
  87. package/src/hub/permission-mode.ts +3 -40
  88. package/src/hub/permission-paths.ts +41 -0
  89. package/src/hub/recovery-policy.ts +1 -1
  90. package/src/hub/releases-inventory.ts +198 -0
  91. package/src/hub/runtime-capture-prune.ts +25 -3
  92. package/src/hub/runtime-prune-health.ts +8 -1
  93. package/src/hub/sdlc-release-authorization.ts +42 -21
  94. package/src/hub/sdlc-release-diagnostics.ts +5 -0
  95. package/src/hub/sdlc-release-policy.ts +21 -7
  96. package/src/hub/sdlc-release.ts +80 -20
  97. package/src/hub/sdlc.ts +7 -3
  98. package/src/hub/tasks.ts +138 -36
  99. package/src/ui/plugin.ts +1 -1
@@ -754,12 +754,12 @@ var init_compat = __esm(() => {
754
754
  },
755
755
  "kimi-review": {
756
756
  label: "Kimi reviewer (kimi-code)",
757
- verified: ["2.2.0", "2.3.0", "2.3.1", "2.3.2", "2.4.1", "2.5.1", "2.7.2"],
757
+ 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"],
758
758
  gate: "isolation",
759
759
  probe: ["kimi", "--version"],
760
760
  parse: (out) => plain(out.trim()),
761
761
  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.",
762
- receipt: "docs/verification/2026-11-25-kimi-272-reviewer-compat.md"
762
+ receipt: "docs/verification/2026-11-29-kimi-281-reviewer-compat.md"
763
763
  },
764
764
  "kimi-tui": {
765
765
  label: "Kimi TUI completion facts",
@@ -835,6 +835,181 @@ function bundleInStatus(status) {
835
835
  return typeof value === "string" && value.startsWith("/") && /[\\/]plugins[\\/]agent-hub[\\/]server\.js$/.test(value) ? value : undefined;
836
836
  }
837
837
 
838
+ // src/hub/hub-check.ts
839
+ function expectedHubLink(definition, form) {
840
+ return definition?.transport === "ws-pull" || form !== undefined && definition?.attach?.pullOnlyForms?.includes(form) ? "pull" : "push";
841
+ }
842
+ function renderHubCheck(check, only) {
843
+ const rows = only ? check.peers.filter((peer) => only.includes(peer.id)) : check.peers.filter((peer) => peer.observed !== "offline" || !peer.ok);
844
+ const lines = [`Hub check (agent-hub ${check.version}, control port ${check.controlPort})`];
845
+ for (const peer of rows) {
846
+ if (peer.ok && peer.observed !== "offline") {
847
+ lines.push(` \u2713 ${peer.id}: ${peer.observed}${peer.queued ? `, ${peer.queued} queued` : ""}`);
848
+ continue;
849
+ }
850
+ lines.push(` \u26A0 ${peer.id}: ${peer.observed}${peer.cause ? `, ${peer.cause}` : ""}${peer.queued ? `, ${peer.queued} queued` : ""}${peer.nextStep ? `; next: ${peer.nextStep}` : ""}`);
851
+ }
852
+ if (rows.length === 0)
853
+ lines.push(" no agents attached");
854
+ return lines;
855
+ }
856
+ function renderHubCheckUnavailable(result = HUB_CHECK_UNAVAILABLE) {
857
+ return [`Hub check: \u26A0 ${result.cause}; next: ${result.nextStep}`];
858
+ }
859
+ var UNVERIFIED, HUB_CHECK_UNAVAILABLE;
860
+ var init_hub_check = __esm(() => {
861
+ UNVERIFIED = new Set(["launch-unverified", "unknown", "unreported"]);
862
+ HUB_CHECK_UNAVAILABLE = { unavailable: true, cause: "the hub check could not be read from the hub", nextStep: "ahub status" };
863
+ });
864
+
865
+ // node_modules/@staix/cli-output/src/index.ts
866
+ function terminalText(value, options = {}) {
867
+ const text = String(value ?? "").replace(/\r\n?/g, `
868
+ `).replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\|$)/g, "").replace(/\x1b[P_X^][\s\S]*?(?:\x1b\\|$)/g, "").replace(/(?:\x1b\[|\x9b)[0-?]*[ -/]*(?:[@-~]|(?=\n|$))/g, "").replace(/\x1b[^\n]?/g, "");
869
+ return options.singleLine ? text.replace(/[\x00-\x1f\x7f-\x9f]/g, " ") : text.replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "");
870
+ }
871
+ function paint(spans, color, styles = {}) {
872
+ return spans.map((span) => {
873
+ const text = terminalText(span.text);
874
+ const role = span.role && Object.hasOwn(ROLE_SGR, span.role) ? ROLE_SGR[span.role] : undefined;
875
+ const custom = span.style && Object.hasOwn(styles, span.style) ? styles[span.style] : undefined;
876
+ if (custom && !/^\x1b\[[0-9;]+m$/.test(custom))
877
+ throw new Error(`invalid SGR for style ${span.style}`);
878
+ const sgr = role !== undefined ? role : custom;
879
+ return color && sgr && text ? sgr + text + SGR_RESET : text;
880
+ }).join("");
881
+ }
882
+ var SGR_RESET = "\x1B[0m", ROLE_SGR, MARKERS, EXIT;
883
+ var init_src = __esm(() => {
884
+ ROLE_SGR = Object.freeze({
885
+ header: "\x1B[1;34m",
886
+ section: "\x1B[1;35m",
887
+ key: "\x1B[34m",
888
+ value: "",
889
+ success: "\x1B[1;32m",
890
+ warning: "\x1B[1;33m",
891
+ error: "\x1B[1;31m",
892
+ hint: "\x1B[90m",
893
+ accent: "\x1B[36m"
894
+ });
895
+ MARKERS = Object.freeze({
896
+ ok: { glyph: "\u2713", ascii: "ok", role: "success" },
897
+ fail: { glyph: "\u2717", ascii: "x", role: "error" },
898
+ warn: { glyph: "\u26A0", ascii: "!", role: "warning" },
899
+ absent: { glyph: "-", ascii: "-", role: "hint" },
900
+ unknown: { glyph: "?", ascii: "?", role: "hint" },
901
+ pending: { glyph: "~", ascii: "~", role: "hint" },
902
+ active: { glyph: "*", ascii: "*", role: "success" },
903
+ next: { glyph: "\u2192", ascii: "->", role: "accent" }
904
+ });
905
+ EXIT = Object.freeze({ ok: 0, fail: 1, usage: 2, tempfail: 75 });
906
+ });
907
+
908
+ // src/cli/output-standard.ts
909
+ var TONE_SGR;
910
+ var init_output_standard = __esm(() => {
911
+ init_src();
912
+ TONE_SGR = Object.freeze({ strong: "\x1B[1;36m", failure: "\x1B[31m", number: "\x1B[1m", issueRef: "\x1B[4m", taskRef: "\x1B[4;35m" });
913
+ });
914
+
915
+ // src/cli/warn-line.ts
916
+ var plain2 = (text) => text.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\|$)/g, "").replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "");
917
+ var init_warn_line = __esm(() => {
918
+ init_output_standard();
919
+ });
920
+
921
+ // src/cli/launch-check.ts
922
+ async function readLaunchCheck(connectOnce, totalMs = LAUNCH_CHECK_TOTAL_MS) {
923
+ const deadline = Date.now() + totalMs;
924
+ let expired = false;
925
+ let open;
926
+ let timer;
927
+ const closeOpen = () => {
928
+ const client = open;
929
+ open = undefined;
930
+ try {
931
+ client?.close();
932
+ } catch {}
933
+ };
934
+ const attempt = (async () => {
935
+ const client = await connectOnce(Math.max(1, deadline - Date.now()));
936
+ if (expired) {
937
+ try {
938
+ client.close();
939
+ } catch {}
940
+ return;
941
+ }
942
+ open = client;
943
+ const reply = await client.request({ t: "status" }, Math.max(1, deadline - Date.now()));
944
+ const check = reply?.status?.hubCheck;
945
+ return check && Array.isArray(check.peers) ? check : undefined;
946
+ })().catch(() => {
947
+ return;
948
+ });
949
+ try {
950
+ return await Promise.race([attempt, new Promise((resolve) => {
951
+ timer = setTimeout(() => {
952
+ expired = true;
953
+ closeOpen();
954
+ resolve(undefined);
955
+ }, totalMs);
956
+ })]);
957
+ } catch {
958
+ return;
959
+ } finally {
960
+ if (timer)
961
+ clearTimeout(timer);
962
+ closeOpen();
963
+ }
964
+ }
965
+ function cleanLine(line) {
966
+ return plain2(line.replace(/[\r\n]+/g, " "));
967
+ }
968
+ function renderLaunchCheck(check, peer, definition, form) {
969
+ if (!check)
970
+ return renderHubCheckUnavailable(HUB_CHECK_UNAVAILABLE);
971
+ const row = check.peers.find((item) => item.id === peer);
972
+ const expected = row?.expected ?? expectedHubLink(definition, form);
973
+ const lines = [renderHubCheck(check, [])[0], ` ${peer}: starting, expected link ${expected}, ${row ? `${row.queued} queued` : "queue unknown"}; check again after it starts: ahub status`];
974
+ if (row && row.observed !== "offline")
975
+ lines.push(` state before this launch: ${row.observed}${row.cause ? `, ${row.cause}` : ""}`);
976
+ return lines;
977
+ }
978
+ function fixedName(token) {
979
+ if (token === undefined)
980
+ return;
981
+ if (token.startsWith("-p"))
982
+ return "-p";
983
+ for (const flag of ["--print", "--output-format", "--dangerously-load-development-channels"])
984
+ if (token.startsWith(flag))
985
+ return flag;
986
+ return FIXED_WORDS.has(token) ? token : undefined;
987
+ }
988
+ function claudeArgvNextStep(command, position) {
989
+ if (position === undefined)
990
+ return "Shorten the arguments passed to ahub claude (long command lines and control characters are not attested), then run it again.";
991
+ if (position <= 2)
992
+ return `Try ahub claude --session-id "$(uuidgen | tr 'A-Z' 'a-z')" and report it on #1798`;
993
+ const name = fixedName(command.trim().split(/\s+/)[position]);
994
+ if (name === undefined)
995
+ return "Remove the argument at that position, or start ahub claude without your prompt and type it in the session; the channel is not attested while it is there.";
996
+ return `${name} runs Claude without its channel or changes which channels load, so no hub link can attach; start without ${name}, and if it is a word in your prompt, start ahub claude without the prompt and type it in the session.`;
997
+ }
998
+ function printLaunchCheck(snapshot, peer, definition, form = "tui") {
999
+ if (process.stderr.isTTY !== true)
1000
+ return;
1001
+ const candidate = snapshot?.hubCheck;
1002
+ const check = candidate && Array.isArray(candidate.peers) ? candidate : undefined;
1003
+ for (const line of renderLaunchCheck(check, peer, definition, form))
1004
+ console.error(cleanLine(line));
1005
+ }
1006
+ var LAUNCH_CHECK_TOTAL_MS = 3000, FIXED_WORDS, START_HOOK_TIMEOUT_S = 5;
1007
+ var init_launch_check = __esm(() => {
1008
+ init_hub_check();
1009
+ init_warn_line();
1010
+ FIXED_WORDS = new Set(["--background", "--detach", "--daemon", "daemon", "bg", "bg-spare"]);
1011
+ });
1012
+
838
1013
  // src/adapters/same-directory.ts
839
1014
  function sameDirectory(named, directory) {
840
1015
  if (typeof named !== "string" || !named || named.length > 4096 || /[\u0000-\u001f\u007f]/.test(named))
@@ -1613,6 +1788,7 @@ async function runAgyEntry(ctx) {
1613
1788
  const status = (await hub.request({ t: "status" })).status;
1614
1789
  if (rosterInStatus(status, "agy") !== true)
1615
1790
  fail("agy is off roster; add it with ahub roster add agy");
1791
+ printLaunchCheck(status, "agy", ctx.definition, "tui");
1616
1792
  const admitted = await hub.request({ t: "native_hook_launch", op: "begin", peer: "agy" });
1617
1793
  if (!admitted.ok || typeof admitted.launchId !== "string" || typeof admitted.instanceId !== "string")
1618
1794
  fail(admitted.error ?? "native hook launch was not admitted");
@@ -1646,6 +1822,7 @@ async function runAgyEntry(ctx) {
1646
1822
  var AGY_LAUNCH_NOTICE = "Antigravity: pull-only TUI; native permissions unmanaged, no hub sandbox; hub tools appear from the second turn (send any first prompt, then ask for hub work)";
1647
1823
  var init_entry = __esm(() => {
1648
1824
  init_compat();
1825
+ init_launch_check();
1649
1826
  init_agy_mcp();
1650
1827
  init_child_process();
1651
1828
  });
@@ -5840,7 +6017,7 @@ var init_acp = __esm(() => {
5840
6017
  } catch (error) {
5841
6018
  if (error instanceof RpcTimeoutError && current()) {
5842
6019
  if (this.activeDeliveryId)
5843
- this.delivery({ id: this.activeDeliveryId, state: "failed_safe", reason: "ACP model acknowledgement timed out before a prompt was sent; restart this peer before retrying" });
6020
+ 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" });
5844
6021
  this.activeDeliveryId = undefined;
5845
6022
  this.activeLegacy = undefined;
5846
6023
  this.modelUnknown = true;
@@ -5924,7 +6101,7 @@ var init_acp = __esm(() => {
5924
6101
  if (reason !== undefined)
5925
6102
  this.turn++;
5926
6103
  if (this.activeDeliveryId)
5927
- this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason: reason ?? "ACP session stopped before settlement" });
6104
+ this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason: reason ?? "ACP session stopped before settlement", failureCause: "turn aborted" });
5928
6105
  this.settleSteers("needs_review", reason ?? "ACP session stopped before settlement");
5929
6106
  this.activeDeliveryId = undefined;
5930
6107
  const proc = this.proc;
@@ -5956,7 +6133,7 @@ var init_acp = __esm(() => {
5956
6133
  async deliver(envs, deliveryId) {
5957
6134
  if (this.state !== "idle" || this.stopping) {
5958
6135
  if (deliveryId)
5959
- this.delivery({ id: deliveryId, state: "failed_safe", reason: `${this.id} is ${this.state}` });
6136
+ this.delivery({ id: deliveryId, state: "failed_safe", reason: `${this.id} is ${this.state}`, failureCause: this.state === "offline" ? "peer offline" : "adapter refused" });
5960
6137
  throw new Error(`${this.id} is ${this.state}`);
5961
6138
  }
5962
6139
  let selection;
@@ -5964,14 +6141,14 @@ var init_acp = __esm(() => {
5964
6141
  selection = this.opts.getModelOverride?.();
5965
6142
  } catch {
5966
6143
  if (deliveryId)
5967
- this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP retained model selection is unavailable; inspect model status, clear the override or restart before retrying" });
6144
+ 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" });
5968
6145
  throw new Error("ACP retained model selection is unavailable; inspect model status, clear the override or restart before retrying");
5969
6146
  }
5970
6147
  const target = selection?.model ?? this.modelBaseline;
5971
6148
  if (selection && (!target || !this.acceptsModelOverride(target))) {
5972
6149
  selection.rejected?.();
5973
6150
  if (deliveryId)
5974
- this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP model is not advertised by this verified session; inspect model status and retry" });
6151
+ 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" });
5975
6152
  throw new Error("ACP model is not advertised by this verified session; inspect model status and retry");
5976
6153
  }
5977
6154
  const turn = ++this.turn;
@@ -6004,7 +6181,7 @@ var init_acp = __esm(() => {
6004
6181
  if (turn === this.turn && !this.modelTurn?.sent) {
6005
6182
  selection.rejected?.();
6006
6183
  if (deliveryId && this.activeDeliveryId === deliveryId)
6007
- this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP model change did not admit a prompt; inspect status and retry" });
6184
+ this.delivery({ id: deliveryId, state: "failed_safe", reason: "ACP model change did not admit a prompt; inspect status and retry", failureCause: "adapter refused" });
6008
6185
  this.activeDeliveryId = undefined;
6009
6186
  this.activeLegacy = undefined;
6010
6187
  this.modelTurn = undefined;
@@ -6050,9 +6227,9 @@ ${renderDigest(envs, this.primed)}` : renderDigest(envs, this.primed) }] });
6050
6227
  this.reportTurnFailure(envs, `ACP prompt ended without normal completion (${String(result?.stopReason ?? "unknown")})`);
6051
6228
  if (deliveryId && this.activeDeliveryId === deliveryId) {
6052
6229
  this.acceptDelivery();
6053
- this.delivery({ id: deliveryId, state: result?.stopReason === "end_turn" ? "completed" : "needs_review", ...result?.stopReason === "end_turn" ? {} : { reason: "ACP prompt ended without normal completion" } });
6230
+ 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" } });
6054
6231
  }
6055
- this.settleSteers(result?.stopReason === "end_turn" ? "completed" : "needs_review", "ACP prompt ended without normal completion");
6232
+ this.settleSteers(result?.stopReason === "end_turn" ? "completed" : "needs_review", "ACP prompt ended without normal completion", "turn aborted");
6056
6233
  }).catch((e) => {
6057
6234
  if (turn !== this.turn) {
6058
6235
  if (this.cancelWait?.turn === turn)
@@ -6063,7 +6240,7 @@ ${renderDigest(envs, this.primed)}` : renderDigest(envs, this.primed) }] });
6063
6240
  this.modelTurn?.selection.rejected?.();
6064
6241
  this.endActivity("failed", true);
6065
6242
  const reason = this.nativePolicy !== undefined || this.opts.requireOwnedGroup ? "Configured ACP prompt failed" : sanitize(e.message);
6066
- this.settleSteers("needs_review", reason);
6243
+ this.settleSteers("needs_review", reason, "push error");
6067
6244
  this.opts.log?.(this.nativePolicy !== undefined || this.opts.requireOwnedGroup ? "Configured ACP prompt failed; native details withheld" : `[${this.id}] prompt failed: ${reason}`);
6068
6245
  const quota = !this.stopping && this.kimiAgent ? acpQuotaRefusal(e.message) : undefined;
6069
6246
  if (quota) {
@@ -6075,7 +6252,7 @@ ${renderDigest(envs, this.primed)}` : renderDigest(envs, this.primed) }] });
6075
6252
  }
6076
6253
  const safe = paused && !this.deliveryAccepted && !this.promptActivity;
6077
6254
  if (deliveryId && this.activeDeliveryId === deliveryId)
6078
- this.delivery({ id: deliveryId, state: safe ? "failed_safe" : "needs_review", reason, ...safe ? { quota: true } : {} });
6255
+ this.delivery({ id: deliveryId, state: safe ? "failed_safe" : "needs_review", reason, failureCause: safe ? "adapter refused" : "push error", ...safe ? { quota: true } : {} });
6079
6256
  else if (!deliveryId && this.activeLegacy?.turn === turn) {
6080
6257
  this.activeLegacy = undefined;
6081
6258
  this.onFailed?.(envs, safe ? { quota: true } : undefined);
@@ -6084,7 +6261,7 @@ ${renderDigest(envs, this.primed)}` : renderDigest(envs, this.primed) }] });
6084
6261
  }
6085
6262
  this.reportTurnFailure(envs, reason);
6086
6263
  if (deliveryId && this.activeDeliveryId === deliveryId)
6087
- this.delivery({ id: deliveryId, state: "needs_review", reason });
6264
+ this.delivery({ id: deliveryId, state: "needs_review", reason, failureCause: "push error" });
6088
6265
  else if (!deliveryId && this.activeLegacy?.turn === turn) {
6089
6266
  this.activeLegacy = undefined;
6090
6267
  this.onFailed?.(envs);
@@ -6225,8 +6402,8 @@ ${renderDigest(envs, this.primed)}` : renderDigest(envs, this.primed) }] });
6225
6402
  p.reject(new Error(reason));
6226
6403
  this.pending.clear();
6227
6404
  if (this.activeDeliveryId)
6228
- this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason });
6229
- this.settleSteers("needs_review", reason);
6405
+ this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason, failureCause: "push error" });
6406
+ this.settleSteers("needs_review", reason, "push error");
6230
6407
  this.activeDeliveryId = undefined;
6231
6408
  this.setState("offline");
6232
6409
  }
@@ -9219,7 +9396,7 @@ var init_session = __esm(() => {
9219
9396
  };
9220
9397
  });
9221
9398
 
9222
- // src/hub/permission-mode.ts
9399
+ // src/hub/permission-paths.ts
9223
9400
  import { lstatSync as lstatSync12 } from "fs";
9224
9401
  function hardLinked(path) {
9225
9402
  try {
@@ -9230,10 +9407,7 @@ function hardLinked(path) {
9230
9407
  }
9231
9408
  }
9232
9409
  var PERMISSION_MODES, isPermissionMode = (value) => typeof value === "string" && PERMISSION_MODES.includes(value), PI_EDIT_TOOLS, AGENT_CONFIG_SEGMENTS, INSTRUCTION_FILES, isInstructionPath = (path) => path.split(/[\\/]/).some((segment) => INSTRUCTION_FILES.has(foldSegment(segment))), foldSegment = (segment) => segment.normalize("NFKC").replace(/\p{Default_Ignorable_Code_Point}/gu, "").toLowerCase().toUpperCase().toLowerCase(), HUB_WRITE_SEGMENTS, isHubWritePath = (path) => path.split(/[\\/]/).some((segment) => HUB_WRITE_SEGMENTS.has(foldSegment(segment))), isAgentConfigPath = (path) => path.split(/[\\/]/).some((segment) => AGENT_CONFIG_SEGMENTS.has(foldSegment(segment)));
9233
- var init_permission_mode = __esm(() => {
9234
- init_registry();
9235
- init_kimi_native();
9236
- init_qwen_native();
9410
+ var init_permission_paths = __esm(() => {
9237
9411
  PERMISSION_MODES = ["ask", "ask-when-needed", "never-ask"];
9238
9412
  PI_EDIT_TOOLS = new Set(["edit", "write"]);
9239
9413
  AGENT_CONFIG_SEGMENTS = new Set([".claude", ".codex", ".qwen", ".kimi", ".kimi-code", ".jcode", ".pi", ".mcp.json", ".agents", ".agent", "_agents", "_agent", ".gemini", ".grok", ".claude.json"]);
@@ -9241,6 +9415,15 @@ var init_permission_mode = __esm(() => {
9241
9415
  HUB_WRITE_SEGMENTS = new Set([".git", ".agenthub"]);
9242
9416
  });
9243
9417
 
9418
+ // src/hub/permission-mode.ts
9419
+ var init_permission_mode = __esm(() => {
9420
+ init_registry();
9421
+ init_permission_paths();
9422
+ init_kimi_native();
9423
+ init_qwen_native();
9424
+ init_permission_paths();
9425
+ });
9426
+
9244
9427
  // src/hub/path-policy.ts
9245
9428
  import { accessSync, constants as constants5, lstatSync as lstatSync13, opendirSync, readlinkSync, statSync as statSync3 } from "fs";
9246
9429
  import { dirname as dirname8, isAbsolute as isAbsolute5, join as join13, relative as relative3, resolve as resolve9, sep as sep3 } from "path";
@@ -9457,7 +9640,7 @@ function matchesPolicy(cwd, path, paths, includeParents = false, options = {}) {
9457
9640
  var insideRoot = (rel) => rel !== ".." && !rel.startsWith(`..${sep3}`) && !isAbsolute5(rel), within = (path, root) => path === root || path.startsWith(root.endsWith(sep3) ? root : root + sep3), beneath = (path, root) => within(path.toLowerCase(), root.toLowerCase()) || within(foldSegment(path), foldSegment(root)), lowerBeneath = (path, root) => within(path.toLowerCase(), root.toLowerCase());
9458
9641
  var init_path_policy = __esm(() => {
9459
9642
  init_project();
9460
- init_permission_mode();
9643
+ init_permission_paths();
9461
9644
  });
9462
9645
 
9463
9646
  // src/local/deny.ts
@@ -14799,7 +14982,7 @@ var package_default;
14799
14982
  var init_package = __esm(() => {
14800
14983
  package_default = {
14801
14984
  name: "@staix/agent-hub",
14802
- version: "0.49.1",
14985
+ version: "0.51.0",
14803
14986
  description: "Native multi-agent hub: Claude Code, Codex, Kimi Code, Pi and local inference as peers in one project",
14804
14987
  license: "MIT",
14805
14988
  type: "module",
@@ -15002,6 +15185,9 @@ var init_review_comments = __esm(() => {
15002
15185
  init_review_anchor();
15003
15186
  });
15004
15187
 
15188
+ // node_modules/@staix/agent-mem/src/memory/purge-intent.ts
15189
+ var init_purge_intent = () => {};
15190
+
15005
15191
  // node_modules/@staix/agent-mem/src/memory/recap-scratch.ts
15006
15192
  var RECAP_SCRATCH;
15007
15193
  var init_recap_scratch = __esm(() => {
@@ -15187,6 +15373,7 @@ var init_public_prune_input_chain = __esm(() => {
15187
15373
  // node_modules/@staix/agent-mem/src/memory/sync-placement-active.ts
15188
15374
  var pruneAdvanceMemo, shardProofs, snapshotBindings;
15189
15375
  var init_sync_placement_active = __esm(() => {
15376
+ init_purge_intent();
15190
15377
  init_profile_marker_cache();
15191
15378
  init_generation();
15192
15379
  init_platform();
@@ -15205,6 +15392,7 @@ var init_sync_placement_active = __esm(() => {
15205
15392
  // node_modules/@staix/agent-mem/src/memory/mutation.ts
15206
15393
  var mutations;
15207
15394
  var init_mutation = __esm(() => {
15395
+ init_purge_intent();
15208
15396
  init_platform();
15209
15397
  mutations = new WeakMap;
15210
15398
  });
@@ -15213,6 +15401,7 @@ var init_mutation = __esm(() => {
15213
15401
  import { closeSync as closeSync9, constants as constants8, fstatSync as fstatSync8, lstatSync as lstatSync20, openSync as openSync9, readFileSync as readFileSync8, readSync as readSync6 } from "fs";
15214
15402
  var MAX_BYTES4, SEMVER, READER_VERSION, floorMemo;
15215
15403
  var init_formats = __esm(() => {
15404
+ init_purge_intent();
15216
15405
  MAX_BYTES4 = 64 * 1024;
15217
15406
  SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/;
15218
15407
  READER_VERSION = (() => {
@@ -15466,6 +15655,7 @@ function readMarkerUncached(file) {
15466
15655
  }
15467
15656
  var doctorContext, PLACEMENT_STAGE1_REFUSAL = "sync placement v3 requires matching durable activation metadata; keep the current compatible profile active until person-authorized activation is complete", PLACEMENT_MARKER_REFUSAL = "sync placement metadata is invalid or unsupported; person inspection and a compatible reader are required before continuing", SyncPlacementRuntimeError, MarkerChanged, readMarker;
15468
15657
  var init_sync_placement_guard = __esm(() => {
15658
+ init_purge_intent();
15469
15659
  init_profile_marker_cache();
15470
15660
  init_sync_placement_active();
15471
15661
  init_sync_placement_realm_effective();
@@ -15805,6 +15995,7 @@ var init_capture_input = __esm(() => {
15805
15995
  // node_modules/@staix/agent-mem/src/memory/capture.ts
15806
15996
  var SPOOL_MAX_BYTES;
15807
15997
  var init_capture = __esm(() => {
15998
+ init_purge_intent();
15808
15999
  init_brief_cache();
15809
16000
  init_formats();
15810
16001
  init_screen();
@@ -15903,6 +16094,7 @@ var init_migrate = __esm(() => {
15903
16094
  // node_modules/@staix/agent-mem/src/memory/reader-lease.ts
15904
16095
  var open;
15905
16096
  var init_reader_lease = __esm(() => {
16097
+ init_purge_intent();
15906
16098
  init_generation();
15907
16099
  init_mutation();
15908
16100
  init_platform();
@@ -15923,10 +16115,10 @@ var init_metrics = __esm(() => {
15923
16115
  SEARCH_BYTES = 30 * 1024;
15924
16116
  PHASE_BYTES = 6 * 1024;
15925
16117
  });
15926
-
15927
16118
  // node_modules/@staix/agent-mem/src/memory/store.ts
15928
16119
  var DEFAULT_TTL_MS, UNSETTLED_MS, DEFAULT_LEASE_MS, MIGRATION_BOOTSTRAP, curatedDepth, curatedPending, curatedRecovery;
15929
16120
  var init_store = __esm(() => {
16121
+ init_purge_intent();
15930
16122
  init_recap_scratch();
15931
16123
  init_brief_curated();
15932
16124
  init_curated_cache_state();
@@ -15984,49 +16176,6 @@ var init_capacity = __esm(() => {
15984
16176
  init_capture();
15985
16177
  });
15986
16178
 
15987
- // node_modules/@staix/cli-output/src/index.ts
15988
- function terminalText(value, options = {}) {
15989
- const text = String(value ?? "").replace(/\r\n?/g, `
15990
- `).replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\|$)/g, "").replace(/\x1b[P_X^][\s\S]*?(?:\x1b\\|$)/g, "").replace(/(?:\x1b\[|\x9b)[0-?]*[ -/]*(?:[@-~]|(?=\n|$))/g, "").replace(/\x1b[^\n]?/g, "");
15991
- return options.singleLine ? text.replace(/[\x00-\x1f\x7f-\x9f]/g, " ") : text.replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "");
15992
- }
15993
- function paint(spans, color, styles = {}) {
15994
- return spans.map((span) => {
15995
- const text = terminalText(span.text);
15996
- const role = span.role && Object.hasOwn(ROLE_SGR, span.role) ? ROLE_SGR[span.role] : undefined;
15997
- const custom = span.style && Object.hasOwn(styles, span.style) ? styles[span.style] : undefined;
15998
- if (custom && !/^\x1b\[[0-9;]+m$/.test(custom))
15999
- throw new Error(`invalid SGR for style ${span.style}`);
16000
- const sgr = role !== undefined ? role : custom;
16001
- return color && sgr && text ? sgr + text + SGR_RESET : text;
16002
- }).join("");
16003
- }
16004
- var SGR_RESET = "\x1B[0m", ROLE_SGR, MARKERS, EXIT;
16005
- var init_src = __esm(() => {
16006
- ROLE_SGR = Object.freeze({
16007
- header: "\x1B[1;34m",
16008
- section: "\x1B[1;35m",
16009
- key: "\x1B[34m",
16010
- value: "",
16011
- success: "\x1B[1;32m",
16012
- warning: "\x1B[1;33m",
16013
- error: "\x1B[1;31m",
16014
- hint: "\x1B[90m",
16015
- accent: "\x1B[36m"
16016
- });
16017
- MARKERS = Object.freeze({
16018
- ok: { glyph: "\u2713", ascii: "ok", role: "success" },
16019
- fail: { glyph: "\u2717", ascii: "x", role: "error" },
16020
- warn: { glyph: "\u26A0", ascii: "!", role: "warning" },
16021
- absent: { glyph: "-", ascii: "-", role: "hint" },
16022
- unknown: { glyph: "?", ascii: "?", role: "hint" },
16023
- pending: { glyph: "~", ascii: "~", role: "hint" },
16024
- active: { glyph: "*", ascii: "*", role: "success" },
16025
- next: { glyph: "\u2192", ascii: "->", role: "accent" }
16026
- });
16027
- EXIT = Object.freeze({ ok: 0, fail: 1, usage: 2, tempfail: 75 });
16028
- });
16029
-
16030
16179
  // node_modules/@staix/agent-mem/src/memory/style.ts
16031
16180
  function style(color, ascii = true) {
16032
16181
  return {
@@ -16156,6 +16305,7 @@ var init_topic = __esm(() => {
16156
16305
  // node_modules/@staix/agent-mem/src/memory/candidates.ts
16157
16306
  var CANDIDATE_RETENTION, COUNTER_RETENTION;
16158
16307
  var init_candidates = __esm(() => {
16308
+ init_purge_intent();
16159
16309
  init_formats();
16160
16310
  init_candidate_pending();
16161
16311
  init_note_add();
@@ -16231,6 +16381,7 @@ var init_sync_binding = () => {};
16231
16381
  // node_modules/@staix/agent-mem/src/memory/sync.ts
16232
16382
  var liveGroups;
16233
16383
  var init_sync = __esm(() => {
16384
+ init_purge_intent();
16234
16385
  init_sync_placement_guard();
16235
16386
  init_formats();
16236
16387
  init_generation();
@@ -16678,6 +16829,7 @@ var init_brief_curated_native = __esm(() => {
16678
16829
 
16679
16830
  // node_modules/@staix/agent-mem/src/memory/home-binding-fence.ts
16680
16831
  var init_home_binding_fence = __esm(() => {
16832
+ init_purge_intent();
16681
16833
  init_public_prune_view();
16682
16834
  });
16683
16835
 
@@ -17362,6 +17514,18 @@ var init_sync_placement_writer_context = __esm(() => {
17362
17514
  init_sync_placement_refusal_category();
17363
17515
  });
17364
17516
 
17517
+ // node_modules/@staix/agent-mem/src/memory/read-curated-entries.ts
17518
+ var FRESHNESS_HASH_BYTES;
17519
+ var init_read_curated_entries = __esm(() => {
17520
+ init_formats();
17521
+ init_lifecycle();
17522
+ init_purge_intent();
17523
+ init_generation();
17524
+ init_shard();
17525
+ init_store();
17526
+ FRESHNESS_HASH_BYTES = 16 * 1024 * 1024;
17527
+ });
17528
+
17365
17529
  // node_modules/@staix/agent-mem/src/index.ts
17366
17530
  var init_src2 = __esm(() => {
17367
17531
  init_platform();
@@ -17387,6 +17551,7 @@ var init_src2 = __esm(() => {
17387
17551
  init_capture_input();
17388
17552
  init_record_instruction();
17389
17553
  init_skills_install();
17554
+ init_read_curated_entries();
17390
17555
  init_store();
17391
17556
  init_capture();
17392
17557
  init_shard();
@@ -19003,7 +19168,7 @@ function own3(value, key) {
19003
19168
  throw unavailable2;
19004
19169
  return descriptor?.value;
19005
19170
  }
19006
- function plain2(value) {
19171
+ function plain3(value) {
19007
19172
  return !!value && typeof value === "object" && !types6.isProxy(value) && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
19008
19173
  }
19009
19174
  function dataArray(value) {
@@ -19012,7 +19177,7 @@ function dataArray(value) {
19012
19177
  function command(argumentsText) {
19013
19178
  try {
19014
19179
  const args = JSON.parse(argumentsText);
19015
- if (!plain2(args))
19180
+ if (!plain3(args))
19016
19181
  return { explicit: true };
19017
19182
  const value = own3(args, "command");
19018
19183
  return { explicit: Object.hasOwn(args, "command"), ...typeof value === "string" ? { value } : {} };
@@ -19113,7 +19278,7 @@ function projectOutcomeWithContext(assistant, tools, prior = []) {
19113
19278
  if (!dataArray(tools) || tools.length > WIRE_BYTES2 / 20 || !dataArray(prior) || prior.length > WIRE_BYTES2 / 20)
19114
19279
  return;
19115
19280
  for (const entry of prior) {
19116
- if (!plain2(entry) || Object.keys(entry).some((key) => key !== "digest" && key !== "operation") || typeof own3(entry, "digest") !== "string" || !/^[a-f0-9]{64}$/.test(own3(entry, "digest")))
19281
+ if (!plain3(entry) || Object.keys(entry).some((key) => key !== "digest" && key !== "operation") || typeof own3(entry, "digest") !== "string" || !/^[a-f0-9]{64}$/.test(own3(entry, "digest")))
19117
19282
  return;
19118
19283
  if (Object.hasOwn(entry, "operation")) {
19119
19284
  const name = own3(entry, "operation");
@@ -21055,18 +21220,6 @@ function kimiAcpCommand(command, model) {
21055
21220
  return [cmd, ...model ? ["--model", model, ...args] : args];
21056
21221
  }
21057
21222
 
21058
- // src/cli/output-standard.ts
21059
- var TONE_SGR;
21060
- var init_output_standard = __esm(() => {
21061
- init_src();
21062
- TONE_SGR = Object.freeze({ strong: "\x1B[1;36m", failure: "\x1B[31m", number: "\x1B[1m", issueRef: "\x1B[4m", taskRef: "\x1B[4;35m" });
21063
- });
21064
-
21065
- // src/cli/warn-line.ts
21066
- var init_warn_line = __esm(() => {
21067
- init_output_standard();
21068
- });
21069
-
21070
21223
  // src/adapters/definitions/native-cli-retained.ts
21071
21224
  function retainedLaunchWarning(status, peer, definition) {
21072
21225
  const keys = definition.cli.launchConfigKeys;
@@ -21096,6 +21249,11 @@ function sessionSettings(tee, facts) {
21096
21249
  if (facts.observeNative)
21097
21250
  Object.assign(settings.hooks, { SessionStart: [{ matcher: "*", hooks }], UserPromptSubmit: [{ hooks }] });
21098
21251
  }
21252
+ if (facts?.startCheck) {
21253
+ const check = { type: "command", command: `AGENTHUB_STATE_DIR=${sh(facts.stateDir)} AGENTHUB_HOOK_PURPOSE='start-check' bun ${sh(facts.script)}`, timeout: START_HOOK_TIMEOUT_S };
21254
+ const hooks = settings.hooks ?? (settings.hooks = {});
21255
+ hooks.SessionStart = [...hooks.SessionStart ?? [], { matcher: "startup|resume", hooks: [check] }];
21256
+ }
21099
21257
  return JSON.stringify(settings);
21100
21258
  }
21101
21259
  var CLAUDE_CHANNEL = "plugin:agent-hub@agent-hub", UNATTENDED_WARNING = "WARNING: --unattended disables permission prompts. Other agents' messages are untrusted input and this agent will act on its own judgment without asking you.", sh = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
@@ -21106,6 +21264,7 @@ var init_launch2 = __esm(() => {
21106
21264
  init_project();
21107
21265
  init_child_process();
21108
21266
  init_registry();
21267
+ init_launch_check();
21109
21268
  init_warn_line();
21110
21269
  init_qwen_native();
21111
21270
  });
@@ -22072,6 +22231,214 @@ var init_hooks2 = __esm(() => {
22072
22231
  AGY_FACTS_HOOK = { decode: decodeAgyHook, encode: encodeAgyHook, read: readAgyTranscript };
22073
22232
  });
22074
22233
 
22234
+ // src/adapters/kimi-tui-facts.ts
22235
+ import { closeSync as closeSync14, constants as constants11, fstatSync as fstatSync13, lstatSync as lstatSync24, openSync as openSync14, readSync as readSync11, readdirSync as readdirSync5 } from "fs";
22236
+ import { createHash as createHash13 } from "crypto";
22237
+ import { basename as basename6, dirname as dirname15, isAbsolute as isAbsolute8, join as join24, relative as relative6 } from "path";
22238
+ import { homedir as homedir6 } from "os";
22239
+ function decodeKimiTuiHook(event, value) {
22240
+ if (!EVENTS3.includes(event) || !record7(value) || value.hook_event_name !== event || value.client_type !== "kimi_code_cli" || typeof value.session_id !== "string" || !SESSION.test(value.session_id) || typeof value.cwd !== "string" || !isAbsolute8(value.cwd) || value.cwd.length > 4096)
22241
+ return;
22242
+ if ((event === "TurnStarted" || event === "Interrupt") && !integer2(value.turn_id))
22243
+ return;
22244
+ if (event === "TaskStarted" && (typeof value.task_id !== "string" || !TASK.test(value.task_id)))
22245
+ return;
22246
+ const home = process.env.KIMI_CODE_HOME ?? join24(process.env.HOME ?? homedir6(), ".kimi-code");
22247
+ const transcriptPath = value.agentHubTranscriptPath ?? join24(home, "session_index.jsonl");
22248
+ if (typeof transcriptPath !== "string" || !isAbsolute8(transcriptPath) || transcriptPath.length > 4096)
22249
+ return;
22250
+ const phase = { TurnStarted: "start", Stop: "stop", StopFailure: "stop", Interrupt: "stop", SessionEnd: "session", TaskStarted: "pre", Notification: "post" }[event];
22251
+ return { event, phase, sessionId: value.session_id, transcriptPath, workspacePaths: [value.cwd], tool: "", input: {} };
22252
+ }
22253
+ function encodeKimiTuiHook() {
22254
+ return;
22255
+ }
22256
+ function readBytes(path, cap, tail = false) {
22257
+ const link = lstatSync24(path);
22258
+ if (!link.isFile() || link.isSymbolicLink() || link.nlink !== 1)
22259
+ throw new Error("not a regular file");
22260
+ const fd = openSync14(path, constants11.O_RDONLY | constants11.O_NOFOLLOW);
22261
+ try {
22262
+ const stat = fstatSync13(fd);
22263
+ if (!stat.isFile() || stat.nlink !== 1 || !tail && stat.size > cap)
22264
+ throw new Error("invalid file");
22265
+ const length = Math.min(stat.size, cap), start = tail ? stat.size - length : 0;
22266
+ const bytes = Buffer.alloc(length);
22267
+ let offset = 0;
22268
+ while (offset < length) {
22269
+ const count = readSync11(fd, bytes, offset, length - offset, start + offset);
22270
+ if (count <= 0)
22271
+ throw new Error("short read");
22272
+ offset += count;
22273
+ }
22274
+ return bytes;
22275
+ } finally {
22276
+ closeSync14(fd);
22277
+ }
22278
+ }
22279
+ function sessionDirectory(index, session) {
22280
+ const home = dirname15(index), sessions = realPath(join24(home, "sessions"));
22281
+ let listed;
22282
+ for (const line of readBytes(index, INDEX_CAP2).toString("utf8").split(`
22283
+ `)) {
22284
+ if (!line.includes(session))
22285
+ continue;
22286
+ let row;
22287
+ try {
22288
+ row = JSON.parse(line);
22289
+ } catch {
22290
+ continue;
22291
+ }
22292
+ if (record7(row) && row.sessionId === session && typeof row.sessionDir === "string") {
22293
+ if (listed)
22294
+ throw new Error("duplicate session");
22295
+ listed = row.sessionDir;
22296
+ }
22297
+ }
22298
+ if (!listed)
22299
+ throw new Error("session not indexed");
22300
+ const directory = realPath(listed);
22301
+ if (!inside3(sessions, directory))
22302
+ throw new Error("session outside home");
22303
+ return directory;
22304
+ }
22305
+ function taskInventory(agents) {
22306
+ let active = 0;
22307
+ const names = readdirSync5(agents, { withFileTypes: true });
22308
+ if (names.length > MAX_AGENTS2)
22309
+ throw new Error("too many agents");
22310
+ for (const entry of names) {
22311
+ if (!AGENT.test(entry.name))
22312
+ continue;
22313
+ if (!entry.isDirectory())
22314
+ continue;
22315
+ const tasks = join24(agents, entry.name, "tasks");
22316
+ const dir = lstatSync24(tasks, { throwIfNoEntry: false });
22317
+ if (!dir)
22318
+ continue;
22319
+ if (!dir.isDirectory() || dir.isSymbolicLink())
22320
+ throw new Error("invalid task directory");
22321
+ const files = readdirSync5(tasks).filter((name) => name.endsWith(".json")).sort();
22322
+ if (files.length > MAX_TASKS)
22323
+ throw new Error("too many tasks");
22324
+ for (const name of files) {
22325
+ if (!TASK.test(name.slice(0, -5)))
22326
+ throw new Error("invalid task name");
22327
+ const row = JSON.parse(readBytes(join24(tasks, name), TASK_CAP).toString("utf8"));
22328
+ if (!record7(row) || row.taskId !== name.slice(0, -5) || typeof row.status !== "string")
22329
+ throw new Error("invalid task");
22330
+ if (row.status === "running" && row.endedAt === null) {
22331
+ active++;
22332
+ continue;
22333
+ }
22334
+ const terminal = ["completed", "failed", "cancelled"].includes(row.status) && integer2(row.endedAt);
22335
+ if (!terminal)
22336
+ throw new Error("unknown task state");
22337
+ }
22338
+ }
22339
+ return active;
22340
+ }
22341
+ function readKimiTuiTranscript(session, index) {
22342
+ if (!SESSION.test(session) || basename6(index) !== "session_index.jsonl" || !isAbsolute8(index))
22343
+ return empty();
22344
+ try {
22345
+ const directory = sessionDirectory(index, session);
22346
+ const wire = join24(directory, "agents", "main", "wire.jsonl");
22347
+ if (!inside3(directory, realPath(wire)))
22348
+ return empty();
22349
+ const bytes = readBytes(wire, WIRE_CAP, true);
22350
+ if (bytes.length === 0 || bytes[bytes.length - 1] !== 10)
22351
+ return empty();
22352
+ const lines = bytes.toString("utf8").split(`
22353
+ `);
22354
+ if (bytes.length === WIRE_CAP && !lines[0]?.startsWith('{"type":"metadata"'))
22355
+ lines.shift();
22356
+ const prompts = new Map;
22357
+ const ends = new Map;
22358
+ const promptEnds = new Map;
22359
+ const promptEndTurnIds = new Map;
22360
+ let started;
22361
+ for (const line of lines) {
22362
+ if (!line || !/"(?:turn\.prompt|turn\.ended|prompt\.completed|prompt\.aborted)"/.test(line))
22363
+ continue;
22364
+ let row;
22365
+ try {
22366
+ row = JSON.parse(line);
22367
+ } catch {
22368
+ return empty();
22369
+ }
22370
+ if (!record7(row))
22371
+ return empty();
22372
+ if (row.type === "turn.prompt" && integer2(row.turnId) && record7(row.origin) && typeof row.origin.kind === "string") {
22373
+ const turn = row.turnId, id = typeof row.promptId === "string" ? row.promptId : typeof row.origin.notificationId === "string" ? row.origin.notificationId : `turn-${turn}`;
22374
+ const prompt = { turn, id, origin: row.origin.kind };
22375
+ prompts.set(turn, prompt);
22376
+ started = prompt;
22377
+ } else if (row.type === "turn.ended" && integer2(row.turnId) && ["completed", "failed", "cancelled"].includes(String(row.reason))) {
22378
+ const turn = row.turnId;
22379
+ ends.set(turn, { turn, reason: row.reason });
22380
+ } else if (row.type === "prompt.completed" && typeof row.promptId === "string" && ["completed", "failed"].includes(String(row.reason))) {
22381
+ promptEnds.set(row.promptId, row.reason);
22382
+ if (integer2(row.turnId))
22383
+ promptEndTurnIds.set(row.turnId, row.promptId);
22384
+ } else if (row.type === "prompt.aborted" && typeof row.promptId === "string") {
22385
+ promptEnds.set(row.promptId, "cancelled");
22386
+ if (integer2(row.turnId))
22387
+ promptEndTurnIds.set(row.turnId, row.promptId);
22388
+ } else if (row.type === "turn.prompt" || row.type === "turn.ended")
22389
+ return empty();
22390
+ }
22391
+ let completion;
22392
+ for (const [turn, end] of ends) {
22393
+ const prompt = prompts.get(turn), promptReason = prompt ? promptEnds.get(prompt.id) : undefined, turnPromptId = promptEndTurnIds.get(turn);
22394
+ if (!prompt || promptReason !== undefined && promptReason !== end.reason || turnPromptId !== undefined && turnPromptId !== prompt.id)
22395
+ continue;
22396
+ completion = { id: createHash13("sha256").update(`${session}:${turn}:${prompt.id}:${end.reason}`).digest("hex"), index: turn, reason: end.reason };
22397
+ }
22398
+ let background;
22399
+ try {
22400
+ background = taskInventory(join24(directory, "agents"));
22401
+ } catch {}
22402
+ return {
22403
+ factIds: [],
22404
+ ...completion ? { completion } : {},
22405
+ ...started ? { started: { id: createHash13("sha256").update(`${session}:${started.turn}:${started.id}`).digest("hex"), index: started.turn, origin: started.origin } } : {},
22406
+ ...background === undefined ? {} : { background }
22407
+ };
22408
+ } catch {
22409
+ return empty();
22410
+ }
22411
+ }
22412
+ var EVENTS3, SESSION, AGENT, TASK, INDEX_CAP2, WIRE_CAP, TASK_CAP, MAX_AGENTS2 = 256, MAX_TASKS = 256, record7 = (value) => !!value && typeof value === "object" && !Array.isArray(value), integer2 = (value) => Number.isSafeInteger(value) && value >= 0, inside3 = (root, path) => {
22413
+ const rel = relative6(root, path);
22414
+ return rel !== "" && rel !== ".." && !rel.startsWith("../") && !isAbsolute8(rel);
22415
+ }, empty = () => ({ factIds: [] }), KIMI_TUI_FACTS_HOOK;
22416
+ var init_kimi_tui_facts = __esm(() => {
22417
+ init_project();
22418
+ EVENTS3 = ["TurnStarted", "Stop", "StopFailure", "Interrupt", "SessionEnd", "TaskStarted", "Notification"];
22419
+ SESSION = /^session_[A-Za-z0-9_-]{1,120}$/;
22420
+ AGENT = /^[A-Za-z0-9._-]{1,64}$/;
22421
+ TASK = /^[A-Za-z0-9._:-]{1,128}$/;
22422
+ INDEX_CAP2 = 16 * 1024 * 1024;
22423
+ WIRE_CAP = 8 * 1024 * 1024;
22424
+ TASK_CAP = 64 * 1024;
22425
+ KIMI_TUI_FACTS_HOOK = { decode: decodeKimiTuiHook, encode: encodeKimiTuiHook, read: readKimiTuiTranscript };
22426
+ });
22427
+
22428
+ // src/adapters/native-facts-hooks.ts
22429
+ function nativeFactsHook(peer) {
22430
+ return Object.hasOwn(NATIVE_FACTS_HOOKS, peer) ? NATIVE_FACTS_HOOKS[peer] : undefined;
22431
+ }
22432
+ var NATIVE_FACTS_HOOKS;
22433
+ var init_native_facts_hooks = __esm(() => {
22434
+ init_hooks2();
22435
+ init_kimi_tui_facts();
22436
+ NATIVE_FACTS_HOOKS = Object.freeze({
22437
+ agy: AGY_FACTS_HOOK,
22438
+ kimi: KIMI_TUI_FACTS_HOOK
22439
+ });
22440
+ });
22441
+
22075
22442
  // src/adapters/agy/definition.ts
22076
22443
  function agyLaunch(ctx) {
22077
22444
  const argv = ["agy", ...ctx.userArgs], command = argv.map(shellQuote2).join(" ");
@@ -22082,7 +22449,7 @@ var DISPLAY, shellQuote2 = (value) => `'${value.replace(/'/g, `'\\''`)}'`, AGY_D
22082
22449
  var init_definition = __esm(() => {
22083
22450
  init_entry();
22084
22451
  init_reviewer_variants();
22085
- init_hooks2();
22452
+ init_native_facts_hooks();
22086
22453
  DISPLAY = { palette: { fg: "#6558a6", bg: "#f1effa" } };
22087
22454
  AGY_DEFINITION = {
22088
22455
  api: 1,
@@ -22131,7 +22498,7 @@ var init_definition = __esm(() => {
22131
22498
  routing: { allowedRoles: ["implementer", "verifier"] },
22132
22499
  reviewer: { defaultPool: false, declaration: "automatic", unavailable: "agy is an implementer peer (#485)" },
22133
22500
  reviewerVariant: AGY_REVIEWER_VARIANT,
22134
- hooks: { factsHook: AGY_FACTS_HOOK }
22501
+ hooks: { factsHook: NATIVE_FACTS_HOOKS.agy }
22135
22502
  };
22136
22503
  });
22137
22504
 
@@ -22139,9 +22506,71 @@ var init_definition = __esm(() => {
22139
22506
  function builtinCliEntries(definitions) {
22140
22507
  return Object.freeze(definitions.flatMap((definition) => definition.cli.entry ? [Object.freeze({ ...definition.cli.entry, command: definition.cli.command })] : []));
22141
22508
  }
22509
+ // src/adapters/claude-channel-evidence.ts
22510
+ import { spawnSync as spawnSync4 } from "child_process";
22511
+ function classifyClaudeParentCommand(command, rejectedArgument) {
22512
+ if (!command || command.length > 4096 || /[\n\r\0]/.test(command))
22513
+ return "launch-unverified";
22514
+ const argv = command.trim().split(/\s+/);
22515
+ const executable = argv[0]?.split("/").at(-1);
22516
+ const reject = (position) => {
22517
+ rejectedArgument?.(position);
22518
+ return "launch-unverified";
22519
+ };
22520
+ if (executable !== "claude")
22521
+ return reject(0);
22522
+ if (argv[1] !== "--dangerously-load-development-channels")
22523
+ return reject(1);
22524
+ if (argv.length < 3 || !TARGETS.has(argv[2]))
22525
+ return reject(2);
22526
+ 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="));
22527
+ if (rejected >= 0)
22528
+ return reject(rejected + 3);
22529
+ return "development-channel-launch";
22530
+ }
22531
+ function readClaudeParentCommand(ppid) {
22532
+ try {
22533
+ const result = spawnSync4("/bin/ps", ["-ww", "-p", String(ppid), "-o", "command="], {
22534
+ encoding: "utf8",
22535
+ timeout: 1500,
22536
+ maxBuffer: 4096,
22537
+ env: { PATH: "/usr/bin:/bin", LC_ALL: "C" }
22538
+ });
22539
+ if (result.error || result.status !== 0 || typeof result.stdout !== "string" || !result.stdout.trim() || result.stdout.trim().includes(`
22540
+ `))
22541
+ return;
22542
+ return result.stdout.trim();
22543
+ } catch {
22544
+ return;
22545
+ }
22546
+ }
22547
+ function claudeChannelEvidence(env = process.env, ppid = process.ppid, read = claudeParentCommandPort.read) {
22548
+ if (env.AGENTHUB_CHANNEL !== "1")
22549
+ return "unknown";
22550
+ if (!Number.isSafeInteger(ppid) || ppid <= 1)
22551
+ return "unknown";
22552
+ try {
22553
+ const command = read(ppid);
22554
+ if (!command || process.ppid !== ppid)
22555
+ return "unknown";
22556
+ return classifyClaudeParentCommand(command);
22557
+ } catch {
22558
+ return "unknown";
22559
+ }
22560
+ }
22561
+ function currentClaudeChannelEvidence() {
22562
+ return claudeChannelEvidence();
22563
+ }
22564
+ var claudeParentCommandPort, TARGETS, DISABLING;
22565
+ var init_claude_channel_evidence = __esm(() => {
22566
+ claudeParentCommandPort = { read: readClaudeParentCommand };
22567
+ TARGETS = new Set(["plugin:agent-hub@agent-hub", "server:agent-hub"]);
22568
+ DISABLING = new Set(["-p", "--print", "--output-format", "--background", "--detach", "--daemon", "daemon", "bg", "bg-spare"]);
22569
+ });
22570
+
22142
22571
  // src/adapters/definitions/native-cli-entry-claude.ts
22143
22572
  import { readFileSync as readFileSync11 } from "fs";
22144
- import { join as join24 } from "path";
22573
+ import { join as join25 } from "path";
22145
22574
  import { randomUUID as randomUUID10 } from "crypto";
22146
22575
  function managedSession(nativeArgs) {
22147
22576
  const separator = nativeArgs.indexOf("--");
@@ -22161,7 +22590,7 @@ function managedSession(nativeArgs) {
22161
22590
  if (resume.length)
22162
22591
  return resume.length === 1 && isClaudeSessionUuid(resume[0]) ? resume[0] : undefined;
22163
22592
  const id = randomUUID10();
22164
- nativeArgs.unshift("--session-id", id);
22593
+ nativeArgs.splice(options.length, 0, "--session-id", id);
22165
22594
  return id;
22166
22595
  }
22167
22596
  async function runClaudeEntry(ctx) {
@@ -22213,17 +22642,19 @@ async function runClaudeEntry(ctx) {
22213
22642
  }
22214
22643
  }
22215
22644
  let original;
22216
- for (const file of [join24(executionCwd, ".claude", "settings.local.json"), join24(executionCwd, ".claude", "settings.json"), join24(process.env.HOME ?? "", ".claude", "settings.json")]) {
22645
+ for (const file of [join25(executionCwd, ".claude", "settings.local.json"), join25(executionCwd, ".claude", "settings.json"), join25(process.env.HOME ?? "", ".claude", "settings.json")]) {
22217
22646
  try {
22218
22647
  original ??= JSON.parse(readFileSync11(file, "utf8")).statusLine;
22219
22648
  } catch {}
22220
22649
  }
22221
- const facts = claudeObservationHooks(projectConfig(), { script: join24(cliDir, "facts-hook.ts"), stateDir });
22650
+ const facts = claudeObservationHooks(projectConfig(), { script: join25(cliDir, "facts-hook.ts"), stateDir });
22651
+ if (facts)
22652
+ facts.startCheck = true;
22222
22653
  let previousLaunch;
22223
22654
  try {
22224
- previousLaunch = JSON.parse(readFileSync11(join24(stateDir, claudeStateFile("claude-launch", peer)), "utf8"));
22655
+ previousLaunch = JSON.parse(readFileSync11(join25(stateDir, claudeStateFile("claude-launch", peer)), "utf8"));
22225
22656
  } catch {}
22226
- const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script: join24(cliDir, "statusline-tee.ts"), stateDir, ...original ? { original } : {} }, ...facts ? { facts } : {} });
22657
+ const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script: join25(cliDir, "statusline-tee.ts"), stateDir, ...original ? { original } : {} }, ...facts ? { facts } : {} });
22227
22658
  let result;
22228
22659
  try {
22229
22660
  let launchRecord;
@@ -22235,12 +22666,25 @@ async function runClaudeEntry(ctx) {
22235
22666
  recordClaudeLaunch(stateDir, launchRecord);
22236
22667
  cleanupStaleClaudeSettings(stateDir, previousLaunch);
22237
22668
  }
22669
+ let rejectedPosition;
22670
+ const evidence = classifyClaudeParentCommand([launch.cmd, ...launch.args].join(" "), (position) => {
22671
+ rejectedPosition = position;
22672
+ });
22673
+ if (evidence !== "development-channel-launch") {
22674
+ const cause = rejectedPosition === undefined ? "command length or control characters" : `argv[${rejectedPosition}]`;
22675
+ console.error(`Hub check failed for Claude channel (${evidence} at ${cause}). ${claudeArgvNextStep([launch.cmd, ...launch.args].join(" "), rejectedPosition)}`);
22676
+ }
22238
22677
  if (launch.warning)
22239
22678
  console.error(launch.warning);
22679
+ const beforeSpawn = async () => {
22680
+ if (process.stderr.isTTY !== true)
22681
+ return;
22682
+ printLaunchCheck({ hubCheck: await readLaunchCheck((timeoutMs) => ctx.connectOnce(timeoutMs)) }, peer, ctx.definition, "tui");
22683
+ };
22240
22684
  const env = nativeLaunchEnv("claude", childEnv());
22241
22685
  if (ctx.instance)
22242
22686
  env.AGENTHUB_PEER_ID = peer;
22243
- result = await runClaudeLaunch(launch, { cwd: executionCwd, stateDir, env: { ...env, AGENTHUB_STATE_DIR: stateDir, AGENTHUB_PROJECT_DIR: cwd }, ...launchRecord ? { record: launchRecord } : {} });
22687
+ result = await runClaudeLaunch(launch, { cwd: executionCwd, stateDir, env: { ...env, AGENTHUB_STATE_DIR: stateDir, AGENTHUB_PROJECT_DIR: cwd }, ...launchRecord ? { record: launchRecord } : {}, beforeSpawn });
22244
22688
  } finally {
22245
22689
  cleanupClaudeSettings(stateDir, launch.settingsFile);
22246
22690
  }
@@ -22249,7 +22693,9 @@ async function runClaudeEntry(ctx) {
22249
22693
  process.exit(result.status ?? 1);
22250
22694
  }
22251
22695
  var init_native_cli_entry_claude = __esm(() => {
22696
+ init_claude_channel_evidence();
22252
22697
  init_claude_state();
22698
+ init_launch_check();
22253
22699
  });
22254
22700
 
22255
22701
  // src/adapters/definitions/native-cli-entry-codex.ts
@@ -22287,6 +22733,7 @@ async function runCodexEntry(ctx) {
22287
22733
  const warning = retainedLaunchWarning(snapshot, peer, ctx.definition);
22288
22734
  if (warning)
22289
22735
  console.error(warning);
22736
+ printLaunchCheck(snapshot, peer, ctx.definition, "tui");
22290
22737
  const res = await hub.request({ t: "start", peer, args: { unattended: launch0.unattended === true }, operationId: process.env.AGENTHUB_RECOVERY_OPERATION });
22291
22738
  if (!res.ok) {
22292
22739
  hub.close();
@@ -22316,14 +22763,16 @@ async function runCodexEntry(ctx) {
22316
22763
  console.error(launch0.warning);
22317
22764
  exec(launch.cmd, launch.args, "codex");
22318
22765
  }
22319
- var init_native_cli_entry_codex = () => {};
22766
+ var init_native_cli_entry_codex = __esm(() => {
22767
+ init_launch_check();
22768
+ });
22320
22769
 
22321
22770
  // src/cli/kimi-plugin.ts
22322
22771
  import { randomUUID as randomUUID11 } from "crypto";
22323
- import { closeSync as closeSync14, lstatSync as lstatSync24, mkdirSync as mkdirSync12, openSync as openSync14, readFileSync as readFileSync12, renameSync as renameSync6, rmdirSync as rmdirSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync10 } from "fs";
22324
- import { dirname as dirname15, isAbsolute as isAbsolute8, join as join25 } from "path";
22772
+ import { closeSync as closeSync15, lstatSync as lstatSync25, mkdirSync as mkdirSync12, openSync as openSync15, readFileSync as readFileSync12, renameSync as renameSync6, rmdirSync as rmdirSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync10 } from "fs";
22773
+ import { dirname as dirname16, isAbsolute as isAbsolute9, join as join26 } from "path";
22325
22774
  function file(path, cap) {
22326
- const stat = lstatSync24(path, { throwIfNoEntry: false });
22775
+ const stat = lstatSync25(path, { throwIfNoEntry: false });
22327
22776
  if (!stat)
22328
22777
  return;
22329
22778
  if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1 || stat.size > cap)
@@ -22343,33 +22792,33 @@ function parse2(value, name) {
22343
22792
  }
22344
22793
  }
22345
22794
  function atomic(path, bytes, before) {
22346
- const current = lstatSync24(path, { throwIfNoEntry: false });
22795
+ const current = lstatSync25(path, { throwIfNoEntry: false });
22347
22796
  if (before ? !current || current.dev !== before.dev || current.ino !== before.ino : current)
22348
22797
  throw new Error(`${path} changed before its managed write`);
22349
22798
  const temporary = `${path}.${randomUUID11()}.tmp`;
22350
22799
  let fd;
22351
22800
  try {
22352
- fd = openSync14(temporary, "wx", 384);
22801
+ fd = openSync15(temporary, "wx", 384);
22353
22802
  writeFileSync10(fd, bytes);
22354
- closeSync14(fd);
22803
+ closeSync15(fd);
22355
22804
  fd = undefined;
22356
22805
  renameSync6(temporary, path);
22357
22806
  } finally {
22358
22807
  if (fd !== undefined)
22359
- closeSync14(fd);
22808
+ closeSync15(fd);
22360
22809
  try {
22361
22810
  unlinkSync4(temporary);
22362
22811
  } catch {}
22363
22812
  }
22364
22813
  }
22365
22814
  function removeFile(path, expected) {
22366
- const current = lstatSync24(path, { throwIfNoEntry: false });
22815
+ const current = lstatSync25(path, { throwIfNoEntry: false });
22367
22816
  if (!current || !current.isFile() || current.isSymbolicLink() || current.nlink !== 1 || !readFileSync12(path).equals(expected))
22368
22817
  return;
22369
22818
  unlinkSync4(path);
22370
22819
  }
22371
22820
  function manifest() {
22372
- return { name: ID2, version: "1.0.0", description: "Managed by the ahub kimi launcher for this launch only.", hooks: EVENTS3.map((event) => ({ event, command: `bun ./kimi-hook.js ${event}`, timeout: 5 })) };
22821
+ return { name: ID2, version: "1.0.0", description: "Managed by the ahub kimi launcher for this launch only.", hooks: EVENTS4.map((event) => ({ event, command: `bun ./kimi-hook.js ${event}`, timeout: 5 })) };
22373
22822
  }
22374
22823
  function ownerProof(options) {
22375
22824
  const pid = options.ownerPid ?? process.pid, signature = options.ownerSignature ?? processSignature(pid);
@@ -22388,13 +22837,13 @@ function staleOwner(record, options) {
22388
22837
  }
22389
22838
  }
22390
22839
  function plan2(options) {
22391
- if (!isAbsolute8(options.home) || !isAbsolute8(options.hookScript) || !/^[A-Za-z0-9._:-]{1,128}$/.test(options.launchId))
22840
+ if (!isAbsolute9(options.home) || !isAbsolute9(options.hookScript) || !/^[A-Za-z0-9._:-]{1,128}$/.test(options.launchId))
22392
22841
  throw new Error("Kimi home, hook bundle and launch identity must be valid");
22393
22842
  directory(options.home);
22394
22843
  const hook = file(options.hookScript, MAX_HOOK);
22395
22844
  if (!hook)
22396
22845
  throw new Error("Kimi hook bundle is missing");
22397
- const root = join25(options.home, "plugins"), managed = join25(root, "managed", ID2), installed = join25(root, "installed.json");
22846
+ const root = join26(options.home, "plugins"), managed = join26(root, "managed", ID2), installed = join26(root, "installed.json");
22398
22847
  const installedBefore = file(installed, MAX_INSTALLED), document = parse2(installedBefore, installed);
22399
22848
  if (document && (document.version !== 1 || !Array.isArray(document.plugins)))
22400
22849
  throw new Error(`${installed} has an unsupported shape`);
@@ -22407,11 +22856,11 @@ function plan2(options) {
22407
22856
  if (record && (record.root !== managed || record.source !== "local-path" || record.origin !== "custom" || record.enabled !== true || typeof record.originalSource !== "string" || record.agentHubLaunch !== options.launchId && options.replaceStale !== true)) {
22408
22857
  throw new Error("Kimi's agent-hub plugin belongs to another launch or is disabled; it was not changed");
22409
22858
  }
22410
- const manifestBefore = file(join25(managed, "kimi.plugin.json"), MAX_INSTALLED), hookBefore = file(join25(managed, "kimi-hook.js"), MAX_HOOK);
22859
+ const manifestBefore = file(join26(managed, "kimi.plugin.json"), MAX_INSTALLED), hookBefore = file(join26(managed, "kimi-hook.js"), MAX_HOOK);
22411
22860
  const nextManifest = Buffer.from(`${JSON.stringify(manifest(), null, 2)}
22412
22861
  `);
22413
22862
  const now = new Date(options.now ?? Date.now()).toISOString();
22414
- const changed = !record || record.agentHubLaunch !== options.launchId || !record.agentHubOwner || !manifestBefore?.bytes.equals(nextManifest) || !hookBefore?.bytes.equals(hook.bytes) || record.originalSource !== dirname15(options.hookScript);
22863
+ const changed = !record || record.agentHubLaunch !== options.launchId || !record.agentHubOwner || !manifestBefore?.bytes.equals(nextManifest) || !hookBefore?.bytes.equals(hook.bytes) || record.originalSource !== dirname16(options.hookScript);
22415
22864
  const nextRecord = {
22416
22865
  id: ID2,
22417
22866
  root: managed,
@@ -22420,7 +22869,7 @@ function plan2(options) {
22420
22869
  enabled: true,
22421
22870
  installedAt: typeof record?.installedAt === "string" ? record.installedAt : now,
22422
22871
  updatedAt: changed ? now : typeof record?.updatedAt === "string" ? record.updatedAt : now,
22423
- originalSource: dirname15(options.hookScript),
22872
+ originalSource: dirname16(options.hookScript),
22424
22873
  agentHubLaunch: options.launchId,
22425
22874
  agentHubOwner: record && record.agentHubLaunch === options.launchId && record.agentHubOwner ? record.agentHubOwner : ownerProof(options)
22426
22875
  };
@@ -22432,36 +22881,36 @@ function plan2(options) {
22432
22881
  ...record ? { record } : {},
22433
22882
  changed,
22434
22883
  targets: [
22435
- { path: join25(managed, "kimi.plugin.json"), next: nextManifest, ...manifestBefore ? { before: manifestBefore } : {} },
22436
- { path: join25(managed, "kimi-hook.js"), next: hook.bytes, ...hookBefore ? { before: hookBefore } : {} },
22884
+ { path: join26(managed, "kimi.plugin.json"), next: nextManifest, ...manifestBefore ? { before: manifestBefore } : {} },
22885
+ { path: join26(managed, "kimi-hook.js"), next: hook.bytes, ...hookBefore ? { before: hookBefore } : {} },
22437
22886
  { path: installed, next: Buffer.from(`${JSON.stringify(nextDocument, null, 2)}
22438
22887
  `), ...installedBefore ? { before: installedBefore } : {} }
22439
22888
  ]
22440
22889
  };
22441
22890
  }
22442
22891
  function kimiPluginPreview(home, hookScript) {
22443
- if (!isAbsolute8(home) || !isAbsolute8(hookScript))
22892
+ if (!isAbsolute9(home) || !isAbsolute9(hookScript))
22444
22893
  throw new Error("Kimi home and hook bundle must be absolute paths");
22445
22894
  directory(home, false);
22446
22895
  if (!file(hookScript, MAX_HOOK))
22447
22896
  throw new Error("Kimi hook bundle is missing");
22448
- return { file: join25(home, "plugins", "managed", ID2), changed: true, action: "only after Kimi 2.5.2 is confirmed, install the launch-scoped completion plugin and remove it on exit; other versions keep the existing TUI with no plugin" };
22897
+ return { file: join26(home, "plugins", "managed", ID2), changed: true, action: "only after Kimi 2.5.2 is confirmed, install the launch-scoped completion plugin and remove it on exit; other versions keep the existing TUI with no plugin" };
22449
22898
  }
22450
22899
  function locked(options, run) {
22451
- if (!isAbsolute8(options.home))
22900
+ if (!isAbsolute9(options.home))
22452
22901
  throw new Error("Kimi home must be an absolute path");
22453
22902
  directory(options.home);
22454
- const path = join25(options.home, "agent-hub-plugin.lock");
22903
+ const path = join26(options.home, "agent-hub-plugin.lock");
22455
22904
  let fd;
22456
22905
  try {
22457
- fd = openSync14(path, "wx", 384);
22906
+ fd = openSync15(path, "wx", 384);
22458
22907
  } catch {
22459
22908
  throw new Error(`Another Kimi plugin replacement is active or left a stale lock; retry after it exits or inspect ${path}`);
22460
22909
  }
22461
22910
  try {
22462
22911
  return run();
22463
22912
  } finally {
22464
- closeSync14(fd);
22913
+ closeSync15(fd);
22465
22914
  unlinkSync4(path);
22466
22915
  }
22467
22916
  }
@@ -22470,7 +22919,7 @@ function ensureKimiPlugin(options) {
22470
22919
  const current = plan2(options);
22471
22920
  if (!current.changed)
22472
22921
  return { changed: false };
22473
- for (const path of [join25(options.home, "plugins"), join25(options.home, "plugins", "managed"), current.managed]) {
22922
+ for (const path of [join26(options.home, "plugins"), join26(options.home, "plugins", "managed"), current.managed]) {
22474
22923
  if (!directory(path, false))
22475
22924
  mkdirSync12(path, { mode: 448 });
22476
22925
  }
@@ -22495,15 +22944,15 @@ function cleanupKimiPlugin(options) {
22495
22944
  atomic(current.installed, Buffer.from(`${JSON.stringify(next, null, 2)}
22496
22945
  `), installedBefore?.stat);
22497
22946
  const [manifestTarget, hookTarget] = current.targets;
22498
- removeFile(join25(current.managed, "kimi.plugin.json"), manifestTarget.next);
22499
- removeFile(join25(current.managed, "kimi-hook.js"), hookTarget.next);
22947
+ removeFile(join26(current.managed, "kimi.plugin.json"), manifestTarget.next);
22948
+ removeFile(join26(current.managed, "kimi-hook.js"), hookTarget.next);
22500
22949
  try {
22501
22950
  rmdirSync4(current.managed);
22502
22951
  } catch {}
22503
22952
  });
22504
22953
  }
22505
- var EVENTS3, ID2 = "agent-hub", MAX_INSTALLED, MAX_HOOK, object8 = (value) => !!value && typeof value === "object" && !Array.isArray(value), directory = (path, required = true) => {
22506
- const stat = lstatSync24(path, { throwIfNoEntry: false });
22954
+ var EVENTS4, ID2 = "agent-hub", MAX_INSTALLED, MAX_HOOK, object8 = (value) => !!value && typeof value === "object" && !Array.isArray(value), directory = (path, required = true) => {
22955
+ const stat = lstatSync25(path, { throwIfNoEntry: false });
22507
22956
  if (stat && (!stat.isDirectory() || stat.isSymbolicLink()))
22508
22957
  throw new Error(`${path} must be a plain directory`);
22509
22958
  if (!stat && required)
@@ -22512,15 +22961,15 @@ var EVENTS3, ID2 = "agent-hub", MAX_INSTALLED, MAX_HOOK, object8 = (value) => !!
22512
22961
  };
22513
22962
  var init_kimi_plugin = __esm(() => {
22514
22963
  init_process_signature();
22515
- EVENTS3 = ["TurnStarted", "Stop", "StopFailure", "Interrupt", "SessionEnd", "TaskStarted", "Notification"];
22964
+ EVENTS4 = ["TurnStarted", "Stop", "StopFailure", "Interrupt", "SessionEnd", "TaskStarted", "Notification"];
22516
22965
  MAX_INSTALLED = 1024 * 1024;
22517
22966
  MAX_HOOK = 8 * 1024 * 1024;
22518
22967
  });
22519
22968
 
22520
22969
  // src/adapters/definitions/native-cli-entry-kimi.ts
22521
- import { join as join26, resolve as resolve14 } from "path";
22522
- import { homedir as homedir6 } from "os";
22523
- import { spawn as spawn10, spawnSync as spawnSync4 } from "child_process";
22970
+ import { join as join27, resolve as resolve14 } from "path";
22971
+ import { homedir as homedir7 } from "os";
22972
+ import { spawn as spawn10, spawnSync as spawnSync5 } from "child_process";
22524
22973
  import { mkdirSync as mkdirSync13 } from "fs";
22525
22974
  function kimiTuiVersionGate(stdout) {
22526
22975
  const verdict = assessVersion("kimi-tui", COMPAT["kimi-tui"].parse(stdout));
@@ -22610,6 +23059,7 @@ async function runKimiEntry(ctx) {
22610
23059
  const warning = retainedLaunchWarning(snapshot, peer, ctx.definition);
22611
23060
  if (warning)
22612
23061
  console.error(warning);
23062
+ printLaunchCheck(snapshot, peer, ctx.definition, "tui");
22613
23063
  const owner = snapshot?.peers?.[peer];
22614
23064
  if (owner && !["offline"].includes(owner.state) && !owner.pullOnly)
22615
23065
  fail("Kimi is running headless; run ahub stop kimi before starting its TUI");
@@ -22628,7 +23078,7 @@ async function runKimiEntry(ctx) {
22628
23078
  throw running ? new Error(`${error.message} (the command is the running hub's kimi_cmd: the value in the config file is retained until ahub settings reload)`) : error;
22629
23079
  }
22630
23080
  const probe = kimiTuiVersionProbe(buildKimiTuiLaunch(command));
22631
- const version = spawnSync4(probe.cmd, probe.args, { encoding: "utf8", timeout: 5000, maxBuffer: 4096, env: nativeLaunchEnv("kimi", childEnv()) });
23081
+ const version = spawnSync5(probe.cmd, probe.args, { encoding: "utf8", timeout: 5000, maxBuffer: 4096, env: nativeLaunchEnv("kimi", childEnv()) });
22632
23082
  const gate = kimiTuiVersionGate(version.status === 0 ? version.stdout : "");
22633
23083
  if (version.status === 0 && version.stdout.trim() && gate.message)
22634
23084
  console.error(`${gate.message}. Completion receipts are off; the TUI launches as before.`);
@@ -22640,7 +23090,7 @@ async function runKimiEntry(ctx) {
22640
23090
  if (!gate.ok) {
22641
23091
  result = await runKimiTui(launch.cmd, launch.args, cwd, nativeEnv);
22642
23092
  } else {
22643
- const nativeHome = nativeEnv.KIMI_CODE_HOME ?? join26(nativeEnv.HOME ?? homedir6(), ".kimi-code");
23093
+ const nativeHome = nativeEnv.KIMI_CODE_HOME ?? join27(nativeEnv.HOME ?? homedir7(), ".kimi-code");
22644
23094
  let nativeLaunchId, completionEnv, plugin;
22645
23095
  try {
22646
23096
  mkdirSync13(nativeHome, { recursive: true, mode: 448 });
@@ -22649,7 +23099,7 @@ async function runKimiEntry(ctx) {
22649
23099
  throw new Error(native.error ?? "native hook launch was not admitted");
22650
23100
  nativeLaunchId = native.launchId;
22651
23101
  plugin = { home: nativeHome, hookScript: resolve14(serverBundle, "../kimi-hook.js"), launchId: native.launchId, replaceStale: true };
22652
- console.error(`Kimi TUI completion facts: installing a launch-scoped native plugin under ${join26(nativeHome, "plugins", "managed", "agent-hub")}; it will be removed after this TUI exits`);
23102
+ console.error(`Kimi TUI completion facts: installing a launch-scoped native plugin under ${join27(nativeHome, "plugins", "managed", "agent-hub")}; it will be removed after this TUI exits`);
22653
23103
  ensureKimiPlugin(plugin);
22654
23104
  completionEnv = { ...nativeEnv, AGENTHUB_INSTANCE_ID: native.instanceId, AGENTHUB_LAUNCH_ID: native.launchId, AGENTHUB_HOOK_PURPOSE: "facts" };
22655
23105
  } catch (error) {
@@ -22660,7 +23110,7 @@ async function runKimiEntry(ctx) {
22660
23110
  try {
22661
23111
  cleanupKimiPlugin(plugin);
22662
23112
  } catch {
22663
- console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join26(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
23113
+ console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join27(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
22664
23114
  }
22665
23115
  }
22666
23116
  if (completionEnv) {
@@ -22673,7 +23123,7 @@ async function runKimiEntry(ctx) {
22673
23123
  try {
22674
23124
  cleanupKimiPlugin(plugin);
22675
23125
  } catch {
22676
- console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join26(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
23126
+ console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join27(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
22677
23127
  }
22678
23128
  }
22679
23129
  } else {
@@ -22706,6 +23156,7 @@ async function runKimiEntry(ctx) {
22706
23156
  }
22707
23157
  }
22708
23158
  var init_native_cli_entry_kimi = __esm(() => {
23159
+ init_launch_check();
22709
23160
  init_compat();
22710
23161
  init_kimi_plugin();
22711
23162
  });
@@ -22794,6 +23245,8 @@ async function runPiEntry(ctx) {
22794
23245
  const warning = retainedLaunchWarning(snapshot, peer, ctx.definition);
22795
23246
  if (warning)
22796
23247
  console.error(warning);
23248
+ if (options.mode === "tui")
23249
+ printLaunchCheck(snapshot, peer, ctx.definition, "tui");
22797
23250
  const res = await hub.request({ t: "start", peer, args: options, operationId: process.env.AGENTHUB_RECOVERY_OPERATION });
22798
23251
  hub.close();
22799
23252
  if (!res.ok)
@@ -22821,7 +23274,9 @@ async function runPiEntry(ctx) {
22821
23274
  }
22822
23275
  console.log(res.already ? `${peer} is already attached` : `${peer} attached (headless). Talk to it with: ahub say @${peer} "..."`);
22823
23276
  }
22824
- var init_native_cli_entry_pi = () => {};
23277
+ var init_native_cli_entry_pi = __esm(() => {
23278
+ init_launch_check();
23279
+ });
22825
23280
 
22826
23281
  // src/adapters/definitions/native-cli-entry-local.ts
22827
23282
  async function runLocalEntry(ctx) {
@@ -22983,6 +23438,8 @@ async function runJcodeEntry(ctx) {
22983
23438
  const warning = retainedLaunchWarning(snapshot, peer, ctx.definition);
22984
23439
  if (warning)
22985
23440
  console.error(warning);
23441
+ if (mode === "tui" && !print)
23442
+ printLaunchCheck(snapshot, peer, ctx.definition, "tui");
22986
23443
  const options = { model: one["--model"], providerProfile: one["--provider-profile"], sessionId: one["--session-id"] };
22987
23444
  if (print) {
22988
23445
  if (!hub.features.includes("native_tui_launch") || mode !== "tui")
@@ -23037,12 +23494,13 @@ async function runJcodeEntry(ctx) {
23037
23494
  }
23038
23495
  var WAITING = "jcode's TUI opens after its first hub turn; send it work, or Ctrl-C";
23039
23496
  var init_native_cli_entry_jcode = __esm(() => {
23497
+ init_launch_check();
23040
23498
  init_jcode();
23041
23499
  });
23042
23500
 
23043
23501
  // src/adapters/definitions/native-cli-preview-claude.ts
23044
23502
  import { readFileSync as readFileSync13 } from "fs";
23045
- import { join as join27 } from "path";
23503
+ import { join as join28 } from "path";
23046
23504
  function previewClaude(ctx) {
23047
23505
  const { args, cwd, stateDir, cliDir, unattended, config } = ctx;
23048
23506
  const { buildLaunch, claudeObservationHooks } = ctx.helpers;
@@ -23050,13 +23508,13 @@ function previewClaude(ctx) {
23050
23508
  let envNames = state.envNames;
23051
23509
  let launch;
23052
23510
  let original;
23053
- for (const file of [join27(cwd, ".claude/settings.local.json"), join27(cwd, ".claude/settings.json"), join27(process.env.HOME ?? "", ".claude/settings.json")]) {
23511
+ for (const file of [join28(cwd, ".claude/settings.local.json"), join28(cwd, ".claude/settings.json"), join28(process.env.HOME ?? "", ".claude/settings.json")]) {
23054
23512
  try {
23055
23513
  original ??= JSON.parse(readFileSync13(file, "utf8")).statusLine;
23056
23514
  } catch {}
23057
23515
  }
23058
- const facts = claudeObservationHooks(config, { script: join27(cliDir, "facts-hook.ts"), stateDir });
23059
- launch = buildLaunch("claude", args, { preview: true, unattended, statusLine: { script: join27(cliDir, "statusline-tee.ts"), stateDir, ...original ? { original: { command: original.command ? REDACTED : "", ...typeof original.refreshInterval === "number" && Number.isFinite(original.refreshInterval) ? { refreshInterval: original.refreshInterval } : {}, ...typeof original.padding === "number" && Number.isFinite(original.padding) ? { padding: original.padding } : {} } } : {} }, ...facts ? { facts } : {} });
23516
+ const facts = claudeObservationHooks(config, { script: join28(cliDir, "facts-hook.ts"), stateDir });
23517
+ launch = buildLaunch("claude", args, { preview: true, unattended, statusLine: { script: join28(cliDir, "statusline-tee.ts"), stateDir, ...original ? { original: { command: original.command ? REDACTED : "", ...typeof original.refreshInterval === "number" && Number.isFinite(original.refreshInterval) ? { refreshInterval: original.refreshInterval } : {}, ...typeof original.padding === "number" && Number.isFinite(original.padding) ? { padding: original.padding } : {} } } : {} }, ...facts ? { facts } : {} });
23060
23518
  const safeArgs = args.map((arg, i) => {
23061
23519
  if (args[i - 1] === "--settings")
23062
23520
  return "{}";
@@ -23067,7 +23525,7 @@ function previewClaude(ctx) {
23067
23525
  return publicArg(arg);
23068
23526
  });
23069
23527
  const publicLaunch = buildLaunch("claude", safeArgs, { preview: true, unattended, statusLine: {
23070
- script: join27(cliDir, "statusline-tee.ts"),
23528
+ script: join28(cliDir, "statusline-tee.ts"),
23071
23529
  stateDir,
23072
23530
  ...original ? { original: { command: original.command ? REDACTED : "", ...typeof original.refreshInterval === "number" && Number.isFinite(original.refreshInterval) ? { refreshInterval: original.refreshInterval } : {}, ...typeof original.padding === "number" && Number.isFinite(original.padding) ? { padding: original.padding } : {} } } : {}
23073
23531
  }, facts });
@@ -23100,8 +23558,8 @@ function previewCodex(ctx) {
23100
23558
  var init_native_cli_preview_codex = () => {};
23101
23559
 
23102
23560
  // src/adapters/definitions/native-cli-preview-kimi.ts
23103
- import { join as join28 } from "path";
23104
- import { homedir as homedir7 } from "os";
23561
+ import { join as join29 } from "path";
23562
+ import { homedir as homedir8 } from "os";
23105
23563
  function previewKimi(ctx) {
23106
23564
  const { args, cwd, stateDir, cliDir, config } = ctx;
23107
23565
  const { childEnv, startModeOf, buildKimiLaunch, buildKimiTuiLaunch, nativeLaunchEnv, kimiMcpPlan } = ctx.helpers;
@@ -23126,10 +23584,10 @@ function previewKimi(ctx) {
23126
23584
  const nativeEnv = nativeLaunchEnv("kimi", childEnv());
23127
23585
  envNames = Object.keys(nativeEnv).concat(["AGENTHUB_STATE_DIR", "AGENTHUB_PROJECT_DIR", "AGENTHUB_INSTANCE_ID", "AGENTHUB_LAUNCH_ID", "AGENTHUB_HOOK_PURPOSE"]);
23128
23586
  unresolved.push({ field: "nativeLaunchId", reason: "native completion facts bind to the launch admitted by the running hub" });
23129
- const home = nativeEnv.KIMI_CODE_HOME ?? join28(nativeEnv.HOME ?? homedir7(), ".kimi-code");
23130
- completionPlugin = kimiPluginPreview(home, join28(cliDir, "../../plugins/agent-hub/kimi-hook.js"));
23587
+ const home = nativeEnv.KIMI_CODE_HOME ?? join29(nativeEnv.HOME ?? homedir8(), ".kimi-code");
23588
+ completionPlugin = kimiPluginPreview(home, join29(cliDir, "../../plugins/agent-hub/kimi-hook.js"));
23131
23589
  }
23132
- const { file, action, changed, tracked } = kimiMcpPlan(cwd, stateDir, join28(cliDir, "../../plugins/agent-hub/server.js"), mode);
23590
+ const { file, action, changed, tracked } = kimiMcpPlan(cwd, stateDir, join29(cliDir, "../../plugins/agent-hub/server.js"), mode);
23133
23591
  kimiMetadata = { mode, mcp: { file, action, changed, tracked }, ...completionPlugin ? { completionPlugin } : {} };
23134
23592
  return finishPreview(ctx, launch, envNames, unresolved, kimiMetadata);
23135
23593
  }
@@ -23138,7 +23596,7 @@ var init_native_cli_preview_kimi = __esm(() => {
23138
23596
  });
23139
23597
 
23140
23598
  // src/adapters/definitions/native-cli-preview-pi.ts
23141
- import { join as join29, resolve as resolve16 } from "path";
23599
+ import { join as join30, resolve as resolve16 } from "path";
23142
23600
  function previewPi(ctx) {
23143
23601
  const { args, stateDir, cliDir, config } = ctx;
23144
23602
  const { relayModelIds, buildPiLaunch, startModeOf } = ctx.helpers;
@@ -23173,7 +23631,7 @@ function previewPi(ctx) {
23173
23631
  tools: [],
23174
23632
  preamble: REDACTED,
23175
23633
  maxSteps: config.pi.max_steps
23176
- }, {}, resolve16(join29(cliDir, "../pi/extension.ts")), UNRESOLVED, UNRESOLVED);
23634
+ }, {}, resolve16(join30(cliDir, "../pi/extension.ts")), UNRESOLVED, UNRESOLVED);
23177
23635
  launch = pi;
23178
23636
  envNames = Object.keys(pi.env).concat(["PATH", "HOME", "USER", "SHELL", "TMPDIR", "TERM", "TERM_PROGRAM", "LANG", "LC_ALL", "LC_CTYPE", "NO_COLOR", "CODEX_HOME"].filter((key) => process.env[key] !== undefined));
23179
23637
  if (mode === "tui")
@@ -23263,8 +23721,8 @@ var init_native_config_policy = __esm(() => {
23263
23721
  });
23264
23722
 
23265
23723
  // src/adapters/definitions/native-policy-aux.ts
23266
- import { closeSync as closeSync15, constants as constants11, fstatSync as fstatSync13, openSync as openSync15, readdirSync as readdirSync5, readFileSync as readFileSync14 } from "fs";
23267
- import { isAbsolute as isAbsolute9, join as join30, normalize } from "path";
23724
+ import { closeSync as closeSync16, constants as constants12, fstatSync as fstatSync14, openSync as openSync16, readdirSync as readdirSync6, readFileSync as readFileSync14 } from "fs";
23725
+ import { isAbsolute as isAbsolute10, join as join31, normalize } from "path";
23268
23726
  function claudeCrashPlan(_meta) {
23269
23727
  return { how: "claude: the Claude Code plugin reconnects by itself while that session is still open" };
23270
23728
  }
@@ -23309,13 +23767,13 @@ function localCrashPlan(meta) {
23309
23767
  }
23310
23768
  function claudePlugins(root, cwd) {
23311
23769
  const enabled = new Map;
23312
- for (const file of [join30(root, "settings.json"), ...cwd ? [join30(cwd, ".claude", "settings.json"), join30(cwd, ".claude", "settings.local.json")] : []]) {
23770
+ for (const file of [join31(root, "settings.json"), ...cwd ? [join31(cwd, ".claude", "settings.json"), join31(cwd, ".claude", "settings.local.json")] : []]) {
23313
23771
  const map = json(file)?.enabledPlugins;
23314
23772
  if (map && typeof map === "object")
23315
23773
  for (const [key, on] of Object.entries(map))
23316
23774
  enabled.set(key, on === true);
23317
23775
  }
23318
- const installed = json(join30(root, "plugins", "installed_plugins.json"))?.plugins ?? {};
23776
+ const installed = json(join31(root, "plugins", "installed_plugins.json"))?.plugins ?? {};
23319
23777
  const out = [];
23320
23778
  for (const [key, on] of enabled) {
23321
23779
  if (!on)
@@ -23329,7 +23787,7 @@ function claudePlugins(root, cwd) {
23329
23787
  return out;
23330
23788
  }
23331
23789
  function codexPlugins(root) {
23332
- const config = text2(join30(root, "config.toml"));
23790
+ const config = text2(join31(root, "config.toml"));
23333
23791
  if (config === undefined)
23334
23792
  return [];
23335
23793
  const found = new Map, disabled = new Set;
@@ -23348,7 +23806,7 @@ function codexPlugins(root) {
23348
23806
  continue;
23349
23807
  let versions = [];
23350
23808
  try {
23351
- versions = readdirSync5(join30(root, "plugins", "cache", market, plugin));
23809
+ versions = readdirSync6(join31(root, "plugins", "cache", market, plugin));
23352
23810
  } catch {}
23353
23811
  out.push({ name, version: versions.length === 1 ? version2(versions[0]) : null });
23354
23812
  }
@@ -23363,13 +23821,13 @@ function parsePiContinuity(value) {
23363
23821
  return { sessionId: value.sessionId, ...value.sessionFile === undefined ? {} : { sessionFile: value.sessionFile }, ...value.backend === undefined ? {} : { backend: value.backend }, ...value.model === undefined ? {} : { model: value.model } };
23364
23822
  }
23365
23823
  function absoluteContinuityPath(value) {
23366
- return typeof value === "string" && value.length > 0 && value.length <= 4096 && !/[\x00-\x1f\x7f]/.test(value) && isAbsolute9(value) && normalize(value) === value;
23824
+ return typeof value === "string" && value.length > 0 && value.length <= 4096 && !/[\x00-\x1f\x7f]/.test(value) && isAbsolute10(value) && normalize(value) === value;
23367
23825
  }
23368
23826
  var str3 = (value) => typeof value === "string" && value ? value : undefined, PLUGINS, CLAUDE_ONLY, text2 = (file) => {
23369
23827
  let fd;
23370
23828
  try {
23371
- fd = openSync15(file, constants11.O_RDONLY | constants11.O_NONBLOCK);
23372
- const st = fstatSync13(fd);
23829
+ fd = openSync16(file, constants12.O_RDONLY | constants12.O_NONBLOCK);
23830
+ const st = fstatSync14(fd);
23373
23831
  if (!st.isFile() || st.size > 1024 * 1024)
23374
23832
  return;
23375
23833
  return readFileSync14(fd, "utf8");
@@ -23377,7 +23835,7 @@ var str3 = (value) => typeof value === "string" && value ? value : undefined, PL
23377
23835
  return;
23378
23836
  } finally {
23379
23837
  if (fd !== undefined)
23380
- closeSync15(fd);
23838
+ closeSync16(fd);
23381
23839
  }
23382
23840
  }, json = (file) => {
23383
23841
  try {
@@ -23386,7 +23844,7 @@ var str3 = (value) => typeof value === "string" && value ? value : undefined, PL
23386
23844
  } catch {
23387
23845
  return;
23388
23846
  }
23389
- }, version2 = (v) => typeof v === "string" && /^[0-9A-Za-z.+_-]{1,40}$/.test(v) ? v : null, claudePluginInventory = (ctx) => claudePlugins(ctx.env.CLAUDE_CONFIG_DIR?.trim() || join30(ctx.home, ".claude"), ctx.cwd), codexPluginInventory = (ctx) => codexPlugins(ctx.env.CODEX_HOME?.trim() || join30(ctx.home, ".codex")), codexToolSemantic = (name, _command) => name.toLowerCase() === "filechange" ? "edit" : undefined;
23847
+ }, version2 = (v) => typeof v === "string" && /^[0-9A-Za-z.+_-]{1,40}$/.test(v) ? v : null, claudePluginInventory = (ctx) => claudePlugins(ctx.env.CLAUDE_CONFIG_DIR?.trim() || join31(ctx.home, ".claude"), ctx.cwd), codexPluginInventory = (ctx) => codexPlugins(ctx.env.CODEX_HOME?.trim() || join31(ctx.home, ".codex")), codexToolSemantic = (name, _command) => name.toLowerCase() === "filechange" ? "edit" : undefined;
23390
23848
  var init_native_policy_aux = __esm(() => {
23391
23849
  PLUGINS = new Map([["claude-mem", "claude-mem"], ["ponytail", "ponytail"], ["open-code-review", "open-code-review"]]);
23392
23850
  CLAUDE_ONLY = new Map([["codex@openai-codex", "codex-plugin"]]);
@@ -23431,7 +23889,7 @@ var init_native_cli_launch_common = __esm(() => {
23431
23889
  // src/adapters/definitions/native-cli-claude-launch.ts
23432
23890
  import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync11, renameSync as renameSync7, unlinkSync as unlinkSync5, readFileSync as readFileSync15 } from "fs";
23433
23891
  import { randomUUID as randomUUID12 } from "crypto";
23434
- import { resolve as resolve17, join as join31 } from "path";
23892
+ import { resolve as resolve17, join as join32 } from "path";
23435
23893
  function claudeChannel(userArgs) {
23436
23894
  const bundle = resolve17(import.meta.dir, "../../../plugins/agent-hub/server.js");
23437
23895
  for (let i = 0;i < userArgs.length; i++) {
@@ -23447,7 +23905,8 @@ function claudeChannel(userArgs) {
23447
23905
  }
23448
23906
  return CLAUDE_CHANNEL;
23449
23907
  }
23450
- function claudeNativeLaunch(ctx) {
23908
+ function claudeNativeLaunch(input) {
23909
+ const ctx = input.preview && input.facts ? { ...input, facts: { ...input.facts, startCheck: true } } : input;
23451
23910
  const { passthrough, unattended } = nativeLaunchArguments("claude", ctx, CLAUDE_LAUNCH_POLICY);
23452
23911
  const build = () => {
23453
23912
  const own = passthrough.some((a) => a === "--settings" || a.startsWith("--settings="));
@@ -23493,7 +23952,7 @@ function claudeNativeLaunch(ctx) {
23493
23952
  const stateDir = ctx.facts?.stateDir ?? ctx.statusLine?.stateDir;
23494
23953
  if (!stateDir)
23495
23954
  throw new Error("Claude session settings require the hub state directory");
23496
- const file = join31(stateDir, `claude-settings-${randomUUID12()}.json`);
23955
+ const file = join32(stateDir, `claude-settings-${randomUUID12()}.json`);
23497
23956
  try {
23498
23957
  mkdirSync14(stateDir, { recursive: true, mode: 448 });
23499
23958
  writeFileSync11(`${file}.tmp`, settingsArgs[1], { mode: 384, flag: "wx" });
@@ -23551,14 +24010,14 @@ var init_native_cli_codex_launch = __esm(() => {
23551
24010
 
23552
24011
  // src/cli/recovery-session-file.ts
23553
24012
  import { statSync as statSync6 } from "fs";
23554
- import { homedir as homedir8 } from "os";
23555
- import { join as join32 } from "path";
24013
+ import { homedir as homedir9 } from "os";
24014
+ import { join as join33 } from "path";
23556
24015
  function checkedSessionPath(binding, kind) {
23557
24016
  if (kind === "rollout")
23558
- return join32(binding.launch.env.CODEX_HOME ?? join32(homedir8(), ".codex"), "sessions");
23559
- const config = binding.launch.env.CLAUDE_CONFIG_DIR ?? join32(homedir8(), ".claude");
24017
+ return join33(binding.launch.env.CODEX_HOME ?? join33(homedir9(), ".codex"), "sessions");
24018
+ const config = binding.launch.env.CLAUDE_CONFIG_DIR ?? join33(homedir9(), ".claude");
23560
24019
  const slug = binding.projectRoot.replace(/[^a-zA-Z0-9]/g, "-");
23561
- return join32(config, "projects", slug, `${binding.sessionId}.jsonl`);
24020
+ return join33(config, "projects", slug, `${binding.sessionId}.jsonl`);
23562
24021
  }
23563
24022
  function recordedFileState(file) {
23564
24023
  try {
@@ -23570,11 +24029,11 @@ function recordedFileState(file) {
23570
24029
  var init_recovery_session_file = () => {};
23571
24030
 
23572
24031
  // src/adapters/definitions/native-recovery.ts
23573
- import { readdirSync as readdirSync6 } from "fs";
23574
- import { basename as basename6, join as join33 } from "path";
24032
+ import { readdirSync as readdirSync7 } from "fs";
24033
+ import { basename as basename7, join as join34 } from "path";
23575
24034
  var rolloutState = (binding) => {
23576
24035
  try {
23577
- return readdirSync6(checkedSessionPath(binding, "rollout"), { recursive: true }).some((name) => String(name).endsWith(".jsonl") && basename6(String(name)).includes(binding.sessionId));
24036
+ return readdirSync7(checkedSessionPath(binding, "rollout"), { recursive: true }).some((name) => String(name).endsWith(".jsonl") && basename7(String(name)).includes(binding.sessionId));
23578
24037
  } catch (error) {
23579
24038
  return error.code === "ENOENT" ? false : "unknown";
23580
24039
  }
@@ -23595,7 +24054,7 @@ var init_native_recovery = __esm(() => {
23595
24054
  if (phase !== "plan")
23596
24055
  return false;
23597
24056
  let current, started = false, turned = false;
23598
- for (const e of readEvents(join33(stateDir, "events.jsonl"))) {
24057
+ for (const e of readEvents(join34(stateDir, "events.jsonl"))) {
23599
24058
  if (e.type === "native_thread" && e.peer === binding.peer) {
23600
24059
  current = e.thread;
23601
24060
  if (e.thread === binding.sessionId && e.fresh)
@@ -23671,200 +24130,6 @@ var init_native_recovery = __esm(() => {
23671
24130
  };
23672
24131
  });
23673
24132
 
23674
- // src/adapters/kimi-tui-facts.ts
23675
- import { closeSync as closeSync16, constants as constants12, fstatSync as fstatSync14, lstatSync as lstatSync25, openSync as openSync16, readSync as readSync11, readdirSync as readdirSync7 } from "fs";
23676
- import { createHash as createHash13 } from "crypto";
23677
- import { basename as basename7, dirname as dirname16, isAbsolute as isAbsolute10, join as join34, relative as relative6 } from "path";
23678
- import { homedir as homedir9 } from "os";
23679
- function decodeKimiTuiHook(event, value) {
23680
- if (!EVENTS4.includes(event) || !record7(value) || value.hook_event_name !== event || value.client_type !== "kimi_code_cli" || typeof value.session_id !== "string" || !SESSION.test(value.session_id) || typeof value.cwd !== "string" || !isAbsolute10(value.cwd) || value.cwd.length > 4096)
23681
- return;
23682
- if ((event === "TurnStarted" || event === "Interrupt") && !integer2(value.turn_id))
23683
- return;
23684
- if (event === "TaskStarted" && (typeof value.task_id !== "string" || !TASK.test(value.task_id)))
23685
- return;
23686
- const home = process.env.KIMI_CODE_HOME ?? join34(process.env.HOME ?? homedir9(), ".kimi-code");
23687
- const transcriptPath = value.agentHubTranscriptPath ?? join34(home, "session_index.jsonl");
23688
- if (typeof transcriptPath !== "string" || !isAbsolute10(transcriptPath) || transcriptPath.length > 4096)
23689
- return;
23690
- const phase = { TurnStarted: "start", Stop: "stop", StopFailure: "stop", Interrupt: "stop", SessionEnd: "session", TaskStarted: "pre", Notification: "post" }[event];
23691
- return { event, phase, sessionId: value.session_id, transcriptPath, workspacePaths: [value.cwd], tool: "", input: {} };
23692
- }
23693
- function encodeKimiTuiHook() {
23694
- return;
23695
- }
23696
- function readBytes(path, cap, tail = false) {
23697
- const link = lstatSync25(path);
23698
- if (!link.isFile() || link.isSymbolicLink() || link.nlink !== 1)
23699
- throw new Error("not a regular file");
23700
- const fd = openSync16(path, constants12.O_RDONLY | constants12.O_NOFOLLOW);
23701
- try {
23702
- const stat = fstatSync14(fd);
23703
- if (!stat.isFile() || stat.nlink !== 1 || !tail && stat.size > cap)
23704
- throw new Error("invalid file");
23705
- const length = Math.min(stat.size, cap), start = tail ? stat.size - length : 0;
23706
- const bytes = Buffer.alloc(length);
23707
- let offset = 0;
23708
- while (offset < length) {
23709
- const count = readSync11(fd, bytes, offset, length - offset, start + offset);
23710
- if (count <= 0)
23711
- throw new Error("short read");
23712
- offset += count;
23713
- }
23714
- return bytes;
23715
- } finally {
23716
- closeSync16(fd);
23717
- }
23718
- }
23719
- function sessionDirectory(index, session) {
23720
- const home = dirname16(index), sessions = realPath(join34(home, "sessions"));
23721
- let listed;
23722
- for (const line of readBytes(index, INDEX_CAP2).toString("utf8").split(`
23723
- `)) {
23724
- if (!line.includes(session))
23725
- continue;
23726
- let row;
23727
- try {
23728
- row = JSON.parse(line);
23729
- } catch {
23730
- continue;
23731
- }
23732
- if (record7(row) && row.sessionId === session && typeof row.sessionDir === "string") {
23733
- if (listed)
23734
- throw new Error("duplicate session");
23735
- listed = row.sessionDir;
23736
- }
23737
- }
23738
- if (!listed)
23739
- throw new Error("session not indexed");
23740
- const directory = realPath(listed);
23741
- if (!inside3(sessions, directory))
23742
- throw new Error("session outside home");
23743
- return directory;
23744
- }
23745
- function taskInventory(agents) {
23746
- let active = 0;
23747
- const names = readdirSync7(agents, { withFileTypes: true });
23748
- if (names.length > MAX_AGENTS2)
23749
- throw new Error("too many agents");
23750
- for (const entry of names) {
23751
- if (!AGENT.test(entry.name))
23752
- continue;
23753
- if (!entry.isDirectory())
23754
- continue;
23755
- const tasks = join34(agents, entry.name, "tasks");
23756
- const dir = lstatSync25(tasks, { throwIfNoEntry: false });
23757
- if (!dir)
23758
- continue;
23759
- if (!dir.isDirectory() || dir.isSymbolicLink())
23760
- throw new Error("invalid task directory");
23761
- const files = readdirSync7(tasks).filter((name) => name.endsWith(".json")).sort();
23762
- if (files.length > MAX_TASKS)
23763
- throw new Error("too many tasks");
23764
- for (const name of files) {
23765
- if (!TASK.test(name.slice(0, -5)))
23766
- throw new Error("invalid task name");
23767
- const row = JSON.parse(readBytes(join34(tasks, name), TASK_CAP).toString("utf8"));
23768
- if (!record7(row) || row.taskId !== name.slice(0, -5) || typeof row.status !== "string")
23769
- throw new Error("invalid task");
23770
- if (row.status === "running" && row.endedAt === null) {
23771
- active++;
23772
- continue;
23773
- }
23774
- const terminal = ["completed", "failed", "cancelled"].includes(row.status) && integer2(row.endedAt);
23775
- if (!terminal)
23776
- throw new Error("unknown task state");
23777
- }
23778
- }
23779
- return active;
23780
- }
23781
- function readKimiTuiTranscript(session, index) {
23782
- if (!SESSION.test(session) || basename7(index) !== "session_index.jsonl" || !isAbsolute10(index))
23783
- return empty();
23784
- try {
23785
- const directory = sessionDirectory(index, session);
23786
- const wire = join34(directory, "agents", "main", "wire.jsonl");
23787
- if (!inside3(directory, realPath(wire)))
23788
- return empty();
23789
- const bytes = readBytes(wire, WIRE_CAP, true);
23790
- if (bytes.length === 0 || bytes[bytes.length - 1] !== 10)
23791
- return empty();
23792
- const lines = bytes.toString("utf8").split(`
23793
- `);
23794
- if (bytes.length === WIRE_CAP && !lines[0]?.startsWith('{"type":"metadata"'))
23795
- lines.shift();
23796
- const prompts = new Map;
23797
- const ends = new Map;
23798
- const promptEnds = new Map;
23799
- const promptEndTurnIds = new Map;
23800
- let started;
23801
- for (const line of lines) {
23802
- if (!line || !/"(?:turn\.prompt|turn\.ended|prompt\.completed|prompt\.aborted)"/.test(line))
23803
- continue;
23804
- let row;
23805
- try {
23806
- row = JSON.parse(line);
23807
- } catch {
23808
- return empty();
23809
- }
23810
- if (!record7(row))
23811
- return empty();
23812
- if (row.type === "turn.prompt" && integer2(row.turnId) && record7(row.origin) && typeof row.origin.kind === "string") {
23813
- const turn = row.turnId, id = typeof row.promptId === "string" ? row.promptId : typeof row.origin.notificationId === "string" ? row.origin.notificationId : `turn-${turn}`;
23814
- const prompt = { turn, id, origin: row.origin.kind };
23815
- prompts.set(turn, prompt);
23816
- started = prompt;
23817
- } else if (row.type === "turn.ended" && integer2(row.turnId) && ["completed", "failed", "cancelled"].includes(String(row.reason))) {
23818
- const turn = row.turnId;
23819
- ends.set(turn, { turn, reason: row.reason });
23820
- } else if (row.type === "prompt.completed" && typeof row.promptId === "string" && ["completed", "failed"].includes(String(row.reason))) {
23821
- promptEnds.set(row.promptId, row.reason);
23822
- if (integer2(row.turnId))
23823
- promptEndTurnIds.set(row.turnId, row.promptId);
23824
- } else if (row.type === "prompt.aborted" && typeof row.promptId === "string") {
23825
- promptEnds.set(row.promptId, "cancelled");
23826
- if (integer2(row.turnId))
23827
- promptEndTurnIds.set(row.turnId, row.promptId);
23828
- } else if (row.type === "turn.prompt" || row.type === "turn.ended")
23829
- return empty();
23830
- }
23831
- let completion;
23832
- for (const [turn, end] of ends) {
23833
- const prompt = prompts.get(turn), promptReason = prompt ? promptEnds.get(prompt.id) : undefined, turnPromptId = promptEndTurnIds.get(turn);
23834
- if (!prompt || promptReason !== undefined && promptReason !== end.reason || turnPromptId !== undefined && turnPromptId !== prompt.id)
23835
- continue;
23836
- completion = { id: createHash13("sha256").update(`${session}:${turn}:${prompt.id}:${end.reason}`).digest("hex"), index: turn, reason: end.reason };
23837
- }
23838
- let background;
23839
- try {
23840
- background = taskInventory(join34(directory, "agents"));
23841
- } catch {}
23842
- return {
23843
- factIds: [],
23844
- ...completion ? { completion } : {},
23845
- ...started ? { started: { id: createHash13("sha256").update(`${session}:${started.turn}:${started.id}`).digest("hex"), index: started.turn, origin: started.origin } } : {},
23846
- ...background === undefined ? {} : { background }
23847
- };
23848
- } catch {
23849
- return empty();
23850
- }
23851
- }
23852
- var EVENTS4, SESSION, AGENT, TASK, INDEX_CAP2, WIRE_CAP, TASK_CAP, MAX_AGENTS2 = 256, MAX_TASKS = 256, record7 = (value) => !!value && typeof value === "object" && !Array.isArray(value), integer2 = (value) => Number.isSafeInteger(value) && value >= 0, inside3 = (root, path) => {
23853
- const rel = relative6(root, path);
23854
- return rel !== "" && rel !== ".." && !rel.startsWith("../") && !isAbsolute10(rel);
23855
- }, empty = () => ({ factIds: [] }), KIMI_TUI_FACTS_HOOK;
23856
- var init_kimi_tui_facts = __esm(() => {
23857
- init_project();
23858
- EVENTS4 = ["TurnStarted", "Stop", "StopFailure", "Interrupt", "SessionEnd", "TaskStarted", "Notification"];
23859
- SESSION = /^session_[A-Za-z0-9_-]{1,120}$/;
23860
- AGENT = /^[A-Za-z0-9._-]{1,64}$/;
23861
- TASK = /^[A-Za-z0-9._:-]{1,128}$/;
23862
- INDEX_CAP2 = 16 * 1024 * 1024;
23863
- WIRE_CAP = 8 * 1024 * 1024;
23864
- TASK_CAP = 64 * 1024;
23865
- KIMI_TUI_FACTS_HOOK = { decode: decodeKimiTuiHook, encode: encodeKimiTuiHook, read: readKimiTuiTranscript };
23866
- });
23867
-
23868
24133
  // src/adapters/definitions/builtin-metadata.ts
23869
24134
  function sessionId(field) {
23870
24135
  return (peer) => {
@@ -23894,7 +24159,7 @@ var init_builtin_metadata = __esm(() => {
23894
24159
  init_native_display();
23895
24160
  init_native_recovery();
23896
24161
  init_native_quota();
23897
- init_kimi_tui_facts();
24162
+ init_native_facts_hooks();
23898
24163
  switches = Object.freeze(["--unattended", "--safe", "--new"]);
23899
24164
  implementerRoles = Object.freeze(["implementer", "verifier"]);
23900
24165
  dualForms = Object.freeze(["tui", "headless"]);
@@ -24068,7 +24333,7 @@ var init_builtin_metadata = __esm(() => {
24068
24333
  settle: { signal: "prompt-response" },
24069
24334
  budget: { account: "kimi", resetSoftTokensOnResume: true, context: { source: "acp_usage_update", read: acpContextValue } },
24070
24335
  capabilities: { watch: true },
24071
- hooks: { factsHook: KIMI_TUI_FACTS_HOOK, recallPlatform: "kimi", recallSource: "kimi" },
24336
+ hooks: { factsHook: NATIVE_FACTS_HOOKS.kimi, recallPlatform: "kimi", recallSource: "kimi" },
24072
24337
  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] },
24073
24338
  display: KIMI_DISPLAY
24074
24339
  },
@@ -24195,6 +24460,8 @@ async function runQwenEntry(ctx) {
24195
24460
  const warning = retainedLaunchWarning(snapshot, peer, ctx.definition);
24196
24461
  if (warning)
24197
24462
  console.error(warning);
24463
+ if (mode === "tui")
24464
+ printLaunchCheck(snapshot, peer, ctx.definition, "tui");
24198
24465
  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 }, 35000);
24199
24466
  if (!reply.ok)
24200
24467
  fail(reply.error);
@@ -24223,6 +24490,7 @@ async function runQwenEntry(ctx) {
24223
24490
  }
24224
24491
  var init_native_cli_entry_qwen = __esm(() => {
24225
24492
  init_child_process();
24493
+ init_launch_check();
24226
24494
  });
24227
24495
 
24228
24496
  // src/adapters/definitions/native-cli-preview-qwen.ts
@@ -25052,6 +25320,12 @@ var init_registry = __esm(() => {
25052
25320
  }));
25053
25321
  });
25054
25322
 
25323
+ // src/hub/peer-doing.ts
25324
+ var TITLE_READ_MAX, TITLE_LINE_MAX;
25325
+ var init_peer_doing = __esm(() => {
25326
+ TITLE_READ_MAX = 1024 * 1024;
25327
+ TITLE_LINE_MAX = 64 * 1024;
25328
+ });
25055
25329
  // node_modules/ajv/dist/compile/codegen/code.js
25056
25330
  var require_code = __commonJS(function(exports) {
25057
25331
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -32551,7 +32825,7 @@ class ControlClient {
32551
32825
  client.pending.delete(msg.rid);
32552
32826
  done(msg);
32553
32827
  };
32554
- ws.onopen = () => void client.request({ t: "hello", token: control.token, ...hello, ...expected, clientVersion: VERSION, v: selected, vMin: remote?.vMin === undefined ? selected : Math.max(local.vMin, remote.vMin) }, timeoutMs).then((reply) => {
32828
+ ws.onopen = () => void client.request({ t: "hello", token: control.token, ...hello.role === "tools" && hello.clientPid === undefined ? { clientPid: process.pid } : {}, ...hello, ...expected, clientVersion: VERSION, v: selected, vMin: remote?.vMin === undefined ? selected : Math.max(local.vMin, remote.vMin) }, timeoutMs).then((reply) => {
32555
32829
  if (reply.t !== "welcome" || reply.ok === false)
32556
32830
  return refuse(new Error(reply.error ?? "hub refused handshake"));
32557
32831
  if (expected.projectId && reply.projectId !== expected.projectId || expected.instanceId && reply.instanceId !== expected.instanceId || expected.projectRoot && reply.cwd !== expected.projectRoot) {
@@ -32798,6 +33072,7 @@ init_plan_conformance();
32798
33072
  // src/hub/sdlc-release.ts
32799
33073
  init_child_process();
32800
33074
  init_git();
33075
+ init_project();
32801
33076
  import { fileURLToPath as fileURLToPath2 } from "url";
32802
33077
  var CHECKER_PATH = fileURLToPath2(new URL("../../scripts/check-docs.mjs", import.meta.url));
32803
33078
 
@@ -33009,6 +33284,7 @@ var GROOMING_CODES = new Set(["tests", "spec", "roster", "pull-only", "not-attac
33009
33284
  // src/hub/ci-watch.ts
33010
33285
  init_sdlc();
33011
33286
  var CI_WATCH_DEADLINE_MS = 45 * 60000;
33287
+ var CI_MISSING_RUN_MS = 10 * 60000;
33012
33288
 
33013
33289
  // src/hub/tasks.ts
33014
33290
  init_sdlc();
@@ -33032,10 +33308,7 @@ var MANAGED_HANDOFF = Symbol("managed worktree handoff");
33032
33308
 
33033
33309
  // src/hub/conductor.ts
33034
33310
  init_tool_refusal();
33035
-
33036
- // src/hub/peer-doing.ts
33037
- var TITLE_READ_MAX = 1024 * 1024;
33038
- var TITLE_LINE_MAX = 64 * 1024;
33311
+ init_peer_doing();
33039
33312
 
33040
33313
  // src/hub/instances.ts
33041
33314
  import { types as types10 } from "util";
@@ -41875,57 +42148,8 @@ function buildNativePermissionProbe(request) {
41875
42148
  }
41876
42149
  }
41877
42150
 
41878
- // src/adapters/claude-channel-evidence.ts
41879
- import { spawnSync as spawnSync5 } from "child_process";
41880
- var claudeParentCommandPort = { read: readClaudeParentCommand };
41881
- var TARGETS = new Set(["plugin:agent-hub@agent-hub", "server:agent-hub"]);
41882
- var DISABLING = new Set(["-p", "--print", "--output-format", "--background", "--detach", "--daemon", "daemon", "bg", "bg-spare"]);
41883
- function classifyClaudeParentCommand(command) {
41884
- if (!command || command.length > 4096 || /[\n\r\0]/.test(command))
41885
- return "launch-unverified";
41886
- const argv = command.trim().split(/\s+/);
41887
- const executable = argv[0]?.split("/").at(-1);
41888
- if (executable !== "claude" || argv.length < 3 || argv[1] !== "--dangerously-load-development-channels" || !TARGETS.has(argv[2]))
41889
- return "launch-unverified";
41890
- if (argv.slice(3).some((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=")))
41891
- return "launch-unverified";
41892
- return "development-channel-launch";
41893
- }
41894
- function readClaudeParentCommand(ppid) {
41895
- try {
41896
- const result = spawnSync5("/bin/ps", ["-ww", "-p", String(ppid), "-o", "command="], {
41897
- encoding: "utf8",
41898
- timeout: 1500,
41899
- maxBuffer: 4096,
41900
- env: { PATH: "/usr/bin:/bin", LC_ALL: "C" }
41901
- });
41902
- if (result.error || result.status !== 0 || typeof result.stdout !== "string" || !result.stdout.trim() || result.stdout.trim().includes(`
41903
- `))
41904
- return;
41905
- return result.stdout.trim();
41906
- } catch {
41907
- return;
41908
- }
41909
- }
41910
- function claudeChannelEvidence(env = process.env, ppid = process.ppid, read = claudeParentCommandPort.read) {
41911
- if (env.AGENTHUB_CHANNEL !== "1")
41912
- return "unknown";
41913
- if (!Number.isSafeInteger(ppid) || ppid <= 1)
41914
- return "unknown";
41915
- try {
41916
- const command = read(ppid);
41917
- if (!command || process.ppid !== ppid)
41918
- return "unknown";
41919
- return classifyClaudeParentCommand(command);
41920
- } catch {
41921
- return "unknown";
41922
- }
41923
- }
41924
- function currentClaudeChannelEvidence() {
41925
- return claudeChannelEvidence();
41926
- }
41927
-
41928
42151
  // src/adapters/claude-channel.ts
42152
+ init_claude_channel_evidence();
41929
42153
  var own5 = channelProject(process.cwd(), process.env, (root) => {
41930
42154
  const read = (name) => {
41931
42155
  try {