clawsec 0.0.1

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 (361) hide show
  1. package/README.md +560 -0
  2. package/dist/bin/clawsec.d.ts +7 -0
  3. package/dist/bin/clawsec.d.ts.map +1 -0
  4. package/dist/bin/clawsec.js +12 -0
  5. package/dist/bin/clawsec.js.map +1 -0
  6. package/dist/src/actions/block.d.ts +22 -0
  7. package/dist/src/actions/block.d.ts.map +1 -0
  8. package/dist/src/actions/block.js +83 -0
  9. package/dist/src/actions/block.js.map +1 -0
  10. package/dist/src/actions/confirm.d.ts +35 -0
  11. package/dist/src/actions/confirm.d.ts.map +1 -0
  12. package/dist/src/actions/confirm.js +156 -0
  13. package/dist/src/actions/confirm.js.map +1 -0
  14. package/dist/src/actions/executor.d.ts +64 -0
  15. package/dist/src/actions/executor.d.ts.map +1 -0
  16. package/dist/src/actions/executor.js +114 -0
  17. package/dist/src/actions/executor.js.map +1 -0
  18. package/dist/src/actions/index.d.ts +13 -0
  19. package/dist/src/actions/index.d.ts.map +1 -0
  20. package/dist/src/actions/index.js +15 -0
  21. package/dist/src/actions/index.js.map +1 -0
  22. package/dist/src/actions/log.d.ts +19 -0
  23. package/dist/src/actions/log.d.ts.map +1 -0
  24. package/dist/src/actions/log.js +63 -0
  25. package/dist/src/actions/log.js.map +1 -0
  26. package/dist/src/actions/types.d.ts +85 -0
  27. package/dist/src/actions/types.d.ts.map +1 -0
  28. package/dist/src/actions/types.js +78 -0
  29. package/dist/src/actions/types.js.map +1 -0
  30. package/dist/src/actions/warn.d.ts +22 -0
  31. package/dist/src/actions/warn.d.ts.map +1 -0
  32. package/dist/src/actions/warn.js +84 -0
  33. package/dist/src/actions/warn.js.map +1 -0
  34. package/dist/src/approval/agent-confirm.d.ts +104 -0
  35. package/dist/src/approval/agent-confirm.d.ts.map +1 -0
  36. package/dist/src/approval/agent-confirm.js +173 -0
  37. package/dist/src/approval/agent-confirm.js.map +1 -0
  38. package/dist/src/approval/index.d.ts +14 -0
  39. package/dist/src/approval/index.d.ts.map +1 -0
  40. package/dist/src/approval/index.js +9 -0
  41. package/dist/src/approval/index.js.map +1 -0
  42. package/dist/src/approval/native.d.ts +56 -0
  43. package/dist/src/approval/native.d.ts.map +1 -0
  44. package/dist/src/approval/native.js +196 -0
  45. package/dist/src/approval/native.js.map +1 -0
  46. package/dist/src/approval/store.d.ts +88 -0
  47. package/dist/src/approval/store.d.ts.map +1 -0
  48. package/dist/src/approval/store.js +192 -0
  49. package/dist/src/approval/store.js.map +1 -0
  50. package/dist/src/approval/types.d.ts +119 -0
  51. package/dist/src/approval/types.d.ts.map +1 -0
  52. package/dist/src/approval/types.js +6 -0
  53. package/dist/src/approval/types.js.map +1 -0
  54. package/dist/src/approval/webhook.d.ts +170 -0
  55. package/dist/src/approval/webhook.d.ts.map +1 -0
  56. package/dist/src/approval/webhook.js +362 -0
  57. package/dist/src/approval/webhook.js.map +1 -0
  58. package/dist/src/cli/commands/audit.d.ts +43 -0
  59. package/dist/src/cli/commands/audit.d.ts.map +1 -0
  60. package/dist/src/cli/commands/audit.js +115 -0
  61. package/dist/src/cli/commands/audit.js.map +1 -0
  62. package/dist/src/cli/commands/feedback.d.ts +27 -0
  63. package/dist/src/cli/commands/feedback.d.ts.map +1 -0
  64. package/dist/src/cli/commands/feedback.js +228 -0
  65. package/dist/src/cli/commands/feedback.js.map +1 -0
  66. package/dist/src/cli/commands/index.d.ts +11 -0
  67. package/dist/src/cli/commands/index.d.ts.map +1 -0
  68. package/dist/src/cli/commands/index.js +13 -0
  69. package/dist/src/cli/commands/index.js.map +1 -0
  70. package/dist/src/cli/commands/status.d.ts +20 -0
  71. package/dist/src/cli/commands/status.d.ts.map +1 -0
  72. package/dist/src/cli/commands/status.js +122 -0
  73. package/dist/src/cli/commands/status.js.map +1 -0
  74. package/dist/src/cli/commands/test.d.ts +23 -0
  75. package/dist/src/cli/commands/test.d.ts.map +1 -0
  76. package/dist/src/cli/commands/test.js +134 -0
  77. package/dist/src/cli/commands/test.js.map +1 -0
  78. package/dist/src/cli/commands/types.d.ts +81 -0
  79. package/dist/src/cli/commands/types.d.ts.map +1 -0
  80. package/dist/src/cli/commands/types.js +6 -0
  81. package/dist/src/cli/commands/types.js.map +1 -0
  82. package/dist/src/cli/index.d.ts +17 -0
  83. package/dist/src/cli/index.d.ts.map +1 -0
  84. package/dist/src/cli/index.js +267 -0
  85. package/dist/src/cli/index.js.map +1 -0
  86. package/dist/src/config/defaults.d.ts +20 -0
  87. package/dist/src/config/defaults.d.ts.map +1 -0
  88. package/dist/src/config/defaults.js +123 -0
  89. package/dist/src/config/defaults.js.map +1 -0
  90. package/dist/src/config/index.d.ts +8 -0
  91. package/dist/src/config/index.d.ts.map +1 -0
  92. package/dist/src/config/index.js +41 -0
  93. package/dist/src/config/index.js.map +1 -0
  94. package/dist/src/config/loader.d.ts +99 -0
  95. package/dist/src/config/loader.d.ts.map +1 -0
  96. package/dist/src/config/loader.js +242 -0
  97. package/dist/src/config/loader.js.map +1 -0
  98. package/dist/src/config/schema.d.ts +627 -0
  99. package/dist/src/config/schema.d.ts.map +1 -0
  100. package/dist/src/config/schema.js +585 -0
  101. package/dist/src/config/schema.js.map +1 -0
  102. package/dist/src/detectors/destructive/cloud-detector.d.ts +51 -0
  103. package/dist/src/detectors/destructive/cloud-detector.d.ts.map +1 -0
  104. package/dist/src/detectors/destructive/cloud-detector.js +556 -0
  105. package/dist/src/detectors/destructive/cloud-detector.js.map +1 -0
  106. package/dist/src/detectors/destructive/code-detector.d.ts +59 -0
  107. package/dist/src/detectors/destructive/code-detector.d.ts.map +1 -0
  108. package/dist/src/detectors/destructive/code-detector.js +558 -0
  109. package/dist/src/detectors/destructive/code-detector.js.map +1 -0
  110. package/dist/src/detectors/destructive/index.d.ts +54 -0
  111. package/dist/src/detectors/destructive/index.d.ts.map +1 -0
  112. package/dist/src/detectors/destructive/index.js +168 -0
  113. package/dist/src/detectors/destructive/index.js.map +1 -0
  114. package/dist/src/detectors/destructive/shell-detector.d.ts +43 -0
  115. package/dist/src/detectors/destructive/shell-detector.d.ts.map +1 -0
  116. package/dist/src/detectors/destructive/shell-detector.js +302 -0
  117. package/dist/src/detectors/destructive/shell-detector.js.map +1 -0
  118. package/dist/src/detectors/destructive/types.d.ts +143 -0
  119. package/dist/src/detectors/destructive/types.d.ts.map +1 -0
  120. package/dist/src/detectors/destructive/types.js +6 -0
  121. package/dist/src/detectors/destructive/types.js.map +1 -0
  122. package/dist/src/detectors/exfiltration/cloud-detector.d.ts +51 -0
  123. package/dist/src/detectors/exfiltration/cloud-detector.d.ts.map +1 -0
  124. package/dist/src/detectors/exfiltration/cloud-detector.js +427 -0
  125. package/dist/src/detectors/exfiltration/cloud-detector.js.map +1 -0
  126. package/dist/src/detectors/exfiltration/http-detector.d.ts +47 -0
  127. package/dist/src/detectors/exfiltration/http-detector.d.ts.map +1 -0
  128. package/dist/src/detectors/exfiltration/http-detector.js +429 -0
  129. package/dist/src/detectors/exfiltration/http-detector.js.map +1 -0
  130. package/dist/src/detectors/exfiltration/index.d.ts +44 -0
  131. package/dist/src/detectors/exfiltration/index.d.ts.map +1 -0
  132. package/dist/src/detectors/exfiltration/index.js +118 -0
  133. package/dist/src/detectors/exfiltration/index.js.map +1 -0
  134. package/dist/src/detectors/exfiltration/network-detector.d.ts +55 -0
  135. package/dist/src/detectors/exfiltration/network-detector.d.ts.map +1 -0
  136. package/dist/src/detectors/exfiltration/network-detector.js +504 -0
  137. package/dist/src/detectors/exfiltration/network-detector.js.map +1 -0
  138. package/dist/src/detectors/exfiltration/types.d.ts +139 -0
  139. package/dist/src/detectors/exfiltration/types.d.ts.map +1 -0
  140. package/dist/src/detectors/exfiltration/types.js +6 -0
  141. package/dist/src/detectors/exfiltration/types.js.map +1 -0
  142. package/dist/src/detectors/purchase/domain-detector.d.ts +44 -0
  143. package/dist/src/detectors/purchase/domain-detector.d.ts.map +1 -0
  144. package/dist/src/detectors/purchase/domain-detector.js +296 -0
  145. package/dist/src/detectors/purchase/domain-detector.js.map +1 -0
  146. package/dist/src/detectors/purchase/form-detector.d.ts +27 -0
  147. package/dist/src/detectors/purchase/form-detector.d.ts.map +1 -0
  148. package/dist/src/detectors/purchase/form-detector.js +344 -0
  149. package/dist/src/detectors/purchase/form-detector.js.map +1 -0
  150. package/dist/src/detectors/purchase/index.d.ts +65 -0
  151. package/dist/src/detectors/purchase/index.d.ts.map +1 -0
  152. package/dist/src/detectors/purchase/index.js +216 -0
  153. package/dist/src/detectors/purchase/index.js.map +1 -0
  154. package/dist/src/detectors/purchase/spend-tracker.d.ts +132 -0
  155. package/dist/src/detectors/purchase/spend-tracker.d.ts.map +1 -0
  156. package/dist/src/detectors/purchase/spend-tracker.js +313 -0
  157. package/dist/src/detectors/purchase/spend-tracker.js.map +1 -0
  158. package/dist/src/detectors/purchase/types.d.ts +139 -0
  159. package/dist/src/detectors/purchase/types.d.ts.map +1 -0
  160. package/dist/src/detectors/purchase/types.js +6 -0
  161. package/dist/src/detectors/purchase/types.js.map +1 -0
  162. package/dist/src/detectors/purchase/url-detector.d.ts +31 -0
  163. package/dist/src/detectors/purchase/url-detector.d.ts.map +1 -0
  164. package/dist/src/detectors/purchase/url-detector.js +292 -0
  165. package/dist/src/detectors/purchase/url-detector.js.map +1 -0
  166. package/dist/src/detectors/secrets/api-key-detector.d.ts +30 -0
  167. package/dist/src/detectors/secrets/api-key-detector.d.ts.map +1 -0
  168. package/dist/src/detectors/secrets/api-key-detector.js +297 -0
  169. package/dist/src/detectors/secrets/api-key-detector.js.map +1 -0
  170. package/dist/src/detectors/secrets/index.d.ts +43 -0
  171. package/dist/src/detectors/secrets/index.d.ts.map +1 -0
  172. package/dist/src/detectors/secrets/index.js +261 -0
  173. package/dist/src/detectors/secrets/index.js.map +1 -0
  174. package/dist/src/detectors/secrets/pii-detector.d.ts +54 -0
  175. package/dist/src/detectors/secrets/pii-detector.d.ts.map +1 -0
  176. package/dist/src/detectors/secrets/pii-detector.js +286 -0
  177. package/dist/src/detectors/secrets/pii-detector.js.map +1 -0
  178. package/dist/src/detectors/secrets/token-detector.d.ts +51 -0
  179. package/dist/src/detectors/secrets/token-detector.d.ts.map +1 -0
  180. package/dist/src/detectors/secrets/token-detector.js +233 -0
  181. package/dist/src/detectors/secrets/token-detector.js.map +1 -0
  182. package/dist/src/detectors/secrets/types.d.ts +157 -0
  183. package/dist/src/detectors/secrets/types.d.ts.map +1 -0
  184. package/dist/src/detectors/secrets/types.js +6 -0
  185. package/dist/src/detectors/secrets/types.js.map +1 -0
  186. package/dist/src/detectors/website/category-detector.d.ts +22 -0
  187. package/dist/src/detectors/website/category-detector.d.ts.map +1 -0
  188. package/dist/src/detectors/website/category-detector.js +162 -0
  189. package/dist/src/detectors/website/category-detector.js.map +1 -0
  190. package/dist/src/detectors/website/index.d.ts +53 -0
  191. package/dist/src/detectors/website/index.d.ts.map +1 -0
  192. package/dist/src/detectors/website/index.js +232 -0
  193. package/dist/src/detectors/website/index.js.map +1 -0
  194. package/dist/src/detectors/website/pattern-matcher.d.ts +33 -0
  195. package/dist/src/detectors/website/pattern-matcher.d.ts.map +1 -0
  196. package/dist/src/detectors/website/pattern-matcher.js +121 -0
  197. package/dist/src/detectors/website/pattern-matcher.js.map +1 -0
  198. package/dist/src/detectors/website/types.d.ts +105 -0
  199. package/dist/src/detectors/website/types.d.ts.map +1 -0
  200. package/dist/src/detectors/website/types.js +6 -0
  201. package/dist/src/detectors/website/types.js.map +1 -0
  202. package/dist/src/engine/analyzer.d.ts +87 -0
  203. package/dist/src/engine/analyzer.d.ts.map +1 -0
  204. package/dist/src/engine/analyzer.js +427 -0
  205. package/dist/src/engine/analyzer.js.map +1 -0
  206. package/dist/src/engine/cache.d.ts +80 -0
  207. package/dist/src/engine/cache.d.ts.map +1 -0
  208. package/dist/src/engine/cache.js +167 -0
  209. package/dist/src/engine/cache.js.map +1 -0
  210. package/dist/src/engine/index.d.ts +11 -0
  211. package/dist/src/engine/index.d.ts.map +1 -0
  212. package/dist/src/engine/index.js +11 -0
  213. package/dist/src/engine/index.js.map +1 -0
  214. package/dist/src/engine/llm-client.d.ts +210 -0
  215. package/dist/src/engine/llm-client.d.ts.map +1 -0
  216. package/dist/src/engine/llm-client.js +506 -0
  217. package/dist/src/engine/llm-client.js.map +1 -0
  218. package/dist/src/engine/types.d.ts +163 -0
  219. package/dist/src/engine/types.d.ts.map +1 -0
  220. package/dist/src/engine/types.js +21 -0
  221. package/dist/src/engine/types.js.map +1 -0
  222. package/dist/src/feedback/index.d.ts +9 -0
  223. package/dist/src/feedback/index.d.ts.map +1 -0
  224. package/dist/src/feedback/index.js +8 -0
  225. package/dist/src/feedback/index.js.map +1 -0
  226. package/dist/src/feedback/learner.d.ts +222 -0
  227. package/dist/src/feedback/learner.d.ts.map +1 -0
  228. package/dist/src/feedback/learner.js +401 -0
  229. package/dist/src/feedback/learner.js.map +1 -0
  230. package/dist/src/feedback/store.d.ts +113 -0
  231. package/dist/src/feedback/store.d.ts.map +1 -0
  232. package/dist/src/feedback/store.js +228 -0
  233. package/dist/src/feedback/store.js.map +1 -0
  234. package/dist/src/feedback/types.d.ts +126 -0
  235. package/dist/src/feedback/types.d.ts.map +1 -0
  236. package/dist/src/feedback/types.js +6 -0
  237. package/dist/src/feedback/types.js.map +1 -0
  238. package/dist/src/hooks/before-agent-start/handler.d.ts +37 -0
  239. package/dist/src/hooks/before-agent-start/handler.d.ts.map +1 -0
  240. package/dist/src/hooks/before-agent-start/handler.js +109 -0
  241. package/dist/src/hooks/before-agent-start/handler.js.map +1 -0
  242. package/dist/src/hooks/before-agent-start/index.d.ts +8 -0
  243. package/dist/src/hooks/before-agent-start/index.d.ts.map +1 -0
  244. package/dist/src/hooks/before-agent-start/index.js +7 -0
  245. package/dist/src/hooks/before-agent-start/index.js.map +1 -0
  246. package/dist/src/hooks/before-agent-start/prompts.d.ts +48 -0
  247. package/dist/src/hooks/before-agent-start/prompts.d.ts.map +1 -0
  248. package/dist/src/hooks/before-agent-start/prompts.js +103 -0
  249. package/dist/src/hooks/before-agent-start/prompts.js.map +1 -0
  250. package/dist/src/hooks/before-tool-call/handler.d.ts +42 -0
  251. package/dist/src/hooks/before-tool-call/handler.d.ts.map +1 -0
  252. package/dist/src/hooks/before-tool-call/handler.js +226 -0
  253. package/dist/src/hooks/before-tool-call/handler.js.map +1 -0
  254. package/dist/src/hooks/before-tool-call/index.d.ts +7 -0
  255. package/dist/src/hooks/before-tool-call/index.d.ts.map +1 -0
  256. package/dist/src/hooks/before-tool-call/index.js +6 -0
  257. package/dist/src/hooks/before-tool-call/index.js.map +1 -0
  258. package/dist/src/hooks/tool-result-persist/filter.d.ts +72 -0
  259. package/dist/src/hooks/tool-result-persist/filter.d.ts.map +1 -0
  260. package/dist/src/hooks/tool-result-persist/filter.js +305 -0
  261. package/dist/src/hooks/tool-result-persist/filter.js.map +1 -0
  262. package/dist/src/hooks/tool-result-persist/handler.d.ts +49 -0
  263. package/dist/src/hooks/tool-result-persist/handler.d.ts.map +1 -0
  264. package/dist/src/hooks/tool-result-persist/handler.js +217 -0
  265. package/dist/src/hooks/tool-result-persist/handler.js.map +1 -0
  266. package/dist/src/hooks/tool-result-persist/index.d.ts +11 -0
  267. package/dist/src/hooks/tool-result-persist/index.d.ts.map +1 -0
  268. package/dist/src/hooks/tool-result-persist/index.js +11 -0
  269. package/dist/src/hooks/tool-result-persist/index.js.map +1 -0
  270. package/dist/src/index.d.ts +256 -0
  271. package/dist/src/index.d.ts.map +1 -0
  272. package/dist/src/index.js +222 -0
  273. package/dist/src/index.js.map +1 -0
  274. package/dist/src/notifications/discord.d.ts +10 -0
  275. package/dist/src/notifications/discord.d.ts.map +1 -0
  276. package/dist/src/notifications/discord.js +218 -0
  277. package/dist/src/notifications/discord.js.map +1 -0
  278. package/dist/src/notifications/index.d.ts +37 -0
  279. package/dist/src/notifications/index.d.ts.map +1 -0
  280. package/dist/src/notifications/index.js +68 -0
  281. package/dist/src/notifications/index.js.map +1 -0
  282. package/dist/src/notifications/slack.d.ts +10 -0
  283. package/dist/src/notifications/slack.d.ts.map +1 -0
  284. package/dist/src/notifications/slack.js +218 -0
  285. package/dist/src/notifications/slack.js.map +1 -0
  286. package/dist/src/notifications/telegram.d.ts +10 -0
  287. package/dist/src/notifications/telegram.d.ts.map +1 -0
  288. package/dist/src/notifications/telegram.js +242 -0
  289. package/dist/src/notifications/telegram.js.map +1 -0
  290. package/dist/src/notifications/types.d.ts +119 -0
  291. package/dist/src/notifications/types.d.ts.map +1 -0
  292. package/dist/src/notifications/types.js +6 -0
  293. package/dist/src/notifications/types.js.map +1 -0
  294. package/dist/src/proxy/index.d.ts +8 -0
  295. package/dist/src/proxy/index.d.ts.map +1 -0
  296. package/dist/src/proxy/index.js +9 -0
  297. package/dist/src/proxy/index.js.map +1 -0
  298. package/dist/src/proxy/middleware.d.ts +55 -0
  299. package/dist/src/proxy/middleware.d.ts.map +1 -0
  300. package/dist/src/proxy/middleware.js +215 -0
  301. package/dist/src/proxy/middleware.js.map +1 -0
  302. package/dist/src/proxy/server.d.ts +57 -0
  303. package/dist/src/proxy/server.d.ts.map +1 -0
  304. package/dist/src/proxy/server.js +298 -0
  305. package/dist/src/proxy/server.js.map +1 -0
  306. package/dist/src/proxy/types.d.ts +136 -0
  307. package/dist/src/proxy/types.d.ts.map +1 -0
  308. package/dist/src/proxy/types.js +6 -0
  309. package/dist/src/proxy/types.js.map +1 -0
  310. package/dist/src/sanitization/index.d.ts +10 -0
  311. package/dist/src/sanitization/index.d.ts.map +1 -0
  312. package/dist/src/sanitization/index.js +9 -0
  313. package/dist/src/sanitization/index.js.map +1 -0
  314. package/dist/src/sanitization/patterns.d.ts +51 -0
  315. package/dist/src/sanitization/patterns.d.ts.map +1 -0
  316. package/dist/src/sanitization/patterns.js +266 -0
  317. package/dist/src/sanitization/patterns.js.map +1 -0
  318. package/dist/src/sanitization/scanner.d.ts +29 -0
  319. package/dist/src/sanitization/scanner.d.ts.map +1 -0
  320. package/dist/src/sanitization/scanner.js +328 -0
  321. package/dist/src/sanitization/scanner.js.map +1 -0
  322. package/dist/src/sanitization/types.d.ts +57 -0
  323. package/dist/src/sanitization/types.d.ts.map +1 -0
  324. package/dist/src/sanitization/types.js +5 -0
  325. package/dist/src/sanitization/types.js.map +1 -0
  326. package/openclaw.plugin.json +114 -0
  327. package/package.json +63 -0
  328. package/rules/builtin/README.md +139 -0
  329. package/rules/builtin/ai-services.yaml +70 -0
  330. package/rules/builtin/api-keys.yaml +64 -0
  331. package/rules/builtin/authentication.yaml +56 -0
  332. package/rules/builtin/aws-security.yaml +57 -0
  333. package/rules/builtin/azure-security.yaml +58 -0
  334. package/rules/builtin/cicd-security.yaml +64 -0
  335. package/rules/builtin/cloud-storage.yaml +64 -0
  336. package/rules/builtin/container-registry.yaml +55 -0
  337. package/rules/builtin/crypto-wallets.yaml +71 -0
  338. package/rules/builtin/database-nosql.yaml +58 -0
  339. package/rules/builtin/database-sql.yaml +62 -0
  340. package/rules/builtin/development-env.yaml +67 -0
  341. package/rules/builtin/docker.yaml +57 -0
  342. package/rules/builtin/filesystem.yaml +71 -0
  343. package/rules/builtin/financial-pci.yaml +61 -0
  344. package/rules/builtin/gcp-security.yaml +57 -0
  345. package/rules/builtin/git-operations.yaml +68 -0
  346. package/rules/builtin/healthcare-hipaa.yaml +64 -0
  347. package/rules/builtin/kubernetes.yaml +60 -0
  348. package/rules/builtin/messaging-services.yaml +53 -0
  349. package/rules/builtin/minimal.yaml +47 -0
  350. package/rules/builtin/mobile-development.yaml +61 -0
  351. package/rules/builtin/monitoring.yaml +63 -0
  352. package/rules/builtin/network-security.yaml +57 -0
  353. package/rules/builtin/package-managers.yaml +74 -0
  354. package/rules/builtin/payment-processing.yaml +66 -0
  355. package/rules/builtin/pii-protection.yaml +48 -0
  356. package/rules/builtin/production-strict.yaml +55 -0
  357. package/rules/builtin/secrets-management.yaml +63 -0
  358. package/rules/builtin/serverless.yaml +74 -0
  359. package/rules/builtin/ssh-security.yaml +66 -0
  360. package/rules/builtin/terraform.yaml +51 -0
  361. package/rules/builtin/web-security.yaml +62 -0
