beth-copilot 1.0.18 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/CHANGELOG.md +41 -28
  2. package/README.md +87 -247
  3. package/bin/cli.js +158 -358
  4. package/dist/__tests__/smoke.test.d.ts +8 -0
  5. package/dist/__tests__/smoke.test.d.ts.map +1 -0
  6. package/dist/__tests__/smoke.test.js +49 -0
  7. package/dist/__tests__/smoke.test.js.map +1 -0
  8. package/dist/cli/commands/beads.e2e.test.d.ts +13 -0
  9. package/dist/cli/commands/beads.e2e.test.d.ts.map +1 -0
  10. package/dist/cli/commands/beads.e2e.test.js +526 -0
  11. package/dist/cli/commands/beads.e2e.test.js.map +1 -0
  12. package/dist/cli/commands/cli-edge-cases.e2e.test.d.ts +32 -0
  13. package/dist/cli/commands/cli-edge-cases.e2e.test.d.ts.map +1 -0
  14. package/dist/cli/commands/cli-edge-cases.e2e.test.js +162 -0
  15. package/dist/cli/commands/cli-edge-cases.e2e.test.js.map +1 -0
  16. package/dist/cli/commands/close.d.ts +89 -0
  17. package/dist/cli/commands/close.d.ts.map +1 -0
  18. package/dist/cli/commands/close.e2e.test.d.ts +27 -0
  19. package/dist/cli/commands/close.e2e.test.d.ts.map +1 -0
  20. package/dist/cli/commands/close.e2e.test.js +252 -0
  21. package/dist/cli/commands/close.e2e.test.js.map +1 -0
  22. package/dist/cli/commands/close.js +309 -0
  23. package/dist/cli/commands/close.js.map +1 -0
  24. package/dist/cli/commands/close.test.d.ts +15 -0
  25. package/dist/cli/commands/close.test.d.ts.map +1 -0
  26. package/dist/cli/commands/close.test.js +634 -0
  27. package/dist/cli/commands/close.test.js.map +1 -0
  28. package/dist/cli/commands/doctor.d.ts +23 -0
  29. package/dist/cli/commands/doctor.d.ts.map +1 -1
  30. package/dist/cli/commands/doctor.js +93 -0
  31. package/dist/cli/commands/doctor.js.map +1 -1
  32. package/dist/cli/commands/doctor.test.js +209 -0
  33. package/dist/cli/commands/doctor.test.js.map +1 -1
  34. package/dist/cli/commands/framework-isolation.test.d.ts +30 -0
  35. package/dist/cli/commands/framework-isolation.test.d.ts.map +1 -0
  36. package/dist/cli/commands/framework-isolation.test.js +119 -0
  37. package/dist/cli/commands/framework-isolation.test.js.map +1 -0
  38. package/dist/cli/commands/help.e2e.test.js +4 -4
  39. package/dist/cli/commands/help.e2e.test.js.map +1 -1
  40. package/dist/cli/commands/init-logic.e2e.test.d.ts +37 -0
  41. package/dist/cli/commands/init-logic.e2e.test.d.ts.map +1 -0
  42. package/dist/cli/commands/init-logic.e2e.test.js +305 -0
  43. package/dist/cli/commands/init-logic.e2e.test.js.map +1 -0
  44. package/dist/cli/commands/land.d.ts +142 -0
  45. package/dist/cli/commands/land.d.ts.map +1 -0
  46. package/dist/cli/commands/land.js +647 -0
  47. package/dist/cli/commands/land.js.map +1 -0
  48. package/dist/cli/commands/land.test.d.ts +20 -0
  49. package/dist/cli/commands/land.test.d.ts.map +1 -0
  50. package/dist/cli/commands/land.test.js +622 -0
  51. package/dist/cli/commands/land.test.js.map +1 -0
  52. package/dist/cli/commands/mcp.e2e.test.js +22 -29
  53. package/dist/cli/commands/mcp.e2e.test.js.map +1 -1
  54. package/dist/cli/commands/pipeline.e2e.test.js +20 -20
  55. package/dist/cli/commands/pipeline.e2e.test.js.map +1 -1
  56. package/dist/cli/commands/pre-push-guard.d.ts +84 -0
  57. package/dist/cli/commands/pre-push-guard.d.ts.map +1 -0
  58. package/dist/cli/commands/pre-push-guard.e2e.test.d.ts +24 -0
  59. package/dist/cli/commands/pre-push-guard.e2e.test.d.ts.map +1 -0
  60. package/dist/cli/commands/pre-push-guard.e2e.test.js +171 -0
  61. package/dist/cli/commands/pre-push-guard.e2e.test.js.map +1 -0
  62. package/dist/cli/commands/pre-push-guard.js +257 -0
  63. package/dist/cli/commands/pre-push-guard.js.map +1 -0
  64. package/dist/cli/commands/pre-push-guard.test.d.ts +15 -0
  65. package/dist/cli/commands/pre-push-guard.test.d.ts.map +1 -0
  66. package/dist/cli/commands/pre-push-guard.test.js +397 -0
  67. package/dist/cli/commands/pre-push-guard.test.js.map +1 -0
  68. package/dist/cli/commands/quickstart-expanded.e2e.test.d.ts +23 -0
  69. package/dist/cli/commands/quickstart-expanded.e2e.test.d.ts.map +1 -0
  70. package/dist/cli/commands/quickstart-expanded.e2e.test.js +179 -0
  71. package/dist/cli/commands/quickstart-expanded.e2e.test.js.map +1 -0
  72. package/dist/cli/commands/quickstart.d.ts.map +1 -1
  73. package/dist/cli/commands/quickstart.js +7 -23
  74. package/dist/cli/commands/quickstart.js.map +1 -1
  75. package/dist/cli/commands/quickstart.test.js +40 -67
  76. package/dist/cli/commands/quickstart.test.js.map +1 -1
  77. package/dist/core/agents/suite.test.js +4 -2
  78. package/dist/core/agents/suite.test.js.map +1 -1
  79. package/dist/core/agents/tools.test.js +5 -1
  80. package/dist/core/agents/tools.test.js.map +1 -1
  81. package/dist/index.d.ts +3 -10
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +5 -10
  84. package/dist/index.js.map +1 -1
  85. package/package.json +15 -9
  86. package/sbom.json +2011 -819
  87. package/templates/.github/agents/beth.agent.md +220 -66
  88. package/templates/.github/agents/developer.agent.md +53 -90
  89. package/templates/.github/agents/product-manager.agent.md +15 -68
  90. package/templates/.github/agents/researcher.agent.md +20 -71
  91. package/templates/.github/agents/security-reviewer.agent.md +29 -81
  92. package/templates/.github/agents/tester.agent.md +40 -69
  93. package/templates/.github/agents/ux-designer.agent.md +20 -74
  94. package/templates/.github/copilot-instructions.md +217 -225
  95. package/templates/AGENTS.md +108 -20
  96. package/templates/mcp.json.example +0 -3
  97. package/dist/cli/commands/client-config.d.ts +0 -31
  98. package/dist/cli/commands/client-config.d.ts.map +0 -1
  99. package/dist/cli/commands/client-config.e2e.test.d.ts +0 -15
  100. package/dist/cli/commands/client-config.e2e.test.d.ts.map +0 -1
  101. package/dist/cli/commands/client-config.e2e.test.js +0 -556
  102. package/dist/cli/commands/client-config.e2e.test.js.map +0 -1
  103. package/dist/cli/commands/client-config.js +0 -73
  104. package/dist/cli/commands/client-config.js.map +0 -1
  105. package/dist/cli/commands/client-config.test.d.ts +0 -6
  106. package/dist/cli/commands/client-config.test.d.ts.map +0 -1
  107. package/dist/cli/commands/client-config.test.js +0 -133
  108. package/dist/cli/commands/client-config.test.js.map +0 -1
  109. package/dist/cli/commands/init-quickstart.e2e.test.d.ts +0 -11
  110. package/dist/cli/commands/init-quickstart.e2e.test.d.ts.map +0 -1
  111. package/dist/cli/commands/init-quickstart.e2e.test.js +0 -221
  112. package/dist/cli/commands/init-quickstart.e2e.test.js.map +0 -1
  113. package/dist/core/context.d.ts +0 -171
  114. package/dist/core/context.d.ts.map +0 -1
  115. package/dist/core/context.js +0 -353
  116. package/dist/core/context.js.map +0 -1
  117. package/dist/core/context.test.d.ts +0 -8
  118. package/dist/core/context.test.d.ts.map +0 -1
  119. package/dist/core/context.test.js +0 -253
  120. package/dist/core/context.test.js.map +0 -1
  121. package/dist/core/handoffs.d.ts +0 -151
  122. package/dist/core/handoffs.d.ts.map +0 -1
  123. package/dist/core/handoffs.js +0 -220
  124. package/dist/core/handoffs.js.map +0 -1
  125. package/dist/core/handoffs.test.d.ts +0 -8
  126. package/dist/core/handoffs.test.d.ts.map +0 -1
  127. package/dist/core/handoffs.test.js +0 -231
  128. package/dist/core/handoffs.test.js.map +0 -1
  129. package/dist/core/orchestrator.d.ts +0 -246
  130. package/dist/core/orchestrator.d.ts.map +0 -1
  131. package/dist/core/orchestrator.js +0 -514
  132. package/dist/core/orchestrator.js.map +0 -1
  133. package/dist/core/orchestrator.test.d.ts +0 -8
  134. package/dist/core/orchestrator.test.d.ts.map +0 -1
  135. package/dist/core/orchestrator.test.js +0 -517
  136. package/dist/core/orchestrator.test.js.map +0 -1
  137. package/dist/core/router.d.ts +0 -102
  138. package/dist/core/router.d.ts.map +0 -1
  139. package/dist/core/router.js +0 -178
  140. package/dist/core/router.js.map +0 -1
  141. package/dist/core/router.test.d.ts +0 -8
  142. package/dist/core/router.test.d.ts.map +0 -1
  143. package/dist/core/router.test.js +0 -215
  144. package/dist/core/router.test.js.map +0 -1
  145. package/dist/init.test.js +0 -288
  146. package/dist/providers/azure.d.ts +0 -147
  147. package/dist/providers/azure.d.ts.map +0 -1
  148. package/dist/providers/azure.js +0 -491
  149. package/dist/providers/azure.js.map +0 -1
  150. package/dist/providers/azure.test.d.ts +0 -11
  151. package/dist/providers/azure.test.d.ts.map +0 -1
  152. package/dist/providers/azure.test.js +0 -330
  153. package/dist/providers/azure.test.js.map +0 -1
  154. package/dist/providers/config.d.ts +0 -87
  155. package/dist/providers/config.d.ts.map +0 -1
  156. package/dist/providers/config.js +0 -193
  157. package/dist/providers/config.js.map +0 -1
  158. package/dist/providers/config.test.d.ts +0 -7
  159. package/dist/providers/config.test.d.ts.map +0 -1
  160. package/dist/providers/config.test.js +0 -370
  161. package/dist/providers/config.test.js.map +0 -1
  162. package/dist/providers/index.d.ts +0 -18
  163. package/dist/providers/index.d.ts.map +0 -1
  164. package/dist/providers/index.js +0 -14
  165. package/dist/providers/index.js.map +0 -1
  166. package/dist/providers/interface.d.ts +0 -191
  167. package/dist/providers/interface.d.ts.map +0 -1
  168. package/dist/providers/interface.js +0 -94
  169. package/dist/providers/interface.js.map +0 -1
  170. package/dist/providers/retry.d.ts +0 -128
  171. package/dist/providers/retry.d.ts.map +0 -1
  172. package/dist/providers/retry.js +0 -205
  173. package/dist/providers/retry.js.map +0 -1
  174. package/dist/providers/retry.test.d.ts +0 -7
  175. package/dist/providers/retry.test.d.ts.map +0 -1
  176. package/dist/providers/retry.test.js +0 -439
  177. package/dist/providers/retry.test.js.map +0 -1
  178. package/dist/providers/streaming.d.ts +0 -157
  179. package/dist/providers/streaming.d.ts.map +0 -1
  180. package/dist/providers/streaming.js +0 -233
  181. package/dist/providers/streaming.js.map +0 -1
  182. package/dist/providers/streaming.test.d.ts +0 -7
  183. package/dist/providers/streaming.test.d.ts.map +0 -1
  184. package/dist/providers/streaming.test.js +0 -372
  185. package/dist/providers/streaming.test.js.map +0 -1
  186. package/dist/providers/types.d.ts +0 -209
  187. package/dist/providers/types.d.ts.map +0 -1
  188. package/dist/providers/types.js +0 -53
  189. package/dist/providers/types.js.map +0 -1
  190. package/dist/providers/types.test.d.ts +0 -7
  191. package/dist/providers/types.test.d.ts.map +0 -1
  192. package/dist/providers/types.test.js +0 -141
  193. package/dist/providers/types.test.js.map +0 -1
  194. package/dist/tools/cli/beads.d.ts +0 -27
  195. package/dist/tools/cli/beads.d.ts.map +0 -1
  196. package/dist/tools/cli/beads.js +0 -172
  197. package/dist/tools/cli/beads.js.map +0 -1
  198. package/dist/tools/cli/beads.test.d.ts +0 -8
  199. package/dist/tools/cli/beads.test.d.ts.map +0 -1
  200. package/dist/tools/cli/beads.test.js +0 -264
  201. package/dist/tools/cli/beads.test.js.map +0 -1
  202. package/dist/tools/cli/editFile.d.ts +0 -17
  203. package/dist/tools/cli/editFile.d.ts.map +0 -1
  204. package/dist/tools/cli/editFile.js +0 -125
  205. package/dist/tools/cli/editFile.js.map +0 -1
  206. package/dist/tools/cli/editFile.test.d.ts +0 -8
  207. package/dist/tools/cli/editFile.test.d.ts.map +0 -1
  208. package/dist/tools/cli/editFile.test.js +0 -177
  209. package/dist/tools/cli/editFile.test.js.map +0 -1
  210. package/dist/tools/cli/readFile.d.ts +0 -25
  211. package/dist/tools/cli/readFile.d.ts.map +0 -1
  212. package/dist/tools/cli/readFile.js +0 -118
  213. package/dist/tools/cli/readFile.js.map +0 -1
  214. package/dist/tools/cli/readFile.test.d.ts +0 -8
  215. package/dist/tools/cli/readFile.test.d.ts.map +0 -1
  216. package/dist/tools/cli/readFile.test.js +0 -194
  217. package/dist/tools/cli/readFile.test.js.map +0 -1
  218. package/dist/tools/cli/search.d.ts +0 -16
  219. package/dist/tools/cli/search.d.ts.map +0 -1
  220. package/dist/tools/cli/search.js +0 -261
  221. package/dist/tools/cli/search.js.map +0 -1
  222. package/dist/tools/cli/search.test.d.ts +0 -8
  223. package/dist/tools/cli/search.test.d.ts.map +0 -1
  224. package/dist/tools/cli/search.test.js +0 -172
  225. package/dist/tools/cli/search.test.js.map +0 -1
  226. package/dist/tools/cli/subagent.d.ts +0 -43
  227. package/dist/tools/cli/subagent.d.ts.map +0 -1
  228. package/dist/tools/cli/subagent.js +0 -99
  229. package/dist/tools/cli/subagent.js.map +0 -1
  230. package/dist/tools/cli/subagent.test.d.ts +0 -8
  231. package/dist/tools/cli/subagent.test.d.ts.map +0 -1
  232. package/dist/tools/cli/subagent.test.js +0 -190
  233. package/dist/tools/cli/subagent.test.js.map +0 -1
  234. package/dist/tools/cli/terminal.d.ts +0 -19
  235. package/dist/tools/cli/terminal.d.ts.map +0 -1
  236. package/dist/tools/cli/terminal.js +0 -164
  237. package/dist/tools/cli/terminal.js.map +0 -1
  238. package/dist/tools/cli/terminal.test.d.ts +0 -8
  239. package/dist/tools/cli/terminal.test.d.ts.map +0 -1
  240. package/dist/tools/cli/terminal.test.js +0 -161
  241. package/dist/tools/cli/terminal.test.js.map +0 -1
  242. package/dist/tools/index.d.ts +0 -25
  243. package/dist/tools/index.d.ts.map +0 -1
  244. package/dist/tools/index.js +0 -41
  245. package/dist/tools/index.js.map +0 -1
  246. package/dist/tools/interface.d.ts +0 -64
  247. package/dist/tools/interface.d.ts.map +0 -1
  248. package/dist/tools/interface.js +0 -37
  249. package/dist/tools/interface.js.map +0 -1
  250. package/dist/tools/interface.test.d.ts +0 -7
  251. package/dist/tools/interface.test.d.ts.map +0 -1
  252. package/dist/tools/interface.test.js +0 -179
  253. package/dist/tools/interface.test.js.map +0 -1
  254. package/dist/tools/mcp/bridge.d.ts +0 -48
  255. package/dist/tools/mcp/bridge.d.ts.map +0 -1
  256. package/dist/tools/mcp/bridge.js +0 -128
  257. package/dist/tools/mcp/bridge.js.map +0 -1
  258. package/dist/tools/mcp/bridge.test.d.ts +0 -8
  259. package/dist/tools/mcp/bridge.test.d.ts.map +0 -1
  260. package/dist/tools/mcp/bridge.test.js +0 -300
  261. package/dist/tools/mcp/bridge.test.js.map +0 -1
  262. package/dist/tools/mcp/client.d.ts +0 -135
  263. package/dist/tools/mcp/client.d.ts.map +0 -1
  264. package/dist/tools/mcp/client.js +0 -263
  265. package/dist/tools/mcp/client.js.map +0 -1
  266. package/dist/tools/mcp/client.test.d.ts +0 -8
  267. package/dist/tools/mcp/client.test.d.ts.map +0 -1
  268. package/dist/tools/mcp/client.test.js +0 -390
  269. package/dist/tools/mcp/client.test.js.map +0 -1
  270. package/dist/tools/registry.d.ts +0 -82
  271. package/dist/tools/registry.d.ts.map +0 -1
  272. package/dist/tools/registry.js +0 -99
  273. package/dist/tools/registry.js.map +0 -1
  274. package/dist/tools/registry.test.d.ts +0 -7
  275. package/dist/tools/registry.test.d.ts.map +0 -1
  276. package/dist/tools/registry.test.js +0 -199
  277. package/dist/tools/registry.test.js.map +0 -1
  278. package/dist/tools/suite.test.d.ts +0 -11
  279. package/dist/tools/suite.test.d.ts.map +0 -1
  280. package/dist/tools/suite.test.js +0 -119
  281. package/dist/tools/suite.test.js.map +0 -1
  282. package/dist/tools/types.d.ts +0 -75
  283. package/dist/tools/types.d.ts.map +0 -1
  284. package/dist/tools/types.js +0 -30
  285. package/dist/tools/types.js.map +0 -1
  286. package/dist/tools/types.test.d.ts +0 -7
  287. package/dist/tools/types.test.d.ts.map +0 -1
  288. package/dist/tools/types.test.js +0 -178
  289. package/dist/tools/types.test.js.map +0 -1
  290. package/templates/.vscode/mcp.json +0 -20
  291. package/templates/CLAUDE.md +0 -129
