@dexto/core 1.1.11 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (416) hide show
  1. package/README.md +24 -4
  2. package/dist/Dexto.cjs +4 -14
  3. package/dist/Dexto.d.ts +8 -29
  4. package/dist/Dexto.d.ts.map +1 -1
  5. package/dist/Dexto.js +4 -12
  6. package/dist/agent/DextoAgent.cjs +92 -3
  7. package/dist/agent/DextoAgent.d.ts +12 -4
  8. package/dist/agent/DextoAgent.d.ts.map +1 -1
  9. package/dist/agent/DextoAgent.js +52 -3
  10. package/dist/agent/agentCard.js +1 -0
  11. package/dist/agent/error-codes.cjs +1 -0
  12. package/dist/agent/error-codes.d.ts +1 -0
  13. package/dist/agent/error-codes.d.ts.map +1 -1
  14. package/dist/agent/error-codes.js +2 -0
  15. package/dist/agent/errors.cjs +13 -0
  16. package/dist/agent/errors.d.ts +4 -0
  17. package/dist/agent/errors.d.ts.map +1 -1
  18. package/dist/agent/errors.js +14 -0
  19. package/dist/agent/index.js +1 -0
  20. package/dist/agent/registry/error-codes.js +1 -0
  21. package/dist/agent/registry/errors.js +1 -0
  22. package/dist/agent/registry/registry.js +1 -0
  23. package/dist/agent/registry/types.js +1 -0
  24. package/dist/agent/registry/user-registry.js +1 -0
  25. package/dist/agent/schemas.cjs +6 -1
  26. package/dist/agent/schemas.d.ts +113 -3
  27. package/dist/agent/schemas.d.ts.map +1 -1
  28. package/dist/agent/schemas.js +7 -1
  29. package/dist/agent/state-manager.js +1 -0
  30. package/dist/approval/error-codes.js +1 -0
  31. package/dist/approval/errors.js +1 -0
  32. package/dist/approval/index.js +1 -0
  33. package/dist/approval/manager.cjs +30 -0
  34. package/dist/approval/manager.d.ts +23 -1
  35. package/dist/approval/manager.d.ts.map +1 -1
  36. package/dist/approval/manager.js +31 -0
  37. package/dist/approval/providers/event-based-approval-provider.js +1 -0
  38. package/dist/approval/providers/factory.js +1 -0
  39. package/dist/approval/providers/noop-approval-provider.js +1 -0
  40. package/dist/approval/schemas.cjs +36 -0
  41. package/dist/approval/schemas.d.ts +173 -0
  42. package/dist/approval/schemas.d.ts.map +1 -1
  43. package/dist/approval/schemas.js +33 -0
  44. package/dist/approval/types.cjs +1 -0
  45. package/dist/approval/types.d.ts +27 -1
  46. package/dist/approval/types.d.ts.map +1 -1
  47. package/dist/approval/types.js +2 -0
  48. package/dist/chunk-C6A6W6XS.js +53 -0
  49. package/dist/config/agent-resolver.js +1 -0
  50. package/dist/config/error-codes.js +1 -0
  51. package/dist/config/errors.js +1 -0
  52. package/dist/config/loader.js +1 -0
  53. package/dist/config/writer.js +1 -0
  54. package/dist/context/compression/middle-removal.js +1 -0
  55. package/dist/context/compression/oldest-removal.js +1 -0
  56. package/dist/context/error-codes.js +1 -0
  57. package/dist/context/errors.js +1 -0
  58. package/dist/context/index.js +1 -0
  59. package/dist/context/manager.cjs +36 -1
  60. package/dist/context/manager.d.ts.map +1 -1
  61. package/dist/context/manager.js +27 -1
  62. package/dist/context/media-helpers.js +1 -0
  63. package/dist/context/utils.cjs +102 -6
  64. package/dist/context/utils.d.ts +35 -2
  65. package/dist/context/utils.d.ts.map +1 -1
  66. package/dist/context/utils.js +100 -6
  67. package/dist/errors/DextoBaseError.js +1 -0
  68. package/dist/errors/DextoRuntimeError.js +1 -0
  69. package/dist/errors/DextoValidationError.js +1 -0
  70. package/dist/errors/index.js +1 -0
  71. package/dist/errors/result-bridge.js +1 -0
  72. package/dist/errors/types.cjs +3 -0
  73. package/dist/errors/types.d.ts +7 -2
  74. package/dist/errors/types.d.ts.map +1 -1
  75. package/dist/errors/types.js +4 -0
  76. package/dist/events/index.cjs +1 -0
  77. package/dist/events/index.d.ts +6 -2
  78. package/dist/events/index.d.ts.map +1 -1
  79. package/dist/events/index.js +2 -0
  80. package/dist/filesystem/error-codes.cjs +53 -0
  81. package/dist/filesystem/error-codes.d.ts +31 -0
  82. package/dist/filesystem/error-codes.d.ts.map +1 -0
  83. package/dist/filesystem/error-codes.js +30 -0
  84. package/dist/filesystem/errors.cjs +303 -0
  85. package/dist/filesystem/errors.d.ts +109 -0
  86. package/dist/filesystem/errors.d.ts.map +1 -0
  87. package/dist/filesystem/errors.js +280 -0
  88. package/dist/filesystem/filesystem-service.cjs +482 -0
  89. package/dist/filesystem/filesystem-service.d.ts +57 -0
  90. package/dist/filesystem/filesystem-service.d.ts.map +1 -0
  91. package/dist/filesystem/filesystem-service.js +449 -0
  92. package/dist/filesystem/index.cjs +37 -0
  93. package/dist/filesystem/index.d.ts +11 -0
  94. package/dist/filesystem/index.d.ts.map +1 -0
  95. package/dist/filesystem/index.js +11 -0
  96. package/dist/filesystem/path-validator.cjs +172 -0
  97. package/dist/filesystem/path-validator.d.ts +53 -0
  98. package/dist/filesystem/path-validator.d.ts.map +1 -0
  99. package/dist/filesystem/path-validator.js +139 -0
  100. package/dist/filesystem/types.cjs +16 -0
  101. package/dist/filesystem/types.d.ts +171 -0
  102. package/dist/filesystem/types.d.ts.map +1 -0
  103. package/dist/filesystem/types.js +0 -0
  104. package/dist/index.browser.js +1 -0
  105. package/dist/index.cjs +3 -3
  106. package/dist/index.d.ts +2 -1
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +3 -2
  109. package/dist/llm/error-codes.js +1 -0
  110. package/dist/llm/errors.js +1 -0
  111. package/dist/llm/formatters/anthropic.js +1 -0
  112. package/dist/llm/formatters/factory.js +1 -0
  113. package/dist/llm/formatters/openai.js +1 -0
  114. package/dist/llm/formatters/vercel.js +1 -0
  115. package/dist/llm/registry.cjs +15 -15
  116. package/dist/llm/registry.d.ts +1 -1
  117. package/dist/llm/registry.js +16 -15
  118. package/dist/llm/resolver.js +1 -0
  119. package/dist/llm/schemas.cjs +6 -2
  120. package/dist/llm/schemas.d.ts +10 -0
  121. package/dist/llm/schemas.d.ts.map +1 -1
  122. package/dist/llm/schemas.js +7 -2
  123. package/dist/llm/services/anthropic.cjs +67 -0
  124. package/dist/llm/services/anthropic.d.ts +6 -0
  125. package/dist/llm/services/anthropic.d.ts.map +1 -1
  126. package/dist/llm/services/anthropic.js +27 -0
  127. package/dist/llm/services/factory.js +1 -0
  128. package/dist/llm/services/openai.cjs +87 -0
  129. package/dist/llm/services/openai.d.ts +6 -0
  130. package/dist/llm/services/openai.d.ts.map +1 -1
  131. package/dist/llm/services/openai.js +47 -0
  132. package/dist/llm/services/test-utils.integration.cjs +1 -1
  133. package/dist/llm/services/test-utils.integration.js +2 -1
  134. package/dist/llm/services/vercel.cjs +144 -97
  135. package/dist/llm/services/vercel.d.ts +6 -1
  136. package/dist/llm/services/vercel.d.ts.map +1 -1
  137. package/dist/llm/services/vercel.js +105 -98
  138. package/dist/llm/tokenizer/anthropic.js +1 -0
  139. package/dist/llm/tokenizer/default.js +1 -0
  140. package/dist/llm/tokenizer/factory.js +1 -0
  141. package/dist/llm/tokenizer/google.js +1 -0
  142. package/dist/llm/tokenizer/openai.cjs +1 -1
  143. package/dist/llm/tokenizer/openai.d.ts +1 -1
  144. package/dist/llm/tokenizer/openai.js +2 -1
  145. package/dist/llm/tokenizer/types.js +1 -0
  146. package/dist/llm/types.d.ts +2 -2
  147. package/dist/llm/types.d.ts.map +1 -1
  148. package/dist/llm/types.js +1 -0
  149. package/dist/llm/validation.js +1 -0
  150. package/dist/logger/browser.js +1 -0
  151. package/dist/logger/logger.d.ts +42 -0
  152. package/dist/logger/logger.d.ts.map +1 -1
  153. package/dist/logger/logger.js +1 -0
  154. package/dist/mcp/error-codes.cjs +1 -0
  155. package/dist/mcp/error-codes.d.ts +1 -0
  156. package/dist/mcp/error-codes.d.ts.map +1 -1
  157. package/dist/mcp/error-codes.js +2 -0
  158. package/dist/mcp/errors.cjs +12 -0
  159. package/dist/mcp/errors.d.ts +7 -0
  160. package/dist/mcp/errors.d.ts.map +1 -1
  161. package/dist/mcp/errors.js +13 -0
  162. package/dist/mcp/manager.cjs +66 -16
  163. package/dist/mcp/manager.d.ts +7 -0
  164. package/dist/mcp/manager.d.ts.map +1 -1
  165. package/dist/mcp/manager.js +67 -16
  166. package/dist/mcp/mcp-client.js +1 -0
  167. package/dist/mcp/resolver.js +1 -0
  168. package/dist/mcp/schemas.js +1 -0
  169. package/dist/mcp/types.d.ts +1 -1
  170. package/dist/mcp/types.d.ts.map +1 -1
  171. package/dist/memory/error-codes.js +1 -0
  172. package/dist/memory/errors.js +1 -0
  173. package/dist/memory/index.js +1 -0
  174. package/dist/memory/manager.js +1 -0
  175. package/dist/memory/schemas.js +1 -0
  176. package/dist/plugins/builtins/content-policy.js +1 -0
  177. package/dist/plugins/builtins/response-sanitizer.js +1 -0
  178. package/dist/plugins/error-codes.js +1 -0
  179. package/dist/plugins/index.js +1 -0
  180. package/dist/plugins/loader.js +1 -0
  181. package/dist/plugins/manager.js +1 -0
  182. package/dist/plugins/registrations/builtins.js +1 -0
  183. package/dist/plugins/schemas.js +1 -0
  184. package/dist/preferences/constants.js +1 -0
  185. package/dist/preferences/error-codes.js +1 -0
  186. package/dist/preferences/errors.js +1 -0
  187. package/dist/preferences/index.js +1 -0
  188. package/dist/preferences/loader.cjs +3 -1
  189. package/dist/preferences/loader.d.ts +10 -1
  190. package/dist/preferences/loader.d.ts.map +1 -1
  191. package/dist/preferences/loader.js +4 -1
  192. package/dist/preferences/schemas.cjs +2 -1
  193. package/dist/preferences/schemas.d.ts +8 -0
  194. package/dist/preferences/schemas.d.ts.map +1 -1
  195. package/dist/preferences/schemas.js +3 -1
  196. package/dist/process/command-validator.cjs +544 -0
  197. package/dist/process/command-validator.d.ts +46 -0
  198. package/dist/process/command-validator.d.ts.map +1 -0
  199. package/dist/process/command-validator.js +521 -0
  200. package/dist/process/error-codes.cjs +47 -0
  201. package/dist/process/error-codes.d.ts +25 -0
  202. package/dist/process/error-codes.d.ts.map +1 -0
  203. package/dist/process/error-codes.js +24 -0
  204. package/dist/process/errors.cjs +244 -0
  205. package/dist/process/errors.d.ts +87 -0
  206. package/dist/process/errors.d.ts.map +1 -0
  207. package/dist/process/errors.js +221 -0
  208. package/dist/process/index.cjs +37 -0
  209. package/dist/process/index.d.ts +11 -0
  210. package/dist/process/index.d.ts.map +1 -0
  211. package/dist/process/index.js +11 -0
  212. package/dist/process/process-service.cjs +443 -0
  213. package/dist/process/process-service.d.ts +62 -0
  214. package/dist/process/process-service.d.ts.map +1 -0
  215. package/dist/process/process-service.js +410 -0
  216. package/dist/process/types.cjs +16 -0
  217. package/dist/process/types.d.ts +107 -0
  218. package/dist/process/types.d.ts.map +1 -0
  219. package/dist/process/types.js +0 -0
  220. package/dist/prompts/error-codes.js +1 -0
  221. package/dist/prompts/errors.js +1 -0
  222. package/dist/prompts/index.js +1 -0
  223. package/dist/prompts/name-validation.js +1 -0
  224. package/dist/prompts/prompt-manager.js +1 -0
  225. package/dist/prompts/providers/custom-prompt-provider.js +1 -0
  226. package/dist/prompts/providers/file-prompt-provider.js +1 -0
  227. package/dist/prompts/providers/mcp-prompt-provider.js +1 -0
  228. package/dist/prompts/providers/starter-prompt-provider.js +1 -0
  229. package/dist/prompts/schemas.js +1 -0
  230. package/dist/prompts/utils.js +1 -0
  231. package/dist/resources/error-codes.js +1 -0
  232. package/dist/resources/errors.js +1 -0
  233. package/dist/resources/handlers/blob-handler.js +1 -0
  234. package/dist/resources/handlers/factory.js +1 -0
  235. package/dist/resources/handlers/filesystem-handler.cjs +1 -1
  236. package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
  237. package/dist/resources/handlers/filesystem-handler.js +2 -1
  238. package/dist/resources/index.js +1 -0
  239. package/dist/resources/internal-provider.js +1 -0
  240. package/dist/resources/manager.js +1 -0
  241. package/dist/resources/reference-parser.js +1 -0
  242. package/dist/resources/schemas.js +1 -0
  243. package/dist/search/index.js +1 -0
  244. package/dist/search/search-service.js +1 -0
  245. package/dist/session/chat-session.cjs +2 -2
  246. package/dist/session/chat-session.d.ts +2 -2
  247. package/dist/session/chat-session.js +3 -2
  248. package/dist/session/error-codes.js +1 -0
  249. package/dist/session/errors.js +1 -0
  250. package/dist/session/history/database.js +1 -0
  251. package/dist/session/history/factory.js +1 -0
  252. package/dist/session/history/memory.js +1 -0
  253. package/dist/session/index.js +1 -0
  254. package/dist/session/schemas.js +1 -0
  255. package/dist/session/session-manager.d.ts +6 -0
  256. package/dist/session/session-manager.d.ts.map +1 -1
  257. package/dist/session/session-manager.js +1 -0
  258. package/dist/session/title-generator.js +1 -0
  259. package/dist/storage/blob/factory.cjs +3 -3
  260. package/dist/storage/blob/factory.d.ts +3 -1
  261. package/dist/storage/blob/factory.d.ts.map +1 -1
  262. package/dist/storage/blob/factory.js +4 -3
  263. package/dist/storage/blob/local-blob-store.cjs +18 -2
  264. package/dist/storage/blob/local-blob-store.d.ts +2 -1
  265. package/dist/storage/blob/local-blob-store.d.ts.map +1 -1
  266. package/dist/storage/blob/local-blob-store.js +19 -2
  267. package/dist/storage/blob/schemas.js +1 -0
  268. package/dist/storage/cache/factory.js +1 -0
  269. package/dist/storage/cache/memory-cache-store.js +1 -0
  270. package/dist/storage/cache/redis-store.js +1 -0
  271. package/dist/storage/cache/schemas.js +1 -0
  272. package/dist/storage/database/factory.cjs +7 -5
  273. package/dist/storage/database/factory.d.ts +3 -1
  274. package/dist/storage/database/factory.d.ts.map +1 -1
  275. package/dist/storage/database/factory.js +8 -5
  276. package/dist/storage/database/memory-database-store.js +1 -0
  277. package/dist/storage/database/postgres-store.js +1 -0
  278. package/dist/storage/database/schemas.cjs +1 -1
  279. package/dist/storage/database/schemas.js +2 -1
  280. package/dist/storage/database/sqlite-store.cjs +20 -2
  281. package/dist/storage/database/sqlite-store.d.ts +2 -1
  282. package/dist/storage/database/sqlite-store.d.ts.map +1 -1
  283. package/dist/storage/database/sqlite-store.js +21 -2
  284. package/dist/storage/error-codes.cjs +1 -0
  285. package/dist/storage/error-codes.d.ts +1 -0
  286. package/dist/storage/error-codes.d.ts.map +1 -1
  287. package/dist/storage/error-codes.js +2 -0
  288. package/dist/storage/errors.cjs +15 -0
  289. package/dist/storage/errors.d.ts +4 -0
  290. package/dist/storage/errors.d.ts.map +1 -1
  291. package/dist/storage/errors.js +16 -0
  292. package/dist/storage/index.js +1 -0
  293. package/dist/storage/schemas.js +1 -0
  294. package/dist/storage/storage-manager.cjs +7 -5
  295. package/dist/storage/storage-manager.d.ts +5 -2
  296. package/dist/storage/storage-manager.d.ts.map +1 -1
  297. package/dist/storage/storage-manager.js +8 -5
  298. package/dist/systemPrompt/contributors.js +1 -0
  299. package/dist/systemPrompt/error-codes.js +1 -0
  300. package/dist/systemPrompt/errors.js +1 -0
  301. package/dist/systemPrompt/in-built-prompts.js +1 -0
  302. package/dist/systemPrompt/index.js +1 -0
  303. package/dist/systemPrompt/manager.js +1 -0
  304. package/dist/systemPrompt/registry.js +1 -0
  305. package/dist/systemPrompt/schemas.js +1 -0
  306. package/dist/telemetry/decorators.cjs +175 -0
  307. package/dist/telemetry/decorators.d.ts +17 -0
  308. package/dist/telemetry/decorators.d.ts.map +1 -0
  309. package/dist/telemetry/decorators.js +157 -0
  310. package/dist/telemetry/exporters.cjs +108 -0
  311. package/dist/telemetry/exporters.d.ts +29 -0
  312. package/dist/telemetry/exporters.d.ts.map +1 -0
  313. package/dist/telemetry/exporters.js +85 -0
  314. package/dist/telemetry/index.cjs +28 -0
  315. package/dist/telemetry/index.d.ts +2 -0
  316. package/dist/telemetry/index.d.ts.map +1 -0
  317. package/dist/telemetry/index.js +5 -0
  318. package/dist/telemetry/schemas.cjs +71 -0
  319. package/dist/telemetry/schemas.d.ts +54 -0
  320. package/dist/telemetry/schemas.d.ts.map +1 -0
  321. package/dist/telemetry/schemas.js +48 -0
  322. package/dist/telemetry/telemetry.cjs +228 -0
  323. package/dist/telemetry/telemetry.d.ts +74 -0
  324. package/dist/telemetry/telemetry.d.ts.map +1 -0
  325. package/dist/telemetry/telemetry.js +205 -0
  326. package/dist/telemetry/types.cjs +16 -0
  327. package/dist/telemetry/types.d.ts +22 -0
  328. package/dist/telemetry/types.d.ts.map +1 -0
  329. package/dist/telemetry/types.js +0 -0
  330. package/dist/telemetry/utils.cjs +87 -0
  331. package/dist/telemetry/utils.d.ts +21 -0
  332. package/dist/telemetry/utils.d.ts.map +1 -0
  333. package/dist/telemetry/utils.js +62 -0
  334. package/dist/tools/confirmation/allowed-tools-provider/factory.js +1 -0
  335. package/dist/tools/confirmation/allowed-tools-provider/in-memory.js +1 -0
  336. package/dist/tools/confirmation/allowed-tools-provider/storage.js +1 -0
  337. package/dist/tools/error-codes.js +1 -0
  338. package/dist/tools/errors.js +1 -0
  339. package/dist/tools/index.js +1 -0
  340. package/dist/tools/internal-tools/constants.cjs +39 -0
  341. package/dist/tools/internal-tools/constants.d.ts +12 -0
  342. package/dist/tools/internal-tools/constants.d.ts.map +1 -0
  343. package/dist/tools/internal-tools/constants.js +16 -0
  344. package/dist/tools/internal-tools/implementations/ask-user-tool.js +1 -0
  345. package/dist/tools/internal-tools/implementations/bash-exec-tool.cjs +106 -0
  346. package/dist/tools/internal-tools/implementations/bash-exec-tool.d.ts +13 -0
  347. package/dist/tools/internal-tools/implementations/bash-exec-tool.d.ts.map +1 -0
  348. package/dist/tools/internal-tools/implementations/bash-exec-tool.js +73 -0
  349. package/dist/tools/internal-tools/implementations/bash-output-tool.cjs +49 -0
  350. package/dist/tools/internal-tools/implementations/bash-output-tool.d.ts +12 -0
  351. package/dist/tools/internal-tools/implementations/bash-output-tool.d.ts.map +1 -0
  352. package/dist/tools/internal-tools/implementations/bash-output-tool.js +26 -0
  353. package/dist/tools/internal-tools/implementations/edit-file-tool.cjs +62 -0
  354. package/dist/tools/internal-tools/implementations/edit-file-tool.d.ts +12 -0
  355. package/dist/tools/internal-tools/implementations/edit-file-tool.d.ts.map +1 -0
  356. package/dist/tools/internal-tools/implementations/edit-file-tool.js +39 -0
  357. package/dist/tools/internal-tools/implementations/glob-files-tool.cjs +57 -0
  358. package/dist/tools/internal-tools/implementations/glob-files-tool.d.ts +12 -0
  359. package/dist/tools/internal-tools/implementations/glob-files-tool.d.ts.map +1 -0
  360. package/dist/tools/internal-tools/implementations/glob-files-tool.js +34 -0
  361. package/dist/tools/internal-tools/implementations/grep-content-tool.cjs +71 -0
  362. package/dist/tools/internal-tools/implementations/grep-content-tool.d.ts +12 -0
  363. package/dist/tools/internal-tools/implementations/grep-content-tool.d.ts.map +1 -0
  364. package/dist/tools/internal-tools/implementations/grep-content-tool.js +48 -0
  365. package/dist/tools/internal-tools/implementations/kill-process-tool.cjs +47 -0
  366. package/dist/tools/internal-tools/implementations/kill-process-tool.d.ts +12 -0
  367. package/dist/tools/internal-tools/implementations/kill-process-tool.d.ts.map +1 -0
  368. package/dist/tools/internal-tools/implementations/kill-process-tool.js +24 -0
  369. package/dist/tools/internal-tools/implementations/read-file-tool.cjs +55 -0
  370. package/dist/tools/internal-tools/implementations/read-file-tool.d.ts +12 -0
  371. package/dist/tools/internal-tools/implementations/read-file-tool.d.ts.map +1 -0
  372. package/dist/tools/internal-tools/implementations/read-file-tool.js +32 -0
  373. package/dist/tools/internal-tools/implementations/search-history-tool.js +1 -0
  374. package/dist/tools/internal-tools/implementations/write-file-tool.cjs +56 -0
  375. package/dist/tools/internal-tools/implementations/write-file-tool.d.ts +12 -0
  376. package/dist/tools/internal-tools/implementations/write-file-tool.d.ts.map +1 -0
  377. package/dist/tools/internal-tools/implementations/write-file-tool.js +33 -0
  378. package/dist/tools/internal-tools/index.cjs +3 -1
  379. package/dist/tools/internal-tools/index.d.ts +1 -0
  380. package/dist/tools/internal-tools/index.d.ts.map +1 -1
  381. package/dist/tools/internal-tools/index.js +1 -0
  382. package/dist/tools/internal-tools/provider.js +1 -0
  383. package/dist/tools/internal-tools/registry.cjs +40 -4
  384. package/dist/tools/internal-tools/registry.d.ts +5 -9
  385. package/dist/tools/internal-tools/registry.d.ts.map +1 -1
  386. package/dist/tools/internal-tools/registry.js +41 -3
  387. package/dist/tools/schemas.cjs +18 -5
  388. package/dist/tools/schemas.d.ts +30 -1
  389. package/dist/tools/schemas.d.ts.map +1 -1
  390. package/dist/tools/schemas.js +15 -2
  391. package/dist/tools/tool-manager.cjs +158 -19
  392. package/dist/tools/tool-manager.d.ts +48 -2
  393. package/dist/tools/tool-manager.d.ts.map +1 -1
  394. package/dist/tools/tool-manager.js +118 -19
  395. package/dist/utils/api-key-resolver.js +1 -0
  396. package/dist/utils/api-key-store.js +1 -0
  397. package/dist/utils/async-context.js +1 -0
  398. package/dist/utils/debug.js +1 -0
  399. package/dist/utils/env.js +1 -0
  400. package/dist/utils/error-conversion.js +1 -0
  401. package/dist/utils/execution-context.js +1 -0
  402. package/dist/utils/fs-walk.js +1 -0
  403. package/dist/utils/path.js +1 -0
  404. package/dist/utils/port-utils.js +1 -0
  405. package/dist/utils/redactor.js +1 -0
  406. package/dist/utils/result.js +1 -0
  407. package/dist/utils/safe-stringify.js +1 -0
  408. package/dist/utils/schema-metadata.js +1 -0
  409. package/dist/utils/schema.js +1 -0
  410. package/dist/utils/service-initializer.cjs +42 -4
  411. package/dist/utils/service-initializer.d.ts +2 -1
  412. package/dist/utils/service-initializer.d.ts.map +1 -1
  413. package/dist/utils/service-initializer.js +33 -4
  414. package/dist/utils/user-info.js +1 -0
  415. package/dist/utils/zod-schema-converter.js +1 -0
  416. package/package.json +11 -1
