@dexto/core 1.2.3 → 1.2.5

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 (523) hide show
  1. package/README.md +60 -0
  2. package/dist/agent/DextoAgent.cjs +579 -345
  3. package/dist/agent/DextoAgent.d.ts +131 -83
  4. package/dist/agent/DextoAgent.d.ts.map +1 -1
  5. package/dist/agent/DextoAgent.js +573 -336
  6. package/dist/agent/agentCard.cjs +4 -2
  7. package/dist/agent/agentCard.d.ts +0 -1
  8. package/dist/agent/agentCard.d.ts.map +1 -1
  9. package/dist/agent/agentCard.js +4 -2
  10. package/dist/agent/index.cjs +3 -7
  11. package/dist/agent/index.d.ts +3 -3
  12. package/dist/agent/index.d.ts.map +1 -1
  13. package/dist/agent/index.js +7 -6
  14. package/dist/agent/schemas.cjs +164 -64
  15. package/dist/agent/schemas.d.ts +2605 -517
  16. package/dist/agent/schemas.d.ts.map +1 -1
  17. package/dist/agent/schemas.js +167 -64
  18. package/dist/agent/state-manager.cjs +28 -23
  19. package/dist/agent/state-manager.d.ts +4 -1
  20. package/dist/agent/state-manager.d.ts.map +1 -1
  21. package/dist/agent/state-manager.js +28 -23
  22. package/dist/{preferences/constants.cjs → agent/types.cjs} +2 -14
  23. package/dist/agent/types.d.ts +54 -0
  24. package/dist/agent/types.d.ts.map +1 -0
  25. package/dist/agent/types.js +0 -0
  26. package/dist/approval/errors.cjs +89 -8
  27. package/dist/approval/errors.d.ts +5 -3
  28. package/dist/approval/errors.d.ts.map +1 -1
  29. package/dist/approval/errors.js +89 -8
  30. package/dist/approval/{providers/factory.d.ts → factory.d.ts} +2 -2
  31. package/dist/approval/factory.d.ts.map +1 -0
  32. package/dist/approval/{providers/factory.js → factory.js} +1 -1
  33. package/dist/approval/index.cjs +4 -6
  34. package/dist/approval/index.d.ts +3 -5
  35. package/dist/approval/index.d.ts.map +1 -1
  36. package/dist/approval/index.js +4 -5
  37. package/dist/approval/manager.cjs +140 -37
  38. package/dist/approval/manager.d.ts +56 -17
  39. package/dist/approval/manager.d.ts.map +1 -1
  40. package/dist/approval/manager.js +141 -38
  41. package/dist/approval/schemas.cjs +9 -1
  42. package/dist/approval/schemas.d.ts +120 -35
  43. package/dist/approval/schemas.d.ts.map +1 -1
  44. package/dist/approval/schemas.js +9 -2
  45. package/dist/approval/types.cjs +14 -2
  46. package/dist/approval/types.d.ts +64 -12
  47. package/dist/approval/types.d.ts.map +1 -1
  48. package/dist/approval/types.js +12 -1
  49. package/dist/context/compression/middle-removal.cjs +11 -11
  50. package/dist/context/compression/middle-removal.d.ts +3 -1
  51. package/dist/context/compression/middle-removal.d.ts.map +1 -1
  52. package/dist/context/compression/middle-removal.js +11 -11
  53. package/dist/context/compression/oldest-removal.cjs +18 -5
  54. package/dist/context/compression/oldest-removal.d.ts +3 -1
  55. package/dist/context/compression/oldest-removal.d.ts.map +1 -1
  56. package/dist/context/compression/oldest-removal.js +18 -5
  57. package/dist/context/manager.cjs +94 -67
  58. package/dist/context/manager.d.ts +13 -10
  59. package/dist/context/manager.d.ts.map +1 -1
  60. package/dist/context/manager.js +94 -67
  61. package/dist/context/utils.cjs +79 -65
  62. package/dist/context/utils.d.ts +15 -12
  63. package/dist/context/utils.d.ts.map +1 -1
  64. package/dist/context/utils.js +45 -31
  65. package/dist/errors/DextoRuntimeError.d.ts +5 -5
  66. package/dist/errors/DextoRuntimeError.d.ts.map +1 -1
  67. package/dist/errors/result-bridge.cjs +2 -3
  68. package/dist/errors/result-bridge.d.ts +5 -3
  69. package/dist/errors/result-bridge.d.ts.map +1 -1
  70. package/dist/errors/result-bridge.js +1 -2
  71. package/dist/errors/types.cjs +1 -2
  72. package/dist/errors/types.d.ts +5 -8
  73. package/dist/errors/types.d.ts.map +1 -1
  74. package/dist/errors/types.js +1 -2
  75. package/dist/events/index.cjs +125 -55
  76. package/dist/events/index.d.ts +204 -97
  77. package/dist/events/index.d.ts.map +1 -1
  78. package/dist/events/index.js +123 -55
  79. package/dist/filesystem/filesystem-service.cjs +40 -30
  80. package/dist/filesystem/filesystem-service.d.ts +9 -1
  81. package/dist/filesystem/filesystem-service.d.ts.map +1 -1
  82. package/dist/filesystem/filesystem-service.js +40 -30
  83. package/dist/filesystem/path-validator.cjs +4 -3
  84. package/dist/filesystem/path-validator.d.ts +3 -1
  85. package/dist/filesystem/path-validator.d.ts.map +1 -1
  86. package/dist/filesystem/path-validator.js +4 -3
  87. package/dist/filesystem/types.d.ts +3 -3
  88. package/dist/filesystem/types.d.ts.map +1 -1
  89. package/dist/index.browser.cjs +7 -0
  90. package/dist/index.browser.d.ts +2 -0
  91. package/dist/index.browser.d.ts.map +1 -1
  92. package/dist/index.browser.js +4 -0
  93. package/dist/index.cjs +0 -7
  94. package/dist/index.d.ts +12 -3
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +0 -4
  97. package/dist/llm/formatters/anthropic.cjs +32 -21
  98. package/dist/llm/formatters/anthropic.d.ts +3 -0
  99. package/dist/llm/formatters/anthropic.d.ts.map +1 -1
  100. package/dist/llm/formatters/anthropic.js +32 -21
  101. package/dist/llm/formatters/factory.cjs +6 -7
  102. package/dist/llm/formatters/factory.d.ts +2 -1
  103. package/dist/llm/formatters/factory.d.ts.map +1 -1
  104. package/dist/llm/formatters/factory.js +4 -5
  105. package/dist/llm/formatters/openai.cjs +38 -9
  106. package/dist/llm/formatters/openai.d.ts +3 -0
  107. package/dist/llm/formatters/openai.d.ts.map +1 -1
  108. package/dist/llm/formatters/openai.js +38 -9
  109. package/dist/llm/formatters/vercel.cjs +49 -8
  110. package/dist/llm/formatters/vercel.d.ts +3 -0
  111. package/dist/llm/formatters/vercel.d.ts.map +1 -1
  112. package/dist/llm/formatters/vercel.js +49 -8
  113. package/dist/llm/registry.cjs +153 -17
  114. package/dist/llm/registry.d.ts +5 -2
  115. package/dist/llm/registry.d.ts.map +1 -1
  116. package/dist/llm/registry.js +143 -7
  117. package/dist/llm/resolver.cjs +4 -4
  118. package/dist/llm/resolver.d.ts +3 -2
  119. package/dist/llm/resolver.d.ts.map +1 -1
  120. package/dist/llm/resolver.js +4 -4
  121. package/dist/llm/schemas.cjs +6 -3
  122. package/dist/llm/schemas.d.ts +51 -17
  123. package/dist/llm/schemas.d.ts.map +1 -1
  124. package/dist/llm/schemas.js +5 -3
  125. package/dist/llm/services/anthropic.cjs +216 -183
  126. package/dist/llm/services/anthropic.d.ts +3 -1
  127. package/dist/llm/services/anthropic.d.ts.map +1 -1
  128. package/dist/llm/services/anthropic.js +217 -184
  129. package/dist/llm/services/factory.cjs +15 -9
  130. package/dist/llm/services/factory.d.ts +2 -1
  131. package/dist/llm/services/factory.d.ts.map +1 -1
  132. package/dist/llm/services/factory.js +15 -9
  133. package/dist/llm/services/openai.cjs +262 -225
  134. package/dist/llm/services/openai.d.ts +3 -1
  135. package/dist/llm/services/openai.d.ts.map +1 -1
  136. package/dist/llm/services/openai.js +263 -226
  137. package/dist/llm/services/test-utils.integration.cjs +58 -12
  138. package/dist/llm/services/test-utils.integration.d.ts.map +1 -1
  139. package/dist/llm/services/test-utils.integration.js +58 -12
  140. package/dist/llm/services/types.d.ts +9 -0
  141. package/dist/llm/services/types.d.ts.map +1 -1
  142. package/dist/llm/services/vercel.cjs +163 -111
  143. package/dist/llm/services/vercel.d.ts +3 -1
  144. package/dist/llm/services/vercel.d.ts.map +1 -1
  145. package/dist/llm/services/vercel.js +157 -105
  146. package/dist/llm/tokenizer/factory.cjs +2 -2
  147. package/dist/llm/tokenizer/factory.d.ts +3 -1
  148. package/dist/llm/tokenizer/factory.d.ts.map +1 -1
  149. package/dist/llm/tokenizer/factory.js +2 -2
  150. package/dist/llm/tokenizer/openai.cjs +16 -9
  151. package/dist/llm/tokenizer/openai.d.ts +4 -1
  152. package/dist/llm/tokenizer/openai.d.ts.map +1 -1
  153. package/dist/llm/tokenizer/openai.js +16 -9
  154. package/dist/llm/validation.cjs +8 -9
  155. package/dist/llm/validation.d.ts +3 -1
  156. package/dist/llm/validation.d.ts.map +1 -1
  157. package/dist/llm/validation.js +5 -6
  158. package/dist/logger/factory.cjs +54 -0
  159. package/dist/logger/factory.d.ts +36 -0
  160. package/dist/logger/factory.d.ts.map +1 -0
  161. package/dist/logger/factory.js +31 -0
  162. package/dist/logger/index.cjs +42 -3
  163. package/dist/logger/index.d.ts +17 -1
  164. package/dist/logger/index.d.ts.map +1 -1
  165. package/dist/logger/index.js +26 -1
  166. package/dist/logger/logger.cjs +30 -17
  167. package/dist/logger/logger.d.ts.map +1 -1
  168. package/dist/logger/logger.js +30 -17
  169. package/dist/logger/v2/dexto-logger.cjs +141 -0
  170. package/dist/logger/v2/dexto-logger.d.ts +54 -0
  171. package/dist/logger/v2/dexto-logger.d.ts.map +1 -0
  172. package/dist/logger/v2/dexto-logger.js +118 -0
  173. package/dist/{preferences → logger/v2}/error-codes.cjs +11 -10
  174. package/dist/logger/v2/error-codes.d.ts +13 -0
  175. package/dist/logger/v2/error-codes.d.ts.map +1 -0
  176. package/dist/logger/v2/error-codes.js +13 -0
  177. package/dist/logger/v2/errors.cjs +107 -0
  178. package/dist/logger/v2/errors.d.ts +32 -0
  179. package/dist/logger/v2/errors.d.ts.map +1 -0
  180. package/dist/logger/v2/errors.js +84 -0
  181. package/dist/logger/v2/schemas.cjs +57 -0
  182. package/dist/logger/v2/schemas.d.ts +147 -0
  183. package/dist/logger/v2/schemas.d.ts.map +1 -0
  184. package/dist/logger/v2/schemas.js +33 -0
  185. package/dist/logger/v2/transport-factory.cjs +53 -0
  186. package/dist/logger/v2/transport-factory.d.ts +21 -0
  187. package/dist/logger/v2/transport-factory.d.ts.map +1 -0
  188. package/dist/logger/v2/transport-factory.js +29 -0
  189. package/dist/logger/v2/transports/console-transport.cjs +79 -0
  190. package/dist/logger/v2/transports/console-transport.d.ts +23 -0
  191. package/dist/logger/v2/transports/console-transport.d.ts.map +1 -0
  192. package/dist/logger/v2/transports/console-transport.js +46 -0
  193. package/dist/logger/v2/transports/file-transport.cjs +161 -0
  194. package/dist/logger/v2/transports/file-transport.d.ts +46 -0
  195. package/dist/logger/v2/transports/file-transport.d.ts.map +1 -0
  196. package/dist/logger/v2/transports/file-transport.js +128 -0
  197. package/dist/logger/v2/types.cjs +49 -0
  198. package/dist/logger/v2/types.d.ts +123 -0
  199. package/dist/logger/v2/types.d.ts.map +1 -0
  200. package/dist/logger/v2/types.js +26 -0
  201. package/dist/mcp/manager.cjs +88 -78
  202. package/dist/mcp/manager.d.ts +3 -1
  203. package/dist/mcp/manager.d.ts.map +1 -1
  204. package/dist/mcp/manager.js +88 -78
  205. package/dist/mcp/mcp-client.cjs +109 -79
  206. package/dist/mcp/mcp-client.d.ts +3 -0
  207. package/dist/mcp/mcp-client.d.ts.map +1 -1
  208. package/dist/mcp/mcp-client.js +102 -72
  209. package/dist/memory/manager.cjs +9 -7
  210. package/dist/memory/manager.d.ts +3 -1
  211. package/dist/memory/manager.d.ts.map +1 -1
  212. package/dist/memory/manager.js +9 -7
  213. package/dist/memory/schemas.d.ts +6 -6
  214. package/dist/plugins/manager.cjs +21 -19
  215. package/dist/plugins/manager.d.ts +3 -1
  216. package/dist/plugins/manager.d.ts.map +1 -1
  217. package/dist/plugins/manager.js +21 -19
  218. package/dist/plugins/schemas.d.ts +9 -9
  219. package/dist/plugins/types.d.ts +2 -2
  220. package/dist/plugins/types.d.ts.map +1 -1
  221. package/dist/process/command-validator.cjs +30 -20
  222. package/dist/process/command-validator.d.ts +4 -1
  223. package/dist/process/command-validator.d.ts.map +1 -1
  224. package/dist/process/command-validator.js +30 -20
  225. package/dist/process/process-service.cjs +23 -21
  226. package/dist/process/process-service.d.ts +3 -1
  227. package/dist/process/process-service.d.ts.map +1 -1
  228. package/dist/process/process-service.js +23 -21
  229. package/dist/prompts/prompt-manager.cjs +25 -18
  230. package/dist/prompts/prompt-manager.d.ts +3 -1
  231. package/dist/prompts/prompt-manager.d.ts.map +1 -1
  232. package/dist/prompts/prompt-manager.js +25 -18
  233. package/dist/prompts/providers/custom-prompt-provider.cjs +11 -7
  234. package/dist/prompts/providers/custom-prompt-provider.d.ts +3 -1
  235. package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
  236. package/dist/prompts/providers/custom-prompt-provider.js +11 -7
  237. package/dist/prompts/providers/file-prompt-provider.cjs +14 -12
  238. package/dist/prompts/providers/file-prompt-provider.d.ts +3 -1
  239. package/dist/prompts/providers/file-prompt-provider.d.ts.map +1 -1
  240. package/dist/prompts/providers/file-prompt-provider.js +14 -12
  241. package/dist/prompts/providers/mcp-prompt-provider.cjs +7 -6
  242. package/dist/prompts/providers/mcp-prompt-provider.d.ts +3 -1
  243. package/dist/prompts/providers/mcp-prompt-provider.d.ts.map +1 -1
  244. package/dist/prompts/providers/mcp-prompt-provider.js +7 -6
  245. package/dist/prompts/providers/starter-prompt-provider.cjs +7 -5
  246. package/dist/prompts/providers/starter-prompt-provider.d.ts +3 -1
  247. package/dist/prompts/providers/starter-prompt-provider.d.ts.map +1 -1
  248. package/dist/prompts/providers/starter-prompt-provider.js +7 -5
  249. package/dist/prompts/schemas.d.ts +3 -3
  250. package/dist/resources/handlers/blob-handler.cjs +15 -11
  251. package/dist/resources/handlers/blob-handler.d.ts +3 -1
  252. package/dist/resources/handlers/blob-handler.d.ts.map +1 -1
  253. package/dist/resources/handlers/blob-handler.js +15 -11
  254. package/dist/resources/handlers/factory.cjs +3 -3
  255. package/dist/resources/handlers/factory.d.ts +2 -1
  256. package/dist/resources/handlers/factory.d.ts.map +1 -1
  257. package/dist/resources/handlers/factory.js +3 -3
  258. package/dist/resources/handlers/filesystem-handler.cjs +10 -8
  259. package/dist/resources/handlers/filesystem-handler.d.ts +3 -1
  260. package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
  261. package/dist/resources/handlers/filesystem-handler.js +10 -8
  262. package/dist/resources/internal-provider.cjs +28 -20
  263. package/dist/resources/internal-provider.d.ts +3 -1
  264. package/dist/resources/internal-provider.d.ts.map +1 -1
  265. package/dist/resources/internal-provider.js +28 -20
  266. package/dist/resources/manager.cjs +34 -25
  267. package/dist/resources/manager.d.ts +3 -1
  268. package/dist/resources/manager.d.ts.map +1 -1
  269. package/dist/resources/manager.js +34 -25
  270. package/dist/resources/schemas.d.ts +6 -6
  271. package/dist/search/search-service.cjs +8 -6
  272. package/dist/search/search-service.d.ts +3 -1
  273. package/dist/search/search-service.d.ts.map +1 -1
  274. package/dist/search/search-service.js +8 -6
  275. package/dist/session/chat-session.cjs +40 -27
  276. package/dist/session/chat-session.d.ts +10 -7
  277. package/dist/session/chat-session.d.ts.map +1 -1
  278. package/dist/session/chat-session.js +40 -27
  279. package/dist/session/history/database.cjs +18 -11
  280. package/dist/session/history/database.d.ts +3 -1
  281. package/dist/session/history/database.d.ts.map +1 -1
  282. package/dist/session/history/database.js +18 -11
  283. package/dist/session/history/factory.cjs +2 -2
  284. package/dist/session/history/factory.d.ts +5 -1
  285. package/dist/session/history/factory.d.ts.map +1 -1
  286. package/dist/session/history/factory.js +2 -2
  287. package/dist/session/session-manager.cjs +37 -53
  288. package/dist/session/session-manager.d.ts +3 -17
  289. package/dist/session/session-manager.d.ts.map +1 -1
  290. package/dist/session/session-manager.js +37 -53
  291. package/dist/session/title-generator.cjs +3 -2
  292. package/dist/session/title-generator.d.ts +2 -1
  293. package/dist/session/title-generator.d.ts.map +1 -1
  294. package/dist/session/title-generator.js +3 -2
  295. package/dist/storage/blob/factory.cjs +9 -18
  296. package/dist/storage/blob/factory.d.ts +5 -4
  297. package/dist/storage/blob/factory.d.ts.map +1 -1
  298. package/dist/storage/blob/factory.js +8 -17
  299. package/dist/storage/blob/local-blob-store.cjs +25 -32
  300. package/dist/storage/blob/local-blob-store.d.ts +3 -2
  301. package/dist/storage/blob/local-blob-store.d.ts.map +1 -1
  302. package/dist/storage/blob/local-blob-store.js +25 -32
  303. package/dist/storage/blob/memory-blob-store.cjs +326 -0
  304. package/dist/storage/blob/memory-blob-store.d.ts +66 -0
  305. package/dist/storage/blob/memory-blob-store.d.ts.map +1 -0
  306. package/dist/storage/blob/memory-blob-store.js +303 -0
  307. package/dist/storage/blob/schemas.cjs +3 -1
  308. package/dist/storage/blob/schemas.d.ts +6 -6
  309. package/dist/storage/blob/schemas.d.ts.map +1 -1
  310. package/dist/storage/blob/schemas.js +3 -1
  311. package/dist/storage/cache/factory.cjs +7 -8
  312. package/dist/storage/cache/factory.d.ts +4 -1
  313. package/dist/storage/cache/factory.d.ts.map +1 -1
  314. package/dist/storage/cache/factory.js +4 -5
  315. package/dist/storage/cache/redis-store.cjs +4 -1
  316. package/dist/storage/cache/redis-store.d.ts +3 -1
  317. package/dist/storage/cache/redis-store.d.ts.map +1 -1
  318. package/dist/storage/cache/redis-store.js +4 -1
  319. package/dist/storage/database/factory.cjs +13 -16
  320. package/dist/storage/database/factory.d.ts +5 -3
  321. package/dist/storage/database/factory.d.ts.map +1 -1
  322. package/dist/storage/database/factory.js +9 -12
  323. package/dist/storage/database/postgres-store.cjs +4 -1
  324. package/dist/storage/database/postgres-store.d.ts +3 -1
  325. package/dist/storage/database/postgres-store.d.ts.map +1 -1
  326. package/dist/storage/database/postgres-store.js +4 -1
  327. package/dist/storage/database/schemas.cjs +3 -4
  328. package/dist/storage/database/schemas.d.ts +8 -16
  329. package/dist/storage/database/schemas.d.ts.map +1 -1
  330. package/dist/storage/database/schemas.js +3 -4
  331. package/dist/storage/database/sqlite-store.cjs +17 -45
  332. package/dist/storage/database/sqlite-store.d.ts +3 -3
  333. package/dist/storage/database/sqlite-store.d.ts.map +1 -1
  334. package/dist/storage/database/sqlite-store.js +17 -45
  335. package/dist/storage/schemas.cjs +3 -1
  336. package/dist/storage/schemas.d.ts +16 -23
  337. package/dist/storage/schemas.d.ts.map +1 -1
  338. package/dist/storage/schemas.js +3 -1
  339. package/dist/storage/storage-manager.cjs +15 -15
  340. package/dist/storage/storage-manager.d.ts +6 -6
  341. package/dist/storage/storage-manager.d.ts.map +1 -1
  342. package/dist/storage/storage-manager.js +15 -15
  343. package/dist/systemPrompt/contributors.cjs +15 -15
  344. package/dist/systemPrompt/contributors.d.ts +5 -3
  345. package/dist/systemPrompt/contributors.d.ts.map +1 -1
  346. package/dist/systemPrompt/contributors.js +15 -15
  347. package/dist/systemPrompt/manager.cjs +11 -8
  348. package/dist/systemPrompt/manager.d.ts +4 -2
  349. package/dist/systemPrompt/manager.d.ts.map +1 -1
  350. package/dist/systemPrompt/manager.js +11 -8
  351. package/dist/systemPrompt/schemas.cjs +21 -1
  352. package/dist/systemPrompt/schemas.d.ts +53 -53
  353. package/dist/systemPrompt/schemas.d.ts.map +1 -1
  354. package/dist/systemPrompt/schemas.js +11 -1
  355. package/dist/telemetry/decorators.cjs +54 -15
  356. package/dist/telemetry/decorators.d.ts.map +1 -1
  357. package/dist/telemetry/decorators.js +54 -15
  358. package/dist/telemetry/utils.cjs +21 -14
  359. package/dist/telemetry/utils.d.ts +7 -3
  360. package/dist/telemetry/utils.d.ts.map +1 -1
  361. package/dist/telemetry/utils.js +21 -14
  362. package/dist/tools/confirmation/allowed-tools-provider/factory.cjs +2 -2
  363. package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts +2 -1
  364. package/dist/tools/confirmation/allowed-tools-provider/factory.d.ts.map +1 -1
  365. package/dist/tools/confirmation/allowed-tools-provider/factory.js +2 -2
  366. package/dist/tools/confirmation/allowed-tools-provider/storage.cjs +7 -6
  367. package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts +3 -1
  368. package/dist/tools/confirmation/allowed-tools-provider/storage.d.ts.map +1 -1
  369. package/dist/tools/confirmation/allowed-tools-provider/storage.js +7 -6
  370. package/dist/tools/errors.cjs +2 -1
  371. package/dist/tools/errors.d.ts.map +1 -1
  372. package/dist/tools/errors.js +2 -1
  373. package/dist/tools/internal-tools/constants.cjs +2 -1
  374. package/dist/tools/internal-tools/constants.d.ts +1 -1
  375. package/dist/tools/internal-tools/constants.d.ts.map +1 -1
  376. package/dist/tools/internal-tools/constants.js +2 -1
  377. package/dist/tools/internal-tools/implementations/bash-exec-tool.cjs +1 -1
  378. package/dist/tools/internal-tools/implementations/bash-exec-tool.js +1 -1
  379. package/dist/tools/internal-tools/implementations/delegate-to-url-tool.cjs +192 -0
  380. package/dist/tools/internal-tools/implementations/delegate-to-url-tool.d.ts +33 -0
  381. package/dist/tools/internal-tools/implementations/delegate-to-url-tool.d.ts.map +1 -0
  382. package/dist/tools/internal-tools/implementations/delegate-to-url-tool.js +169 -0
  383. package/dist/tools/internal-tools/provider.cjs +21 -17
  384. package/dist/tools/internal-tools/provider.d.ts +3 -1
  385. package/dist/tools/internal-tools/provider.d.ts.map +1 -1
  386. package/dist/tools/internal-tools/provider.js +21 -17
  387. package/dist/tools/internal-tools/registry.cjs +5 -0
  388. package/dist/tools/internal-tools/registry.d.ts.map +1 -1
  389. package/dist/tools/internal-tools/registry.js +5 -0
  390. package/dist/tools/schemas.cjs +16 -4
  391. package/dist/tools/schemas.d.ts +21 -9
  392. package/dist/tools/schemas.d.ts.map +1 -1
  393. package/dist/tools/schemas.js +15 -4
  394. package/dist/tools/tool-manager.cjs +64 -47
  395. package/dist/tools/tool-manager.d.ts +4 -2
  396. package/dist/tools/tool-manager.d.ts.map +1 -1
  397. package/dist/tools/tool-manager.js +61 -44
  398. package/dist/tools/types.d.ts +0 -4
  399. package/dist/tools/types.d.ts.map +1 -1
  400. package/dist/utils/env-file.cjs +118 -0
  401. package/dist/utils/env-file.d.ts +5 -0
  402. package/dist/utils/env-file.d.ts.map +1 -0
  403. package/dist/utils/env-file.js +85 -0
  404. package/dist/utils/error-conversion.cjs +23 -1
  405. package/dist/utils/error-conversion.d.ts +2 -1
  406. package/dist/utils/error-conversion.d.ts.map +1 -1
  407. package/dist/utils/error-conversion.js +23 -1
  408. package/dist/utils/execution-context.d.ts.map +1 -1
  409. package/dist/utils/fs-walk.d.ts.map +1 -1
  410. package/dist/utils/index.cjs +7 -9
  411. package/dist/utils/index.d.ts +3 -4
  412. package/dist/utils/index.d.ts.map +1 -1
  413. package/dist/utils/index.js +3 -4
  414. package/dist/utils/path.cjs +22 -57
  415. package/dist/utils/path.d.ts +8 -7
  416. package/dist/utils/path.d.ts.map +1 -1
  417. package/dist/utils/path.js +21 -54
  418. package/dist/utils/result.cjs +37 -14
  419. package/dist/utils/result.d.ts.map +1 -1
  420. package/dist/utils/result.js +37 -14
  421. package/dist/utils/schema.cjs +2 -3
  422. package/dist/utils/schema.d.ts +2 -1
  423. package/dist/utils/schema.d.ts.map +1 -1
  424. package/dist/utils/schema.js +1 -2
  425. package/dist/utils/service-initializer.cjs +87 -61
  426. package/dist/utils/service-initializer.d.ts +4 -2
  427. package/dist/utils/service-initializer.d.ts.map +1 -1
  428. package/dist/utils/service-initializer.js +69 -43
  429. package/package.json +7 -3
  430. package/dist/Dexto.cjs +0 -251
  431. package/dist/Dexto.d.ts +0 -191
  432. package/dist/Dexto.d.ts.map +0 -1
  433. package/dist/Dexto.js +0 -228
  434. package/dist/agent/registry/error-codes.cjs +0 -44
  435. package/dist/agent/registry/error-codes.d.ts +0 -21
  436. package/dist/agent/registry/error-codes.d.ts.map +0 -1
  437. package/dist/agent/registry/error-codes.js +0 -21
  438. package/dist/agent/registry/errors.cjs +0 -188
  439. package/dist/agent/registry/errors.d.ts +0 -63
  440. package/dist/agent/registry/errors.d.ts.map +0 -1
  441. package/dist/agent/registry/errors.js +0 -165
  442. package/dist/agent/registry/registry.cjs +0 -479
  443. package/dist/agent/registry/registry.d.ts +0 -130
  444. package/dist/agent/registry/registry.d.ts.map +0 -1
  445. package/dist/agent/registry/registry.js +0 -453
  446. package/dist/agent/registry/types.cjs +0 -74
  447. package/dist/agent/registry/types.d.ts +0 -142
  448. package/dist/agent/registry/types.d.ts.map +0 -1
  449. package/dist/agent/registry/types.js +0 -48
  450. package/dist/agent/registry/user-registry.cjs +0 -140
  451. package/dist/agent/registry/user-registry.d.ts +0 -34
  452. package/dist/agent/registry/user-registry.d.ts.map +0 -1
  453. package/dist/agent/registry/user-registry.js +0 -105
  454. package/dist/approval/providers/event-based-approval-provider.cjs +0 -156
  455. package/dist/approval/providers/event-based-approval-provider.d.ts +0 -39
  456. package/dist/approval/providers/event-based-approval-provider.d.ts.map +0 -1
  457. package/dist/approval/providers/event-based-approval-provider.js +0 -133
  458. package/dist/approval/providers/factory.d.ts.map +0 -1
  459. package/dist/approval/providers/noop-approval-provider.cjs +0 -54
  460. package/dist/approval/providers/noop-approval-provider.d.ts +0 -18
  461. package/dist/approval/providers/noop-approval-provider.d.ts.map +0 -1
  462. package/dist/approval/providers/noop-approval-provider.js +0 -31
  463. package/dist/config/agent-resolver.cjs +0 -153
  464. package/dist/config/agent-resolver.d.ts +0 -14
  465. package/dist/config/agent-resolver.d.ts.map +0 -1
  466. package/dist/config/agent-resolver.js +0 -123
  467. package/dist/config/error-codes.cjs +0 -39
  468. package/dist/config/error-codes.d.ts +0 -16
  469. package/dist/config/error-codes.d.ts.map +0 -1
  470. package/dist/config/error-codes.js +0 -16
  471. package/dist/config/errors.cjs +0 -126
  472. package/dist/config/errors.d.ts +0 -34
  473. package/dist/config/errors.d.ts.map +0 -1
  474. package/dist/config/errors.js +0 -103
  475. package/dist/config/index.cjs +0 -26
  476. package/dist/config/index.d.ts +0 -4
  477. package/dist/config/index.d.ts.map +0 -1
  478. package/dist/config/index.js +0 -3
  479. package/dist/config/loader.cjs +0 -119
  480. package/dist/config/loader.d.ts +0 -16
  481. package/dist/config/loader.d.ts.map +0 -1
  482. package/dist/config/loader.js +0 -86
  483. package/dist/config/writer.cjs +0 -182
  484. package/dist/config/writer.d.ts +0 -35
  485. package/dist/config/writer.d.ts.map +0 -1
  486. package/dist/config/writer.js +0 -147
  487. package/dist/preferences/constants.d.ts +0 -2
  488. package/dist/preferences/constants.d.ts.map +0 -1
  489. package/dist/preferences/constants.js +0 -5
  490. package/dist/preferences/error-codes.d.ts +0 -8
  491. package/dist/preferences/error-codes.d.ts.map +0 -1
  492. package/dist/preferences/error-codes.js +0 -12
  493. package/dist/preferences/errors.cjs +0 -75
  494. package/dist/preferences/errors.d.ts +0 -18
  495. package/dist/preferences/errors.d.ts.map +0 -1
  496. package/dist/preferences/errors.js +0 -51
  497. package/dist/preferences/index.cjs +0 -55
  498. package/dist/preferences/index.d.ts +0 -6
  499. package/dist/preferences/index.d.ts.map +0 -1
  500. package/dist/preferences/index.js +0 -32
  501. package/dist/preferences/loader.cjs +0 -138
  502. package/dist/preferences/loader.d.ts +0 -51
  503. package/dist/preferences/loader.d.ts.map +0 -1
  504. package/dist/preferences/loader.js +0 -110
  505. package/dist/preferences/schemas.cjs +0 -75
  506. package/dist/preferences/schemas.d.ts +0 -110
  507. package/dist/preferences/schemas.d.ts.map +0 -1
  508. package/dist/preferences/schemas.js +0 -49
  509. package/dist/utils/api-key-store.cjs +0 -56
  510. package/dist/utils/api-key-store.d.ts +0 -24
  511. package/dist/utils/api-key-store.d.ts.map +0 -1
  512. package/dist/utils/api-key-store.js +0 -31
  513. package/dist/utils/env.cjs +0 -154
  514. package/dist/utils/env.d.ts +0 -28
  515. package/dist/utils/env.d.ts.map +0 -1
  516. package/dist/utils/env.js +0 -119
  517. package/dist/utils/port-utils.cjs +0 -37
  518. package/dist/utils/port-utils.d.ts +0 -10
  519. package/dist/utils/port-utils.d.ts.map +0 -1
  520. package/dist/utils/port-utils.js +0 -14
  521. package/dist/utils/port-utils.spec.cjs +0 -26
  522. package/dist/utils/port-utils.spec.js +0 -25
  523. /package/dist/approval/{providers/factory.cjs → factory.cjs} +0 -0
