@ken-jo/agent-connector 0.3.1 → 0.4.1

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 (189) hide show
  1. package/README.md +180 -16
  2. package/dist/action-WT7GVRCC.js +55 -0
  3. package/dist/action-WT7GVRCC.js.map +1 -0
  4. package/dist/amazon-q-COAL3764.js +276 -0
  5. package/dist/amazon-q-COAL3764.js.map +1 -0
  6. package/dist/{amp-YGV66GJT.js → amp-4U33CU7E.js} +81 -5
  7. package/dist/amp-4U33CU7E.js.map +1 -0
  8. package/dist/{antigravity-7IBYFO6P.js → antigravity-AMKKKHS4.js} +4 -4
  9. package/dist/{antigravity-cli-JEOUP2VN.js → antigravity-cli-XERXEH5W.js} +4 -4
  10. package/dist/{chunk-3JCRUROU.js → chunk-24IDL5RW.js} +13 -4
  11. package/dist/chunk-24IDL5RW.js.map +1 -0
  12. package/dist/chunk-2AVLX7GH.js +351 -0
  13. package/dist/chunk-2AVLX7GH.js.map +1 -0
  14. package/dist/{chunk-GSGDG2BV.js → chunk-4ENJK5S2.js} +106 -176
  15. package/dist/chunk-4ENJK5S2.js.map +1 -0
  16. package/dist/{chunk-ZAM4M7LI.js → chunk-5OWS5CMA.js} +136 -296
  17. package/dist/chunk-5OWS5CMA.js.map +1 -0
  18. package/dist/{chunk-PD4VFEBY.js → chunk-CPLK7GTE.js} +79 -5
  19. package/dist/chunk-CPLK7GTE.js.map +1 -0
  20. package/dist/chunk-DCKFYWGM.js +237 -0
  21. package/dist/chunk-DCKFYWGM.js.map +1 -0
  22. package/dist/chunk-EGCBZ2DC.js +83 -0
  23. package/dist/chunk-EGCBZ2DC.js.map +1 -0
  24. package/dist/chunk-F5RX62T7.js +21 -0
  25. package/dist/chunk-F5RX62T7.js.map +1 -0
  26. package/dist/chunk-FAHIMJRU.js +177 -0
  27. package/dist/chunk-FAHIMJRU.js.map +1 -0
  28. package/dist/{chunk-MEH7GC7R.js → chunk-I5MLE6S7.js} +33 -3
  29. package/dist/chunk-I5MLE6S7.js.map +1 -0
  30. package/dist/{chunk-KVAAFYRR.js → chunk-KHO5WNTP.js} +2 -18
  31. package/dist/chunk-KHO5WNTP.js.map +1 -0
  32. package/dist/{chunk-KQSNDFBN.js → chunk-LQRAPXS4.js} +3 -3
  33. package/dist/{chunk-3RBLIHPZ.js → chunk-O5TWCIJN.js} +27 -17
  34. package/dist/chunk-O5TWCIJN.js.map +1 -0
  35. package/dist/{chunk-WNREHWKL.js → chunk-QREL7LZJ.js} +5 -4
  36. package/dist/chunk-QREL7LZJ.js.map +1 -0
  37. package/dist/{chunk-KMAKDD3Z.js → chunk-RIMVWCZY.js} +37 -12
  38. package/dist/chunk-RIMVWCZY.js.map +1 -0
  39. package/dist/{openclaw-UZ5BMCGQ.js → chunk-URHQMFB3.js} +210 -41
  40. package/dist/chunk-URHQMFB3.js.map +1 -0
  41. package/dist/chunk-WZA4CSGJ.js +28 -0
  42. package/dist/chunk-WZA4CSGJ.js.map +1 -0
  43. package/dist/chunk-XJ4S47CT.js +44 -0
  44. package/dist/chunk-XJ4S47CT.js.map +1 -0
  45. package/dist/{claude-code-4275HQU4.js → claude-code-W4PUFZL5.js} +194 -52
  46. package/dist/claude-code-W4PUFZL5.js.map +1 -0
  47. package/dist/cli/sdk.js +5 -3
  48. package/dist/cli/sdk.js.map +1 -1
  49. package/dist/cli.js +1 -1
  50. package/dist/cline-WRYMNS7Z.js +442 -0
  51. package/dist/cline-WRYMNS7Z.js.map +1 -0
  52. package/dist/{codebuff-LE3KBZGM.js → codebuff-DH5Y7GAT.js} +106 -5
  53. package/dist/codebuff-DH5Y7GAT.js.map +1 -0
  54. package/dist/{codex-4BY2ZJIW.js → codex-DDHIV767.js} +43 -11
  55. package/dist/codex-DDHIV767.js.map +1 -0
  56. package/dist/continue-K43SUHLQ.js +790 -0
  57. package/dist/continue-K43SUHLQ.js.map +1 -0
  58. package/dist/{copilot-cli-IPISKO3V.js → copilot-cli-Q3SSPT4V.js} +70 -12
  59. package/dist/copilot-cli-Q3SSPT4V.js.map +1 -0
  60. package/dist/{crush-X3E25EQG.js → crush-MBEH2R3I.js} +130 -6
  61. package/dist/crush-MBEH2R3I.js.map +1 -0
  62. package/dist/{cursor-UH3W622V.js → cursor-TMBXDYR4.js} +119 -16
  63. package/dist/cursor-TMBXDYR4.js.map +1 -0
  64. package/dist/{detect-U3E7NVNW.js → detect-KG5FG3EV.js} +5 -3
  65. package/dist/{detect-U3E7NVNW.js.map → detect-KG5FG3EV.js.map} +1 -1
  66. package/dist/{doctor-DZTWED4O.js → doctor-FLZF34Y3.js} +226 -96
  67. package/dist/doctor-FLZF34Y3.js.map +1 -0
  68. package/dist/{droid-T5VBRXZF.js → droid-JC2NT6S4.js} +298 -10
  69. package/dist/droid-JC2NT6S4.js.map +1 -0
  70. package/dist/{gemini-cli-ZSUK55UA.js → gemini-cli-ILR7M5X3.js} +62 -10
  71. package/dist/gemini-cli-ILR7M5X3.js.map +1 -0
  72. package/dist/{goose-M3RR3CZG.js → goose-SFO5BBGW.js} +112 -10
  73. package/dist/goose-SFO5BBGW.js.map +1 -0
  74. package/dist/{hermes-CUNKIAR5.js → hermes-3N7WN4WS.js} +329 -15
  75. package/dist/hermes-3N7WN4WS.js.map +1 -0
  76. package/dist/{hook-EVY7LOUQ.js → hook-XR3Z45FB.js} +16 -10
  77. package/dist/hook-XR3Z45FB.js.map +1 -0
  78. package/dist/index.d.ts +71 -3
  79. package/dist/index.js +23 -3
  80. package/dist/{install-OWAS5UIE.js → install-BSR62UHJ.js} +12 -9
  81. package/dist/{install-OWAS5UIE.js.map → install-BSR62UHJ.js.map} +1 -1
  82. package/dist/introspect-Nw8hTReX.d.ts +53 -0
  83. package/dist/{jetbrains-copilot-C3HDGGML.js → jetbrains-copilot-NRZHI5PC.js} +85 -18
  84. package/dist/jetbrains-copilot-NRZHI5PC.js.map +1 -0
  85. package/dist/{kilo-PKAJCWPX.js → kilo-5NWOXVSD.js} +16 -16
  86. package/dist/kilo-5NWOXVSD.js.map +1 -0
  87. package/dist/{kilo-cli-QWUVXG2O.js → kilo-cli-UZ7R5UOP.js} +3 -3
  88. package/dist/{kimi-EVD7YKXS.js → kimi-2YFK2GBA.js} +87 -25
  89. package/dist/kimi-2YFK2GBA.js.map +1 -0
  90. package/dist/{kiro-UQRY6EIO.js → kiro-YL6AWUYG.js} +3 -3
  91. package/dist/{leaderboard-CSWHI4UY.js → leaderboard-MJG24O35.js} +2 -2
  92. package/dist/mimo-code-FTMGSKMQ.js +790 -0
  93. package/dist/mimo-code-FTMGSKMQ.js.map +1 -0
  94. package/dist/{mux-5CI5FP2W.js → mux-5XZFB44C.js} +156 -6
  95. package/dist/mux-5XZFB44C.js.map +1 -0
  96. package/dist/nemoclaw-W5KEJ3WX.js +58 -0
  97. package/dist/nemoclaw-W5KEJ3WX.js.map +1 -0
  98. package/dist/{omp-AXA7XY22.js → omp-2QMEY6HD.js} +138 -18
  99. package/dist/omp-2QMEY6HD.js.map +1 -0
  100. package/dist/openclaw-EXJEFNZI.js +18 -0
  101. package/dist/openclaw-EXJEFNZI.js.map +1 -0
  102. package/dist/{opencode-NZBRLJN3.js → opencode-WNXYJR4X.js} +84 -27
  103. package/dist/opencode-WNXYJR4X.js.map +1 -0
  104. package/dist/{package-WFOS4QVU.js → package-ACZXJHWB.js} +8 -6
  105. package/dist/{package-WFOS4QVU.js.map → package-ACZXJHWB.js.map} +1 -1
  106. package/dist/{pi-WMTUX6ES.js → pi-PVVPVWKG.js} +3 -2
  107. package/dist/{pi-WMTUX6ES.js.map → pi-PVVPVWKG.js.map} +1 -1
  108. package/dist/{qwen-code-MRRIUQ3P.js → qwen-code-G4CXKUHR.js} +426 -10
  109. package/dist/qwen-code-G4CXKUHR.js.map +1 -0
  110. package/dist/{roo-code-NI5UU6JB.js → roo-code-67TYJIQR.js} +137 -4
  111. package/dist/roo-code-67TYJIQR.js.map +1 -0
  112. package/dist/runtime/index.d.ts +96 -2
  113. package/dist/runtime/index.js +19 -10
  114. package/dist/sdk/index.d.ts +52 -0
  115. package/dist/sdk/index.js +82 -0
  116. package/dist/sdk/index.js.map +1 -0
  117. package/dist/sdk/test.d.ts +74 -0
  118. package/dist/sdk/test.js +292 -0
  119. package/dist/sdk/test.js.map +1 -0
  120. package/dist/{serve-3C2VFPAY.js → serve-GER7URPR.js} +13 -9
  121. package/dist/{serve-3C2VFPAY.js.map → serve-GER7URPR.js.map} +1 -1
  122. package/dist/{status-MKQYX5MW.js → status-LAJE3BM5.js} +10 -7
  123. package/dist/{status-MKQYX5MW.js.map → status-LAJE3BM5.js.map} +1 -1
  124. package/dist/statusline-L376ZPZU.js +60 -0
  125. package/dist/statusline-L376ZPZU.js.map +1 -0
  126. package/dist/{telemetry-3DN6XGYB.js → telemetry-B3DX3PWU.js} +6 -4
  127. package/dist/{telemetry-3DN6XGYB.js.map → telemetry-B3DX3PWU.js.map} +1 -1
  128. package/dist/{trae-CQC72RHH.js → trae-7CZZGOGI.js} +99 -5
  129. package/dist/trae-7CZZGOGI.js.map +1 -0
  130. package/dist/{types-CNigfEuR.d.ts → types-CRVrFWeU.d.ts} +322 -18
  131. package/dist/{uninstall-WG6PFWF3.js → uninstall-ZYTW7YMZ.js} +12 -9
  132. package/dist/{uninstall-WG6PFWF3.js.map → uninstall-ZYTW7YMZ.js.map} +1 -1
  133. package/dist/{upgrade-32NC2RKI.js → upgrade-4LUEEOZW.js} +12 -9
  134. package/dist/{upgrade-32NC2RKI.js.map → upgrade-4LUEEOZW.js.map} +1 -1
  135. package/dist/{usage-CJOM2WQM.js → usage-ZFBVQF3H.js} +2 -2
  136. package/dist/{usage-event-472X3DOY.js → usage-event-GZ32AGEB.js} +12 -8
  137. package/dist/{usage-event-472X3DOY.js.map → usage-event-GZ32AGEB.js.map} +1 -1
  138. package/dist/{vscode-copilot-4RVRTCKV.js → vscode-copilot-MF2CDNMT.js} +23 -10
  139. package/dist/vscode-copilot-MF2CDNMT.js.map +1 -0
  140. package/dist/{warp-X6MB67NT.js → warp-VKG55TAT.js} +55 -4
  141. package/dist/warp-VKG55TAT.js.map +1 -0
  142. package/dist/windsurf-FU5G4SHF.js +443 -0
  143. package/dist/windsurf-FU5G4SHF.js.map +1 -0
  144. package/dist/{zed-NTCYW4V2.js → zed-SFUHL3GS.js} +3 -3
  145. package/package.json +10 -2
  146. package/dist/amp-YGV66GJT.js.map +0 -1
  147. package/dist/chunk-3JCRUROU.js.map +0 -1
  148. package/dist/chunk-3RBLIHPZ.js.map +0 -1
  149. package/dist/chunk-GSGDG2BV.js.map +0 -1
  150. package/dist/chunk-KMAKDD3Z.js.map +0 -1
  151. package/dist/chunk-KVAAFYRR.js.map +0 -1
  152. package/dist/chunk-MEH7GC7R.js.map +0 -1
  153. package/dist/chunk-NJU275US.js +0 -238
  154. package/dist/chunk-NJU275US.js.map +0 -1
  155. package/dist/chunk-PD4VFEBY.js.map +0 -1
  156. package/dist/chunk-WNREHWKL.js.map +0 -1
  157. package/dist/chunk-ZAM4M7LI.js.map +0 -1
  158. package/dist/claude-code-4275HQU4.js.map +0 -1
  159. package/dist/codebuff-LE3KBZGM.js.map +0 -1
  160. package/dist/codex-4BY2ZJIW.js.map +0 -1
  161. package/dist/copilot-cli-IPISKO3V.js.map +0 -1
  162. package/dist/crush-X3E25EQG.js.map +0 -1
  163. package/dist/cursor-UH3W622V.js.map +0 -1
  164. package/dist/doctor-DZTWED4O.js.map +0 -1
  165. package/dist/droid-T5VBRXZF.js.map +0 -1
  166. package/dist/gemini-cli-ZSUK55UA.js.map +0 -1
  167. package/dist/goose-M3RR3CZG.js.map +0 -1
  168. package/dist/hermes-CUNKIAR5.js.map +0 -1
  169. package/dist/hook-EVY7LOUQ.js.map +0 -1
  170. package/dist/jetbrains-copilot-C3HDGGML.js.map +0 -1
  171. package/dist/kilo-PKAJCWPX.js.map +0 -1
  172. package/dist/kimi-EVD7YKXS.js.map +0 -1
  173. package/dist/mux-5CI5FP2W.js.map +0 -1
  174. package/dist/omp-AXA7XY22.js.map +0 -1
  175. package/dist/openclaw-UZ5BMCGQ.js.map +0 -1
  176. package/dist/opencode-NZBRLJN3.js.map +0 -1
  177. package/dist/qwen-code-MRRIUQ3P.js.map +0 -1
  178. package/dist/roo-code-NI5UU6JB.js.map +0 -1
  179. package/dist/trae-CQC72RHH.js.map +0 -1
  180. package/dist/vscode-copilot-4RVRTCKV.js.map +0 -1
  181. package/dist/warp-X6MB67NT.js.map +0 -1
  182. /package/dist/{antigravity-7IBYFO6P.js.map → antigravity-AMKKKHS4.js.map} +0 -0
  183. /package/dist/{antigravity-cli-JEOUP2VN.js.map → antigravity-cli-XERXEH5W.js.map} +0 -0
  184. /package/dist/{chunk-KQSNDFBN.js.map → chunk-LQRAPXS4.js.map} +0 -0
  185. /package/dist/{kilo-cli-QWUVXG2O.js.map → kilo-cli-UZ7R5UOP.js.map} +0 -0
  186. /package/dist/{kiro-UQRY6EIO.js.map → kiro-YL6AWUYG.js.map} +0 -0
  187. /package/dist/{leaderboard-CSWHI4UY.js.map → leaderboard-MJG24O35.js.map} +0 -0
  188. /package/dist/{usage-CJOM2WQM.js.map → usage-ZFBVQF3H.js.map} +0 -0
  189. /package/dist/{zed-NTCYW4V2.js.map → zed-SFUHL3GS.js.map} +0 -0
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- marketplaceDoctorChecks
4
- } from "./chunk-KMAKDD3Z.js";
5
- import "./chunk-WNREHWKL.js";
3
+ marketplaceDoctorChecks,
4
+ syncConnector
5
+ } from "./chunk-RIMVWCZY.js";
6
+ import "./chunk-QREL7LZJ.js";
6
7
  import {
7
8
  readMarketplaceInstalls
8
9
  } from "./chunk-G5CQHVQG.js";
