@crewx/sdk 0.8.0-rc.73 → 0.8.0-rc.75

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 +68 -103
  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
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Boxing domain types — Box/Thread/Context types for SDK boxing module.
3
+ */
1
4
  export interface BoxRow {
2
5
  id: string;
3
6
  thread_id: string;
@@ -84,3 +87,4 @@ export interface CreateBoxParams {
84
87
  sourceTokens: number;
85
88
  summaryTokens?: number | null;
86
89
  }
90
+ //# sourceMappingURL=box.types.d.ts.map
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
+ /**
3
+ * Boxing domain types — Box/Thread/Context types for SDK boxing module.
4
+ */
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  //# sourceMappingURL=box.types.js.map
@@ -1,8 +1,7 @@
1
- import type { ITaskReader, ITokenizer } from './box-storage.interface';
2
- import type { BoxResponse, ContextBuildParams, ContextBuildResponse } from './box.types';
3
- export interface IBoxServiceReader {
4
- listBoxes(threadId: string): {
5
- boxes: BoxResponse[];
6
- };
7
- }
1
+ /**
2
+ * buildContext() builds hot/warm context windows from thread messages and box summaries.
3
+ */
4
+ import type { IBoxServiceReader, ITaskReader, ITokenizer } from './box-storage.interface';
5
+ import type { ContextBuildParams, ContextBuildResponse } from './box.types';
8
6
  export declare function buildContext(threadId: string, taskReader: ITaskReader, boxService: IBoxServiceReader, params: ContextBuildParams, tokenizer: ITokenizer): ContextBuildResponse;
7
+ //# sourceMappingURL=context-builder.d.ts.map
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ /**
3
+ * buildContext() — builds hot/warm context windows from thread messages and box summaries.
4
+ */
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.buildContext = buildContext;
4
7
  function buildContext(threadId, taskReader, boxService, params, tokenizer) {
@@ -0,0 +1,65 @@
1
+ /**
2
+ * CrewxClient — Browser client for CrewX SDK.
3
+ *
4
+ * Communicates with a server running CrewX SDK via HTTP.
5
+ * Handles the Client-Intercept pattern automatically:
6
+ * registerTool() + query() — that's it.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { CrewxClient } from '@crewx/sdk/client';
11
+ *
12
+ * const crewx = new CrewxClient('http://localhost:3000');
13
+ * crewx.registerTool('browser_storage_read', {
14
+ * execute: async ({ key }) => localStorage.getItem(key),
15
+ * });
16
+ *
17
+ * const result = await crewx.query('assistant', 'read my settings');
18
+ * console.log(result.data);
19
+ * ```
20
+ */
21
+ export interface ClientToolDefinition {
22
+ description?: string;
23
+ parameters?: Record<string, unknown>;
24
+ execute: (args: Record<string, unknown>) => Promise<unknown>;
25
+ }
26
+ export interface QueryCallbacks {
27
+ /** Called when the agent invokes a client tool. */
28
+ onToolCall?: (call: {
29
+ toolCallId: string;
30
+ toolName: string;
31
+ args: Record<string, unknown>;
32
+ }) => void;
33
+ }
34
+ export interface QueryResponse {
35
+ status: string;
36
+ data?: string;
37
+ toolCall?: {
38
+ toolCallId: string;
39
+ toolName: string;
40
+ args: Record<string, unknown>;
41
+ };
42
+ threadId?: string;
43
+ error?: {
44
+ message: string;
45
+ };
46
+ }
47
+ export declare class CrewxClient {
48
+ private readonly baseUrl;
49
+ private readonly tools;
50
+ constructor(baseUrl: string);
51
+ /**
52
+ * Register a browser-side tool.
53
+ * When the server agent calls a tool with this name (and no server-side execute),
54
+ * CrewxClient automatically runs it locally and sends the result back.
55
+ */
56
+ registerTool(name: string, definition: ClientToolDefinition): void;
57
+ /**
58
+ * Send a message to an agent.
59
+ * The requires_action loop is handled automatically — if the agent calls a
60
+ * client tool, CrewxClient executes it locally and continues the conversation.
61
+ */
62
+ query(agent: string, message: string, callbacks?: QueryCallbacks): Promise<QueryResponse>;
63
+ private _post;
64
+ }
65
+ //# sourceMappingURL=CrewxClient.d.ts.map
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * CrewxClient — Browser client for CrewX SDK.
4
+ *
5
+ * Communicates with a server running CrewX SDK via HTTP.
6
+ * Handles the Client-Intercept pattern automatically:
7
+ * registerTool() + query() — that's it.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { CrewxClient } from '@crewx/sdk/client';
12
+ *
13
+ * const crewx = new CrewxClient('http://localhost:3000');
14
+ * crewx.registerTool('browser_storage_read', {
15
+ * execute: async ({ key }) => localStorage.getItem(key),
16
+ * });
17
+ *
18
+ * const result = await crewx.query('assistant', 'read my settings');
19
+ * console.log(result.data);
20
+ * ```
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.CrewxClient = void 0;
24
+ class CrewxClient {
25
+ baseUrl;
26
+ tools = new Map();
27
+ constructor(baseUrl) {
28
+ this.baseUrl = baseUrl.replace(/\/$/, '');
29
+ }
30
+ /**
31
+ * Register a browser-side tool.
32
+ * When the server agent calls a tool with this name (and no server-side execute),
33
+ * CrewxClient automatically runs it locally and sends the result back.
34
+ */
35
+ registerTool(name, definition) {
36
+ this.tools.set(name, definition);
37
+ }
38
+ /**
39
+ * Send a message to an agent.
40
+ * The requires_action loop is handled automatically — if the agent calls a
41
+ * client tool, CrewxClient executes it locally and continues the conversation.
42
+ */
43
+ async query(agent, message, callbacks) {
44
+ let response = await this._post('/api/chat', { agent, message });
45
+ while (response.status === 'requires_action') {
46
+ const { toolCall, threadId } = response;
47
+ if (!toolCall)
48
+ break;
49
+ const tool = this.tools.get(toolCall.toolName);
50
+ if (callbacks?.onToolCall) {
51
+ callbacks.onToolCall(toolCall);
52
+ }
53
+ let toolResult;
54
+ if (tool?.execute) {
55
+ try {
56
+ const raw = await tool.execute(toolCall.args);
57
+ toolResult = typeof raw === 'string' ? raw : JSON.stringify(raw);
58
+ }
59
+ catch (err) {
60
+ toolResult = `Error: ${err.message}`;
61
+ }
62
+ }
63
+ else {
64
+ toolResult = `Error: No client handler for tool "${toolCall.toolName}"`;
65
+ }
66
+ response = await this._post('/api/chat/continue', {
67
+ threadId,
68
+ toolCallId: toolCall.toolCallId,
69
+ result: toolResult,
70
+ });
71
+ }
72
+ return response;
73
+ }
74
+ async _post(path, body) {
75
+ const res = await fetch(`${this.baseUrl}${path}`, {
76
+ method: 'POST',
77
+ headers: { 'Content-Type': 'application/json' },
78
+ body: JSON.stringify(body),
79
+ });
80
+ if (!res.ok)
81
+ throw new Error(`HTTP ${res.status}`);
82
+ return res.json();
83
+ }
84
+ }
85
+ exports.CrewxClient = CrewxClient;
86
+ //# sourceMappingURL=CrewxClient.js.map
@@ -0,0 +1,3 @@
1
+ export { CrewxClient } from './CrewxClient.js';
2
+ export type { ClientToolDefinition, QueryCallbacks, QueryResponse } from './CrewxClient.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CrewxClient = void 0;
4
+ var CrewxClient_js_1 = require("./CrewxClient.js");
5
+ Object.defineProperty(exports, "CrewxClient", { enumerable: true, get: function () { return CrewxClient_js_1.CrewxClient; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Browser-safe YAML config loader.
3
+ * Only parseYamlContent — no file I/O.
4
+ */
5
+ import type { CrewxProjectConfig } from '../types/index.js';
6
+ export declare class ConfigLoadError extends Error {
7
+ readonly cause?: unknown | undefined;
8
+ constructor(message: string, cause?: unknown | undefined);
9
+ }
10
+ /**
11
+ * Parse YAML string into a validated CrewxProjectConfig.
12
+ */
13
+ export declare function parseYamlContent(yamlString: string): CrewxProjectConfig;
14
+ //# sourceMappingURL=loader.browser.d.ts.map
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * Browser-safe YAML config loader.
4
+ * Only parseYamlContent — no file I/O.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ConfigLoadError = void 0;
8
+ exports.parseYamlContent = parseYamlContent;
9
+ const js_yaml_1 = require("js-yaml");
10
+ const index_js_1 = require("../types/index.js");
11
+ class ConfigLoadError extends Error {
12
+ cause;
13
+ constructor(message, cause) {
14
+ super(message);
15
+ this.cause = cause;
16
+ this.name = 'ConfigLoadError';
17
+ }
18
+ }
19
+ exports.ConfigLoadError = ConfigLoadError;
20
+ /**
21
+ * Parse YAML string into a validated CrewxProjectConfig.
22
+ */
23
+ function parseYamlContent(yamlString) {
24
+ if (!yamlString || typeof yamlString !== 'string' || !yamlString.trim()) {
25
+ throw new ConfigLoadError('YAML content must be a non-empty string');
26
+ }
27
+ let raw;
28
+ try {
29
+ raw = (0, js_yaml_1.load)(yamlString);
30
+ }
31
+ catch (err) {
32
+ throw new ConfigLoadError(`YAML parse error: ${err.message}`, err);
33
+ }
34
+ const normalized = normalizeRaw(raw);
35
+ const result = index_js_1.CrewxProjectConfigSchema.safeParse(normalized);
36
+ if (!result.success) {
37
+ throw new ConfigLoadError(`Config validation error: ${result.error.message}`);
38
+ }
39
+ return result.data;
40
+ }
41
+ function normalizeRaw(raw) {
42
+ if (!raw || typeof raw !== 'object') {
43
+ return { agents: [] };
44
+ }
45
+ const obj = raw;
46
+ if (obj.agents && typeof obj.agents === 'object' && !Array.isArray(obj.agents)) {
47
+ const agentsMap = obj.agents;
48
+ const agentsArray = Object.entries(agentsMap).map(([id, cfg]) => {
49
+ const agentCfg = (cfg && typeof cfg === 'object' ? cfg : {});
50
+ return { id, ...agentCfg };
51
+ });
52
+ return { ...obj, agents: agentsArray };
53
+ }
54
+ if (!obj.agents) {
55
+ return { ...obj, agents: [] };
56
+ }
57
+ return obj;
58
+ }
59
+ //# sourceMappingURL=loader.browser.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * YAML configuration loader for CrewX projects.
3
+ * Reads crewx.yaml and validates it with Zod schema.
4
+ */
5
+ import type { CrewxProjectConfig } from '../types';
6
+ export declare class ConfigLoadError extends Error {
7
+ readonly cause?: unknown | undefined;
8
+ constructor(message: string, cause?: unknown | undefined);
9
+ }
10
+ /**
11
+ * Parse YAML string into a validated CrewxProjectConfig.
12
+ * Converts the agents record (keyed by id) into an array.
13
+ */
14
+ export declare function parseYamlContent(yamlString: string): CrewxProjectConfig;
15
+ /**
16
+ * Load and parse crewx.yaml from a file path.
17
+ */
18
+ export declare function loadYamlFile(filePath: string): CrewxProjectConfig;
19
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ /**
3
+ * YAML configuration loader for CrewX projects.
4
+ * Reads crewx.yaml and validates it with Zod schema.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ConfigLoadError = void 0;
8
+ exports.parseYamlContent = parseYamlContent;
9
+ exports.loadYamlFile = loadYamlFile;
10
+ const js_yaml_1 = require("js-yaml");
11
+ const fs_1 = require("fs");
12
+ const types_1 = require("../types");
13
+ class ConfigLoadError extends Error {
14
+ cause;
15
+ constructor(message, cause) {
16
+ super(message);
17
+ this.cause = cause;
18
+ this.name = 'ConfigLoadError';
19
+ }
20
+ }
21
+ exports.ConfigLoadError = ConfigLoadError;
22
+ /**
23
+ * Parse YAML string into a validated CrewxProjectConfig.
24
+ * Converts the agents record (keyed by id) into an array.
25
+ */
26
+ function parseYamlContent(yamlString) {
27
+ if (!yamlString || typeof yamlString !== 'string' || !yamlString.trim()) {
28
+ throw new ConfigLoadError('YAML content must be a non-empty string');
29
+ }
30
+ let raw;
31
+ try {
32
+ raw = (0, js_yaml_1.load)(yamlString);
33
+ }
34
+ catch (err) {
35
+ throw new ConfigLoadError(`YAML parse error: ${err.message}`, err);
36
+ }
37
+ // Normalize agents: YAML has agents as a map (Record<id, config>),
38
+ // but our type uses an array with 'id' field.
39
+ const normalized = normalizeRaw(raw);
40
+ const result = types_1.CrewxProjectConfigSchema.safeParse(normalized);
41
+ if (!result.success) {
42
+ throw new ConfigLoadError(`Config validation error: ${result.error.message}`);
43
+ }
44
+ return result.data;
45
+ }
46
+ /**
47
+ * Load and parse crewx.yaml from a file path.
48
+ */
49
+ function loadYamlFile(filePath) {
50
+ let content;
51
+ try {
52
+ content = (0, fs_1.readFileSync)(filePath, 'utf-8');
53
+ }
54
+ catch (err) {
55
+ throw new ConfigLoadError(`Cannot read file: ${filePath}`, err);
56
+ }
57
+ return parseYamlContent(content);
58
+ }
59
+ /**
60
+ * Normalize raw YAML output:
61
+ * - agents map (Record<id, agentConfig>) → agents array ([{ id, ...agentConfig }])
62
+ */
63
+ function normalizeRaw(raw) {
64
+ if (!raw || typeof raw !== 'object') {
65
+ return { agents: [] };
66
+ }
67
+ const obj = raw;
68
+ // Gather agents as array (support map form and array form)
69
+ let agentsArray;
70
+ if (obj.agents && typeof obj.agents === 'object' && !Array.isArray(obj.agents)) {
71
+ const agentsMap = obj.agents;
72
+ agentsArray = Object.entries(agentsMap).map(([id, cfg]) => {
73
+ const agentCfg = (cfg && typeof cfg === 'object' ? cfg : {});
74
+ return { id, ...agentCfg };
75
+ });
76
+ }
77
+ else if (Array.isArray(obj.agents)) {
78
+ agentsArray = obj.agents;
79
+ }
80
+ else {
81
+ return { ...obj, agents: [] };
82
+ }
83
+ // Normalize inline.provider → top-level provider (fallback for cross-repo yaml compat)
84
+ const normalizedAgents = agentsArray.map(agent => {
85
+ if (agent.provider === undefined && agent.inline && typeof agent.inline === 'object') {
86
+ const inline = agent.inline;
87
+ if (inline.provider !== undefined) {
88
+ return { ...agent, provider: inline.provider };
89
+ }
90
+ }
91
+ return agent;
92
+ });
93
+ return { ...obj, agents: normalizedAgents };
94
+ }
95
+ //# sourceMappingURL=loader.js.map
@@ -1,3 +1,5 @@
1
- export * from './conversation-history.interface';
2
- export * from './conversation-config';
3
- export * from './conversation-storage.service';
1
+ export * from './types.js';
2
+ export { SqliteConversationProvider } from './sqlite-provider.js';
3
+ export { toTaskReader } from './to-task-reader.js';
4
+ export { toTemplateMessages } from './to-template-messages.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -14,7 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./conversation-history.interface"), exports);
18
- __exportStar(require("./conversation-config"), exports);
19
- __exportStar(require("./conversation-storage.service"), exports);
17
+ exports.toTemplateMessages = exports.toTaskReader = exports.SqliteConversationProvider = void 0;
18
+ __exportStar(require("./types.js"), exports);
19
+ var sqlite_provider_js_1 = require("./sqlite-provider.js");
20
+ Object.defineProperty(exports, "SqliteConversationProvider", { enumerable: true, get: function () { return sqlite_provider_js_1.SqliteConversationProvider; } });
21
+ var to_task_reader_js_1 = require("./to-task-reader.js");
22
+ Object.defineProperty(exports, "toTaskReader", { enumerable: true, get: function () { return to_task_reader_js_1.toTaskReader; } });
23
+ var to_template_messages_js_1 = require("./to-template-messages.js");
24
+ Object.defineProperty(exports, "toTemplateMessages", { enumerable: true, get: function () { return to_template_messages_js_1.toTemplateMessages; } });
20
25
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * SqliteConversationProvider — reads/writes conversation history from ~/.crewx/crewx.db.
3
+ *
4
+ * Security:
5
+ * - SEC-1: SELECT columns are explicitly whitelisted (no rendered_prompt, command, logs, metadata).
6
+ * - SEC-2: All queries use parameterized bindings (? placeholders).
7
+ * - Writes target `threads` table ONLY — `tasks` table writes are owned by SqliteTracingPlugin.
8
+ */
9
+ import type { ConversationThread, FetchHistoryOptions, IConversationHistoryProvider, Platform } from './types';
10
+ export declare class SqliteConversationProvider implements IConversationHistoryProvider {
11
+ private db;
12
+ constructor(dbPath?: string);
13
+ private init;
14
+ ensureThread(threadId: string, platform: Platform, workspaceId?: string): Promise<void>;
15
+ fetchHistory(threadId: string, options?: FetchHistoryOptions): Promise<ConversationThread>;
16
+ saveUserMessage(threadId: string, text: string, _userId?: string, _metadata?: Record<string, unknown>): Promise<void>;
17
+ saveAssistantMessage(threadId: string, text: string, _agentId: string, _metadata?: Record<string, unknown>): Promise<void>;
18
+ close(): void;
19
+ private rowsToMessages;
20
+ }
21
+ //# sourceMappingURL=sqlite-provider.d.ts.map
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ /**
3
+ * SqliteConversationProvider — reads/writes conversation history from ~/.crewx/crewx.db.
4
+ *
5
+ * Security:
6
+ * - SEC-1: SELECT columns are explicitly whitelisted (no rendered_prompt, command, logs, metadata).
7
+ * - SEC-2: All queries use parameterized bindings (? placeholders).
8
+ * - Writes target `threads` table ONLY — `tasks` table writes are owned by SqliteTracingPlugin.
9
+ */
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.SqliteConversationProvider = void 0;
15
+ const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
16
+ const path_1 = require("path");
17
+ const os_1 = require("os");
18
+ const THREADS_DDL = `
19
+ CREATE TABLE IF NOT EXISTS threads (
20
+ id TEXT PRIMARY KEY,
21
+ workspace_id TEXT,
22
+ platform TEXT NOT NULL DEFAULT 'cli',
23
+ title TEXT,
24
+ first_message TEXT,
25
+ last_message TEXT,
26
+ message_count INTEGER NOT NULL DEFAULT 0,
27
+ created_at TEXT NOT NULL,
28
+ updated_at TEXT NOT NULL,
29
+ metadata TEXT
30
+ )
31
+ `;
32
+ const COLUMNS = [
33
+ 'id', 'thread_id', 'prompt', 'result', 'started_at',
34
+ 'trace_id', 'status', 'parent_task_id', 'agent_id',
35
+ ];
36
+ function stripCliNoise(content) {
37
+ let cleaned = content.replace(/<conversation_history[^>]*>[\s\S]*?<\/conversation_history>/g, '');
38
+ const lines = cleaned.split('\n');
39
+ const cleanLines = lines.filter(line => {
40
+ if (line.startsWith('Loaded ') && line.includes('layouts from'))
41
+ return false;
42
+ if (line.includes('[dotenv@'))
43
+ return false;
44
+ if (line.includes('[Nest]') && line.includes('DEBUG'))
45
+ return false;
46
+ if (line.startsWith('Registered custom layout:'))
47
+ return false;
48
+ if (line.startsWith('Updated custom layout:'))
49
+ return false;
50
+ return true;
51
+ });
52
+ return cleanLines.join('\n').trim();
53
+ }
54
+ function cleanResult(raw) {
55
+ if (!raw)
56
+ return '';
57
+ let content = raw;
58
+ try {
59
+ const parsed = JSON.parse(content);
60
+ if (Array.isArray(parsed)) {
61
+ content = parsed
62
+ .filter((c) => c?.type === 'text' && c?.text)
63
+ .map((c) => c.text)
64
+ .join('\n');
65
+ }
66
+ else if (parsed && typeof parsed === 'object' && parsed.result !== undefined) {
67
+ content = parsed.result || '';
68
+ }
69
+ }
70
+ catch {
71
+ content = stripCliNoise(content);
72
+ }
73
+ return content;
74
+ }
75
+ class SqliteConversationProvider {
76
+ db;
77
+ constructor(dbPath) {
78
+ const resolved = dbPath ?? (0, path_1.join)((0, os_1.homedir)(), '.crewx', 'crewx.db');
79
+ this.db = new better_sqlite3_1.default(resolved);
80
+ this.init();
81
+ }
82
+ init() {
83
+ this.db.pragma('journal_mode = WAL');
84
+ this.db.exec(THREADS_DDL);
85
+ }
86
+ async ensureThread(threadId, platform, workspaceId) {
87
+ const row = this.db.prepare('SELECT platform FROM threads WHERE id = ?').get(threadId);
88
+ if (row) {
89
+ if (row.platform !== platform) {
90
+ throw new Error(`Thread '${threadId}' already exists with platform '${row.platform}' — cannot change to '${platform}' (platform is immutable)`);
91
+ }
92
+ // Backfill workspace_id if missing on existing thread (WI-CONV-003)
93
+ if (workspaceId) {
94
+ this.db.prepare('UPDATE threads SET workspace_id = COALESCE(workspace_id, ?) WHERE id = ?').run(workspaceId, threadId);
95
+ }
96
+ return;
97
+ }
98
+ const now = new Date().toISOString();
99
+ this.db.prepare('INSERT INTO threads (id, platform, workspace_id, message_count, created_at, updated_at) VALUES (?, ?, ?, 0, ?, ?)').run(threadId, platform, workspaceId ?? null, now, now);
100
+ }
101
+ async fetchHistory(threadId, options) {
102
+ const limit = options?.limit ?? 100;
103
+ const conditions = [
104
+ 'thread_id = ?',
105
+ '(parent_task_id IS NULL OR parent_task_id = \'\')',
106
+ '(status IN (\'done\', \'completed\', \'success\') OR status IS NULL)',
107
+ ];
108
+ const params = [threadId];
109
+ if (options?.currentTraceId) {
110
+ conditions.push('trace_id != ?');
111
+ params.push(options.currentTraceId);
112
+ }
113
+ const where = conditions.join(' AND ');
114
+ const selectCols = COLUMNS.join(', ');
115
+ const sql = `SELECT ${selectCols} FROM tasks WHERE ${where} ORDER BY started_at ASC LIMIT ?`;
116
+ params.push(limit);
117
+ const rows = this.db.prepare(sql).all(...params);
118
+ const threadRow = this.db.prepare('SELECT platform, title, first_message, last_message, message_count, updated_at FROM threads WHERE id = ?').get(threadId);
119
+ const platform = threadRow?.platform ?? 'cli';
120
+ const messages = this.rowsToMessages(rows);
121
+ return {
122
+ threadId,
123
+ platform: platform,
124
+ messages,
125
+ metadata: {
126
+ title: threadRow?.title ?? undefined,
127
+ firstMessage: threadRow?.first_message ?? undefined,
128
+ lastMessage: threadRow?.last_message ?? undefined,
129
+ messageCount: threadRow?.message_count ?? 0,
130
+ updatedAt: threadRow?.updated_at ? new Date(threadRow.updated_at).getTime() : undefined,
131
+ },
132
+ };
133
+ }
134
+ async saveUserMessage(threadId, text, _userId, _metadata) {
135
+ const now = new Date().toISOString();
136
+ this.db.prepare(`UPDATE threads
137
+ SET first_message = COALESCE(first_message, ?),
138
+ last_message = ?,
139
+ message_count = message_count + 1,
140
+ updated_at = ?
141
+ WHERE id = ?`).run(text, text, now, threadId);
142
+ }
143
+ async saveAssistantMessage(threadId, text, _agentId, _metadata) {
144
+ const now = new Date().toISOString();
145
+ this.db.prepare(`UPDATE threads
146
+ SET last_message = ?,
147
+ updated_at = ?
148
+ WHERE id = ?`).run(text, now, threadId);
149
+ }
150
+ close() {
151
+ this.db.close();
152
+ }
153
+ rowsToMessages(rows) {
154
+ const messages = [];
155
+ for (const row of rows) {
156
+ if (row.prompt) {
157
+ messages.push({
158
+ id: `${row.id}-user`,
159
+ text: row.prompt,
160
+ isAssistant: false,
161
+ timestamp: new Date(row.started_at).getTime(),
162
+ });
163
+ }
164
+ const cleaned = cleanResult(row.result);
165
+ if (cleaned) {
166
+ messages.push({
167
+ id: `${row.id}-assistant`,
168
+ text: cleaned,
169
+ isAssistant: true,
170
+ timestamp: new Date(row.started_at).getTime(),
171
+ });
172
+ }
173
+ }
174
+ return messages;
175
+ }
176
+ }
177
+ exports.SqliteConversationProvider = SqliteConversationProvider;
178
+ //# sourceMappingURL=sqlite-provider.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * toTaskReader — adapter from ConversationThread to boxing ITaskReader.
3
+ *
4
+ * SQ3 invariant:
5
+ * The returned ThreadMessage[] is structured as [user, assistant, user, assistant, ...]
6
+ * where each task produces exactly 2 consecutive elements (user first, then assistant).
7
+ * context-builder.ts:31~42 pairs messages as [i, i+1], so violating this invariant
8
+ * would corrupt context. Tasks without assistants (failed/running) are already
9
+ * filtered by fetchHistory — this adapter performs no additional filtering.
10
+ */
11
+ import type { ConversationThread } from './types';
12
+ import type { ITaskReader } from '../boxing/box-storage.interface';
13
+ export declare function toTaskReader(thread: ConversationThread): ITaskReader;
14
+ //# sourceMappingURL=to-task-reader.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * toTaskReader — adapter from ConversationThread to boxing ITaskReader.
4
+ *
5
+ * SQ3 invariant:
6
+ * The returned ThreadMessage[] is structured as [user, assistant, user, assistant, ...]
7
+ * where each task produces exactly 2 consecutive elements (user first, then assistant).
8
+ * context-builder.ts:31~42 pairs messages as [i, i+1], so violating this invariant
9
+ * would corrupt context. Tasks without assistants (failed/running) are already
10
+ * filtered by fetchHistory — this adapter performs no additional filtering.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.toTaskReader = toTaskReader;
14
+ function toTaskReader(thread) {
15
+ const messages = thread.messages.map((msg) => ({
16
+ id: msg.id,
17
+ role: msg.isAssistant ? 'assistant' : 'user',
18
+ content: msg.text,
19
+ timestamp: new Date(msg.timestamp).toISOString(),
20
+ metadata: msg.metadata ?? null,
21
+ }));
22
+ return {
23
+ getThreadMessages(_threadId) {
24
+ return messages;
25
+ },
26
+ };
27
+ }
28
+ //# sourceMappingURL=to-task-reader.js.map