@crewx/sdk 0.8.0-rc.72 → 0.8.0-rc.74

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 (548) hide show
  1. package/README.md +380 -818
  2. package/dist/adapter/context-builder.d.ts +35 -0
  3. package/dist/adapter/context-builder.js +87 -0
  4. package/dist/adapter/index.d.ts +5 -0
  5. package/dist/{core/remote → adapter}/index.js +3 -2
  6. package/dist/adapter/plugin-helper.d.ts +19 -0
  7. package/dist/adapter/plugin-helper.js +45 -0
  8. package/dist/adapter/scoped-store.d.ts +12 -0
  9. package/dist/adapter/scoped-store.js +43 -0
  10. package/dist/adapter/types.d.ts +264 -0
  11. package/dist/adapter/types.js +23 -0
  12. package/dist/agent/resolver.d.ts +18 -0
  13. package/dist/agent/resolver.js +46 -0
  14. package/dist/boxing/box-storage.interface.d.ts +12 -0
  15. package/dist/boxing/box-storage.interface.js +3 -0
  16. package/dist/boxing/box.service.d.ts +4 -0
  17. package/dist/boxing/box.service.js +5 -1
  18. package/dist/boxing/box.types.d.ts +4 -0
  19. package/dist/boxing/box.types.js +3 -0
  20. package/dist/boxing/context-builder.d.ts +6 -7
  21. package/dist/boxing/context-builder.js +3 -0
  22. package/dist/client/CrewxClient.d.ts +65 -0
  23. package/dist/client/CrewxClient.js +86 -0
  24. package/dist/client/index.d.ts +3 -0
  25. package/dist/client/index.js +6 -0
  26. package/dist/config/loader.browser.d.ts +14 -0
  27. package/dist/config/loader.browser.js +59 -0
  28. package/dist/config/loader.d.ts +19 -0
  29. package/dist/config/loader.js +95 -0
  30. package/dist/conversation/index.d.ts +5 -3
  31. package/dist/conversation/index.js +8 -3
  32. package/dist/conversation/sqlite-provider.d.ts +21 -0
  33. package/dist/conversation/sqlite-provider.js +178 -0
  34. package/dist/conversation/to-task-reader.d.ts +14 -0
  35. package/dist/conversation/to-task-reader.js +28 -0
  36. package/dist/conversation/to-template-messages.d.ts +15 -0
  37. package/dist/conversation/to-template-messages.js +34 -0
  38. package/dist/conversation/types.d.ts +101 -0
  39. package/dist/conversation/types.js +10 -0
  40. package/dist/esm/agent/resolver.js +41 -0
  41. package/dist/esm/boxing/box-storage.interface.js +5 -0
  42. package/dist/esm/boxing/box.service.js +69 -0
  43. package/dist/esm/boxing/box.types.js +5 -0
  44. package/dist/esm/boxing/context-builder.js +76 -0
  45. package/dist/esm/client/CrewxClient.js +82 -0
  46. package/dist/esm/client/index.js +2 -0
  47. package/dist/esm/config/loader.browser.js +54 -0
  48. package/dist/esm/config/loader.js +77 -0
  49. package/dist/esm/events/TypedEventEmitter.js +61 -0
  50. package/dist/esm/events/types.js +8 -0
  51. package/dist/esm/facade/Crewx.browser.js +310 -0
  52. package/dist/esm/facade/Crewx.js +941 -0
  53. package/dist/esm/hooks/define.js +10 -0
  54. package/dist/esm/hooks/dispatch.js +76 -0
  55. package/dist/esm/hooks/index.js +6 -0
  56. package/dist/esm/hooks/observer.js +56 -0
  57. package/dist/esm/hooks/plugin.js +12 -0
  58. package/dist/esm/hooks/types.js +9 -0
  59. package/dist/esm/index.browser.js +15 -0
  60. package/dist/esm/index.js +60 -0
  61. package/dist/esm/layout/loader.js +268 -0
  62. package/dist/esm/layout/props-validator.js +297 -0
  63. package/dist/esm/layout/renderer.js +180 -0
  64. package/dist/esm/layout/types.js +31 -0
  65. package/dist/esm/parallel/agent-runtime.js +21 -0
  66. package/dist/esm/parallel/helpers.js +214 -0
  67. package/dist/esm/parallel/index.js +5 -0
  68. package/dist/esm/parallel/parallel-runner.js +221 -0
  69. package/dist/esm/parallel/types.js +5 -0
  70. package/dist/esm/parsers/agent-call.util.js +15 -0
  71. package/dist/esm/parsers/claude.parser.js +64 -0
  72. package/dist/esm/parsers/codex.parser.js +97 -0
  73. package/dist/esm/parsers/copilot.parser.js +63 -0
  74. package/dist/esm/parsers/gemini.parser.js +43 -0
  75. package/dist/esm/parsers/opencode.parser.js +73 -0
  76. package/dist/esm/parsers/router.js +53 -0
  77. package/dist/esm/platform/BrowserFsAdapter.js +80 -0
  78. package/dist/esm/platform/IFsAdapter.js +2 -0
  79. package/dist/esm/platform/NodeFsAdapter.js +34 -0
  80. package/dist/esm/plugin/plugin-provider.js +202 -0
  81. package/dist/esm/plugin/types.js +8 -0
  82. package/dist/esm/plugin.js +25 -0
  83. package/dist/esm/provider/bridge.browser.js +43 -0
  84. package/dist/esm/provider/bridge.js +373 -0
  85. package/dist/esm/provider/parse-usage.js +80 -0
  86. package/dist/esm/provider/register-api.js +21 -0
  87. package/dist/esm/provider/vercel-runtime.js +310 -0
  88. package/dist/esm/remote/index.js +10 -0
  89. package/dist/esm/remote/remote-agent-manager.js +194 -0
  90. package/dist/esm/remote/remote-provider.js +98 -0
  91. package/dist/esm/remote/remote-transport.js +79 -0
  92. package/dist/esm/remote/types.js +8 -0
  93. package/dist/esm/server/auth.js +31 -0
  94. package/dist/esm/server/handler.js +72 -0
  95. package/dist/esm/server/index.js +5 -0
  96. package/dist/esm/server/tool-adapter.js +92 -0
  97. package/dist/esm/template/engine.js +100 -0
  98. package/dist/esm/template/helpers/exec.browser.js +31 -0
  99. package/dist/esm/template/helpers/exec.js +220 -0
  100. package/dist/esm/template/helpers/fenced_code.js +17 -0
  101. package/dist/esm/template/helpers/include.js +20 -0
  102. package/dist/esm/template/helpers/p1p2.js +83 -0
  103. package/dist/esm/template/loader/DocumentLoader.js +124 -0
  104. package/dist/esm/template/types.js +5 -0
  105. package/dist/esm/tools/delegate.js +57 -0
  106. package/dist/esm/tools/index.js +5 -0
  107. package/dist/esm/tools/node/builtin.js +541 -0
  108. package/dist/esm/tools/node/index.js +54 -0
  109. package/dist/esm/types/index.js +27 -0
  110. package/dist/esm/types/task-log.types.js +5 -0
  111. package/dist/esm/utils/env-defaults.js +23 -0
  112. package/dist/esm/utils/glob-match.js +38 -0
  113. package/dist/esm/utils/id.js +46 -0
  114. package/dist/esm/utils/workspace.js +21 -0
  115. package/dist/events/TypedEventEmitter.d.ts +31 -0
  116. package/dist/events/TypedEventEmitter.js +65 -0
  117. package/dist/events/types.d.ts +139 -0
  118. package/dist/events/types.js +9 -0
  119. package/dist/facade/Crewx.browser.d.ts +73 -0
  120. package/dist/facade/Crewx.browser.js +314 -0
  121. package/dist/facade/Crewx.d.ts +267 -0
  122. package/dist/facade/Crewx.js +1299 -0
  123. package/dist/hooks/define.d.ts +10 -0
  124. package/dist/hooks/define.js +13 -0
  125. package/dist/hooks/dispatch.d.ts +61 -0
  126. package/dist/hooks/dispatch.js +147 -0
  127. package/dist/hooks/index.d.ts +13 -0
  128. package/dist/hooks/index.js +24 -0
  129. package/dist/hooks/observer.d.ts +20 -0
  130. package/dist/hooks/observer.js +60 -0
  131. package/dist/hooks/plugin.d.ts +19 -0
  132. package/dist/hooks/plugin.js +17 -0
  133. package/dist/hooks/tool-normalize.d.ts +29 -0
  134. package/dist/hooks/tool-normalize.js +110 -0
  135. package/dist/hooks/types.d.ts +79 -0
  136. package/dist/hooks/types.js +12 -0
  137. package/dist/hooks/yaml-plugin.d.ts +29 -0
  138. package/dist/hooks/yaml-plugin.js +356 -0
  139. package/dist/index.browser.d.ts +15 -0
  140. package/dist/index.browser.js +25 -0
  141. package/dist/index.d.ts +70 -58
  142. package/dist/index.js +144 -133
  143. package/dist/{services/layout-loader.service.d.ts → layout/loader.d.ts} +24 -4
  144. package/dist/{services/layout-loader.service.js → layout/loader.js} +103 -73
  145. package/dist/{services/props-validator.service.d.ts → layout/props-validator.d.ts} +7 -1
  146. package/dist/{services/props-validator.service.js → layout/props-validator.js} +28 -59
  147. package/dist/{services/layout-renderer.service.d.ts → layout/renderer.d.ts} +28 -14
  148. package/dist/layout/renderer.js +193 -0
  149. package/dist/{types/layout.types.d.ts → layout/types.d.ts} +47 -1
  150. package/dist/{types/layout.types.js → layout/types.js} +15 -1
  151. package/dist/parallel/agent-runtime.d.ts +31 -0
  152. package/dist/parallel/agent-runtime.js +25 -0
  153. package/dist/{core/parallel → parallel}/helpers.d.ts +2 -1
  154. package/dist/{core/parallel → parallel}/helpers.js +55 -88
  155. package/dist/parallel/index.d.ts +8 -0
  156. package/dist/{core/parallel → parallel}/index.js +5 -3
  157. package/dist/{core/parallel → parallel}/parallel-runner.d.ts +8 -1
  158. package/dist/{core/parallel → parallel}/parallel-runner.js +53 -57
  159. package/dist/parallel/types.d.ts +65 -0
  160. package/dist/parallel/types.js +6 -0
  161. package/dist/parsers/agent-call.util.d.ts +3 -0
  162. package/dist/parsers/agent-call.util.js +2 -0
  163. package/dist/parsers/api.parser.d.ts +10 -0
  164. package/dist/parsers/api.parser.js +26 -0
  165. package/dist/parsers/claude.parser.d.ts +8 -0
  166. package/dist/parsers/claude.parser.js +22 -1
  167. package/dist/parsers/codex.parser.d.ts +8 -0
  168. package/dist/parsers/codex.parser.js +11 -0
  169. package/dist/parsers/copilot.parser.d.ts +9 -0
  170. package/dist/parsers/copilot.parser.js +8 -0
  171. package/dist/parsers/gemini.parser.d.ts +10 -0
  172. package/dist/parsers/gemini.parser.js +10 -0
  173. package/dist/parsers/opencode.parser.d.ts +12 -0
  174. package/dist/parsers/opencode.parser.js +76 -0
  175. package/dist/parsers/router.d.ts +7 -0
  176. package/dist/parsers/router.js +56 -0
  177. package/dist/platform/BrowserFsAdapter.d.ts +37 -0
  178. package/dist/platform/BrowserFsAdapter.js +84 -0
  179. package/dist/platform/IFsAdapter.d.ts +29 -0
  180. package/dist/{core/remote/types.js → platform/IFsAdapter.js} +1 -1
  181. package/dist/platform/NodeFsAdapter.d.ts +16 -0
  182. package/dist/platform/NodeFsAdapter.js +38 -0
  183. package/dist/plugin/plugin-provider.d.ts +33 -0
  184. package/dist/plugin/plugin-provider.js +207 -0
  185. package/dist/plugin/types.d.ts +53 -0
  186. package/dist/plugin/types.js +9 -0
  187. package/dist/plugin.d.ts +33 -0
  188. package/dist/plugin.js +29 -0
  189. package/dist/plugins/conversation.d.ts +18 -0
  190. package/dist/plugins/conversation.js +59 -0
  191. package/dist/plugins/file-logger.d.ts +29 -0
  192. package/dist/plugins/file-logger.js +87 -0
  193. package/dist/plugins/index.d.ts +16 -0
  194. package/dist/plugins/index.js +19 -0
  195. package/dist/plugins/sqlite-tracing.d.ts +29 -0
  196. package/dist/plugins/sqlite-tracing.js +112 -0
  197. package/dist/provider/bridge.browser.d.ts +49 -0
  198. package/dist/provider/bridge.browser.js +49 -0
  199. package/dist/provider/bridge.d.ts +106 -0
  200. package/dist/provider/bridge.js +380 -0
  201. package/dist/provider/mastra-runtime.d.ts +45 -0
  202. package/dist/provider/mastra-runtime.js +208 -0
  203. package/dist/provider/parse-usage.d.ts +20 -0
  204. package/dist/provider/parse-usage.js +83 -0
  205. package/dist/provider/register-api.d.ts +14 -0
  206. package/dist/provider/register-api.js +24 -0
  207. package/dist/provider/vercel-runtime.d.ts +54 -0
  208. package/dist/provider/vercel-runtime.js +347 -0
  209. package/dist/remote/index.d.ts +13 -0
  210. package/dist/remote/index.js +32 -0
  211. package/dist/remote/remote-agent-manager.d.ts +54 -0
  212. package/dist/{core/remote → remote}/remote-agent-manager.js +100 -97
  213. package/dist/remote/remote-provider.d.ts +47 -0
  214. package/dist/remote/remote-provider.js +141 -0
  215. package/dist/remote/remote-transport.d.ts +32 -0
  216. package/dist/remote/remote-transport.js +83 -0
  217. package/dist/remote/types.d.ts +147 -0
  218. package/dist/remote/types.js +9 -0
  219. package/dist/server/auth.d.ts +21 -0
  220. package/dist/server/auth.js +35 -0
  221. package/dist/server/handler.d.ts +24 -0
  222. package/dist/server/handler.js +75 -0
  223. package/dist/server/index.d.ts +7 -0
  224. package/dist/server/index.js +9 -0
  225. package/dist/server/tool-adapter.d.ts +19 -0
  226. package/dist/server/tool-adapter.js +95 -0
  227. package/dist/template/engine.d.ts +28 -0
  228. package/dist/template/engine.js +137 -0
  229. package/dist/template/helpers/exec.browser.d.ts +22 -0
  230. package/dist/template/helpers/exec.browser.js +41 -0
  231. package/dist/template/helpers/exec.d.ts +60 -0
  232. package/dist/template/helpers/exec.js +230 -0
  233. package/dist/template/helpers/fenced_code.d.ts +22 -0
  234. package/dist/template/helpers/fenced_code.js +20 -0
  235. package/dist/template/helpers/format-conversation.d.ts +30 -0
  236. package/dist/template/helpers/format-conversation.js +53 -0
  237. package/dist/template/helpers/include.d.ts +16 -0
  238. package/dist/template/helpers/include.js +23 -0
  239. package/dist/template/helpers/p1p2.d.ts +37 -0
  240. package/dist/template/helpers/p1p2.js +90 -0
  241. package/dist/template/loader/DocumentLoader.d.ts +48 -0
  242. package/dist/template/loader/DocumentLoader.js +128 -0
  243. package/dist/template/types.d.ts +51 -0
  244. package/dist/template/types.js +6 -0
  245. package/dist/testing/index.d.ts +12 -0
  246. package/dist/testing/index.js +16 -0
  247. package/dist/testing/mock-audit.d.ts +10 -0
  248. package/dist/testing/mock-audit.js +13 -0
  249. package/dist/testing/mock-context.d.ts +27 -0
  250. package/dist/testing/mock-context.js +68 -0
  251. package/dist/testing/mock-logger.d.ts +15 -0
  252. package/dist/testing/mock-logger.js +27 -0
  253. package/dist/testing/mock-router.d.ts +16 -0
  254. package/dist/testing/mock-router.js +67 -0
  255. package/dist/testing/mock-storage.d.ts +9 -0
  256. package/dist/testing/mock-storage.js +21 -0
  257. package/dist/testing/mock-store.d.ts +3 -0
  258. package/dist/testing/mock-store.js +8 -0
  259. package/dist/tools/delegate.d.ts +10 -0
  260. package/dist/tools/delegate.js +60 -0
  261. package/dist/tools/index.d.ts +5 -12
  262. package/dist/tools/index.js +6 -37
  263. package/dist/tools/node/builtin.d.ts +23 -0
  264. package/dist/tools/node/builtin.js +547 -0
  265. package/dist/tools/node/index.d.ts +23 -0
  266. package/dist/tools/node/index.js +59 -0
  267. package/dist/types/index.d.ts +804 -6
  268. package/dist/types/index.js +29 -20
  269. package/dist/types/task-log.types.d.ts +4 -0
  270. package/dist/types/task-log.types.js +3 -0
  271. package/dist/utils/env-defaults.d.ts +18 -0
  272. package/dist/utils/env-defaults.js +27 -0
  273. package/dist/utils/glob-match.d.ts +18 -0
  274. package/dist/utils/glob-match.js +42 -0
  275. package/dist/{core → utils}/id.d.ts +15 -0
  276. package/dist/utils/id.js +50 -0
  277. package/dist/utils/timestamp.d.ts +2 -0
  278. package/dist/utils/timestamp.js +13 -0
  279. package/dist/{core → utils}/workspace.d.ts +4 -0
  280. package/dist/{core → utils}/workspace.js +3 -0
  281. package/package.json +67 -102
  282. package/src/schemas/hooks.schema.json +59 -0
  283. package/templates/agents/default.yaml +490 -0
  284. package/templates/agents/minimal.yaml +16 -0
  285. package/LICENSE +0 -201
  286. package/dist/adapters/MastraToolAdapter.d.ts +0 -9
  287. package/dist/adapters/MastraToolAdapter.js +0 -66
  288. package/dist/adapters/MastraToolAdapter.js.map +0 -1
  289. package/dist/api/index.d.ts +0 -2
  290. package/dist/api/index.js +0 -8
  291. package/dist/api/index.js.map +0 -1
  292. package/dist/boxing/box-storage.interface.js.map +0 -1
  293. package/dist/boxing/box.service.js.map +0 -1
  294. package/dist/boxing/box.types.js.map +0 -1
  295. package/dist/boxing/context-builder.js.map +0 -1
  296. package/dist/boxing/index.d.ts +0 -6
  297. package/dist/boxing/index.js +0 -11
  298. package/dist/boxing/index.js.map +0 -1
  299. package/dist/boxing/tokenizer.d.ts +0 -3
  300. package/dist/boxing/tokenizer.js +0 -11
  301. package/dist/boxing/tokenizer.js.map +0 -1
  302. package/dist/config/api-provider-parser.d.ts +0 -58
  303. package/dist/config/api-provider-parser.js +0 -212
  304. package/dist/config/api-provider-parser.js.map +0 -1
  305. package/dist/config/index.d.ts +0 -3
  306. package/dist/config/index.js +0 -20
  307. package/dist/config/index.js.map +0 -1
  308. package/dist/config/log.config.d.ts +0 -7
  309. package/dist/config/log.config.js +0 -20
  310. package/dist/config/log.config.js.map +0 -1
  311. package/dist/config/pricing.d.ts +0 -11
  312. package/dist/config/pricing.js +0 -53
  313. package/dist/config/pricing.js.map +0 -1
  314. package/dist/config/timeout.config.d.ts +0 -14
  315. package/dist/config/timeout.config.js +0 -34
  316. package/dist/config/timeout.config.js.map +0 -1
  317. package/dist/config/yaml-loader.d.ts +0 -8
  318. package/dist/config/yaml-loader.js +0 -155
  319. package/dist/config/yaml-loader.js.map +0 -1
  320. package/dist/constants/index.d.ts +0 -4
  321. package/dist/constants/index.js +0 -8
  322. package/dist/constants/index.js.map +0 -1
  323. package/dist/constants.d.ts +0 -1
  324. package/dist/constants.js +0 -18
  325. package/dist/constants.js.map +0 -1
  326. package/dist/conversation/conversation-config.d.ts +0 -9
  327. package/dist/conversation/conversation-config.js +0 -22
  328. package/dist/conversation/conversation-config.js.map +0 -1
  329. package/dist/conversation/conversation-history.interface.d.ts +0 -36
  330. package/dist/conversation/conversation-history.interface.js +0 -3
  331. package/dist/conversation/conversation-history.interface.js.map +0 -1
  332. package/dist/conversation/conversation-storage.service.d.ts +0 -16
  333. package/dist/conversation/conversation-storage.service.js +0 -213
  334. package/dist/conversation/conversation-storage.service.js.map +0 -1
  335. package/dist/conversation/index.js.map +0 -1
  336. package/dist/core/__tests__/id.test.d.ts +0 -1
  337. package/dist/core/__tests__/id.test.js +0 -115
  338. package/dist/core/__tests__/id.test.js.map +0 -1
  339. package/dist/core/agent/agent-factory.d.ts +0 -37
  340. package/dist/core/agent/agent-factory.js +0 -68
  341. package/dist/core/agent/agent-factory.js.map +0 -1
  342. package/dist/core/agent/agent-runtime.d.ts +0 -52
  343. package/dist/core/agent/agent-runtime.js +0 -206
  344. package/dist/core/agent/agent-runtime.js.map +0 -1
  345. package/dist/core/agent/event-bus.d.ts +0 -44
  346. package/dist/core/agent/event-bus.js +0 -43
  347. package/dist/core/agent/event-bus.js.map +0 -1
  348. package/dist/core/agent/index.d.ts +0 -3
  349. package/dist/core/agent/index.js +0 -13
  350. package/dist/core/agent/index.js.map +0 -1
  351. package/dist/core/env-defaults.d.ts +0 -1
  352. package/dist/core/env-defaults.js +0 -7
  353. package/dist/core/env-defaults.js.map +0 -1
  354. package/dist/core/id.js +0 -27
  355. package/dist/core/id.js.map +0 -1
  356. package/dist/core/parallel/helpers.js.map +0 -1
  357. package/dist/core/parallel/index.d.ts +0 -4
  358. package/dist/core/parallel/index.js.map +0 -1
  359. package/dist/core/parallel/parallel-runner.js.map +0 -1
  360. package/dist/core/parallel/types.d.ts +0 -41
  361. package/dist/core/parallel/types.js +0 -3
  362. package/dist/core/parallel/types.js.map +0 -1
  363. package/dist/core/providers/MastraAPIProvider.d.ts +0 -31
  364. package/dist/core/providers/MastraAPIProvider.js +0 -365
  365. package/dist/core/providers/MastraAPIProvider.js.map +0 -1
  366. package/dist/core/providers/ai-provider.interface.d.ts +0 -79
  367. package/dist/core/providers/ai-provider.interface.js +0 -23
  368. package/dist/core/providers/ai-provider.interface.js.map +0 -1
  369. package/dist/core/providers/base-ai.provider.d.ts +0 -84
  370. package/dist/core/providers/base-ai.provider.js +0 -1237
  371. package/dist/core/providers/base-ai.provider.js.map +0 -1
  372. package/dist/core/providers/base-ai.types.d.ts +0 -26
  373. package/dist/core/providers/base-ai.types.js +0 -3
  374. package/dist/core/providers/base-ai.types.js.map +0 -1
  375. package/dist/core/providers/claude.provider.d.ts +0 -19
  376. package/dist/core/providers/claude.provider.js +0 -170
  377. package/dist/core/providers/claude.provider.js.map +0 -1
  378. package/dist/core/providers/codex.provider.d.ts +0 -21
  379. package/dist/core/providers/codex.provider.js +0 -134
  380. package/dist/core/providers/codex.provider.js.map +0 -1
  381. package/dist/core/providers/copilot.provider.d.ts +0 -25
  382. package/dist/core/providers/copilot.provider.js +0 -146
  383. package/dist/core/providers/copilot.provider.js.map +0 -1
  384. package/dist/core/providers/dynamic-provider.factory.d.ts +0 -74
  385. package/dist/core/providers/dynamic-provider.factory.js +0 -645
  386. package/dist/core/providers/dynamic-provider.factory.js.map +0 -1
  387. package/dist/core/providers/gemini.provider.d.ts +0 -16
  388. package/dist/core/providers/gemini.provider.js +0 -101
  389. package/dist/core/providers/gemini.provider.js.map +0 -1
  390. package/dist/core/providers/index.d.ts +0 -8
  391. package/dist/core/providers/index.js +0 -20
  392. package/dist/core/providers/index.js.map +0 -1
  393. package/dist/core/providers/mock.provider.d.ts +0 -13
  394. package/dist/core/providers/mock.provider.js +0 -55
  395. package/dist/core/providers/mock.provider.js.map +0 -1
  396. package/dist/core/providers/provider-factory.d.ts +0 -3
  397. package/dist/core/providers/provider-factory.js +0 -65
  398. package/dist/core/providers/provider-factory.js.map +0 -1
  399. package/dist/core/providers/tool-call.types.d.ts +0 -39
  400. package/dist/core/providers/tool-call.types.js +0 -3
  401. package/dist/core/providers/tool-call.types.js.map +0 -1
  402. package/dist/core/remote/index.d.ts +0 -3
  403. package/dist/core/remote/index.js.map +0 -1
  404. package/dist/core/remote/remote-agent-manager.d.ts +0 -24
  405. package/dist/core/remote/remote-agent-manager.js.map +0 -1
  406. package/dist/core/remote/remote-transport.d.ts +0 -15
  407. package/dist/core/remote/remote-transport.js +0 -70
  408. package/dist/core/remote/remote-transport.js.map +0 -1
  409. package/dist/core/remote/types.d.ts +0 -79
  410. package/dist/core/remote/types.js.map +0 -1
  411. package/dist/core/workspace.js.map +0 -1
  412. package/dist/index.js.map +0 -1
  413. package/dist/internal/index.d.ts +0 -1
  414. package/dist/internal/index.js +0 -6
  415. package/dist/internal/index.js.map +0 -1
  416. package/dist/knowledge/DocumentManager.d.ts +0 -4
  417. package/dist/knowledge/DocumentManager.js +0 -119
  418. package/dist/knowledge/DocumentManager.js.map +0 -1
  419. package/dist/knowledge/index.d.ts +0 -1
  420. package/dist/knowledge/index.js +0 -18
  421. package/dist/knowledge/index.js.map +0 -1
  422. package/dist/parsers/agent-call.util.js.map +0 -1
  423. package/dist/parsers/claude.parser.js.map +0 -1
  424. package/dist/parsers/codex.parser.js.map +0 -1
  425. package/dist/parsers/copilot.parser.js.map +0 -1
  426. package/dist/parsers/gemini.parser.js.map +0 -1
  427. package/dist/parsers/index.d.ts +0 -7
  428. package/dist/parsers/index.js +0 -45
  429. package/dist/parsers/index.js.map +0 -1
  430. package/dist/schema/skills-parser.d.ts +0 -8
  431. package/dist/schema/skills-parser.js +0 -438
  432. package/dist/schema/skills-parser.js.map +0 -1
  433. package/dist/schema/skills.types.d.ts +0 -158
  434. package/dist/schema/skills.types.js +0 -41
  435. package/dist/schema/skills.types.js.map +0 -1
  436. package/dist/schemas/api-provider.schema.d.ts +0 -432
  437. package/dist/schemas/api-provider.schema.js +0 -50
  438. package/dist/schemas/api-provider.schema.js.map +0 -1
  439. package/dist/services/index.d.ts +0 -2
  440. package/dist/services/index.js +0 -19
  441. package/dist/services/index.js.map +0 -1
  442. package/dist/services/layout-loader.service.js.map +0 -1
  443. package/dist/services/layout-renderer.service.js +0 -325
  444. package/dist/services/layout-renderer.service.js.map +0 -1
  445. package/dist/services/props-validator.service.js.map +0 -1
  446. package/dist/skills/adapter/claude-skill-adapter.d.ts +0 -11
  447. package/dist/skills/adapter/claude-skill-adapter.js +0 -222
  448. package/dist/skills/adapter/claude-skill-adapter.js.map +0 -1
  449. package/dist/skills/index.d.ts +0 -6
  450. package/dist/skills/index.js +0 -31
  451. package/dist/skills/index.js.map +0 -1
  452. package/dist/skills/runtime/progressive-loader.d.ts +0 -27
  453. package/dist/skills/runtime/progressive-loader.js +0 -186
  454. package/dist/skills/runtime/progressive-loader.js.map +0 -1
  455. package/dist/skills/runtime/runtime-requirements-validator.d.ts +0 -23
  456. package/dist/skills/runtime/runtime-requirements-validator.js +0 -248
  457. package/dist/skills/runtime/runtime-requirements-validator.js.map +0 -1
  458. package/dist/skills/runtime/skill-runtime.service.d.ts +0 -42
  459. package/dist/skills/runtime/skill-runtime.service.js +0 -434
  460. package/dist/skills/runtime/skill-runtime.service.js.map +0 -1
  461. package/dist/tools/file-system.service.d.ts +0 -10
  462. package/dist/tools/file-system.service.js +0 -33
  463. package/dist/tools/file-system.service.js.map +0 -1
  464. package/dist/tools/find.tool.d.ts +0 -21
  465. package/dist/tools/find.tool.js +0 -139
  466. package/dist/tools/find.tool.js.map +0 -1
  467. package/dist/tools/glob.tool.d.ts +0 -24
  468. package/dist/tools/glob.tool.js +0 -153
  469. package/dist/tools/glob.tool.js.map +0 -1
  470. package/dist/tools/grep.tool.d.ts +0 -1
  471. package/dist/tools/grep.tool.js +0 -137
  472. package/dist/tools/grep.tool.js.map +0 -1
  473. package/dist/tools/index.js.map +0 -1
  474. package/dist/tools/ls.tool.d.ts +0 -1
  475. package/dist/tools/ls.tool.js +0 -94
  476. package/dist/tools/ls.tool.js.map +0 -1
  477. package/dist/tools/read-file.tool.d.ts +0 -1
  478. package/dist/tools/read-file.tool.js +0 -69
  479. package/dist/tools/read-file.tool.js.map +0 -1
  480. package/dist/tools/replace.tool.d.ts +0 -1
  481. package/dist/tools/replace.tool.js +0 -68
  482. package/dist/tools/replace.tool.js.map +0 -1
  483. package/dist/tools/run-shell-command.tool.d.ts +0 -1
  484. package/dist/tools/run-shell-command.tool.js +0 -64
  485. package/dist/tools/run-shell-command.tool.js.map +0 -1
  486. package/dist/tools/tree.tool.d.ts +0 -1
  487. package/dist/tools/tree.tool.js +0 -109
  488. package/dist/tools/tree.tool.js.map +0 -1
  489. package/dist/tools/types.d.ts +0 -42
  490. package/dist/tools/types.js +0 -13
  491. package/dist/tools/types.js.map +0 -1
  492. package/dist/tools/utils/file-utils.d.ts +0 -5
  493. package/dist/tools/utils/file-utils.js +0 -221
  494. package/dist/tools/utils/file-utils.js.map +0 -1
  495. package/dist/tools/write-file.tool.d.ts +0 -1
  496. package/dist/tools/write-file.tool.js +0 -55
  497. package/dist/tools/write-file.tool.js.map +0 -1
  498. package/dist/types/agent.types.d.ts +0 -134
  499. package/dist/types/agent.types.js +0 -16
  500. package/dist/types/agent.types.js.map +0 -1
  501. package/dist/types/api-provider.types.d.ts +0 -85
  502. package/dist/types/api-provider.types.js +0 -65
  503. package/dist/types/api-provider.types.js.map +0 -1
  504. package/dist/types/index.js.map +0 -1
  505. package/dist/types/layout.types.js.map +0 -1
  506. package/dist/types/provider.types.d.ts +0 -12
  507. package/dist/types/provider.types.js +0 -3
  508. package/dist/types/provider.types.js.map +0 -1
  509. package/dist/types/skill-runtime.types.d.ts +0 -244
  510. package/dist/types/skill-runtime.types.js +0 -44
  511. package/dist/types/skill-runtime.types.js.map +0 -1
  512. package/dist/types/structured-payload.types.d.ts +0 -46
  513. package/dist/types/structured-payload.types.js +0 -65
  514. package/dist/types/structured-payload.types.js.map +0 -1
  515. package/dist/types/task-log.types.js.map +0 -1
  516. package/dist/types/template.types.d.ts +0 -38
  517. package/dist/types/template.types.js +0 -3
  518. package/dist/types/template.types.js.map +0 -1
  519. package/dist/types.d.ts +0 -1
  520. package/dist/types.js +0 -18
  521. package/dist/types.js.map +0 -1
  522. package/dist/utils/api-provider-normalizer.d.ts +0 -16
  523. package/dist/utils/api-provider-normalizer.js +0 -135
  524. package/dist/utils/api-provider-normalizer.js.map +0 -1
  525. package/dist/utils/base-message-formatter.d.ts +0 -32
  526. package/dist/utils/base-message-formatter.js +0 -170
  527. package/dist/utils/base-message-formatter.js.map +0 -1
  528. package/dist/utils/error-utils.d.ts +0 -3
  529. package/dist/utils/error-utils.js +0 -27
  530. package/dist/utils/error-utils.js.map +0 -1
  531. package/dist/utils/index.d.ts +0 -4
  532. package/dist/utils/index.js +0 -21
  533. package/dist/utils/index.js.map +0 -1
  534. package/dist/utils/math-utils.d.ts +0 -3
  535. package/dist/utils/math-utils.js +0 -10
  536. package/dist/utils/math-utils.js.map +0 -1
  537. package/dist/utils/mention-parser.d.ts +0 -18
  538. package/dist/utils/mention-parser.js +0 -136
  539. package/dist/utils/mention-parser.js.map +0 -1
  540. package/dist/utils/string-utils.d.ts +0 -1
  541. package/dist/utils/string-utils.js +0 -10
  542. package/dist/utils/string-utils.js.map +0 -1
  543. package/dist/utils.d.ts +0 -3
  544. package/dist/utils.js +0 -20
  545. package/dist/utils.js.map +0 -1
  546. package/schema/api-provider-config.json +0 -138
  547. package/schema/crewx-config.json +0 -224
  548. package/schema/skills-config.json +0 -306
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ /**
3
+ * LayoutRenderer — Handlebars-based layout rendering.
4
+ * Ported from packages/sdk-bak/src/services/layout-renderer.service.ts.
5
+ * Excluded: registerTemplateHelpers (exec/shell-quote).
6
+ * Exec is handled separately by TemplateEngine in the facade layer.
7
+ * WI-CONV-002: formatConversation helper restored.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.LayoutRenderer = exports.PropsValidationError = void 0;
14
+ const handlebars_1 = __importDefault(require("handlebars"));
15
+ const format_conversation_1 = require("../template/helpers/format-conversation");
16
+ const props_validator_1 = require("./props-validator");
17
+ const types_1 = require("./types");
18
+ var types_2 = require("./types");
19
+ Object.defineProperty(exports, "PropsValidationError", { enumerable: true, get: function () { return types_2.PropsValidationError; } });
20
+ /**
21
+ * LayoutRenderer — renders layout templates with Handlebars.
22
+ */
23
+ class LayoutRenderer {
24
+ handlebars;
25
+ propsValidator;
26
+ constructor(propsValidator) {
27
+ this.handlebars = handlebars_1.default.create();
28
+ this.propsValidator = propsValidator ?? new props_validator_1.PropsValidator();
29
+ this.registerHelpers();
30
+ }
31
+ /**
32
+ * Render a layout template with the given context.
33
+ */
34
+ render(layout, context, options = {}) {
35
+ try {
36
+ const preparedContext = this.prepareRenderContext(layout, context, options);
37
+ const template = this.handlebars.compile(layout.template, { noEscape: true });
38
+ return template(preparedContext);
39
+ }
40
+ catch (error) {
41
+ if (error instanceof Error) {
42
+ throw new Error(`Template rendering failed for layout '${layout.id}': ${error.message}`);
43
+ }
44
+ throw new Error(`Unknown error rendering layout '${layout.id}'`);
45
+ }
46
+ }
47
+ /**
48
+ * Validate props against schema.
49
+ */
50
+ validate(props, propsSchema, mode = 'lenient') {
51
+ return this.executeValidation(props, propsSchema, mode);
52
+ }
53
+ /**
54
+ * Merge default props and runtime props, then validate.
55
+ */
56
+ resolveProps(layout, props, mode = 'lenient') {
57
+ const mergedProps = this.mergeProps(layout.defaultProps, props);
58
+ if (!layout.propsSchema || Object.keys(layout.propsSchema).length === 0) {
59
+ return { valid: true, props: mergedProps, errors: [] };
60
+ }
61
+ return this.executeValidation(mergedProps, layout.propsSchema, mode);
62
+ }
63
+ prepareRenderContext(layout, context, options) {
64
+ const { validationMode = 'lenient', skipValidation = false } = options;
65
+ const resolvedProps = skipValidation
66
+ ? this.mergeProps(layout.defaultProps, context.props)
67
+ : this.resolveProps(layout, context.props, validationMode).props;
68
+ return {
69
+ ...context,
70
+ vars: this.sanitizeVars(context.vars),
71
+ props: resolvedProps,
72
+ };
73
+ }
74
+ /**
75
+ * Register built-in Handlebars helpers (no exec).
76
+ * WI-CONV-002: formatConversation block helper registered for conversation history.
77
+ */
78
+ registerHelpers() {
79
+ // Conversation history block helper (WI-CONV-002)
80
+ this.handlebars.registerHelper('formatConversation', format_conversation_1.formatConversationHelper);
81
+ // Built-in block helpers
82
+ if (handlebars_1.default.helpers.each) {
83
+ this.handlebars.registerHelper('each', handlebars_1.default.helpers.each);
84
+ }
85
+ if (handlebars_1.default.helpers.if) {
86
+ this.handlebars.registerHelper('if', handlebars_1.default.helpers.if);
87
+ }
88
+ if (handlebars_1.default.helpers.unless) {
89
+ this.handlebars.registerHelper('unless', handlebars_1.default.helpers.unless);
90
+ }
91
+ if (handlebars_1.default.helpers.with) {
92
+ this.handlebars.registerHelper('with', handlebars_1.default.helpers.with);
93
+ }
94
+ this.handlebars.registerHelper('eq', function (a, b) {
95
+ return a === b;
96
+ });
97
+ this.handlebars.registerHelper('ne', function (a, b) {
98
+ return a !== b;
99
+ });
100
+ this.handlebars.registerHelper('gt', function (a, b) {
101
+ return a > b;
102
+ });
103
+ this.handlebars.registerHelper('lt', function (a, b) {
104
+ return a < b;
105
+ });
106
+ this.handlebars.registerHelper('json', function (obj) {
107
+ return new handlebars_1.default.SafeString(JSON.stringify(obj));
108
+ });
109
+ this.handlebars.registerHelper('raw', function (options) {
110
+ return typeof options?.fn === 'function' ? options.fn(this) : '';
111
+ });
112
+ this.handlebars.registerHelper('escapeHandlebars', function (text) {
113
+ if (typeof text !== 'string')
114
+ return '';
115
+ return text.replace(/\{\{/g, '&#123;&#123;').replace(/\}\}/g, '&#125;&#125;');
116
+ });
117
+ this.handlebars.registerHelper('formatFileSize', function (bytes) {
118
+ if (bytes === 0)
119
+ return '0 B';
120
+ const sizes = ['B', 'KB', 'MB', 'GB'];
121
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
122
+ return Math.round((bytes / Math.pow(1024, i)) * 100) / 100 + ' ' + sizes[i];
123
+ });
124
+ }
125
+ executeValidation(props, propsSchema, mode) {
126
+ try {
127
+ return this.propsValidator.validate(props, propsSchema, mode);
128
+ }
129
+ catch (error) {
130
+ if (error instanceof types_1.PropsValidationError && error.errors && error.errors.length > 0) {
131
+ const firstError = error.errors[0];
132
+ if (firstError) {
133
+ throw new types_1.PropsValidationError(firstError.message, error.errors);
134
+ }
135
+ }
136
+ throw error;
137
+ }
138
+ }
139
+ mergeProps(defaultProps, overrides) {
140
+ const base = this.cloneDeep(defaultProps ?? {});
141
+ if (!overrides)
142
+ return base;
143
+ return this.deepMerge(base, overrides);
144
+ }
145
+ deepMerge(target, source) {
146
+ for (const [key, value] of Object.entries(source)) {
147
+ if (this.isPlainObject(value)) {
148
+ const existing = target[key];
149
+ target[key] = this.deepMerge(this.isPlainObject(existing) ? existing : {}, value);
150
+ continue;
151
+ }
152
+ if (Array.isArray(value)) {
153
+ target[key] = this.cloneDeep(value);
154
+ continue;
155
+ }
156
+ target[key] = value;
157
+ }
158
+ return target;
159
+ }
160
+ cloneDeep(value) {
161
+ if (Array.isArray(value)) {
162
+ return value.map(item => this.cloneDeep(item));
163
+ }
164
+ if (this.isPlainObject(value)) {
165
+ const cloned = {};
166
+ for (const [key, nested] of Object.entries(value)) {
167
+ cloned[key] = this.cloneDeep(nested);
168
+ }
169
+ return cloned;
170
+ }
171
+ return value;
172
+ }
173
+ isPlainObject(value) {
174
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
175
+ }
176
+ sanitizeVars(vars) {
177
+ if (!vars)
178
+ return {};
179
+ const sanitizedVars = { ...vars };
180
+ if (typeof vars.user_input === 'string') {
181
+ sanitizedVars.user_input_raw = vars.user_input;
182
+ const escapedHandlebars = vars.user_input
183
+ .replace(/\{\{\{/g, '&#123;&#123;&#123;')
184
+ .replace(/\}\}\}/g, '&#125;&#125;&#125;')
185
+ .replace(/\{\{/g, '&#123;&#123;')
186
+ .replace(/\}\}/g, '&#125;&#125;');
187
+ sanitizedVars.user_input = this.handlebars.escapeExpression(escapedHandlebars);
188
+ }
189
+ return sanitizedVars;
190
+ }
191
+ }
192
+ exports.LayoutRenderer = LayoutRenderer;
193
+ //# sourceMappingURL=renderer.js.map
@@ -1,4 +1,18 @@
1
- import type { TemplateVars } from './template.types';
1
+ /**
2
+ * Layout system type definitions for CrewX SDK.
3
+ * Ported from packages/sdk-bak/src/types/layout.types.ts (1:1, import path only changed).
4
+ */
5
+ /**
6
+ * Template variables for layout rendering (security_key, custom extensions).
7
+ */
8
+ export interface TemplateVars {
9
+ /** Authentication token used to validate prompt containers */
10
+ security_key?: string;
11
+ [key: string]: unknown;
12
+ }
13
+ /**
14
+ * Prop schema definition (React PropTypes style).
15
+ */
2
16
  export interface PropSchema {
3
17
  type: 'string' | 'number' | 'bool' | 'array' | 'arrayOf' | 'object' | 'shape' | 'oneOfType' | 'func' | 'node';
4
18
  isRequired?: boolean;
@@ -15,6 +29,9 @@ export interface PropSchema {
15
29
  pattern?: string;
16
30
  description?: string;
17
31
  }
32
+ /**
33
+ * Layout definition loaded from YAML.
34
+ */
18
35
  export interface LayoutDefinition {
19
36
  id: string;
20
37
  version: string;
@@ -23,6 +40,9 @@ export interface LayoutDefinition {
23
40
  propsSchema: Record<string, PropSchema>;
24
41
  defaultProps: Record<string, any>;
25
42
  }
43
+ /**
44
+ * Custom layout configuration for runtime registration.
45
+ */
26
46
  export interface CustomLayoutDefinition {
27
47
  template: string;
28
48
  description?: string;
@@ -30,25 +50,40 @@ export interface CustomLayoutDefinition {
30
50
  propsSchema?: Record<string, any>;
31
51
  defaultProps?: Record<string, any>;
32
52
  }
53
+ /**
54
+ * Inline layout specification from agent config.
55
+ */
33
56
  export type InlineLayoutSpec = string | {
34
57
  id: string;
35
58
  props?: Record<string, any>;
36
59
  };
60
+ /**
61
+ * Validation result from PropsValidator.
62
+ */
37
63
  export interface ValidationResult {
38
64
  valid: boolean;
39
65
  props: Record<string, any>;
40
66
  errors: ValidationError[];
41
67
  }
68
+ /**
69
+ * Validation error details.
70
+ */
42
71
  export interface ValidationError {
43
72
  path: string;
44
73
  message: string;
45
74
  value?: any;
46
75
  }
76
+ /**
77
+ * Layout loader options.
78
+ */
47
79
  export interface LoaderOptions {
48
80
  templatesPath: string;
49
81
  validationMode?: 'strict' | 'lenient';
50
82
  fallbackLayoutId?: string;
51
83
  }
84
+ /**
85
+ * Render context for layout-specific template rendering.
86
+ */
52
87
  export interface RenderContext {
53
88
  user_input?: string;
54
89
  messages?: Array<{
@@ -94,7 +129,11 @@ export interface RenderContext {
94
129
  [key: string]: any;
95
130
  };
96
131
  context?: Record<string, any>;
132
+ [key: string]: unknown;
97
133
  }
134
+ /**
135
+ * Raw layout YAML structure.
136
+ */
98
137
  export interface RawLayoutYaml {
99
138
  id?: string;
100
139
  version?: string;
@@ -103,13 +142,20 @@ export interface RawLayoutYaml {
103
142
  template?: string;
104
143
  layouts?: Record<string, string>;
105
144
  }
145
+ /**
146
+ * Error thrown when layout loading fails.
147
+ */
106
148
  export declare class LayoutLoadError extends Error {
107
149
  readonly layoutId?: string | undefined;
108
150
  readonly cause?: Error | undefined;
109
151
  constructor(message: string, layoutId?: string | undefined, cause?: Error | undefined);
110
152
  }
153
+ /**
154
+ * Error thrown when props validation fails (strict mode).
155
+ */
111
156
  export declare class PropsValidationError extends Error {
112
157
  readonly errors: ValidationError[];
113
158
  readonly cause?: Error | undefined;
114
159
  constructor(message: string, errors?: ValidationError[], cause?: Error | undefined);
115
160
  }
161
+ //# sourceMappingURL=types.d.ts.map
@@ -1,7 +1,16 @@
1
1
  "use strict";
2
+ /**
3
+ * Layout system type definitions for CrewX SDK.
4
+ * Ported from packages/sdk-bak/src/types/layout.types.ts (1:1, import path only changed).
5
+ */
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  exports.PropsValidationError = exports.LayoutLoadError = void 0;
8
+ /**
9
+ * Error thrown when layout loading fails.
10
+ */
4
11
  class LayoutLoadError extends Error {
12
+ layoutId;
13
+ cause;
5
14
  constructor(message, layoutId, cause) {
6
15
  super(message);
7
16
  this.layoutId = layoutId;
@@ -10,7 +19,12 @@ class LayoutLoadError extends Error {
10
19
  }
11
20
  }
12
21
  exports.LayoutLoadError = LayoutLoadError;
22
+ /**
23
+ * Error thrown when props validation fails (strict mode).
24
+ */
13
25
  class PropsValidationError extends Error {
26
+ errors;
27
+ cause;
14
28
  constructor(message, errors = [], cause) {
15
29
  super(message);
16
30
  this.errors = errors;
@@ -19,4 +33,4 @@ class PropsValidationError extends Error {
19
33
  }
20
34
  }
21
35
  exports.PropsValidationError = PropsValidationError;
22
- //# sourceMappingURL=layout.types.js.map
36
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Minimal AgentRuntime for the parallel execution module.
3
+ * Provides query/execute methods to run agent operations.
4
+ * Tests use vi.spyOn(AgentRuntime.prototype, 'query') to mock these methods.
5
+ */
6
+ export interface AgentQueryRequest {
7
+ agentId?: string;
8
+ prompt: string;
9
+ context?: string;
10
+ }
11
+ export interface AgentExecuteRequest {
12
+ agentId?: string;
13
+ prompt: string;
14
+ context?: string;
15
+ }
16
+ export interface AgentResult {
17
+ content: string;
18
+ success: boolean;
19
+ agentId?: string;
20
+ metadata?: Record<string, unknown>;
21
+ }
22
+ /**
23
+ * Runtime that executes agent query/execute operations.
24
+ * Default implementation throws — callers must inject a working provider
25
+ * or mock the prototype methods in tests.
26
+ */
27
+ export declare class AgentRuntime {
28
+ query(_request: AgentQueryRequest): Promise<AgentResult>;
29
+ execute(_request: AgentExecuteRequest): Promise<AgentResult>;
30
+ }
31
+ //# sourceMappingURL=agent-runtime.d.ts.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * Minimal AgentRuntime for the parallel execution module.
4
+ * Provides query/execute methods to run agent operations.
5
+ * Tests use vi.spyOn(AgentRuntime.prototype, 'query') to mock these methods.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.AgentRuntime = void 0;
9
+ /**
10
+ * Runtime that executes agent query/execute operations.
11
+ * Default implementation throws — callers must inject a working provider
12
+ * or mock the prototype methods in tests.
13
+ */
14
+ class AgentRuntime {
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
+ async query(_request) {
17
+ throw new Error('AgentRuntime.query is not implemented. Provide a subclass or mock AgentRuntime.prototype.query.');
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ async execute(_request) {
21
+ throw new Error('AgentRuntime.execute is not implemented. Provide a subclass or mock AgentRuntime.prototype.execute.');
22
+ }
23
+ }
24
+ exports.AgentRuntime = AgentRuntime;
25
+ //# sourceMappingURL=agent-runtime.js.map
@@ -1,5 +1,5 @@
1
1
  import type { ParallelRunnerMetrics } from './types';
2
- import { type AgentQueryRequest, type AgentExecuteRequest, type AgentResult } from '../agent';
2
+ import type { AgentQueryRequest, AgentExecuteRequest, AgentResult } from './agent-runtime';
3
3
  export interface RetryPolicy {
4
4
  maxRetries: number;
5
5
  retryDelay: number;
@@ -25,3 +25,4 @@ export interface HelperResult<T = AgentResult> {
25
25
  }
26
26
  export declare const runQueriesParallel: (queries: AgentQueryRequest[], config?: ParallelConfig) => Promise<AgentResult[]>;
27
27
  export declare const runExecutesParallel: (requests: AgentExecuteRequest[], config?: ParallelConfig) => Promise<AgentResult[]>;
28
+ //# sourceMappingURL=helpers.d.ts.map
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runExecutesParallel = exports.runQueriesParallel = void 0;
4
4
  const parallel_runner_1 = require("./parallel-runner");
5
- const agent_1 = require("../agent");
5
+ const agent_runtime_1 = require("./agent-runtime");
6
6
  const DEFAULT_CONCURRENCY = 3;
7
- const DEFAULT_TIMEOUT_MS = 30000;
7
+ const DEFAULT_TIMEOUT_MS = 30_000;
8
8
  const DEFAULT_RETRY_DELAY_MS = 500;
9
9
  const normalizeConcurrency = (value) => {
10
10
  if (typeof value !== 'number' || Number.isNaN(value) || !Number.isFinite(value)) {
@@ -14,18 +14,15 @@ const normalizeConcurrency = (value) => {
14
14
  return normalized > 0 ? normalized : DEFAULT_CONCURRENCY;
15
15
  };
16
16
  const normalizeTimeout = (value) => {
17
- if (value === undefined) {
17
+ if (value === undefined)
18
18
  return DEFAULT_TIMEOUT_MS;
19
- }
20
- if (typeof value !== 'number' || Number.isNaN(value) || value <= 0) {
19
+ if (typeof value !== 'number' || Number.isNaN(value) || value <= 0)
21
20
  return DEFAULT_TIMEOUT_MS;
22
- }
23
21
  return value;
24
22
  };
25
23
  const normalizeRetryPolicy = (policy) => {
26
- if (!policy) {
24
+ if (!policy)
27
25
  return { maxRetries: 0, retryDelay: DEFAULT_RETRY_DELAY_MS };
28
- }
29
26
  const maxRetries = Number.isInteger(policy.maxRetries) && policy.maxRetries >= 0
30
27
  ? policy.maxRetries
31
28
  : 0;
@@ -36,18 +33,15 @@ const normalizeRetryPolicy = (policy) => {
36
33
  };
37
34
  const createAbortError = (signal) => {
38
35
  const reason = signal.reason;
39
- if (reason instanceof Error) {
36
+ if (reason instanceof Error)
40
37
  return reason;
41
- }
42
- if (typeof reason === 'string') {
38
+ if (typeof reason === 'string')
43
39
  return new Error(reason);
44
- }
45
40
  return new Error('Parallel operation aborted');
46
41
  };
47
42
  const waitForDelay = (delayMs, signal) => {
48
- if (delayMs <= 0) {
43
+ if (delayMs <= 0)
49
44
  return Promise.resolve();
50
- }
51
45
  return new Promise((resolve, reject) => {
52
46
  const timer = setTimeout(() => {
53
47
  signal.removeEventListener('abort', onAbort);
@@ -67,72 +61,64 @@ const waitForDelay = (delayMs, signal) => {
67
61
  const executeWithRetry = async (execute, retryPolicy, signal) => {
68
62
  let lastFailureResult;
69
63
  let lastError;
70
- for (let attempt = 0; attempt <= retryPolicy.maxRetries; attempt += 1) {
71
- if (signal.aborted) {
64
+ for (let attempt = 0; attempt <= retryPolicy.maxRetries; attempt++) {
65
+ if (signal.aborted)
72
66
  throw createAbortError(signal);
73
- }
74
67
  try {
75
68
  const result = await execute();
76
69
  lastFailureResult = result;
77
- if (result.success || attempt === retryPolicy.maxRetries) {
70
+ if (result.success || attempt === retryPolicy.maxRetries)
78
71
  return result;
79
- }
80
72
  }
81
73
  catch (error) {
82
74
  lastError = error;
83
- if (signal.aborted) {
75
+ if (signal.aborted)
84
76
  throw createAbortError(signal);
85
- }
86
77
  if (attempt === retryPolicy.maxRetries) {
87
- const normalizedError = error instanceof Error ? error : new Error(String(error));
88
- throw normalizedError;
78
+ throw error instanceof Error ? error : new Error(String(error));
89
79
  }
90
80
  }
91
81
  if (attempt < retryPolicy.maxRetries) {
92
82
  await waitForDelay(retryPolicy.retryDelay, signal);
93
83
  }
94
84
  }
95
- if (lastFailureResult) {
85
+ if (lastFailureResult)
96
86
  return lastFailureResult;
97
- }
98
- if (lastError) {
87
+ if (lastError)
99
88
  throw lastError instanceof Error ? lastError : new Error(String(lastError));
100
- }
101
89
  throw new Error('Parallel helper encountered an unexpected state');
102
90
  };
103
- const recordProgress = (callbacks, state, wasSuccessful) => {
91
+ const recordProgress = (config, state, wasSuccessful) => {
104
92
  state.completed += 1;
105
- if (wasSuccessful) {
93
+ if (wasSuccessful)
106
94
  state.success += 1;
107
- }
108
- else {
95
+ else
109
96
  state.failure += 1;
110
- }
111
97
  try {
112
- callbacks.onProgress?.(state.completed, state.total);
98
+ config.onProgress?.(state.completed, state.total);
113
99
  }
114
100
  catch (error) {
115
- if (process.env.NODE_ENV !== 'production') {
101
+ if (process.env['NODE_ENV'] !== 'production') {
116
102
  console.warn('Parallel helper onProgress callback threw an error:', error);
117
103
  }
118
104
  }
119
105
  };
120
- const mapResults = (taskResults) => {
121
- return taskResults.map((taskResult) => ({
106
+ const buildAgentResults = (taskResults) => {
107
+ const decorated = taskResults.map((taskResult) => ({
122
108
  metadata: taskResult.metadata,
123
109
  taskResult,
124
110
  }));
125
- };
126
- const buildAgentResults = (decoratedResults) => {
127
- const ordered = decoratedResults.slice().sort((a, b) => a.metadata.index - b.metadata.index);
128
- return ordered.map(({ metadata, taskResult }) => {
111
+ return decorated
112
+ .slice()
113
+ .sort((a, b) => a.metadata.index - b.metadata.index)
114
+ .map(({ metadata, taskResult }) => {
129
115
  if (taskResult.value) {
130
- const baseResult = taskResult.value;
116
+ const base = taskResult.value;
131
117
  return {
132
- ...baseResult,
133
- agentId: baseResult.agentId ?? metadata.request.agentId,
118
+ ...base,
119
+ agentId: base.agentId ?? metadata.request.agentId,
134
120
  metadata: {
135
- ...baseResult.metadata,
121
+ ...base.metadata,
136
122
  requestIndex: metadata.index,
137
123
  mode: metadata.mode,
138
124
  },
@@ -152,20 +138,19 @@ const buildAgentResults = (decoratedResults) => {
152
138
  };
153
139
  });
154
140
  };
155
- const collectErrors = (decoratedResults) => {
156
- return decoratedResults
157
- .filter(({ taskResult }) => !taskResult.success)
158
- .map(({ metadata, taskResult }) => {
141
+ const collectErrors = (taskResults) => {
142
+ return taskResults
143
+ .filter((r) => !r.success)
144
+ .map((taskResult) => {
145
+ const meta = taskResult.metadata;
159
146
  if (taskResult.error instanceof Error) {
160
- return { index: metadata.index, error: taskResult.error };
147
+ return { index: meta.index, error: taskResult.error };
161
148
  }
162
149
  if (taskResult.value && !taskResult.value.success) {
163
- const errorMessage = taskResult.value.metadata?.error
164
- ?? taskResult.value.content
165
- ?? 'Agent returned unsuccessful result';
166
- return { index: metadata.index, error: new Error(errorMessage) };
150
+ const msg = String(taskResult.value.metadata?.['error'] ?? taskResult.value.content ?? 'Agent returned unsuccessful result');
151
+ return { index: meta.index, error: new Error(msg) };
167
152
  }
168
- return { index: metadata.index, error: new Error('Unknown failure') };
153
+ return { index: meta.index, error: new Error('Unknown failure') };
169
154
  });
170
155
  };
171
156
  const createCallbacks = (progressState, config) => ({
@@ -182,23 +167,13 @@ const runAgentOperations = async (requests, mode, config = {}) => {
182
167
  }
183
168
  if (requests.length === 0) {
184
169
  const emptyMetrics = {
185
- totalTasks: 0,
186
- startedTasks: 0,
187
- completedTasks: 0,
188
- successCount: 0,
189
- failureCount: 0,
190
- totalDurationMs: 0,
191
- averageDurationMs: 0,
192
- throughput: 0,
170
+ totalTasks: 0, startedTasks: 0, completedTasks: 0,
171
+ successCount: 0, failureCount: 0, totalDurationMs: 0,
172
+ averageDurationMs: 0, throughput: 0,
193
173
  };
194
174
  const summary = {
195
- total: 0,
196
- completed: 0,
197
- successCount: 0,
198
- failureCount: 0,
199
- results: [],
200
- errors: [],
201
- metrics: emptyMetrics,
175
+ total: 0, completed: 0, successCount: 0, failureCount: 0,
176
+ results: [], errors: [], metrics: emptyMetrics,
202
177
  };
203
178
  config.onComplete?.(summary);
204
179
  return [];
@@ -207,37 +182,29 @@ const runAgentOperations = async (requests, mode, config = {}) => {
207
182
  const timeout = normalizeTimeout(config.timeout);
208
183
  const retryPolicy = normalizeRetryPolicy(config.retryPolicy);
209
184
  const runner = new parallel_runner_1.ParallelRunner();
210
- const runtime = new agent_1.AgentRuntime();
211
- const runSingleOperation = (request) => (mode === 'query'
212
- ? runtime.query(request)
213
- : runtime.execute(request));
185
+ const runtime = new agent_runtime_1.AgentRuntime();
214
186
  const tasks = requests.map((request, index) => ({
215
187
  id: `${mode}:${request.agentId ?? 'anonymous'}:${index}`,
216
188
  metadata: { index, mode, request },
217
- run: (context) => executeWithRetry(() => runSingleOperation(request), retryPolicy, context.signal),
189
+ run: (context) => executeWithRetry(() => mode === 'query'
190
+ ? runtime.query(request)
191
+ : runtime.execute(request), retryPolicy, context.signal),
218
192
  }));
219
- const progressState = {
220
- completed: 0,
221
- success: 0,
222
- failure: 0,
223
- total: requests.length,
224
- };
225
- const runnerOptions = {
193
+ const progressState = { completed: 0, success: 0, failure: 0, total: requests.length };
194
+ const taskResults = await runner.run(tasks, {
226
195
  maxConcurrency: concurrency,
227
196
  timeoutMs: timeout,
228
197
  evaluateTaskSuccess: (value) => value.success,
229
198
  callbacks: createCallbacks(progressState, config),
230
- };
231
- const taskResults = await runner.run(tasks, runnerOptions);
232
- const decoratedResults = mapResults(taskResults);
233
- const agentResults = buildAgentResults(decoratedResults);
234
- const errors = collectErrors(decoratedResults);
199
+ });
200
+ const agentResults = buildAgentResults(taskResults);
201
+ const errors = collectErrors(taskResults);
235
202
  const metrics = runner.getMetrics();
236
203
  const summary = {
237
204
  total: requests.length,
238
205
  completed: requests.length,
239
- successCount: agentResults.filter((item) => item.success).length,
240
- failureCount: agentResults.filter((item) => !item.success).length,
206
+ successCount: agentResults.filter((r) => r.success).length,
207
+ failureCount: agentResults.filter((r) => !r.success).length,
241
208
  results: agentResults,
242
209
  errors,
243
210
  metrics,
@@ -0,0 +1,8 @@
1
+ export { ParallelRunner } from './parallel-runner';
2
+ export { ParallelRunnerTimeoutError } from './parallel-runner';
3
+ export type { Task, TaskResult, TaskExecutionContext, TaskCallbacks, ParallelRunnerOptions, ParallelRunnerMetrics, } from './types';
4
+ export { runQueriesParallel, runExecutesParallel } from './helpers';
5
+ export type { ParallelConfig, HelperResult, RetryPolicy } from './helpers';
6
+ export { AgentRuntime } from './agent-runtime';
7
+ export type { AgentResult, AgentQueryRequest, AgentExecuteRequest } from './agent-runtime';
8
+ //# sourceMappingURL=index.d.ts.map