@@ -11,7 +12,7 @@ import {
11
12
  parseScope,
12
13
  parseTargets,
13
14
  print
14
- } from "./chunk-3RBLIHPZ.js";
15
+ } from "./chunk-O5TWCIJN.js";
15
16
  import {
16
17
  LineBuffer,
17
18
  idKey,
@@ -19,23 +20,28 @@ import {
19
20
  } from "./chunk-OP4KBXUO.js";
20
21
  import {
21
22
  spawnChild
22
- } from "./chunk-KVAAFYRR.js";
23
+ } from "./chunk-F5RX62T7.js";
23
24
  import {
24
- REGISTERED_PLATFORM_IDS,
25
- detectInstalledPlatforms,
26
- loadAdapter
27
- } from "./chunk-NJU275US.js";
25
+ detectInstalledPlatforms
26
+ } from "./chunk-EGCBZ2DC.js";
27
+ import "./chunk-KHO5WNTP.js";
28
28
  import {
29
29
  findConnectorConfig,
30
30
  listRegisteredConnectors,
31
- loadConnectorFromPath
32
- } from "./chunk-3JCRUROU.js";
31
+ loadConnectorFromPath,
32
+ readRegisteredMeta
33
+ } from "./chunk-24IDL5RW.js";
33
34
  import {
34
35
  MCP_PROTOCOL_VERSION
35
- } from "./chunk-GSGDG2BV.js";
36
+ } from "./chunk-4ENJK5S2.js";
37
+ import {
38
+ REGISTERED_PLATFORM_IDS,
39
+ loadAdapter
40
+ } from "./chunk-DCKFYWGM.js";
41
+ import "./chunk-FAHIMJRU.js";
36
42
  import "./chunk-OPXAP3AC.js";
