agent-bundle 0.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 (376) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -0
  3. package/dist/agent/agent.d.ts +32 -0
  4. package/dist/agent/agent.js +241 -0
  5. package/dist/agent/agent.js.map +1 -0
  6. package/dist/agent/agent.test-helpers.d.ts +63 -0
  7. package/dist/agent/agent.test-helpers.js +170 -0
  8. package/dist/agent/agent.test-helpers.js.map +1 -0
  9. package/dist/agent/define-agent.d.ts +2 -0
  10. package/dist/agent/define-agent.js +18 -0
  11. package/dist/agent/define-agent.js.map +1 -0
  12. package/dist/agent/dependencies.d.ts +15 -0
  13. package/dist/agent/dependencies.js +14 -0
  14. package/dist/agent/dependencies.js.map +1 -0
  15. package/dist/agent/index.d.ts +4 -0
  16. package/dist/agent/index.js +5 -0
  17. package/dist/agent/index.js.map +1 -0
  18. package/dist/agent/internals.d.ts +28 -0
  19. package/dist/agent/internals.js +160 -0
  20. package/dist/agent/internals.js.map +1 -0
  21. package/dist/agent/session.d.ts +4 -0
  22. package/dist/agent/session.js +2 -0
  23. package/dist/agent/session.js.map +1 -0
  24. package/dist/agent/types.d.ts +52 -0
  25. package/dist/agent/types.js +2 -0
  26. package/dist/agent/types.js.map +1 -0
  27. package/dist/agent-loop/agent-loop.d.ts +27 -0
  28. package/dist/agent-loop/agent-loop.js +2 -0
  29. package/dist/agent-loop/agent-loop.js.map +1 -0
  30. package/dist/agent-loop/index.d.ts +4 -0
  31. package/dist/agent-loop/index.js +5 -0
  32. package/dist/agent-loop/index.js.map +1 -0
  33. package/dist/agent-loop/pi-mono/events.d.ts +3 -0
  34. package/dist/agent-loop/pi-mono/events.js +73 -0
  35. package/dist/agent-loop/pi-mono/events.js.map +1 -0
  36. package/dist/agent-loop/pi-mono/index.d.ts +1 -0
  37. package/dist/agent-loop/pi-mono/index.js +2 -0
  38. package/dist/agent-loop/pi-mono/index.js.map +1 -0
  39. package/dist/agent-loop/pi-mono/input.d.ts +6 -0
  40. package/dist/agent-loop/pi-mono/input.js +120 -0
  41. package/dist/agent-loop/pi-mono/input.js.map +1 -0
  42. package/dist/agent-loop/pi-mono/model.d.ts +7 -0
  43. package/dist/agent-loop/pi-mono/model.js +72 -0
  44. package/dist/agent-loop/pi-mono/model.js.map +1 -0
  45. package/dist/agent-loop/pi-mono/pi-mono-loop.d.ts +11 -0
  46. package/dist/agent-loop/pi-mono/pi-mono-loop.js +167 -0
  47. package/dist/agent-loop/pi-mono/pi-mono-loop.js.map +1 -0
  48. package/dist/agent-loop/pi-mono/pi-mono-loop.test-helpers.d.ts +28 -0
  49. package/dist/agent-loop/pi-mono/pi-mono-loop.test-helpers.js +76 -0
  50. package/dist/agent-loop/pi-mono/pi-mono-loop.test-helpers.js.map +1 -0
  51. package/dist/agent-loop/pi-mono/queue.d.ts +9 -0
  52. package/dist/agent-loop/pi-mono/queue.js +37 -0
  53. package/dist/agent-loop/pi-mono/queue.js.map +1 -0
  54. package/dist/agent-loop/pi-mono/tools.d.ts +4 -0
  55. package/dist/agent-loop/pi-mono/tools.js +164 -0
  56. package/dist/agent-loop/pi-mono/tools.js.map +1 -0
  57. package/dist/agent-loop/pi-mono/utils.d.ts +14 -0
  58. package/dist/agent-loop/pi-mono/utils.js +83 -0
  59. package/dist/agent-loop/pi-mono/utils.js.map +1 -0
  60. package/dist/agent-loop/system-prompt/fill.d.ts +1 -0
  61. package/dist/agent-loop/system-prompt/fill.js +19 -0
  62. package/dist/agent-loop/system-prompt/fill.js.map +1 -0
  63. package/dist/agent-loop/system-prompt/generate.d.ts +11 -0
  64. package/dist/agent-loop/system-prompt/generate.js +21 -0
  65. package/dist/agent-loop/system-prompt/generate.js.map +1 -0
  66. package/dist/agent-loop/system-prompt/index.d.ts +2 -0
  67. package/dist/agent-loop/system-prompt/index.js +3 -0
  68. package/dist/agent-loop/system-prompt/index.js.map +1 -0
  69. package/dist/agent-loop/types.d.ts +77 -0
  70. package/dist/agent-loop/types.js +2 -0
  71. package/dist/agent-loop/types.js.map +1 -0
  72. package/dist/cli/build/build.d.ts +35 -0
  73. package/dist/cli/build/build.js +174 -0
  74. package/dist/cli/build/build.js.map +1 -0
  75. package/dist/cli/build/build.test-helpers.d.ts +9 -0
  76. package/dist/cli/build/build.test-helpers.js +50 -0
  77. package/dist/cli/build/build.test-helpers.js.map +1 -0
  78. package/dist/cli/build/codegen-commands.d.ts +16 -0
  79. package/dist/cli/build/codegen-commands.js +81 -0
  80. package/dist/cli/build/codegen-commands.js.map +1 -0
  81. package/dist/cli/build/codegen.d.ts +55 -0
  82. package/dist/cli/build/codegen.js +212 -0
  83. package/dist/cli/build/codegen.js.map +1 -0
  84. package/dist/cli/build/e2b-template.d.ts +38 -0
  85. package/dist/cli/build/e2b-template.js +210 -0
  86. package/dist/cli/build/e2b-template.js.map +1 -0
  87. package/dist/cli/build/e2b-template.test-helpers.d.ts +19 -0
  88. package/dist/cli/build/e2b-template.test-helpers.js +80 -0
  89. package/dist/cli/build/e2b-template.test-helpers.js.map +1 -0
  90. package/dist/cli/build/sandbox-image.d.ts +35 -0
  91. package/dist/cli/build/sandbox-image.js +57 -0
  92. package/dist/cli/build/sandbox-image.js.map +1 -0
  93. package/dist/cli/build-codegen.d.ts +41 -0
  94. package/dist/cli/build-codegen.js +168 -0
  95. package/dist/cli/build-codegen.js.map +1 -0
  96. package/dist/cli/build-e2b-template.d.ts +38 -0
  97. package/dist/cli/build-e2b-template.js +223 -0
  98. package/dist/cli/build-e2b-template.js.map +1 -0
  99. package/dist/cli/build-e2b-template.test-helpers.d.ts +19 -0
  100. package/dist/cli/build-e2b-template.test-helpers.js +80 -0
  101. package/dist/cli/build-e2b-template.test-helpers.js.map +1 -0
  102. package/dist/cli/build-sandbox-image.d.ts +35 -0
  103. package/dist/cli/build-sandbox-image.js +57 -0
  104. package/dist/cli/build-sandbox-image.js.map +1 -0
  105. package/dist/cli/build.d.ts +30 -0
  106. package/dist/cli/build.js +151 -0
  107. package/dist/cli/build.js.map +1 -0
  108. package/dist/cli/build.test-helpers.d.ts +9 -0
  109. package/dist/cli/build.test-helpers.js +50 -0
  110. package/dist/cli/build.test-helpers.js.map +1 -0
  111. package/dist/cli/config/load-bundle-config.d.ts +2 -0
  112. package/dist/cli/config/load-bundle-config.js +20 -0
  113. package/dist/cli/config/load-bundle-config.js.map +1 -0
  114. package/dist/cli/config/resolve-project-root.d.ts +1 -0
  115. package/dist/cli/config/resolve-project-root.js +19 -0
  116. package/dist/cli/config/resolve-project-root.js.map +1 -0
  117. package/dist/cli/deploy/aws-cli.d.ts +42 -0
  118. package/dist/cli/deploy/aws-cli.js +95 -0
  119. package/dist/cli/deploy/aws-cli.js.map +1 -0
  120. package/dist/cli/deploy/aws-ecr.d.ts +20 -0
  121. package/dist/cli/deploy/aws-ecr.js +97 -0
  122. package/dist/cli/deploy/aws-ecr.js.map +1 -0
  123. package/dist/cli/deploy/aws-ecs-infra.d.ts +39 -0
  124. package/dist/cli/deploy/aws-ecs-infra.js +169 -0
  125. package/dist/cli/deploy/aws-ecs-infra.js.map +1 -0
  126. package/dist/cli/deploy/aws-ecs-role.d.ts +9 -0
  127. package/dist/cli/deploy/aws-ecs-role.js +114 -0
  128. package/dist/cli/deploy/aws-ecs-role.js.map +1 -0
  129. package/dist/cli/deploy/aws-ecs-service.d.ts +37 -0
  130. package/dist/cli/deploy/aws-ecs-service.js +207 -0
  131. package/dist/cli/deploy/aws-ecs-service.js.map +1 -0
  132. package/dist/cli/deploy/aws-ecs-shared.d.ts +59 -0
  133. package/dist/cli/deploy/aws-ecs-shared.js +30 -0
  134. package/dist/cli/deploy/aws-ecs-shared.js.map +1 -0
  135. package/dist/cli/deploy/aws-ecs.d.ts +3 -0
  136. package/dist/cli/deploy/aws-ecs.js +141 -0
  137. package/dist/cli/deploy/aws-ecs.js.map +1 -0
  138. package/dist/cli/deploy/aws-prerequisites.d.ts +16 -0
  139. package/dist/cli/deploy/aws-prerequisites.js +28 -0
  140. package/dist/cli/deploy/aws-prerequisites.js.map +1 -0
  141. package/dist/cli/deploy/aws-teardown.d.ts +13 -0
  142. package/dist/cli/deploy/aws-teardown.js +204 -0
  143. package/dist/cli/deploy/aws-teardown.js.map +1 -0
  144. package/dist/cli/deploy/deploy.d.ts +36 -0
  145. package/dist/cli/deploy/deploy.js +209 -0
  146. package/dist/cli/deploy/deploy.js.map +1 -0
  147. package/dist/cli/error.d.ts +1 -0
  148. package/dist/cli/error.js +4 -0
  149. package/dist/cli/error.js.map +1 -0
  150. package/dist/cli/generate/generate.d.ts +37 -0
  151. package/dist/cli/generate/generate.js +121 -0
  152. package/dist/cli/generate/generate.js.map +1 -0
  153. package/dist/cli/generate.d.ts +32 -0
  154. package/dist/cli/generate.js +102 -0
  155. package/dist/cli/generate.js.map +1 -0
  156. package/dist/cli/index.d.ts +2 -0
  157. package/dist/cli/index.js +182 -0
  158. package/dist/cli/index.js.map +1 -0
  159. package/dist/cli/load-bundle-config.d.ts +2 -0
  160. package/dist/cli/load-bundle-config.js +20 -0
  161. package/dist/cli/load-bundle-config.js.map +1 -0
  162. package/dist/cli/resolve-project-root.d.ts +1 -0
  163. package/dist/cli/resolve-project-root.js +19 -0
  164. package/dist/cli/resolve-project-root.js.map +1 -0
  165. package/dist/cli/serve/dev.d.ts +6 -0
  166. package/dist/cli/serve/dev.js +73 -0
  167. package/dist/cli/serve/dev.js.map +1 -0
  168. package/dist/cli/serve/http.d.ts +12 -0
  169. package/dist/cli/serve/http.js +123 -0
  170. package/dist/cli/serve/http.js.map +1 -0
  171. package/dist/cli/serve/init.d.ts +42 -0
  172. package/dist/cli/serve/init.js +110 -0
  173. package/dist/cli/serve/init.js.map +1 -0
  174. package/dist/cli/serve/runtime.d.ts +25 -0
  175. package/dist/cli/serve/runtime.js +142 -0
  176. package/dist/cli/serve/runtime.js.map +1 -0
  177. package/dist/cli/serve/serve.d.ts +7 -0
  178. package/dist/cli/serve/serve.js +63 -0
  179. package/dist/cli/serve/serve.js.map +1 -0
  180. package/dist/cli/serve/serve.test-helpers.d.ts +36 -0
  181. package/dist/cli/serve/serve.test-helpers.js +205 -0
  182. package/dist/cli/serve/serve.test-helpers.js.map +1 -0
  183. package/dist/cli/serve/worktree-port.d.ts +36 -0
  184. package/dist/cli/serve/worktree-port.js +124 -0
  185. package/dist/cli/serve/worktree-port.js.map +1 -0
  186. package/dist/cli/serve-http.d.ts +12 -0
  187. package/dist/cli/serve-http.js +112 -0
  188. package/dist/cli/serve-http.js.map +1 -0
  189. package/dist/cli/serve-runtime.d.ts +16 -0
  190. package/dist/cli/serve-runtime.js +122 -0
  191. package/dist/cli/serve-runtime.js.map +1 -0
  192. package/dist/cli/serve.d.ts +33 -0
  193. package/dist/cli/serve.js +150 -0
  194. package/dist/cli/serve.js.map +1 -0
  195. package/dist/cli/serve.test-helpers.d.ts +30 -0
  196. package/dist/cli/serve.test-helpers.js +145 -0
  197. package/dist/cli/serve.test-helpers.js.map +1 -0
  198. package/dist/code-formatter/bundle.json +41 -0
  199. package/dist/code-formatter/index.ts +26 -0
  200. package/dist/code-formatter/package.json +10 -0
  201. package/dist/code-formatter/types.ts +2 -0
  202. package/dist/code-formatter-e2b/bundle.json +40 -0
  203. package/dist/code-formatter-e2b/index.ts +25 -0
  204. package/dist/code-formatter-e2b/package.json +10 -0
  205. package/dist/code-formatter-e2b/types.ts +2 -0
  206. package/dist/coding-assistant-ollama/bundle.json +43 -0
  207. package/dist/coding-assistant-ollama/index.ts +28 -0
  208. package/dist/coding-assistant-ollama/package.json +10 -0
  209. package/dist/coding-assistant-ollama/types.ts +2 -0
  210. package/dist/commands/find.d.ts +8 -0
  211. package/dist/commands/find.js +11 -0
  212. package/dist/commands/find.js.map +1 -0
  213. package/dist/commands/loader.d.ts +13 -0
  214. package/dist/commands/loader.js +163 -0
  215. package/dist/commands/loader.js.map +1 -0
  216. package/dist/commands/types.d.ts +7 -0
  217. package/dist/commands/types.js +2 -0
  218. package/dist/commands/types.js.map +1 -0
  219. package/dist/commands/with-commands.d.ts +6 -0
  220. package/dist/commands/with-commands.js +19 -0
  221. package/dist/commands/with-commands.js.map +1 -0
  222. package/dist/data-analyst/bundle.json +40 -0
  223. package/dist/data-analyst/index.ts +25 -0
  224. package/dist/data-analyst/package.json +10 -0
  225. package/dist/data-analyst/types.ts +2 -0
  226. package/dist/financial-analyst/bundle.json +40 -0
  227. package/dist/financial-analyst/index.ts +25 -0
  228. package/dist/financial-analyst/package.json +10 -0
  229. package/dist/financial-analyst/types.ts +2 -0
  230. package/dist/mcp/client-manager.d.ts +26 -0
  231. package/dist/mcp/client-manager.js +101 -0
  232. package/dist/mcp/client-manager.js.map +1 -0
  233. package/dist/mcp/connect-server.d.ts +21 -0
  234. package/dist/mcp/connect-server.js +170 -0
  235. package/dist/mcp/connect-server.js.map +1 -0
  236. package/dist/mcp/index.d.ts +2 -0
  237. package/dist/mcp/index.js +3 -0
  238. package/dist/mcp/index.js.map +1 -0
  239. package/dist/mcp/sandbox-stdio-transport.d.ts +32 -0
  240. package/dist/mcp/sandbox-stdio-transport.js +199 -0
  241. package/dist/mcp/sandbox-stdio-transport.js.map +1 -0
  242. package/dist/observability/hooks.d.ts +10 -0
  243. package/dist/observability/hooks.js +97 -0
  244. package/dist/observability/hooks.js.map +1 -0
  245. package/dist/observability/index.d.ts +6 -0
  246. package/dist/observability/index.js +7 -0
  247. package/dist/observability/index.js.map +1 -0
  248. package/dist/observability/metrics.d.ts +31 -0
  249. package/dist/observability/metrics.js +61 -0
  250. package/dist/observability/metrics.js.map +1 -0
  251. package/dist/observability/middleware.d.ts +12 -0
  252. package/dist/observability/middleware.js +45 -0
  253. package/dist/observability/middleware.js.map +1 -0
  254. package/dist/observability/otel-harness.test-util.d.ts +37 -0
  255. package/dist/observability/otel-harness.test-util.js +96 -0
  256. package/dist/observability/otel-harness.test-util.js.map +1 -0
  257. package/dist/observability/provider.d.ts +8 -0
  258. package/dist/observability/provider.js +19 -0
  259. package/dist/observability/provider.js.map +1 -0
  260. package/dist/observability/tracing.d.ts +14 -0
  261. package/dist/observability/tracing.js +40 -0
  262. package/dist/observability/tracing.js.map +1 -0
  263. package/dist/observability/types.d.ts +39 -0
  264. package/dist/observability/types.js +31 -0
  265. package/dist/observability/types.js.map +1 -0
  266. package/dist/personalized-recommend/bundle.json +64 -0
  267. package/dist/personalized-recommend/index.ts +41 -0
  268. package/dist/personalized-recommend/package.json +10 -0
  269. package/dist/personalized-recommend/types.ts +2 -0
  270. package/dist/plugins/loader.d.ts +11 -0
  271. package/dist/plugins/loader.js +100 -0
  272. package/dist/plugins/loader.js.map +1 -0
  273. package/dist/plugins/merge.d.ts +10 -0
  274. package/dist/plugins/merge.js +22 -0
  275. package/dist/plugins/merge.js.map +1 -0
  276. package/dist/plugins/parse.d.ts +10 -0
  277. package/dist/plugins/parse.js +139 -0
  278. package/dist/plugins/parse.js.map +1 -0
  279. package/dist/plugins/types.d.ts +28 -0
  280. package/dist/plugins/types.js +2 -0
  281. package/dist/plugins/types.js.map +1 -0
  282. package/dist/plugins/urls.d.ts +7 -0
  283. package/dist/plugins/urls.js +40 -0
  284. package/dist/plugins/urls.js.map +1 -0
  285. package/dist/runtime.d.ts +5 -0
  286. package/dist/runtime.js +3 -0
  287. package/dist/runtime.js.map +1 -0
  288. package/dist/sandbox/factory.d.ts +2 -0
  289. package/dist/sandbox/factory.js +27 -0
  290. package/dist/sandbox/factory.js.map +1 -0
  291. package/dist/sandbox/index.d.ts +4 -0
  292. package/dist/sandbox/index.js +5 -0
  293. package/dist/sandbox/index.js.map +1 -0
  294. package/dist/sandbox/providers/e2b.d.ts +28 -0
  295. package/dist/sandbox/providers/e2b.js +294 -0
  296. package/dist/sandbox/providers/e2b.js.map +1 -0
  297. package/dist/sandbox/providers/kubernetes-command-run.d.ts +8 -0
  298. package/dist/sandbox/providers/kubernetes-command-run.js +195 -0
  299. package/dist/sandbox/providers/kubernetes-command-run.js.map +1 -0
  300. package/dist/sandbox/providers/kubernetes-helpers.d.ts +31 -0
  301. package/dist/sandbox/providers/kubernetes-helpers.js +152 -0
  302. package/dist/sandbox/providers/kubernetes-helpers.js.map +1 -0
  303. package/dist/sandbox/providers/kubernetes-kubeconfig.d.ts +7 -0
  304. package/dist/sandbox/providers/kubernetes-kubeconfig.js +51 -0
  305. package/dist/sandbox/providers/kubernetes-kubeconfig.js.map +1 -0
  306. package/dist/sandbox/providers/kubernetes-spawn.d.ts +2 -0
  307. package/dist/sandbox/providers/kubernetes-spawn.js +42 -0
  308. package/dist/sandbox/providers/kubernetes-spawn.js.map +1 -0
  309. package/dist/sandbox/providers/kubernetes-spawn.utils.d.ts +32 -0
  310. package/dist/sandbox/providers/kubernetes-spawn.utils.js +249 -0
  311. package/dist/sandbox/providers/kubernetes-spawn.utils.js.map +1 -0
  312. package/dist/sandbox/providers/kubernetes.constants.d.ts +3 -0
  313. package/dist/sandbox/providers/kubernetes.constants.js +4 -0
  314. package/dist/sandbox/providers/kubernetes.constants.js.map +1 -0
  315. package/dist/sandbox/providers/kubernetes.d.ts +37 -0
  316. package/dist/sandbox/providers/kubernetes.js +258 -0
  317. package/dist/sandbox/providers/kubernetes.js.map +1 -0
  318. package/dist/sandbox/types.d.ts +57 -0
  319. package/dist/sandbox/types.js +2 -0
  320. package/dist/sandbox/types.js.map +1 -0
  321. package/dist/sandbox/utils.d.ts +1 -0
  322. package/dist/sandbox/utils.js +4 -0
  323. package/dist/sandbox/utils.js.map +1 -0
  324. package/dist/schema/bundle.d.ts +143 -0
  325. package/dist/schema/bundle.js +203 -0
  326. package/dist/schema/bundle.js.map +1 -0
  327. package/dist/service/command-routes.d.ts +8 -0
  328. package/dist/service/command-routes.js +44 -0
  329. package/dist/service/command-routes.js.map +1 -0
  330. package/dist/service/create-server.d.ts +9 -0
  331. package/dist/service/create-server.js +113 -0
  332. package/dist/service/create-server.js.map +1 -0
  333. package/dist/service/index.d.ts +1 -0
  334. package/dist/service/index.js +2 -0
  335. package/dist/service/index.js.map +1 -0
  336. package/dist/skills/index.d.ts +1 -0
  337. package/dist/skills/index.js +2 -0
  338. package/dist/skills/index.js.map +1 -0
  339. package/dist/skills/loader.d.ts +18 -0
  340. package/dist/skills/loader.js +142 -0
  341. package/dist/skills/loader.js.map +1 -0
  342. package/dist/skills/summaries.d.ts +8 -0
  343. package/dist/skills/summaries.js +9 -0
  344. package/dist/skills/summaries.js.map +1 -0
  345. package/dist/test-helpers/env.d.ts +2 -0
  346. package/dist/test-helpers/env.js +20 -0
  347. package/dist/test-helpers/env.js.map +1 -0
  348. package/dist/test-helpers/mock-agent.d.ts +56 -0
  349. package/dist/test-helpers/mock-agent.js +180 -0
  350. package/dist/test-helpers/mock-agent.js.map +1 -0
  351. package/dist/test-helpers/mock-sandbox.d.ts +33 -0
  352. package/dist/test-helpers/mock-sandbox.js +200 -0
  353. package/dist/test-helpers/mock-sandbox.js.map +1 -0
  354. package/dist/tui/index.d.ts +2 -0
  355. package/dist/tui/index.js +3 -0
  356. package/dist/tui/index.js.map +1 -0
  357. package/dist/tui/render.d.ts +8 -0
  358. package/dist/tui/render.js +40 -0
  359. package/dist/tui/render.js.map +1 -0
  360. package/dist/tui/tui.d.ts +19 -0
  361. package/dist/tui/tui.js +133 -0
  362. package/dist/tui/tui.js.map +1 -0
  363. package/dist/webui/create-webui-server.d.ts +22 -0
  364. package/dist/webui/create-webui-server.js +293 -0
  365. package/dist/webui/create-webui-server.js.map +1 -0
  366. package/dist/webui/event-bus.d.ts +16 -0
  367. package/dist/webui/event-bus.js +24 -0
  368. package/dist/webui/event-bus.js.map +1 -0
  369. package/dist/webui/index.d.ts +2 -0
  370. package/dist/webui/index.js +3 -0
  371. package/dist/webui/index.js.map +1 -0
  372. package/dist/webui/public/app.js +847 -0
  373. package/dist/webui/public/file-transfer.js +114 -0
  374. package/dist/webui/public/index.html +166 -0
  375. package/dist/webui/public/styles.css +1678 -0
  376. package/package.json +99 -0
