@ken-jo/agent-connector 0.4.26 → 0.4.44

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 (152) hide show
  1. package/dist/{action-AZRZ3V7E.js → action-72J2TCKQ.js} +8 -8
  2. package/dist/{amazon-q-BWSOHTW5.js → amazon-q-UFLBUSHG.js} +15 -16
  3. package/dist/amazon-q-UFLBUSHG.js.map +1 -0
  4. package/dist/{amp-TF5X6OGH.js → amp-5DJK7VAL.js} +3 -5
  5. package/dist/{amp-TF5X6OGH.js.map → amp-5DJK7VAL.js.map} +1 -1
  6. package/dist/{antigravity-3XHBPXZK.js → antigravity-NWP2TUG6.js} +3 -4
  7. package/dist/{antigravity-cli-TJGOBUPK.js → antigravity-cli-KPNLE7X4.js} +3 -4
  8. package/dist/{antigravity-cli-TJGOBUPK.js.map → antigravity-cli-KPNLE7X4.js.map} +1 -1
  9. package/dist/{chunk-YRBFSZ2G.js → chunk-3Q6YEDCG.js} +3 -5
  10. package/dist/{chunk-YRBFSZ2G.js.map → chunk-3Q6YEDCG.js.map} +1 -1
  11. package/dist/{chunk-Q5HR4ADS.js → chunk-5M2SMDA4.js} +2 -2
  12. package/dist/{chunk-3I7UG52L.js → chunk-A767JFHW.js} +65 -4
  13. package/dist/chunk-A767JFHW.js.map +1 -0
  14. package/dist/{chunk-JLMD3IGK.js → chunk-ASHAMORS.js} +2 -2
  15. package/dist/{chunk-YKVNI44Y.js → chunk-B47MDOV3.js} +3 -3
  16. package/dist/{chunk-ZVTPSV5Z.js → chunk-CFM3JKIR.js} +5 -5
  17. package/dist/{chunk-HZDU3J4U.js → chunk-E3GWKJU5.js} +20 -4
  18. package/dist/chunk-E3GWKJU5.js.map +1 -0
  19. package/dist/{chunk-KD4BE5MW.js → chunk-ERV4TKRV.js} +3 -5
  20. package/dist/{chunk-KD4BE5MW.js.map → chunk-ERV4TKRV.js.map} +1 -1
  21. package/dist/{chunk-25BNMXPP.js → chunk-IKEXNI2W.js} +18 -18
  22. package/dist/{chunk-HU6DZZBG.js → chunk-SBV2QJ5C.js} +36 -36
  23. package/dist/{chunk-OLI5SD6I.js → chunk-UXG64P6R.js} +2 -2
  24. package/dist/{chunk-IW46JIQM.js → chunk-VPSHGDDQ.js} +5 -5
  25. package/dist/{chunk-YEJCNOET.js → chunk-WZWK4ICE.js} +2 -2
  26. package/dist/{cursor-R5QB4YR4.js → chunk-XW46WVR2.js} +11 -12
  27. package/dist/chunk-XW46WVR2.js.map +1 -0
  28. package/dist/{claude-code-JLPFUZ4V.js → claude-code-HXIVRZCY.js} +6 -8
  29. package/dist/{claude-code-JLPFUZ4V.js.map → claude-code-HXIVRZCY.js.map} +1 -1
  30. package/dist/cli/sdk.js +4 -4
  31. package/dist/cli.js +1 -1
  32. package/dist/{cline-GBP3EVSX.js → cline-AGFJF4AC.js} +3 -5
  33. package/dist/{cline-GBP3EVSX.js.map → cline-AGFJF4AC.js.map} +1 -1
  34. package/dist/{codebuff-WMKFUVER.js → codebuff-YUQ4PN7G.js} +3 -5
  35. package/dist/{codebuff-WMKFUVER.js.map → codebuff-YUQ4PN7G.js.map} +1 -1
  36. package/dist/{codex-5CZR5XKX.js → codex-FLU37DV3.js} +26 -11
  37. package/dist/codex-FLU37DV3.js.map +1 -0
  38. package/dist/{continue-3AGXWM5W.js → continue-ZMI4YN75.js} +2 -3
  39. package/dist/{continue-3AGXWM5W.js.map → continue-ZMI4YN75.js.map} +1 -1
  40. package/dist/{copilot-cli-IH4P3GRZ.js → copilot-cli-XPRJ5MQB.js} +29 -5
  41. package/dist/copilot-cli-XPRJ5MQB.js.map +1 -0
  42. package/dist/{crush-FDBL3JEK.js → crush-3OB5ZTCC.js} +11 -10
  43. package/dist/crush-3OB5ZTCC.js.map +1 -0
  44. package/dist/cursor-F4HYO2FP.js +22 -0
  45. package/dist/{detect-L5OZPVFO.js → detect-L3NJTBO5.js} +4 -4
  46. package/dist/{doctor-WDIQ2YFE.js → doctor-PUE4HO3N.js} +13 -10
  47. package/dist/{doctor-WDIQ2YFE.js.map → doctor-PUE4HO3N.js.map} +1 -1
  48. package/dist/{droid-X2QHQL7D.js → droid-NZCKYKOV.js} +3 -5
  49. package/dist/{droid-X2QHQL7D.js.map → droid-NZCKYKOV.js.map} +1 -1
  50. package/dist/{gemini-cli-HCN7XKSX.js → gemini-cli-3ZGCXUDD.js} +3 -5
  51. package/dist/{gemini-cli-HCN7XKSX.js.map → gemini-cli-3ZGCXUDD.js.map} +1 -1
  52. package/dist/{goose-ILMM76JP.js → goose-MGGNVXJP.js} +56 -9
  53. package/dist/goose-MGGNVXJP.js.map +1 -0
  54. package/dist/{hermes-YX2ODUZL.js → hermes-L3CBJ37L.js} +8 -6
  55. package/dist/hermes-L3CBJ37L.js.map +1 -0
  56. package/dist/{hook-JRDQ56BN.js → hook-S3DNNGZX.js} +8 -8
  57. package/dist/index.js +2 -2
  58. package/dist/{install-HRCVPRAQ.js → install-7SUJFRYO.js} +13 -10
  59. package/dist/{install-HRCVPRAQ.js.map → install-7SUJFRYO.js.map} +1 -1
  60. package/dist/{jetbrains-copilot-QESFUN6W.js → jetbrains-copilot-M2LHJBAW.js} +3 -5
  61. package/dist/{jetbrains-copilot-QESFUN6W.js.map → jetbrains-copilot-M2LHJBAW.js.map} +1 -1
  62. package/dist/{kilo-POTCYIRG.js → kilo-RMRP2EL7.js} +3 -5
  63. package/dist/{kilo-POTCYIRG.js.map → kilo-RMRP2EL7.js.map} +1 -1
  64. package/dist/{kilo-cli-MO6FSMH2.js → kilo-cli-6ITBNHTH.js} +14 -10
  65. package/dist/kilo-cli-6ITBNHTH.js.map +1 -0
  66. package/dist/{kimi-RXS36OJP.js → kimi-QYHWAY54.js} +65 -25
  67. package/dist/kimi-QYHWAY54.js.map +1 -0
  68. package/dist/{kiro-VTLX7CMF.js → kiro-2K5UJVGC.js} +11 -16
  69. package/dist/kiro-2K5UJVGC.js.map +1 -0
  70. package/dist/{leaderboard-ASGR3E2U.js → leaderboard-2VAAOK3D.js} +2 -2
  71. package/dist/{mimo-code-F4BWMESO.js → mimo-code-K7AMX2QW.js} +3 -5
  72. package/dist/{mimo-code-F4BWMESO.js.map → mimo-code-K7AMX2QW.js.map} +1 -1
  73. package/dist/{mux-2YFCYFM7.js → mux-GT7FWVLH.js} +3 -5
  74. package/dist/{mux-2YFCYFM7.js.map → mux-GT7FWVLH.js.map} +1 -1
  75. package/dist/{nemoclaw-QDB6O22A.js → nemoclaw-GQMS6CUM.js} +3 -4
  76. package/dist/{nemoclaw-QDB6O22A.js.map → nemoclaw-GQMS6CUM.js.map} +1 -1
  77. package/dist/{omp-P2JNAEPN.js → omp-2RPYIZUF.js} +2 -3
  78. package/dist/{omp-P2JNAEPN.js.map → omp-2RPYIZUF.js.map} +1 -1
  79. package/dist/{openclaw-3UMBSSZM.js → openclaw-P5GMEEGC.js} +3 -4
  80. package/dist/openclaw-P5GMEEGC.js.map +1 -0
  81. package/dist/{opencode-Q6H4YT66.js → opencode-5D2SK3EX.js} +3 -5
  82. package/dist/{opencode-Q6H4YT66.js.map → opencode-5D2SK3EX.js.map} +1 -1
  83. package/dist/{package-IXBSG7HD.js → package-VUX663ET.js} +10 -7
  84. package/dist/{package-IXBSG7HD.js.map → package-VUX663ET.js.map} +1 -1
  85. package/dist/{pi-GW25LPC3.js → pi-ZMM4KJTO.js} +2 -3
  86. package/dist/{pi-GW25LPC3.js.map → pi-ZMM4KJTO.js.map} +1 -1
  87. package/dist/{qwen-code-R6XXEEHJ.js → qwen-code-4ZLVGN2C.js} +9 -11
  88. package/dist/qwen-code-4ZLVGN2C.js.map +1 -0
  89. package/dist/{roo-code-EZPNFC5V.js → roo-code-67QGLQRM.js} +4 -5
  90. package/dist/roo-code-67QGLQRM.js.map +1 -0
  91. package/dist/runtime/index.js +6 -6
  92. package/dist/sdk/index.js +3 -3
  93. package/dist/sdk/test.js +5 -5
  94. package/dist/{serve-CFBQYKRB.js → serve-MOIIYFER.js} +8 -8
  95. package/dist/{status-ASBFEFQQ.js → status-SCBCWS7H.js} +6 -6
  96. package/dist/{statusline-WKLWSM7I.js → statusline-NRPDOPGA.js} +7 -7
  97. package/dist/{telemetry-64GCGNIW.js → telemetry-Q55B5NSZ.js} +5 -5
  98. package/dist/{trae-6VQW2UVP.js → trae-TMJPHWZ5.js} +3 -5
  99. package/dist/{trae-6VQW2UVP.js.map → trae-TMJPHWZ5.js.map} +1 -1
  100. package/dist/{uninstall-KDJYE5ET.js → uninstall-SNI7GPQD.js} +13 -10
  101. package/dist/{uninstall-KDJYE5ET.js.map → uninstall-SNI7GPQD.js.map} +1 -1
  102. package/dist/{upgrade-YQRVYR5U.js → upgrade-ZUNBJWJ7.js} +13 -10
  103. package/dist/{upgrade-YQRVYR5U.js.map → upgrade-ZUNBJWJ7.js.map} +1 -1
  104. package/dist/{usage-OV2BDZKF.js → usage-UQDBIU42.js} +2 -2
  105. package/dist/{usage-event-KPI3NEX3.js → usage-event-HPG2BIAY.js} +7 -7
  106. package/dist/{vscode-copilot-UOEEV4P3.js → vscode-copilot-H7JKUKLZ.js} +19 -8
  107. package/dist/vscode-copilot-H7JKUKLZ.js.map +1 -0
  108. package/dist/{warp-LUK2BPCU.js → warp-SVDVKQQI.js} +3 -5
  109. package/dist/{warp-LUK2BPCU.js.map → warp-SVDVKQQI.js.map} +1 -1
  110. package/dist/{windsurf-NZ3G42NQ.js → windsurf-H36YKOMR.js} +3 -5
  111. package/dist/{windsurf-NZ3G42NQ.js.map → windsurf-H36YKOMR.js.map} +1 -1
  112. package/dist/{zed-LGWGZ4EO.js → zed-LHWJALLZ.js} +3 -5
  113. package/dist/{zed-LGWGZ4EO.js.map → zed-LHWJALLZ.js.map} +1 -1
  114. package/package.json +1 -1
  115. package/dist/amazon-q-BWSOHTW5.js.map +0 -1
  116. package/dist/chunk-3I7UG52L.js.map +0 -1
  117. package/dist/chunk-HZDU3J4U.js.map +0 -1
  118. package/dist/chunk-IEGR4TP3.js +0 -70
  119. package/dist/chunk-IEGR4TP3.js.map +0 -1
  120. package/dist/codex-5CZR5XKX.js.map +0 -1
  121. package/dist/copilot-cli-IH4P3GRZ.js.map +0 -1
  122. package/dist/crush-FDBL3JEK.js.map +0 -1
  123. package/dist/cursor-R5QB4YR4.js.map +0 -1
  124. package/dist/goose-ILMM76JP.js.map +0 -1
  125. package/dist/hermes-YX2ODUZL.js.map +0 -1
  126. package/dist/kilo-cli-MO6FSMH2.js.map +0 -1
  127. package/dist/kimi-RXS36OJP.js.map +0 -1
  128. package/dist/kiro-VTLX7CMF.js.map +0 -1
  129. package/dist/qwen-code-R6XXEEHJ.js.map +0 -1
  130. package/dist/roo-code-EZPNFC5V.js.map +0 -1
  131. package/dist/vscode-copilot-UOEEV4P3.js.map +0 -1
  132. /package/dist/{action-AZRZ3V7E.js.map → action-72J2TCKQ.js.map} +0 -0
  133. /package/dist/{antigravity-3XHBPXZK.js.map → antigravity-NWP2TUG6.js.map} +0 -0
  134. /package/dist/{chunk-Q5HR4ADS.js.map → chunk-5M2SMDA4.js.map} +0 -0
  135. /package/dist/{chunk-JLMD3IGK.js.map → chunk-ASHAMORS.js.map} +0 -0
  136. /package/dist/{chunk-YKVNI44Y.js.map → chunk-B47MDOV3.js.map} +0 -0
  137. /package/dist/{chunk-ZVTPSV5Z.js.map → chunk-CFM3JKIR.js.map} +0 -0
  138. /package/dist/{chunk-25BNMXPP.js.map → chunk-IKEXNI2W.js.map} +0 -0
  139. /package/dist/{chunk-HU6DZZBG.js.map → chunk-SBV2QJ5C.js.map} +0 -0
  140. /package/dist/{chunk-OLI5SD6I.js.map → chunk-UXG64P6R.js.map} +0 -0
  141. /package/dist/{chunk-IW46JIQM.js.map → chunk-VPSHGDDQ.js.map} +0 -0
  142. /package/dist/{chunk-YEJCNOET.js.map → chunk-WZWK4ICE.js.map} +0 -0
  143. /package/dist/{openclaw-3UMBSSZM.js.map → cursor-F4HYO2FP.js.map} +0 -0
  144. /package/dist/{detect-L5OZPVFO.js.map → detect-L3NJTBO5.js.map} +0 -0
  145. /package/dist/{hook-JRDQ56BN.js.map → hook-S3DNNGZX.js.map} +0 -0
  146. /package/dist/{leaderboard-ASGR3E2U.js.map → leaderboard-2VAAOK3D.js.map} +0 -0
  147. /package/dist/{serve-CFBQYKRB.js.map → serve-MOIIYFER.js.map} +0 -0
  148. /package/dist/{status-ASBFEFQQ.js.map → status-SCBCWS7H.js.map} +0 -0
  149. /package/dist/{statusline-WKLWSM7I.js.map → statusline-NRPDOPGA.js.map} +0 -0
  150. /package/dist/{telemetry-64GCGNIW.js.map → telemetry-Q55B5NSZ.js.map} +0 -0
  151. /package/dist/{usage-OV2BDZKF.js.map → usage-UQDBIU42.js.map} +0 -0
  152. /package/dist/{usage-event-KPI3NEX3.js.map → usage-event-HPG2BIAY.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/crush/index.ts"],"sourcesContent":["/**\n * adapters/crush — Crush (Charm) platform adapter for agent-connector.\n *\n * Crush is a json-stdio host. A single JSON config file holds BOTH the MCP\n * server registrations and the hook registrations, and agent-connector MERGES\n * into it (never replaces it — unrelated keys are preserved verbatim):\n * - User scope: ~/.config/crush/crush.json\n * (Windows: %LOCALAPPDATA%\\crush\\crush.json)\n * - Project scope: ./.crush.json (preferred) or ./crush.json\n *\n * MCP servers live under the ROOT KEY \"mcp\" (NOT \"mcpServers\"). A stdio entry is\n * { type:\"stdio\", command, args, env, timeout:120, disabled:false }.\n * Hooks live under the top-level \"hooks\" key. Crush supports PreToolUse ONLY;\n * the hook reads the host's JSON on stdin and writes a JSON object on stdout\n * carrying a `decision` field. A deny is `{ decision:\"deny\", reason }` on\n * stdout (exit 0); an allow is an empty stdout (exit 0). Crush cannot rewrite\n * tool args/output nor inject session context — every non-deny decision (and\n * every non-PreToolUse event) degrades to a silent allow.\n *\n * SECURITY NOTE: Crush expands `$(...)` command substitution in its config file\n * at load time. We therefore NEVER emit shell-substitution syntax into the\n * command/args/env we write — every value is a literal path/string built by the\n * spawn helpers (which quote, not interpolate). Connector ids are kebab-case and\n * the home-bin path is an absolute literal, so nothing we write can be coerced\n * into a `$(...)` substitution.\n */\n\nimport { existsSync, statSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n PreToolUseEvent,\n ServerDef,\n Transport,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport { localAppData, xdgConfigHome } from \"../../core/host-paths.js\";\nimport {\n buildHomeBinHookCommand,\n buildWrappedStdio,\n isHomeBinHookCommand,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\n\nconst HOST: PlatformId = \"crush\";\n/** Crush registers MCP servers under \"mcp\" — NOT the \"mcpServers\" of Claude/Gemini. */\nconst MCP_ROOT_KEY = \"mcp\";\n/** Default per-server timeout (seconds) Crush expects on a stdio entry. */\nconst STDIO_TIMEOUT_SECONDS = 120;\n\n/**\n * Crush hook events agent-connector can register. Crush honors PreToolUse ONLY,\n * and only its deny decision is meaningful; every other normalized event has no\n * Crush equivalent and is skipped at install time.\n */\nconst CRUSH_HOOK_EVENTS = [\"PreToolUse\"] as const;\ntype CrushHookEventName = (typeof CRUSH_HOOK_EVENTS)[number];\n\n/**\n * Newer canonical events with NO Crush analog: there is no permission-dialog,\n * tool-failure, or subagent lifecycle hook. Declared hooks for these warn-skip\n * at install so the degradation is reported, never silent. (The legacy silent\n * drop of the other unwired events — SessionStart, Stop, … — predates this\n * convention and is deliberately left untouched.)\n */\nconst WARN_SKIP_EVENTS: ReadonlySet<HookEventName> = new Set([\n \"PermissionRequest\",\n \"PostToolUseFailure\",\n \"SubagentStart\",\n \"SubagentStop\",\n]);\n\n// ─────────────────────────────────────────────────────────────────────────\n// Native config shapes (only the parts we touch; rest preserved verbatim)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** One hook registration entry as Crush stores it under top-level \"hooks\". */\ninterface CrushHookEntry {\n matcher?: string;\n command: string;\n [key: string]: unknown;\n}\n\n/** Crush's crush.json shape — only the keys we read/merge. */\ninterface CrushConfigFile {\n mcp?: Record<string, unknown>;\n hooks?: Record<string, CrushHookEntry[]>;\n [key: string]: unknown;\n}\n\n/** Native stdio MCP server entry under \"mcp\". */\ninterface CrushStdioServer {\n type: \"stdio\";\n command: string;\n args: string[];\n env?: Record<string, string>;\n timeout: number;\n disabled: boolean;\n}\n\n/** Native HTTP MCP server entry under \"mcp\". */\ninterface CrushHttpServer {\n type: \"http\";\n url: string;\n headers?: Record<string, string>;\n timeout: number;\n disabled: boolean;\n}\n\n/** Raw Crush hook stdin payload (Claude-style: PascalCase event, snake_case fields). */\ninterface CrushHookInput {\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n session_id?: string;\n cwd?: string;\n hook_event_name?: string;\n connector?: unknown;\n}\n\nexport class CrushAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Crush\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block via the BaseAdapter default\n // (memoryTargets: project <projectDir>/AGENTS.md; user scope where documented).\n supportsMemory: true,\n // PreToolUse deny is the only hook decision Crush honors.\n preToolUse: true,\n postToolUse: false,\n preCompact: false,\n sessionStart: false,\n sessionEnd: false,\n userPromptSubmit: false,\n stop: false,\n notification: false,\n // Newer events: Crush honors PreToolUse ONLY — no permission-dialog,\n // tool-failure, or subagent lifecycle events exist, so permissionRequest /\n // postToolUseFailure / subagentStart / subagentStop stay unset — install\n // reports the standard skip-warn for them.\n // Crush is deny-only: it cannot rewrite tool args/output nor inject context.\n canModifyArgs: false,\n canModifyOutput: false,\n canInjectSessionContext: false,\n transports: [\"stdio\", \"http\"],\n // Content surface: Crush auto-discovers Agent-Skills dirs (dir-per-skill\n // SKILL.md). Paths are HARD-CODED — no crush.json entry needed\n // (charmbracelet/crush internal/config/load.go GlobalSkillsDirs +\n // ProjectSkillsDir, fetched 2026-06-16):\n // project → <projectDir>/.crush/skills/<name>/SKILL.md (crush-native, in\n // projectSkillSubdirs; preferred over .agents/.claude/.cursor)\n // user → ~/.config/crush/skills/<name>/SKILL.md (home.Config()/crush/\n // skills; XDG_CONFIG_HOME or ~/.config).\n supportsSkills: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = this.userConfigDir();\n const userConfig = join(userDir, \"crush.json\");\n const projectDot = join(projectDir, \".crush.json\");\n const projectBare = join(projectDir, \"crush.json\");\n const userInstalled = existsSync(userDir) || existsSync(userConfig);\n const projInstalled = existsSync(projectDot) || existsSync(projectBare);\n const installed = userInstalled || projInstalled;\n // Report the scope/path that actually matched so a project-only install is\n // not misreported as a (non-existent) user install.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const projectPath = existsSync(projectBare) && !existsSync(projectDot) ? projectBare : projectDot;\n const configPath = scope === \"project\" ? projectPath : userConfig;\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? scope === \"project\"\n ? `found project Crush config at ${configPath}`\n : `found Crush config under ${userDir}`\n : `no Crush config at ${userConfig}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\" ? ctx.projectDir : this.userConfigDir();\n }\n\n /** MCP servers and hooks share ONE crush.json file. */\n getServerConfigPath(ctx: InstallContext): string {\n if (ctx.scope === \"project\") {\n // Prefer ./.crush.json, but MERGE into an existing ./crush.json if that is\n // the file already present (so we don't fork the user's config in two).\n const dot = join(ctx.projectDir, \".crush.json\");\n const bare = join(ctx.projectDir, \"crush.json\");\n if (existsSync(bare) && !existsSync(dot)) return bare;\n return dot;\n }\n return join(this.userConfigDir(), \"crush.json\");\n }\n\n /** Hooks live in the SAME crush.json under the top-level \"hooks\" key. */\n getHookConfigPath(ctx: InstallContext): string {\n return this.getServerConfigPath(ctx);\n }\n\n /**\n * Crush's user config dir, mirroring its own `home.Config()` resolution\n * (charmbracelet/crush internal/home/home.go: `cmp.Or(XDG_CONFIG_HOME, ~/.config)`):\n * - Windows: %LOCALAPPDATA%\\crush (Local; falls back to AppData/Local)\n * - macOS / Linux: $XDG_CONFIG_HOME/crush or ~/.config/crush\n * (crush honors $XDG_CONFIG_HOME on Linux/macOS; the `xdgConfigHome()` helper\n * is byte-identical to ~/.config when XDG is unset.)\n */\n private userConfigDir(): string {\n if (process.platform === \"win32\") {\n return join(localAppData(), \"crush\");\n }\n return join(xdgConfigHome(), \"crush\");\n }\n\n // ── MCP server install / uninstall (crush.json → mcp.<id>) ───────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for crush\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /**\n * Render a normalized ServerDef into Crush's native \"mcp\" entry. Crush has no\n * documented native `${env:VAR}` interpolation — and it expands `$(...)` at\n * load time — so refs are resolved to LITERALS at install time (the safe\n * posture for a host without native interpolation, matching Codex/Kimi).\n */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): CrushStdioServer | CrushHttpServer {\n const transport: Transport = server.transport;\n const disabled = server.enabled === false;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Resolve to literals — never emit `$(...)` Crush would expand at load.\n command = resolveEnvRefsDeep(command);\n args = resolveEnvRefsDeep(args);\n\n const entry: CrushStdioServer = {\n type: \"stdio\",\n command,\n args,\n timeout: STDIO_TIMEOUT_SECONDS,\n disabled,\n };\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // http (and any other remote transport we surface) — Crush registers a URL.\n const entry: CrushHttpServer = {\n type: \"http\",\n url: resolveEnvRefsDeep(server.url ?? \"\"),\n timeout: STDIO_TIMEOUT_SECONDS,\n disabled,\n };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /** Resolve env/header values to literals (no native interpolation on Crush). */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep({ ...env }))) {\n out[k] = String(v);\n }\n return out;\n }\n\n // ── Hook install / uninstall (crush.json → hooks.PreToolUse[]) ───────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.hooks === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"hooks disabled for crush\" }];\n }\n\n const events = this.effectiveHookEvents(ctx);\n const dropped = this.warnSkipHookEvents(ctx);\n const path = this.getHookConfigPath(ctx);\n\n if (events.length === 0 && dropped.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks declared\" }];\n }\n\n const cfg = this.readJson<CrushConfigFile>(path) ?? {};\n const __skip = this.malformedHookRootSkip(path, (cfg as Record<string, unknown>).hooks);\n if (__skip) return [__skip];\n const hooks = (cfg.hooks ??= {});\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n // Declared events Crush cannot fire are reported, never silently dropped.\n for (const event of dropped) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path,\n detail: `${event} has no Crush hook equivalent — skipped`,\n });\n }\n\n for (const event of events) {\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const matcher = connector.hooks[event]?.matcher ?? \"\";\n const entry: CrushHookEntry = { matcher, command };\n\n const bucket = (hooks[event] ??= []);\n const existingIdx = bucket.findIndex((e) => this.isOurHook(e, ctx));\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path,\n detail: `hooks.${event} already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({ platform: this.id, action: \"update\", path, detail: `hooks.${event}` });\n } else {\n bucket.push(entry);\n changes.push({ platform: this.id, action: \"create\", path, detail: `hooks.${event}` });\n }\n mutated = true;\n }\n\n if (mutated) this.writeJson(path, cfg, ctx.dryRun);\n return changes;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const path = this.getHookConfigPath(ctx);\n const cfg = this.readJson<CrushConfigFile>(path);\n const hooks = cfg?.hooks;\n if (!cfg || !hooks) {\n return [\n { platform: this.id, action: \"skip\", path, detail: \"no hooks section present\" },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of Object.keys(hooks)) {\n const bucket = hooks[event];\n if (!Array.isArray(bucket)) continue;\n\n // Keep every entry that is NOT ours (anchored match) so a shared-prefix\n // connector id — or the user's own hook — is never stripped.\n const kept = bucket.filter((e) => !this.isOurHook(e, ctx));\n const removed = bucket.length - kept.length;\n if (removed > 0) {\n if (kept.length > 0) hooks[event] = kept;\n else delete hooks[event];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path,\n detail: `hooks.${event} (${removed})`,\n });\n mutated = true;\n }\n }\n\n if (mutated) this.writeJson(path, cfg, ctx.dryRun);\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path,\n detail: \"no matching hook entries\",\n });\n }\n return changes;\n }\n\n // ── Internal helpers ─────────────────────────────────────────────────────\n\n /** Which canonical hook events to register for Crush, honoring overrides. */\n private effectiveHookEvents(ctx: InstallContext): CrushHookEventName[] {\n if (ctx.connector.platforms[HOST]?.hooks === false) return [];\n return CRUSH_HOOK_EVENTS.filter((e) => ctx.connector.hookEvents.includes(e));\n }\n\n /** Declared events Crush has no analog for — install reports a warn-skip. */\n private warnSkipHookEvents(ctx: InstallContext): HookEventName[] {\n if (ctx.connector.platforms[HOST]?.hooks === false) return [];\n return ctx.connector.hookEvents.filter((e) => WARN_SKIP_EVENTS.has(e));\n }\n\n /**\n * Does this hook entry belong to this connector? Anchored on the home-bin +\n * connector-id token (isHomeBinHookCommand) so uninstalling a shared-prefix\n * connector id never strips a sibling's hook.\n */\n private isOurHook(entry: CrushHookEntry | undefined, ctx: InstallContext): boolean {\n if (!entry || typeof entry !== \"object\") return false;\n return isHomeBinHookCommand(entry.command, ctx.homeBinPath, ctx.connector.id);\n }\n\n // ── Content surface: skills (dir-per-skill SKILL.md) ─────────────────────\n // CONTENT-ONLY: pure native-file writers, mirroring goose/openclaw. No\n // runtime dispatch, no home-bin pointer, no telemetry wrap. Each write is\n // idempotent (byte-identical → skip) via writeContentFile and reversible via\n // removeContentFile + removeDirIfEmpty (never rm -rf a shared dir). Honors\n // platforms[\"crush\"].skills === false. No crush.json entry is written — Crush\n // auto-discovers these hard-coded dirs (load.go GlobalSkillsDirs/ProjectSkillsDir).\n //\n // Native locations (Agent-Skills spec — dir-per-skill SKILL.md + resources):\n // project → <projectDir>/.crush/skills/<name>/SKILL.md\n // user → ~/.config/crush/skills/<name>/SKILL.md\n\n /** The skills ROOT dir for ctx.scope (parent of every per-skill dir). */\n private skillsDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".crush\", \"skills\")\n : join(this.userConfigDir(), \"skills\");\n }\n\n /** Per-skill directory: <skillsDir>/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\n }\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for crush\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Guard a skills path occupied by a regular FILE (would throw ENOTDIR on\n // mkdir): skip-warn rather than crash (the cline `.clinerules`-is-a-file\n // precedent). The per-skill dir or any parent up to the scope root counts.\n const blockingFile = firstFileOnPath(this.skillsDir(ctx), dir);\n if (blockingFile !== null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: blockingFile,\n detail: `${blockingFile} is a file, not a directory; skill \"${skill.name}\" skipped`,\n });\n continue;\n }\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), renderSkillMd(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const configPath = this.getServerConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = this.effectiveHookEvents(ctx);\n return [\n {\n name: `${this.name}: crush.json present`,\n check: () =>\n existsSync(configPath)\n ? { status: \"OK\", detail: configPath }\n : { status: \"FAIL\", detail: `not found: ${configPath}` },\n },\n {\n name: `${this.name}: mcp.${connectorId} registered`,\n check: () => {\n if (!ctx.connector.server) return { status: \"OK\", detail: \"no MCP server declared\" };\n const cfg = this.readJson<CrushConfigFile>(configPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n const present =\n typeof bucket === \"object\" && bucket !== null && connectorId in bucket;\n return present\n ? { status: \"OK\", detail: `mcp.${connectorId}` }\n : { status: \"FAIL\", detail: `mcp.${connectorId} not found in ${configPath}` };\n },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (hookEvents.length === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n const cfg = this.readJson<CrushConfigFile>(configPath);\n if (!cfg) return { status: \"FAIL\", detail: `cannot read ${configPath}` };\n const hooks = cfg.hooks ?? {};\n const registered = Object.values(hooks).some((entries) =>\n (entries ?? []).some((e) => isHomeBinHookCommand(e?.command, homeBin, connectorId)),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${configPath}` };\n },\n },\n ];\n }\n\n // ── Runtime: parse Crush stdin JSON → normalized event ───────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as CrushHookInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = typeof input.session_id === \"string\" ? input.session_id : \"\";\n const projectDir = typeof input.cwd === \"string\" ? input.cwd : undefined;\n\n const base = {\n hostPlatform: HOST,\n connectorId,\n sessionId,\n raw,\n ...(projectDir !== undefined ? { projectDir } : {}),\n } as const;\n\n if (event === \"PreToolUse\") {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n\n // Crush only ever delivers PreToolUse. Surface anything else loudly rather\n // than silently mis-parsing a payload the host cannot actually produce.\n throw new Error(`unsupported crush hook event: ${String(event)}`);\n }\n\n // ── Runtime: normalized response → Crush native hook reply ───────────────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const decision = response.decision ?? \"allow\";\n\n // deny → Crush blocks the pending tool call via a stdout JSON object with a\n // `decision:\"deny\"` (+ reason). Only PreToolUse is honored; every other\n // event/decision degrades to a silent allow.\n if (decision === \"deny\" && event === \"PreToolUse\") {\n return this.stdout({\n decision: \"deny\",\n reason: response.reason ?? \"Blocked by hook\",\n });\n }\n\n // allow / modify / context / ask / unsupported → pass through (exit 0, empty\n // stdout). Crush cannot rewrite args/output or inject context, so those are\n // dropped fail-open here (the deny path above is the only fail-safe lever).\n return { exitCode: 0 };\n }\n\n private stdout(payload: unknown): HookReply {\n return { exitCode: 0, stdout: JSON.stringify(payload) };\n }\n}\n\n/**\n * Walk every path segment from `root` down to (and including) `leaf` and return\n * the FIRST one that exists as a regular file (which would make a mkdir for the\n * skill dir throw ENOTDIR), else null. Used to skip-warn instead of crashing\n * when a user has a `.crush/skills` file where we need a directory.\n */\nfunction firstFileOnPath(root: string, leaf: string): string | null {\n const segments: string[] = [];\n let cur = leaf;\n while (cur.length >= root.length) {\n segments.unshift(cur);\n if (cur === root) break;\n const parent = dirname(cur);\n if (parent === cur) break;\n cur = parent;\n }\n for (const p of segments) {\n if (!existsSync(p)) return null; // nothing planted from here down\n try {\n if (statSync(p).isFile()) return p;\n } catch {\n return null;\n }\n }\n return null;\n}\n\nexport const adapter = new CrushAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,YAAY,gBAAgB;AACrC,SAAS,SAAS,YAAY;AA0B9B,IAAM,OAAmB;AAEzB,IAAM,eAAe;AAErB,IAAM,wBAAwB;AAO9B,IAAM,oBAAoB,CAAC,YAAY;AAUvC,IAAM,mBAA+C,oBAAI,IAAI;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAiDM,IAAM,eAAN,cAA2B,YAA+B;AAAA,EACtD,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA;AAAA,IAEhB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMd,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,YAAY,CAAC,SAAS,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAS5B,gBAAgB;AAAA,EAClB;AAAA;AAAA,EAIA,gBAAgB,YAAsC;AACpD,UAAM,UA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B,MAAI,MAAM;AACV,SAAO,IAAI,UAAU,KAAK,QAAQ;AAChC,aAAS,QAAQ,GAAG;AACpB,QAAI,QAAQ,KAAM;AAClB,UAAM,SAAS,QAAQ,GAAG;AAC1B,QAAI,WAAW,IAAK;AACpB,UAAM;AAAA,EACR;AACA,aAAW,KAAK,UAAU;AACxB,QAAI,CAAC,WAAW,CAAC,EAAG,QAAO;AAC3B,QAAI;AACF,UAAI,SAAS,CAAC,EAAE,OAAO,EAAG,QAAO;AAAA,IACnC,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,UAAU,IAAI,aAAa;AACxC,IAAO,gBAAQ;","names":["entry"]}
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CURSOR_EVENT_MAP,
4
+ CURSOR_HOOKS_VERSION,
5
+ CursorAdapter,
6
+ adapter,
7
+ cursor_default
8
+ } from "./chunk-XW46WVR2.js";
9
+ import "./chunk-H53QZQJI.js";
10
+ import "./chunk-DBQMX75U.js";
11
+ import "./chunk-A767JFHW.js";
12
+ import "./chunk-TO57WYBB.js";
13
+ import "./chunk-ZY25RG4Y.js";
14
+ import "./chunk-QY42WGBX.js";
15
+ export {
16
+ CURSOR_EVENT_MAP,
17
+ CURSOR_HOOKS_VERSION,
18
+ CursorAdapter,
19
+ adapter,
20
+ cursor_default as default
21
+ };
22
+ //# sourceMappingURL=cursor-F4HYO2FP.js.map
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  print
4
- } from "./chunk-25BNMXPP.js";
4
+ } from "./chunk-IKEXNI2W.js";
5
5
  import {
6
6
  detectInstalledPlatforms
7
- } from "./chunk-Q5HR4ADS.js";
8
- import "./chunk-HU6DZZBG.js";
7
+ } from "./chunk-5M2SMDA4.js";
8
+ import "./chunk-SBV2QJ5C.js";
9
9
 