37
43
  import "./chunk-7L6ITC4T.js";
38
- import "./chunk-MEH7GC7R.js";
44
+ import "./chunk-I5MLE6S7.js";
39
45
  import "./chunk-N6HH7K6P.js";
40
46
  import {
41
47
  dataRoot,
@@ -225,36 +231,41 @@ async function resolveDoctorConnectors(connectorPath, projectDir) {
225
231
  const configPath = connectorPath ?? findConnectorConfig(projectDir);
226
232
  if (configPath) {
227
233
  try {
228
- const { connector } = await loadConnectorFromPath(configPath);
229
- return [connector];
234
+ const { connector, modulePath } = await loadConnectorFromPath(configPath);
235
+ return [{ connector, modulePath }];
230
236
  } catch {
231
237
  }
232
238
  }
233
239
  const registered = listRegisteredConnectors();
234
- if (registered.length > 0) return registered;
235
- return [
236
- {
237
- id: "agent-connector",
238
- displayName: "agent-connector",
239
- version: "0.0.0",
240
- hooks: {},
241
- hookEvents: [],
242
- telemetry: {
243
- enabled: true,
244
- modelFamilyHint: "auto",
245
- measureToolDefs: true,
246
- hostNativeUsage: false,
247
- store: "ndjson",
248
- calibration: { anthropicCountTokens: false }
249
- },
250
- commands: [],
251
- skills: [],
252
- subagents: [],
253
- memory: [],
254
- platforms: {},
255
- targets: "auto"
256
- }
257
- ];
240
+ if (registered.length > 0) {
241
+ return registered.map((connector) => {
242
+ const meta = readRegisteredMeta(connector.id);
243
+ return { connector, modulePath: meta?.modulePath ?? "" };
244
+ });
245
+ }
246
+ const fallback = {
247
+ id: "agent-connector",
248
+ displayName: "agent-connector",
249
+ version: "0.0.0",
250
+ hooks: {},
251
+ hookEvents: [],
252
+ telemetry: {
253
+ enabled: true,
254
+ modelFamilyHint: "auto",
255
+ measureToolDefs: true,
256
+ hostNativeUsage: false,
257
+ store: "ndjson",
258
+ calibration: { anthropicCountTokens: false }
259
+ },
260
+ commands: [],
261
+ skills: [],
262
+ subagents: [],
263
+ memory: [],
264
+ actions: [],
265
+ platforms: {},
266
+ targets: "auto"
267
+ };
268
+ return [{ connector: fallback, modulePath: "" }];
258
269
  }
259
270
  function buildContext(connector, id, scope, projectDir) {
260
271
  return {
@@ -266,6 +277,67 @@ function buildContext(connector, id, scope, projectDir) {
266
277
  dryRun: true
267
278
  };
268
279
  }
280
+ async function collectDiagnostics(entries, ids, scope, projectDir) {
281
+ const multi = entries.length > 1;
282
+ const byPlatform = [];
283
+ const tagged = [];
284
+ let anyFail = false;
285
+ for (const id of ids) {
286
+ const adapter = await loadAdapter(id);
287
+ if (!adapter) {
288
+ const r = {
289
+ check: `${id}: adapter`,
290
+ status: "fail",
291
+ message: `no adapter registered for ${id}`
292
+ };
293
+ byPlatform.push({ platform: id, results: [r] });
294
+ anyFail = true;
295
+ continue;
296
+ }
297
+ const results = [];
298
+ for (let i = 0; i < entries.length; i++) {
299
+ const { connector } = entries[i];
300
+ if (connector.targets !== "auto" && !connector.targets.includes(id)) continue;
301
+ if (readMarketplaceInstalls(connector.id)[id]) {
302
+ const note = {
303
+ check: `${connector.id}: ${id} delivery`,
304
+ status: "pass",
305
+ message: "surfaces delivered via the marketplace plugin \u2014 see marketplace checks"
306
+ };
307
+ const tagged_note = multi ? { ...note, check: `(${connector.id}) ${note.check}` } : note;
308
+ results.push(tagged_note);
309
+ tagged.push({ result: tagged_note, entryIndex: i });
310
+ continue;
311
+ }
312
+ const ctx = buildContext(connector, id, scope, projectDir);
313
+ let r;
314
+ try {
315
+ r = adapter.doctor(ctx);
316
+ } catch (err) {
317
+ const message = err instanceof Error ? err.message : String(err);
318
+ r = [{ check: `${adapter.name}: doctor`, status: "fail", message }];
319
+ }
320
+ const tagged_r = multi ? r.map((d) => ({ ...d, check: `(${connector.id}) ${d.check}` })) : r;
321
+ results.push(...tagged_r);
322
+ for (const tr of tagged_r) tagged.push({ result: tr, entryIndex: i });
323
+ }
324
+ if (results.some((d) => d.status === "fail")) anyFail = true;
325
+ byPlatform.push({ platform: id, results });
326
+ }
327
+ for (let i = 0; i < entries.length; i++) {
328
+ const { connector } = entries[i];
329
+ const groups = await marketplaceDoctorChecks(connector, scope, projectDir);
330
+ for (const group of groups) {
331
+ const tagged_g = multi ? group.results.map((d) => ({ ...d, check: `(${connector.id}) ${d.check}` })) : group.results;
332
+ if (tagged_g.some((d) => d.status === "fail")) anyFail = true;
333
+ for (const tg of tagged_g) tagged.push({ result: tg, entryIndex: i });
334
+ const bucket = byPlatform.find((b) => b.platform === group.platform);
335
+ if (bucket) bucket.results.push(...tagged_g);
336
+ else byPlatform.push({ platform: group.platform, results: tagged_g });
337
+ }
338
+ }
339
+ return { byPlatform, tagged, anyFail };
340
+ }
269
341
  async function run(argv) {
270
342
  const { values } = parseArgs({
271
343
  args: argv,
@@ -275,15 +347,17 @@ async function run(argv) {
275
347
  connector: { type: "string" },
276
348
  project: { type: "string" },
277
349
  json: { type: "boolean", default: false },
278
- probe: { type: "boolean", default: false }
350
+ probe: { type: "boolean", default: false },
351
+ heal: { type: "boolean", default: false },
352
+ "dry-run": { type: "boolean", default: false }
279
353
  },
280
354
  allowPositionals: false
281
355
  });
282
356
  const projectDir = values.project ?? process.cwd();
283
357
  const scope = parseScope(values.scope);
284
358
  if (scope == null) return fail(`invalid --scope "${values.scope}" (use user|project)`);
285
- const connectors = await resolveDoctorConnectors(values.connector, projectDir);
286
- const multi = connectors.length > 1;
359
+ const entries = await resolveDoctorConnectors(values.connector, projectDir);
360
+ const connectors = entries.map((e) => e.connector);
287
361
  const explicit = parseTargets(values.targets);
288
362
  let ids;
289
363
  if (explicit && explicit.length > 0) {
@@ -301,64 +375,120 @@ async function run(argv) {
301
375
  print("doctor: no target platforms (none detected; pass --targets to force).");
302
376
  return 0;
303
377
  }
304
- const byPlatform = [];
305
- let anyFail = false;
306
- for (const id of ids) {
307
- const adapter = await loadAdapter(id);
308
- if (!adapter) {
309
- byPlatform.push({
310
- platform: id,
311
- results: [
312
- {
313
- check: `${id}: adapter`,
314
- status: "fail",
315
- message: `no adapter registered for ${id}`
316
- }
317
- ]
378
+ if (values.heal) {
379
+ const { tagged, anyFail: preFail } = await collectDiagnostics(
380
+ entries,
381
+ ids,
382
+ scope,
383
+ projectDir
384
+ );
385
+ const fixableByEntry = /* @__PURE__ */ new Map();
386
+ const deferredByEntry = /* @__PURE__ */ new Map();
387
+ for (const { result, entryIndex } of tagged) {
388
+ if (result.status === "pass") continue;
389
+ const canSync = !!entries[entryIndex].modulePath;
390
+ if (result.fixable && canSync) {
391
+ if (!fixableByEntry.has(entryIndex)) fixableByEntry.set(entryIndex, []);
392
+ fixableByEntry.get(entryIndex).push(result);
393
+ } else {
394
+ if (!deferredByEntry.has(entryIndex)) deferredByEntry.set(entryIndex, []);
395
+ deferredByEntry.get(entryIndex).push(result);
396
+ }
397
+ }
398
+ if (values["dry-run"]) {
399
+ for (const [idx, fixable] of fixableByEntry) {
400
+ const { connector } = entries[idx];
401
+ print(
402
+ `would heal via sync (${connector.id}): ${fixable.map((r) => r.check).join(", ")}`
403
+ );
404
+ }
405
+ for (const [idx, deferred2] of deferredByEntry) {
406
+ const { connector } = entries[idx];
407
+ for (const r of deferred2) {
408
+ print(
409
+ `would defer (${connector.id}): ${r.check} \u2014 ${r.fix ?? "no auto-fix available"}`
410
+ );
411
+ }
412
+ }
413
+ if (fixableByEntry.size === 0 && deferredByEntry.size === 0) {
414
+ print("doctor --heal --dry-run: nothing to heal.");
415
+ }
416
+ return 0;
417
+ }
418
+ for (const [idx] of fixableByEntry) {
419
+ const { connector, modulePath } = entries[idx];
420
+ await syncConnector({
421
+ connector,
422
+ modulePath,
423
+ scope,
424
+ projectDir,
425
+ targets: ids,
426
+ dryRun: false
318
427
  });
319
- anyFail = true;
320
- continue;
321
428
  }
322
- const results = [];
323
- for (const connector of connectors) {
324
- if (connector.targets !== "auto" && !connector.targets.includes(id)) continue;
325
- if (readMarketplaceInstalls(connector.id)[id]) {
326
- const note = {
327
- check: `${connector.id}: ${id} delivery`,
328
- status: "pass",
329
- message: "surfaces delivered via the marketplace plugin \u2014 see marketplace checks"
330
- };
331
- results.push(multi ? { ...note, check: `(${connector.id}) ${note.check}` } : note);
332
- continue;
429
+ const { tagged: postTagged, anyFail: postFail } = await collectDiagnostics(
430
+ entries,
431
+ ids,
432
+ scope,
433
+ projectDir
434
+ );
435
+ const preNonPass = new Set(
436
+ tagged.filter((t) => t.result.status !== "pass").map((t) => t.result.check)
437
+ );
438
+ const postNonPass = new Set(
439
+ postTagged.filter((t) => t.result.status !== "pass").map((t) => t.result.check)
440
+ );
441
+ const healed = [];
442
+ const stillFailing = [];
443
+ const deferred = [];
444
+ for (const check of preNonPass) {
445
+ if (!postNonPass.has(check)) healed.push(check);
446
+ }
447
+ for (const { result, entryIndex } of postTagged) {
448
+ if (result.status === "pass") continue;
449
+ const canSync = !!entries[entryIndex].modulePath;
450
+ if (result.fixable && canSync) {
451
+ stillFailing.push(result);
452
+ } else {
453
+ deferred.push(result);
333
454
  }
334
- const ctx = buildContext(connector, id, scope, projectDir);
335
- let r;
336
- try {
337
- r = adapter.doctor(ctx);
338
- } catch (err) {
339
- const message = err instanceof Error ? err.message : String(err);
340
- r = [{ check: `${adapter.name}: doctor`, status: "fail", message }];
455
+ }
456
+ if (values.json) {
457
+ print(JSON.stringify({ healed, deferred, stillFailing }, null, 2));
458
+ return postFail ? 1 : 0;
459
+ }
460
+ if (healed.length > 0) {
461
+ print(`healed (${healed.length}):`);
462
+ for (const c of healed) print(` [pass] ${c}`);
463
+ print("");
464
+ }
465
+ if (stillFailing.length > 0) {
466
+ print(`still failing after sync (${stillFailing.length}):`);
467
+ for (const r of stillFailing) {
468
+ print(` ${STATUS_GLYPH[r.status]} ${r.check} \u2014 ${r.message}`);
469
+ if (r.fix) print(` fix: ${r.fix}`);
341
470
  }
342
- results.push(
343
- ...multi ? r.map((d) => ({ ...d, check: `(${connector.id}) ${d.check}` })) : r
344
- );
471
+ print("");
345
472
  }
346
- if (results.some((d) => d.status === "fail")) anyFail = true;
347
- byPlatform.push({ platform: id, results });
348
- }
349
- for (const connector of connectors) {
350
- const groups = await marketplaceDoctorChecks(connector, scope, projectDir);
351
- for (const group of groups) {
352
- const tagged = multi ? group.results.map((d) => ({ ...d, check: `(${connector.id}) ${d.check}` })) : group.results;
353
- if (tagged.some((d) => d.status === "fail")) anyFail = true;
354
- const bucket = byPlatform.find((b) => b.platform === group.platform);
355
- if (bucket) bucket.results.push(...tagged);
356
- else byPlatform.push({ platform: group.platform, results: tagged });
473
+ if (deferred.length > 0) {
474
+ print(`deferred \u2014 requires manual action (${deferred.length}):`);
475
+ for (const r of deferred) {
476
+ print(` ${STATUS_GLYPH[r.status]} ${r.check} \u2014 ${r.message}`);
477
+ if (r.fix) print(` fix: ${r.fix}`);
478
+ }
479
+ print("");
480
+ }
481
+ if (healed.length === 0 && stillFailing.length === 0 && deferred.length === 0 && !preFail) {
482
+ print("doctor --heal: nothing to heal, all checks passed.");
483
+ } else if (stillFailing.length === 0 && deferred.length === 0) {
484
+ print("doctor --heal: all fixable findings resolved.");
357
485
  }
486
+ return postFail ? 1 : 0;
358
487
  }
488
+ const { byPlatform, anyFail } = await collectDiagnostics(entries, ids, scope, projectDir);
359
489
  const probes = [];
360
490
  if (values.probe) {
361
- for (const connector of connectors) {
491
+ for (const { connector } of entries) {
362
492
  const s = connector.server;
363
493
  if (!s || s.transport !== "stdio" || !s.command) {
364
494
  probes.push({
@@ -377,13 +507,13 @@ async function run(argv) {
377
507
  label: connector.id,
378
508
  ...s.env ? { env: s.env } : {}
379
509
  });
380
- if (results.some((d) => d.status === "fail")) anyFail = true;
381
510
  probes.push({ connector: connector.id, results });
382
511
  }
383
512
  }
513
+ const probesFail = probes.some((p) => p.results.some((r) => r.status === "fail"));
384
514
  if (values.json) {
385
515
  print(JSON.stringify(values.probe ? { platforms: byPlatform, probes } : byPlatform, null, 2));
386
- return anyFail ? 1 : 0;
516
+ return anyFail || probesFail ? 1 : 0;
387
517
  }
388
518
  for (const { platform, results } of byPlatform) {
389
519
  print(`${platform}:`);
@@ -401,10 +531,10 @@ async function run(argv) {
401
531
  }
402
532
  print("");
403
533
  }
404
- print(anyFail ? "doctor: one or more checks FAILED." : "doctor: all checks passed.");
405
- return anyFail ? 1 : 0;
534
+ print(anyFail || probesFail ? "doctor: one or more checks FAILED." : "doctor: all checks passed.");
535
+ return anyFail || probesFail ? 1 : 0;
406
536
  }
407
537
  export {
408
538
  run
409
539
  };
410
- //# sourceMappingURL=doctor-DZTWED4O.js.map
540
+ //# sourceMappingURL=doctor-FLZF34Y3.js.map
@@ -0,0 +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,GAAoB;AAClC,SAAO,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AAClD;AAGA,SAAS,WAAW,KAAiE;AACnF,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,OAAO,CAAC,CAAC,GAAG;AAC9C,QAAI,CAAC,IAAI,EAAE,QAAQ,uCAAuC,CAAC,IAAI,SAAS,QAAQ,IAAI,IAAI,KAAK,EAAE;AAAA,EACjG;AACA,SAAO;AACT;AAMA,eAAsB,iBACpB,SACA,MACA,OAAqB,CAAC,GACO;AAC7B,QAAM,QAAQ,KAAK,QAAQ,GAAG,KAAK,KAAK,OAAO;AAC/C,QAAM,YAAY,KAAK,aAAa;AACpC,QAAM,kBAAkB,KAAK,mBAAmB;AAChD,QAAM,UAA8B,CAAC;AAIrC,QAAM,QAAQ,WAAW,SAAS,MAAM;AAAA,IACtC,OAAO,CAAC,QAAQ,QAAQ,SAAS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