@@ -0,0 +1,163 @@
1
+ import { createHash } from "node:crypto";
2
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { parse as parseYaml } from "yaml";
5
+ const DEFAULT_CACHE_DIR = "node_modules/.cache/agent-bundle/commands";
6
+ const FRONTMATTER_PATTERN = /^---\n([\s\S]*?)\n---\n?/;
7
+ const CATEGORY_PLACEHOLDER_PATTERN = /~~[a-zA-Z0-9_-]+/g;
8
+ function isNodeError(error) {
9
+ return error instanceof Error && "code" in error;
10
+ }
11
+ function normalizeMarkdown(markdown) {
12
+ return markdown.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
13
+ }
14
+ function stripCategoryPlaceholders(content) {
15
+ return content.replace(CATEGORY_PLACEHOLDER_PATTERN, "");
16
+ }
17
+ function parseFrontmatter(markdown) {
18
+ const normalized = normalizeMarkdown(markdown);
19
+ const match = normalized.match(FRONTMATTER_PATTERN);
20
+ if (!match) {
21
+ return { frontmatter: {}, content: normalized };
22
+ }
23
+ const parsed = parseYaml(match[1]);
24
+ return {
25
+ frontmatter: parsed && typeof parsed === "object" ? parsed : {},
26
+ content: normalized,
27
+ };
28
+ }
29
+ function getRequiredField(frontmatter, fieldName, sourcePath) {
30
+ const value = frontmatter[fieldName];
31
+ if (typeof value === "string" && value.trim().length > 0) {
32
+ return value.trim();
33
+ }
34
+ throw new Error(`Command at ${sourcePath} must define a non-empty frontmatter field: ${fieldName}`);
35
+ }
36
+ function getOptionalStringField(frontmatter, fieldName) {
37
+ const value = frontmatter[fieldName];
38
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
39
+ }
40
+ function toLocalCommandFilePath(basePath, commandPath) {
41
+ const resolved = resolve(basePath, commandPath);
42
+ if (resolved.endsWith(".md")) {
43
+ return resolved;
44
+ }
45
+ return `${resolved}.md`;
46
+ }
47
+ function toGithubRawUrl(entry) {
48
+ const normalizedRef = encodeURIComponent(entry.ref);
49
+ const commandPath = entry.command?.trim() ?? "";
50
+ const withExtension = commandPath.length === 0
51
+ ? "COMMAND.md"
52
+ : commandPath.endsWith(".md")
53
+ ? commandPath
54
+ : `${commandPath}.md`;
55
+ const encodedPath = withExtension
56
+ .split("/")
57
+ .filter((segment) => segment.length > 0)
58
+ .map((segment) => encodeURIComponent(segment))
59
+ .join("/");
60
+ return `https://raw.githubusercontent.com/${entry.github}/${normalizedRef}/${encodedPath}`;
61
+ }
62
+ function toUrlCommandMarkdownUrl(rawUrl) {
63
+ const parsed = new URL(rawUrl);
64
+ if (!parsed.pathname.endsWith(".md")) {
65
+ const trimmedPath = parsed.pathname.endsWith("/")
66
+ ? parsed.pathname.slice(0, -1)
67
+ : parsed.pathname;
68
+ parsed.pathname = `${trimmedPath}.md`;
69
+ }
70
+ return parsed.toString();
71
+ }
72
+ function createCachePath(url, cacheDir) {
73
+ const hash = createHash("sha256").update(url).digest("hex");
74
+ return join(cacheDir, hash);
75
+ }
76
+ async function readCachedContent(cachePath) {
77
+ try {
78
+ return await readFile(cachePath, "utf8");
79
+ }
80
+ catch (error) {
81
+ if (isNodeError(error) && error.code === "ENOENT") {
82
+ return null;
83
+ }
84
+ throw error;
85
+ }
86
+ }
87
+ async function fetchRemoteCommandContent(url, options) {
88
+ const shouldUseCache = options.cache ?? true;
89
+ const cacheDir = options.cacheDir ?? DEFAULT_CACHE_DIR;
90
+ const cachePath = createCachePath(url, cacheDir);
91
+ if (shouldUseCache) {
92
+ const cachedContent = await readCachedContent(cachePath);
93
+ if (cachedContent !== null) {
94
+ return cachedContent;
95
+ }
96
+ }
97
+ const fetchImpl = options.fetchImpl ?? globalThis.fetch;
98
+ const response = await fetchImpl(url);
99
+ if (!response.ok) {
100
+ throw new Error(`Failed to fetch command from ${url}: ${response.status} ${response.statusText}`.trim());
101
+ }
102
+ const content = await response.text();
103
+ if (shouldUseCache) {
104
+ await mkdir(dirname(cachePath), { recursive: true });
105
+ await writeFile(cachePath, content, "utf8");
106
+ }
107
+ return content;
108
+ }
109
+ function getStringFieldOrDefault(frontmatter, fieldName) {
110
+ const value = frontmatter[fieldName];
111
+ return typeof value === "string" ? value.trim() : "";
112
+ }
113
+ function toCommand(markdown, sourcePath) {
114
+ const parsed = parseFrontmatter(markdown);
115
+ return {
116
+ name: getRequiredField(parsed.frontmatter, "name", sourcePath),
117
+ description: getStringFieldOrDefault(parsed.frontmatter, "description"),
118
+ argumentHint: getOptionalStringField(parsed.frontmatter, "argument-hint"),
119
+ content: stripCategoryPlaceholders(parsed.content),
120
+ sourcePath,
121
+ };
122
+ }
123
+ async function loadLocalCommand(entry, options) {
124
+ if (!options.basePath) {
125
+ throw new Error("basePath is required to load local commands.");
126
+ }
127
+ const filePath = toLocalCommandFilePath(options.basePath, entry.path);
128
+ const content = await readFile(filePath, "utf8");
129
+ return toCommand(content, filePath);
130
+ }
131
+ async function loadGithubCommand(entry, options) {
132
+ const sourceUrl = toGithubRawUrl(entry);
133
+ const content = await fetchRemoteCommandContent(sourceUrl, options);
134
+ return toCommand(content, sourceUrl);
135
+ }
136
+ async function loadUrlCommand(entry, options) {
137
+ const sourceUrl = toUrlCommandMarkdownUrl(entry.url);
138
+ const content = await fetchRemoteCommandContent(sourceUrl, options);
139
+ return toCommand(content, sourceUrl);
140
+ }
141
+ export async function loadCommand(entry, options = {}) {
142
+ if ("path" in entry) {
143
+ return await loadLocalCommand(entry, options);
144
+ }
145
+ if ("github" in entry) {
146
+ return await loadGithubCommand(entry, options);
147
+ }
148
+ return await loadUrlCommand(entry, options);
149
+ }
150
+ export async function loadAllCommands(entries, basePath, options = {}) {
151
+ const results = await Promise.allSettled(entries.map((entry) => loadCommand(entry, { ...options, basePath })));
152
+ const commands = [];
153
+ for (const result of results) {
154
+ if (result.status === "fulfilled") {
155
+ commands.push(result.value);
156
+ }
157
+ else {
158
+ console.warn(`[commands] Failed to load command: ${result.reason}`);
159
+ }
160
+ }
161
+ return commands;
162
+ }
163
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/commands/loader.ts"],"names":[],"mappings":"AAAA,OAA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AAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,sCAAsC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type Command = {
2
+ name: string;
3
+ description: string;
4
+ argumentHint?: string;
5
+ content: string;
6
+ sourcePath: string;
7
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { Agent } from "../agent/types.js";
2
+ export type CommandDef = {
3
+ methodName: string;
4
+ content: string;
5
+ };
6
+ export declare function withCommands<T>(agent: Agent, commands: CommandDef[]): Agent & T;
@@ -0,0 +1,19 @@
1
+ const RESERVED_KEYS = new Set([
2
+ "name", "status", "respond", "respondStream", "shutdown",
3
+ "__proto__", "constructor", "toString", "hasOwnProperty", "valueOf",
4
+ ]);
5
+ export function withCommands(agent, commands) {
6
+ const target = agent;
7
+ commands.forEach((cmd) => {
8
+ if (RESERVED_KEYS.has(cmd.methodName)) {
9
+ throw new Error(`Command method name "${cmd.methodName}" conflicts with a reserved Agent property.`);
10
+ }
11
+ target[cmd.methodName] = async (args = "") => {
12
+ const content = cmd.content.replace(/\$ARGUMENTS/g, () => args);
13
+ const input = [{ role: "user", content }];
14
+ return agent.respond(input);
15
+ };
16
+ });
17
+ return target;
18
+ }
19
+ //# sourceMappingURL=with-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-commands.js","sourceRoot":"","sources":["../../src/commands/with-commands.ts"],"names":[],"mappings":"AAQA,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC;IACjD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU;IACxD,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS;CACpE,CAAC,CAAC;AAEH,MAAM,UAAU,YAAY,CAAI,KAAY,EAAE,QAAsB;IAClE,MAAM,MAAM,GAAG,KAAwC,CAAC;IAExD,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACvB,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,wBAAwB,GAAG,CAAC,UAAU,6CAA6C,CACpF,CAAC;QACJ,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,KAAK,EAAE,OAAe,EAAE,EAA2B,EAAE;YAC5E,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YAChE,MAAM,KAAK,GAAkB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAmB,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "data-analyst",
3
+ "namePascal": "DataAnalyst",
4
+ "model": {
5
+ "provider": "openai",
6
+ "model": "gpt-5.3-codex"
7
+ },
8
+ "sandbox": {
9
+ "provider": "e2b",
10
+ "timeout": 300,
11
+ "resources": {
12
+ "cpu": 2,
13
+ "memory": "512MB"
14
+ },
15
+ "e2b": {
16
+ "template": "data-analyst-demo",
17
+ "build": {
18
+ "dockerfile": "./Dockerfile"
19
+ }
20
+ }
21
+ },
22
+ "prompt": {
23
+ "system": "You are a data analysis agent.\nYou have access to a sandboxed Python environment with pandas, matplotlib, and numpy.\nFollow the skill instructions precisely.\nAlways use the tools available to you — do not produce output without using tools.\nUse `/workspace/` as the working directory for all files.\nBefore replying with results, always read the output files with the Read tool.\n",
24
+ "variables": []
25
+ },
26
+ "systemPrompt": "You are a data analysis agent.\nYou have access to a sandboxed Python environment with pandas, matplotlib, and numpy.\nFollow the skill instructions precisely.\nAlways use the tools available to you — do not produce output without using tools.\nUse `/workspace/` as the working directory for all files.\nBefore replying with results, always read the output files with the Read tool.\n\n## Skills\n\n### data-analysis\n---\nname: data-analysis\ndescription: Analyze data using Python with pandas, matplotlib, and numpy.\n---\n\n# Data Analysis\n\nYou are given a data analysis task by the user. Follow these steps:\n\n1. **Write** a Python script to `/workspace/analysis.py` that:\n - Creates or reads the data as described by the user\n - Performs the requested analysis using pandas/numpy\n - Prints summary statistics to stdout\n - Saves any charts to `/workspace/chart.png` using matplotlib (use `savefig`, not `show`)\n\n2. **Run** the script in the sandbox using Bash:\n ```\n cd /workspace && python3 analysis.py\n ```\n\n3. **Read** the Bash output to get the printed results.\n\n4. Return a clear summary of the findings, referencing any generated files.\n\nRules:\n\n- Always use `/workspace/` as the working directory.\n- Use `matplotlib.use('Agg')` before importing pyplot (no display server).\n- Save figures with `plt.savefig('/workspace/chart.png', dpi=100, bbox_inches='tight')`.\n- If the user provides CSV data inline, write it to `/workspace/data.csv` first.\n- If the Bash command fails, return the error output and suggest fixes.",
27
+ "skills": [
28
+ {
29
+ "name": "data-analysis",
30
+ "description": "Analyze data using Python with pandas, matplotlib, and numpy.",
31
+ "sourcePath": "/Users/yujiachen/Projects/agent-bundle/demo/data-analyst-e2b/skills/data-analysis/SKILL.md",
32
+ "content": "---\nname: data-analysis\ndescription: Analyze data using Python with pandas, matplotlib, and numpy.\n---\n\n# Data Analysis\n\nYou are given a data analysis task by the user. Follow these steps:\n\n1. **Write** a Python script to `/workspace/analysis.py` that:\n - Creates or reads the data as described by the user\n - Performs the requested analysis using pandas/numpy\n - Prints summary statistics to stdout\n - Saves any charts to `/workspace/chart.png` using matplotlib (use `savefig`, not `show`)\n\n2. **Run** the script in the sandbox using Bash:\n ```\n cd /workspace && python3 analysis.py\n ```\n\n3. **Read** the Bash output to get the printed results.\n\n4. Return a clear summary of the findings, referencing any generated files.\n\nRules:\n\n- Always use `/workspace/` as the working directory.\n- Use `matplotlib.use('Agg')` before importing pyplot (no display server).\n- Save figures with `plt.savefig('/workspace/chart.png', dpi=100, bbox_inches='tight')`.\n- If the user provides CSV data inline, write it to `/workspace/data.csv` first.\n- If the Bash command fails, return the error output and suggest fixes.\n"
33
+ }
34
+ ],
35
+ "commands": [],
36
+ "sandboxImage": {
37
+ "provider": "e2b",
38
+ "ref": "data-analyst-demo"
39
+ }
40
+ }
@@ -0,0 +1,25 @@
1
+ import { defineAgent } from "agent-bundle/runtime";
2
+
3
+ export const DataAnalyst = defineAgent({
4
+ name: "data-analyst",
5
+ sandbox: {
6
+ provider: "e2b",
7
+ timeout: 300,
8
+ resources: {
9
+ cpu: 2,
10
+ memory: "512MB"
11
+ },
12
+ e2b: {
13
+ template: "data-analyst-demo",
14
+ build: {
15
+ dockerfile: "./Dockerfile"
16
+ }
17
+ }
18
+ },
19
+ model: {
20
+ provider: "openai",
21
+ model: "gpt-5.3-codex"
22
+ },
23
+ systemPrompt: "You are a data analysis agent.\nYou have access to a sandboxed Python environment with pandas, matplotlib, and numpy.\nFollow the skill instructions precisely.\nAlways use the tools available to you \u2014 do not produce output without using tools.\nUse `/workspace/` as the working directory for all files.\nBefore replying with results, always read the output files with the Read tool.\n\n## Skills\n\n### data-analysis\n---\nname: data-analysis\ndescription: Analyze data using Python with pandas, matplotlib, and numpy.\n---\n\n# Data Analysis\n\nYou are given a data analysis task by the user. Follow these steps:\n\n1. **Write** a Python script to `/workspace/analysis.py` that:\n - Creates or reads the data as described by the user\n - Performs the requested analysis using pandas/numpy\n - Prints summary statistics to stdout\n - Saves any charts to `/workspace/chart.png` using matplotlib (use `savefig`, not `show`)\n\n2. **Run** the script in the sandbox using Bash:\n ```\n cd /workspace && python3 analysis.py\n ```\n\n3. **Read** the Bash output to get the printed results.\n\n4. Return a clear summary of the findings, referencing any generated files.\n\nRules:\n\n- Always use `/workspace/` as the working directory.\n- Use `matplotlib.use('Agg')` before importing pyplot (no display server).\n- Save figures with `plt.savefig('/workspace/chart.png', dpi=100, bbox_inches='tight')`.\n- If the user provides CSV data inline, write it to `/workspace/data.csv` first.\n- If the Bash command fails, return the error output and suggest fixes.",
24
+ variables: [] as const
25
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@agent-bundle/data-analyst",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "main": "./index.ts",
6
+ "types": "./index.ts",
7
+ "dependencies": {
8
+ "agent-bundle": "*"
9
+ }
10
+ }
@@ -0,0 +1,2 @@
1
+ export interface DataAnalystVariables {
2
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "financial-analyst",
3
+ "namePascal": "FinancialAnalyst",
4
+ "model": {
5
+ "provider": "openai",
6
+ "model": "gpt-5.3-codex"
7
+ },
8
+ "sandbox": {
9
+ "provider": "e2b",
10
+ "timeout": 300,
11
+ "resources": {
12
+ "cpu": 2,
13
+ "memory": "512MB"
14
+ },
15
+ "e2b": {
16
+ "template": "financial-analyst-demo",
17
+ "build": {
18
+ "dockerfile": "./Dockerfile"
19
+ }
20
+ }
21
+ },
22
+ "prompt": {
23
+ "system": "You are a financial analysis agent. Use the tools and skills available to you\nto help users with financial analysis tasks including variance analysis,\nfinancial statement generation, and data reconciliation.\n",
24
+ "variables": []
25
+ },
26
+ "systemPrompt": "You are a financial analysis agent. Use the tools and skills available to you\nto help users with financial analysis tasks including variance analysis,\nfinancial statement generation, and data reconciliation.\n\n## Skills\n\n### Report Formatter\n---\nname: Report Formatter\ndescription: Format financial analysis results into structured reports with tables and summaries.\n---\n\n# Report Formatter\n\nWhen presenting financial analysis results, format them as structured reports.\n\n## Output Format\n\n1. **Executive Summary** - A 2-3 sentence overview of key findings.\n2. **Data Table** - Present numerical data in a markdown table with headers.\n3. **Key Metrics** - Highlight the most important metrics as a bullet list.\n4. **Recommendations** - Actionable next steps based on the analysis.\n\n## Guidelines\n\n- Always include currency symbols and proper number formatting.\n- Round percentages to two decimal places.\n- Flag any values that deviate more than 10% from the expected range.\n- Use the sandbox to generate CSV exports when the user requests downloadable output.",
27
+ "skills": [
28
+ {
29
+ "name": "Report Formatter",
30
+ "description": "Format financial analysis results into structured reports with tables and summaries.",
31
+ "sourcePath": "/Users/yujiachen/Projects/agent-bundle/demo/financial-plugin/skills/report-formatter/SKILL.md",
32
+ "content": "---\nname: Report Formatter\ndescription: Format financial analysis results into structured reports with tables and summaries.\n---\n\n# Report Formatter\n\nWhen presenting financial analysis results, format them as structured reports.\n\n## Output Format\n\n1. **Executive Summary** - A 2-3 sentence overview of key findings.\n2. **Data Table** - Present numerical data in a markdown table with headers.\n3. **Key Metrics** - Highlight the most important metrics as a bullet list.\n4. **Recommendations** - Actionable next steps based on the analysis.\n\n## Guidelines\n\n- Always include currency symbols and proper number formatting.\n- Round percentages to two decimal places.\n- Flag any values that deviate more than 10% from the expected range.\n- Use the sandbox to generate CSV exports when the user requests downloadable output.\n"
33
+ }
34
+ ],
35
+ "commands": [],
36
+ "sandboxImage": {
37
+ "provider": "e2b",
38
+ "ref": "financial-analyst-demo"
39
+ }
40
+ }
@@ -0,0 +1,25 @@
1
+ import { defineAgent } from "agent-bundle/runtime";
2
+
3
+ export const FinancialAnalyst = defineAgent({
4
+ name: "financial-analyst",
5
+ sandbox: {
6
+ provider: "e2b",
7
+ timeout: 300,
8
+ resources: {
9
+ cpu: 2,
10
+ memory: "512MB"
11
+ },
12
+ e2b: {
13
+ template: "financial-analyst-demo",
14
+ build: {
15
+ dockerfile: "./Dockerfile"
16
+ }
17
+ }
18
+ },
19
+ model: {
20
+ provider: "openai",
21
+ model: "gpt-5.3-codex"
22
+ },
23
+ systemPrompt: "You are a financial analysis agent. Use the tools and skills available to you\nto help users with financial analysis tasks including variance analysis,\nfinancial statement generation, and data reconciliation.\n\n## Skills\n\n### Report Formatter\n---\nname: Report Formatter\ndescription: Format financial analysis results into structured reports with tables and summaries.\n---\n\n# Report Formatter\n\nWhen presenting financial analysis results, format them as structured reports.\n\n## Output Format\n\n1. **Executive Summary** - A 2-3 sentence overview of key findings.\n2. **Data Table** - Present numerical data in a markdown table with headers.\n3. **Key Metrics** - Highlight the most important metrics as a bullet list.\n4. **Recommendations** - Actionable next steps based on the analysis.\n\n## Guidelines\n\n- Always include currency symbols and proper number formatting.\n- Round percentages to two decimal places.\n- Flag any values that deviate more than 10% from the expected range.\n- Use the sandbox to generate CSV exports when the user requests downloadable output.",
24
+ variables: [] as const
25
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@agent-bundle/financial-analyst",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "main": "./index.ts",
6
+ "types": "./index.ts",
7
+ "dependencies": {
8
+ "agent-bundle": "*"
9
+ }
10
+ }
@@ -0,0 +1,2 @@
1
+ export interface FinancialAnalystVariables {
2
+ }
@@ -0,0 +1,26 @@
1
+ import type { ToolCall, ToolResult } from "../agent-loop/index.js";
2
+ import type { McpServerConfig } from "../agent/types.js";
3
+ import type { SandboxIO } from "../sandbox/types.js";
4
+ import { type ConnectMcpServer } from "./connect-server.js";
5
+ type Logger = Pick<Console, "warn">;
6
+ export type McpClientManager = {
7
+ tools: readonly {
8
+ name: string;
9
+ description: string;
10
+ inputSchema: {
11
+ type: "object";
12
+ properties?: Record<string, unknown>;
13
+ required?: string[];
14
+ [key: string]: unknown;
15
+ };
16
+ }[];
17
+ callTool(call: ToolCall): Promise<ToolResult>;
18
+ dispose(): Promise<void>;
19
+ };
20
+ export type CreateMcpClientManagerOptions = {
21
+ connectServer?: ConnectMcpServer;
22
+ logger?: Logger;
23
+ sandbox?: SandboxIO | null;
24
+ };
25
+ export declare function createMcpClientManager(servers: readonly McpServerConfig[], tokens: Record<string, string>, options?: CreateMcpClientManagerOptions): Promise<McpClientManager | null>;
26
+ export {};
@@ -0,0 +1,101 @@
1
+ import { defaultConnectServer, toServerLocation, } from "./connect-server.js";
2
+ const MCP_TOOL_PREFIX = "mcp__";
3
+ function toErrorMessage(error) {
4
+ if (error instanceof Error) {
5
+ return error.message;
6
+ }
7
+ return String(error);
8
+ }
9
+ function toToolError(toolCallId, message) {
10
+ return {
11
+ toolCallId,
12
+ output: message,
13
+ isError: true,
14
+ };
15
+ }
16
+ function toNamespacedToolName(serverName, toolName) {
17
+ return `${MCP_TOOL_PREFIX}${serverName}__${toolName}`;
18
+ }
19
+ function buildToolRouteMap(connections, logger) {
20
+ const routes = new Map();
21
+ const tools = [];
22
+ connections.forEach((connection) => {
23
+ connection.tools.forEach((tool) => {
24
+ const namespacedName = toNamespacedToolName(connection.serverName, tool.name);
25
+ if (routes.has(namespacedName)) {
26
+ logger.warn(`MCP duplicate tool detected for "${namespacedName}". Keeping the first registration.`);
27
+ return;
28
+ }
29
+ routes.set(namespacedName, {
30
+ serverName: connection.serverName,
31
+ toolName: tool.name,
32
+ connection,
33
+ });
34
+ tools.push({
35
+ name: namespacedName,
36
+ description: tool.description,
37
+ inputSchema: tool.inputSchema,
38
+ });
39
+ });
40
+ });
41
+ return { tools, routes };
42
+ }
43
+ function createManager(connections, logger) {
44
+ const { tools, routes } = buildToolRouteMap(connections, logger);
45
+ return {
46
+ tools,
47
+ callTool: async (call) => {
48
+ const route = routes.get(call.name);
49
+ if (!route) {
50
+ return toToolError(call.id, `MCP tool "${call.name}" is not available.`);
51
+ }
52
+ try {
53
+ const result = await route.connection.callTool(route.toolName, call.input);
54
+ return {
55
+ toolCallId: call.id,
56
+ output: result.output,
57
+ ...(result.isError ? { isError: true } : {}),
58
+ };
59
+ }
60
+ catch (error) {
61
+ return toToolError(call.id, `MCP tool "${call.name}" failed on server "${route.serverName}": ${toErrorMessage(error)}`);
62
+ }
63
+ },
64
+ dispose: async () => {
65
+ const closeResults = await Promise.allSettled(connections.map(async (connection) => {
66
+ await connection.close();
67
+ }));
68
+ const failures = closeResults.flatMap((result, index) => {
69
+ if (result.status === "fulfilled") {
70
+ return [];
71
+ }
72
+ const serverName = connections[index]?.serverName ?? "unknown";
73
+ return [`${serverName}: ${toErrorMessage(result.reason)}`];
74
+ });
75
+ if (failures.length > 0) {
76
+ throw new Error(`Failed to close MCP connections: ${failures.join(" | ")}`);
77
+ }
78
+ },
79
+ };
80
+ }
81
+ export async function createMcpClientManager(servers, tokens, options = {}) {
82
+ if (servers.length === 0) {
83
+ return null;
84
+ }
85
+ const logger = options.logger ?? console;
86
+ const connectServer = options.connectServer ?? defaultConnectServer;
87
+ const sandbox = options.sandbox ?? null;
88
+ const connections = await Promise.all(servers.map(async (server) => {
89
+ const token = tokens[server.name];
90
+ try {
91
+ return await connectServer(server, token, sandbox);
92
+ }
93
+ catch (error) {
94
+ logger.warn(`MCP server "${server.name}" at ${toServerLocation(server)} is unreachable: ${toErrorMessage(error)}`);
95
+ return null;
96
+ }
97
+ }));
98
+ const reachableConnections = connections.filter((connection) => connection !== null);
99
+ return createManager(reachableConnections, logger);
100
+ }
101
+ //# sourceMappingURL=client-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-manager.js","sourceRoot":"","sources":["../../src/mcp/client-manager.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,GAGjB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,eAAe,GAAG,OAAO,CAAC;AAgChC,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,UAAkB,EAAE,OAAe;IACtD,OAAO;QACL,UAAU;QACV,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,UAAkB,EAAE,QAAgB;IAChE,OAAO,GAAG,eAAe,GAAG,UAAU,KAAK,QAAQ,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a,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { AgentLoopTool } from "../agent-loop/index.js";
2
+ import type { McpServerConfig } from "../agent/types.js";
3
+ import type { SandboxIO } from "../sandbox/types.js";
4
+ export type McpConnectionCallResult = {
5
+ output: unknown;
6
+ isError?: boolean;
7
+ };
8
+ export type DiscoveredTool = {
9
+ name: string;
10
+ description: string;
11
+ inputSchema: AgentLoopTool["inputSchema"];
12
+ };
13
+ export type McpConnection = {
14
+ serverName: string;
15
+ tools: readonly DiscoveredTool[];
16
+ callTool(toolName: string, input: Record<string, unknown>): Promise<McpConnectionCallResult>;
17
+ close(): Promise<void>;
18
+ };
19
+ export type ConnectMcpServer = (server: McpServerConfig, token: string | undefined, sandbox: SandboxIO | null) => Promise<McpConnection>;
20
+ export declare function toServerLocation(server: McpServerConfig): string;
21
+ export declare function defaultConnectServer(server: McpServerConfig, token: string | undefined, sandbox: SandboxIO | null): Promise<McpConnection>;