10
10
  // src/cli/commands/detect.ts
11
11
  import { parseArgs } from "util";
@@ -71,4 +71,4 @@ async function run(argv) {
71
71
  export {
72
72
  run
73
73
  };
74
- //# sourceMappingURL=detect-L5OZPVFO.js.map
74
+ //# sourceMappingURL=detect-L3NJTBO5.js.map
@@ -2,17 +2,18 @@
2
2
  import {
3
3
  marketplaceDoctorChecks,
4
4
  syncConnector
5
- } from "./chunk-IW46JIQM.js";
6
- import "./chunk-HZDU3J4U.js";
5
+ } from "./chunk-VPSHGDDQ.js";
6
+ import "./chunk-E3GWKJU5.js";
7
7
  import {
8
8
  readMarketplaceInstalls
9
9
  } from "./chunk-M3H7PQWT.js";
10
+ import "./chunk-XW46WVR2.js";
10
11
  import {
11
12
  fail,
12
13
  parseScope,
13
14
  parseTargets,
14
15
  print
15
- } from "./chunk-25BNMXPP.js";
16
+ } from "./chunk-IKEXNI2W.js";
16
17
  import {
17
18
  LineBuffer,
18
19
  idKey,
@@ -23,25 +24,27 @@ import {
23
24
  } from "./chunk-7QRUZAUG.js";
24
25
  import {
25
26
  detectInstalledPlatforms
26
- } from "./chunk-Q5HR4ADS.js";
27
+ } from "./chunk-5M2SMDA4.js";
27
28
  import "./chunk-KHO5WNTP.js";
