@sentropic/h2a 0.98.6 → 0.98.7-rc.2

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 (170) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/dist/cli-command-map.d.ts.map +1 -1
  4. package/dist/cli-command-map.js +1 -0
  5. package/dist/cli-command-map.js.map +1 -1
  6. package/dist/cli-contract.js +2 -2
  7. package/dist/cli-contract.js.map +1 -1
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +226 -16
  10. package/dist/cli.js.map +1 -1
  11. package/dist/hosts/agy.js +1 -1
  12. package/dist/hosts/agy.js.map +1 -1
  13. package/dist/hosts/installation-doctor.d.ts +1 -0
  14. package/dist/hosts/installation-doctor.d.ts.map +1 -1
  15. package/dist/hosts/installation-doctor.js +1 -1
  16. package/dist/hosts/installation-doctor.js.map +1 -1
  17. package/dist/hosts/muse.d.ts.map +1 -1
  18. package/dist/hosts/muse.js +2 -4
  19. package/dist/hosts/muse.js.map +1 -1
  20. package/dist/hosts/native-artifacts.d.ts +33 -0
  21. package/dist/hosts/native-artifacts.d.ts.map +1 -0
  22. package/dist/hosts/native-artifacts.js +104 -0
  23. package/dist/hosts/native-artifacts.js.map +1 -0
  24. package/dist/hosts/native-catalog.d.ts +19 -0
  25. package/dist/hosts/native-catalog.d.ts.map +1 -0
  26. package/dist/hosts/native-catalog.js +14 -0
  27. package/dist/hosts/native-catalog.js.map +1 -0
  28. package/dist/hosts/native-convergence.d.ts +132 -0
  29. package/dist/hosts/native-convergence.d.ts.map +1 -0
  30. package/dist/hosts/native-convergence.js +86 -0
  31. package/dist/hosts/native-convergence.js.map +1 -0
  32. package/dist/hosts/native-files.d.ts +40 -0
  33. package/dist/hosts/native-files.d.ts.map +1 -0
  34. package/dist/hosts/native-files.js +131 -0
  35. package/dist/hosts/native-files.js.map +1 -0
  36. package/dist/hosts/native-inspection.d.ts +31 -0
  37. package/dist/hosts/native-inspection.d.ts.map +1 -0
  38. package/dist/hosts/native-inspection.js +79 -0
  39. package/dist/hosts/native-inspection.js.map +1 -0
  40. package/dist/hosts/native-paths.d.ts +11 -0
  41. package/dist/hosts/native-paths.d.ts.map +1 -0
  42. package/dist/hosts/native-paths.js +21 -0
  43. package/dist/hosts/native-paths.js.map +1 -0
  44. package/dist/hosts/native-proof.d.ts +32 -0
  45. package/dist/hosts/native-proof.d.ts.map +1 -0
  46. package/dist/hosts/native-proof.js +31 -0
  47. package/dist/hosts/native-proof.js.map +1 -0
  48. package/dist/hosts/native-runtime-record.d.ts +3 -0
  49. package/dist/hosts/native-runtime-record.d.ts.map +1 -0
  50. package/dist/hosts/native-runtime-record.js +60 -0
  51. package/dist/hosts/native-runtime-record.js.map +1 -0
  52. package/dist/hosts/native-skills.d.ts +24 -0
  53. package/dist/hosts/native-skills.d.ts.map +1 -0
  54. package/dist/hosts/native-skills.js +56 -0
  55. package/dist/hosts/native-skills.js.map +1 -0
  56. package/dist/hosts/native-toml.d.ts +18 -0
  57. package/dist/hosts/native-toml.d.ts.map +1 -0
  58. package/dist/hosts/native-toml.js +91 -0
  59. package/dist/hosts/native-toml.js.map +1 -0
  60. package/dist/hosts/operator-notices.d.ts +3 -0
  61. package/dist/hosts/operator-notices.d.ts.map +1 -0
  62. package/dist/hosts/operator-notices.js +31 -0
  63. package/dist/hosts/operator-notices.js.map +1 -0
  64. package/dist/hosts/plugin.d.ts.map +1 -1
  65. package/dist/hosts/plugin.js +3 -2
  66. package/dist/hosts/plugin.js.map +1 -1
  67. package/dist/hosts/upgrade-equipment.d.ts +42 -0
  68. package/dist/hosts/upgrade-equipment.d.ts.map +1 -0
  69. package/dist/hosts/upgrade-equipment.js +26 -0
  70. package/dist/hosts/upgrade-equipment.js.map +1 -0
  71. package/dist/hosts/vibe-discovery.d.ts +12 -0
  72. package/dist/hosts/vibe-discovery.d.ts.map +1 -0
  73. package/dist/hosts/vibe-discovery.js +33 -0
  74. package/dist/hosts/vibe-discovery.js.map +1 -0
  75. package/dist/hosts/vibe-equipment.d.ts +71 -0
  76. package/dist/hosts/vibe-equipment.d.ts.map +1 -0
  77. package/dist/hosts/vibe-equipment.js +162 -0
  78. package/dist/hosts/vibe-equipment.js.map +1 -0
  79. package/dist/hosts/vibe-mcp.d.ts +32 -0
  80. package/dist/hosts/vibe-mcp.d.ts.map +1 -0
  81. package/dist/hosts/vibe-mcp.js +210 -0
  82. package/dist/hosts/vibe-mcp.js.map +1 -0
  83. package/dist/hosts/vibe.d.ts +12 -3
  84. package/dist/hosts/vibe.d.ts.map +1 -1
  85. package/dist/hosts/vibe.js +15 -7
  86. package/dist/hosts/vibe.js.map +1 -1
  87. package/dist/index.d.ts +1 -1
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +1 -1
  90. package/dist/index.js.map +1 -1
  91. package/dist/runtime/agy-claude.d.ts +42 -0
  92. package/dist/runtime/agy-claude.d.ts.map +1 -0
  93. package/dist/runtime/agy-claude.js +140 -0
  94. package/dist/runtime/agy-claude.js.map +1 -0
  95. package/dist/runtime/live/contracts.d.ts +55 -0
  96. package/dist/runtime/live/contracts.d.ts.map +1 -0
  97. package/dist/runtime/live/contracts.js +59 -0
  98. package/dist/runtime/live/contracts.js.map +1 -0
  99. package/dist/runtime/local-files/identity-fence.d.ts.map +1 -1
  100. package/dist/runtime/local-files/identity-fence.js +2 -0
  101. package/dist/runtime/local-files/identity-fence.js.map +1 -1
  102. package/dist/runtime/local-files/orphan-gc.d.ts +3 -0
  103. package/dist/runtime/local-files/orphan-gc.d.ts.map +1 -0
  104. package/dist/runtime/local-files/orphan-gc.js +69 -0
  105. package/dist/runtime/local-files/orphan-gc.js.map +1 -0
  106. package/dist/runtime/local-files/presence.d.ts +5 -2
  107. package/dist/runtime/local-files/presence.d.ts.map +1 -1
  108. package/dist/runtime/local-files/presence.js +32 -29
  109. package/dist/runtime/local-files/presence.js.map +1 -1
  110. package/dist/runtime/local-files/recipient-hints.d.ts +10 -0
  111. package/dist/runtime/local-files/recipient-hints.d.ts.map +1 -0
  112. package/dist/runtime/local-files/recipient-hints.js +156 -0
  113. package/dist/runtime/local-files/recipient-hints.js.map +1 -0
  114. package/dist/runtime/local-files/store.d.ts.map +1 -1
  115. package/dist/runtime/local-files/store.js +22 -2
  116. package/dist/runtime/local-files/store.js.map +1 -1
  117. package/dist/runtime/mcp/agent-launch.d.ts +3 -0
  118. package/dist/runtime/mcp/agent-launch.d.ts.map +1 -1
  119. package/dist/runtime/mcp/agent-launch.js +93 -8
  120. package/dist/runtime/mcp/agent-launch.js.map +1 -1
  121. package/dist/runtime/mcp/handlers.d.ts +1 -0
  122. package/dist/runtime/mcp/handlers.d.ts.map +1 -1
  123. package/dist/runtime/mcp/handlers.js +7 -4
  124. package/dist/runtime/mcp/handlers.js.map +1 -1
  125. package/dist/runtime/mcp/notifications.d.ts +2 -1
  126. package/dist/runtime/mcp/notifications.d.ts.map +1 -1
  127. package/dist/runtime/mcp/notifications.js +16 -2
  128. package/dist/runtime/mcp/notifications.js.map +1 -1
  129. package/dist/runtime/mcp/server.d.ts +3 -0
  130. package/dist/runtime/mcp/server.d.ts.map +1 -1
  131. package/dist/runtime/mcp/server.js +19 -6
  132. package/dist/runtime/mcp/server.js.map +1 -1
  133. package/dist/runtime/mcp/sessions.d.ts +6 -6
  134. package/dist/runtime/mcp/sessions.d.ts.map +1 -1
  135. package/dist/runtime/mcp/sessions.js +18 -6
  136. package/dist/runtime/mcp/sessions.js.map +1 -1
  137. package/dist/runtime/mcp/stdio.d.ts.map +1 -1
  138. package/dist/runtime/mcp/stdio.js +11 -0
  139. package/dist/runtime/mcp/stdio.js.map +1 -1
  140. package/dist/runtime/mcp/tools.d.ts.map +1 -1
  141. package/dist/runtime/mcp/tools.js +7 -4
  142. package/dist/runtime/mcp/tools.js.map +1 -1
  143. package/dist/runtime/send.d.ts +10 -0
  144. package/dist/runtime/send.d.ts.map +1 -1
  145. package/dist/runtime/send.js +80 -5
  146. package/dist/runtime/send.js.map +1 -1
  147. package/dist/runtime/upgrade/index.d.ts +1 -0
  148. package/dist/runtime/upgrade/index.d.ts.map +1 -1
  149. package/dist/runtime/upgrade/index.js +1 -0
  150. package/dist/runtime/upgrade/index.js.map +1 -1
  151. package/dist/vendor/engram-live/contracts.d.ts +825 -0
  152. package/dist/vendor/engram-live/contracts.js +1734 -0
  153. package/fixtures/native-host-catalog.json +1 -0
  154. package/fixtures/native-host-history.json +1261 -0
  155. package/fixtures/native-host-renderers.json +1 -0
  156. package/hooks/deny-manual-h2a-cli.mjs +38 -0
  157. package/hooks/hooks.json +17 -0
  158. package/hooks/vibe-post-agent.mjs +29 -0
  159. package/hooks/vibe-pre-tool.mjs +40 -0
  160. package/package.json +13 -6
  161. package/scripts/qualification-budget.mjs +56 -0
  162. package/scripts/qualification-cleanup.mjs +15 -0
  163. package/scripts/qualification-oracles.mjs +44 -0
  164. package/scripts/qualification-patch.mjs +21 -0
  165. package/scripts/qualification-poll-hosts.mjs +19 -0
  166. package/scripts/qualification-probe.mjs +63 -0
  167. package/scripts/qualification-rpc.mjs +59 -0
  168. package/scripts/qualification-vibe.mjs +159 -0
  169. package/scripts/qualify-host.mjs +143 -0
  170. package/skills/h2a/SKILL.md +6 -2