@@ -0,0 +1,506 @@
1
+ /**
2
+ * LLM Client for analyzing ambiguous security detections
3
+ *
4
+ * This module provides an LLM client that analyzes ambiguous detections
5
+ * to determine if they're true threats. Used when the HybridAnalyzer
6
+ * sets requiresLLM = true for cases with ambiguous confidence (0.5-0.8).
7
+ */
8
+ // ============================================================================
9
+ // Constants
10
+ // ============================================================================
11
+ /** Default timeout for LLM requests (30 seconds) */
12
+ export const DEFAULT_LLM_TIMEOUT_MS = 30000;
13
+ /** Default TTL for LLM response cache (5 minutes - longer than detection cache) */
14
+ export const DEFAULT_LLM_CACHE_TTL_MS = 5 * 60 * 1000;
15
+ /** Maximum cache size for LLM responses */
16
+ export const MAX_LLM_CACHE_SIZE = 500;
17
+ // ============================================================================
18
+ // Cache for LLM Responses
19
+ // ============================================================================
20
+ /**
21
+ * Generic in-memory cache for LLM responses
22
+ */
23
+ export class LLMResponseCache {
24
+ cache;
25
+ defaultTtl;
26
+ constructor(defaultTtlMs = DEFAULT_LLM_CACHE_TTL_MS) {
27
+ this.cache = new Map();
28
+ this.defaultTtl = defaultTtlMs;
29
+ }
30
+ /**
31
+ * Generate a cache key from the request
32
+ */
33
+ generateKey(request) {
34
+ const keyData = {
35
+ category: request.detection.category,
36
+ reason: request.detection.reason,
37
+ toolName: request.context.toolName,
38
+ toolInput: request.context.toolInput,
39
+ };
40
+ return JSON.stringify(keyData);
41
+ }
42
+ /**
43
+ * Get a cached result
44
+ */
45
+ get(key) {
46
+ const entry = this.cache.get(key);
47
+ if (!entry) {
48
+ return undefined;
49
+ }
50
+ if (this.isExpired(entry)) {
51
+ this.cache.delete(key);
52
+ return undefined;
53
+ }
54
+ return entry.value;
55
+ }
56
+ /**
57
+ * Set a cached result
58
+ */
59
+ set(key, result, ttl) {
60
+ if (this.cache.size >= MAX_LLM_CACHE_SIZE) {
61
+ this.evictExpired();
62
+ if (this.cache.size >= MAX_LLM_CACHE_SIZE) {
63
+ this.evictOldest(Math.floor(MAX_LLM_CACHE_SIZE * 0.1));
64
+ }
65
+ }
66
+ const entry = {
67
+ value: result,
68
+ createdAt: Date.now(),
69
+ ttl: ttl ?? this.defaultTtl,
70
+ };
71
+ this.cache.set(key, entry);
72
+ }
73
+ /**
74
+ * Check if a key exists and is not expired
75
+ */
76
+ has(key) {
77
+ const entry = this.cache.get(key);
78
+ if (!entry) {
79
+ return false;
80
+ }
81
+ if (this.isExpired(entry)) {
82
+ this.cache.delete(key);
83
+ return false;
84
+ }
85
+ return true;
86
+ }
87
+ /**
88
+ * Clear all entries
89
+ */
90
+ clear() {
91
+ this.cache.clear();
92
+ }
93
+ /**
94
+ * Get cache size
95
+ */
96
+ size() {
97
+ return this.cache.size;
98
+ }
99
+ isExpired(entry) {
100
+ return Date.now() - entry.createdAt >= entry.ttl;
101
+ }
102
+ evictExpired() {
103
+ const now = Date.now();
104
+ for (const [key, entry] of this.cache) {
105
+ if (now - entry.createdAt >= entry.ttl) {
106
+ this.cache.delete(key);
107
+ }
108
+ }
109
+ }
110
+ evictOldest(count) {
111
+ const entries = Array.from(this.cache.entries()).sort((a, b) => a[1].createdAt - b[1].createdAt);
112
+ for (let i = 0; i < Math.min(count, entries.length); i++) {
113
+ this.cache.delete(entries[i][0]);
114
+ }
115
+ }
116
+ }
117
+ // ============================================================================
118
+ // Prompt Generation
119
+ // ============================================================================
120
+ /**
121
+ * Build a prompt for LLM analysis of a security detection
122
+ */
123
+ export function buildAnalysisPrompt(request) {
124
+ const { detection, context } = request;
125
+ const toolInputStr = JSON.stringify(context.toolInput, null, 2);
126
+ let prompt = `You are a security analyst reviewing a potentially suspicious action by an AI agent.
127
+
128
+ ## Detection Details
129
+ - **Category**: ${detection.category}
130
+ - **Severity**: ${detection.severity}
131
+ - **Confidence**: ${(detection.confidence * 100).toFixed(0)}%
132
+ - **Reason**: ${detection.reason}
133
+
134
+ ## Tool Call Context
135
+ - **Tool Name**: ${context.toolName}
136
+ - **Tool Input**:
137
+ \`\`\`json
138
+ ${toolInputStr}
139
+ \`\`\``;
140
+ if (context.url) {
141
+ prompt += `\n- **URL**: ${context.url}`;
142
+ }
143
+ if (context.toolOutput) {
144
+ const truncatedOutput = context.toolOutput.length > 500
145
+ ? context.toolOutput.substring(0, 500) + '...'
146
+ : context.toolOutput;
147
+ prompt += `\n- **Tool Output** (truncated):\n\`\`\`\n${truncatedOutput}\n\`\`\``;
148
+ }
149
+ if (detection.metadata) {
150
+ prompt += `\n- **Additional Metadata**: ${JSON.stringify(detection.metadata)}`;
151
+ }
152
+ prompt += `
153
+
154
+ ## Your Task
155
+ Analyze this detection and determine if this represents a real security threat or a false positive.
156
+
157
+ Consider:
158
+ 1. Is the detected action genuinely dangerous or malicious?
159
+ 2. Could this be a legitimate use case that triggered a false positive?
160
+ 3. What is the potential impact if this action is allowed?
161
+ 4. Are there any contextual clues that suggest benign intent?
162
+
163
+ ## Response Format
164
+ Respond with a JSON object in the following format:
165
+ \`\`\`json
166
+ {
167
+ "determination": "threat" | "safe" | "uncertain",
168
+ "confidence": 0.0 to 1.0,
169
+ "reasoning": "Brief explanation of your analysis",
170
+ "suggestedAction": "block" | "confirm" | "allow"
171
+ }
172
+ \`\`\`
173
+
174
+ Guidelines for determination:
175
+ - "threat": Clear evidence of malicious or dangerous intent
176
+ - "safe": Clear evidence this is a legitimate, safe operation
177
+ - "uncertain": Cannot determine with confidence; err on the side of caution
178
+
179
+ Guidelines for suggestedAction:
180
+ - "block": For clear threats or high-risk uncertain cases
181
+ - "confirm": When user confirmation would be helpful
182
+ - "allow": Only for clearly safe operations`;
183
+ return prompt;
184
+ }
185
+ /**
186
+ * Parse LLM response to extract structured result
187
+ */
188
+ export function parseAnalysisResponse(response) {
189
+ // Try to extract JSON from the response
190
+ const jsonMatch = response.match(/```json\s*([\s\S]*?)\s*```/);
191
+ const jsonStr = jsonMatch ? jsonMatch[1] : response;
192
+ try {
193
+ const parsed = JSON.parse(jsonStr.trim());
194
+ // Validate and normalize the response
195
+ const determination = normalizeDetermination(parsed.determination);
196
+ const confidence = normalizeConfidence(parsed.confidence);
197
+ const reasoning = typeof parsed.reasoning === 'string' ? parsed.reasoning : 'No reasoning provided';
198
+ const suggestedAction = normalizeSuggestedAction(parsed.suggestedAction, determination);
199
+ return {
200
+ determination,
201
+ confidence,
202
+ reasoning,
203
+ suggestedAction,
204
+ };
205
+ }
206
+ catch {
207
+ // If parsing fails, return uncertain result
208
+ return {
209
+ determination: 'uncertain',
210
+ confidence: 0.5,
211
+ reasoning: 'Failed to parse LLM response',
212
+ suggestedAction: 'confirm',
213
+ };
214
+ }
215
+ }
216
+ function normalizeDetermination(value) {
217
+ if (value === 'threat' || value === 'safe' || value === 'uncertain') {
218
+ return value;
219
+ }
220
+ return 'uncertain';
221
+ }
222
+ function normalizeConfidence(value) {
223
+ if (typeof value === 'number' && value >= 0 && value <= 1) {
224
+ return value;
225
+ }
226
+ return 0.5;
227
+ }
228
+ function normalizeSuggestedAction(value, determination) {
229
+ if (value === 'block' || value === 'confirm' || value === 'allow') {
230
+ return value;
231
+ }
232
+ // Default based on determination
233
+ switch (determination) {
234
+ case 'threat':
235
+ return 'block';
236
+ case 'safe':
237
+ return 'allow';
238
+ case 'uncertain':
239
+ return 'confirm';
240
+ }
241
+ }
242
+ /**
243
+ * Real LLM client that uses OpenClaw API
244
+ */
245
+ export class OpenClawLLMClient {
246
+ api;
247
+ model;
248
+ timeoutMs;
249
+ cache;
250
+ cacheTtlMs;
251
+ constructor(api, config) {
252
+ this.api = api;
253
+ this.model = config.llmConfig.model;
254
+ this.timeoutMs = config.timeoutMs ?? DEFAULT_LLM_TIMEOUT_MS;
255
+ this.cacheTtlMs = config.cacheTtlMs ?? DEFAULT_LLM_CACHE_TTL_MS;
256
+ this.cache = config.enableCache !== false ? new LLMResponseCache(this.cacheTtlMs) : null;
257
+ }
258
+ isAvailable() {
259
+ return this.api.isAvailable();
260
+ }
261
+ async analyze(request) {
262
+ // Check cache first
263
+ if (this.cache) {
264
+ const cacheKey = this.cache.generateKey(request);
265
+ const cached = this.cache.get(cacheKey);
266
+ if (cached) {
267
+ return cached;
268
+ }
269
+ }
270
+ try {
271
+ const prompt = buildAnalysisPrompt(request);
272
+ const response = await this.api.complete(prompt, {
273
+ model: this.model,
274
+ timeout: this.timeoutMs,
275
+ });
276
+ const result = parseAnalysisResponse(response);
277
+ // Cache the result
278
+ if (this.cache) {
279
+ const cacheKey = this.cache.generateKey(request);
280
+ this.cache.set(cacheKey, result);
281
+ }
282
+ return result;
283
+ }
284
+ catch (error) {
285
+ // Return uncertain on error
286
+ return {
287
+ determination: 'uncertain',
288
+ confidence: 0.5,
289
+ reasoning: `LLM analysis failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
290
+ suggestedAction: 'confirm',
291
+ };
292
+ }
293
+ }
294
+ /**
295
+ * Clear the response cache
296
+ */
297
+ clearCache() {
298
+ this.cache?.clear();
299
+ }
300
+ /**
301
+ * Get cache statistics
302
+ */
303
+ getCacheStats() {
304
+ return {
305
+ size: this.cache?.size() ?? 0,
306
+ enabled: this.cache !== null,
307
+ };
308
+ }
309
+ }
310
+ /**
311
+ * Mock LLM client for testing
312
+ * Provides deterministic responses based on detection characteristics
313
+ */
314
+ export class MockLLMClient {
315
+ available;
316
+ responseDelay;
317
+ cache;
318
+ customResponses;
319
+ constructor(options) {
320
+ this.available = options?.available ?? true;
321
+ this.responseDelay = options?.responseDelay ?? 0;
322
+ this.cache = options?.enableCache !== false ? new LLMResponseCache(options?.cacheTtlMs) : null;
323
+ this.customResponses = new Map();
324
+ }
325
+ isAvailable() {
326
+ return this.available;
327
+ }
328
+ /**
329
+ * Set availability for testing
330
+ */
331
+ setAvailable(available) {
332
+ this.available = available;
333
+ }
334
+ /**
335
+ * Set a custom response for a specific category
336
+ */
337
+ setCustomResponse(category, response) {
338
+ this.customResponses.set(category, response);
339
+ }
340
+ async analyze(request) {
341
+ if (!this.available) {
342
+ return {
343
+ determination: 'uncertain',
344
+ confidence: 0.5,
345
+ reasoning: 'LLM client unavailable',
346
+ suggestedAction: 'confirm',
347
+ };
348
+ }
349
+ // Check cache first
350
+ if (this.cache) {
351
+ const cacheKey = this.cache.generateKey(request);
352
+ const cached = this.cache.get(cacheKey);
353
+ if (cached) {
354
+ return cached;
355
+ }
356
+ }
357
+ // Simulate processing time
358
+ if (this.responseDelay > 0) {
359
+ await new Promise((resolve) => setTimeout(resolve, this.responseDelay));
360
+ }
361
+ // Check for custom response
362
+ const customResponse = this.customResponses.get(request.detection.category);
363
+ if (customResponse) {
364
+ if (this.cache) {
365
+ const cacheKey = this.cache.generateKey(request);
366
+ this.cache.set(cacheKey, customResponse);
367
+ }
368
+ return customResponse;
369
+ }
370
+ // Generate deterministic response based on detection
371
+ const result = this.generateMockResponse(request);
372
+ // Cache the result
373
+ if (this.cache) {
374
+ const cacheKey = this.cache.generateKey(request);
375
+ this.cache.set(cacheKey, result);
376
+ }
377
+ return result;
378
+ }
379
+ /**
380
+ * Generate a mock response based on detection characteristics
381
+ */
382
+ generateMockResponse(request) {
383
+ const { detection, context } = request;
384
+ // High confidence detections are treated as threats
385
+ if (detection.confidence >= 0.75) {
386
+ return {
387
+ determination: 'threat',
388
+ confidence: 0.85,
389
+ reasoning: `High confidence ${detection.category} detection confirms threat`,
390
+ suggestedAction: 'block',
391
+ };
392
+ }
393
+ // Low confidence detections are treated as safe
394
+ if (detection.confidence < 0.55) {
395
+ return {
396
+ determination: 'safe',
397
+ confidence: 0.7,
398
+ reasoning: `Low confidence ${detection.category} detection likely false positive`,
399
+ suggestedAction: 'allow',
400
+ };
401
+ }
402
+ // Category-specific logic for mid-range confidence
403
+ switch (detection.category) {
404
+ case 'purchase':
405
+ // Purchase in known checkout flows is more likely a threat
406
+ if (context.url?.includes('checkout') || context.url?.includes('pay')) {
407
+ return {
408
+ determination: 'threat',
409
+ confidence: 0.8,
410
+ reasoning: 'Checkout or payment URL indicates real purchase attempt',
411
+ suggestedAction: 'block',
412
+ };
413
+ }
414
+ break;
415
+ case 'destructive':
416
+ // Destructive commands in test directories might be safe
417
+ if (JSON.stringify(context.toolInput).includes('test')) {
418
+ return {
419
+ determination: 'safe',
420
+ confidence: 0.65,
421
+ reasoning: 'Command appears to target test files/directories',
422
+ suggestedAction: 'confirm',
423
+ };
424
+ }
425
+ break;
426
+ case 'secrets':
427
+ // Secrets in env.example files are usually safe
428
+ if (JSON.stringify(context.toolInput).includes('example')) {
429
+ return {
430
+ determination: 'safe',
431
+ confidence: 0.75,
432
+ reasoning: 'Secret appears to be in example/template file',
433
+ suggestedAction: 'allow',
434
+ };
435
+ }
436
+ break;
437
+ case 'exfiltration':
438
+ // Exfiltration to localhost is usually safe
439
+ if (context.url?.includes('localhost') || context.url?.includes('127.0.0.1')) {
440
+ return {
441
+ determination: 'safe',
442
+ confidence: 0.8,
443
+ reasoning: 'Target is localhost, likely development/testing',
444
+ suggestedAction: 'allow',
445
+ };
446
+ }
447
+ break;
448
+ }
449
+ // Default uncertain response for ambiguous cases
450
+ return {
451
+ determination: 'uncertain',
452
+ confidence: 0.6,
453
+ reasoning: `Unable to definitively classify ${detection.category} detection`,
454
+ suggestedAction: 'confirm',
455
+ };
456
+ }
457
+ /**
458
+ * Clear the response cache
459
+ */
460
+ clearCache() {
461
+ this.cache?.clear();
462
+ }
463
+ /**
464
+ * Get cache statistics
465
+ */
466
+ getCacheStats() {
467
+ return {
468
+ size: this.cache?.size() ?? 0,
469
+ enabled: this.cache !== null,
470
+ };
471
+ }
472
+ }
473
+ // ============================================================================
474
+ // Factory Functions
475
+ // ============================================================================
476
+ /**
477
+ * Create an LLM client
478
+ *
479
+ * @param config - LLM client configuration
480
+ * @param api - Optional OpenClaw API instance (if available, creates real client)
481
+ * @returns LLM client instance
482
+ */
483
+ export function createLLMClient(config, api) {
484
+ // If API is provided and available, use real client
485
+ if (api && api.isAvailable()) {
486
+ return new OpenClawLLMClient(api, config);
487
+ }
488
+ // Otherwise return mock client
489
+ return new MockLLMClient({
490
+ enableCache: config.enableCache,
491
+ cacheTtlMs: config.cacheTtlMs,
492
+ });
493
+ }
494
+ /**
495
+ * Create a mock LLM client for testing
496
+ */
497
+ export function createMockLLMClient(options) {
498
+ return new MockLLMClient(options);
499
+ }
500
+ /**
501
+ * Create an unavailable LLM client (always returns uncertain)
502
+ */
503
+ export function createUnavailableLLMClient() {
504
+ return new MockLLMClient({ available: false });
505
+ }
506
+ //# sourceMappingURL=llm-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-client.js","sourceRoot":"","sources":["../../../src/engine/llm-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgEH,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,oDAAoD;AACpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,mFAAmF;AACnF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEtD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,KAAK,CAA6C;IAClD,UAAU,CAAS;IAE3B,YAAY,eAAuB,wBAAwB;QACzD,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAA2B;QACrC,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ;YACpC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM;YAChC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ;YAClC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS;SACrC,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;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W;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAKnC;IACC,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,IAAI,aAAa,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Hybrid Detection Engine Types
3
+ * Type definitions for the main detection engine that orchestrates all detectors
4
+ */
5
+ import type { Severity, ClawsecConfig } from '../config/index.js';
6
+ /**
7
+ * Actions that can be returned by the analyzer
8
+ * Note: This extends the config Action type with 'allow' for analysis results
9
+ */
10
+ export type AnalysisAction = 'allow' | 'block' | 'confirm' | 'warn' | 'log';
11
+ /**
12
+ * Threat categories that can be detected
13
+ */
14
+ export type ThreatCategory = 'purchase' | 'website' | 'destructive' | 'secrets' | 'exfiltration';
15
+ /**
16
+ * Detection context provided to the engine
17
+ */
18
+ export interface ToolCallContext {
19
+ /** Name of the tool being invoked */
20
+ toolName: string;
21
+ /** Input parameters to the tool */
22
+ toolInput: Record<string, unknown>;
23
+ /** URL being accessed (for browser/navigation tools) */
24
+ url?: string;
25
+ /** Output from the tool (for post-execution scanning like secrets) */
26
+ toolOutput?: string;
27
+ }
28
+ /**
29
+ * Individual detection result
30
+ */
31
+ export interface Detection {
32
+ /** Category of threat detected */
33
+ category: ThreatCategory;
34
+ /** Severity level */
35
+ severity: Severity;
36
+ /** Confidence score from 0 to 1 */
37
+ confidence: number;
38
+ /** Human-readable reason for the detection */
39
+ reason: string;
40
+ /** Additional metadata about the detection */
41
+ metadata?: Record<string, unknown>;
42
+ }
43
+ /**
44
+ * Result of the analysis
45
+ */
46
+ export interface AnalysisResult {
47
+ /** Recommended action to take */
48
+ action: AnalysisAction;
49
+ /** All detections found across all enabled detectors */
50
+ detections: Detection[];
51
+ /** Highest severity detection (if any) */
52
+ primaryDetection?: Detection;
53
+ /** True if the result needs LLM analysis for ambiguous cases */
54
+ requiresLLM: boolean;
55
+ /** True if the result was retrieved from cache */
56
+ cached: boolean;
57
+ /** Analysis duration in milliseconds */
58
+ durationMs?: number;
59
+ }
60
+ /**
61
+ * Cache entry for storing analysis results
62
+ */
63
+ export interface CacheEntry<T> {
64
+ /** The cached value */
65
+ value: T;
66
+ /** Timestamp when the entry was created */
67
+ createdAt: number;
68
+ /** Time-to-live in milliseconds */
69
+ ttl: number;
70
+ }
71
+ /**
72
+ * Cache interface for detection results
73
+ */
74
+ export interface DetectionCache {
75
+ /** Get a cached result by key */
76
+ get(key: string): AnalysisResult | undefined;
77
+ /** Set a cached result */
78
+ set(key: string, result: AnalysisResult, ttl?: number): void;
79
+ /** Check if a key exists and is not expired */
80
+ has(key: string): boolean;
81
+ /** Clear all entries */
82
+ clear(): void;
83
+ /** Delete a specific entry */
84
+ delete(key: string): boolean;
85
+ /** Get the number of entries */
86
+ size(): number;
87
+ }
88
+ /**
89
+ * Configuration for the analyzer
90
+ */
91
+ export interface AnalyzerConfig {
92
+ /** The Clawsec configuration */
93
+ config: ClawsecConfig;
94
+ /** Enable caching (default: true) */
95
+ enableCache?: boolean;
96
+ /** Cache TTL in milliseconds (default: 5 minutes) */
97
+ cacheTtlMs?: number;
98
+ /** Optional LLM client for analyzing ambiguous detections */
99
+ llmClient?: LLMClient;
100
+ }
101
+ /**
102
+ * LLM analysis result determination
103
+ */
104
+ export type LLMDetermination = 'threat' | 'safe' | 'uncertain';
105
+ /**
106
+ * LLM analysis suggested action
107
+ */
108
+ export type LLMSuggestedAction = 'block' | 'confirm' | 'allow';
109
+ /**
110
+ * Result of LLM analysis
111
+ */
112
+ export interface LLMAnalysisResult {
113
+ /** Determination of the threat level */
114
+ determination: LLMDetermination;
115
+ /** Confidence in the determination (0-1) */
116
+ confidence: number;
117
+ /** Reasoning behind the determination */
118
+ reasoning: string;
119
+ /** Suggested action based on analysis */
120
+ suggestedAction: LLMSuggestedAction;
121
+ }
122
+ /**
123
+ * Request to analyze a detection with LLM
124
+ */
125
+ export interface LLMAnalysisRequest {
126
+ /** The detection to analyze */
127
+ detection: Detection;
128
+ /** Context of the tool call that triggered the detection */
129
+ context: ToolCallContext;
130
+ }
131
+ /**
132
+ * Interface for LLM clients (minimal for avoiding circular deps)
133
+ */
134
+ export interface LLMClient {
135
+ /** Analyze a detection and determine if it's a real threat */
136
+ analyze(request: LLMAnalysisRequest): Promise<LLMAnalysisResult>;
137
+ /** Check if the LLM client is available and configured */
138
+ isAvailable(): boolean;
139
+ }
140
+ /**
141
+ * Main analyzer interface
142
+ */
143
+ export interface Analyzer {
144
+ /** Analyze a tool call and return the result */
145
+ analyze(context: ToolCallContext): Promise<AnalysisResult>;
146
+ /** Clear the detection cache */
147
+ clearCache(): void;
148
+ /** Get cache statistics */
149
+ getCacheStats(): {
150
+ size: number;
151
+ enabled: boolean;
152
+ };
153
+ }
154
+ /**
155
+ * Severity weights for sorting (higher = more severe)
156
+ */
157
+ export declare const SEVERITY_WEIGHTS: Record<Severity, number>;
158
+ /**
159
+ * Compare two severities
160
+ * @returns negative if a < b, 0 if equal, positive if a > b
161
+ */
162
+ export declare function compareSeverity(a: Severity, b: Severity): number;
163
+ //# sourceMappingURL=types.d.ts.map