28
29
  import {
29
30
  findConnectorConfig,
30
31
  listRegisteredConnectors,
31
32
  loadConnectorFromPath,
32
33
  readRegisteredMeta
33
- } from "./chunk-OLI5SD6I.js";
34
+ } from "./chunk-UXG64P6R.js";
34
35
  import {
35
36
  MCP_PROTOCOL_VERSION
36
- } from "./chunk-YEJCNOET.js";
37
+ } from "./chunk-WZWK4ICE.js";
37
38
  import {
38
39
  REGISTERED_PLATFORM_IDS,
39
40
  loadAdapter
40
- } from "./chunk-HU6DZZBG.js";
41
+ } from "./chunk-SBV2QJ5C.js";
41
42
  import "./chunk-L7ESV37V.js";
42
- import "./chunk-UM5S7DKK.js";
43
43
  import "./chunk-OPXAP3AC.js";
44
- import "./chunk-IEGR4TP3.js";
44
+ import "./chunk-UM5S7DKK.js";
45
+ import "./chunk-H53QZQJI.js";
46
+ import "./chunk-DBQMX75U.js";
47
+ import "./chunk-A767JFHW.js";
45
48
  import "./chunk-TO57WYBB.js";
46
49
  import "./chunk-ZY25RG4Y.js";
