@ken-jo/agent-connector 0.4.67 → 0.4.75

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 (160) hide show
  1. package/README.md +43 -6
  2. package/dist/{action-RUM6GP23.js → action-TCKBTTZX.js} +8 -8
  3. package/dist/{amazon-q-KXVJFT7Q.js → amazon-q-CB4XFX7T.js} +3 -3
  4. package/dist/{amp-WAPHJYTK.js → amp-6Q5OYHNW.js} +7 -3
  5. package/dist/amp-6Q5OYHNW.js.map +1 -0
  6. package/dist/{antigravity-GF3RU42A.js → antigravity-WIK3XBN5.js} +4 -4
  7. package/dist/{antigravity-cli-OH27IFH5.js → antigravity-cli-L3RZMF6V.js} +4 -4
  8. package/dist/{chunk-E45SUUD7.js → chunk-24K6JOKV.js} +3 -3
  9. package/dist/{chunk-IZ4XQ23W.js → chunk-2L6LTQ6L.js} +41 -6
  10. package/dist/chunk-2L6LTQ6L.js.map +1 -0
  11. package/dist/{chunk-RQCBBLTA.js → chunk-5LAFKXFM.js} +2 -2
  12. package/dist/{chunk-UVBAH263.js → chunk-7ITLLYWB.js} +2 -2
  13. package/dist/{chunk-DBQMX75U.js → chunk-BEFVJ2OE.js} +28 -2
  14. package/dist/chunk-BEFVJ2OE.js.map +1 -0
  15. package/dist/{chunk-ZSMGHEB5.js → chunk-DI6OWKH2.js} +7 -3
  16. package/dist/chunk-DI6OWKH2.js.map +1 -0
  17. package/dist/chunk-ECSRTK4M.js +386 -0
  18. package/dist/chunk-ECSRTK4M.js.map +1 -0
  19. package/dist/{chunk-F5COBB5F.js → chunk-FUXUEXDP.js} +3 -3
  20. package/dist/{chunk-NXR4HM5N.js → chunk-HKM3HUOK.js} +19 -19
  21. package/dist/{chunk-NXR4HM5N.js.map → chunk-HKM3HUOK.js.map} +1 -1
  22. package/dist/{chunk-P5KA5NVR.js → chunk-MDZG5QHB.js} +49 -3
  23. package/dist/chunk-MDZG5QHB.js.map +1 -0
  24. package/dist/{chunk-CSRBMJLU.js → chunk-MHDQWZ4A.js} +5 -5
  25. package/dist/{chunk-RHML2NOB.js → chunk-NUGMVVV2.js} +2 -2
  26. package/dist/chunk-NUGMVVV2.js.map +1 -0
  27. package/dist/{chunk-ZEFUDBTY.js → chunk-OEQJGBBW.js} +4 -4
  28. package/dist/{chunk-3Y23ZYYF.js → chunk-Q42SEI7W.js} +3 -3
  29. package/dist/{chunk-LS65GL2P.js → chunk-Q5LECKZL.js} +36 -36
  30. package/dist/{chunk-GCRRX4MO.js → chunk-TW4DVR4V.js} +2 -2
  31. package/dist/{claude-code-WLN43K7I.js → claude-code-HFBAAVWS.js} +10 -6
  32. package/dist/claude-code-HFBAAVWS.js.map +1 -0
  33. package/dist/cli/sdk.js +4 -4
  34. package/dist/cli.js +1 -1
  35. package/dist/{cline-PEGTGVQD.js → cline-26W4FEZ6.js} +3 -3
  36. package/dist/{codebuff-UG6LVSOM.js → codebuff-J5KEEBIL.js} +7 -3
  37. package/dist/codebuff-J5KEEBIL.js.map +1 -0
  38. package/dist/{codex-4LVDQXCD.js → codex-JKQ6TLRI.js} +16 -23
  39. package/dist/codex-JKQ6TLRI.js.map +1 -0
  40. package/dist/{continue-DYV5V55Y.js → continue-KQSJUSWX.js} +3 -3
  41. package/dist/{copilot-cli-NVFXFLUF.js → copilot-cli-YBNKLYUB.js} +65 -22
  42. package/dist/copilot-cli-YBNKLYUB.js.map +1 -0
  43. package/dist/{crush-PP4HYZLT.js → crush-JTWTZIPB.js} +20 -10
  44. package/dist/crush-JTWTZIPB.js.map +1 -0
  45. package/dist/{cursor-XMXOZKAP.js → cursor-2NIZSDZ4.js} +4 -4
  46. package/dist/{detect-IZOWP5AA.js → detect-CWEIQCRC.js} +4 -4
  47. package/dist/{doctor-5IVUQ2YH.js → doctor-AC437ZAW.js} +95 -13
  48. package/dist/doctor-AC437ZAW.js.map +1 -0
  49. package/dist/{droid-ETNOUIPJ.js → droid-HF2AIFB2.js} +3 -3
  50. package/dist/{gemini-cli-P7XJXWVH.js → gemini-cli-2EOK26S2.js} +3 -3
  51. package/dist/{goose-UZVA6MQC.js → goose-55JOTXS5.js} +3 -3
  52. package/dist/{hermes-IC6R4CII.js → hermes-QVZOZU4B.js} +3 -3
  53. package/dist/{hook-7IUPIHCZ.js → hook-VYD3OCLM.js} +8 -8
  54. package/dist/index.d.ts +2 -2
  55. package/dist/index.js +2 -2
  56. package/dist/{install-EP6GPQ65.js → install-S6BYIJ62.js} +11 -11
  57. package/dist/{introspect-BFcXpfUp.d.ts → introspect-5o5ick0_.d.ts} +9 -4
  58. package/dist/{jetbrains-copilot-MZO2RQGJ.js → jetbrains-copilot-DZ2ATXFN.js} +2 -2
  59. package/dist/{kilo-CCB34CQQ.js → kilo-GJNSBWVV.js} +3 -3
  60. package/dist/{kilo-cli-EOMN3WC7.js → kilo-cli-2CCB3DBI.js} +3 -3
  61. package/dist/{kimi-GUSJME55.js → kimi-YRPCSB6N.js} +3 -3
  62. package/dist/{kiro-6OHZ5RGV.js → kiro-BUOQFASX.js} +3 -3
  63. package/dist/{leaderboard-6I2E5XZK.js → leaderboard-SUSUDKHR.js} +2 -2
  64. package/dist/{mimo-code-ZPJJ6IIW.js → mimo-code-V4FP5PUJ.js} +3 -3
  65. package/dist/{mux-AFTVMGGM.js → mux-CMJSM42O.js} +3 -3
  66. package/dist/{nemoclaw-D5EN4G2Q.js → nemoclaw-VP56PGKC.js} +4 -4
  67. package/dist/{omp-GKI2PZ7G.js → omp-OOFGD3GG.js} +3 -3
  68. package/dist/{openclaw-A76PCNBV.js → openclaw-V73XHPXP.js} +4 -4
  69. package/dist/{opencode-M34E6PI7.js → opencode-MKLHSQRD.js} +3 -3
  70. package/dist/{package-BWLV24OO.js → package-KOAAVKHH.js} +9 -9
  71. package/dist/{pi-HVG6ZWFE.js → pi-NMVL7OFL.js} +2 -2
  72. package/dist/{qwen-code-OWLM3I5P.js → qwen-code-2XE2T6F4.js} +3 -3
  73. package/dist/{roo-code-RFKKTNNI.js → roo-code-YJOIKCCS.js} +3 -3
  74. package/dist/runtime/index.d.ts +1 -1
  75. package/dist/runtime/index.js +6 -6
  76. package/dist/sdk/index.d.ts +3 -3
  77. package/dist/sdk/index.js +3 -3
  78. package/dist/sdk/test.d.ts +33 -3
  79. package/dist/sdk/test.js +10 -280
  80. package/dist/sdk/test.js.map +1 -1
  81. package/dist/{serve-CM4HZPMP.js → serve-BU23QUSJ.js} +8 -8
  82. package/dist/{status-BPB4VLQX.js → status-N5LCQQ3R.js} +6 -6
  83. package/dist/{statusline-HIKR2I4Q.js → statusline-442XOF7R.js} +7 -7
  84. package/dist/{telemetry-SBVUJYNE.js → telemetry-V4YQL2NU.js} +5 -5
  85. package/dist/{trae-FVHQALK3.js → trae-QSV2JZFT.js} +3 -3
  86. package/dist/{types-ChUrvw0j.d.ts → types-D6RWGXm1.d.ts} +13 -0
  87. package/dist/{uninstall-MO3RGGVE.js → uninstall-WGEKTCDZ.js} +11 -11
  88. package/dist/{upgrade-6XIGSPGY.js → upgrade-IH7CKPTO.js} +11 -11
  89. package/dist/{usage-IBN36ZVW.js → usage-DI7XRCKM.js} +2 -2
  90. package/dist/{usage-event-4RJP37K6.js → usage-event-2FCU55AN.js} +7 -7
  91. package/dist/{vscode-copilot-6FLDRTKV.js → vscode-copilot-R23RTVST.js} +7 -3
  92. package/dist/vscode-copilot-R23RTVST.js.map +1 -0
  93. package/dist/{warp-7CC52UJV.js → warp-B72XSQ5G.js} +3 -3
  94. package/dist/{windsurf-6ZLQMBQW.js → windsurf-642VBMQ2.js} +3 -3
  95. package/dist/{zed-FULJMNBV.js → zed-6UJS7JKB.js} +3 -3
  96. package/package.json +1 -1
  97. package/dist/amp-WAPHJYTK.js.map +0 -1
  98. package/dist/chunk-DBQMX75U.js.map +0 -1
  99. package/dist/chunk-IZ4XQ23W.js.map +0 -1
  100. package/dist/chunk-P5KA5NVR.js.map +0 -1
  101. package/dist/chunk-RHML2NOB.js.map +0 -1
  102. package/dist/chunk-ZSMGHEB5.js.map +0 -1
  103. package/dist/claude-code-WLN43K7I.js.map +0 -1
  104. package/dist/codebuff-UG6LVSOM.js.map +0 -1
  105. package/dist/codex-4LVDQXCD.js.map +0 -1
  106. package/dist/copilot-cli-NVFXFLUF.js.map +0 -1
  107. package/dist/crush-PP4HYZLT.js.map +0 -1
  108. package/dist/doctor-5IVUQ2YH.js.map +0 -1
  109. package/dist/vscode-copilot-6FLDRTKV.js.map +0 -1
  110. /package/dist/{action-RUM6GP23.js.map → action-TCKBTTZX.js.map} +0 -0
  111. /package/dist/{amazon-q-KXVJFT7Q.js.map → amazon-q-CB4XFX7T.js.map} +0 -0
  112. /package/dist/{antigravity-GF3RU42A.js.map → antigravity-WIK3XBN5.js.map} +0 -0
  113. /package/dist/{antigravity-cli-OH27IFH5.js.map → antigravity-cli-L3RZMF6V.js.map} +0 -0
  114. /package/dist/{chunk-E45SUUD7.js.map → chunk-24K6JOKV.js.map} +0 -0
  115. /package/dist/{chunk-RQCBBLTA.js.map → chunk-5LAFKXFM.js.map} +0 -0
  116. /package/dist/{chunk-UVBAH263.js.map → chunk-7ITLLYWB.js.map} +0 -0
  117. /package/dist/{chunk-F5COBB5F.js.map → chunk-FUXUEXDP.js.map} +0 -0
  118. /package/dist/{chunk-CSRBMJLU.js.map → chunk-MHDQWZ4A.js.map} +0 -0
  119. /package/dist/{chunk-ZEFUDBTY.js.map → chunk-OEQJGBBW.js.map} +0 -0
  120. /package/dist/{chunk-3Y23ZYYF.js.map → chunk-Q42SEI7W.js.map} +0 -0
  121. /package/dist/{chunk-LS65GL2P.js.map → chunk-Q5LECKZL.js.map} +0 -0
  122. /package/dist/{chunk-GCRRX4MO.js.map → chunk-TW4DVR4V.js.map} +0 -0
  123. /package/dist/{cline-PEGTGVQD.js.map → cline-26W4FEZ6.js.map} +0 -0
  124. /package/dist/{continue-DYV5V55Y.js.map → continue-KQSJUSWX.js.map} +0 -0
  125. /package/dist/{cursor-XMXOZKAP.js.map → cursor-2NIZSDZ4.js.map} +0 -0
  126. /package/dist/{detect-IZOWP5AA.js.map → detect-CWEIQCRC.js.map} +0 -0
  127. /package/dist/{droid-ETNOUIPJ.js.map → droid-HF2AIFB2.js.map} +0 -0
  128. /package/dist/{gemini-cli-P7XJXWVH.js.map → gemini-cli-2EOK26S2.js.map} +0 -0
  129. /package/dist/{goose-UZVA6MQC.js.map → goose-55JOTXS5.js.map} +0 -0
  130. /package/dist/{hermes-IC6R4CII.js.map → hermes-QVZOZU4B.js.map} +0 -0
  131. /package/dist/{hook-7IUPIHCZ.js.map → hook-VYD3OCLM.js.map} +0 -0
  132. /package/dist/{install-EP6GPQ65.js.map → install-S6BYIJ62.js.map} +0 -0
  133. /package/dist/{jetbrains-copilot-MZO2RQGJ.js.map → jetbrains-copilot-DZ2ATXFN.js.map} +0 -0
  134. /package/dist/{kilo-CCB34CQQ.js.map → kilo-GJNSBWVV.js.map} +0 -0
  135. /package/dist/{kilo-cli-EOMN3WC7.js.map → kilo-cli-2CCB3DBI.js.map} +0 -0
  136. /package/dist/{kimi-GUSJME55.js.map → kimi-YRPCSB6N.js.map} +0 -0
  137. /package/dist/{kiro-6OHZ5RGV.js.map → kiro-BUOQFASX.js.map} +0 -0
  138. /package/dist/{leaderboard-6I2E5XZK.js.map → leaderboard-SUSUDKHR.js.map} +0 -0
  139. /package/dist/{mimo-code-ZPJJ6IIW.js.map → mimo-code-V4FP5PUJ.js.map} +0 -0
  140. /package/dist/{mux-AFTVMGGM.js.map → mux-CMJSM42O.js.map} +0 -0
  141. /package/dist/{nemoclaw-D5EN4G2Q.js.map → nemoclaw-VP56PGKC.js.map} +0 -0
  142. /package/dist/{omp-GKI2PZ7G.js.map → omp-OOFGD3GG.js.map} +0 -0
  143. /package/dist/{openclaw-A76PCNBV.js.map → openclaw-V73XHPXP.js.map} +0 -0
  144. /package/dist/{opencode-M34E6PI7.js.map → opencode-MKLHSQRD.js.map} +0 -0
  145. /package/dist/{package-BWLV24OO.js.map → package-KOAAVKHH.js.map} +0 -0
  146. /package/dist/{pi-HVG6ZWFE.js.map → pi-NMVL7OFL.js.map} +0 -0
  147. /package/dist/{qwen-code-OWLM3I5P.js.map → qwen-code-2XE2T6F4.js.map} +0 -0
  148. /package/dist/{roo-code-RFKKTNNI.js.map → roo-code-YJOIKCCS.js.map} +0 -0
  149. /package/dist/{serve-CM4HZPMP.js.map → serve-BU23QUSJ.js.map} +0 -0
  150. /package/dist/{status-BPB4VLQX.js.map → status-N5LCQQ3R.js.map} +0 -0
  151. /package/dist/{statusline-HIKR2I4Q.js.map → statusline-442XOF7R.js.map} +0 -0
  152. /package/dist/{telemetry-SBVUJYNE.js.map → telemetry-V4YQL2NU.js.map} +0 -0
  153. /package/dist/{trae-FVHQALK3.js.map → trae-QSV2JZFT.js.map} +0 -0
  154. /package/dist/{uninstall-MO3RGGVE.js.map → uninstall-WGEKTCDZ.js.map} +0 -0
  155. /package/dist/{upgrade-6XIGSPGY.js.map → upgrade-IH7CKPTO.js.map} +0 -0
  156. /package/dist/{usage-IBN36ZVW.js.map → usage-DI7XRCKM.js.map} +0 -0
  157. /package/dist/{usage-event-4RJP37K6.js.map → usage-event-2FCU55AN.js.map} +0 -0
  158. /package/dist/{warp-7CC52UJV.js.map → warp-B72XSQ5G.js.map} +0 -0
  159. /package/dist/{windsurf-6ZLQMBQW.js.map → windsurf-642VBMQ2.js.map} +0 -0
  160. /package/dist/{zed-FULJMNBV.js.map → zed-6UJS7JKB.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/test-harness.ts"],"sourcesContent":["/**\n * sdk/test-harness — the SHIPPED, OFFLINE behavioral harness.\n *\n * Two read-only tools a connector author runs WITHOUT installing anything or\n * touching the host's filesystem:\n *\n * • `explain(connector)` — the static per-host × per-DECLARED-surface matrix:\n * for every registered host and every surface the connector actually ships,\n * is it `native` (the host can honor it), `disabled` (the connector opted\n * out for that host via `platforms[host].<surface> === false`), or\n * `skip-warn` (the host cannot honor it → install would skip-warn)?\n *\n * • `simulate(connector, opts)` — runs the REAL adapter parse → handler →\n * format chain INLINE against a host-shaped raw payload and reports whether\n * the host actually HONORS the connector's response (the trustworthy part:\n * it surfaces the documented degradations, e.g. Codex silently dropping a\n * UserPromptSubmit \"context\" injection that has no stdout path).\n *\n * It deliberately does NOT import the runtime entrypoints (runHook /\n * runStatusline) — those load the REGISTERED connector from disk and record\n * telemetry. The harness instead re-implements the tiny parse→handler→format\n * chain against the in-memory connector + the adapter, mirroring the runtime's\n * input tolerance (empty/malformed payload → `{}`) and its fail-safe envelope.\n */\n\nimport type {\n HookEventName,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n PlatformOverride,\n ResolvedConnector,\n} from \"../core/types.js\";\nimport { allAdapters, loadAdapter } from \"../adapters/registry.js\";\nimport type { NormalizedEvent } from \"../adapters/spi.js\";\nimport {\n compileMatcher,\n eventMatcherSubject,\n} from \"../runtime/hook-entrypoint.js\";\nimport type { SurfaceName } from \"./introspect.js\";\nimport { hostCanFireEvent, SURFACE_PREDICATES } from \"./introspect.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// explain — the static per-host × per-declared-surface matrix\n// ─────────────────────────────────────────────────────────────────────────\n\n/** One cell of the {@link explain} matrix: a host × a declared surface. */\nexport interface ExplainRow {\n host: PlatformId;\n surface: SurfaceName;\n /**\n * - \"native\" — the host's capabilities pass the surface predicate.\n * - \"disabled\" — the connector opted out for this host\n * (`platforms[host].<surface> === false`).\n * - \"skip-warn\" — the host cannot honor it; install would skip-warn.\n */\n support: \"native\" | \"skip-warn\" | \"disabled\";\n reason: string;\n}\n\n/**\n * The GLOBAL surfaces a connector declares (these apply to every host — only\n * declared surfaces get a matrix row). The two platform-scoped surfaces\n * (`configPatch` / `nativeHooks`) are deliberately EXCLUDED here: they are\n * declared under one specific `platforms[host]`, so each is added PER HOST in\n * {@link explain} (see {@link platformScopedSurfacesFor}) — adding them globally\n * would falsely promise a configPatch row on hosts that never declared it.\n */\nfunction declaredGlobalSurfaces(connector: ResolvedConnector): SurfaceName[] {\n const out: SurfaceName[] = [];\n if (connector.server) out.push(\"server\");\n if (Object.keys(connector.hooks).length > 0) out.push(\"hooks\");\n if (connector.commands.length > 0) out.push(\"commands\");\n if (connector.skills.length > 0) out.push(\"skills\");\n if (connector.subagents.length > 0) out.push(\"subagents\");\n if (connector.memory.length > 0) out.push(\"memory\");\n if (connector.statusline) out.push(\"statusline\");\n if (connector.actions.length > 0) out.push(\"actions\");\n return out;\n}\n\n/**\n * The platform-scoped surfaces (`configPatch` / `nativeHooks`) THIS host\n * actually declares — keyed off the host's own `platforms[host]` override, so a\n * configPatch declared under claude-code never shows up as a row for codex.\n */\nfunction platformScopedSurfacesFor(\n override: PlatformOverride | undefined,\n): SurfaceName[] {\n const out: SurfaceName[] = [];\n if (!override) return out;\n if ((override.configPatch?.length ?? 0) > 0) out.push(\"configPatch\");\n if (override.nativeHooks != null && Object.keys(override.nativeHooks).length > 0) {\n out.push(\"nativeHooks\");\n }\n return out;\n}\n\n/**\n * Is the surface explicitly DISABLED for this host? Mirrors the per-host opt-out\n * the installer honors: a boolean-or-object surface override is \"disabled\" only\n * when set to the literal `false` (the object form is a tuning, not an opt-out).\n * `configPatch` / `nativeHooks` have no boolean opt-out form — declaring them is\n * the opt-in, so they are never \"disabled\".\n */\nfunction isDisabledForHost(\n connector: ResolvedConnector,\n host: PlatformId,\n surface: SurfaceName,\n): boolean {\n const override = connector.platforms[host];\n if (!override) return false;\n switch (surface) {\n case \"server\":\n return override.server === false;\n case \"hooks\":\n return override.hooks === false;\n case \"commands\":\n return override.commands === false;\n case \"skills\":\n return override.skills === false;\n case \"subagents\":\n return override.subagents === false;\n case \"memory\":\n return override.memory === false;\n case \"statusline\":\n return override.statusline === false;\n case \"actions\":\n case \"configPatch\":\n case \"nativeHooks\":\n // No per-host boolean opt-out form (declaring them is the opt-in).\n return false;\n }\n}\n\n/**\n * The static support matrix: every registered host × every surface the\n * connector declares. Rows are sorted by host then surface for stable output.\n * Pure read of the adapter capabilities — installs nothing, writes nothing.\n */\nexport async function explain(connector: ResolvedConnector): Promise<ExplainRow[]> {\n const globalSurfaces = declaredGlobalSurfaces(connector);\n const adapters = await allAdapters();\n const rows: ExplainRow[] = [];\n\n for (const adapter of adapters) {\n // Per-host surface set = the global surfaces every host gets a row for, plus\n // the platform-scoped surfaces THIS host actually declares (configPatch /\n // nativeHooks live under platforms[host], so they are host-local).\n const override = connector.platforms[adapter.id];\n const surfaces = [\n ...globalSurfaces,\n ...platformScopedSurfacesFor(override),\n ];\n for (const surface of surfaces) {\n if (isDisabledForHost(connector, adapter.id, surface)) {\n rows.push({\n host: adapter.id,\n surface,\n support: \"disabled\",\n reason: `connector opted out for ${adapter.id} (platforms.${adapter.id}.${surface} = false)`,\n });\n continue;\n }\n // The hooks surface is judged against the connector's SPECIFIC declared\n // events, not the coarse \"host has a hook runtime\" predicate — otherwise a\n // Stop-only connector falsely shows `native` on a PreToolUse-only host\n // (the host CAN fire a hook, just not the one this connector declared).\n if (surface === \"hooks\") {\n rows.push(hooksRow(connector, adapter.id, adapter.capabilities));\n continue;\n }\n const native = SURFACE_PREDICATES[surface](adapter.capabilities);\n rows.push({\n host: adapter.id,\n surface,\n support: native ? \"native\" : \"skip-warn\",\n reason: explainReason(adapter.id, surface, native),\n });\n }\n }\n\n rows.sort((a, b) =>\n a.host === b.host ? a.surface.localeCompare(b.surface) : a.host.localeCompare(b.host),\n );\n return rows;\n}\n\n/**\n * The per-DECLARED-event hooks verdict for one host. A connector's hooks surface\n * is `native` only when EVERY event it declares can fire on the host; if any\n * declared event has no native equivalent the row is `skip-warn` and the reason\n * names the specific dead events (the same events install skip-warns). This is\n * the fix for the OR-across-all-events false green: a Stop-only connector on a\n * host that cannot fire Stop now reports skip-warn, not native.\n *\n * Reuses {@link hostCanFireEvent} — the single per-event source of truth shared\n * with {@link SURFACE_PREDICATES} and simulate's runtime verdict — so explain\n * never re-derives the per-event rules.\n */\nfunction hooksRow(\n connector: ResolvedConnector,\n host: PlatformId,\n capabilities: PlatformCapabilities,\n): ExplainRow {\n const declared = connector.hookEvents;\n const dead = declared.filter((e) => !hostCanFireEvent(capabilities, e));\n if (dead.length === 0) {\n return {\n host,\n surface: \"hooks\",\n support: \"native\",\n reason: `${host} can fire every declared hook event (${declared.join(\", \")})`,\n };\n }\n const fireable = declared.filter((e) => hostCanFireEvent(capabilities, e));\n const reason =\n fireable.length === 0\n ? `${host} cannot fire any declared hook event (${dead.join(\", \")}); install skip-warns each`\n : `${host} cannot fire ${dead.join(\", \")} (install skip-warns these); honors ${fireable.join(\", \")}`;\n return { host, surface: \"hooks\", support: \"skip-warn\", reason };\n}\n\n/**\n * The human-readable reason for a native/skip-warn cell. `server` is a special\n * case: the predicate is CAPABILITY-based (the host advertises ≥1 MCP\n * transport), but advertising a transport does NOT guarantee a writable\n * registration — e.g. jetbrains-copilot advertises stdio yet its installServer\n * skip-warns because MCP is managed in IDE settings. So the server reason states\n * the verdict is capability-based and registration may be host-managed, rather\n * than promising a write. (A precise per-adapter installServer dry-run is a\n * Phase-2 enhancement — until then this avoids over-promising.)\n */\nfunction explainReason(host: PlatformId, surface: SurfaceName, native: boolean): string {\n if (surface === \"server\") {\n return native\n ? `${host} advertises an MCP transport (capability-based; registration may be host-managed)`\n : `${host} advertises no MCP transport; install skip-warns`;\n }\n return native\n ? `${host} natively supports ${surface}`\n : `${host} cannot honor ${surface}; install skip-warns`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// simulate — the real adapter parse → handler → format chain, inline\n// ─────────────────────────────────────────────────────────────────────────\n\n/** What to drive through the harness: one host, one surface, one raw payload. */\nexport interface SimulateOptions {\n surface: \"hooks\" | \"statusline\";\n host: PlatformId | string;\n /** REQUIRED when `surface === \"hooks\"`: which normalized lifecycle event. */\n event?: HookEventName;\n /** The host-shaped RAW payload (what the host would pipe in on stdin). */\n input: unknown;\n}\n\n/** The harness verdict: did the host actually honor the connector's response? */\nexport interface SimulateResult {\n /** True when the host's native reply carries the connector's intent. */\n honored: boolean;\n /** The host-native stdout the adapter would emit (when there is one). */\n hostReply?: string;\n /** Human-readable why — names the documented degradation when honored:false. */\n reason: string;\n}\n\n/**\n * Tolerantly coerce the raw payload, mirroring the runtime's parseStdin: a\n * string is JSON-parsed (empty/malformed → `{}`); a nullish value → `{}`; any\n * other value (already-parsed object) is passed through untouched.\n */\nfunction coerceInput(input: unknown): unknown {\n if (input == null) return {};\n if (typeof input === \"string\") {\n const trimmed = input.trim();\n if (trimmed === \"\") return {};\n try {\n return JSON.parse(trimmed);\n } catch {\n return {};\n }\n }\n return input;\n}\n\n/** Normalize a handler's return into a concrete response (void/non-object → `{}`). */\nfunction normalizeResponse(value: HookResponse | void): HookResponse {\n if (value == null || typeof value !== \"object\") return {};\n return value;\n}\n\n/**\n * The decoded shape of a host's native hook reply on stdout. Every json-stdio\n * adapter writes a SUBSET of these fields (claude-code / codex share the\n * `hookSpecificOutput` envelope; Stop-class continuation uses the TOP-LEVEL\n * `decision:\"block\"`). We read the DECODED fields — never substring-match the\n * serialized JSON, which a path/newline/quote in the payload would break.\n */\ninterface ParsedReply {\n /** Top-level Stop-class continuation: {\"decision\":\"block\",\"reason\"}. */\n decision?: unknown;\n reason?: unknown;\n /** Top-level Claude context channel (no adapter emits it yet; future-proofing). */\n systemMessage?: unknown;\n hookSpecificOutput?: {\n hookEventName?: unknown;\n additionalContext?: unknown;\n permissionDecision?: unknown;\n permissionDecisionReason?: unknown;\n updatedInput?: unknown;\n /** PermissionRequest nested envelope: decision:{behavior:\"allow\"|\"deny\", updatedInput?}. */\n decision?: { behavior?: unknown; updatedInput?: unknown };\n };\n}\n\n/**\n * Tolerantly decode a reply's stdout into {@link ParsedReply}. Empty / absent /\n * unparseable stdout is a legitimate \"no payload\" signal (the adapter wrote a\n * bare exit-0) → `undefined`, the honest \"this decision had no stdout path\"\n * verdict input.\n */\nfunction parseReplyStdout(stdout: string | undefined): ParsedReply | undefined {\n if (stdout == null || stdout.trim() === \"\") return undefined;\n try {\n const value = JSON.parse(stdout);\n return value != null && typeof value === \"object\"\n ? (value as ParsedReply)\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Structural deep-equal for plain JSON values (objects/arrays/primitives). */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (typeof a !== typeof b || a == null || b == null) return false;\n if (typeof a !== \"object\") return false;\n const aArr = Array.isArray(a);\n if (aArr !== Array.isArray(b)) return false;\n if (aArr) {\n const x = a as unknown[];\n const y = b as unknown[];\n return x.length === y.length && x.every((v, i) => deepEqual(v, y[i]));\n }\n const x = a as Record<string, unknown>;\n const y = b as Record<string, unknown>;\n const xk = Object.keys(x);\n const yk = Object.keys(y);\n return xk.length === yk.length && xk.every((k) => deepEqual(x[k], y[k]));\n}\n\n/**\n * Decide whether the host HONORED a decision-bearing response, judging the\n * PARSED reply against each adapter's ACTUAL (event, decision) contract — never\n * by substring-matching the serialized JSON. `allow`/no-decision is always\n * pass-through honored; every other decision is honored only when the decoded\n * reply carries that exact intent, and the verdict names the documented\n * degradation when it does not.\n */\nfunction judgeHookHonor(\n host: string,\n event: HookEventName,\n response: HookResponse,\n stdout: string | undefined,\n): { honored: boolean; reason: string } {\n const decision = response.decision;\n if (decision === undefined || decision === \"allow\") {\n return { honored: true, reason: \"pass-through allow\" };\n }\n\n const reply = parseReplyStdout(stdout);\n const hso = reply?.hookSpecificOutput;\n\n if (decision === \"context\") {\n // Honored only when the DECODED additionalContext equals what the handler\n // asked to inject (claude-code's hookSpecificOutput.additionalContext, or a\n // future top-level systemMessage). codex only emits this on\n // SessionStart/PostToolUse — every other event silently drops it.\n const want = response.additionalContext;\n const got = hso?.additionalContext ?? reply?.systemMessage;\n if (reply && got === want) {\n return { honored: true, reason: `${host} injects context on ${event}` };\n }\n return {\n honored: false,\n reason: `${host} drops context on ${event} (no stdout path)`,\n };\n }\n\n if (decision === \"deny\") {\n if (!reply) {\n return {\n honored: false,\n reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`,\n };\n }\n // A real block: PreToolUse's permissionDecision:\"deny\", or the\n // PermissionRequest nested decision.behavior:\"deny\".\n if (hso?.permissionDecision === \"deny\" || hso?.decision?.behavior === \"deny\") {\n return { honored: true, reason: `${host} blocks ${event}` };\n }\n // Stop-class continuation: top-level decision:\"block\" KEEPS the session /\n // subagent running (persistence) — the SEMANTIC OPPOSITE of a block. Honored\n // (the reply carried the intent), but the reason must not say \"blocks\".\n if (reply.decision === \"block\") {\n return {\n honored: true,\n reason: `${host} continues the session/subagent on ${event} (persistence) — NOT a block`,\n };\n }\n // SubagentStart / PostToolUseFailure DEGRADE a deny to a context note — the\n // spawn/failure is not actually blocked.\n if (hso?.additionalContext != null) {\n return {\n honored: false,\n reason: `${host} degrades deny to a context note on ${event}; spawn/failure not blocked`,\n };\n }\n return {\n honored: false,\n reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`,\n };\n }\n\n if (decision === \"ask\") {\n if (hso?.permissionDecision === \"ask\") {\n return { honored: true, reason: `${host} asks on ${event}` };\n }\n // On PermissionRequest, ask/void falls through to the host's NATIVE dialog\n // (the dialog IS the ask), which the adapter expresses as a bare exit-0.\n if (event === \"PermissionRequest\" && !reply) {\n return {\n honored: true,\n reason: `${host} shows the native confirmation dialog on ${event} (the ask)`,\n };\n }\n return {\n honored: false,\n reason: `${host} drops ask on ${event} (no ask path)`,\n };\n }\n\n // decision === \"modify\": honored only when the decoded updatedInput deep-equals\n // what the handler asked to write (hookSpecificOutput.updatedInput, or the\n // PermissionRequest nested decision.updatedInput).\n const wrote = hso?.updatedInput ?? hso?.decision?.updatedInput;\n if (reply && wrote !== undefined && deepEqual(wrote, response.updatedInput)) {\n return { honored: true, reason: `${host} rewrites tool input on ${event}` };\n }\n return {\n honored: false,\n reason: `${host} drops modify on ${event} (modify not honored)`,\n };\n}\n\n/**\n * Run the connector against ONE host-shaped payload through the REAL adapter\n * path and report whether the host honors the response. Self-contained (does not\n * touch the registered-connector loader or telemetry) and fail-safe: any throw\n * in the chain degrades to `honored:false` with the error message, never rejects.\n */\nexport async function simulate(\n connector: ResolvedConnector,\n opts: SimulateOptions,\n): Promise<SimulateResult> {\n try {\n const adapter = await loadAdapter(opts.host);\n if (!adapter) {\n return { honored: false, reason: `unknown host \"${opts.host}\"` };\n }\n\n if (opts.surface === \"statusline\") {\n if (\n !(adapter.capabilities.supportsStatusline ?? false) ||\n !adapter.parseStatusInput ||\n !adapter.formatStatusOutput\n ) {\n return { honored: false, reason: `${opts.host} has no statusline surface` };\n }\n // Guarding on the TOP-LEVEL render is sufficient: a `hosts`-only statusline\n // (a hosts: map with no top-level render) is rejected at defineConnector, so\n // a connector that targets `opts.host` only via hosts[] still has a top-level\n // render here. (If that author-time invariant ever relaxes, revisit this.)\n if (!connector.statusline || typeof connector.statusline.render !== \"function\") {\n return { honored: false, reason: \"connector declares no statusline\" };\n }\n const ctx = adapter.parseStatusInput(coerceInput(opts.input));\n ctx.connectorId = connector.id;\n // Defensive: parseStatusInput now sets ctx.capabilities (it is required on\n // StatuslineContext), but a future adapter could omit it — backfill from\n // the adapter so render() can always read ctx.capabilities.\n if (ctx.capabilities == null) ctx.capabilities = adapter.capabilities;\n // Per-host render override, mirroring the runtime: hosts[host].render wins\n // over the top-level render; an unlisted host falls back to top-level.\n const perHost = connector.statusline.hosts?.[opts.host as PlatformId]?.render;\n const render =\n typeof perHost === \"function\" ? perHost : connector.statusline.render;\n const rendered = await render(ctx);\n const line = rendered == null ? \"\" : String(rendered);\n const reply = adapter.formatStatusOutput(line);\n return {\n honored: true,\n ...(reply.stdout !== undefined ? { hostReply: reply.stdout } : {}),\n reason: \"rendered\",\n };\n }\n\n // surface === \"hooks\"\n const event = opts.event;\n if (!event) {\n return { honored: false, reason: \"event is required when surface === \\\"hooks\\\"\" };\n }\n if (!adapter.parseEvent || !adapter.formatReply) {\n return { honored: false, reason: `${opts.host} has no hook runtime (mcp-only)` };\n }\n\n const evt = adapter.parseEvent(event, coerceInput(opts.input));\n evt.connectorId = connector.id;\n // Mirror the runtime: runHook backfills evt.capabilities from the adapter so\n // a handler reading evt.capabilities behaves the same here. (scope/telemetry\n // are runtime-only — recovered from the registered meta / store, which the\n // offline harness deliberately never touches — so they stay undefined.)\n evt.capabilities = adapter.capabilities;\n\n // Guarding on the TOP-LEVEL handler is sufficient: a `hosts`-only hook (a\n // hosts: map with no top-level handler) is rejected at defineConnector, so a\n // host targeted only via hosts[] still has a top-level handler here. (If that\n // author-time invariant ever relaxes, revisit this.)\n const definition = connector.hooks[event];\n if (!definition || typeof definition.handler !== \"function\") {\n return { honored: false, reason: `connector declares no ${event} handler` };\n }\n\n // Matcher filtering, in lockstep with runHook: when the connector's matcher\n // is set and the event's subject (tool name, or agent type for Subagent*\n // events) does not match, the host never runs the handler — so the harness\n // must NOT run it either, and reports the (honored) exclusion. Reuses the\n // runtime helpers directly so the two stay byte-for-byte aligned.\n const subject = eventMatcherSubject(evt as NormalizedEvent);\n if (subject !== undefined) {\n const re = compileMatcher(definition.matcher);\n if (re && !re.test(subject)) {\n return {\n honored: true,\n reason: `matcher excludes ${subject} (handler not run)`,\n };\n }\n }\n\n // Per-host handler override, mirroring runHook: hosts[host].handler wins\n // over the top-level handler; an unlisted host falls back to top-level.\n const perHost = definition.hosts?.[opts.host as PlatformId]?.handler;\n const handler = typeof perHost === \"function\" ? perHost : definition.handler;\n const response = normalizeResponse(\n await handler(evt as never),\n );\n const reply = adapter.formatReply(event, response);\n const verdict = judgeHookHonor(String(opts.host), event, response, reply.stdout);\n return {\n honored: verdict.honored,\n ...(reply.stdout !== undefined ? { hostReply: reply.stdout } : {}),\n reason: verdict.reason,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n const verb = opts.surface === \"statusline\" ? \"render\" : \"handler\";\n return { honored: false, reason: `${verb} threw: ${message}` };\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// explainHooks — the per-(host, event) honor verdict (powers doctor --explain)\n// ─────────────────────────────────────────────────────────────────────────\n\n/**\n * One per-(host, event) cell of {@link explainHooks}.\n *\n * - \"honored\" — the host fires the event AND carries the connector's response\n * intent (simulate's runtime verdict, e.g. a real deny/block).\n * - \"degraded\" — the host fires the event but silently DROPS the response's\n * decision (e.g. codex fires UserPromptSubmit but has no stdout\n * path for a context injection, so the injection vanishes).\n * - \"dropped\" — the host cannot fire the event at all (no native equivalent /\n * mcp-only host); install skip-warns it and it never runs.\n */\nexport interface HookEventVerdict {\n host: PlatformId;\n event: HookEventName;\n verdict: \"honored\" | \"degraded\" | \"dropped\";\n /** The simulate()-grade reason string (names the documented degradation). */\n reason: string;\n}\n\n/**\n * A subject (tool name / agent type) that SATISFIES the connector's matcher for\n * this event, so a matcher-gated hook actually runs and the verdict reflects the\n * real honor — not a spurious \"matcher excludes my arbitrary synthetic tool\".\n * A plain-literal matcher (no regex metacharacters — the common case, e.g.\n * `acme_query`) IS the subject. A missing/empty matcher matches everything, and\n * a complex regex falls back to the generic subject (then an honest \"matcher\n * excludes\" verdict surfaces — the dev's matcher genuinely would not fire here).\n */\nfunction matchingSubject(matcher: string | undefined, fallback: string): string {\n if (!matcher || matcher === \"\") return fallback;\n return /^[\\w.-]+$/.test(matcher) ? matcher : fallback;\n}\n\n/**\n * A minimal host-shaped synthetic payload so the real parse→handler→format\n * chain has something to run on. The harness coerces a `{}` to a valid event,\n * but tool/subagent events read a subject (tool name / agent type) the connector\n * matcher may filter on — so we plant a subject that SATISFIES the connector's\n * declared matcher ({@link matchingSubject}) to exercise the honor path.\n */\nfunction syntheticPayloadFor(\n event: HookEventName,\n matcher: string | undefined,\n): Record<string, unknown> {\n switch (event) {\n case \"PreToolUse\":\n case \"PostToolUse\":\n case \"PostToolUseFailure\":\n case \"PermissionRequest\": {\n const tool = matchingSubject(matcher, \"Bash\");\n return { tool_name: tool, tool_input: { command: \"echo hi\" } };\n }\n case \"SubagentStart\":\n case \"SubagentStop\": {\n const agent = matchingSubject(matcher, \"general\");\n return { agent_type: agent, subagent_type: agent };\n }\n case \"UserPromptSubmit\":\n return { prompt: \"hello\" };\n default:\n return {};\n }\n}\n\n/**\n * The per-(host, event) hook honor matrix for the connector's DECLARED events\n * across `hosts` — the trustworthy detail behind `doctor --explain`.\n *\n * For each (host, declared event): when the host cannot fire the event\n * ({@link hostCanFireEvent} is false, OR the host has no hook runtime at all)\n * the cell is `dropped`; otherwise it RUNS the real chain via {@link simulate}\n * and reports `honored` (simulate honored the response) or `degraded` (the host\n * fired but dropped the decision). Reuses the per-event signal + simulate's\n * verdict — no per-event honor logic is re-derived here.\n */\nexport async function explainHooks(\n connector: ResolvedConnector,\n hosts: (PlatformId | string)[],\n): Promise<HookEventVerdict[]> {\n const events = connector.hookEvents;\n const rows: HookEventVerdict[] = [];\n\n for (const host of hosts) {\n const adapter = await loadAdapter(host);\n if (!adapter) {\n for (const event of events) {\n rows.push({\n host: host as PlatformId,\n event,\n verdict: \"dropped\",\n reason: `unknown host \"${host}\"`,\n });\n }\n continue;\n }\n\n // An mcp-only host (no hook runtime) drops every declared event.\n const hasHookRuntime = !!adapter.parseEvent && !!adapter.formatReply;\n\n for (const event of events) {\n if (!hasHookRuntime) {\n rows.push({\n host: adapter.id,\n event,\n verdict: \"dropped\",\n reason: `${adapter.id} has no hook runtime (mcp-only) — ${event} never fires`,\n });\n continue;\n }\n if (!hostCanFireEvent(adapter.capabilities, event)) {\n rows.push({\n host: adapter.id,\n event,\n verdict: \"dropped\",\n reason: `${adapter.id} has no ${event} equivalent — install skip-warns it; never fires`,\n });\n continue;\n }\n const sim = await simulate(connector, {\n surface: \"hooks\",\n host: adapter.id,\n event,\n input: syntheticPayloadFor(event, connector.hooks[event]?.matcher),\n });\n rows.push({\n host: adapter.id,\n event,\n verdict: sim.honored ? \"honored\" : \"degraded\",\n reason: sim.reason,\n });\n }\n }\n\n rows.sort((a, b) =>\n a.host === b.host ? a.event.localeCompare(b.event) : a.host.localeCompare(b.host),\n );\n return rows;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoEA,SAAS,uBAAuB,WAA6C;AAC3E,QAAM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C;AACD;AAAA,MACF;AACA,YAAM,MAAM,MAAM,SAAS,WAAW;AAAA,QACpC,SAAS;AAAA,QACT,MAAM,QAAQ;AAAA,QACd;AAAA,QACA,OAAO,oBAAoB,OAAO,UAAU,MAAM,KAAK,GAAG,OAAO;AAAA,MACnE,CAAC;AACD,WAAK,KAAK;AAAA,QACR,MAAM,QAAQ;AAAA,QACd;AAAA,QACA,SAAS,IAAI,UAAU,YAAY;AAAA,QACnC,QAAQ,IAAI;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EACF;AAEA,OAAK;AAAA,IAAK,CAAC,GAAG,MACZ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,EAAE,KAAK,IAAI,EAAE,KAAK,cAAc,EAAE,IAAI;AAAA,EAClF;AACA,SAAO;AACT;","names":["x","y","perHost","reply"]}
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  resolveEnvRefsDeep
4
- } from "./chunk-DBQMX75U.js";
4
+ } from "./chunk-BEFVJ2OE.js";
5
5
  import {
6
6
  BaseAdapter,
7
7
  parseJsonc,
8
8
  renderSkillMd
9
- } from "./chunk-RHML2NOB.js";
9
+ } from "./chunk-NUGMVVV2.js";
10
10
  import {
11
11
  buildWrappedStdio
12
12
  } from "./chunk-TO57WYBB.js";