@@ -0,0 +1,544 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var command_validator_exports = {};
20
+ __export(command_validator_exports, {
21
+ CommandValidator: () => CommandValidator
22
+ });
23
+ module.exports = __toCommonJS(command_validator_exports);
24
+ var import_logger = require("../logger/index.js");
25
+ const MAX_COMMAND_LENGTH = 1e4;
26
+ const DANGEROUS_PATTERNS = [
27
+ // File system destruction
28
+ /rm\s+-rf\s+\//,
29
+ // rm -rf /
30
+ /rm\s+-rf\s+\/\s*$/,
31
+ // rm -rf / (end of line)
32
+ /rm\s+-rf\s+\/\s*2/,
33
+ // rm -rf / 2>/dev/null (with error suppression)
34
+ // Fork bomb variations
35
+ /:\(\)\{\s*:\|:&\s*\};:/,
36
+ // Classic fork bomb
37
+ /:\(\)\{\s*:\|:&\s*\};/,
38
+ // Fork bomb without final colon
39
+ /:\(\)\{\s*:\|:&\s*\}/,
40
+ // Fork bomb without semicolon
41
+ // Disk operations
42
+ /dd\s+if=.*of=\/dev\//,
43
+ // dd to disk devices
44
+ /dd\s+if=\/dev\/zero.*of=\/dev\//,
45
+ // dd zero to disk
46
+ /dd\s+if=\/dev\/urandom.*of=\/dev\//,
47
+ // dd random to disk
48
+ />\s*\/dev\/sd[a-z]/,
49
+ // Write to disk devices
50
+ />>\s*\/dev\/sd[a-z]/,
51
+ // Append to disk devices
52
+ // Filesystem operations
53
+ /mkfs\./,
54
+ // Format filesystem
55
+ /mkfs\s+/,
56
+ // Format filesystem with space
57
+ /fdisk\s+\/dev\/sd[a-z]/,
58
+ // Partition disk
59
+ /parted\s+\/dev\/sd[a-z]/,
60
+ // Partition disk with parted
61
+ // Download and execute patterns
62
+ /wget.*\|\s*sh/,
63
+ // wget | sh
64
+ /wget.*\|\s*bash/,
65
+ // wget | bash
66
+ /curl.*\|\s*sh/,
67
+ // curl | sh
68
+ /curl.*\|\s*bash/,
69
+ // curl | bash
70
+ /wget.*\|\s*python/,
71
+ // wget | python
72
+ /curl.*\|\s*python/,
73
+ // curl | python
74
+ // Shell execution
75
+ /\|\s*bash/,
76
+ // Pipe to bash
77
+ /\|\s*sh/,
78
+ // Pipe to sh
79
+ /\|\s*zsh/,
80
+ // Pipe to zsh
81
+ /\|\s*fish/,
82
+ // Pipe to fish
83
+ // Command evaluation
84
+ /eval\s+\$\(/,
85
+ // eval $()
86
+ /eval\s+`/,
87
+ // eval backticks
88
+ /eval\s+"/,
89
+ // eval double quotes
90
+ /eval\s+'/,
91
+ // eval single quotes
92
+ // Permission changes
93
+ /chmod\s+777\s+\//,
94
+ // chmod 777 /
95
+ /chmod\s+777\s+\/\s*$/,
96
+ // chmod 777 / (end of line)
97
+ /chmod\s+-R\s+777\s+\//,
98
+ // chmod -R 777 /
99
+ /chown\s+-R\s+root\s+\//,
100
+ // chown -R root /
101
+ // Network operations
102
+ /nc\s+-l\s+-p\s+\d+/,
103
+ // netcat listener
104
+ /ncat\s+-l\s+-p\s+\d+/,
105
+ // ncat listener
106
+ /socat\s+.*LISTEN/,
107
+ // socat listener
108
+ // Process manipulation
109
+ /killall\s+-9/,
110
+ // killall -9
111
+ /pkill\s+-9/,
112
+ // pkill -9
113
+ /kill\s+-9\s+-1/,
114
+ // kill -9 -1 (kill all processes)
115
+ // System shutdown/reboot
116
+ /shutdown\s+now/,
117
+ // shutdown now
118
+ /reboot/,
119
+ // reboot
120
+ /halt/,
121
+ // halt
122
+ /poweroff/,
123
+ // poweroff
124
+ // Memory operations
125
+ /echo\s+3\s*>\s*\/proc\/sys\/vm\/drop_caches/,
126
+ // Clear page cache
127
+ /sync\s*;\s*echo\s+3\s*>\s*\/proc\/sys\/vm\/drop_caches/,
128
+ // Sync and clear cache
129
+ // Network interface manipulation
130
+ /ifconfig\s+.*down/,
131
+ // Bring interface down
132
+ /ip\s+link\s+set\s+.*down/,
133
+ // Bring interface down with ip
134
+ // Package manager operations
135
+ /apt\s+remove\s+--purge\s+.*/,
136
+ // Remove packages
137
+ /yum\s+remove\s+.*/,
138
+ // Remove packages
139
+ /dnf\s+remove\s+.*/,
140
+ // Remove packages
141
+ /pacman\s+-R\s+.*/
142
+ // Remove packages
143
+ ];
144
+ const INJECTION_PATTERNS = [
145
+ // Command chaining with dangerous commands
146
+ /;\s*rm\s+-rf/,
147
+ // ; rm -rf
148
+ /&&\s*rm\s+-rf/,
149
+ // && rm -rf
150
+ /\|\s*rm\s+-rf/,
151
+ // | rm -rf
152
+ /;\s*chmod\s+777/,
153
+ // ; chmod 777
154
+ /&&\s*chmod\s+777/,
155
+ // && chmod 777
156
+ /;\s*chown\s+root/,
157
+ // ; chown root
158
+ /&&\s*chown\s+root/,
159
+ // && chown root
160
+ // Command substitution with dangerous commands
161
+ /`.*rm.*`/,
162
+ // backticks with rm
163
+ /\$\(.*rm.*\)/,
164
+ // $() with rm
165
+ /`.*chmod.*`/,
166
+ // backticks with chmod
167
+ /\$\(.*chmod.*\)/,
168
+ // $() with chmod
169
+ /`.*chown.*`/,
170
+ // backticks with chown
171
+ /\$\(.*chown.*\)/,
172
+ // $() with chown
173
+ // Multiple command separators
174
+ /;\s*;\s*/,
175
+ // Multiple semicolons
176
+ /&&\s*&&\s*/,
177
+ // Multiple && operators
178
+ /\|\|\s*\|\|\s*/,
179
+ // Multiple || operators
180
+ // Redirection with dangerous commands
181
+ /rm\s+.*>\s*\/dev\/null/,
182
+ // rm with output redirection
183
+ /chmod\s+.*>\s*\/dev\/null/,
184
+ // chmod with output redirection
185
+ /chown\s+.*>\s*\/dev\/null/,
186
+ // chown with output redirection
187
+ // Environment variable manipulation
188
+ /\$[A-Z_]+\s*=\s*.*rm/,
189
+ // Environment variable with rm
190
+ /\$[A-Z_]+\s*=\s*.*chmod/,
191
+ // Environment variable with chmod
192
+ /\$[A-Z_]+\s*=\s*.*chown/
193
+ // Environment variable with chown
194
+ ];
195
+ const REQUIRES_APPROVAL_PATTERNS = [
196
+ // File operations
197
+ /^rm\s+/,
198
+ // rm (removal)
199
+ /^mv\s+/,
200
+ // move files
201
+ /^cp\s+/,
202
+ // copy files
203
+ /^chmod\s+/,
204
+ // chmod
205
+ /^chown\s+/,
206
+ // chown
207
+ /^chgrp\s+/,
208
+ // chgrp
209
+ /^ln\s+/,
210
+ // create links
211
+ /^unlink\s+/,
212
+ // unlink files
213
+ // Git operations
214
+ /^git\s+push/,
215
+ // git push
216
+ /^git\s+commit/,
217
+ // git commit
218
+ /^git\s+reset/,
219
+ // git reset
220
+ /^git\s+rebase/,
221
+ // git rebase
222
+ /^git\s+merge/,
223
+ // git merge
224
+ /^git\s+checkout/,
225
+ // git checkout
226
+ /^git\s+branch/,
227
+ // git branch
228
+ /^git\s+tag/,
229
+ // git tag
230
+ // Package management
231
+ /^npm\s+publish/,
232
+ // npm publish
233
+ /^npm\s+uninstall/,
234
+ // npm uninstall
235
+ /^yarn\s+publish/,
236
+ // yarn publish
237
+ /^yarn\s+remove/,
238
+ // yarn remove
239
+ /^pip\s+install/,
240
+ // pip install
241
+ /^pip\s+uninstall/,
242
+ // pip uninstall
243
+ /^apt\s+install/,
244
+ // apt install
245
+ /^apt\s+remove/,
246
+ // apt remove
247
+ /^yum\s+install/,
248
+ // yum install
249
+ /^yum\s+remove/,
250
+ // yum remove
251
+ /^dnf\s+install/,
252
+ // dnf install
253
+ /^dnf\s+remove/,
254
+ // dnf remove
255
+ /^pacman\s+-S/,
256
+ // pacman install
257
+ /^pacman\s+-R/,
258
+ // pacman remove
259
+ // Container operations
260
+ /^docker\s+/,
261
+ // docker commands
262
+ /^podman\s+/,
263
+ // podman commands
264
+ /^kubectl\s+/,
265
+ // kubectl commands
266
+ // System operations
267
+ /^sudo\s+/,
268
+ // sudo commands
269
+ /^su\s+/,
270
+ // su commands
271
+ /^systemctl\s+/,
272
+ // systemctl commands
273
+ /^service\s+/,
274
+ // service commands
275
+ /^mount\s+/,
276
+ // mount commands
277
+ /^umount\s+/,
278
+ // umount commands
279
+ /^fdisk\s+/,
280
+ // fdisk commands
281
+ /^parted\s+/,
282
+ // parted commands
283
+ /^mkfs\s+/,
284
+ // mkfs commands
285
+ /^fsck\s+/,
286
+ // fsck commands
287
+ // Network operations
288
+ /^iptables\s+/,
289
+ // iptables commands
290
+ /^ufw\s+/,
291
+ // ufw commands
292
+ /^firewall-cmd\s+/,
293
+ // firewall-cmd commands
294
+ /^sshd\s+/,
295
+ // sshd commands
296
+ /^ssh\s+/,
297
+ // ssh commands
298
+ /^scp\s+/,
299
+ // scp commands
300
+ /^rsync\s+/,
301
+ // rsync commands
302
+ // Process management
303
+ /^kill\s+/,
304
+ // kill commands
305
+ /^killall\s+/,
306
+ // killall commands
307
+ /^pkill\s+/,
308
+ // pkill commands
309
+ /^nohup\s+/,
310
+ // nohup commands
311
+ /^screen\s+/,
312
+ // screen commands
313
+ /^tmux\s+/,
314
+ // tmux commands
315
+ // Database operations
316
+ /^mysql\s+/,
317
+ // mysql commands
318
+ /^psql\s+/,
319
+ // psql commands
320
+ /^sqlite3\s+/,
321
+ // sqlite3 commands
322
+ /^mongodb\s+/,
323
+ // mongodb commands
324
+ /^redis-cli\s+/
325
+ // redis-cli commands
326
+ ];
327
+ const SAFE_PATTERNS = [
328
+ // Directory navigation with commands
329
+ /^cd\s+.*&&\s+\w+/,
330
+ // cd && command
331
+ /^cd\s+.*;\s+\w+/,
332
+ // cd ; command
333
+ // Safe pipe operations
334
+ /\|\s*grep/,
335
+ // | grep
336
+ /\|\s*head/,
337
+ // | head
338
+ /\|\s*tail/,
339
+ // | tail
340
+ /\|\s*sort/,
341
+ // | sort
342
+ /\|\s*uniq/,
343
+ // | uniq
344
+ /\|\s*wc/,
345
+ // | wc
346
+ /\|\s*cat/,
347
+ // | cat
348
+ /\|\s*less/,
349
+ // | less
350
+ /\|\s*more/,
351
+ // | more
352
+ /\|\s*awk/,
353
+ // | awk
354
+ /\|\s*sed/,
355
+ // | sed
356
+ /\|\s*cut/,
357
+ // | cut
358
+ /\|\s*tr/,
359
+ // | tr
360
+ /\|\s*xargs/,
361
+ // | xargs
362
+ // Safe redirection
363
+ /^ls\s+.*>/,
364
+ // ls with output redirection
365
+ /^find\s+.*>/,
366
+ // find with output redirection
367
+ /^grep\s+.*>/,
368
+ // grep with output redirection
369
+ /^cat\s+.*>/
370
+ // cat with output redirection
371
+ ];
372
+ const WRITE_PATTERNS = [
373
+ // Output redirection
374
+ />/,
375
+ // output redirection
376
+ />>/,
377
+ // append redirection
378
+ /2>/,
379
+ // error redirection
380
+ /2>>/,
381
+ // error append redirection
382
+ /&>/,
383
+ // both output and error redirection
384
+ /&>>/,
385
+ // both output and error append redirection
386
+ // File operations
387
+ /tee\s+/,
388
+ // tee command
389
+ /touch\s+/,
390
+ // touch command
391
+ /mkdir\s+/,
392
+ // mkdir command
393
+ /rmdir\s+/,
394
+ // rmdir command
395
+ // Text editors
396
+ /vim\s+/,
397
+ // vim command
398
+ /nano\s+/,
399
+ // nano command
400
+ /emacs\s+/,
401
+ // emacs command
402
+ /code\s+/,
403
+ // code command (VS Code)
404
+ // File copying and moving
405
+ /cp\s+/,
406
+ // cp command
407
+ /mv\s+/,
408
+ // mv command
409
+ /scp\s+/,
410
+ // scp command
411
+ /rsync\s+/
412
+ // rsync command
413
+ ];
414
+ class CommandValidator {
415
+ config;
416
+ constructor(config) {
417
+ this.config = config;
418
+ import_logger.logger.debug(`CommandValidator initialized with security level: ${config.securityLevel}`);
419
+ }
420
+ /**
421
+ * Validate a command for security and policy compliance
422
+ */
423
+ validateCommand(command) {
424
+ if (!command || command.trim() === "") {
425
+ return {
426
+ isValid: false,
427
+ error: "Command cannot be empty"
428
+ };
429
+ }
430
+ const trimmedCommand = command.trim();
431
+ if (trimmedCommand.length > MAX_COMMAND_LENGTH) {
432
+ return {
433
+ isValid: false,
434
+ error: `Command too long: ${trimmedCommand.length} characters. Maximum: ${MAX_COMMAND_LENGTH}`
435
+ };
436
+ }
437
+ if (this.config.securityLevel !== "permissive") {
438
+ for (const pattern of DANGEROUS_PATTERNS) {
439
+ if (pattern.test(trimmedCommand)) {
440
+ return {
441
+ isValid: false,
442
+ error: `Command matches dangerous pattern: ${pattern.source}`
443
+ };
444
+ }
445
+ }
446
+ }
447
+ const injectionResult = this.detectInjection(trimmedCommand);
448
+ if (!injectionResult.isValid) {
449
+ return injectionResult;
450
+ }
451
+ for (const blockedPattern of this.config.blockedCommands) {
452
+ if (trimmedCommand.includes(blockedPattern)) {
453
+ return {
454
+ isValid: false,
455
+ error: `Command is blocked: matches "${blockedPattern}"`
456
+ };
457
+ }
458
+ }
459
+ if (this.config.allowedCommands.length > 0) {
460
+ const isAllowed = this.config.allowedCommands.some(
461
+ (allowedCmd) => trimmedCommand.startsWith(allowedCmd)
462
+ );
463
+ if (!isAllowed) {
464
+ return {
465
+ isValid: false,
466
+ error: `Command not in allowed list. Allowed: ${this.config.allowedCommands.join(", ")}`
467
+ };
468
+ }
469
+ }
470
+ const requiresApproval = this.determineApprovalRequirement(trimmedCommand);
471
+ return {
472
+ isValid: true,
473
+ normalizedCommand: trimmedCommand,
474
+ requiresApproval
475
+ };
476
+ }
477
+ /**
478
+ * Detect command injection attempts
479
+ */
480
+ detectInjection(command) {
481
+ for (const pattern of INJECTION_PATTERNS) {
482
+ if (pattern.test(command)) {
483
+ return {
484
+ isValid: false,
485
+ error: `Potential command injection detected: ${pattern.source}`
486
+ };
487
+ }
488
+ }
489
+ if (this.config.securityLevel === "strict") {
490
+ const hasMultipleCommands = /;|\|{1,2}|&&/.test(command);
491
+ if (hasMultipleCommands) {
492
+ const isSafe = SAFE_PATTERNS.some((pattern) => pattern.test(command));
493
+ if (!isSafe) {
494
+ return {
495
+ isValid: false,
496
+ error: "Multiple commands detected in strict mode. Use moderate or permissive mode if this is intentional."
497
+ };
498
+ }
499
+ }
500
+ }
501
+ return {
502
+ isValid: true
503
+ };
504
+ }
505
+ /**
506
+ * Determine if a command requires approval
507
+ */
508
+ determineApprovalRequirement(command) {
509
+ for (const pattern of REQUIRES_APPROVAL_PATTERNS) {
510
+ if (pattern.test(command)) {
511
+ return true;
512
+ }
513
+ }
514
+ if (this.config.securityLevel === "strict") {
515
+ return true;
516
+ }
517
+ if (this.config.securityLevel === "moderate") {
518
+ return WRITE_PATTERNS.some((pattern) => pattern.test(command));
519
+ }
520
+ return false;
521
+ }
522
+ /**
523
+ * Get list of blocked commands
524
+ */
525
+ getBlockedCommands() {
526
+ return [...this.config.blockedCommands];
527
+ }
528
+ /**
529
+ * Get list of allowed commands
530
+ */
531
+ getAllowedCommands() {
532
+ return [...this.config.allowedCommands];
533
+ }
534
+ /**
535
+ * Get security level
536
+ */
537
+ getSecurityLevel() {
538
+ return this.config.securityLevel;
539
+ }
540
+ }
541
+ // Annotate the CommonJS export names for ESM import in node:
542
+ 0 && (module.exports = {
543
+ CommandValidator
544
+ });
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Command Validator
3
+ *
4
+ * Security-focused command validation for process execution
5
+ */
6
+ import { ProcessConfig, CommandValidation } from './types.js';
7
+ /**
8
+ * CommandValidator - Validates commands for security and policy compliance
9
+ *
10
+ * Security checks:
11
+ * 1. Command length limits
12
+ * 2. Dangerous command patterns
13
+ * 3. Command injection detection
14
+ * 4. Allowed/blocked command lists
15
+ * 5. Shell metacharacter analysis
16
+ * TODO: Add tests for this class
17
+ */
18
+ export declare class CommandValidator {
19
+ private config;
20
+ constructor(config: ProcessConfig);
21
+ /**
22
+ * Validate a command for security and policy compliance
23
+ */
24
+ validateCommand(command: string): CommandValidation;
25
+ /**
26
+ * Detect command injection attempts
27
+ */
28
+ private detectInjection;
29
+ /**
30
+ * Determine if a command requires approval
31
+ */
32
+ private determineApprovalRequirement;
33
+ /**
34
+ * Get list of blocked commands
35
+ */
36
+ getBlockedCommands(): string[];
37
+ /**
38
+ * Get list of allowed commands
39
+ */
40
+ getAllowedCommands(): string[];
41
+ /**
42
+ * Get security level
43
+ */
44
+ getSecurityLevel(): string;
45
+ }
46
+ //# sourceMappingURL=command-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-validator.d.ts","sourceRoot":"","sources":["../../src/process/command-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAqQ9D;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa;IAKjC;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAuEnD;;OAEG;IACH,OAAO,CAAC,eAAe;IAgCvB;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAsBpC;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,gBAAgB,IAAI,MAAM;CAG7B"}