47
50
  import {
@@ -538,4 +541,4 @@ async function run(argv) {
538
541
  export {
539
542
  run
540
543
  };
541
- //# sourceMappingURL=doctor-WDIQ2YFE.js.map
544
+ //# sourceMappingURL=doctor-PUE4HO3N.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/commands/doctor.ts","../src/runtime/probe.ts"],"sourcesContent":["/**\n * cli/commands/doctor — health-check every detected platform.\n *\n * For each detected host (or the explicit --targets list) we load its adapter,\n * build a uniform InstallContext, and run adapter.doctor(ctx). Results are\n * printed as pass/warn/fail with any suggested fix. Exit code is non-zero when\n * any check fails (warns alone do not fail the command).\n *\n * The connector context comes from the local config when present; otherwise a\n * minimal id-only connector is used so path-only checks still run.\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport type {\n DiagnosticResult,\n InstallScope,\n PlatformId,\n ResolvedConnector,\n} from \"../../core/types.js\";\nimport type { InstallContext } from \"../../adapters/spi.js\";\nimport { detectInstalledPlatforms } from \"../../adapters/detect.js\";\nimport { loadAdapter, REGISTERED_PLATFORM_IDS } from \"../../adapters/registry.js\";\nimport {\n findConnectorConfig,\n listRegisteredConnectors,\n loadConnectorFromPath,\n readRegisteredMeta,\n} from \"../../core/load-connector.js\";\nimport { syncConnector } from \"../../core/installer.js\";\nimport { marketplaceDoctorChecks } from \"../../core/marketplace.js\";\nimport { readMarketplaceInstalls } from \"../../core/marketplace-state.js\";\nimport { dataRoot, homeBinPath } from \"../../core/paths.js\";\nimport { probeStdioServer } from \"../../runtime/probe.js\";\nimport { fail, parseScope, parseTargets, print } from \"../app.js\";\n\nconst STATUS_GLYPH: Record<DiagnosticResult[\"status\"], string> = {\n pass: \"[pass]\",\n warn: \"[warn]\",\n fail: \"[FAIL]\",\n};\n\n/** A resolved connector together with the path to its source module. */\ninterface ConnectorEntry {\n connector: ResolvedConnector;\n /** Absolute path to the connector source (JSON or JS/TS). Used by syncConnector. */\n modulePath: string;\n}\n\n/**\n * Resolve which connector(s) doctor should health-check, in precedence order:\n * 1. An explicit --connector path, or a local agent-connector.config.* file.\n * 2. Every connector registered under the data-root (what is actually\n * installed). This is the common case — `doctor` from anywhere reports on\n * the real installs, not a guess from the working directory.\n * 3. A minimal id-only placeholder so path-only checks still run.\n */\nasync function resolveDoctorConnectors(\n connectorPath: string | undefined,\n projectDir: string,\n): Promise<ConnectorEntry[]> {\n const configPath = connectorPath ?? findConnectorConfig(projectDir);\n if (configPath) {\n try {\n const { connector, modulePath } = await loadConnectorFromPath(configPath);\n return [{ connector, modulePath }];\n } catch {\n /* fall through */\n }\n }\n\n const registered = listRegisteredConnectors();\n if (registered.length > 0) {\n return registered.map((connector) => {\n const meta = readRegisteredMeta(connector.id);\n return { connector, modulePath: meta?.modulePath ?? \"\" };\n });\n }\n\n const fallback: ResolvedConnector = {\n id: \"agent-connector\",\n displayName: \"agent-connector\",\n version: \"0.0.0\",\n hooks: {},\n hookEvents: [],\n telemetry: {\n enabled: true,\n modelFamilyHint: \"auto\",\n measureToolDefs: true,\n hostNativeUsage: false,\n store: \"ndjson\",\n calibration: { anthropicCountTokens: false },\n },\n commands: [],\n skills: [],\n subagents: [],\n memory: [],\n actions: [],\n platforms: {},\n targets: \"auto\",\n };\n return [{ connector: fallback, modulePath: \"\" }];\n}\n\nfunction buildContext(\n connector: ResolvedConnector,\n id: PlatformId,\n scope: InstallScope,\n projectDir: string,\n): InstallContext {\n return {\n connector,\n scope: connector.platforms[id]?.scope ?? scope,\n projectDir,\n homeBinPath: homeBinPath(),\n dataRoot: dataRoot(),\n dryRun: true,\n };\n}\n\n/** Collected diagnostics tagged with the connector entry they came from. */\ninterface TaggedResult {\n result: DiagnosticResult;\n /** Index into the entries array — used to group by connector for heal. */\n entryIndex: number;\n}\n\n/**\n * Run all diagnostic checks for the given entries/ids and return tagged results\n * plus the flat byPlatform buckets for display.\n */\nasync function collectDiagnostics(\n entries: ConnectorEntry[],\n ids: PlatformId[],\n scope: InstallScope,\n projectDir: string,\n): Promise<{\n byPlatform: { platform: PlatformId; results: DiagnosticResult[] }[];\n tagged: TaggedResult[];\n anyFail: boolean;\n}> {\n const multi = entries.length > 1;\n const byPlatform: { platform: PlatformId; results: DiagnosticResult[] }[] = [];\n const tagged: TaggedResult[] = [];\n let anyFail = false;\n\n for (const id of ids) {\n const adapter = await loadAdapter(id);\n if (!adapter) {\n const r: DiagnosticResult = {\n check: `${id}: adapter`,\n status: \"fail\",\n message: `no adapter registered for ${id}`,\n };\n byPlatform.push({ platform: id, results: [r] });\n anyFail = true;\n continue;\n }\n const results: DiagnosticResult[] = [];\n for (let i = 0; i < entries.length; i++) {\n const { connector } = entries[i]!;\n // A connector with an explicit target list is only checked on those hosts.\n if (connector.targets !== \"auto\" && !connector.targets.includes(id)) continue;\n\n // MARKETPLACE-installed on this host: its surfaces are delivered via the\n // host's plugin (in the plugin cache), NOT the direct-config locations the\n // adapter's doctor() inspects — so the direct checks would falsely FAIL\n // (mcp_servers/command/skill \"not found\"). Skip them; the marketplace-method\n // checks below cover this install's real health.\n if (readMarketplaceInstalls(connector.id)[id]) {\n const note: DiagnosticResult = {\n check: `${connector.id}: ${id} delivery`,\n status: \"pass\",\n message: \"surfaces delivered via the marketplace plugin — see marketplace checks\",\n };\n const tagged_note = multi ? { ...note, check: `(${connector.id}) ${note.check}` } : note;\n results.push(tagged_note);\n tagged.push({ result: tagged_note, entryIndex: i });\n continue;\n }\n\n const ctx = buildContext(connector, id, scope, projectDir);\n let r: DiagnosticResult[];\n try {\n r = adapter.doctor(ctx);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n r = [{ check: `${adapter.name}: doctor`, status: \"fail\", message }];\n }\n // When checking multiple connectors, tag each check with the connector id.\n const tagged_r = multi ? r.map((d) => ({ ...d, check: `(${connector.id}) ${d.check}` })) : r;\n results.push(...tagged_r);\n for (const tr of tagged_r) tagged.push({ result: tr, entryIndex: i });\n }\n if (results.some((d) => d.status === \"fail\")) anyFail = true;\n byPlatform.push({ platform: id, results });\n }\n\n // ── Marketplace-method checks ─────────────────────────────────────────────\n for (let i = 0; i < entries.length; i++) {\n const { connector } = entries[i]!;\n const groups = await marketplaceDoctorChecks(connector, scope, projectDir);\n for (const group of groups) {\n const tagged_g = multi\n ? group.results.map((d) => ({ ...d, check: `(${connector.id}) ${d.check}` }))\n : group.results;\n if (tagged_g.some((d) => d.status === \"fail\")) anyFail = true;\n for (const tg of tagged_g) tagged.push({ result: tg, entryIndex: i });\n const bucket = byPlatform.find((b) => b.platform === group.platform);\n if (bucket) bucket.results.push(...tagged_g);\n else byPlatform.push({ platform: group.platform, results: tagged_g });\n }\n }\n\n return { byPlatform, tagged, anyFail };\n}\n\nexport async function run(argv: string[]): Promise<number> {\n const { values } = parseArgs({\n args: argv,\n options: {\n scope: { type: \"string\", default: \"user\" },\n targets: { type: \"string\" },\n connector: { type: \"string\" },\n project: { type: \"string\" },\n json: { type: \"boolean\", default: false },\n probe: { type: \"boolean\", default: false },\n heal: { type: \"boolean\", default: false },\n \"dry-run\": { type: \"boolean\", default: false },\n },\n allowPositionals: false,\n });\n\n const projectDir = values.project ?? process.cwd();\n\n const scope = parseScope(values.scope);\n if (scope == null) return fail(`invalid --scope \"${values.scope}\" (use user|project)`);\n\n const entries = await resolveDoctorConnectors(values.connector, projectDir);\n const connectors = entries.map((e) => e.connector);\n\n // Target set: explicit --targets (intersected with the registry), else the\n // same chain install uses — connector-declared targets ∩ detected platforms\n // (\"auto\" = everything detected). Without this, doctor red-flags every\n // detected host the connector never targeted (found dogfooding context-mode:\n // targets:[5 ids] installed clean, doctor FAILed the other 9 detected hosts).\n const explicit = parseTargets(values.targets);\n let ids: PlatformId[];\n if (explicit && explicit.length > 0) {\n ids = explicit.filter((id) => REGISTERED_PLATFORM_IDS.has(id));\n } else {\n const detected = await detectInstalledPlatforms(projectDir);\n ids = detected.map((p) => p.id);\n const anyAuto = connectors.some((c) => c.targets === \"auto\");\n if (!anyAuto) {\n const targeted = new Set(connectors.flatMap((c) => c.targets as PlatformId[]));\n ids = ids.filter((id) => targeted.has(id));\n }\n }\n\n if (ids.length === 0 && !values.probe) {\n print(\"doctor: no target platforms (none detected; pass --targets to force).\");\n return 0;\n }\n\n // ── Heal path ─────────────────────────────────────────────────────────────\n if (values.heal) {\n const { tagged, anyFail: preFail } = await collectDiagnostics(\n entries,\n ids,\n scope,\n projectDir,\n );\n\n // Partition: fixable vs deferred (non-pass, not fixable)\n const fixableByEntry = new Map<number, DiagnosticResult[]>();\n const deferredByEntry = new Map<number, DiagnosticResult[]>();\n for (const { result, entryIndex } of tagged) {\n if (result.status === \"pass\") continue;\n // A finding is only HEALABLE if it is fixable AND its connector has a\n // module path we can re-sync from. A placeholder/unregistered connector\n // (empty modulePath) must NEVER be synced — doing so would fabricate a\n // bogus registry record via registerConnector(connector, \"\"). Route its\n // fixable findings to deferred instead.\n const canSync = !!entries[entryIndex]!.modulePath;\n if (result.fixable && canSync) {\n if (!fixableByEntry.has(entryIndex)) fixableByEntry.set(entryIndex, []);\n fixableByEntry.get(entryIndex)!.push(result);\n } else {\n if (!deferredByEntry.has(entryIndex)) deferredByEntry.set(entryIndex, []);\n deferredByEntry.get(entryIndex)!.push(result);\n }\n }\n\n if (values[\"dry-run\"]) {\n // Dry-run: print what would happen, write nothing.\n for (const [idx, fixable] of fixableByEntry) {\n const { connector } = entries[idx]!;\n print(\n `would heal via sync (${connector.id}): ${fixable.map((r) => r.check).join(\", \")}`,\n );\n }\n for (const [idx, deferred] of deferredByEntry) {\n const { connector } = entries[idx]!;\n for (const r of deferred) {\n print(\n `would defer (${connector.id}): ${r.check} — ${r.fix ?? \"no auto-fix available\"}`,\n );\n }\n }\n if (fixableByEntry.size === 0 && deferredByEntry.size === 0) {\n print(\"doctor --heal --dry-run: nothing to heal.\");\n }\n return 0;\n }\n\n // Real heal: sync each connector that has fixable findings.\n for (const [idx] of fixableByEntry) {\n const { connector, modulePath } = entries[idx]!;\n await syncConnector({\n connector,\n modulePath,\n scope,\n projectDir,\n targets: ids,\n dryRun: false,\n });\n }\n\n // Re-run diagnostics to compute what changed.\n const { tagged: postTagged, anyFail: postFail } = await collectDiagnostics(\n entries,\n ids,\n scope,\n projectDir,\n );\n\n // Classify post-heal results.\n const preNonPass = new Set(\n tagged\n .filter((t) => t.result.status !== \"pass\")\n .map((t) => t.result.check),\n );\n const postNonPass = new Set(\n postTagged\n .filter((t) => t.result.status !== \"pass\")\n .map((t) => t.result.check),\n );\n\n const healed: string[] = [];\n const stillFailing: DiagnosticResult[] = [];\n const deferred: DiagnosticResult[] = [];\n\n // Healed = was non-pass before, now pass\n for (const check of preNonPass) {\n if (!postNonPass.has(check)) healed.push(check);\n }\n // Post-heal non-pass findings. Classify consistently with the pre-heal\n // partition: a fixable finding we could not sync (no modulePath) is deferred,\n // not \"still failing after sync\" — we never attempted a sync for it.\n for (const { result, entryIndex } of postTagged) {\n if (result.status === \"pass\") continue;\n const canSync = !!entries[entryIndex]!.modulePath;\n if (result.fixable && canSync) {\n stillFailing.push(result);\n } else {\n deferred.push(result);\n }\n }\n\n if (values.json) {\n print(JSON.stringify({ healed, deferred, stillFailing }, null, 2));\n return postFail ? 1 : 0;\n }\n\n if (healed.length > 0) {\n print(`healed (${healed.length}):`);\n for (const c of healed) print(` [pass] ${c}`);\n print(\"\");\n }\n if (stillFailing.length > 0) {\n print(`still failing after sync (${stillFailing.length}):`);\n for (const r of stillFailing) {\n print(` ${STATUS_GLYPH[r.status]} ${r.check} — ${r.message}`);\n if (r.fix) print(` fix: ${r.fix}`);\n }\n print(\"\");\n }\n if (deferred.length > 0) {\n print(`deferred — requires manual action (${deferred.length}):`);\n for (const r of deferred) {\n print(` ${STATUS_GLYPH[r.status]} ${r.check} — ${r.message}`);\n if (r.fix) print(` fix: ${r.fix}`);\n }\n print(\"\");\n }\n if (healed.length === 0 && stillFailing.length === 0 && deferred.length === 0 && !preFail) {\n print(\"doctor --heal: nothing to heal, all checks passed.\");\n } else if (stillFailing.length === 0 && deferred.length === 0) {\n print(\"doctor --heal: all fixable findings resolved.\");\n }\n return postFail ? 1 : 0;\n }\n\n // ── Normal diagnose path (no --heal) ─────────────────────────────────────\n const { byPlatform, anyFail } = await collectDiagnostics(entries, ids, scope, projectDir);\n\n // ── Live MCP probe (--probe): connector-scoped, not platform-scoped ──────\n // Spawns each connector's REAL stdio server and runs initialize → ping →\n // tools/list. Probe FAILs fold into the doctor exit code.\n const probes: { connector: string; results: DiagnosticResult[] }[] = [];\n if (values.probe) {\n for (const { connector } of entries) {\n const s = connector.server;\n if (!s || s.transport !== \"stdio\" || !s.command) {\n probes.push({\n connector: connector.id,\n results: [\n {\n check: `${connector.id}: MCP probe`,\n status: \"warn\",\n message: s\n ? `transport \"${s.transport}\" is not stdio — live probe skipped`\n : \"no server to probe\",\n },\n ],\n });\n continue;\n }\n const results = await probeStdioServer(s.command, s.args ?? [], {\n label: connector.id,\n ...(s.env ? { env: s.env } : {}),\n });\n probes.push({ connector: connector.id, results });\n }\n }\n\n const probesFail = probes.some((p) => p.results.some((r) => r.status === \"fail\"));\n\n if (values.json) {\n print(JSON.stringify(values.probe ? { platforms: byPlatform, probes } : byPlatform, null, 2));\n return anyFail || probesFail ? 1 : 0;\n }\n\n for (const { platform, results } of byPlatform) {\n print(`${platform}:`);\n for (const r of results) {\n print(` ${STATUS_GLYPH[r.status]} ${r.check} — ${r.message}`);\n if (r.fix) print(` fix: ${r.fix}`);\n }\n print(\"\");\n }\n for (const { connector, results } of probes) {\n print(`probe ${connector}:`);\n for (const r of results) {\n print(` ${STATUS_GLYPH[r.status]} ${r.check} — ${r.message}`);\n if (r.fix) print(` fix: ${r.fix}`);\n }\n print(\"\");\n }\n print(anyFail || probesFail ? \"doctor: one or more checks FAILED.\" : \"doctor: all checks passed.\");\n return anyFail || probesFail ? 1 : 0;\n}\n","/**\n * runtime/probe — a live MCP connection-lifecycle probe for `doctor --probe`.\n *\n * Where `doctor` checks files on disk, this spawns the connector's REAL stdio\n * server and speaks the MCP wire protocol to it: initialize → (read negotiated\n * protocolVersion + capabilities + serverInfo) → notifications/initialized →\n * ping (liveness) → tools/list (gated on the tools capability). It reuses the\n * SAME newline-delimited JSON-RPC framing + id-correlation as the telemetry\n * proxy (telemetry/jsonrpc), so the probe and the serve path read the wire\n * identically. Each step becomes a DiagnosticResult so doctor renders/aggregates\n * it uniformly; a dead/unlaunchable server FAILs (non-zero doctor exit).\n *\n * Negotiation rule: we OFFER {@link MCP_PROTOCOL_VERSION} but ACCEPT whatever\n * version the server returns (we only report it), per the spec — never a\n * hardcoded equality. There is no MCP shutdown message; we close stdin then\n * SIGTERM/SIGKILL.\n */\n\nimport type { DiagnosticResult } from \"../core/types.js\";\nimport { MCP_PROTOCOL_VERSION } from \"../core/mcp-standard.js\";\nimport { spawnChild } from \"../core/spawn-child.js\";\nimport { type JsonRpcMessage, LineBuffer, idKey, isObject } from \"../telemetry/jsonrpc.js\";\n\nconst DEFAULT_TIMEOUT_MS = 5000;\n\nexport interface ProbeOptions {\n /** Per-step timeout in ms (default 5000). */\n timeoutMs?: number;\n /** Prefix for each DiagnosticResult.check (e.g. the connector id). */\n label?: string;\n /** Env merged over process.env for the spawned server (${env:VAR} resolved). */\n env?: Record<string, string>;\n /** Protocol version offered in initialize. Default {@link MCP_PROTOCOL_VERSION}. */\n protocolVersion?: string;\n}\n\nfunction diag(\n status: DiagnosticResult[\"status\"],\n check: string,\n message: string,\n fix?: string,\n): DiagnosticResult {\n return { check, status, message, ...(fix ? { fix } : {}) };\n}\n\nfunction errMsg(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n\n/** Resolve `${env:VAR}` references in env values against the current process env. */\nfunction resolveEnv(env: Record<string, string> | undefined): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(env ?? {})) {\n out[k] = v.replace(/\\$\\{env:([A-Za-z_][A-Za-z0-9_]*)\\}/g, (_m, name) => process.env[name] ?? \"\");\n }\n return out;\n}\n\n/**\n * Spawn the stdio MCP server `command args` and run a real lifecycle probe.\n * Always resolves (never rejects) with one DiagnosticResult per step.\n */\nexport async function probeStdioServer(\n command: string,\n args: string[],\n opts: ProbeOptions = {},\n): Promise<DiagnosticResult[]> {\n const label = opts.label ? `${opts.label}: ` : \"\";\n const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const protocolVersion = opts.protocolVersion ?? MCP_PROTOCOL_VERSION;\n const results: DiagnosticResult[] = [];\n\n // spawnChild resolves a bare Windows package runner (npx/uvx → .cmd/.exe) so\n // the probe agrees with the live serve path; no-op on macOS/Linux.\n const child = spawnChild(command, args, {\n stdio: [\"pipe\", \"pipe\", \"inherit\"],\n env: { ...process.env, ...resolveEnv(opts.env) },\n });\n\n interface Pending {\n resolve: (m: JsonRpcMessage) => void;\n reject: (e: Error) => void;\n }\n const pending = new Map<string, Pending>();\n let spawnErr: Error | null = null;\n let exitCode: number | null = null;\n\n const rejectAll = (e: Error): void => {\n for (const p of pending.values()) p.reject(e);\n pending.clear();\n };\n child.on(\"error\", (e) => {\n spawnErr = e;\n rejectAll(e);\n });\n child.on(\"exit\", (code) => {\n exitCode = code ?? 0;\n rejectAll(new Error(`server exited (code ${exitCode}) before responding`));\n });\n\n const lines = new LineBuffer((line) => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n return; // non-JSON stdout noise — ignore\n }\n if (!isObject(parsed)) return;\n const k = idKey((parsed as JsonRpcMessage).id);\n if (k && pending.has(k)) {\n const p = pending.get(k)!;\n pending.delete(k);\n p.resolve(parsed as JsonRpcMessage);\n }\n });\n child.stdout?.on(\"data\", (c: Buffer) => lines.push(c));\n\n const send = (m: JsonRpcMessage): void => {\n if (child.stdin && child.stdin.writable) child.stdin.write(`${JSON.stringify(m)}\\n`);\n };\n const request = (id: number | string, method: string, params?: unknown): Promise<JsonRpcMessage> => {\n const key = idKey(id)!;\n return new Promise<JsonRpcMessage>((resolve, reject) => {\n const timer = setTimeout(() => {\n pending.delete(key);\n reject(new Error(`no response within ${timeoutMs}ms`));\n }, timeoutMs);\n if (typeof timer.unref === \"function\") timer.unref();\n pending.set(key, {\n resolve: (m) => {\n clearTimeout(timer);\n resolve(m);\n },\n reject: (e) => {\n clearTimeout(timer);\n reject(e);\n },\n });\n send({ jsonrpc: \"2.0\", id, method, ...(params !== undefined ? { params } : {}) });\n });\n };\n\n const cleanup = (): DiagnosticResult[] => {\n try {\n if (child.stdin && child.stdin.writable) child.stdin.end();\n } catch {\n /* ignore */\n }\n try {\n child.kill(\"SIGTERM\");\n } catch {\n /* ignore */\n }\n const killTimer = setTimeout(() => {\n try {\n child.kill(\"SIGKILL\");\n } catch {\n /* ignore */\n }\n }, 500);\n if (typeof killTimer.unref === \"function\") killTimer.unref();\n return results;\n };\n\n // 1. initialize\n let initResult: Record<string, unknown>;\n try {\n const res = await request(1, \"initialize\", {\n protocolVersion,\n capabilities: {},\n clientInfo: { name: \"agent-connector-probe\", version: \"1\" },\n });\n if (isObject(res.error)) {\n results.push(\n diag(\"fail\", `${label}MCP initialize`, `server returned error: ${JSON.stringify(res.error)}`),\n );\n return cleanup();\n }\n initResult = isObject(res.result) ? res.result : {};\n } catch (e) {\n if (spawnErr) {\n results.push(\n diag(\n \"fail\",\n `${label}MCP initialize`,\n `server not launchable: ${errMsg(spawnErr)}`,\n `check that \"${command}\" is installed and on PATH`,\n ),\n );\n } else if (exitCode !== null) {\n // On Windows an unresolvable command surfaces as an early non-zero exit\n // (cmd.exe \"command not found\") rather than a spawn 'error' event, so fold\n // the not-launchable hint in here too — useful whether the command is\n // missing or the server genuinely crashed before initialize.\n results.push(\n diag(\n \"fail\",\n `${label}MCP initialize`,\n `server not launchable, or it exited (code ${exitCode}) before initialize`,\n `check that \"${command}\" is installed and on PATH`,\n ),\n );\n } else {\n results.push(diag(\"fail\", `${label}MCP initialize`, errMsg(e)));\n }\n return cleanup();\n }\n\n const serverInfo = isObject(initResult.serverInfo) ? initResult.serverInfo : {};\n const sName = typeof serverInfo.name === \"string\" ? serverInfo.name : \"unknown\";\n const sVer = typeof serverInfo.version === \"string\" ? serverInfo.version : \"?\";\n const negotiated =\n typeof initResult.protocolVersion === \"string\" ? initResult.protocolVersion : \"(none)\";\n results.push(diag(\"pass\", `${label}MCP initialize`, `serverInfo ${sName}@${sVer}, protocol ${negotiated}`));\n\n // capabilities (presence = feature offered)\n const caps = isObject(initResult.capabilities) ? initResult.capabilities : {};\n const capNames = [\"tools\", \"resources\", \"prompts\", \"logging\", \"completions\"].filter((c) => c in caps);\n results.push(\n diag(\"pass\", `${label}capabilities`, capNames.length > 0 ? capNames.join(\", \") : \"(none advertised)\"),\n );\n\n // 2. initialized notification (required before normal requests)\n send({ jsonrpc: \"2.0\", method: \"notifications/initialized\" });\n\n // 3. ping — liveness confirm (warn, not fail, on timeout)\n try {\n await request(\"probe-ping\", \"ping\");\n results.push(diag(\"pass\", `${label}ping`, \"alive\"));\n } catch (e) {\n results.push(diag(\"warn\", `${label}ping`, `no ping response (${errMsg(e)})`));\n }\n\n // 4. tools/list — only if the server advertised a tools capability\n if (\"tools\" in caps) {\n try {\n const res = await request(2, \"tools/list\", {});\n const r = isObject(res.result) ? res.result : {};\n const tools = Array.isArray(r.tools) ? r.tools : [];\n results.push(diag(\"pass\", `${label}tools/list`, `${tools.length} tool(s)`));\n } catch (e) {\n results.push(diag(\"fail\", `${label}tools/list`, `no tools/list response (${errMsg(e)})`));\n }\n } else {\n results.push(\n diag(\"warn\", `${label}tools/list`, \"skipped — server advertised no tools capability\"),\n );\n }\n\n return cleanup();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,SAAS,iBAAiB;;;ACW1B,IAAM,qBAAqB;AAa3B,SAAS,KACP,QACA,OACA,SACA,KACkB;AAClB,SAAO,EAAE,OAAO,QAAQ,SAAS,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC,EAAG;AAC3D;AAEA,SAAS,OAAO,G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EACV;AACA,QAAM,WAAW,aAAa,uCAAuC,4BAA4B;AACjG,SAAO,WAAW,aAAa,IAAI;AACrC;","names":["deferred"]}
1
+ {"version":3,"sources":["../src/cli/commands/doctor.ts","../src/runtime/probe.ts"],"sourcesContent":["/**\n * cli/commands/doctor — health-check every detected platform.\n *\n * For each detected host (or the explicit --targets list) we load its adapter,\n * build a uniform InstallContext, and run adapter.doctor(ctx). Results are\n * printed as pass/warn/fail with any suggested fix. Exit code is non-zero when\n * any check fails (warns alone do not fail the command).\n *\n * The connector context comes from the local config when present; otherwise a\n * minimal id-only connector is used so path-only checks still run.\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport type {\n DiagnosticResult,\n InstallScope,\n PlatformId,\n ResolvedConnector,\n} from \"../../core/types.js\";\nimport type { InstallContext } from \"../../adapters/spi.js\";\nimport { detectInstalledPlatforms } from \"../../adapters/detect.js\";\nimport { loadAdapter, REGISTERED_PLATFORM_IDS } from \"../../adapters/registry.js\";\nimport {\n findConnectorConfig,\n listRegisteredConnectors,\n loadConnectorFromPath,\n readRegisteredMeta,\n} from \"../../core/load-connector.js\";\nimport { syncConnector } from \"../../core/installer.js\";\nimport { marketplaceDoctorChecks } from \"../../core/marketplace.js\";\nimport { readMarketplaceInstalls } from \"../../core/marketplace-state.js\";\nimport { dataRoot, homeBinPath } from \"../../core/paths.js\";\nimport { probeStdioServer } from \"../../runtime/probe.js\";\nimport { fail, parseScope, parseTargets, print } from \"../app.js\";\n\nconst STATUS_GLYPH: Record<DiagnosticResult[\"status\"], string> = {\n pass: \"[pass]\",\n warn: \"[warn]\",\n fail: \"[FAIL]\",\n};\n\n/** A resolved connector together with the path to its source module. */\ninterface ConnectorEntry {\n connector: ResolvedConnector;\n /** Absolute path to the connector source (JSON or JS/TS). Used by syncConnector. */\n modulePath: string;\n}\n\n/**\n * Resolve which connector(s) doctor should health-check, in precedence order:\n * 1. An explicit --connector path, or a local agent-connector.config.* file.\n * 2. Every connector registered under the data-root (what is actually\n * installed). This is the common case — `doctor` from anywhere reports on\n * the real installs, not a guess from the working directory.\n * 3. A minimal id-only placeholder so path-only checks still run.\n */\nasync function resolveDoctorConnectors(\n connectorPath: string | undefined,\n projectDir: string,\n): Promise<ConnectorEntry[]> {\n const configPath = connectorPath ?? findConnectorConfig(projectDir);\n if (configPath) {\n try {\n const { connector, modulePath } = await loadConnectorFromPath(configPath);\n return [{ connector, modulePath }];\n } catch {\n /* fall through */\n }\n }\n\n const registered = listRegisteredConnectors();\n if (registered.length > 0) {\n return registered.map((connector) => {\n const meta = readRegisteredMeta(connector.id);\n return { connector, modulePath: meta?.modulePath ?? \"\" };\n });\n }\n\n const fallback: ResolvedConnector = {\n id: \"agent-connector\",\n displayName: \"agent-connector\",\n version: \"0.0.0\",\n hooks: {},\n hookEvents: [],\n telemetry: {\n enabled: true,\n modelFamilyHint: \"auto\",\n measureToolDefs: true,\n hostNativeUsage: false,\n store: \"ndjson\",\n calibration: { anthropicCountTokens: false },\n },\n commands: [],\n skills: [],\n subagents: [],\n memory: [],\n actions: [],\n platforms: {},\n targets: \"auto\",\n };\n return [{ connector: fallback, modulePath: \"\" }];\n}\n\nfunction buildContext(\n connector: ResolvedConnector,\n id: PlatformId,\n scope: InstallScope,\n projectDir: string,\n): InstallContext {\n return {\n connector,\n scope: connector.platforms[id]?.scope ?? scope,\n projectDir,\n homeBinPath: homeBinPath(),\n dataRoot: dataRoot(),\n dryRun: true,\n };\n}\n\n/** Collected diagnostics tagged with the connector entry they came from. */\ninterface TaggedResult {\n result: DiagnosticResult;\n /** Index into the entries array — used to group by connector for heal. */\n entryIndex: number;\n}\n\n/**\n * Run all diagnostic checks for the given entries/ids and return tagged results\n * plus the flat byPlatform buckets for display.\n */\nasync function collectDiagnostics(\n entries: ConnectorEntry[],\n ids: PlatformId[],\n scope: InstallScope,\n projectDir: string,\n): Promise<{\n byPlatform: { platform: PlatformId; results: DiagnosticResult[] }[];\n tagged: TaggedResult[];\n anyFail: boolean;\n}> {\n const multi = entries.length > 1;\n const byPlatform: { platform: PlatformId; results: DiagnosticResult[] }[] = [];\n const tagged: TaggedResult[] = [];\n let anyFail = false;\n\n for (const id of ids) {\n const adapter = await loadAdapter(id);\n if (!adapter) {\n const r: DiagnosticResult = {\n check: `${id}: adapter`,\n status: \"fail\",\n message: `no adapter registered for ${id}`,\n };\n byPlatform.push({ platform: id, results: [r] });\n anyFail = true;\n continue;\n }\n const results: DiagnosticResult[] = [];\n for (let i = 0; i < entries.length; i++) {\n const { connector } = entries[i]!;\n // A connector with an explicit target list is only checked on those hosts.\n if (connector.targets !== \"auto\" && !connector.targets.includes(id)) continue;\n\n // MARKETPLACE-installed on this host: its surfaces are delivered via the\n // host's plugin (in the plugin cache), NOT the direct-config locations the\n // adapter's doctor() inspects — so the direct checks would falsely FAIL\n // (mcp_servers/command/skill \"not found\"). Skip them; the marketplace-method\n // checks below cover this install's real health.\n if (readMarketplaceInstalls(connector.id)[id]) {\n const note: DiagnosticResult = {\n check: `${connector.id}: ${id} delivery`,\n status: \"pass\",\n message: \"surfaces delivered via the marketplace plugin — see marketplace checks\",\n };\n const tagged_note = multi ? { ...note, check: `(${connector.id}) ${note.check}` } : note;\n results.push(tagged_note);\n tagged.push({ result: tagged_note, entryIndex: i });\n continue;\n }\n\n const ctx = buildContext(connector, id, scope, projectDir);\n let r: DiagnosticResult[];\n try {\n r = adapter.doctor(ctx);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n r = [{ check: `${adapter.name}: doctor`, status: \"fail\", message }];\n }\n // When checking multiple connectors, tag each check with the connector id.\n const tagged_r = multi ? r.map((d) => ({ ...d, check: `(${connector.id}) ${d.check}` })) : r;\n results.push(...tagged_r);\n for (const tr of tagged_r) tagged.push({ result: tr, entryIndex: i });\n }\n if (results.some((d) => d.status === \"fail\")) anyFail = true;\n byPlatform.push({ platform: id, results });\n }\n\n // ── Marketplace-method checks ─────────────────────────────────────────────\n for (let i = 0; i < entries.length; i++) {\n const { connector } = entries[i]!;\n const groups = await marketplaceDoctorChecks(connector, scope, projectDir);\n for (const group of groups) {\n const tagged_g = multi\n ? group.results.map((d) => ({ ...d, check: `(${connector.id}) ${d.check}` }))\n : group.results;\n if (tagged_g.some((d) => d.status === \"fail\")) anyFail = true;\n for (const tg of tagged_g) tagged.push({ result: tg, entryIndex: i });\n const bucket = byPlatform.find((b) => b.platform === group.platform);\n if (bucket) bucket.results.push(...tagged_g);\n else byPlatform.push({ platform: group.platform, results: tagged_g });\n }\n }\n\n return { byPlatform, tagged, anyFail };\n}\n\nexport async function run(argv: string[]): Promise<number> {\n const { values } = parseArgs({\n args: argv,\n options: {\n scope: { type: \"string\", default: \"user\" },\n targets: { type: \"string\" },\n connector: { type: \"string\" },\n project: { type: \"string\" },\n json: { type: \"boolean\", default: false },\n probe: { type: \"boolean\", default: false },\n heal: { type: \"boolean\", default: false },\n \"dry-run\": { type: \"boolean\", default: false },\n },\n allowPositionals: false,\n });\n\n const projectDir = values.project ?? process.cwd();\n\n const scope = parseScope(values.scope);\n if (scope == null) return fail(`invalid --scope \"${values.scope}\" (use user|project)`);\n\n const entries = await resolveDoctorConnectors(values.connector, projectDir);\n const connectors = entries.map((e) => e.connector);\n\n // Target set: explicit --targets (intersected with the registry), else the\n // same chain install uses — connector-declared targets ∩ detected platforms\n // (\"auto\" = everything detected). Without this, doctor red-flags every\n // detected host the connector never targeted (found dogfooding context-mode:\n // targets:[5 ids] installed clean, doctor FAILed the other 9 detected hosts).\n const explicit = parseTargets(values.targets);\n let ids: PlatformId[];\n if (explicit && explicit.length > 0) {\n ids = explicit.filter((id) => REGISTERED_PLATFORM_IDS.has(id));\n } else {\n const detected = await detectInstalledPlatforms(projectDir);\n ids = detected.map((p) => p.id);\n const anyAuto = connectors.some((c) => c.targets === \"auto\");\n if (!anyAuto) {\n const targeted = new Set(connectors.flatMap((c) => c.targets as PlatformId[]));\n ids = ids.filter((id) => targeted.has(id));\n }\n }\n\n if (ids.length === 0 && !values.probe) {\n print(\"doctor: no target platforms (none detected; pass --targets to force).\");\n return 0;\n }\n\n // ── Heal path ─────────────────────────────────────────────────────────────\n if (values.heal) {\n const { tagged, anyFail: preFail } = await collectDiagnostics(\n entries,\n ids,\n scope,\n projectDir,\n );\n\n // Partition: fixable vs deferred (non-pass, not fixable)\n const fixableByEntry = new Map<number, DiagnosticResult[]>();\n const deferredByEntry = new Map<number, DiagnosticResult[]>();\n for (const { result, entryIndex } of tagged) {\n if (result.status === \"pass\") continue;\n // A finding is only HEALABLE if it is fixable AND its connector has a\n // module path we can re-sync from. A placeholder/unregistered connector\n // (empty modulePath) must NEVER be synced — doing so would fabricate a\n // bogus registry record via registerConnector(connector, \"\"). Route its\n // fixable findings to deferred instead.\n const canSync = !!entries[entryIndex]!.modulePath;\n if (result.fixable && canSync) {\n if (!fixableByEntry.has(entryIndex)) fixableByEntry.set(entryIndex, []);\n fixableByEntry.get(entryIndex)!.push(result);\n } else {\n if (!deferredByEntry.has(entryIndex)) deferredByEntry.set(entryIndex, []);\n deferredByEntry.get(entryIndex)!.push(result);\n }\n }\n\n if (values[\"dry-run\"]) {\n // Dry-run: print what would happen, write nothing.\n for (const [idx, fixable] of fixableByEntry) {\n const { connector } = entries[idx]!;\n print(\n `would heal via sync (${connector.id}): ${fixable.map((r) => r.check).join(\", \")}`,\n );\n }\n for (const [idx, deferred] of deferredByEntry) {\n const { connector } = entries[idx]!;\n for (const r of deferred) {\n print(\n `would defer (${connector.id}): ${r.check} — ${r.fix ?? \"no auto-fix available\"}`,\n );\n }\n }\n if (fixableByEntry.size === 0 && deferredByEntry.size === 0) {\n print(\"doctor --heal --dry-run: nothing to heal.\");\n }\n return 0;\n }\n\n // Real heal: sync each connector that has fixable findings.\n for (const [idx] of fixableByEntry) {\n const { connector, modulePath } = entries[idx]!;\n await syncConnector({\n connector,\n modulePath,\n scope,\n projectDir,\n targets: ids,\n dryRun: false,\n });\n }\n\n // Re-run diagnostics to compute what changed.\n const { tagged: postTagged, anyFail: postFail } = await collectDiagnostics(\n entries,\n ids,\n scope,\n projectDir,\n );\n\n // Classify post-heal results.\n const preNonPass = new Set(\n tagged\n .filter((t) => t.result.status !== \"pass\")\n .map((t) => t.result.check),\n );\n const postNonPass = new Set(\n postTagged\n .filter((t) => t.result.status !== \"pass\")\n .map((t) => t.result.check),\n );\n\n const healed: string[] = [];\n const stillFailing: DiagnosticResult[] = [];\n const deferred: DiagnosticResult[] = [];\n\n // Healed = was non-pass before, now pass\n for (const check of preNonPass) {\n if (!postNonPass.has(check)) healed.push(check);\n }\n // Post-heal non-pass findings. Classify consistently with the pre-heal\n // partition: a fixable finding we could not sync (no modulePath) is deferred,\n // not \"still failing after sync\" — we never attempted a sync for it.\n for (const { result, entryIndex } of postTagged) {\n if (result.status === \"pass\") continue;\n const canSync = !!entries[entryIndex]!.modulePath;\n if (result.fixable && canSync) {\n stillFailing.push(result);\n } else {\n deferred.push(result);\n }\n }\n\n if (values.json) {\n print(JSON.stringify({ healed, deferred, stillFailing }, null, 2));\n return postFail ? 1 : 0;\n }\n\n if (healed.length > 0) {\n print(`healed (${healed.length}):`);\n for (const c of healed) print(` [pass] ${c}`);\n print(\"\");\n }\n if (stillFailing.length > 0) {\n print(`still failing after sync (${stillFailing.length}):`);\n for (const r of stillFailing) {\n print(` ${STATUS_GLYPH[r.status]} ${r.check} — ${r.message}`);\n if (r.fix) print(` fix: ${r.fix}`);\n }\n print(\"\");\n }\n if (deferred.length > 0) {\n print(`deferred — requires manual action (${deferred.length}):`);\n for (const r of deferred) {\n print(` ${STATUS_GLYPH[r.status]} ${r.check} — ${r.message}`);\n if (r.fix) print(` fix: ${r.fix}`);\n }\n print(\"\");\n }\n if (healed.length === 0 && stillFailing.length === 0 && deferred.length === 0 && !preFail) {\n print(\"doctor --heal: nothing to heal, all checks passed.\");\n } else if (stillFailing.length === 0 && deferred.length === 0) {\n print(\"doctor --heal: all fixable findings resolved.\");\n }\n return postFail ? 1 : 0;\n }\n\n // ── Normal diagnose path (no --heal) ─────────────────────────────────────\n const { byPlatform, anyFail } = await collectDiagnostics(entries, ids, scope, projectDir);\n\n // ── Live MCP probe (--probe): connector-scoped, not platform-scoped ──────\n // Spawns each connector's REAL stdio server and runs initialize → ping →\n // tools/list. Probe FAILs fold into the doctor exit code.\n const probes: { connector: string; results: DiagnosticResult[] }[] = [];\n if (values.probe) {\n for (const { connector } of entries) {\n const s = connector.server;\n if (!s || s.transport !== \"stdio\" || !s.command) {\n probes.push({\n connector: connector.id,\n results: [\n {\n check: `${connector.id}: MCP probe`,\n status: \"warn\",\n message: s\n ? `transport \"${s.transport}\" is not stdio — live probe skipped`\n : \"no server to probe\",\n },\n ],\n });\n continue;\n }\n const results = await probeStdioServer(s.command, s.args ?? [], {\n label: connector.id,\n ...(s.env ? { env: s.env } : {}),\n });\n probes.push({ connector: connector.id, results });\n }\n }\n\n const probesFail = probes.some((p) => p.results.some((r) => r.status === \"fail\"));\n\n if (values.json) {\n print(JSON.stringify(values.probe ? { platforms: byPlatform, probes } : byPlatform, null, 2));\n return anyFail || probesFail ? 1 : 0;\n }\n\n for (const { platform, results } of byPlatform) {\n print(`${platform}:`);\n for (const r of results) {\n print(` ${STATUS_GLYPH[r.status]} ${r.check} — ${r.message}`);\n if (r.fix) print(` fix: ${r.fix}`);\n }\n print(\"\");\n }\n for (const { connector, results } of probes) {\n print(`probe ${connector}:`);\n for (const r of results) {\n print(` ${STATUS_GLYPH[r.status]} ${r.check} — ${r.message}`);\n if (r.fix) print(` fix: ${r.fix}`);\n }\n print(\"\");\n }\n print(anyFail || probesFail ? \"doctor: one or more checks FAILED.\" : \"doctor: all checks passed.\");\n return anyFail || probesFail ? 1 : 0;\n}\n","/**\n * runtime/probe — a live MCP connection-lifecycle probe for `doctor --probe`.\n *\n * Where `doctor` checks files on disk, this spawns the connector's REAL stdio\n * server and speaks the MCP wire protocol to it: initialize → (read negotiated\n * protocolVersion + capabilities + serverInfo) → notifications/initialized →\n * ping (liveness) → tools/list (gated on the tools capability). It reuses the\n * SAME newline-delimited JSON-RPC framing + id-correlation as the telemetry\n * proxy (telemetry/jsonrpc), so the probe and the serve path read the wire\n * identically. Each step becomes a DiagnosticResult so doctor renders/aggregates\n * it uniformly; a dead/unlaunchable server FAILs (non-zero doctor exit).\n *\n * Negotiation rule: we OFFER {@link MCP_PROTOCOL_VERSION} but ACCEPT whatever\n * version the server returns (we only report it), per the spec — never a\n * hardcoded equality. There is no MCP shutdown message; we close stdin then\n * SIGTERM/SIGKILL.\n */\n\nimport type { DiagnosticResult } from \"../core/types.js\";\nimport { MCP_PROTOCOL_VERSION } from \"../core/mcp-standard.js\";\nimport { spawnChild } from \"../core/spawn-child.js\";\nimport { type JsonRpcMessage, LineBuffer, idKey, isObject } from \"../telemetry/jsonrpc.js\";\n\nconst DEFAULT_TIMEOUT_MS = 5000;\n\nexport interface ProbeOptions {\n /** Per-step timeout in ms (default 5000). */\n timeoutMs?: number;\n /** Prefix for each DiagnosticResult.check (e.g. the connector id). */\n label?: string;\n /** Env merged over process.env for the spawned server (${env:VAR} resolved). */\n env?: Record<string, string>;\n /** Protocol version offered in initialize. Default {@link MCP_PROTOCOL_VERSION}. */\n protocolVersion?: string;\n}\n\nfunction diag(\n status: DiagnosticResult[\"status\"],\n check: string,\n message: string,\n fix?: string,\n): DiagnosticResult {\n return { check, status, message, ...(fix ? { fix } : {}) };\n}\n\nfunction errMsg(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n\n/** Resolve `${env:VAR}` references in env values against the current process env. */\nfunction resolveEnv(env: Record<string, string> | undefined): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(env ?? {})) {\n out[k] = v.replace(/\\$\\{env:([A-Za-z_][A-Za-z0-9_]*)\\}/g, (_m, name) => process.env[name] ?? \"\");\n }\n return out;\n}\n\n/**\n * Spawn the stdio MCP server `command args` and run a real lifecycle probe.\n * Always resolves (never rejects) with one DiagnosticResult per step.\n */\nexport async function probeStdioServer(\n command: string,\n args: string[],\n opts: ProbeOptions = {},\n): Promise<DiagnosticResult[]> {\n const label = opts.label ? `${opts.label}: ` : \"\";\n const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const protocolVersion = opts.protocolVersion ?? MCP_PROTOCOL_VERSION;\n const results: DiagnosticResult[] = [];\n\n // spawnChild resolves a bare Windows package runner (npx/uvx → .cmd/.exe) so\n // the probe agrees with the live serve path; no-op on macOS/Linux.\n const child = spawnChild(command, args, {\n stdio: [\"pipe\", \"pipe\", \"inherit\"],\n env: { ...process.env, ...resolveEnv(opts.env) },\n });\n\n interface Pending {\n resolve: (m: JsonRpcMessage) => void;\n reject: (e: Error) => void;\n }\n const pending = new Map<string, Pending>();\n let spawnErr: Error | null = null;\n let exitCode: number | null = null;\n\n const rejectAll = (e: Error): void => {\n for (const p of pending.values()) p.reject(e);\n pending.clear();\n };\n child.on(\"error\", (e) => {\n spawnErr = e;\n rejectAll(e);\n });\n child.on(\"exit\", (code) => {\n exitCode = code ?? 0;\n rejectAll(new Error(`server exited (code ${exitCode}) before responding`));\n });\n\n const lines = new LineBuffer((line) => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n return; // non-JSON stdout noise — ignore\n }\n if (!isObject(parsed)) return;\n const k = idKey((parsed as JsonRpcMessage).id);\n if (k && pending.has(k)) {\n const p = pending.get(k)!;\n pending.delete(k);\n p.resolve(parsed as JsonRpcMessage);\n }\n });\n child.stdout?.on(\"data\", (c: Buffer) => lines.push(c));\n\n const send = (m: JsonRpcMessage): void => {\n if (child.stdin && child.stdin.writable) child.stdin.write(`${JSON.stringify(m)}\\n`);\n };\n const request = (id: number | string, method: string, params?: unknown): Promise<JsonRpcMessage> => {\n const key = idKey(id)!;\n return new Promise<JsonRpcMessage>((resolve, reject) => {\n const timer = setTimeout(() => {\n pending.delete(key);\n reject(new Error(`no response within ${timeoutMs}ms`));\n }, timeoutMs);\n if (typeof timer.unref === \"function\") timer.unref();\n pending.set(key, {\n resolve: (m) => {\n clearTimeout(timer);\n resolve(m);\n },\n reject: (e) => {\n clearTimeout(timer);\n reject(e);\n },\n });\n send({ jsonrpc: \"2.0\", id, method, ...(params !== undefined ? { params } : {}) });\n });\n };\n\n const cleanup = (): DiagnosticResult[] => {\n try {\n if (child.stdin && child.stdin.writable) child.stdin.end();\n } catch {\n /* ignore */\n }\n try {\n child.kill(\"SIGTERM\");\n } catch {\n /* ignore */\n }\n const killTimer = setTimeout(() => {\n try {\n child.kill(\"SIGKILL\");\n } catch {\n /* ignore */\n }\n }, 500);\n if (typeof killTimer.unref === \"function\") killTimer.unref();\n return results;\n };\n\n // 1. initialize\n let initResult: Record<string, unknown>;\n try {\n const res = await request(1, \"initialize\", {\n protocolVersion,\n capabilities: {},\n clientInfo: { name: \"agent-connector-probe\", version: \"1\" },\n });\n if (isObject(res.error)) {\n results.push(\n diag(\"fail\", `${label}MCP initialize`, `server returned error: ${JSON.stringify(res.error)}`),\n );\n return cleanup();\n }\n initResult = isObject(res.result) ? res.result : {};\n } catch (e) {\n if (spawnErr) {\n results.push(\n diag(\n \"fail\",\n `${label}MCP initialize`,\n `server not launchable: ${errMsg(spawnErr)}`,\n `check that \"${command}\" is installed and on PATH`,\n ),\n );\n } else if (exitCode !== null) {\n // On Windows an unresolvable command surfaces as an early non-zero exit\n // (cmd.exe \"command not found\") rather than a spawn 'error' event, so fold\n // the not-launchable hint in here too — useful whether the command is\n // missing or the server genuinely crashed before initialize.\n results.push(\n diag(\n \"fail\",\n `${label}MCP initialize`,\n `server not launchable, or it exited (code ${exitCode}) before initialize`,\n `check that \"${command}\" is installed and on PATH`,\n ),\n );\n } else {\n results.push(diag(\"fail\", `${label}MCP initialize`, errMsg(e)));\n }\n return cleanup();\n }\n\n const serverInfo = isObject(initResult.serverInfo) ? initResult.serverInfo : {};\n const sName = typeof serverInfo.name === \"string\" ? serverInfo.name : \"unknown\";\n const sVer = typeof serverInfo.version === \"string\" ? serverInfo.version : \"?\";\n const negotiated =\n typeof initResult.protocolVersion === \"string\" ? initResult.protocolVersion : \"(none)\";\n results.push(diag(\"pass\", `${label}MCP initialize`, `serverInfo ${sName}@${sVer}, protocol ${negotiated}`));\n\n // capabilities (presence = feature offered)\n const caps = isObject(initResult.capabilities) ? initResult.capabilities : {};\n const capNames = [\"tools\", \"resources\", \"prompts\", \"logging\", \"completions\"].filter((c) => c in caps);\n results.push(\n diag(\"pass\", `${label}capabilities`, capNames.length > 0 ? capNames.join(\", \") : \"(none advertised)\"),\n );\n\n // 2. initialized notification (required before normal requests)\n send({ jsonrpc: \"2.0\", method: \"notifications/initialized\" });\n\n // 3. ping — liveness confirm (warn, not fail, on timeout)\n try {\n await request(\"probe-ping\", \"ping\");\n results.push(diag(\"pass\", `${label}ping`, \"alive\"));\n } catch (e) {\n results.push(diag(\"warn\", `${label}ping`, `no ping response (${errMsg(e)})`));\n }\n\n // 4. tools/list — only if the server advertised a tools capability\n if (\"tools\" in caps) {\n try {\n const res = await request(2, \"tools/list\", {});\n const r = isObject(res.result) ? res.result : {};\n const tools = Array.isArray(r.tools) ? r.tools : [];\n results.push(diag(\"pass\", `${label}tools/list`, `${tools.length} tool(s)`));\n } catch (e) {\n results.push(diag(\"fail\", `${label}tools/list`, `no tools/list response (${errMsg(e)})`));\n }\n } else {\n results.push(\n diag(\"warn\", `${label}tools/list`, \"skipped — server advertised no tools capability\"),\n );\n }\n\n return cleanup();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,SAAS,iBAAiB;;;ACW1B,IAAM,qBAAqB;AAa3B,SAAS,KACP,QACA,OACA,SACA,KACkB;AAClB,SAAO,EAAE,OAAO,QAAQ,SAAS,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC,EAAG;AAC3D;AAEA,SAAS,OAAO,GAAoB;AAClC,SAAO,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AAClD;AAGA,SAAS,WAAW,KAAiE;AACnF,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,GAAG,C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
7
7
  } from "./chunk-DBQMX75U.js";
8
8
  import {
9
- BaseAdapter
10
- } from "./chunk-3I7UG52L.js";
11
- import {
9
+ BaseAdapter,
12
10
  renderCommandMd
13
- } from "./chunk-IEGR4TP3.js";
11
+ } from "./chunk-A767JFHW.js";
14
12
  import {
15
13
  buildWrappedStdio,
16
14
  isHomeBinHookCommand
@@ -657,4 +655,4 @@ export {
657
655
  adapter,
658
656
  droid_default as default
659
657
  };
660
- //# sourceMappingURL=droid-X2QHQL7D.js.map
658
+ //# sourceMappingURL=droid-NZCKYKOV.js.map