@@ -1,479 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var registry_exports = {};
30
- __export(registry_exports, {
31
- LocalAgentRegistry: () => LocalAgentRegistry,
32
- getAgentRegistry: () => getAgentRegistry
33
- });
34
- module.exports = __toCommonJS(registry_exports);
35
- var import_fs = require("fs");
36
- var import_fs2 = require("fs");
37
- var import_path = __toESM(require("path"), 1);
38
- var import_logger = require("../../logger/index.cjs");
39
- var import_path2 = require("../../utils/path.cjs");
40
- var import_loader = require("../../preferences/loader.cjs");
41
- var import_writer = require("../../config/writer.cjs");
42
- var import_types = require("./types.js");
43
- var import_errors = require("./errors.js");
44
- var import_user_registry = require("./user-registry.js");
45
- let cachedRegistry = null;
46
- class LocalAgentRegistry {
47
- _registry = null;
48
- /**
49
- * Lazy load registry from JSON file
50
- */
51
- getRegistry() {
52
- if (this._registry === null) {
53
- this._registry = this.loadRegistry();
54
- }
55
- return this._registry;
56
- }
57
- /**
58
- * Load and merge bundled + user registries
59
- * Uses fail-fast approach - throws RegistryError for any loading issues
60
- */
61
- loadRegistry() {
62
- let jsonPath;
63
- try {
64
- jsonPath = (0, import_path2.resolveBundledScript)("agents/agent-registry.json");
65
- } catch (error) {
66
- throw import_errors.RegistryError.registryNotFound(
67
- "agents/agent-registry.json",
68
- error instanceof Error ? error.message : String(error)
69
- );
70
- }
71
- if (!(0, import_fs.existsSync)(jsonPath)) {
72
- throw import_errors.RegistryError.registryNotFound(jsonPath, "File doesn't exist");
73
- }
74
- let bundledRegistry;
75
- try {
76
- const jsonData = (0, import_fs.readFileSync)(jsonPath, "utf-8");
77
- const rawRegistry = JSON.parse(jsonData);
78
- bundledRegistry = import_types.RegistrySchema.parse((0, import_types.normalizeRegistryJson)(rawRegistry));
79
- } catch (error) {
80
- throw import_errors.RegistryError.registryParseError(
81
- jsonPath,
82
- error instanceof Error ? error.message : String(error)
83
- );
84
- }
85
- const userRegistry = (0, import_user_registry.loadUserRegistry)();
86
- const merged = (0, import_user_registry.mergeRegistries)(bundledRegistry, userRegistry);
87
- import_logger.logger.debug(
88
- `Loaded registry: ${Object.keys(bundledRegistry.agents).length} bundled, ${Object.keys(userRegistry.agents).length} custom`
89
- );
90
- return merged;
91
- }
92
- /**
93
- * Check if agent exists in registry by ID
94
- */
95
- hasAgent(agentId) {
96
- const registry = this.getRegistry();
97
- return agentId in registry.agents;
98
- }
99
- /**
100
- * Get available agents with their metadata from registry
101
- */
102
- getAvailableAgents() {
103
- const registry = this.getRegistry();
104
- return registry.agents;
105
- }
106
- /**
107
- * Validate custom agent ID doesn't conflict with bundled registry
108
- * @throws RegistryError if ID conflicts with builtin agent
109
- */
110
- validateCustomAgentId(agentId) {
111
- let jsonPath;
112
- try {
113
- jsonPath = (0, import_path2.resolveBundledScript)("agents/agent-registry.json");
114
- } catch (error) {
115
- throw import_errors.RegistryError.registryNotFound(
116
- "agents/agent-registry.json",
117
- error instanceof Error ? error.message : String(error)
118
- );
119
- }
120
- try {
121
- const jsonData = (0, import_fs.readFileSync)(jsonPath, "utf-8");
122
- const bundledRegistry = import_types.RegistrySchema.parse(
123
- (0, import_types.normalizeRegistryJson)(JSON.parse(jsonData))
124
- );
125
- if (agentId in bundledRegistry.agents) {
126
- throw import_errors.RegistryError.customAgentNameConflict(agentId);
127
- }
128
- } catch (error) {
129
- if (error instanceof Error && /name conflicts with builtin agent/.test(error.message)) {
130
- throw error;
131
- }
132
- throw import_errors.RegistryError.registryParseError(
133
- jsonPath,
134
- error instanceof Error ? error.message : String(error)
135
- );
136
- }
137
- }
138
- /**
139
- * Resolve main config file for installed agent
140
- * Handles both directory agents (with main field) and single-file agents
141
- */
142
- resolveMainConfig(agentDir, agentId) {
143
- const registry = this.getRegistry();
144
- const agentData = registry.agents[agentId];
145
- if (!agentData) {
146
- const available = Object.keys(registry.agents);
147
- throw import_errors.RegistryError.agentNotFound(agentId, available);
148
- }
149
- if (agentData.source.endsWith("/")) {
150
- if (!agentData.main) {
151
- throw import_errors.RegistryError.agentInvalidEntry(
152
- agentId,
153
- "directory entry missing main field"
154
- );
155
- }
156
- const mainConfigPath = import_path.default.join(agentDir, agentData.main);
157
- if (!(0, import_fs.existsSync)(mainConfigPath)) {
158
- throw import_errors.RegistryError.mainConfigMissing(agentId, mainConfigPath);
159
- }
160
- return mainConfigPath;
161
- } else {
162
- const filename = import_path.default.basename(agentData.source);
163
- const configPath = import_path.default.join(agentDir, filename);
164
- if (!(0, import_fs.existsSync)(configPath)) {
165
- throw import_errors.RegistryError.configNotFound(configPath);
166
- }
167
- return configPath;
168
- }
169
- }
170
- /**
171
- * Install agent atomically using temp + rename pattern
172
- * @param agentId ID of the agent to install
173
- * @param injectPreferences Whether to inject global preferences into installed agent (default: true)
174
- */
175
- async installAgent(agentId, injectPreferences = true) {
176
- import_logger.logger.info(`Installing agent: ${agentId}`);
177
- const registry = this.getRegistry();
178
- const agentData = registry.agents[agentId];
179
- if (!agentData) {
180
- const available = Object.keys(registry.agents);
181
- throw import_errors.RegistryError.agentNotFound(agentId, available);
182
- }
183
- const globalAgentsDir = (0, import_path2.getDextoGlobalPath)("agents");
184
- const targetDir = import_path.default.resolve(globalAgentsDir, agentId);
185
- const relTarget = import_path.default.relative(globalAgentsDir, targetDir);
186
- if (relTarget.startsWith("..") || import_path.default.isAbsolute(relTarget)) {
187
- throw import_errors.RegistryError.installationFailed(
188
- agentId,
189
- "invalid agentId: path traversal detected"
190
- );
191
- }
192
- if ((0, import_fs.existsSync)(targetDir)) {
193
- import_logger.logger.info(`Agent '${agentId}' already installed`);
194
- return this.resolveMainConfig(targetDir, agentId);
195
- }
196
- await import_fs2.promises.mkdir(globalAgentsDir, { recursive: true });
197
- const sourcePath = (0, import_path2.resolveBundledScript)(`agents/${agentData.source}`);
198
- const tempDir = `${targetDir}.tmp.${Date.now()}`;
199
- try {
200
- if (agentData.source.endsWith("/")) {
201
- await (0, import_path2.copyDirectory)(sourcePath, tempDir);
202
- } else {
203
- await import_fs2.promises.mkdir(tempDir, { recursive: true });
204
- const targetFile = import_path.default.join(tempDir, import_path.default.basename(sourcePath));
205
- await import_fs2.promises.copyFile(sourcePath, targetFile);
206
- }
207
- const mainConfigPath = this.resolveMainConfig(tempDir, agentId);
208
- if (!(0, import_fs.existsSync)(mainConfigPath)) {
209
- throw import_errors.RegistryError.installationValidationFailed(agentId, mainConfigPath);
210
- }
211
- await import_fs2.promises.rename(tempDir, targetDir);
212
- import_logger.logger.info(`\u2713 Installed agent '${agentId}' to ${targetDir}`);
213
- if (injectPreferences) {
214
- try {
215
- const preferences = await (0, import_loader.loadGlobalPreferences)();
216
- await (0, import_writer.writePreferencesToAgent)(targetDir, preferences);
217
- import_logger.logger.info(`\u2713 Applied global preferences to installed agent '${agentId}'`);
218
- } catch (error) {
219
- import_logger.logger.warn(
220
- `Failed to inject preferences to '${agentId}': ${error instanceof Error ? error.message : String(error)}`
221
- );
222
- console.log(
223
- `\u26A0\uFE0F Warning: Could not apply preferences to '${agentId}' - agent will use bundled settings`
224
- );
225
- }
226
- } else {
227
- import_logger.logger.info(
228
- `Skipped preference injection for '${agentId}' (injectPreferences=false)`
229
- );
230
- }
231
- return this.resolveMainConfig(targetDir, agentId);
232
- } catch (error) {
233
- try {
234
- if ((0, import_fs.existsSync)(tempDir)) {
235
- await import_fs2.promises.rm(tempDir, { recursive: true, force: true });
236
- }
237
- } catch (cleanupError) {
238
- import_logger.logger.error(
239
- `Failed to clean up temp directory: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Skipping cleanup...`
240
- );
241
- }
242
- throw import_errors.RegistryError.installationFailed(
243
- agentId,
244
- error instanceof Error ? error.message : String(error)
245
- );
246
- }
247
- }
248
- /**
249
- * Install a custom agent from a local file path
250
- * @param agentId Unique identifier for the custom agent
251
- * @param sourcePath Absolute path to agent YAML file or directory
252
- * @param metadata Agent metadata (name for display, description, author, tags, main)
253
- * @param injectPreferences Whether to inject global preferences (default: true)
254
- * @returns Path to the installed agent's main config file
255
- */
256
- async installCustomAgentFromPath(agentId, sourcePath, metadata, injectPreferences = true) {
257
- import_logger.logger.info(`Installing custom agent '${agentId}' from ${sourcePath}`);
258
- this.validateCustomAgentId(agentId);
259
- if (!(0, import_fs.existsSync)(sourcePath)) {
260
- throw import_errors.RegistryError.configNotFound(sourcePath);
261
- }
262
- const globalAgentsDir = (0, import_path2.getDextoGlobalPath)("agents");
263
- const targetDir = import_path.default.resolve(globalAgentsDir, agentId);
264
- const relTarget = import_path.default.relative(globalAgentsDir, targetDir);
265
- if (relTarget.startsWith("..") || import_path.default.isAbsolute(relTarget)) {
266
- throw import_errors.RegistryError.installationFailed(
267
- agentId,
268
- "invalid agentId: path traversal detected"
269
- );
270
- }
271
- if ((0, import_fs.existsSync)(targetDir)) {
272
- throw import_errors.RegistryError.agentAlreadyExists(agentId);
273
- }
274
- await import_fs2.promises.mkdir(globalAgentsDir, { recursive: true });
275
- const stats = await import_fs2.promises.stat(sourcePath);
276
- const isDirectory = stats.isDirectory();
277
- const configFileName = isDirectory ? void 0 : `${agentId}.yml`;
278
- if (!metadata.description) {
279
- throw import_errors.RegistryError.installationFailed(agentId, "description is required");
280
- }
281
- if (isDirectory && !metadata.main) {
282
- throw import_errors.RegistryError.installationFailed(
283
- agentId,
284
- "main field is required for directory-based agents"
285
- );
286
- }
287
- const displayName = metadata.name || agentId.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
288
- const registryEntry = {
289
- id: agentId,
290
- name: displayName,
291
- description: metadata.description,
292
- author: metadata.author,
293
- tags: metadata.tags,
294
- source: isDirectory ? `${agentId}/` : configFileName,
295
- main: metadata.main
296
- };
297
- const tempDir = `${targetDir}.tmp.${Date.now()}`;
298
- try {
299
- if (isDirectory) {
300
- await (0, import_path2.copyDirectory)(sourcePath, tempDir);
301
- } else {
302
- await import_fs2.promises.mkdir(tempDir, { recursive: true });
303
- const targetFile = import_path.default.join(tempDir, configFileName);
304
- await import_fs2.promises.copyFile(sourcePath, targetFile);
305
- }
306
- const tempMainConfigPath = isDirectory ? import_path.default.join(tempDir, metadata.main) : import_path.default.join(tempDir, configFileName);
307
- if (!(0, import_fs.existsSync)(tempMainConfigPath)) {
308
- throw import_errors.RegistryError.installationValidationFailed(agentId, tempMainConfigPath);
309
- }
310
- await import_fs2.promises.rename(tempDir, targetDir);
311
- import_logger.logger.info(`\u2713 Installed custom agent '${agentId}' to ${targetDir}`);
312
- const mainConfigPath = isDirectory && metadata.main ? import_path.default.join(targetDir, metadata.main) : import_path.default.join(targetDir, configFileName);
313
- try {
314
- await (0, import_user_registry.addAgentToUserRegistry)(agentId, registryEntry);
315
- import_logger.logger.info(`\u2713 Added '${agentId}' to user registry`);
316
- this._registry = null;
317
- } catch (registryError) {
318
- try {
319
- if ((0, import_fs.existsSync)(targetDir)) {
320
- await import_fs2.promises.rm(targetDir, { recursive: true, force: true });
321
- import_logger.logger.info(`Rolled back installation: removed ${targetDir}`);
322
- }
323
- } catch (rollbackError) {
324
- import_logger.logger.error(
325
- `Rollback failed for '${agentId}': ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`
326
- );
327
- }
328
- throw registryError;
329
- }
330
- if (injectPreferences) {
331
- try {
332
- const preferences = await (0, import_loader.loadGlobalPreferences)();
333
- await (0, import_writer.writePreferencesToAgent)(targetDir, preferences);
334
- import_logger.logger.info(`\u2713 Applied global preferences to custom agent '${agentId}'`);
335
- } catch (error) {
336
- import_logger.logger.warn(
337
- `Failed to inject preferences to '${agentId}': ${error instanceof Error ? error.message : String(error)}`
338
- );
339
- console.log(
340
- `\u26A0\uFE0F Warning: Could not apply preferences to '${agentId}' - agent will use default settings`
341
- );
342
- }
343
- }
344
- return mainConfigPath;
345
- } catch (error) {
346
- try {
347
- if ((0, import_fs.existsSync)(tempDir)) {
348
- await import_fs2.promises.rm(tempDir, { recursive: true, force: true });
349
- }
350
- } catch (cleanupError) {
351
- import_logger.logger.error(
352
- `Failed to clean up temp directory: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Skipping cleanup...`
353
- );
354
- }
355
- throw import_errors.RegistryError.installationFailed(
356
- agentId,
357
- error instanceof Error ? error.message : String(error)
358
- );
359
- }
360
- }
361
- /**
362
- * Resolve a registry agent ID to a config path
363
- * NOTE: Only handles registry IDs, not file paths (routing done in loadAgentConfig)
364
- * Handles installing agent if needed
365
- * @param agentId ID of the agent to resolve
366
- * @param autoInstall Whether to automatically install missing agents from registry (default: true)
367
- * @param injectPreferences Whether to inject preferences during auto-installation (default: true)
368
- */
369
- async resolveAgent(agentId, autoInstall = true, injectPreferences = true) {
370
- import_logger.logger.debug(`Resolving registry agent: ${agentId}`);
371
- const globalAgentsDir = (0, import_path2.getDextoGlobalPath)("agents");
372
- const installedPath = import_path.default.resolve(globalAgentsDir, agentId);
373
- const relInstalled = import_path.default.relative(globalAgentsDir, installedPath);
374
- if (relInstalled.startsWith("..") || import_path.default.isAbsolute(relInstalled)) {
375
- throw import_errors.RegistryError.agentNotFound(agentId, Object.keys(this.getRegistry().agents));
376
- }
377
- if ((0, import_fs.existsSync)(installedPath)) {
378
- const mainConfig = this.resolveMainConfig(installedPath, agentId);
379
- import_logger.logger.debug(`Resolved installed agent '${agentId}' to: ${mainConfig}`);
380
- return mainConfig;
381
- }
382
- import_logger.logger.debug(`Agent '${agentId}' not found in installed path: ${installedPath}`);
383
- if (this.hasAgent(agentId)) {
384
- if (autoInstall) {
385
- import_logger.logger.info(`Installing agent '${agentId}' from registry...`);
386
- return await this.installAgent(agentId, injectPreferences);
387
- } else {
388
- const registry2 = this.getRegistry();
389
- const available2 = Object.keys(registry2.agents);
390
- throw import_errors.RegistryError.agentNotInstalledAutoInstallDisabled(agentId, available2);
391
- }
392
- }
393
- const registry = this.getRegistry();
394
- const available = Object.keys(registry.agents);
395
- throw import_errors.RegistryError.agentNotFound(agentId, available);
396
- }
397
- /**
398
- * Get list of currently installed agents
399
- */
400
- async getInstalledAgents() {
401
- const globalAgentsDir = (0, import_path2.getDextoGlobalPath)("agents");
402
- if (!(0, import_fs.existsSync)(globalAgentsDir)) {
403
- return [];
404
- }
405
- try {
406
- const entries = await import_fs2.promises.readdir(globalAgentsDir, { withFileTypes: true });
407
- return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => !name.startsWith(".tmp") && !name.includes(".tmp."));
408
- } catch (error) {
409
- import_logger.logger.error(`Failed to read installed agents directory: ${error}`);
410
- return [];
411
- }
412
- }
413
- /**
414
- * Check if an agent is safe to uninstall (not the default agent from preferences)
415
- */
416
- async isAgentSafeToUninstall(agentId) {
417
- try {
418
- const preferences = await (0, import_loader.loadGlobalPreferences)();
419
- const defaultAgent = preferences.defaults.defaultAgent;
420
- return agentId !== defaultAgent;
421
- } catch {
422
- import_logger.logger.warn("Could not load preferences, using fallback protection for default-agent");
423
- return agentId !== "default-agent";
424
- }
425
- }
426
- /**
427
- * Uninstall an agent by removing its directory
428
- * For custom agents: also removes from user registry
429
- * For builtin agents: only removes from disk
430
- * @param agentId ID of the agent to uninstall
431
- * @param force Whether to force uninstall even if agent is protected (default: false)
432
- */
433
- async uninstallAgent(agentId, force = false) {
434
- const globalAgentsDir = (0, import_path2.getDextoGlobalPath)("agents");
435
- const agentDir = import_path.default.resolve(globalAgentsDir, agentId);
436
- const relAgent = import_path.default.relative(globalAgentsDir, agentDir);
437
- if (relAgent.startsWith("..") || import_path.default.isAbsolute(relAgent)) {
438
- throw import_errors.RegistryError.uninstallationFailed(
439
- agentId,
440
- "invalid agentId: path traversal detected"
441
- );
442
- }
443
- import_logger.logger.info(`Uninstalling agent: ${agentId} from ${agentDir}`);
444
- if (!(0, import_fs.existsSync)(agentDir)) {
445
- throw import_errors.RegistryError.agentNotInstalled(agentId);
446
- }
447
- if (!force && !await this.isAgentSafeToUninstall(agentId)) {
448
- throw import_errors.RegistryError.agentProtected(agentId);
449
- }
450
- const registry = this.getRegistry();
451
- const agentData = registry.agents[agentId];
452
- const isCustomAgent = agentData?.type === "custom";
453
- try {
454
- await import_fs2.promises.rm(agentDir, { recursive: true, force: true });
455
- import_logger.logger.info(`\u2713 Removed agent '${agentId}' from ${agentDir}`);
456
- if (isCustomAgent) {
457
- await (0, import_user_registry.removeAgentFromUserRegistry)(agentId);
458
- import_logger.logger.info(`\u2713 Removed custom agent '${agentId}' from user registry`);
459
- this._registry = null;
460
- }
461
- } catch (error) {
462
- throw import_errors.RegistryError.uninstallationFailed(
463
- agentId,
464
- error instanceof Error ? error.message : String(error)
465
- );
466
- }
467
- }
468
- }
469
- function getAgentRegistry() {
470
- if (cachedRegistry === null) {
471
- cachedRegistry = new LocalAgentRegistry();
472
- }
473
- return cachedRegistry;
474
- }
475
- // Annotate the CommonJS export names for ESM import in node:
476
- 0 && (module.exports = {
477
- LocalAgentRegistry,
478
- getAgentRegistry
479
- });
@@ -1,130 +0,0 @@
1
- import { Registry, AgentRegistry, AgentRegistryEntry } from './types.js';
2
- /**
3
- * Local agent registry implementation
4
- *
5
- * TODO: ARCHITECTURAL REFACTOR - Move registry, preferences, and agent resolution to CLI
6
- *
7
- * PROBLEM: Registry operations are CLI concerns but live in Core, causing:
8
- * - Missing analytics for auto-install (when running `dexto`, registry installs agents but doesn't track)
9
- * - Wrong separation of concerns (Core = execution engine, not discovery/setup)
10
- * - Registry manages ~/.dexto/agents filesystem which is CLI-level setup
11
- *
12
- * THE RIGHT ARCHITECTURE:
13
- *
14
- * Move to CLI:
15
- * 1. Agent Registry (packages/core/src/agent/registry/) → packages/cli/src/registry/
16
- * - installAgent(), uninstallAgent(), resolveAgent(), listAgents()
17
- * - Can directly call capture() for analytics
18
- * - Manages ~/.dexto/agents installation directory
19
- *
20
- * 2. Global Preferences (packages/core/src/preferences/) → packages/cli/src/preferences/
21
- * - User's default LLM, model, default agent
22
- * - Used by `dexto setup` command
23
- * - Manages ~/.dexto/preferences.json
24
- *
25
- * 3. Agent Resolution (packages/core/src/config/agent-resolver.ts) → packages/cli/src/agent-resolver.ts
26
- * - Discovery logic: check registry, trigger installs, apply preferences
27
- * - Returns resolved config PATH to core
28
- *
29
- * Core keeps:
30
- * - config/loader.ts - Load YAML from path
31
- * - config/schemas.ts - Zod validation
32
- * - Agent execution (DextoAgent, LLM, tools, MCP)
33
- *
34
- * FLOW AFTER REFACTOR:
35
- * CLI index.ts:
36
- * → CLI: resolveAgentPath() (discovery logic)
37
- * → CLI: registry.resolveAgent()
38
- * → CLI: registry.installAgent() if needed
39
- * → CLI: capture('dexto_install_agent', ...) ✓ Natural!
40
- * → Core: new DextoAgent(configPath) (just loads & runs)
41
- *
42
- * BENEFITS:
43
- * - Clear separation: CLI = setup/discovery, Core = execution
44
- * - Analytics naturally colocated with operations
45
- * - Core is portable (no CLI dependencies)
46
- * - No circular deps (CLI → Core, correct direction)
47
- *
48
- * ESTIMATE: ~3-4 hours (mostly moving code + updating imports)
49
- */
50
- export declare class LocalAgentRegistry implements AgentRegistry {
51
- private _registry;
52
- /**
53
- * Lazy load registry from JSON file
54
- */
55
- getRegistry(): Registry;
56
- /**
57
- * Load and merge bundled + user registries
58
- * Uses fail-fast approach - throws RegistryError for any loading issues
59
- */
60
- private loadRegistry;
61
- /**
62
- * Check if agent exists in registry by ID
63
- */
64
- hasAgent(agentId: string): boolean;
65
- /**
66
- * Get available agents with their metadata from registry
67
- */
68
- getAvailableAgents(): Record<string, AgentRegistryEntry>;
69
- /**
70
- * Validate custom agent ID doesn't conflict with bundled registry
71
- * @throws RegistryError if ID conflicts with builtin agent
72
- */
73
- private validateCustomAgentId;
74
- /**
75
- * Resolve main config file for installed agent
76
- * Handles both directory agents (with main field) and single-file agents
77
- */
78
- resolveMainConfig(agentDir: string, agentId: string): string;
79
- /**
80
- * Install agent atomically using temp + rename pattern
81
- * @param agentId ID of the agent to install
82
- * @param injectPreferences Whether to inject global preferences into installed agent (default: true)
83
- */
84
- installAgent(agentId: string, injectPreferences?: boolean): Promise<string>;
85
- /**
86
- * Install a custom agent from a local file path
87
- * @param agentId Unique identifier for the custom agent
88
- * @param sourcePath Absolute path to agent YAML file or directory
89
- * @param metadata Agent metadata (name for display, description, author, tags, main)
90
- * @param injectPreferences Whether to inject global preferences (default: true)
91
- * @returns Path to the installed agent's main config file
92
- */
93
- installCustomAgentFromPath(agentId: string, sourcePath: string, metadata: {
94
- name?: string;
95
- description: string;
96
- author: string;
97
- tags: string[];
98
- main?: string;
99
- }, injectPreferences?: boolean): Promise<string>;
100
- /**
101
- * Resolve a registry agent ID to a config path
102
- * NOTE: Only handles registry IDs, not file paths (routing done in loadAgentConfig)
103
- * Handles installing agent if needed
104
- * @param agentId ID of the agent to resolve
105
- * @param autoInstall Whether to automatically install missing agents from registry (default: true)
106
- * @param injectPreferences Whether to inject preferences during auto-installation (default: true)
107
- */
108
- resolveAgent(agentId: string, autoInstall?: boolean, injectPreferences?: boolean): Promise<string>;
109
- /**
110
- * Get list of currently installed agents
111
- */
112
- getInstalledAgents(): Promise<string[]>;
113
- /**
114
- * Check if an agent is safe to uninstall (not the default agent from preferences)
115
- */
116
- private isAgentSafeToUninstall;
117
- /**
118
- * Uninstall an agent by removing its directory
119
- * For custom agents: also removes from user registry
120
- * For builtin agents: only removes from disk
121
- * @param agentId ID of the agent to uninstall
122
- * @param force Whether to force uninstall even if agent is protected (default: false)
123
- */
124
- uninstallAgent(agentId: string, force?: boolean): Promise<void>;
125
- }
126
- /**
127
- * Get cached registry instance (singleton pattern)
128
- */
129
- export declare function getAgentRegistry(): LocalAgentRegistry;
130
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/agent/registry/registry.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,QAAQ,EAER,aAAa,EACb,kBAAkB,EAErB,MAAM,YAAY,CAAC;AAYpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IACpD,OAAO,CAAC,SAAS,CAAyB;IAE1C;;OAEG;IACH,WAAW,IAAI,QAAQ;IAOvB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAyCpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAKlC;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAKxD;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAgC7B;;;OAGG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAqC5D;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,iBAAiB,GAAE,OAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAqGvF;;;;;;;OAOG;IACG,0BAA0B,CAC5B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,EACD,iBAAiB,GAAE,OAAc,GAClC,OAAO,CAAC,MAAM,CAAC;IAqKlB;;;;;;;OAOG;IACG,YAAY,CACd,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,OAAc,EAC3B,iBAAiB,GAAE,OAAc,GAClC,OAAO,CAAC,MAAM,CAAC;IAsClB;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAsB7C;;OAEG;YACW,sBAAsB;IAYpC;;;;;;OAMG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CA8C/E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,kBAAkB,CAKrD"}