@@ -1008,4 +1008,4 @@ export {
1008
1008
  adapter,
1009
1009
  openclaw_default
1010
1010
  };
1011
- //# sourceMappingURL=chunk-F5COBB5F.js.map
1011
+ //# sourceMappingURL=chunk-FUXUEXDP.js.map
@@ -73,36 +73,36 @@ function renderInstallResult(result, verb) {
73
73
  return lines.join("\n");
74
74
  }
75
75
  var COMMANDS = {
76
- detect: () => import("./detect-IZOWP5AA.js"),
77
- install: () => import("./install-EP6GPQ65.js"),
78
- uninstall: () => import("./uninstall-MO3RGGVE.js"),
76
+ detect: () => import("./detect-CWEIQCRC.js"),
77
+ install: () => import("./install-S6BYIJ62.js"),
78
+ uninstall: () => import("./uninstall-WGEKTCDZ.js"),
79
79
  // `upgrade` is the single "bring everything current" verb (re-render host
80
80
  // config + refresh the home pointer + managed channel guidance). `sync` and
81
81
  // `update` are kept as back-compat aliases that route to the same module so
82
82
  // existing scripts/docs keep working without a second concept to learn.
83
- upgrade: () => import("./upgrade-6XIGSPGY.js"),
84
- sync: () => import("./upgrade-6XIGSPGY.js"),
85
- update: () => import("./upgrade-6XIGSPGY.js"),
86
- package: () => import("./package-BWLV24OO.js"),
87
- doctor: () => import("./doctor-5IVUQ2YH.js"),
88
- status: () => import("./status-BPB4VLQX.js"),
89
- telemetry: () => import("./telemetry-SBVUJYNE.js"),
90
- usage: () => import("./usage-IBN36ZVW.js"),
91
- leaderboard: () => import("./leaderboard-6I2E5XZK.js"),
92
- hook: () => import("./hook-7IUPIHCZ.js"),
83
+ upgrade: () => import("./upgrade-IH7CKPTO.js"),
84
+ sync: () => import("./upgrade-IH7CKPTO.js"),
85
+ update: () => import("./upgrade-IH7CKPTO.js"),
86
+ package: () => import("./package-KOAAVKHH.js"),
87
+ doctor: () => import("./doctor-AC437ZAW.js"),
88
+ status: () => import("./status-N5LCQQ3R.js"),
89
+ telemetry: () => import("./telemetry-V4YQL2NU.js"),
90
+ usage: () => import("./usage-DI7XRCKM.js"),
91
+ leaderboard: () => import("./leaderboard-SUSUDKHR.js"),
92
+ hook: () => import("./hook-VYD3OCLM.js"),
93
93
  // Internal (omitted from USAGE): the statusline (HUD) entrypoint a host's
94
94
  // status line config points at. Fail-safe: always exits 0 with at most a
95
95
  // rendered line. See cli/commands/statusline.ts.
96
- statusline: () => import("./statusline-HIKR2I4Q.js"),
96
+ statusline: () => import("./statusline-442XOF7R.js"),
97
97
  // Internal (omitted from USAGE): the user-invokable action entrypoint a future
98
98
  // host affordance points at. USER-TRIGGERED: surfaces errors (exit 1 + stderr),
99
99
  // unlike the fail-open hook / fail-safe statusline. See cli/commands/action.ts.
100
- action: () => import("./action-RUM6GP23.js"),
101
- serve: () => import("./serve-CM4HZPMP.js"),
100
+ action: () => import("./action-TCKBTTZX.js"),
101
+ serve: () => import("./serve-BU23QUSJ.js"),
102
102
  // Hidden (omitted from USAGE): the opt-in host-native turn-usage entrypoint an
103
103
  // AfterModel / PostInvocation hook points at. Always exits 0; records a
104
104
  // distinct `model_turn` row. See cli/commands/usage-event.ts.
105
- "usage-event": () => import("./usage-event-4RJP37K6.js")
105
+ "usage-event": () => import("./usage-event-2FCU55AN.js")
106
106
  };