@@ -1,41 +0,0 @@
1
- /**
2
- * Tool Abstraction Module
3
- *
4
- * Barrel exports for the tool abstraction layer.
5
- * Provides a uniform interface for agent tools regardless of
6
- * runtime environment (CLI, Copilot, MCP).
7
- */
8
- import { readFileTool } from './cli/readFile.js';
9
- import { editFileTool } from './cli/editFile.js';
10
- import { searchTool } from './cli/search.js';
11
- import { terminalTool } from './cli/terminal.js';
12
- import { beadsTool } from './cli/beads.js';
13
- import { subagentTool } from './cli/subagent.js';
14
- import { ToolRegistry } from './registry.js';
15
- export { ToolError } from './types.js';
16
- export { toToolDefinition } from './interface.js';
17
- // Registry
18
- export { ToolRegistry } from './registry.js';
19
- // CLI tool implementations
20
- export { readFileTool } from './cli/readFile.js';
21
- export { editFileTool } from './cli/editFile.js';
22
- export { searchTool } from './cli/search.js';
23
- export { terminalTool } from './cli/terminal.js';
24
- export { beadsTool } from './cli/beads.js';
25
- export { subagentTool, isSubagentRequest } from './cli/subagent.js';
26
- // MCP client and bridge
27
- export { MCPClient } from './mcp/client.js';
28
- export { parseMCPConfig, createMCPTools, loadAllMCPTools } from './mcp/bridge.js';
29
- // Convenience factory
30
- /** Create a ToolRegistry pre-loaded with all built-in CLI tools */
31
- export function createDefaultRegistry() {
32
- const registry = new ToolRegistry();
33
- registry.register(readFileTool);
34
- registry.register(editFileTool);
35
- registry.register(searchTool);
36
- registry.register(terminalTool);
37
- registry.register(beadsTool);
38
- registry.register(subagentTool);
39
- return registry;
40
- }
41
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAW7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,WAAW;AACX,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,2BAA2B;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,wBAAwB;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElF,sBAAsB;AAEtB,mEAAmE;AACnE,MAAM,UAAU,qBAAqB;IACnC,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,64 +0,0 @@
1
- /**
2
- * Tool Interface
3
- *
4
- * Abstract interface for all tool implementations.
5
- * Tools are the bridge between LLM function calling and actual
6
- * operations (file I/O, terminal commands, search, etc.).
7
- */
8
- import type { ToolDefinition } from '../providers/types.js';
9
- import type { ToolContext, ToolInputSchema, ToolResult } from './types.js';
10
- /**
11
- * Interface that all tool implementations must satisfy.
12
- *
13
- * Each tool has a unique name, a description for the LLM, a JSON Schema
14
- * describing its expected input, and an execute method that performs the
15
- * actual operation.
16
- *
17
- * @example
18
- * ```typescript
19
- * const readFileTool: Tool = {
20
- * name: 'readFile',
21
- * description: 'Read the contents of a file',
22
- * inputSchema: {
23
- * type: 'object',
24
- * properties: {
25
- * path: { type: 'string', description: 'File path to read' }
26
- * },
27
- * required: ['path'],
28
- * },
29
- * async execute(input, context) {
30
- * const filePath = input.path as string;
31
- * // ... read file logic
32
- * return { success: true, output: contents };
33
- * },
34
- * };
35
- * ```
36
- */
37
- export interface Tool {
38
- /** Unique name for this tool (e.g., 'readFile', 'editFile', 'search') */
39
- readonly name: string;
40
- /** Human-readable description of what this tool does */
41
- readonly description: string;
42
- /** JSON Schema describing the expected input */
43
- readonly inputSchema: ToolInputSchema;
44
- /** Execute the tool with given input and context */
45
- execute(input: Record<string, unknown>, context: ToolContext): Promise<ToolResult>;
46
- }
47
- /**
48
- * Convert a Tool to an OpenAI-compatible ToolDefinition.
49
- *
50
- * This bridges the tool abstraction layer into the LLM provider layer,
51
- * allowing registered tools to be passed as function definitions in
52
- * chat completion requests.
53
- *
54
- * @param tool - The tool to convert
55
- * @returns An OpenAI-compatible tool definition for function calling
56
- *
57
- * @example
58
- * ```typescript
59
- * const definition = toToolDefinition(readFileTool);
60
- * // { type: 'function', function: { name: 'readFile', description: '...', parameters: {...} } }
61
- * ```
62
- */
63
- export declare function toToolDefinition(tool: Tool): ToolDefinition;
64
- //# sourceMappingURL=interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/tools/interface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM3E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,IAAI;IACnB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;IAEtC,oDAAoD;IACpD,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpF;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,cAAc,CAS3D"}
@@ -1,37 +0,0 @@
1
- /**
2
- * Tool Interface
3
- *
4
- * Abstract interface for all tool implementations.
5
- * Tools are the bridge between LLM function calling and actual
6
- * operations (file I/O, terminal commands, search, etc.).
7
- */
8
- // =============================================================================
9
- // Conversion Helpers
10
- // =============================================================================
11
- /**
12
- * Convert a Tool to an OpenAI-compatible ToolDefinition.
13
- *
14
- * This bridges the tool abstraction layer into the LLM provider layer,
15
- * allowing registered tools to be passed as function definitions in
16
- * chat completion requests.
17
- *
18
- * @param tool - The tool to convert
19
- * @returns An OpenAI-compatible tool definition for function calling
20
- *
21
- * @example
22
- * ```typescript
23
- * const definition = toToolDefinition(readFileTool);
24
- * // { type: 'function', function: { name: 'readFile', description: '...', parameters: {...} } }
25
- * ```
26
- */
27
- export function toToolDefinition(tool) {
28
- return {
29
- type: 'function',
30
- function: {
31
- name: tool.name,
32
- description: tool.description,
33
- parameters: tool.inputSchema,
34
- },
35
- };
36
- }
37
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/tools/interface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkDH,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAU;IACzC,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,WAAW;SAC7B;KACF,CAAC;AACJ,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Tool Interface Tests
3
- *
4
- * Tests for the Tool interface and toToolDefinition helper.
5
- */
6
- export {};
7
- //# sourceMappingURL=interface.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.test.d.ts","sourceRoot":"","sources":["../../src/tools/interface.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -1,179 +0,0 @@
1
- /**
2
- * Tool Interface Tests
3
- *
4
- * Tests for the Tool interface and toToolDefinition helper.
5
- */
6
- import { describe, it } from 'node:test';
7
- import assert from 'node:assert';
8
- import { toToolDefinition } from './interface.js';
9
- /**
10
- * Create a minimal mock tool for testing.
11
- */
12
- function createMockTool(overrides) {
13
- return {
14
- name: overrides?.name ?? 'mockTool',
15
- description: overrides?.description ?? 'A mock tool for testing',
16
- inputSchema: overrides?.inputSchema ?? {
17
- type: 'object',
18
- properties: {
19
- input: { type: 'string', description: 'Test input' },
20
- },
21
- required: ['input'],
22
- },
23
- execute: overrides?.execute ?? (async () => ({ success: true, output: 'ok' })),
24
- };
25
- }
26
- /**
27
- * Create a minimal ToolContext for testing.
28
- */
29
- function createMockContext(overrides) {
30
- return {
31
- workingDir: overrides?.workingDir ?? '/test',
32
- permissions: overrides?.permissions ?? {
33
- allowFileRead: true,
34
- allowFileWrite: false,
35
- allowTerminal: false,
36
- allowNetwork: false,
37
- },
38
- signal: overrides?.signal,
39
- };
40
- }
41
- describe('Tool interface', () => {
42
- describe('mock tool implementing interface', () => {
43
- it('should have a name', () => {
44
- const tool = createMockTool({ name: 'readFile' });
45
- assert.strictEqual(tool.name, 'readFile');
46
- });
47
- it('should have a description', () => {
48
- const tool = createMockTool({ description: 'Reads a file' });
49
- assert.strictEqual(tool.description, 'Reads a file');
50
- });
51
- it('should have an inputSchema', () => {
52
- const schema = {
53
- type: 'object',
54
- properties: { path: { type: 'string' } },
55
- required: ['path'],
56
- };
57
- const tool = createMockTool({ inputSchema: schema });
58
- assert.deepStrictEqual(tool.inputSchema, schema);
59
- });
60
- it('should execute and return a ToolResult', async () => {
61
- const tool = createMockTool({
62
- execute: async () => ({ success: true, output: 'file contents' }),
63
- });
64
- const result = await tool.execute({}, createMockContext());
65
- assert.strictEqual(result.success, true);
66
- assert.strictEqual(result.output, 'file contents');
67
- });
68
- it('should receive input in execute', async () => {
69
- let receivedInput = {};
70
- const tool = createMockTool({
71
- execute: async (input) => {
72
- receivedInput = input;
73
- return { success: true, output: 'ok' };
74
- },
75
- });
76
- await tool.execute({ path: '/test.txt' }, createMockContext());
77
- assert.strictEqual(receivedInput.path, '/test.txt');
78
- });
79
- it('should receive context in execute', async () => {
80
- let receivedContext;
81
- const tool = createMockTool({
82
- execute: async (_input, context) => {
83
- receivedContext = context;
84
- return { success: true, output: 'ok' };
85
- },
86
- });
87
- const ctx = createMockContext({ workingDir: '/my/project' });
88
- await tool.execute({}, ctx);
89
- assert.strictEqual(receivedContext?.workingDir, '/my/project');
90
- });
91
- it('should return a failed result', async () => {
92
- const tool = createMockTool({
93
- execute: async () => ({
94
- success: false,
95
- output: '',
96
- error: 'Permission denied',
97
- }),
98
- });
99
- const result = await tool.execute({}, createMockContext());
100
- assert.strictEqual(result.success, false);
101
- assert.strictEqual(result.error, 'Permission denied');
102
- });
103
- it('should return a result with metadata', async () => {
104
- const tool = createMockTool({
105
- execute: async () => ({
106
- success: true,
107
- output: 'Done',
108
- metadata: { linesRead: 42 },
109
- }),
110
- });
111
- const result = await tool.execute({}, createMockContext());
112
- assert.deepStrictEqual(result.metadata, { linesRead: 42 });
113
- });
114
- });
115
- });
116
- describe('toToolDefinition', () => {
117
- it('should return type "function"', () => {
118
- const tool = createMockTool();
119
- const def = toToolDefinition(tool);
120
- assert.strictEqual(def.type, 'function');
121
- });
122
- it('should map tool name to function name', () => {
123
- const tool = createMockTool({ name: 'readFile' });
124
- const def = toToolDefinition(tool);
125
- assert.strictEqual(def.function.name, 'readFile');
126
- });
127
- it('should map tool description to function description', () => {
128
- const tool = createMockTool({ description: 'Read a file from disk' });
129
- const def = toToolDefinition(tool);
130
- assert.strictEqual(def.function.description, 'Read a file from disk');
131
- });
132
- it('should map inputSchema to function parameters', () => {
133
- const schema = {
134
- type: 'object',
135
- properties: {
136
- path: { type: 'string', description: 'File path' },
137
- encoding: { type: 'string', description: 'File encoding' },
138
- },
139
- required: ['path'],
140
- };
141
- const tool = createMockTool({ inputSchema: schema });
142
- const def = toToolDefinition(tool);
143
- assert.deepStrictEqual(def.function.parameters, schema);
144
- });
145
- it('should produce a valid ToolDefinition structure', () => {
146
- const tool = createMockTool({
147
- name: 'search',
148
- description: 'Search the codebase',
149
- inputSchema: {
150
- type: 'object',
151
- properties: {
152
- query: { type: 'string' },
153
- },
154
- required: ['query'],
155
- },
156
- });
157
- const def = toToolDefinition(tool);
158
- assert.deepStrictEqual(def, {
159
- type: 'function',
160
- function: {
161
- name: 'search',
162
- description: 'Search the codebase',
163
- parameters: {
164
- type: 'object',
165
- properties: {
166
- query: { type: 'string' },
167
- },
168
- required: ['query'],
169
- },
170
- },
171
- });
172
- });
173
- it('should handle an empty inputSchema', () => {
174
- const tool = createMockTool({ inputSchema: {} });
175
- const def = toToolDefinition(tool);
176
- assert.deepStrictEqual(def.function.parameters, {});
177
- });
178
- });
179
- //# sourceMappingURL=interface.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.test.js","sourceRoot":"","sources":["../../src/tools/interface.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,aAAa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AM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAEnC,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE;YAC1B,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qBAAqB;gBAClC,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBAC1B;oBACD,QAAQ,EAAE,CAAC,OAAO,CAAC;iBACpB;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,IAAI,GAAG,cAAc,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAEnC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * MCP Tool Bridge
3
- *
4
- * Bridges MCP server tools into the Beth Tool interface.
5
- * Parses mcp.json configuration, connects to MCP servers,
6
- * and wraps their tools as Beth Tool implementations.
7
- */
8
- import { MCPClient, type MCPServerConfig } from './client.js';
9
- import type { Tool } from '../interface.js';
10
- /**
11
- * Parse an mcp.json file and create MCPServerConfig entries for all
12
- * stdio-based servers.
13
- *
14
- * Handles JSONC (JSON with comments) by stripping single-line and
15
- * multi-line comments before parsing.
16
- *
17
- * @param configPath - Absolute path to the mcp.json file
18
- * @returns Map of server name → MCPServerConfig (only stdio servers)
19
- */
20
- export declare function parseMCPConfig(configPath: string): Map<string, MCPServerConfig>;
21
- /**
22
- * Create Beth Tool implementations from an MCP client's tools.
23
- *
24
- * Each MCP tool is wrapped as a Tool with namespaced name
25
- * (`mcp_<serverName>_<toolName>`) to avoid collisions.
26
- *
27
- * @param client - A connected MCPClient
28
- * @returns Array of Tool implementations wrapping MCP tools
29
- */
30
- export declare function createMCPTools(client: MCPClient): Promise<Tool[]>;
31
- /**
32
- * Load all MCP tools from a config file.
33
- *
34
- * Connects to all stdio-based MCP servers defined in the config,
35
- * collects their tools, and returns them along with the client
36
- * references (for cleanup via `disconnect()`).
37
- *
38
- * Servers that fail to connect are skipped with a warning rather
39
- * than failing the entire load.
40
- *
41
- * @param configPath - Absolute path to the mcp.json file
42
- * @returns Object with all bridged tools and client references
43
- */
44
- export declare function loadAllMCPTools(configPath: string): Promise<{
45
- tools: Tool[];
46
- clients: MCPClient[];
47
- }>;
48
- //# sourceMappingURL=bridge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAoB,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AA2B5C;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CA+B/E;AAMD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAIvE;AA4CD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IACjE,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB,CAAC,CAoBD"}
@@ -1,128 +0,0 @@
1
- /**
2
- * MCP Tool Bridge
3
- *
4
- * Bridges MCP server tools into the Beth Tool interface.
5
- * Parses mcp.json configuration, connects to MCP servers,
6
- * and wraps their tools as Beth Tool implementations.
7
- */
8
- import { readFileSync } from 'node:fs';
9
- import { MCPClient } from './client.js';
10
- /**
11
- * Parse an mcp.json file and create MCPServerConfig entries for all
12
- * stdio-based servers.
13
- *
14
- * Handles JSONC (JSON with comments) by stripping single-line and
15
- * multi-line comments before parsing.
16
- *
17
- * @param configPath - Absolute path to the mcp.json file
18
- * @returns Map of server name → MCPServerConfig (only stdio servers)
19
- */
20
- export function parseMCPConfig(configPath) {
21
- const raw = readFileSync(configPath, 'utf-8');
22
- // Strip JSONC comments while preserving strings.
23
- // Matches strings (to skip), block comments, and line comments.
24
- const stripped = raw.replace(/"(?:[^"\\]|\\.)*"|\/\*[\s\S]*?\*\/|\/\/.*$/gm, (match) => (match.startsWith('/') ? '' : match));
25
- const config = JSON.parse(stripped);
26
- const result = new Map();
27
- if (!config.servers || typeof config.servers !== 'object') {
28
- return result;
29
- }
30
- for (const [name, entry] of Object.entries(config.servers)) {
31
- // Only support stdio-based servers (those with a command)
32
- if (!entry.command || typeof entry.command !== 'string') {
33
- continue;
34
- }
35
- result.set(name, {
36
- command: entry.command,
37
- args: Array.isArray(entry.args) ? entry.args.map(String) : [],
38
- ...(entry.env && typeof entry.env === 'object' ? { env: entry.env } : {}),
39
- });
40
- }
41
- return result;
42
- }
43
- // =============================================================================
44
- // Tool Creation
45
- // =============================================================================
46
- /**
47
- * Create Beth Tool implementations from an MCP client's tools.
48
- *
49
- * Each MCP tool is wrapped as a Tool with namespaced name
50
- * (`mcp_<serverName>_<toolName>`) to avoid collisions.
51
- *
52
- * @param client - A connected MCPClient
53
- * @returns Array of Tool implementations wrapping MCP tools
54
- */
55
- export async function createMCPTools(client) {
56
- const mcpTools = await client.listTools();
57
- return mcpTools.map((info) => createToolWrapper(client, info));
58
- }
59
- /**
60
- * Create a single Tool wrapper for an MCP tool.
61
- */
62
- function createToolWrapper(client, info) {
63
- const namespacedName = `mcp_${client.name}_${info.name}`;
64
- return {
65
- name: namespacedName,
66
- description: info.description,
67
- inputSchema: info.inputSchema,
68
- async execute(input, _context) {
69
- try {
70
- const result = await client.callTool(info.name, input);
71
- // MCP tool results can be structured; serialize for ToolResult output
72
- const output = typeof result === 'string'
73
- ? result
74
- : JSON.stringify(result);
75
- return {
76
- success: true,
77
- output,
78
- metadata: { mcpServer: client.name, mcpTool: info.name },
79
- };
80
- }
81
- catch (err) {
82
- const message = err instanceof Error ? err.message : String(err);
83
- return {
84
- success: false,
85
- output: '',
86
- error: message,
87
- metadata: { mcpServer: client.name, mcpTool: info.name },
88
- };
89
- }
90
- },
91
- };
92
- }
93
- // =============================================================================
94
- // Full Loader
95
- // =============================================================================
96
- /**
97
- * Load all MCP tools from a config file.
98
- *
99
- * Connects to all stdio-based MCP servers defined in the config,
100
- * collects their tools, and returns them along with the client
101
- * references (for cleanup via `disconnect()`).
102
- *
103
- * Servers that fail to connect are skipped with a warning rather
104
- * than failing the entire load.
105
- *
106
- * @param configPath - Absolute path to the mcp.json file
107
- * @returns Object with all bridged tools and client references
108
- */
109
- export async function loadAllMCPTools(configPath) {
110
- const configs = parseMCPConfig(configPath);
111
- const tools = [];
112
- const clients = [];
113
- for (const [name, config] of configs) {
114
- const client = new MCPClient(name, config);
115
- try {
116
- await client.connect();
117
- const serverTools = await createMCPTools(client);
118
- tools.push(...serverTools);
119
- clients.push(client);
120
- }
121
- catch {
122
- // Server not available — skip gracefully
123
- await client.disconnect().catch(() => { });
124
- }
125
- }
126
- return { tools, clients };
127
- }
128
- //# sourceMappingURL=bridge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../src/tools/mcp/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,SAAS,EAA0C,MAAM,aAAa,CAAC;AA4BhF;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,MAAM,GAAG,G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ACL,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,EAAE;oBACV,KAAK,EAAE,OAAO;oBACd,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE;iBACzD,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UAAkB;IAItD,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM,OAAO,GAAgB,EAAE,CAAC;IAEhC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE3C,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;YACjD,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,yCAAyC;YACzC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAA+B,CAAC,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * MCP Bridge Tests
3
- *
4
- * Tests for config parsing, tool wrapping, and the MCP-to-Beth
5
- * tool bridge. Uses mock MCPClient rather than real servers.
6
- */
7
- export {};
8
- //# sourceMappingURL=bridge.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bridge.test.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/bridge.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}