package/dist/cli.js CHANGED
@@ -37,6 +37,7 @@
37
37
  * (`H2A_CLI_VERB_CONTRACTS`). Human-readable reference: `docs/cli-contract.md`.
38
38
  */
39
39
  import { execFileSync, spawn, spawnSync } from "node:child_process";
40
+ import { readAgyClaudeQuotaStatus } from "./runtime/agy-claude.js";
40
41
  import { generateKeyPairSync } from "node:crypto";
41
42
  import { once } from "node:events";
42
43
  import { chmodSync, copyFileSync, existsSync, mkdirSync, readdirSync, realpathSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
@@ -62,6 +63,13 @@ import { runHarnessCli, HARNESS_SKILLS } from "./vendor/harness/index.js";
62
63
  import { buildLaunchIndex } from "./runtime/local-files/launch-index.js";
63
64
  import { renderCommandMap } from "./cli-command-map.js";
64
65
  import { resolveHostConfigRoot } from "./runtime/host-config-root.js";
66
+ import { isNativeHost, NATIVE_HOSTS, REGISTRY_WAITING, stateRoot, vibeHome } from "./hosts/native-paths.js";
67
+ import { convergeNativeHost } from "./hosts/native-convergence.js";
68
+ import { nativeSkillArtifacts } from "./hosts/native-skills.js";
69
+ import { assertNativePath, atomicNativeWrite, snapshot as snapshotNativeFile } from "./hosts/native-files.js";
70
+ import { clearVibeDirectRemoved, editVibeMcpServers, setVibeDirectRemoved, VIBE_MCP_NAME } from "./hosts/vibe-mcp.js";
71
+ import { convergeAfterExplicitUpgrade } from "./hosts/upgrade-equipment.js";
72
+ import { captureHostOperatorNotices } from "./hosts/operator-notices.js";
65
73
  import { H2A_ATTESTER_COMPREHENSION_RIGHT, H2A_COMPREHENSION_ATTESTATION_BODY_KIND, H2A_DECLARATION_INTERET_BODY_KIND, H2A_ORG_MANIFEST_FILENAME, H2A_ORG_PROPOSAL_BODY_KIND, H2A_ORG_RATIFIED_BODY_KIND, H2A_ROLES, H2A_WORK_STATUSES, auditNhiPosture, buildComprehensionAttestation, canAttestComprehension, checkEnvelopeFreshness, computeHash, createEnvelope, deriveWorkspaceId, diffOrgManifest, effectiveOrgInstances, isComprehensionAttestation, nhiAttestationEnvelope, nhiInventory, deriveConnectionConfidence, nhiTrustBundle, orgAssignmentEnvelope, parseOrgManifest, signCanonical, signEnvelope, subagentAddress, validateOrgManifest, verifyComprehensionAttestation } from "@sentropic/h2a";
66
74
  import { H2A_CLAUDE_HOST } from "./hosts/claude.js";
67
75
  import { H2A_CODEX_HOST } from "./hosts/codex.js";
@@ -263,9 +271,9 @@ export function renderCliHelp() {
263
271
  " h2a drumbeat escalations [--root <path>]",
264
272
  " h2a drumbeat relance-inbox [--instance <id>] [--relauncher logging|local-tmux|headless|auto] [--root <path>]",
265
273
  " h2a drumbeat watch [--interval-ms <n>] [--max-relances <n>] [--relauncher logging|local-tmux|remote|headless|auto] [--instance <signer> --private-key <pem>] [--decider logging|<command>] [--decider-after <k>] [--decider-enforce] [--root <path>]",
266
- " h2a host setup --host <codex|claude|gemini|agy|hermes|opencode|muse|vibe> [--endpoint local|remote] [--url <https://…/mcp>] [--root <path>] [--print | --write <file>] [--force] [--no-wake] (selects exactly one h2a endpoint; local renders mcp-serve --auto-open --auto-upgrade --wake auto by default)",
274
+ " h2a host setup --host <codex|claude|gemini|agy|hermes|opencode|muse|vibe> [--endpoint local|remote] [--url <https://…/mcp>] [--root <path>] [--print | --write <file>] [--force] [--no-wake] (selects one endpoint; Muse/agy render nonrecommended historical direct paths pending registry bootstrap; Vibe --write installs the interim direct entry pending registry bootstrap (--remove clears it for migration))",
267
275
  " h2a host status [--host <name>]",
268
- " h2a host plugin --host <codex|claude|gemini|agy|hermes|opencode|muse|vibe> --instance <id> [--status <work-status>] [--root <path>] [--write <settings.json> [--force]] [--scaffold <dir>] (--write installs the Stop hook for claude|gemini|codex|hermes|opencode; --scaffold writes codex's full local marketplace + trust step; vibe records via a post_agent hook in ~/.vibe/hooks.toml; agy and muse are poll-only)",
276
+ " h2a host plugin --host <codex|claude|gemini|agy|hermes|opencode|muse|vibe> --instance <id> [--status <work-status>] [--root <path>] [--write <settings.json|hooks.toml> [--force]] [--scaffold <dir>] (--write installs the Stop hook for claude|gemini|codex|hermes|opencode; --scaffold writes codex's full local marketplace + trust step; vibe writes its explicit parent-only wrapper to VIBE_HOME/hooks.toml; agy and muse have no qualified native hooks)",
269
277
  " h2a store migrate [--from <v>] [--to <v>] [--sanitize-paths] [--dry-run] [--root <path>]",
270
278
  " h2a store index-launch --root <absolute-path> (derived indexes; original logs retained)",
271
279
  "",
@@ -274,7 +282,7 @@ export function renderCliHelp() {
274
282
  " h2a conductor [--workspace <id|path>] [--root <path>] (who is the live conductor/owner of a workspace — derived from presence; conductor=role CONDUCTOR if set, else null; candidates=in-workspace live agents)",
275
283
  " h2a conductor-launch-check [--workspace <id|path>] [--root <path>] [--idle-ms <ms>] (DRY-RUN: polls track workspace-activity; recommends launching a conductor if work is stalled and none is live — h2a does NOT spawn; launch parked pending spawn policy + remote)",
276
284
  " h2a conductor-launch --workspace <id|path> [--root <path>] [--idle-ms <ms>] [--confirm] [--remote <instance>] [--instance <self>] (D3 EMIT: if stalled+no conductor, emits a launch-REQUEST envelope to a live remote agent — gated by --confirm + 1/30min/workspace cap; h2a NEVER spawns; remote does the actual spawn)",
277
- " h2a doctor [--root <path>] [--scan <dir>] [--prune] [--repair] [--dry-run] (--repair converges Claude/Codex plugin installs; --repair --dry-run reports host findings/actions without changing them; --prune deletes host-less/phantom/orphan inbox dirs + stray buses; dry-run by default)",
285
+ " h2a doctor [--root <path>] [--scan <dir>] [--prune] [--repair] [--dry-run] [--host <name>] [--skip-hosts] [--guard on|off] [--lifecycle on|off] (--repair converges detected host components; --repair --dry-run reports host findings/actions without changing them; --prune deletes host-less/phantom/orphan inbox dirs + stray buses; dry-run by default)",
278
286
  " h2a keepalive [--root <path>] [--interval <ms>] [--once] (external keepalive prober — refreshes presence for agents whose tmux pane is still alive)",
279
287
  " h2a rename --instance <id> --name <name> [--root <path>] (set a live session's display name so peers can find it via discover --name)",
280
288
  " h2a status [--root <path>] [--scope <s>] [--instance <i>]",
@@ -1486,19 +1494,20 @@ export function cmdUpgrade(flags, streams, runtime) {
1486
1494
  // the boot auto-upgrade (bounded — no infinite terminal wait). No cachePath is
1487
1495
  // passed, so it always checks fresh and is never throttled for an explicit run.
1488
1496
  const result = performAutoUpgrade(current, { ...(runtime ? { runtime } : {}) });
1497
+ const hosts = convergeAfterExplicitUpgrade(result, flags);
1489
1498
  if (result.outcome === "upgraded") {
1490
- streams.stdout.write(`${JSON.stringify({ ok: true, current, latest: result.target, upgraded: true, verified: result.verifiedVersion, package: H2A_CLI_PACKAGE, ...(result.logPath ? { log: result.logPath } : {}) }, null, 2)}\n`);
1499
+ streams.stdout.write(`${JSON.stringify({ ok: true, current, latest: result.target, upgraded: true, verified: result.verifiedVersion, package: H2A_CLI_PACKAGE, hosts, ...(result.logPath ? { log: result.logPath } : {}) }, null, 2)}\n`);
1491
1500
  return 0;
1492
1501
  }
1493
1502
  if (result.outcome === "already-current") {
1494
- streams.stdout.write(`${JSON.stringify({ ok: true, current, latest: result.target ?? current, upgraded: false, reason: "already current or registry unreachable" }, null, 2)}\n`);
1503
+ streams.stdout.write(`${JSON.stringify({ ok: true, current, latest: result.target ?? current, upgraded: false, hosts, reason: "already current or registry unreachable" }, null, 2)}\n`);
1495
1504
  return 0;
1496
1505
  }
1497
1506
  // The target is published but not yet installable (propagation delay). A full
1498
1507
  // `npm i -g` would hit the same registry and fail too, so we do not force it;
1499
1508
  // the staged path retries on a later run. Nothing was mutated.
1500
1509
  if (result.outcome === "deferred-propagation") {
1501
- streams.stdout.write(`${JSON.stringify({ ok: true, current, latest: result.target, upgraded: false, reason: "update published but not yet installable; retry later", ...(result.logPath ? { log: result.logPath } : {}) }, null, 2)}\n`);
1510
+ streams.stdout.write(`${JSON.stringify({ ok: true, current, latest: result.target, upgraded: false, hosts, reason: "update published but not yet installable; retry later", ...(result.logPath ? { log: result.logPath } : {}) }, null, 2)}\n`);
1502
1511
  return 0;
1503
1512
  }
1504
1513
  // skipped-locked / failed.
@@ -3625,6 +3634,105 @@ function driveLineFromHookInput(raw) {
3625
3634
  }
3626
3635
  return driveLineFromText(raw);
3627
3636
  }
3637
+ function resolveVibeSetupTarget(flags) {
3638
+ if (flags.write && flags.write !== "true")
3639
+ return flags.write;
3640
+ return join(vibeHome(), "config.toml");
3641
+ }
3642
+ function vibeWantedEntry(snippet) {
3643
+ const incoming = snippet.config.mcpServers.h2a;
3644
+ if (typeof incoming.url === "string")
3645
+ return { name: VIBE_MCP_NAME, transport: "streamable-http", url: incoming.url };
3646
+ return { name: VIBE_MCP_NAME, transport: "stdio", command: incoming.command ?? "h2a", args: [...(incoming.args ?? ["mcp-serve"])] };
3647
+ }
3648
+ function vibeStateForTarget(targetPath) {
3649
+ return stateRoot("vibe", dirname(resolvePath(targetPath)));
3650
+ }
3651
+ function cmdVibeSetupWrite(flags, streams, snippet, endpoint) {
3652
+ const targetPath = resolveVibeSetupTarget(flags);
3653
+ if (!targetPath.toLowerCase().endsWith(".toml")) {
3654
+ streams.stderr.write(`h2a host setup: --write for Vibe MCP supports TOML only and will not rewrite ${targetPath}. Use the default <VIBE_HOME>/config.toml.\n`);
3655
+ return 1;
3656
+ }
3657
+ const wanted = vibeWantedEntry(snippet);
3658
+ let original;
3659
+ try {
3660
+ if (!existsSync(targetPath))
3661
+ original = "";
3662
+ else
3663
+ original = readFileSync(targetPath, "utf8");
3664
+ }
3665
+ catch (error) {
3666
+ streams.stderr.write(`h2a host setup: cannot read ${targetPath} (${error.message})\n`);
3667
+ return 3;
3668
+ }
3669
+ let edited;
3670
+ try {
3671
+ edited = editVibeMcpServers(original, wanted);
3672
+ }
3673
+ catch (error) {
3674
+ streams.stderr.write(`h2a host setup: ${targetPath} refused (${error.message}); invalid or incompatible TOML is never overwritten, even with --force.\n`);
3675
+ return 2;
3676
+ }
3677
+ if (!edited.changed) {
3678
+ clearVibeDirectRemoved(vibeStateForTarget(targetPath));
3679
+ streams.stdout.write(`${JSON.stringify({ ok: true, host: "vibe", endpoint, path: targetPath, merged: false, replacedH2a: false, removedH2aMcpServers: [], migration: "voie directe — non migrée" }, null, 2)}\n`);
3680
+ return 0;
3681
+ }
3682
+ try {
3683
+ atomicNativeWrite(targetPath, edited.text, { state: vibeStateForTarget(targetPath), expected: snapshotNativeFile(targetPath) });
3684
+ }
3685
+ catch (error) {
3686
+ streams.stderr.write(`h2a host setup: cannot write ${targetPath} (${error.message})\n`);
3687
+ return 3;
3688
+ }
3689
+ clearVibeDirectRemoved(vibeStateForTarget(targetPath));
3690
+ streams.stdout.write(`${JSON.stringify({ ok: true, host: "vibe", endpoint, path: targetPath, merged: true, replacedH2a: edited.replacedH2a, removedH2aMcpServers: edited.removed, migration: "voie directe — non migrée" }, null, 2)}\n`);
3691
+ streams.stderr.write(`# wrote the interim direct mcp_servers.h2a endpoint for host=vibe to ${targetPath} (owner 16/10, derogation O7.2; migration R5/R7: h2a host setup --host vibe --remove)\n# disabled duplicate h2a MCP entries: ${edited.removed.join(", ") || "none"}\n# ${snippet.path.hint}\n`);
3692
+ return 0;
3693
+ }
3694
+ function cmdVibeSetupRemove(flags, streams) {
3695
+ const targetPath = resolveVibeSetupTarget(flags);
3696
+ if (!targetPath.toLowerCase().endsWith(".toml")) {
3697
+ streams.stderr.write(`h2a host setup: --remove for Vibe MCP supports TOML only and will not rewrite ${targetPath}. Use the default <VIBE_HOME>/config.toml.\n`);
3698
+ return 1;
3699
+ }
3700
+ let original;
3701
+ try {
3702
+ if (!existsSync(targetPath))
3703
+ original = "";
3704
+ else
3705
+ original = readFileSync(targetPath, "utf8");
3706
+ }
3707
+ catch (error) {
3708
+ streams.stderr.write(`h2a host setup: cannot read ${targetPath} (${error.message})\n`);
3709
+ return 3;
3710
+ }
3711
+ let edited;
3712
+ try {
3713
+ edited = editVibeMcpServers(original, null);
3714
+ }
3715
+ catch (error) {
3716
+ streams.stderr.write(`h2a host setup: ${targetPath} refused (${error.message}); invalid or incompatible TOML is never overwritten, even with --force.\n`);
3717
+ return 2;
3718
+ }
3719
+ if (!edited.changed) {
3720
+ setVibeDirectRemoved(vibeStateForTarget(targetPath));
3721
+ streams.stdout.write(`${JSON.stringify({ ok: true, host: "vibe", path: targetPath, removed: false, migration: REGISTRY_WAITING }, null, 2)}\n`);
3722
+ return 0;
3723
+ }
3724
+ try {
3725
+ atomicNativeWrite(targetPath, edited.text, { state: vibeStateForTarget(targetPath), expected: snapshotNativeFile(targetPath) });
3726
+ }
3727
+ catch (error) {
3728
+ streams.stderr.write(`h2a host setup: cannot write ${targetPath} (${error.message})\n`);
3729
+ return 3;
3730
+ }
3731
+ setVibeDirectRemoved(vibeStateForTarget(targetPath));
3732
+ streams.stdout.write(`${JSON.stringify({ ok: true, host: "vibe", path: targetPath, removed: true, removedH2aMcpServers: edited.removed, migration: REGISTRY_WAITING }, null, 2)}\n`);
3733
+ streams.stderr.write(`# removed the interim direct mcp_servers.h2a endpoint for host=vibe from ${targetPath}; registry bootstrap expected.\n`);
3734
+ return 0;
3735
+ }
3628
3736
  function cmdHostSetup(flags, streams, options) {
3629
3737
  const host = flags.host;
3630
3738
  if (!host) {
@@ -3714,9 +3822,16 @@ function cmdHostSetup(flags, streams, options) {
3714
3822
  }
3715
3823
  const targetPath = flags.write;
3716
3824
  const printMode = flags.print === "true" || !targetPath;
3825
+ if (host === "vibe" && flags.remove === "true") {
3826
+ return cmdVibeSetupRemove(flags, streams);
3827
+ }
3828
+ if (host === "vibe" && targetPath) {
3829
+ return cmdVibeSetupWrite(flags, streams, snippet, endpoint);
3830
+ }
3717
3831
  if (printMode && !targetPath) {
3718
- streams.stdout.write(`${JSON.stringify(snippet.config, null, 2)}\n`);
3719
- streams.stderr.write(`# ${host} — selected ${endpoint} h2a endpoint; paste this snippet under \`mcpServers\` in:\n# ${snippet.path.hint}\n# example path: ${snippet.path.example}\n`);
3832
+ streams.stdout.write(`${JSON.stringify(isNativeHost(host) ? { ...snippet.config, migration: REGISTRY_WAITING, hint: snippet.path.hint } : snippet.config, null, 2)}\n`);
3833
+ streams.stderr.write(isNativeHost(host) ? `# ${host}: rendu historique non recommandé; ${REGISTRY_WAITING}.\n# ${snippet.path.hint}\n` :
3834
+ `# ${host} — selected ${endpoint} h2a endpoint; paste this snippet under \`mcpServers\` in:\n# ${snippet.path.hint}\n# example path: ${snippet.path.example}\n`);
3720
3835
  return reportHostSetupCoherence(host, streams, options) ? 0 : 2;
3721
3836
  }
3722
3837
  if (isUnsupportedHostWritePath(host, targetPath)) {
@@ -3803,6 +3918,7 @@ function cmdHostSetup(flags, streams, options) {
3803
3918
  replacedH2a,
3804
3919
  removedH2aMcpServers,
3805
3920
  removedTrackMcpServers,
3921
+ ...(isNativeHost(host) ? { migration: "voie directe — non migrée" } : {}),
3806
3922
  ...(coherent ? {} : { next: "h2a doctor --repair" })
3807
3923
  }, null, 2)}\n`);
3808
3924
  streams.stderr.write(`# wrote the selected ${endpoint} mcpServers.h2a endpoint for host=${host} to ${targetPath}\n# disabled duplicate h2a MCP entries: ${removedH2aMcpServers.join(", ") || "none"}\n# disabled standalone Track MCP entries: ${removedTrackMcpServers.join(", ") || "none"}\n# ${snippet.path.hint}\n`);
@@ -3865,7 +3981,17 @@ function cmdHostStatus(flags, streams) {
3865
3981
  mcpAdapterShipped,
3866
3982
  hostSetupShipped,
3867
3983
  hostScenarioShipped,
3868
- summary
3984
+ summary: hostScenarioShipped ? summary.replace('scenario shipped', 'rendu testé') : summary,
3985
+ ...(isNativeHost(descriptor.host) ? { native: (() => {
3986
+ try {
3987
+ return nativeHostReport(descriptor.host, flags, false, false, undefined, streams.cwd?.());
3988
+ }
3989
+ catch (error) {
3990
+ return { ok: false, installation: 'inspection impossible', error: error.message };
3991
+ }
3992
+ })() } : {
3993
+ convergence: ['claude', 'codex'].includes(descriptor.host) ? 'historical doctor convergence; native parity unverified; registry non migré' : 'non couvert'
3994
+ })
3869
3995
  };
3870
3996
  });
3871
3997
  streams.stdout.write(`${JSON.stringify({ ok: true, hosts }, null, 2)}\n`);
@@ -3885,6 +4011,24 @@ function cmdHostPlugin(flags, streams) {
3885
4011
  streams.stderr.write("h2a host plugin: --instance <id> is required\n");
3886
4012
  return 1;
3887
4013
  }
4014
+ if (flags.host === 'vibe') {
4015
+ try {
4016
+ if (flags.instance === 'auto')
4017
+ throw new Error('non disponible — interface B non livrée');
4018
+ if (flags.write && resolvePath(flags.write) !== join(vibeHome(), 'hooks.toml')) {
4019
+ streams.stderr.write('h2a host plugin: this target is not available for vibe; post_agent requires the effective <VIBE_HOME>/hooks.toml TOML file.\n');
4020
+ return 1;
4021
+ }
4022
+ const result = nativeHostReport('vibe', flags, !!flags.write, false, undefined, streams.cwd?.());
4023
+ streams.stdout.write(`${JSON.stringify({ ...result, push: true, mechanism: 'vibe-hooks', record: 'rendered' in result ? result.rendered : '',
4024
+ receive: 'N-A', hint: 'post_agent in <VIBE_HOME>/hooks.toml; ' + ('lifecycleScope' in result ? result.lifecycleScope : 'hôte absent') }, null, 2)}\n`);
4025
+ return result.ok ? 0 : 2;
4026
+ }
4027
+ catch (error) {
4028
+ streams.stderr.write(`h2a host plugin: ${error.message}\n`);
4029
+ return 2;
4030
+ }
4031
+ }
3888
4032
  const render = renderStopHook(flags.host, {
3889
4033
  instance: flags.instance,
3890
4034
  ...(flags.root ? { root: flags.root } : {}),
@@ -4715,10 +4859,19 @@ export function cmdConductorLaunch(argv, streams, opts) {
4715
4859
  return 0;
4716
4860
  }
4717
4861
  function cmdDoctor(flags, streams, options = {}) {
4862
+ if (flags.host && !isNativeHost(flags.host) && !['claude', 'codex'].includes(flags.host)) {
4863
+ streams.stderr.write('h2a doctor: --host must be claude|codex|vibe|muse|agy\n');
4864
+ return 1;
4865
+ }
4866
+ if ((flags.guard || flags.lifecycle) && flags.host !== 'vibe') {
4867
+ streams.stderr.write('h2a doctor: --guard/--lifecycle require --host vibe\n');
4868
+ return 1;
4869
+ }
4718
4870
  const cwd = streams.cwd ?? (() => process.cwd());
4719
4871
  const root = resolveRoot(flags, cwd);
4720
4872
  const report = {
4721
4873
  ok: true,
4874
+ agyClaudeQuota: readAgyClaudeQuotaStatus(),
4722
4875
  root,
4723
4876
  warnings: [],
4724
4877
  checks: {}
@@ -4793,9 +4946,10 @@ function cmdDoctor(flags, streams, options = {}) {
4793
4946
  // is allowed to touch host configuration/caches and invoke native host CLIs.
4794
4947
  // That keeps an ordinary isolated-bus probe independent of the operator's
4795
4948
  // personal Claude/Codex setup while retaining a fail-closed repair surface.
4796
- if (flags.repair === "true") {
4949
+ if (flags.repair === "true" && (!flags.host || ['claude', 'codex'].includes(flags.host))) {
4797
4950
  const dryRun = flags["dry-run"] === "true";
4798
- const hostInstallations = (options.doctorHostInstallations ?? doctorHostInstallations)({ repair: true, dryRun });
4951
+ const hostInstallations = (options.doctorHostInstallations ?? doctorHostInstallations)({ repair: true, dryRun,
4952
+ ...(flags.host ? { hosts: [flags.host] } : {}) });
4799
4953
  checks.hostInstallations = hostInstallations;
4800
4954
  if (!hostInstallations.ok) {
4801
4955
  report.ok = false;
@@ -4844,6 +4998,21 @@ function cmdDoctor(flags, streams, options = {}) {
4844
4998
  message: "pass --repair to detect and converge Claude/Codex host installation drift"
4845
4999
  };
4846
5000
  }
5001
+ if (flags['skip-hosts'] !== 'true') {
5002
+ const selection = flags.host ? isNativeHost(flags.host) ? [flags.host] : [] : NATIVE_HOSTS;
5003
+ const hosts = selection.map(host => {
5004
+ try {
5005
+ const { instance, ...nativeFlags } = flags;
5006
+ return nativeHostReport(host, nativeFlags, flags.repair === 'true', false, undefined, cwd());
5007
+ }
5008
+ catch (error) {
5009
+ return { host, ok: false, installation: 'inspection impossible', error: error.message };
5010
+ }
5011
+ });
5012
+ checks.nativeHostInstallations = { ok: hosts.every(host => host.ok), hosts };
5013
+ if (!hosts.every(host => host.ok))
5014
+ report.ok = false;
5015
+ }
4847
5016
  // ── Warning checks (do NOT flip report.ok) ──────────────────────────────
4848
5017
  // (a) rootSource: record where the root came from
4849
5018
  const rootInfo = resolveRootInfo(flags, cwd);
@@ -5453,7 +5622,9 @@ function cmdConnect(flags, streams) {
5453
5622
  const followUp = [
5454
5623
  flags.host === "remote"
5455
5624
  ? "Use the bridge-provided environment in the remote session Pod"
5456
- : `Merge the snippet above under \`mcpServers\` in ${steps[1].pathExample}`,
5625
+ : flags.host === "vibe" ? `Entrée directe intérimaire (décision owner 16/10, dérogation O7.2) : h2a host setup --host vibe --write ; migration registre R5/R7 : h2a host setup --host vibe --remove puis bootstrap.`
5626
+ : isNativeHost(flags.host) ? `Rendu historique non recommandé — ${REGISTRY_WAITING}; installation et activation par l’intégrateur registre.`
5627
+ : `Merge the snippet above under \`mcpServers\` in ${steps[1].pathExample}`,
5457
5628
  identity.privateKeyPath
5458
5629
  ? `keypair ready: ${identity.privateKeyPath}`
5459
5630
  : `legacy override: run h2a keys generate --instance ${instance} --root ${root} if needed`,
@@ -5565,7 +5736,7 @@ function targetSpecFor(host, cwd) {
5565
5736
  // installed skills are listed at session open.
5566
5737
  return {
5567
5738
  host: "vibe",
5568
- userBase: join(homedir(), ".vibe", "skills"),
5739
+ userBase: join(vibeHome(), "skills"),
5569
5740
  projectBase: join(cwd, ".vibe", "skills"),
5570
5741
  extension: "SKILL.md",
5571
5742
  write: (base, skillName, _parsed, raw) => {
@@ -5704,7 +5875,7 @@ function readSkillFrom(srcDir, dirName, source, renameTo) {
5704
5875
  raw = raw.replace(/^(name:[ \t]*).*$/m, `$1${installName}`);
5705
5876
  parsed = { ...parsed, name: installName };
5706
5877
  }
5707
- return { kind: "skill", skill: { installName, parsed, raw, source } };
5878
+ return { kind: "skill", skill: { installName, parsed, raw, source, resourceDir: join(srcDir, dirName) } };
5708
5879
  }
5709
5880
  /**
5710
5881
  * Resolve the on-disk `skills/` directory of an installed dependency package
@@ -5812,6 +5983,15 @@ function collectInstallableSkills() {
5812
5983
  return { skills, sources, error: harnessRes.error };
5813
5984
  return { skills, sources };
5814
5985
  }
5986
+ function nativeHostReport(host, flags, repair, explicitInstall = false, root, cwd) {
5987
+ const collection = collectInstallableSkills();
5988
+ if (collection.error)
5989
+ throw new Error(collection.error.message);
5990
+ return convergeNativeHost({ host, root, cwd, version: currentCliVersion(), skills: collection.skills, renderGemini: renderSkillAsGeminiToml,
5991
+ sourcesComplete: collection.sources.every(s => s.dir !== null && s.count > 0), repair, explicitInstall,
5992
+ dryRun: flags['dry-run'] === 'true', force: flags.force === 'true', guard: flags.guard, lifecycle: flags.lifecycle,
5993
+ instance: flags.instance, busRoot: flags.root, status: flags.status });
5994
+ }
5815
5995
  function cmdInstallSkills(flags, streams) {
5816
5996
  const host = flags.host;
5817
5997
  if (!host) {
@@ -5841,8 +6021,23 @@ function cmdInstallSkills(flags, streams) {
5841
6021
  return collection.error.exit;
5842
6022
  }
5843
6023
  const targetBase = scope === "user" ? spec.userBase : spec.projectBase;
6024
+ if (scope === 'user' && (isNativeHost(host) || host === 'gemini')) {
6025
+ try {
6026
+ const result = nativeHostReport(host, flags, true, true, dirname(targetBase), cwd());
6027
+ streams.stdout.write(`${JSON.stringify({ ...result, scope, targetBase, installed: 'changed' in result ? result.changed : [], sources: collection.sources,
6028
+ prunedLegacy: [], skipped: 'conflicts' in result ? result.conflicts.map(path => ({ path, reason: 'customized or unknown provenance; preserved' })) : [],
6029
+ ...(host === 'muse' ? { verifyHint: 'muse skills list # project scope requires workspace trust' } : {}),
6030
+ ...(host === 'vibe' ? { verifyHint: 'vibe # skills load at session open; nouvelle session ou reprise propre' } : {}),
6031
+ ...(host === 'agy' ? { importHint: 'agy plugin import gemini # then: agy plugin enable h2a' } : {}) }, null, 2)}\n`);
6032
+ return result.ok ? 0 : 2;
6033
+ }
6034
+ catch (error) {
6035
+ streams.stderr.write(`h2a install-skills: ${error.message}\n`);
6036
+ return 3;
6037
+ }
6038
+ }
5844
6039
  // DEC-057: prune the pre-consolidation skill names if they linger on disk.
5845
- const prunedLegacy = pruneLegacy(spec, targetBase);
6040
+ const prunedLegacy = isNativeHost(host) || host === 'gemini' ? [] : pruneLegacy(spec, targetBase);
5846
6041
  const installed = [];
5847
6042
  const skipped = [];
5848
6043
  for (const skill of collection.skills) {
@@ -5860,7 +6055,18 @@ function cmdInstallSkills(flags, streams) {
5860
6055
  continue;
5861
6056
  }
5862
6057
  try {
5863
- const targetPath = spec.write(targetBase, skillName, skill.parsed, skill.raw);
6058
+ let targetPath;
6059
+ if (scope === 'project' && (isNativeHost(host) || host === 'gemini')) {
6060
+ const artifacts = nativeSkillArtifacts({ host, root: dirname(targetBase), project: true, version: currentCliVersion(), skills: [skill], renderGemini: renderSkillAsGeminiToml, historicalHashes: () => [] });
6061
+ for (const artifact of artifacts) {
6062
+ assertNativePath(artifact.path);
6063
+ mkdirSync(dirname(artifact.path), { recursive: true });
6064
+ writeFileSync(artifact.path, artifact.bytes);
6065
+ }
6066
+ targetPath = probeTarget;
6067
+ }
6068
+ else
6069
+ targetPath = spec.write(targetBase, skillName, skill.parsed, skill.raw);
5864
6070
  installed.push(targetPath);
5865
6071
  }
5866
6072
  catch (error) {
@@ -6268,6 +6474,10 @@ export function runCli(argv = process.argv.slice(2), streams = {
6268
6474
  stderr: process.stderr
6269
6475
  }, options = {}) {
6270
6476
  const { command, flags } = parseFlags(argv);
6477
+ if (streams.stderr === process.stderr && process.stderr.isTTY) {
6478
+ for (const notice of captureHostOperatorNotices())
6479
+ streams.stderr.write(`${notice}\n`);
6480
+ }
6271
6481
  if (command && TRACK_FACADE_VERBS.has(command)) {
6272
6482
  // ④: read-only + sync-write verbs run in-process; `focus` (async) keeps
6273
6483
  // shelling out. Same `.track`, same lock. A native WRITE never falls back to