107
107
  var DEFAULT_PROGRAM_NAME = "agent-connector";
108
108
  var COMMAND_USAGE = {
@@ -113,7 +113,7 @@ var COMMAND_USAGE = {
113
113
  sync: "sync \u2014 alias of upgrade (see `upgrade --help`)",
114
114
  update: "update \u2014 alias of upgrade (see `upgrade --help`)",
115
115
  package: "package [--connector <path>] [--format <fmt>|all] [--out <dir>] [--project <dir>] [--dry-run]",
116
- doctor: "doctor [--targets a,b] [--connector <path>] [--scope user|project] [--project <dir>] [--probe] [--json] [--heal] [--dry-run]",
116
+ doctor: "doctor [--targets a,b] [--connector <path>] [--scope user|project] [--project <dir>] [--probe] [--explain] [--json] [--heal] [--dry-run]\n --explain per-(host,event) hook honor matrix (honored/degraded/dropped). Exit non-zero ONLY when an explicitly-targeted host DEGRADES a declared event (fires it but silently won't honor the reply); dropped/mcp-only hosts and fleet-wide (targets:auto) gaps are informational (exit 0).",
117
117
  status: "status [--connector <path>] [--scope user|project] [--project <dir>] [--json]",
118
118
  telemetry: "telemetry report|export|leaderboard [--by <dim>] [--since <dur>] [--connector <id>] [--scope <slice>] [--format csv|json] [--out <file>] [--json]",
119
119
  usage: "usage report|export|leaderboard [--by <dim>] [--since <dur>] [--platform <id>] [--format csv|json] [--out <file>] [--json]",
@@ -198,4 +198,4 @@ export {
198
198
  renderInstallResult,
199
199
  main
200
200
  };
201
- //# sourceMappingURL=chunk-NXR4HM5N.js.map
201
+ //# sourceMappingURL=chunk-HKM3HUOK.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/app.ts"],"sourcesContent":["/**\n * cli/app — shared CLI helpers + command dispatch (NO side effects).\n *\n * Command modules import the shared helpers (print, fail, parse-flags,\n * renderInstallResult) from here, and main() dispatches the first positional to a\n * command module.\n * This module never auto-runs — `cli/index.ts` is the thin bin entry that calls\n * `main()`. Keeping the auto-run out of here is what prevents a dispatch recursion\n * (a command module importing a helper must not re-trigger the program) and makes\n * it robust to bundler entry-splitting (the old import.meta.url entry-guard broke\n * once tsup hoisted this code into a shared chunk).\n */\n\nimport { createRequire } from \"node:module\";\n\nimport type {\n ChangeRecord,\n InstallResult,\n InstallScope,\n PlatformId,\n} from \"../core/types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Shared helpers (imported by the command modules)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Print a line to stdout (machine-readable payloads must stay on stdout). */\nexport function print(line: string): void {\n process.stdout.write(`${line}\\n`);\n}\n\n/**\n * The brand active for THIS invocation. main() sets it from\n * {@link MainOptions.programName} before dispatch, so error messages printed by\n * command modules via {@link fail} read as the embedding tool (e.g. `acme-db:`)\n * instead of always `agent-connector:`.\n */\nlet activeProgramName = \"agent-connector\";\n\n/** Print an error to stderr (branded) and return a non-zero exit code (default 2). */\nexport function fail(message: string, code = 2): number {\n process.stderr.write(`${activeProgramName}: ${message}\\n`);\n return code;\n}\n\n/**\n * Resolve agent-connector's own package version at runtime. Works from both the\n * bundled dist layout (dist/*.js → ../package.json) and the src layout under\n * tsx/vitest (src/cli/ → ../../package.json); the name check guards against\n * accidentally reading some other package.json on the walk.\n */\nexport function resolveOwnVersion(): string {\n const req = createRequire(import.meta.url);\n for (const rel of [\"../package.json\", \"../../package.json\", \"../../../package.json\"]) {\n try {\n const pkg = req(rel) as { name?: string; version?: string };\n if (pkg.name === \"@ken-jo/agent-connector\" && typeof pkg.version === \"string\") {\n return pkg.version;\n }\n } catch {\n /* keep walking */\n }\n }\n return \"0.0.0\";\n}\n\n/** Parse a --scope value the CLI accepts (user|project) into an InstallScope. */\nexport function parseScope(value: string | undefined): InstallScope | null {\n if (value === \"user\" || value === \"project\") return value;\n return null;\n}\n\n/**\n * Parse a comma-separated --targets value into PlatformId[]. Returns undefined\n * when the flag is absent/empty so callers can fall back to connector/detection.\n */\nexport function parseTargets(value: string | undefined): PlatformId[] | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const ids = value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\") as PlatformId[];\n return ids.length > 0 ? ids : undefined;\n}\n\nconst ACTION_GLYPH: Record<ChangeRecord[\"action\"], string> = {\n create: \"+\",\n update: \"~\",\n remove: \"-\",\n skip: \"=\",\n warn: \"!\",\n};\n\n/**\n * Render an InstallResult as a readable diff: one line per ChangeRecord (glyph,\n * platform, detail, path) followed by any warnings and a summary tally. Used by\n * install / upgrade / uninstall.\n */\nexport function renderInstallResult(\n result: InstallResult,\n verb: \"install\" | \"upgrade\" | \"uninstall\",\n): string {\n const lines: string[] = [];\n const mode = result.dryRun ? \" (dry-run — nothing written)\" : \"\";\n lines.push(`${verb} \"${result.connectorId}\"${mode}`);\n\n if (result.changes.length === 0) {\n lines.push(\" (no changes)\");\n } else {\n for (const c of result.changes) {\n const glyph = ACTION_GLYPH[c.action];\n const where = c.path ? ` ${c.path}` : \"\";\n lines.push(` ${glyph} [${c.platform}] ${c.action}: ${c.detail}${where}`);\n }\n }\n\n if (result.warnings.length > 0) {\n lines.push(\"\");\n lines.push(\"warnings:\");\n for (const w of result.warnings) lines.push(` ! ${w}`);\n }\n\n const tally = result.changes.reduce<Record<ChangeRecord[\"action\"], number>>(\n (acc, c) => {\n acc[c.action] += 1;\n return acc;\n },\n { create: 0, update: 0, remove: 0, skip: 0, warn: 0 },\n );\n lines.push(\"\");\n lines.push(\n `summary: ${tally.create} created, ${tally.update} updated, ` +\n `${tally.remove} removed, ${tally.skip} skipped, ${tally.warn} warning(s)`,\n );\n\n return lines.join(\"\\n\");\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Command dispatch\n// ─────────────────────────────────────────────────────────────────────────\n\n/** A command module: takes the post-command argv slice, returns an exit code. */\ntype CommandModule = { run: (argv: string[]) => Promise<number> | number };\n\n/** Lazy command loaders — keyed by the first positional. Imported on demand. */\nconst COMMANDS: Record<string, () => Promise<CommandModule>> = {\n detect: () => import(\"./commands/detect.js\"),\n install: () => import(\"./commands/install.js\"),\n uninstall: () => import(\"./commands/uninstall.js\"),\n // `upgrade` is the single \"bring everything current\" verb (re-render host\n // config + refresh the home pointer + managed channel guidance). `sync` and\n // `update` are kept as back-compat aliases that route to the same module so\n // existing scripts/docs keep working without a second concept to learn.\n upgrade: () => import(\"./commands/upgrade.js\"),\n sync: () => import(\"./commands/upgrade.js\"),\n update: () => import(\"./commands/upgrade.js\"),\n package: () => import(\"./commands/package.js\"),\n doctor: () => import(\"./commands/doctor.js\"),\n status: () => import(\"./commands/status.js\"),\n telemetry: () => import(\"./commands/telemetry.js\"),\n usage: () => import(\"./commands/usage.js\"),\n leaderboard: () => import(\"./commands/leaderboard.js\"),\n hook: () => import(\"./commands/hook.js\"),\n // Internal (omitted from USAGE): the statusline (HUD) entrypoint a host's\n // status line config points at. Fail-safe: always exits 0 with at most a\n // rendered line. See cli/commands/statusline.ts.\n statusline: () => import(\"./commands/statusline.js\"),\n // Internal (omitted from USAGE): the user-invokable action entrypoint a future\n // host affordance points at. USER-TRIGGERED: surfaces errors (exit 1 + stderr),\n // unlike the fail-open hook / fail-safe statusline. See cli/commands/action.ts.\n action: () => import(\"./commands/action.js\"),\n serve: () => import(\"./commands/serve.js\"),\n // Hidden (omitted from USAGE): the opt-in host-native turn-usage entrypoint an\n // AfterModel / PostInvocation hook points at. Always exits 0; records a\n // distinct `model_turn` row. See cli/commands/usage-event.ts.\n \"usage-event\": () => import(\"./commands/usage-event.js\"),\n};\n\n/** Default program name; an embedding SDK CLI overrides it via {@link MainOptions}. */\nexport const DEFAULT_PROGRAM_NAME = \"agent-connector\";\n\n/**\n * One-line usage signature per command — the single central copy behind\n * `<command> --help` and the friendly bad-flag error. Command modules use\n * node:util parseArgs (strict), which THROWS on an unknown flag; without the\n * dispatcher-level handling in {@link main}, `agent-connector install --help`\n * would die with a raw ERR_PARSE_ARGS stack trace — the very invocation the\n * root help tells users to run.\n */\nconst COMMAND_USAGE: Record<string, string> = {\n detect: \"detect [--json] [--project <dir>]\",\n install:\n \"install [--method direct|marketplace] [--connector <path>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--force]\",\n uninstall:\n \"uninstall [--method auto|direct|marketplace] [--connector <path>] [--connector-id <id>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--purge]\",\n upgrade:\n \"upgrade [--method direct|marketplace] [--channel stable|latest] [--connector <path>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run]\",\n sync: \"sync — alias of upgrade (see `upgrade --help`)\",\n update: \"update — alias of upgrade (see `upgrade --help`)\",\n package:\n \"package [--connector <path>] [--format <fmt>|all] [--out <dir>] [--project <dir>] [--dry-run]\",\n doctor:\n \"doctor [--targets a,b] [--connector <path>] [--scope user|project] [--project <dir>] [--probe] [--json] [--heal] [--dry-run]\",\n status: \"status [--connector <path>] [--scope user|project] [--project <dir>] [--json]\",\n telemetry:\n \"telemetry report|export|leaderboard [--by <dim>] [--since <dur>] [--connector <id>] [--scope <slice>] [--format csv|json] [--out <file>] [--json]\",\n usage:\n \"usage report|export|leaderboard [--by <dim>] [--since <dur>] [--platform <id>] [--format csv|json] [--out <file>] [--json]\",\n leaderboard: \"leaderboard [--since <dur>] [--connector <id>] [--scope <slice>] [--json]\",\n hook: \"hook <platform> <event> --connector <id> (internal — host hook configs point here)\",\n statusline:\n \"statusline <platform> --connector <id> (internal — host status line configs point here)\",\n action:\n \"action <platform> <actionId> --connector <id> (internal — host action affordances point here)\",\n serve:\n \"serve --connector <id> [--scope user|project] [--host <platformId>] -- <command> [args...] (internal — host MCP entries point here)\",\n};\n\n/**\n * Build the top-level usage string for a given program name. The brand replaces\n * \"agent-connector\" in the title, the `usage:` line, and the per-command help\n * footer so an embedded CLI (e.g. `acme-db`) reads as its own tool.\n */\nfunction buildUsage(programName: string): string {\n return `${programName} — write your MCP server + hooks once, install everywhere.\n\nusage: ${programName} <command> [flags]\n\ncommands:\n detect List the AI-agent platforms installed on this machine.\n install Deploy a connector across its target platforms (--method direct writes host config; --method marketplace drives the host's plugin install).\n uninstall Remove a connector's registrations (--method auto reverses whichever method is actually installed).\n upgrade Bring everything current: re-render host config + heal the home pointer + managed update guidance (alias: update, sync).\n package Emit a marketplace/extension bundle (9 host formats, or the standard artifacts mcp-server-json | mcpb).\n doctor Health-check every detected platform; non-zero exit on any failure.\n status Light install-state summary: which connectors are present on which hosts (always exits 0).\n telemetry Inspect local per-tool token telemetry (report | export | leaderboard).\n usage Inspect host-native token usage from agent CLI logs (report | export | leaderboard).\n leaderboard Three leaderboards: 🔌 MCP/plugin (mcp-self) + 🖥️ host/user (host-scan-logs) + 🛰️ host-native turns (host-native-live) — never summed.\n hook Universal json-stdio hook entrypoint (hosts call this).\n serve Telemetry-wrapping MCP stdio proxy (wraps a real server command).\n\nRun \\`${programName} <command> --help\\` for command-specific flags.`;\n}\n\n/** Options accepted by {@link main}. */\nexport interface MainOptions {\n /**\n * The brand shown in usage/help text. Defaults to {@link DEFAULT_PROGRAM_NAME}.\n * An embedding SDK CLI (see cli/sdk.ts) passes its own bin name so every\n * subcommand's help reads as the developer's tool.\n */\n programName?: string;\n}\n\nexport async function main(argv: string[], opts: MainOptions = {}): Promise<number> {\n const programName = opts.programName ?? DEFAULT_PROGRAM_NAME;\n activeProgramName = programName; // brand every fail() in this invocation\n const usage = buildUsage(programName);\n const command = argv[0];\n\n if (command == null || command === \"--help\" || command === \"-h\" || command === \"help\") {\n print(usage);\n return command == null ? 1 : 0;\n }\n if (command === \"--version\" || command === \"-v\") {\n print(`${programName} ${resolveOwnVersion()}`);\n return 0;\n }\n\n const loader = COMMANDS[command];\n if (!loader) {\n process.stderr.write(`${programName}: unknown command \"${command}\"\\n\\n`);\n process.stderr.write(`${usage}\\n`);\n return 2;\n }\n\n // Per-command help: no command module defines a --help flag (strict parseArgs\n // would throw on it), so answer it centrally from COMMAND_USAGE.\n const rest = argv.slice(1);\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n const sig = COMMAND_USAGE[command];\n if (sig) {\n print(`usage: ${programName} ${sig}`);\n return 0;\n }\n }\n\n const mod = await loader();\n try {\n return await mod.run(rest);\n } catch (err) {\n // Friendly bad-flag errors: strict parseArgs throws ERR_PARSE_ARGS_* for an\n // unknown/malformed option — print the message + the usage line instead of\n // letting a raw stack trace reach the user. Everything else still rethrows\n // (the bin entry reports those as fatal).\n const code = (err as { code?: string }).code;\n if (typeof code === \"string\" && code.startsWith(\"ERR_PARSE_ARGS\")) {\n const message = err instanceof Error ? err.message : String(err);\n const sig = COMMAND_USAGE[command];\n if (sig) process.stderr.write(`usage: ${programName} ${sig}\\n`);\n return fail(message);\n }\n throw err;\n }\n}\n"],"mappings":";;;AAaA,SAAS,qBAAqB;AAcvB,SAAS,MAAM,MAAoB;AACxC,UAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAClC;AAQA,IAAI,oBAAoB;AAGjB,SAAS,KAAK,SAAiB,OAAO,GAAW;AACtD,UAAQ,OAAO,MAAM,GAAG,iBAAiB,KAAK,OAAO;AAAA,CAAI;AACzD,SAAO;AACT;AAQO,SAAS,oBAA4B;AAC1C,QAAM,MAAM,cAAc,YAAY,GAAG;AACzC,aAAW,OAAO,CAAC,mBAAmB,sBAAsB,uBAAuB,GAAG;AACpF,QAAI;AACF,YAAM,MAAM,IAAI,GAAG;AACnB,UAAI,IAAI,SAAS,6BAA6B,OAAO,IAAI,YAAY,UAAU;AAC7E,eAAO,IAAI;AAAA,MACb;AAAA,IACF,QAAQ;AAAA,IAER;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,WAAW,OAAgD;AACzE,MAAI,UAAU,UAAU,UAAU,UAAW,QAAO;AACpD,SAAO;AACT;AAMO,S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I,UAAU,OAAO,GAAG;AAC/D,YAAM,MAAM,cAAc,OAAO;AACjC,UAAI,IAAK,SAAQ,OAAO,MAAM,UAAU,WAAW,IAAI,GAAG;AAAA,CAAI;AAC9D,aAAO,KAAK,OAAO;AAAA,IACrB;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/cli/app.ts"],"sourcesContent":["/**\n * cli/app — shared CLI helpers + command dispatch (NO side effects).\n *\n * Command modules import the shared helpers (print, fail, parse-flags,\n * renderInstallResult) from here, and main() dispatches the first positional to a\n * command module.\n * This module never auto-runs — `cli/index.ts` is the thin bin entry that calls\n * `main()`. Keeping the auto-run out of here is what prevents a dispatch recursion\n * (a command module importing a helper must not re-trigger the program) and makes\n * it robust to bundler entry-splitting (the old import.meta.url entry-guard broke\n * once tsup hoisted this code into a shared chunk).\n */\n\nimport { createRequire } from \"node:module\";\n\nimport type {\n ChangeRecord,\n InstallResult,\n InstallScope,\n PlatformId,\n} from \"../core/types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Shared helpers (imported by the command modules)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Print a line to stdout (machine-readable payloads must stay on stdout). */\nexport function print(line: string): void {\n process.stdout.write(`${line}\\n`);\n}\n\n/**\n * The brand active for THIS invocation. main() sets it from\n * {@link MainOptions.programName} before dispatch, so error messages printed by\n * command modules via {@link fail} read as the embedding tool (e.g. `acme-db:`)\n * instead of always `agent-connector:`.\n */\nlet activeProgramName = \"agent-connector\";\n\n/** Print an error to stderr (branded) and return a non-zero exit code (default 2). */\nexport function fail(message: string, code = 2): number {\n process.stderr.write(`${activeProgramName}: ${message}\\n`);\n return code;\n}\n\n/**\n * Resolve agent-connector's own package version at runtime. Works from both the\n * bundled dist layout (dist/*.js → ../package.json) and the src layout under\n * tsx/vitest (src/cli/ → ../../package.json); the name check guards against\n * accidentally reading some other package.json on the walk.\n */\nexport function resolveOwnVersion(): string {\n const req = createRequire(import.meta.url);\n for (const rel of [\"../package.json\", \"../../package.json\", \"../../../package.json\"]) {\n try {\n const pkg = req(rel) as { name?: string; version?: string };\n if (pkg.name === \"@ken-jo/agent-connector\" && typeof pkg.version === \"string\") {\n return pkg.version;\n }\n } catch {\n /* keep walking */\n }\n }\n return \"0.0.0\";\n}\n\n/** Parse a --scope value the CLI accepts (user|project) into an InstallScope. */\nexport function parseScope(value: string | undefined): InstallScope | null {\n if (value === \"user\" || value === \"project\") return value;\n return null;\n}\n\n/**\n * Parse a comma-separated --targets value into PlatformId[]. Returns undefined\n * when the flag is absent/empty so callers can fall back to connector/detection.\n */\nexport function parseTargets(value: string | undefined): PlatformId[] | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const ids = value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\") as PlatformId[];\n return ids.length > 0 ? ids : undefined;\n}\n\nconst ACTION_GLYPH: Record<ChangeRecord[\"action\"], string> = {\n create: \"+\",\n update: \"~\",\n remove: \"-\",\n skip: \"=\",\n warn: \"!\",\n};\n\n/**\n * Render an InstallResult as a readable diff: one line per ChangeRecord (glyph,\n * platform, detail, path) followed by any warnings and a summary tally. Used by\n * install / upgrade / uninstall.\n */\nexport function renderInstallResult(\n result: InstallResult,\n verb: \"install\" | \"upgrade\" | \"uninstall\",\n): string {\n const lines: string[] = [];\n const mode = result.dryRun ? \" (dry-run — nothing written)\" : \"\";\n lines.push(`${verb} \"${result.connectorId}\"${mode}`);\n\n if (result.changes.length === 0) {\n lines.push(\" (no changes)\");\n } else {\n for (const c of result.changes) {\n const glyph = ACTION_GLYPH[c.action];\n const where = c.path ? ` ${c.path}` : \"\";\n lines.push(` ${glyph} [${c.platform}] ${c.action}: ${c.detail}${where}`);\n }\n }\n\n if (result.warnings.length > 0) {\n lines.push(\"\");\n lines.push(\"warnings:\");\n for (const w of result.warnings) lines.push(` ! ${w}`);\n }\n\n const tally = result.changes.reduce<Record<ChangeRecord[\"action\"], number>>(\n (acc, c) => {\n acc[c.action] += 1;\n return acc;\n },\n { create: 0, update: 0, remove: 0, skip: 0, warn: 0 },\n );\n lines.push(\"\");\n lines.push(\n `summary: ${tally.create} created, ${tally.update} updated, ` +\n `${tally.remove} removed, ${tally.skip} skipped, ${tally.warn} warning(s)`,\n );\n\n return lines.join(\"\\n\");\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Command dispatch\n// ─────────────────────────────────────────────────────────────────────────\n\n/** A command module: takes the post-command argv slice, returns an exit code. */\ntype CommandModule = { run: (argv: string[]) => Promise<number> | number };\n\n/** Lazy command loaders — keyed by the first positional. Imported on demand. */\nconst COMMANDS: Record<string, () => Promise<CommandModule>> = {\n detect: () => import(\"./commands/detect.js\"),\n install: () => import(\"./commands/install.js\"),\n uninstall: () => import(\"./commands/uninstall.js\"),\n // `upgrade` is the single \"bring everything current\" verb (re-render host\n // config + refresh the home pointer + managed channel guidance). `sync` and\n // `update` are kept as back-compat aliases that route to the same module so\n // existing scripts/docs keep working without a second concept to learn.\n upgrade: () => import(\"./commands/upgrade.js\"),\n sync: () => import(\"./commands/upgrade.js\"),\n update: () => import(\"./commands/upgrade.js\"),\n package: () => import(\"./commands/package.js\"),\n doctor: () => import(\"./commands/doctor.js\"),\n status: () => import(\"./commands/status.js\"),\n telemetry: () => import(\"./commands/telemetry.js\"),\n usage: () => import(\"./commands/usage.js\"),\n leaderboard: () => import(\"./commands/leaderboard.js\"),\n hook: () => import(\"./commands/hook.js\"),\n // Internal (omitted from USAGE): the statusline (HUD) entrypoint a host's\n // status line config points at. Fail-safe: always exits 0 with at most a\n // rendered line. See cli/commands/statusline.ts.\n statusline: () => import(\"./commands/statusline.js\"),\n // Internal (omitted from USAGE): the user-invokable action entrypoint a future\n // host affordance points at. USER-TRIGGERED: surfaces errors (exit 1 + stderr),\n // unlike the fail-open hook / fail-safe statusline. See cli/commands/action.ts.\n action: () => import(\"./commands/action.js\"),\n serve: () => import(\"./commands/serve.js\"),\n // Hidden (omitted from USAGE): the opt-in host-native turn-usage entrypoint an\n // AfterModel / PostInvocation hook points at. Always exits 0; records a\n // distinct `model_turn` row. See cli/commands/usage-event.ts.\n \"usage-event\": () => import(\"./commands/usage-event.js\"),\n};\n\n/** Default program name; an embedding SDK CLI overrides it via {@link MainOptions}. */\nexport const DEFAULT_PROGRAM_NAME = \"agent-connector\";\n\n/**\n * One-line usage signature per command — the single central copy behind\n * `<command> --help` and the friendly bad-flag error. Command modules use\n * node:util parseArgs (strict), which THROWS on an unknown flag; without the\n * dispatcher-level handling in {@link main}, `agent-connector install --help`\n * would die with a raw ERR_PARSE_ARGS stack trace — the very invocation the\n * root help tells users to run.\n */\nconst COMMAND_USAGE: Record<string, string> = {\n detect: \"detect [--json] [--project <dir>]\",\n install:\n \"install [--method direct|marketplace] [--connector <path>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--force]\",\n uninstall:\n \"uninstall [--method auto|direct|marketplace] [--connector <path>] [--connector-id <id>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--purge]\",\n upgrade:\n \"upgrade [--method direct|marketplace] [--channel stable|latest] [--connector <path>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run]\",\n sync: \"sync — alias of upgrade (see `upgrade --help`)\",\n update: \"update — alias of upgrade (see `upgrade --help`)\",\n package:\n \"package [--connector <path>] [--format <fmt>|all] [--out <dir>] [--project <dir>] [--dry-run]\",\n doctor:\n \"doctor [--targets a,b] [--connector <path>] [--scope user|project] [--project <dir>] [--probe] [--explain] [--json] [--heal] [--dry-run]\\n\" +\n \" --explain per-(host,event) hook honor matrix (honored/degraded/dropped). Exit non-zero ONLY when an explicitly-targeted host DEGRADES a declared event (fires it but silently won't honor the reply); dropped/mcp-only hosts and fleet-wide (targets:auto) gaps are informational (exit 0).\",\n status: \"status [--connector <path>] [--scope user|project] [--project <dir>] [--json]\",\n telemetry:\n \"telemetry report|export|leaderboard [--by <dim>] [--since <dur>] [--connector <id>] [--scope <slice>] [--format csv|json] [--out <file>] [--json]\",\n usage:\n \"usage report|export|leaderboard [--by <dim>] [--since <dur>] [--platform <id>] [--format csv|json] [--out <file>] [--json]\",\n leaderboard: \"leaderboard [--since <dur>] [--connector <id>] [--scope <slice>] [--json]\",\n hook: \"hook <platform> <event> --connector <id> (internal — host hook configs point here)\",\n statusline:\n \"statusline <platform> --connector <id> (internal — host status line configs point here)\",\n action:\n \"action <platform> <actionId> --connector <id> (internal — host action affordances point here)\",\n serve:\n \"serve --connector <id> [--scope user|project] [--host <platformId>] -- <command> [args...] (internal — host MCP entries point here)\",\n};\n\n/**\n * Build the top-level usage string for a given program name. The brand replaces\n * \"agent-connector\" in the title, the `usage:` line, and the per-command help\n * footer so an embedded CLI (e.g. `acme-db`) reads as its own tool.\n */\nfunction buildUsage(programName: string): string {\n return `${programName} — write your MCP server + hooks once, install everywhere.\n\nusage: ${programName} <command> [flags]\n\ncommands:\n detect List the AI-agent platforms installed on this machine.\n install Deploy a connector across its target platforms (--method direct writes host config; --method marketplace drives the host's plugin install).\n uninstall Remove a connector's registrations (--method auto reverses whichever method is actually installed).\n upgrade Bring everything current: re-render host config + heal the home pointer + managed update guidance (alias: update, sync).\n package Emit a marketplace/extension bundle (9 host formats, or the standard artifacts mcp-server-json | mcpb).\n doctor Health-check every detected platform; non-zero exit on any failure.\n status Light install-state summary: which connectors are present on which hosts (always exits 0).\n telemetry Inspect local per-tool token telemetry (report | export | leaderboard).\n usage Inspect host-native token usage from agent CLI logs (report | export | leaderboard).\n leaderboard Three leaderboards: 🔌 MCP/plugin (mcp-self) + 🖥️ host/user (host-scan-logs) + 🛰️ host-native turns (host-native-live) — never summed.\n hook Universal json-stdio hook entrypoint (hosts call this).\n serve Telemetry-wrapping MCP stdio proxy (wraps a real server command).\n\nRun \\`${programName} <command> --help\\` for command-specific flags.`;\n}\n\n/** Options accepted by {@link main}. */\nexport interface MainOptions {\n /**\n * The brand shown in usage/help text. Defaults to {@link DEFAULT_PROGRAM_NAME}.\n * An embedding SDK CLI (see cli/sdk.ts) passes its own bin name so every\n * subcommand's help reads as the developer's tool.\n */\n programName?: string;\n}\n\nexport async function main(argv: string[], opts: MainOptions = {}): Promise<number> {\n const programName = opts.programName ?? DEFAULT_PROGRAM_NAME;\n activeProgramName = programName; // brand every fail() in this invocation\n const usage = buildUsage(programName);\n const command = argv[0];\n\n if (command == null || command === \"--help\" || command === \"-h\" || command === \"help\") {\n print(usage);\n return command == null ? 1 : 0;\n }\n if (command === \"--version\" || command === \"-v\") {\n print(`${programName} ${resolveOwnVersion()}`);\n return 0;\n }\n\n const loader = COMMANDS[command];\n if (!loader) {\n process.stderr.write(`${programName}: unknown command \"${command}\"\\n\\n`);\n process.stderr.write(`${usage}\\n`);\n return 2;\n }\n\n // Per-command help: no command module defines a --help flag (strict parseArgs\n // would throw on it), so answer it centrally from COMMAND_USAGE.\n const rest = argv.slice(1);\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n const sig = COMMAND_USAGE[command];\n if (sig) {\n print(`usage: ${programName} ${sig}`);\n return 0;\n }\n }\n\n const mod = await loader();\n try {\n return await mod.run(rest);\n } catch (err) {\n // Friendly bad-flag errors: strict parseArgs throws ERR_PARSE_ARGS_* for an\n // unknown/malformed option — print the message + the usage line instead of\n // letting a raw stack trace reach the user. Everything else still rethrows\n // (the bin entry reports those as fatal).\n const code = (err as { code?: string }).code;\n if (typeof code === \"string\" && code.startsWith(\"ERR_PARSE_ARGS\")) {\n const message = err instanceof Error ? err.message : String(err);\n const sig = COMMAND_USAGE[command];\n if (sig) process.stderr.write(`usage: ${programName} ${sig}\\n`);\n return fail(message);\n }\n throw err;\n }\n}\n"],"mappings":";;;AAaA,SAAS,qBAAqB;AAcvB,SAAS,MAAM,MAAoB;AACxC,UAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAClC;AAQA,IAAI,oBAAoB;AAGjB,SAAS,KAAK,SAAiB,OAAO,GAAW;AACtD,UAAQ,OAAO,MAAM,GAAG,iBAAiB,KAAK,OAAO;AAAA,CAAI;AACzD,SAAO;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KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,GAAG;AAClD,UAAM,MAAM,cAAc,OAAO;AACjC,QAAI,KAAK;AACP,YAAM,UAAU,WAAW,IAAI,GAAG,EAAE;AACpC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,MAAM,MAAM,OAAO;AACzB,MAAI;AACF,WAAO,MAAM,IAAI,IAAI,IAAI;AAAA,EAC3B,SAAS,KAAK;AAKZ,UAAM,OAAQ,IAA0B;AACxC,QAAI,OAAO,SAAS,YAAY,KAAK,WAAW,gBAAgB,GAAG;AACjE,YAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,YAAM,MAAM,cAAc,OAAO;AACjC,UAAI,IAAK,SAAQ,OAAO,MAAM,UAAU,WAAW,IAAI,GAAG;AAAA,CAAI;AAC9D,aAAO,KAAK,OAAO;AAAA,IACrB;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -2,12 +2,57 @@
2
2
  import {
3
3
  allAdapters,
4
4
  loadAdapter
5
- } from "./chunk-LS65GL2P.js";
5
+ } from "./chunk-Q5LECKZL.js";
6
6
 
7
7
  // src/sdk/introspect.ts
8
+ function hostCanFireEvent(c, event) {
9
+ switch (event) {
10
+ case "SessionStart":
11
+ return c.sessionStart;
12
+ case "SessionEnd":
13
+ return c.sessionEnd;
14
+ case "UserPromptSubmit":
15
+ return c.userPromptSubmit;
16
+ case "PreToolUse":
17
+ return c.preToolUse;
18
+ case "PostToolUse":
19
+ return c.postToolUse;
20
+ case "PreCompact":
21
+ return c.preCompact;
22
+ case "Stop":
23
+ return c.stop;
24
+ case "Notification":
25
+ return c.notification;
26
+ case "PermissionRequest":
27
+ return c.permissionRequest ?? false;
28
+ case "PostToolUseFailure":
29
+ return c.postToolUseFailure ?? false;
30
+ case "SubagentStart":
31
+ return c.subagentStart ?? false;
32
+ case "SubagentStop":
33
+ return c.subagentStop ?? false;
34
+ case "PostCompact":
35
+ return c.postCompact ?? false;
36
+ }
37
+ }
38
+ var ALL_HOOK_EVENTS = [
39
+ "SessionStart",
40
+ "SessionEnd",
41
+ "UserPromptSubmit",
42
+ "PreToolUse",
43
+ "PostToolUse",
44
+ "PreCompact",
45
+ "Stop",
46
+ "Notification",
47
+ "PermissionRequest",
48
+ "PostToolUseFailure",
49
+ "SubagentStart",
50
+ "SubagentStop",
51
+ "PostCompact"
52
+ ];
8
53
  var SURFACE_PREDICATES = {
9
54
  server: (c) => c.transports.length > 0,
10
- hooks: (c) => c.sessionStart || c.preToolUse || c.postToolUse || c.userPromptSubmit || c.stop || c.sessionEnd || c.preCompact || c.notification || (c.permissionRequest ?? false) || (c.postToolUseFailure ?? false) || (c.subagentStart ?? false) || (c.subagentStop ?? false),
55
+ hooks: (c) => ALL_HOOK_EVENTS.some((e) => hostCanFireEvent(c, e)),
11
56
  commands: (c) => c.supportsCommands ?? false,
12
57
  skills: (c) => c.supportsSkills ?? false,
13
58
  subagents: (c) => c.supportsSubagents ?? false,
@@ -36,9 +81,10 @@ async function surfaceSupport(host, surface) {
36
81
  }
37
82
 
38
83
  export {
84
+ hostCanFireEvent,
39
85
  SURFACE_PREDICATES,
40
86
  capabilitiesOf,
41
87
  hostsSupporting,
42
88
  surfaceSupport
43
89
  };
44
- //# sourceMappingURL=chunk-P5KA5NVR.js.map
90
+ //# sourceMappingURL=chunk-MDZG5QHB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/introspect.ts"],"sourcesContent":["/**\n * sdk/introspect — host-capability introspection over the adapter registry.\n *\n * A thin, READ-ONLY query layer above {@link loadAdapter} / {@link allAdapters}:\n * \"which hosts can honor surface X?\" and \"what can host Y do?\". It exists so a\n * connector author (or a docs/CLI surface) can answer those questions WITHOUT\n * reaching into adapter internals or re-deriving the per-surface capability\n * rules — the predicates below are the single source of truth for mapping the\n * raw {@link PlatformCapabilities} flags onto the developer-facing surface names.\n *\n * Everything is async because adapters load lazily (one entry per platform in\n * the registry, imported only when queried).\n */\n\nimport type {\n HookEventName,\n PlatformCapabilities,\n PlatformId,\n} from \"../core/types.js\";\nimport { allAdapters, loadAdapter } from \"../adapters/registry.js\";\n\n/**\n * The single source of truth mapping each normalized {@link HookEventName} onto\n * the {@link PlatformCapabilities} flag that says \"this host can natively FIRE\n * this event\". The optional flags (the newer E1 events + PostCompact) are read\n * as `?? false`, mirroring the supportsCommands precedent — a host that leaves a\n * flag unset cannot fire that event, so a declared hook for it skip-warns at\n * install and `explain` reports it as not honored.\n *\n * This is the per-event signal {@link explain}'s hooks row evaluates against the\n * connector's DECLARED events (so a Stop-only connector on a PreToolUse-only\n * host no longer falsely shows `native`), and the same signal `simulate`'s real\n * parse→handler→format chain expresses at runtime.\n */\nexport function hostCanFireEvent(\n c: PlatformCapabilities,\n event: HookEventName,\n): boolean {\n switch (event) {\n case \"SessionStart\":\n return c.sessionStart;\n case \"SessionEnd\":\n return c.sessionEnd;\n case \"UserPromptSubmit\":\n return c.userPromptSubmit;\n case \"PreToolUse\":\n return c.preToolUse;\n case \"PostToolUse\":\n return c.postToolUse;\n case \"PreCompact\":\n return c.preCompact;\n case \"Stop\":\n return c.stop;\n case \"Notification\":\n return c.notification;\n case \"PermissionRequest\":\n return c.permissionRequest ?? false;\n case \"PostToolUseFailure\":\n return c.postToolUseFailure ?? false;\n case \"SubagentStart\":\n return c.subagentStart ?? false;\n case \"SubagentStop\":\n return c.subagentStop ?? false;\n case \"PostCompact\":\n return c.postCompact ?? false;\n }\n}\n\n/** The full normalized hook-event union, in canonical order. */\nconst ALL_HOOK_EVENTS: HookEventName[] = [\n \"SessionStart\",\n \"SessionEnd\",\n \"UserPromptSubmit\",\n \"PreToolUse\",\n \"PostToolUse\",\n \"PreCompact\",\n \"Stop\",\n \"Notification\",\n \"PermissionRequest\",\n \"PostToolUseFailure\",\n \"SubagentStart\",\n \"SubagentStop\",\n \"PostCompact\",\n];\n\n/**\n * The developer-facing surface names a connector can declare. These mirror the\n * top-level {@link import(\"../core/types.js\").ConnectorConfig} keys (server,\n * hooks, commands, …) plus the platform-scoped `configPatch` / `nativeHooks`\n * escape hatches — the same vocabulary the install diff and `explain` use.\n */\nexport type SurfaceName =\n | \"server\"\n | \"hooks\"\n | \"commands\"\n | \"skills\"\n | \"subagents\"\n | \"memory\"\n | \"statusline\"\n | \"actions\"\n | \"configPatch\"\n | \"nativeHooks\";\n\n/**\n * Pure capability predicate per surface — `true` when the host can NATIVELY\n * honor that surface. The optional capability flags are read as `?? false`\n * (the supportsCommands precedent in core/types), so a host that simply leaves\n * a flag unset reports the surface as unsupported (the installer skip-warns it).\n *\n * `hooks` here is the COARSE host-capability predicate: `true` when the host can\n * fire AT LEAST ONE normalized event (it derives from {@link hostCanFireEvent},\n * the per-event source of truth, so the two never drift). It is the right answer\n * for the connector-less queries ({@link hostsSupporting} / {@link surfaceSupport}:\n * \"which hosts have a hook runtime at all?\"). It is deliberately NOT used by\n * {@link explain}, which must judge the hooks surface against the connector's\n * SPECIFIC declared events — a Stop-only connector on a PreToolUse-only host is\n * NOT honored even though the host has a hook runtime (see {@link explain}).\n */\nexport const SURFACE_PREDICATES: Record<\n SurfaceName,\n (c: PlatformCapabilities) => boolean\n> = {\n server: (c) => c.transports.length > 0,\n hooks: (c) => ALL_HOOK_EVENTS.some((e) => hostCanFireEvent(c, e)),\n commands: (c) => c.supportsCommands ?? false,\n skills: (c) => c.supportsSkills ?? false,\n subagents: (c) => c.supportsSubagents ?? false,\n memory: (c) => c.supportsMemory ?? false,\n statusline: (c) => c.supportsStatusline ?? false,\n // Emitters ship on droid + hermes + warp plus the ts-plugin slash-command\n // hosts omp + openclaw (+ the nemoclaw fork) — the hosts with a verifiable\n // target. Every other host leaves supportsActions unset, so explain() marks\n // actions skip-warn there — the honest state for a host with no emission target.\n actions: (c) => c.supportsActions ?? false,\n configPatch: (c) => c.supportsConfigPatch ?? false,\n nativeHooks: (c) => c.supportsNativeHooks ?? false,\n};\n\n/**\n * The {@link PlatformCapabilities} a host advertises, or `undefined` for an id\n * that is not in the registry (`\"unknown\"`, a usage-only id like `\"synthetic\"`,\n * or a typo) — callers branch on undefined rather than crash.\n */\nexport async function capabilitiesOf(\n host: PlatformId | string,\n): Promise<PlatformCapabilities | undefined> {\n const adapter = await loadAdapter(host);\n return adapter?.capabilities;\n}\n\n/**\n * Every registered host that can NATIVELY honor `surface`, as a sorted id list\n * (stable output for snapshots/docs). Loads all adapters in parallel and keeps\n * only those whose capabilities pass {@link SURFACE_PREDICATES}.\n */\nexport async function hostsSupporting(surface: SurfaceName): Promise<PlatformId[]> {\n const predicate = SURFACE_PREDICATES[surface];\n const adapters = await allAdapters();\n return adapters\n .filter((adapter) => predicate(adapter.capabilities))\n .map((adapter) => adapter.id)\n .sort();\n}\n\n/**\n * Convenience: does `host` natively support `surface`? `false` for an unknown\n * id (no capabilities → cannot support anything).\n */\nexport async function surfaceSupport(\n host: PlatformId | string,\n surface: SurfaceName,\n): Promise<boolean> {\n const capabilities = await capabilitiesOf(host);\n return capabilities ? SURFACE_PREDICATES[surface](capabilities) : false;\n}\n"],"mappings":";;;;;;;AAkCO,SAAS,iBACd,GACA,OACS;AACT,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,aAAO,EAAE;AAAA,IACX,KAAK;AACH,aAAO,EAAE;AAAA,IACX,KAAK;AACH,aAAO,EAAE;AAAA,IACX,KAAK;AACH,aAAO,EAAE;AAAA,IACX,KAAK;AACH,aAAO,EAAE;AAAA,IACX,KAAK;AACH,aAAO,EAAE;AAAA,IACX,KAAK;AACH,aAAO,EAAE;AAAA,IACX,KAAK;AACH,aAAO,EAAE;AAAA,IACX,KAAK;AACH,aAAO,EAAE,qBAAqB;AAAA,IAChC,KAAK;AACH,aAAO,EAAE,sBAAsB;AAAA,IACjC,KAAK;AACH,aAAO,EAAE,iBAAiB;AAAA,IAC5B,KAAK;AACH,aAAO,EAAE,gBAAgB;AAAA,IAC3B,KAAK;AACH,aAAO,EAAE,eAAe;AAAA,EAC5B;AACF;AAGA,IAAM,kBAAmC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+ } from "./chunk-TW4DVR4V.js";
13
13
  import {
14
14
  attachLazyTelemetryUsage,
15
15
  buildTelemetryAccessor,
16
16
  measureToolCall,
17
17
  measureToolDefs
18
- } from "./chunk-E45SUUD7.js";
18
+ } from "./chunk-24K6JOKV.js";
19
19
  import {
20
20
  getTokenizer,
21
21
  inferModelFamily,
@@ -28,11 +28,11 @@ import {
28
28
  import {
29
29
  loadRegisteredConnector,
30
30
  readRegisteredMeta
31
- } from "./chunk-RQCBBLTA.js";
31
+ } from "./chunk-5LAFKXFM.js";
32
32
  import {
33
33
  REGISTERED_PLATFORM_IDS,
34
34
  loadAdapter
35
- } from "./chunk-LS65GL2P.js";
35
+ } from "./chunk-Q5LECKZL.js";
36
36
  import {
37
37
  detectLaunchMethod
38
38
  } from "./chunk-TO57WYBB.js";
@@ -691,4 +691,4 @@ export {
691
691
  runStatusline,
692
692
  runAction
693
693
  };
694
- //# sourceMappingURL=chunk-CSRBMJLU.js.map
694
+ //# sourceMappingURL=chunk-MHDQWZ4A.js.map
@@ -1046,7 +1046,7 @@ var BaseAdapter = class {
1046
1046
  if (hostEvent === void 0) {
1047
1047
  changes.push({
1048
1048
  platform: this.id,
1049
- action: "warn",
1049
+ action: descriptor.unmappedAction ? descriptor.unmappedAction(event) : "warn",
1050
1050
  path: configPath,
1051
1051
  detail: descriptor.unmappedWarnDetail(event)
1052
1052
  });
@@ -1258,4 +1258,4 @@ export {
1258
1258
  renderOpenCodeSubagentMd,
1259
1259
  BaseAdapter
1260
1260
  };
1261
- //# sourceMappingURL=chunk-RHML2NOB.js.map
1261
+ //# sourceMappingURL=chunk-NUGMVVV2.js.map