@dcyfr/ai 2.1.3 → 3.0.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 (468) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +75 -10
  3. package/config/default.json +11 -5
  4. package/config/default.yaml +13 -5
  5. package/dist/.tsbuildinfo +1 -0
  6. package/dist/ai/agents/agent-loader.d.ts.map +1 -1
  7. package/dist/ai/agents/agent-loader.js +1 -0
  8. package/dist/ai/agents/agent-loader.js.map +1 -1
  9. package/dist/ai/agents/agent-registry.d.ts.map +1 -1
  10. package/dist/ai/agents/agent-registry.js.map +1 -1
  11. package/dist/ai/agents/agent-router.d.ts +3 -3
  12. package/dist/ai/agents/agent-router.d.ts.map +1 -1
  13. package/dist/ai/agents/agent-router.js +6 -7
  14. package/dist/ai/agents/agent-router.js.map +1 -1
  15. package/dist/ai/config/schema.js +3 -3
  16. package/dist/ai/config/schema.js.map +1 -1
  17. package/dist/ai/core/provider-registry.d.ts.map +1 -1
  18. package/dist/ai/core/provider-registry.js +47 -16
  19. package/dist/ai/core/provider-registry.js.map +1 -1
  20. package/dist/ai/core/telemetry-engine.d.ts.map +1 -1
  21. package/dist/ai/core/telemetry-engine.js +5 -3
  22. package/dist/ai/core/telemetry-engine.js.map +1 -1
  23. package/dist/ai/delegation/capability-bootstrap.js +1 -1
  24. package/dist/ai/delegation/capability-bootstrap.js.map +1 -1
  25. package/dist/ai/delegation/contract-manager.d.ts +54 -5
  26. package/dist/ai/delegation/contract-manager.d.ts.map +1 -1
  27. package/dist/ai/delegation/contract-manager.js +122 -7
  28. package/dist/ai/delegation/contract-manager.js.map +1 -1
  29. package/dist/ai/delegation/feature-flags.d.ts +1 -1
  30. package/dist/ai/delegation/feature-flags.d.ts.map +1 -1
  31. package/dist/ai/delegation/feature-flags.js +3 -1
  32. package/dist/ai/delegation/feature-flags.js.map +1 -1
  33. package/dist/ai/delegation/index.d.ts +1 -0
  34. package/dist/ai/delegation/index.d.ts.map +1 -1
  35. package/dist/ai/delegation/index.js +2 -0
  36. package/dist/ai/delegation/index.js.map +1 -1
  37. package/dist/ai/delegation/monitoring.d.ts.map +1 -1
  38. package/dist/ai/delegation/monitoring.js +1 -0
  39. package/dist/ai/delegation/monitoring.js.map +1 -1
  40. package/dist/ai/delegation/session-manager.d.ts +16 -1
  41. package/dist/ai/delegation/session-manager.d.ts.map +1 -1
  42. package/dist/ai/delegation/session-manager.js +10 -1
  43. package/dist/ai/delegation/session-manager.js.map +1 -1
  44. package/dist/ai/delegation/session-queue.d.ts.map +1 -1
  45. package/dist/ai/delegation/session-queue.js.map +1 -1
  46. package/dist/ai/examples/integration-demo.d.ts.map +1 -1
  47. package/dist/ai/examples/integration-demo.js +1 -0
  48. package/dist/ai/examples/integration-demo.js.map +1 -1
  49. package/dist/ai/index.d.ts +7 -0
  50. package/dist/ai/index.d.ts.map +1 -1
  51. package/dist/ai/index.js +8 -0
  52. package/dist/ai/index.js.map +1 -1
  53. package/dist/ai/mcp/mcp-registry.d.ts.map +1 -1
  54. package/dist/ai/mcp/mcp-registry.js +1 -1
  55. package/dist/ai/mcp/mcp-registry.js.map +1 -1
  56. package/dist/ai/mcp/servers/analytics/index.d.ts.map +1 -1
  57. package/dist/ai/mcp/servers/analytics/index.js +1 -0
  58. package/dist/ai/mcp/servers/analytics/index.js.map +1 -1
  59. package/dist/ai/mcp/servers/content-manager/index.d.ts.map +1 -1
  60. package/dist/ai/mcp/servers/delegation-monitor/index.js +27 -27
  61. package/dist/ai/mcp/servers/delegation-monitor/index.js.map +1 -1
  62. package/dist/ai/mcp/servers/design-tokens/index.js +1 -1
  63. package/dist/ai/mcp/servers/design-tokens/index.js.map +1 -1
  64. package/dist/ai/mcp/servers/promptintel/index.d.ts.map +1 -1
  65. package/dist/ai/mcp/servers/promptintel/index.js +2 -1
  66. package/dist/ai/mcp/servers/promptintel/index.js.map +1 -1
  67. package/dist/ai/mcp/servers/shared/rate-limiter.d.ts.map +1 -1
  68. package/dist/ai/mcp/servers/shared/rate-limiter.js +1 -0
  69. package/dist/ai/mcp/servers/shared/rate-limiter.js.map +1 -1
  70. package/dist/ai/mcp/servers/shared/redis-client.d.ts.map +1 -1
  71. package/dist/ai/mcp/servers/shared/redis-client.js +2 -0
  72. package/dist/ai/mcp/servers/shared/redis-client.js.map +1 -1
  73. package/dist/ai/mcp/servers/shared/utils.js +12 -18
  74. package/dist/ai/mcp/servers/shared/utils.js.map +1 -1
  75. package/dist/ai/memory/dcyfr-memory.d.ts.map +1 -1
  76. package/dist/ai/memory/dcyfr-memory.js +11 -1
  77. package/dist/ai/memory/dcyfr-memory.js.map +1 -1
  78. package/dist/ai/memory/file-memory-adapter.d.ts +103 -0
  79. package/dist/ai/memory/file-memory-adapter.d.ts.map +1 -0
  80. package/dist/ai/memory/file-memory-adapter.js +532 -0
  81. package/dist/ai/memory/file-memory-adapter.js.map +1 -0
  82. package/dist/ai/memory/index.d.ts +6 -0
  83. package/dist/ai/memory/index.d.ts.map +1 -1
  84. package/dist/ai/memory/index.js +6 -0
  85. package/dist/ai/memory/index.js.map +1 -1
  86. package/dist/ai/memory/mem0-client.d.ts.map +1 -1
  87. package/dist/ai/memory/mem0-client.js +5 -2
  88. package/dist/ai/memory/mem0-client.js.map +1 -1
  89. package/dist/ai/memory/sqlite-index.d.ts +89 -0
  90. package/dist/ai/memory/sqlite-index.d.ts.map +1 -0
  91. package/dist/ai/memory/sqlite-index.js +295 -0
  92. package/dist/ai/memory/sqlite-index.js.map +1 -0
  93. package/dist/ai/memory/types.d.ts.map +1 -1
  94. package/dist/ai/memory/types.js +1 -0
  95. package/dist/ai/memory/types.js.map +1 -1
  96. package/dist/ai/memory/working-memory-persistence.d.ts +79 -0
  97. package/dist/ai/memory/working-memory-persistence.d.ts.map +1 -0
  98. package/dist/ai/memory/working-memory-persistence.js +220 -0
  99. package/dist/ai/memory/working-memory-persistence.js.map +1 -0
  100. package/dist/ai/permissions/attenuation-engine.d.ts.map +1 -1
  101. package/dist/ai/permissions/attenuation-engine.js.map +1 -1
  102. package/dist/ai/reputation/reputation-engine.d.ts +4 -0
  103. package/dist/ai/reputation/reputation-engine.d.ts.map +1 -1
  104. package/dist/ai/reputation/reputation-engine.js +1 -0
  105. package/dist/ai/reputation/reputation-engine.js.map +1 -1
  106. package/dist/ai/runtime/agent-runtime.d.ts.map +1 -1
  107. package/dist/ai/runtime/agent-runtime.js +9 -5
  108. package/dist/ai/runtime/agent-runtime.js.map +1 -1
  109. package/dist/ai/src/batch-processor.d.ts +6 -6
  110. package/dist/ai/src/batch-processor.d.ts.map +1 -1
  111. package/dist/ai/src/batch-processor.js +11 -4
  112. package/dist/ai/src/batch-processor.js.map +1 -1
  113. package/dist/ai/src/capability-bootstrap.d.ts.map +1 -1
  114. package/dist/ai/src/capability-bootstrap.js +1 -0
  115. package/dist/ai/src/capability-bootstrap.js.map +1 -1
  116. package/dist/ai/src/capability-registry.js +1 -1
  117. package/dist/ai/src/capability-registry.js.map +1 -1
  118. package/dist/ai/src/cli/telemetry-dashboard.d.ts +0 -11
  119. package/dist/ai/src/cli/telemetry-dashboard.d.ts.map +1 -1
  120. package/dist/ai/src/cli/telemetry-dashboard.js +12 -6
  121. package/dist/ai/src/cli/telemetry-dashboard.js.map +1 -1
  122. package/dist/ai/src/compaction/context-compactor.d.ts +149 -0
  123. package/dist/ai/src/compaction/context-compactor.d.ts.map +1 -0
  124. package/dist/ai/src/compaction/context-compactor.js +302 -0
  125. package/dist/ai/src/compaction/context-compactor.js.map +1 -0
  126. package/dist/ai/src/compaction/index.d.ts +11 -0
  127. package/dist/ai/src/compaction/index.d.ts.map +1 -0
  128. package/dist/ai/src/compaction/index.js +11 -0
  129. package/dist/ai/src/compaction/index.js.map +1 -0
  130. package/dist/ai/src/compaction/memory-compaction.d.ts +138 -0
  131. package/dist/ai/src/compaction/memory-compaction.d.ts.map +1 -0
  132. package/dist/ai/src/compaction/memory-compaction.js +630 -0
  133. package/dist/ai/src/compaction/memory-compaction.js.map +1 -0
  134. package/dist/ai/src/container/agent-container-dispatcher.d.ts +154 -0
  135. package/dist/ai/src/container/agent-container-dispatcher.d.ts.map +1 -0
  136. package/dist/ai/src/container/agent-container-dispatcher.js +329 -0
  137. package/dist/ai/src/container/agent-container-dispatcher.js.map +1 -0
  138. package/dist/ai/src/container/backend-factory.d.ts +89 -0
  139. package/dist/ai/src/container/backend-factory.d.ts.map +1 -0
  140. package/dist/ai/src/container/backend-factory.js +169 -0
  141. package/dist/ai/src/container/backend-factory.js.map +1 -0
  142. package/dist/ai/src/container/index.d.ts +13 -0
  143. package/dist/ai/src/container/index.d.ts.map +1 -0
  144. package/dist/ai/src/container/index.js +13 -0
  145. package/dist/ai/src/container/index.js.map +1 -0
  146. package/dist/ai/src/container/kubernetes-backend.d.ts +23 -0
  147. package/dist/ai/src/container/kubernetes-backend.d.ts.map +1 -0
  148. package/dist/ai/src/container/kubernetes-backend.js +39 -0
  149. package/dist/ai/src/container/kubernetes-backend.js.map +1 -0
  150. package/dist/ai/src/container/local-docker-backend.d.ts +77 -0
  151. package/dist/ai/src/container/local-docker-backend.d.ts.map +1 -0
  152. package/dist/ai/src/container/local-docker-backend.js +362 -0
  153. package/dist/ai/src/container/local-docker-backend.js.map +1 -0
  154. package/dist/ai/src/container/remote-docker-backend.d.ts +35 -0
  155. package/dist/ai/src/container/remote-docker-backend.d.ts.map +1 -0
  156. package/dist/ai/src/container/remote-docker-backend.js +189 -0
  157. package/dist/ai/src/container/remote-docker-backend.js.map +1 -0
  158. package/dist/ai/src/container/types.d.ts +270 -0
  159. package/dist/ai/src/container/types.d.ts.map +1 -0
  160. package/dist/ai/src/container/types.js +86 -0
  161. package/dist/ai/src/container/types.js.map +1 -0
  162. package/dist/ai/src/delegation/feature-flags.d.ts.map +1 -1
  163. package/dist/ai/src/delegation/feature-flags.js +1 -0
  164. package/dist/ai/src/delegation/feature-flags.js.map +1 -1
  165. package/dist/ai/src/delegation/liability-firebreak.d.ts.map +1 -1
  166. package/dist/ai/src/delegation/liability-firebreak.js +1 -0
  167. package/dist/ai/src/delegation/liability-firebreak.js.map +1 -1
  168. package/dist/ai/src/delegation/security-threat-model.d.ts.map +1 -1
  169. package/dist/ai/src/delegation/security-threat-model.js +1 -1
  170. package/dist/ai/src/delegation/security-threat-model.js.map +1 -1
  171. package/dist/ai/src/delegation-capability-integration.d.ts +1 -1
  172. package/dist/ai/src/delegation-capability-integration.d.ts.map +1 -1
  173. package/dist/ai/src/delegation-capability-integration.js +2 -7
  174. package/dist/ai/src/delegation-capability-integration.js.map +1 -1
  175. package/dist/ai/src/end-to-end-workflow-orchestrator.d.ts.map +1 -1
  176. package/dist/ai/src/end-to-end-workflow-orchestrator.js +2 -1
  177. package/dist/ai/src/end-to-end-workflow-orchestrator.js.map +1 -1
  178. package/dist/ai/src/enhanced-capability-detection.d.ts +1 -1
  179. package/dist/ai/src/enhanced-capability-detection.d.ts.map +1 -1
  180. package/dist/ai/src/enhanced-capability-detection.js +1 -1
  181. package/dist/ai/src/enhanced-capability-detection.js.map +1 -1
  182. package/dist/ai/src/gateway/index.d.ts +6 -0
  183. package/dist/ai/src/gateway/index.d.ts.map +1 -0
  184. package/dist/ai/src/gateway/index.js +6 -0
  185. package/dist/ai/src/gateway/index.js.map +1 -0
  186. package/dist/ai/src/gateway/message-gateway.d.ts +296 -0
  187. package/dist/ai/src/gateway/message-gateway.d.ts.map +1 -0
  188. package/dist/ai/src/gateway/message-gateway.js +415 -0
  189. package/dist/ai/src/gateway/message-gateway.js.map +1 -0
  190. package/dist/ai/src/intelligent-cache-manager.d.ts.map +1 -1
  191. package/dist/ai/src/intelligent-cache-manager.js +2 -1
  192. package/dist/ai/src/intelligent-cache-manager.js.map +1 -1
  193. package/dist/ai/src/mcp/index.d.ts +10 -0
  194. package/dist/ai/src/mcp/index.d.ts.map +1 -0
  195. package/dist/ai/src/mcp/index.js +10 -0
  196. package/dist/ai/src/mcp/index.js.map +1 -0
  197. package/dist/ai/src/mcp/mcp-tool-bridge.d.ts +186 -0
  198. package/dist/ai/src/mcp/mcp-tool-bridge.d.ts.map +1 -0
  199. package/dist/ai/src/mcp/mcp-tool-bridge.js +292 -0
  200. package/dist/ai/src/mcp/mcp-tool-bridge.js.map +1 -0
  201. package/dist/ai/src/mcp-auto-configuration.d.ts.map +1 -1
  202. package/dist/ai/src/mcp-auto-configuration.js +2 -1
  203. package/dist/ai/src/mcp-auto-configuration.js.map +1 -1
  204. package/dist/ai/src/performance-profiler.d.ts.map +1 -1
  205. package/dist/ai/src/performance-profiler.js +1 -0
  206. package/dist/ai/src/performance-profiler.js.map +1 -1
  207. package/dist/ai/src/plugins/anomaly/anomaly-detector.d.ts +58 -0
  208. package/dist/ai/src/plugins/anomaly/anomaly-detector.d.ts.map +1 -0
  209. package/dist/ai/src/plugins/anomaly/anomaly-detector.js +101 -0
  210. package/dist/ai/src/plugins/anomaly/anomaly-detector.js.map +1 -0
  211. package/dist/ai/src/plugins/anomaly/anomaly-monitor.d.ts +145 -0
  212. package/dist/ai/src/plugins/anomaly/anomaly-monitor.d.ts.map +1 -0
  213. package/dist/ai/src/plugins/anomaly/anomaly-monitor.js +245 -0
  214. package/dist/ai/src/plugins/anomaly/anomaly-monitor.js.map +1 -0
  215. package/dist/ai/src/plugins/anomaly/behavior-baseline.d.ts +79 -0
  216. package/dist/ai/src/plugins/anomaly/behavior-baseline.d.ts.map +1 -0
  217. package/dist/ai/src/plugins/anomaly/behavior-baseline.js +161 -0
  218. package/dist/ai/src/plugins/anomaly/behavior-baseline.js.map +1 -0
  219. package/dist/ai/src/plugins/anomaly/index.d.ts +15 -0
  220. package/dist/ai/src/plugins/anomaly/index.d.ts.map +1 -0
  221. package/dist/ai/src/plugins/anomaly/index.js +12 -0
  222. package/dist/ai/src/plugins/anomaly/index.js.map +1 -0
  223. package/dist/ai/src/plugins/anomaly/types.d.ts +150 -0
  224. package/dist/ai/src/plugins/anomaly/types.d.ts.map +1 -0
  225. package/dist/ai/src/plugins/anomaly/types.js +68 -0
  226. package/dist/ai/src/plugins/anomaly/types.js.map +1 -0
  227. package/dist/ai/src/plugins/certification/certification-manager.d.ts +102 -0
  228. package/dist/ai/src/plugins/certification/certification-manager.d.ts.map +1 -0
  229. package/dist/ai/src/plugins/certification/certification-manager.js +321 -0
  230. package/dist/ai/src/plugins/certification/certification-manager.js.map +1 -0
  231. package/dist/ai/src/plugins/certification/index.d.ts +12 -0
  232. package/dist/ai/src/plugins/certification/index.d.ts.map +1 -0
  233. package/dist/ai/src/plugins/certification/index.js +10 -0
  234. package/dist/ai/src/plugins/certification/index.js.map +1 -0
  235. package/dist/ai/src/plugins/certification/types.d.ts +128 -0
  236. package/dist/ai/src/plugins/certification/types.d.ts.map +1 -0
  237. package/dist/ai/src/plugins/certification/types.js +201 -0
  238. package/dist/ai/src/plugins/certification/types.js.map +1 -0
  239. package/dist/ai/src/plugins/escalation/escalation-trigger.d.ts +155 -0
  240. package/dist/ai/src/plugins/escalation/escalation-trigger.d.ts.map +1 -0
  241. package/dist/ai/src/plugins/escalation/escalation-trigger.js +183 -0
  242. package/dist/ai/src/plugins/escalation/escalation-trigger.js.map +1 -0
  243. package/dist/ai/src/plugins/escalation/index.d.ts +11 -0
  244. package/dist/ai/src/plugins/escalation/index.d.ts.map +1 -0
  245. package/dist/ai/src/plugins/escalation/index.js +10 -0
  246. package/dist/ai/src/plugins/escalation/index.js.map +1 -0
  247. package/dist/ai/src/plugins/incidents/incident-response-manager.d.ts +165 -0
  248. package/dist/ai/src/plugins/incidents/incident-response-manager.d.ts.map +1 -0
  249. package/dist/ai/src/plugins/incidents/incident-response-manager.js +462 -0
  250. package/dist/ai/src/plugins/incidents/incident-response-manager.js.map +1 -0
  251. package/dist/ai/src/plugins/incidents/index.d.ts +8 -0
  252. package/dist/ai/src/plugins/incidents/index.d.ts.map +1 -0
  253. package/dist/ai/src/plugins/incidents/index.js +7 -0
  254. package/dist/ai/src/plugins/incidents/index.js.map +1 -0
  255. package/dist/ai/src/plugins/incidents/types.d.ts +183 -0
  256. package/dist/ai/src/plugins/incidents/types.d.ts.map +1 -0
  257. package/dist/ai/src/plugins/incidents/types.js +55 -0
  258. package/dist/ai/src/plugins/incidents/types.js.map +1 -0
  259. package/dist/ai/src/plugins/permissions/index.d.ts +17 -0
  260. package/dist/ai/src/plugins/permissions/index.d.ts.map +1 -0
  261. package/dist/ai/src/plugins/permissions/index.js +14 -0
  262. package/dist/ai/src/plugins/permissions/index.js.map +1 -0
  263. package/dist/ai/src/plugins/permissions/permission-attenuator.d.ts +29 -0
  264. package/dist/ai/src/plugins/permissions/permission-attenuator.d.ts.map +1 -0
  265. package/dist/ai/src/plugins/permissions/permission-attenuator.js +190 -0
  266. package/dist/ai/src/plugins/permissions/permission-attenuator.js.map +1 -0
  267. package/dist/ai/src/plugins/permissions/permission-audit-logger.d.ts +72 -0
  268. package/dist/ai/src/plugins/permissions/permission-audit-logger.d.ts.map +1 -0
  269. package/dist/ai/src/plugins/permissions/permission-audit-logger.js +176 -0
  270. package/dist/ai/src/plugins/permissions/permission-audit-logger.js.map +1 -0
  271. package/dist/ai/src/plugins/permissions/permission-enforcer.d.ts +99 -0
  272. package/dist/ai/src/plugins/permissions/permission-enforcer.d.ts.map +1 -0
  273. package/dist/ai/src/plugins/permissions/permission-enforcer.js +151 -0
  274. package/dist/ai/src/plugins/permissions/permission-enforcer.js.map +1 -0
  275. package/dist/ai/src/plugins/permissions/plugin-permission-validator.d.ts +39 -0
  276. package/dist/ai/src/plugins/permissions/plugin-permission-validator.d.ts.map +1 -0
  277. package/dist/ai/src/plugins/permissions/plugin-permission-validator.js +296 -0
  278. package/dist/ai/src/plugins/permissions/plugin-permission-validator.js.map +1 -0
  279. package/dist/ai/src/plugins/permissions/types.d.ts +116 -0
  280. package/dist/ai/src/plugins/permissions/types.d.ts.map +1 -0
  281. package/dist/ai/src/plugins/permissions/types.js +36 -0
  282. package/dist/ai/src/plugins/permissions/types.js.map +1 -0
  283. package/dist/ai/src/plugins/reputation/index.d.ts +9 -0
  284. package/dist/ai/src/plugins/reputation/index.d.ts.map +1 -0
  285. package/dist/ai/src/plugins/reputation/index.js +8 -0
  286. package/dist/ai/src/plugins/reputation/index.js.map +1 -0
  287. package/dist/ai/src/plugins/reputation/plugin-reputation-db.d.ts +29 -0
  288. package/dist/ai/src/plugins/reputation/plugin-reputation-db.d.ts.map +1 -0
  289. package/dist/ai/src/plugins/reputation/plugin-reputation-db.js +120 -0
  290. package/dist/ai/src/plugins/reputation/plugin-reputation-db.js.map +1 -0
  291. package/dist/ai/src/plugins/reputation/plugin-reputation-engine.d.ts +115 -0
  292. package/dist/ai/src/plugins/reputation/plugin-reputation-engine.d.ts.map +1 -0
  293. package/dist/ai/src/plugins/reputation/plugin-reputation-engine.js +528 -0
  294. package/dist/ai/src/plugins/reputation/plugin-reputation-engine.js.map +1 -0
  295. package/dist/ai/src/plugins/reputation/types.d.ts +149 -0
  296. package/dist/ai/src/plugins/reputation/types.d.ts.map +1 -0
  297. package/dist/ai/src/plugins/reputation/types.js +14 -0
  298. package/dist/ai/src/plugins/reputation/types.js.map +1 -0
  299. package/dist/ai/src/plugins/reviews/index.d.ts +11 -0
  300. package/dist/ai/src/plugins/reviews/index.d.ts.map +1 -0
  301. package/dist/ai/src/plugins/reviews/index.js +10 -0
  302. package/dist/ai/src/plugins/reviews/index.js.map +1 -0
  303. package/dist/ai/src/plugins/reviews/plugin-rating-aggregator.d.ts +116 -0
  304. package/dist/ai/src/plugins/reviews/plugin-rating-aggregator.d.ts.map +1 -0
  305. package/dist/ai/src/plugins/reviews/plugin-rating-aggregator.js +282 -0
  306. package/dist/ai/src/plugins/reviews/plugin-rating-aggregator.js.map +1 -0
  307. package/dist/ai/src/plugins/reviews/types.d.ts +113 -0
  308. package/dist/ai/src/plugins/reviews/types.d.ts.map +1 -0
  309. package/dist/ai/src/plugins/reviews/types.js +55 -0
  310. package/dist/ai/src/plugins/reviews/types.js.map +1 -0
  311. package/dist/ai/src/plugins/runtime/docker-plugin-runner.d.ts +77 -0
  312. package/dist/ai/src/plugins/runtime/docker-plugin-runner.d.ts.map +1 -0
  313. package/dist/ai/src/plugins/runtime/docker-plugin-runner.js +248 -0
  314. package/dist/ai/src/plugins/runtime/docker-plugin-runner.js.map +1 -0
  315. package/dist/ai/src/plugins/runtime/gvisor-plugin-runner.d.ts +99 -0
  316. package/dist/ai/src/plugins/runtime/gvisor-plugin-runner.d.ts.map +1 -0
  317. package/dist/ai/src/plugins/runtime/gvisor-plugin-runner.js +158 -0
  318. package/dist/ai/src/plugins/runtime/gvisor-plugin-runner.js.map +1 -0
  319. package/dist/ai/src/plugins/runtime/index.d.ts +13 -0
  320. package/dist/ai/src/plugins/runtime/index.d.ts.map +1 -0
  321. package/dist/ai/src/plugins/runtime/index.js +11 -0
  322. package/dist/ai/src/plugins/runtime/index.js.map +1 -0
  323. package/dist/ai/src/plugins/runtime/types.d.ts +143 -0
  324. package/dist/ai/src/plugins/runtime/types.d.ts.map +1 -0
  325. package/dist/ai/src/plugins/runtime/types.js +19 -0
  326. package/dist/ai/src/plugins/runtime/types.js.map +1 -0
  327. package/dist/ai/src/plugins/runtime/wasm-plugin-runner.d.ts +104 -0
  328. package/dist/ai/src/plugins/runtime/wasm-plugin-runner.d.ts.map +1 -0
  329. package/dist/ai/src/plugins/runtime/wasm-plugin-runner.js +307 -0
  330. package/dist/ai/src/plugins/runtime/wasm-plugin-runner.js.map +1 -0
  331. package/dist/ai/src/plugins/security/index.d.ts +24 -0
  332. package/dist/ai/src/plugins/security/index.d.ts.map +1 -0
  333. package/dist/ai/src/plugins/security/index.js +23 -0
  334. package/dist/ai/src/plugins/security/index.js.map +1 -0
  335. package/dist/ai/src/plugins/security/license-checker.d.ts +26 -0
  336. package/dist/ai/src/plugins/security/license-checker.d.ts.map +1 -0
  337. package/dist/ai/src/plugins/security/license-checker.js +137 -0
  338. package/dist/ai/src/plugins/security/license-checker.js.map +1 -0
  339. package/dist/ai/src/plugins/security/malware-scanner.d.ts +19 -0
  340. package/dist/ai/src/plugins/security/malware-scanner.d.ts.map +1 -0
  341. package/dist/ai/src/plugins/security/malware-scanner.js +121 -0
  342. package/dist/ai/src/plugins/security/malware-scanner.js.map +1 -0
  343. package/dist/ai/src/plugins/security/plugin-security-scanner.d.ts +36 -0
  344. package/dist/ai/src/plugins/security/plugin-security-scanner.d.ts.map +1 -0
  345. package/dist/ai/src/plugins/security/plugin-security-scanner.js +160 -0
  346. package/dist/ai/src/plugins/security/plugin-security-scanner.js.map +1 -0
  347. package/dist/ai/src/plugins/security/sbom-generator.d.ts +23 -0
  348. package/dist/ai/src/plugins/security/sbom-generator.d.ts.map +1 -0
  349. package/dist/ai/src/plugins/security/sbom-generator.js +115 -0
  350. package/dist/ai/src/plugins/security/sbom-generator.js.map +1 -0
  351. package/dist/ai/src/plugins/security/secret-detector.d.ts +19 -0
  352. package/dist/ai/src/plugins/security/secret-detector.d.ts.map +1 -0
  353. package/dist/ai/src/plugins/security/secret-detector.js +204 -0
  354. package/dist/ai/src/plugins/security/secret-detector.js.map +1 -0
  355. package/dist/ai/src/plugins/security/signature-verifier.d.ts +21 -0
  356. package/dist/ai/src/plugins/security/signature-verifier.d.ts.map +1 -0
  357. package/dist/ai/src/plugins/security/signature-verifier.js +75 -0
  358. package/dist/ai/src/plugins/security/signature-verifier.js.map +1 -0
  359. package/dist/ai/src/plugins/security/sonarcloud-client.d.ts +20 -0
  360. package/dist/ai/src/plugins/security/sonarcloud-client.d.ts.map +1 -0
  361. package/dist/ai/src/plugins/security/sonarcloud-client.js +106 -0
  362. package/dist/ai/src/plugins/security/sonarcloud-client.js.map +1 -0
  363. package/dist/ai/src/plugins/security/trust-score.d.ts +58 -0
  364. package/dist/ai/src/plugins/security/trust-score.d.ts.map +1 -0
  365. package/dist/ai/src/plugins/security/trust-score.js +173 -0
  366. package/dist/ai/src/plugins/security/trust-score.js.map +1 -0
  367. package/dist/ai/src/plugins/security/types.d.ts +220 -0
  368. package/dist/ai/src/plugins/security/types.d.ts.map +1 -0
  369. package/dist/ai/src/plugins/security/types.js +12 -0
  370. package/dist/ai/src/plugins/security/types.js.map +1 -0
  371. package/dist/ai/src/plugins/security/vulnerability-scanner.d.ts +22 -0
  372. package/dist/ai/src/plugins/security/vulnerability-scanner.d.ts.map +1 -0
  373. package/dist/ai/src/plugins/security/vulnerability-scanner.js +109 -0
  374. package/dist/ai/src/plugins/security/vulnerability-scanner.js.map +1 -0
  375. package/dist/ai/src/plugins/tlp/index.d.ts +17 -0
  376. package/dist/ai/src/plugins/tlp/index.d.ts.map +1 -0
  377. package/dist/ai/src/plugins/tlp/index.js +17 -0
  378. package/dist/ai/src/plugins/tlp/index.js.map +1 -0
  379. package/dist/ai/src/plugins/tlp/tlp-classifier.d.ts +55 -0
  380. package/dist/ai/src/plugins/tlp/tlp-classifier.d.ts.map +1 -0
  381. package/dist/ai/src/plugins/tlp/tlp-classifier.js +232 -0
  382. package/dist/ai/src/plugins/tlp/tlp-classifier.js.map +1 -0
  383. package/dist/ai/src/plugins/tlp/tlp-validator.d.ts +97 -0
  384. package/dist/ai/src/plugins/tlp/tlp-validator.d.ts.map +1 -0
  385. package/dist/ai/src/plugins/tlp/tlp-validator.js +120 -0
  386. package/dist/ai/src/plugins/tlp/tlp-validator.js.map +1 -0
  387. package/dist/ai/src/plugins/tlp/types.d.ts +84 -0
  388. package/dist/ai/src/plugins/tlp/types.d.ts.map +1 -0
  389. package/dist/ai/src/plugins/tlp/types.js +20 -0
  390. package/dist/ai/src/plugins/tlp/types.js.map +1 -0
  391. package/dist/ai/src/resource-monitor.d.ts +1 -1
  392. package/dist/ai/src/resource-monitor.d.ts.map +1 -1
  393. package/dist/ai/src/resource-monitor.js +4 -3
  394. package/dist/ai/src/resource-monitor.js.map +1 -1
  395. package/dist/ai/src/runtime/agent-runtime.d.ts +77 -0
  396. package/dist/ai/src/runtime/agent-runtime.d.ts.map +1 -1
  397. package/dist/ai/src/runtime/agent-runtime.js +138 -2
  398. package/dist/ai/src/runtime/agent-runtime.js.map +1 -1
  399. package/dist/ai/src/scheduler/agent-scheduler.d.ts +365 -0
  400. package/dist/ai/src/scheduler/agent-scheduler.d.ts.map +1 -0
  401. package/dist/ai/src/scheduler/agent-scheduler.js +610 -0
  402. package/dist/ai/src/scheduler/agent-scheduler.js.map +1 -0
  403. package/dist/ai/src/scheduler/index.d.ts +6 -0
  404. package/dist/ai/src/scheduler/index.d.ts.map +1 -0
  405. package/dist/ai/src/scheduler/index.js +6 -0
  406. package/dist/ai/src/scheduler/index.js.map +1 -0
  407. package/dist/ai/src/session/index.d.ts +6 -0
  408. package/dist/ai/src/session/index.d.ts.map +1 -0
  409. package/dist/ai/src/session/index.js +6 -0
  410. package/dist/ai/src/session/index.js.map +1 -0
  411. package/dist/ai/src/session/session-manager.d.ts +380 -0
  412. package/dist/ai/src/session/session-manager.d.ts.map +1 -0
  413. package/dist/ai/src/session/session-manager.js +625 -0
  414. package/dist/ai/src/session/session-manager.js.map +1 -0
  415. package/dist/ai/src/skills/index.d.ts +10 -0
  416. package/dist/ai/src/skills/index.d.ts.map +1 -0
  417. package/dist/ai/src/skills/index.js +10 -0
  418. package/dist/ai/src/skills/index.js.map +1 -0
  419. package/dist/ai/src/skills/skill-registry.d.ts +181 -0
  420. package/dist/ai/src/skills/skill-registry.d.ts.map +1 -0
  421. package/dist/ai/src/skills/skill-registry.js +465 -0
  422. package/dist/ai/src/skills/skill-registry.js.map +1 -0
  423. package/dist/ai/src/telemetry/delegation-telemetry.d.ts.map +1 -1
  424. package/dist/ai/src/telemetry/delegation-telemetry.js +1 -0
  425. package/dist/ai/src/telemetry/delegation-telemetry.js.map +1 -1
  426. package/dist/ai/src/telemetry/runtime-telemetry-integration.d.ts +1 -1
  427. package/dist/ai/src/telemetry/runtime-telemetry-integration.d.ts.map +1 -1
  428. package/dist/ai/src/telemetry/runtime-telemetry-integration.js +3 -2
  429. package/dist/ai/src/telemetry/runtime-telemetry-integration.js.map +1 -1
  430. package/dist/ai/src/telemetry/telemetry-utils.d.ts.map +1 -1
  431. package/dist/ai/src/telemetry/telemetry-utils.js +1 -0
  432. package/dist/ai/src/telemetry/telemetry-utils.js.map +1 -1
  433. package/dist/ai/src/types/agent-capabilities.d.ts.map +1 -1
  434. package/dist/ai/src/types/agent-capabilities.js +1 -0
  435. package/dist/ai/src/types/agent-capabilities.js.map +1 -1
  436. package/dist/ai/src/types/delegation-contracts.d.ts +92 -0
  437. package/dist/ai/src/types/delegation-contracts.d.ts.map +1 -1
  438. package/dist/ai/src/types/delegation-contracts.js.map +1 -1
  439. package/dist/ai/src/validation-pipeline-integration.d.ts.map +1 -1
  440. package/dist/ai/src/validation-pipeline-integration.js +1 -2
  441. package/dist/ai/src/validation-pipeline-integration.js.map +1 -1
  442. package/dist/ai/src/verification/multi-modal-formatters.d.ts +1 -1
  443. package/dist/ai/src/verification/multi-modal-formatters.d.ts.map +1 -1
  444. package/dist/ai/src/verification/multi-modal-formatters.js +3 -2
  445. package/dist/ai/src/verification/multi-modal-formatters.js.map +1 -1
  446. package/dist/ai/src/verification/output-formatter.d.ts +1 -1
  447. package/dist/ai/src/verification/output-formatter.d.ts.map +1 -1
  448. package/dist/ai/src/verification/output-formatter.js +2 -1
  449. package/dist/ai/src/verification/output-formatter.js.map +1 -1
  450. package/dist/ai/src/verification/parser-integration.d.ts.map +1 -1
  451. package/dist/ai/src/verification/parser-integration.js.map +1 -1
  452. package/dist/ai/types/agent-capabilities.d.ts +7 -0
  453. package/dist/ai/types/agent-capabilities.d.ts.map +1 -1
  454. package/dist/ai/types/delegation-contracts.d.ts +75 -0
  455. package/dist/ai/types/delegation-contracts.d.ts.map +1 -1
  456. package/dist/ai/types/index.d.ts +3 -3
  457. package/dist/ai/types/index.d.ts.map +1 -1
  458. package/dist/ai/types/index.js.map +1 -1
  459. package/dist/ai/types/permission-tokens.d.ts +23 -0
  460. package/dist/ai/types/permission-tokens.d.ts.map +1 -1
  461. package/dist/ai/types/permission-tokens.js +65 -1
  462. package/dist/ai/types/permission-tokens.js.map +1 -1
  463. package/dist/ai/validation/validation-framework.d.ts.map +1 -1
  464. package/dist/ai/verification/policy-framework.d.ts +1 -1
  465. package/dist/ai/verification/policy-framework.d.ts.map +1 -1
  466. package/dist/ai/verification/policy-framework.js +4 -4
  467. package/dist/ai/verification/policy-framework.js.map +1 -1
  468. package/package.json +33 -4
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Behavior Baseline Profiler
3
+ *
4
+ * Maintains per-plugin rolling statistical baselines using Welford's online
5
+ * algorithm. Tracks mean and standard deviation for each behavioral metric
6
+ * without storing raw samples.
7
+ *
8
+ * @module plugins/anomaly/behavior-baseline
9
+ * @version 1.0.0
10
+ * @date 2026-02-28
11
+ * @license MIT
12
+ */
13
+ import type { PluginBaseline, PluginMetricSample, BehaviorMetric } from './types.js';
14
+ /**
15
+ * In-memory behavior baseline store.
16
+ *
17
+ * Uses Welford's online algorithm for numerically stable computation of
18
+ * rolling mean and standard deviation without retaining raw sample history.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const baseline = new BehaviorBaseline();
23
+ * baseline.updateBaseline({ plugin_id: 'my-plugin', run_id: 'r1',
24
+ * measured_at: new Date().toISOString(), filesystem_ops: 120,
25
+ * network_requests: 5, cpu_percent: 30, memory_mb: 80 });
26
+ *
27
+ * const sigma = baseline.getStdDevsFromMean('my-plugin', 'filesystem_ops', 900);
28
+ * // returns null when < MIN_SAMPLES, or a numeric z-score otherwise
29
+ * ```
30
+ */
31
+ export declare class BehaviorBaseline {
32
+ /**
33
+ * Minimum samples required before std-dev comparisons are meaningful.
34
+ * Below this threshold, `getStdDevsFromMean` returns null.
35
+ */
36
+ static readonly MIN_SAMPLES = 5;
37
+ /** plugin_id → metric → running stats */
38
+ private readonly store;
39
+ /**
40
+ * Incorporate a new sample into all four metric baselines for the plugin.
41
+ * Safe to call on the very first observation — initialises state automatically.
42
+ */
43
+ updateBaseline(sample: PluginMetricSample): void;
44
+ /**
45
+ * Retrieve the current baseline for a specific plugin + metric.
46
+ * Returns `null` if no observations have been made yet.
47
+ */
48
+ getBaseline(pluginId: string, metric: BehaviorMetric): PluginBaseline | null;
49
+ /**
50
+ * Calculate how many standard deviations `value` is from the baseline mean.
51
+ *
52
+ * Returns `null` when:
53
+ * - No baseline exists for this plugin + metric.
54
+ * - Sample count is below `MIN_SAMPLES` (baseline not yet reliable).
55
+ * - The standard deviation is 0 or effectively zero (constant metric) —
56
+ * returns `null` to avoid false spikes on perfectly stable plugins.
57
+ */
58
+ getStdDevsFromMean(pluginId: string, metric: BehaviorMetric, value: number): number | null;
59
+ /**
60
+ * Return all baselines for a given plugin.
61
+ * Useful for serialisation or debugging.
62
+ */
63
+ getAllBaselines(pluginId: string): PluginBaseline[];
64
+ /**
65
+ * Reset all baselines for a plugin. Used when a plugin is re-certified or
66
+ * after a version bump that changes expected behaviour.
67
+ */
68
+ resetBaseline(pluginId: string): void;
69
+ private getOrCreatePluginMap;
70
+ /**
71
+ * Welford's online algorithm — single-pass update of mean and M2.
72
+ *
73
+ * @see https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
74
+ */
75
+ private welfordUpdate;
76
+ /** Population standard deviation derived from M2 accumulator. */
77
+ private deriveStdDev;
78
+ }
79
+ //# sourceMappingURL=behavior-baseline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behavior-baseline.d.ts","sourceRoot":"","sources":["../../../../../packages/ai/src/plugins/anomaly/behavior-baseline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,cAAc,EACf,MAAM,YAAY,CAAC;AAqBpB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAgB;IAC3B;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,WAAW,KAAK;IAEhC,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAM3D;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAahD;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,cAAc,GAAG,IAAI;IAc5E;;;;;;;;OAQG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAU1F;;;OAGG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE;IAqBnD;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQrC,OAAO,CAAC,oBAAoB;IAQ5B;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAerB,iEAAiE;IACjE,OAAO,CAAC,YAAY;CAIrB"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Behavior Baseline Profiler
3
+ *
4
+ * Maintains per-plugin rolling statistical baselines using Welford's online
5
+ * algorithm. Tracks mean and standard deviation for each behavioral metric
6
+ * without storing raw samples.
7
+ *
8
+ * @module plugins/anomaly/behavior-baseline
9
+ * @version 1.0.0
10
+ * @date 2026-02-28
11
+ * @license MIT
12
+ */
13
+ import { BEHAVIOR_METRICS } from './types.js';
14
+ // ---------------------------------------------------------------------------
15
+ // BehaviorBaseline
16
+ // ---------------------------------------------------------------------------
17
+ /**
18
+ * In-memory behavior baseline store.
19
+ *
20
+ * Uses Welford's online algorithm for numerically stable computation of
21
+ * rolling mean and standard deviation without retaining raw sample history.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const baseline = new BehaviorBaseline();
26
+ * baseline.updateBaseline({ plugin_id: 'my-plugin', run_id: 'r1',
27
+ * measured_at: new Date().toISOString(), filesystem_ops: 120,
28
+ * network_requests: 5, cpu_percent: 30, memory_mb: 80 });
29
+ *
30
+ * const sigma = baseline.getStdDevsFromMean('my-plugin', 'filesystem_ops', 900);
31
+ * // returns null when < MIN_SAMPLES, or a numeric z-score otherwise
32
+ * ```
33
+ */
34
+ export class BehaviorBaseline {
35
+ /**
36
+ * Minimum samples required before std-dev comparisons are meaningful.
37
+ * Below this threshold, `getStdDevsFromMean` returns null.
38
+ */
39
+ static MIN_SAMPLES = 5;
40
+ /** plugin_id → metric → running stats */
41
+ store = new Map();
42
+ // --------------------------------------------------------------------------
43
+ // Public API
44
+ // --------------------------------------------------------------------------
45
+ /**
46
+ * Incorporate a new sample into all four metric baselines for the plugin.
47
+ * Safe to call on the very first observation — initialises state automatically.
48
+ */
49
+ updateBaseline(sample) {
50
+ const pluginMap = this.getOrCreatePluginMap(sample.plugin_id);
51
+ const now = sample.measured_at;
52
+ for (const metric of BEHAVIOR_METRICS) {
53
+ const value = sample[metric];
54
+ const state = pluginMap.get(metric) ?? { mean: 0, m2: 0, sample_count: 0, last_updated: now };
55
+ pluginMap.set(metric, this.welfordUpdate(state, value, now));
56
+ }
57
+ this.store.set(sample.plugin_id, pluginMap);
58
+ }
59
+ /**
60
+ * Retrieve the current baseline for a specific plugin + metric.
61
+ * Returns `null` if no observations have been made yet.
62
+ */
63
+ getBaseline(pluginId, metric) {
64
+ const state = this.store.get(pluginId)?.get(metric);
65
+ if (!state || state.sample_count === 0)
66
+ return null;
67
+ return {
68
+ plugin_id: pluginId,
69
+ metric,
70
+ mean: state.mean,
71
+ std_dev: this.deriveStdDev(state),
72
+ sample_count: state.sample_count,
73
+ last_updated: state.last_updated,
74
+ };
75
+ }
76
+ /**
77
+ * Calculate how many standard deviations `value` is from the baseline mean.
78
+ *
79
+ * Returns `null` when:
80
+ * - No baseline exists for this plugin + metric.
81
+ * - Sample count is below `MIN_SAMPLES` (baseline not yet reliable).
82
+ * - The standard deviation is 0 or effectively zero (constant metric) —
83
+ * returns `null` to avoid false spikes on perfectly stable plugins.
84
+ */
85
+ getStdDevsFromMean(pluginId, metric, value) {
86
+ const state = this.store.get(pluginId)?.get(metric);
87
+ if (!state || state.sample_count < BehaviorBaseline.MIN_SAMPLES)
88
+ return null;
89
+ const stdDev = this.deriveStdDev(state);
90
+ if (stdDev < 1e-10)
91
+ return null; // constant metric — no meaningful z-score
92
+ return (value - state.mean) / stdDev;
93
+ }
94
+ /**
95
+ * Return all baselines for a given plugin.
96
+ * Useful for serialisation or debugging.
97
+ */
98
+ getAllBaselines(pluginId) {
99
+ const pluginMap = this.store.get(pluginId);
100
+ if (!pluginMap)
101
+ return [];
102
+ const baselines = [];
103
+ for (const metric of BEHAVIOR_METRICS) {
104
+ const state = pluginMap.get(metric);
105
+ if (state && state.sample_count > 0) {
106
+ baselines.push({
107
+ plugin_id: pluginId,
108
+ metric,
109
+ mean: state.mean,
110
+ std_dev: this.deriveStdDev(state),
111
+ sample_count: state.sample_count,
112
+ last_updated: state.last_updated,
113
+ });
114
+ }
115
+ }
116
+ return baselines;
117
+ }
118
+ /**
119
+ * Reset all baselines for a plugin. Used when a plugin is re-certified or
120
+ * after a version bump that changes expected behaviour.
121
+ */
122
+ resetBaseline(pluginId) {
123
+ this.store.delete(pluginId);
124
+ }
125
+ // --------------------------------------------------------------------------
126
+ // Private helpers
127
+ // --------------------------------------------------------------------------
128
+ getOrCreatePluginMap(pluginId) {
129
+ const existing = this.store.get(pluginId);
130
+ if (existing)
131
+ return existing;
132
+ const map = new Map();
133
+ this.store.set(pluginId, map);
134
+ return map;
135
+ }
136
+ /**
137
+ * Welford's online algorithm — single-pass update of mean and M2.
138
+ *
139
+ * @see https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
140
+ */
141
+ welfordUpdate(state, newValue, now) {
142
+ const n = state.sample_count + 1;
143
+ const delta = newValue - state.mean;
144
+ const newMean = state.mean + delta / n;
145
+ const delta2 = newValue - newMean;
146
+ const newM2 = state.m2 + delta * delta2;
147
+ return {
148
+ mean: newMean,
149
+ m2: newM2,
150
+ sample_count: n,
151
+ last_updated: now,
152
+ };
153
+ }
154
+ /** Population standard deviation derived from M2 accumulator. */
155
+ deriveStdDev(state) {
156
+ if (state.sample_count < 2)
157
+ return 0;
158
+ return Math.sqrt(state.m2 / state.sample_count);
159
+ }
160
+ }
161
+ //# sourceMappingURL=behavior-baseline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behavior-baseline.js","sourceRoot":"","sources":["../../../../../packages/ai/src/plugins/anomaly/behavior-baseline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgB9C,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;OAGG;IACH,MAAM,CAAU,WAAW,GAAG,CAAC,CAAC;IAEhC,yCAAyC;IACxB,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE3D,6EAA6E;IAC7E,aAAa;IACb,6EAA6E;IAE7E;;;OAGG;IACH,cAAc,CAAC,MAA0B;QACvC,MAAM,SAAS,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC9D,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC;QAE/B,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAC7B,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC;YAC9F,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/D,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,QAAg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,GAAG,KAAK,GAAG,MAAM,CAAC;QAExC,OAAO;YACL,IAAI,EAAE,OAAO;YACb,EAAE,EAAE,KAAK;YACT,YAAY,EAAE,CAAC;YACf,YAAY,EAAE,GAAG;SAClB,CAAC;IACJ,CAAC;IAED,iEAAiE;IACzD,YAAY,CAAC,KAAoB;QACvC,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Plugin Behavioral Anomaly Detection
3
+ *
4
+ * Exports the full anomaly detection pipeline for plugin behavioral monitoring.
5
+ *
6
+ * @module plugins/anomaly
7
+ */
8
+ export { BehaviorBaseline } from './behavior-baseline.js';
9
+ export { AnomalyDetector } from './anomaly-detector.js';
10
+ export type { AnomalyDetectorConfig } from './anomaly-detector.js';
11
+ export { AnomalyMonitor } from './anomaly-monitor.js';
12
+ export type { AnomalyMonitorConfig, ResolveOptions, AnomalyStats, } from './anomaly-monitor.js';
13
+ export { ANOMALY_SCHEMA_SQL, BEHAVIOR_METRICS } from './types.js';
14
+ export type { PluginMetricSample, BehaviorMetric, PluginBaseline, AnomalyType, AnomalySeverity, DetectedAnomaly, ReviewStatus, AnomalyReviewItem, AnomalyMonitorResult, AnomalyAxiomPayload, AnomalyAxiomLogger, } from './types.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/ai/src/plugins/anomaly/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Plugin Behavioral Anomaly Detection
3
+ *
4
+ * Exports the full anomaly detection pipeline for plugin behavioral monitoring.
5
+ *
6
+ * @module plugins/anomaly
7
+ */
8
+ export { BehaviorBaseline } from './behavior-baseline.js';
9
+ export { AnomalyDetector } from './anomaly-detector.js';
10
+ export { AnomalyMonitor } from './anomaly-monitor.js';
11
+ export { ANOMALY_SCHEMA_SQL, BEHAVIOR_METRICS } from './types.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/ai/src/plugins/anomaly/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAMtD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Behavioral Anomaly Detection — Types
3
+ *
4
+ * All type definitions for the plugin behavioral anomaly detection system.
5
+ * Implements Phase 16 (Behavioral Anomaly Detection) of the Plugin Marketplace
6
+ * Security roadmap.
7
+ *
8
+ * @module plugins/anomaly/types
9
+ * @version 1.0.0
10
+ * @date 2026-02-28
11
+ * @license MIT
12
+ */
13
+ /** Metrics captured from a single plugin execution run. */
14
+ export interface PluginMetricSample {
15
+ /** Stable plugin identifier (e.g. "my-plugin@1.0.0"). */
16
+ plugin_id: string;
17
+ /** Unique UUID for this execution run. */
18
+ run_id: string;
19
+ /** ISO 8601 timestamp of when the sample was captured. */
20
+ measured_at: string;
21
+ /** Total filesystem system calls (reads + writes + stats). */
22
+ filesystem_ops: number;
23
+ /** Total outbound HTTP/HTTPS requests made during the run. */
24
+ network_requests: number;
25
+ /** Average CPU utilisation as a percentage (0–100). */
26
+ cpu_percent: number;
27
+ /** Peak resident set size in megabytes. */
28
+ memory_mb: number;
29
+ }
30
+ /** The four trackable behavioral metrics. */
31
+ export type BehaviorMetric = 'filesystem_ops' | 'network_requests' | 'cpu_percent' | 'memory_mb';
32
+ /** All trackable metric names. */
33
+ export declare const BEHAVIOR_METRICS: readonly BehaviorMetric[];
34
+ /**
35
+ * Rolling statistical baseline for a single plugin + metric pair.
36
+ * Updated via Welford's online algorithm to avoid storing raw samples.
37
+ */
38
+ export interface PluginBaseline {
39
+ /** Stable plugin identifier. */
40
+ plugin_id: string;
41
+ /** The metric this baseline applies to. */
42
+ metric: BehaviorMetric;
43
+ /** Current rolling mean. */
44
+ mean: number;
45
+ /** Current rolling standard deviation (population). */
46
+ std_dev: number;
47
+ /** Number of samples incorporated so far. */
48
+ sample_count: number;
49
+ /** ISO 8601 timestamp of the most recent update. */
50
+ last_updated: string;
51
+ }
52
+ /** Category of anomalous behaviour detected. */
53
+ export type AnomalyType = 'filesystem_spike' | 'network_spike' | 'cpu_spike' | 'memory_spike';
54
+ /**
55
+ * Anomaly severity levels.
56
+ * - WARNING → 2–3 standard deviations above mean (investigate)
57
+ * - CRITICAL → >3 standard deviations above mean (auto-suspend eligible)
58
+ */
59
+ export type AnomalySeverity = 'WARNING' | 'CRITICAL';
60
+ /** A point-in-time anomaly detected during plugin monitoring. */
61
+ export interface DetectedAnomaly {
62
+ /** UUID for this anomaly event. */
63
+ id: string;
64
+ /** Plugin that produced the anomaly. */
65
+ plugin_id: string;
66
+ /** Run ID that triggered detection. */
67
+ run_id: string;
68
+ /** Category matching the affected metric. */
69
+ anomaly_type: AnomalyType;
70
+ /** Observed value that exceeded the baseline. */
71
+ metric_value: number;
72
+ /** Baseline mean at detection time. */
73
+ baseline_mean: number;
74
+ /** Baseline std deviation at detection time. */
75
+ baseline_std_dev: number;
76
+ /** How many std deviations the observed value is from the mean. */
77
+ std_devs_from_mean: number;
78
+ /** Severity classification. */
79
+ severity: AnomalySeverity;
80
+ /** ISO 8601 detection timestamp. */
81
+ detected_at: string;
82
+ }
83
+ /** Status of an anomaly in the human review queue. */
84
+ export type ReviewStatus = 'PENDING_REVIEW' | 'RESOLVED' | 'FALSE_POSITIVE';
85
+ /** An anomaly queued for human review. */
86
+ export interface AnomalyReviewItem {
87
+ /** UUID matching DetectedAnomaly.id. */
88
+ anomaly_id: string;
89
+ /** Plugin under review. */
90
+ plugin_id: string;
91
+ /** Anomaly category. */
92
+ anomaly_type: AnomalyType;
93
+ /** Severity at time of detection. */
94
+ severity: AnomalySeverity;
95
+ /** Observed metric value. */
96
+ metric_value: number;
97
+ /** Standard deviations from mean. */
98
+ std_devs_from_mean: number;
99
+ /** ISO 8601 detection timestamp. */
100
+ detected_at: string;
101
+ /** Current review status. */
102
+ status: ReviewStatus;
103
+ /** Username / agent ID that reviewed this item. */
104
+ reviewed_by?: string;
105
+ /** ISO 8601 timestamp of resolution. */
106
+ resolved_at?: string;
107
+ /** Free-text notes from the reviewer. */
108
+ resolution_notes?: string;
109
+ }
110
+ /** Result returned after a full observe-detect-alert cycle. */
111
+ export interface AnomalyMonitorResult {
112
+ /** Observed plugin ID. */
113
+ plugin_id: string;
114
+ /** Run ID being monitored. */
115
+ run_id: string;
116
+ /** All anomalies detected in this run. Empty array when clean. */
117
+ anomalies: DetectedAnomaly[];
118
+ /**
119
+ * True when auto-suspend was triggered.
120
+ * Callers should halt execution and await human review before restarting.
121
+ */
122
+ suspended: boolean;
123
+ /** Human-readable reason if `suspended` is true. */
124
+ suspension_reason?: string;
125
+ }
126
+ /** Payload sent to Axiom for each anomaly event. */
127
+ export interface AnomalyAxiomPayload {
128
+ /** Event source identifier. */
129
+ _source: 'dcyfr-plugin-anomaly-monitor';
130
+ plugin_id: string;
131
+ run_id: string;
132
+ anomaly_id: string;
133
+ anomaly_type: AnomalyType;
134
+ severity: AnomalySeverity;
135
+ metric_value: number;
136
+ baseline_mean: number;
137
+ std_devs_from_mean: number;
138
+ auto_suspended: boolean;
139
+ detected_at: string;
140
+ }
141
+ /**
142
+ * Pluggable Axiom logger interface.
143
+ * Inject the real Axiom client in production; use a test double in tests.
144
+ */
145
+ export interface AnomalyAxiomLogger {
146
+ logEvent(payload: AnomalyAxiomPayload): Promise<void>;
147
+ }
148
+ /** DDL for persisting baselines and anomaly records. */
149
+ export declare const ANOMALY_SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS plugin_baselines (\n plugin_id TEXT NOT NULL,\n metric TEXT NOT NULL,\n mean REAL NOT NULL DEFAULT 0,\n std_dev REAL NOT NULL DEFAULT 0,\n sample_count INTEGER NOT NULL DEFAULT 0,\n last_updated TEXT NOT NULL,\n PRIMARY KEY (plugin_id, metric)\n);\n\nCREATE TABLE IF NOT EXISTS plugin_anomalies (\n id TEXT PRIMARY KEY,\n plugin_id TEXT NOT NULL,\n run_id TEXT NOT NULL,\n anomaly_type TEXT NOT NULL,\n metric_value REAL NOT NULL,\n baseline_mean REAL NOT NULL,\n baseline_std_dev REAL NOT NULL,\n std_devs_from_mean REAL NOT NULL,\n severity TEXT NOT NULL,\n detected_at TEXT NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS anomaly_review_queue (\n anomaly_id TEXT PRIMARY KEY,\n plugin_id TEXT NOT NULL,\n anomaly_type TEXT NOT NULL,\n severity TEXT NOT NULL,\n metric_value REAL NOT NULL,\n std_devs_from_mean REAL NOT NULL,\n detected_at TEXT NOT NULL,\n status TEXT NOT NULL DEFAULT 'PENDING_REVIEW',\n reviewed_by TEXT,\n resolved_at TEXT,\n resolution_notes TEXT\n);\n\nCREATE INDEX IF NOT EXISTS idx_anomalies_plugin\n ON plugin_anomalies (plugin_id, detected_at);\n\nCREATE INDEX IF NOT EXISTS idx_review_queue_status\n ON anomaly_review_queue (status, detected_at);\n";
150
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../packages/ai/src/plugins/anomaly/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,cAAc,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,aAAa,GAAG,WAAW,CAAC;AAEjG,kCAAkC;AAClC,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAK5C,CAAC;AAMX;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,MAAM,EAAE,cAAc,CAAC;IACvB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;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xC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAMD,+DAA+D;AAC/D,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAMD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,+BAA+B;IAC/B,OAAO,EAAE,8BAA8B,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,WAAW,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAMD,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,u4CA2C9B,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Behavioral Anomaly Detection — Types
3
+ *
4
+ * All type definitions for the plugin behavioral anomaly detection system.
5
+ * Implements Phase 16 (Behavioral Anomaly Detection) of the Plugin Marketplace
6
+ * Security roadmap.
7
+ *
8
+ * @module plugins/anomaly/types
9
+ * @version 1.0.0
10
+ * @date 2026-02-28
11
+ * @license MIT
12
+ */
13
+ /** All trackable metric names. */
14
+ export const BEHAVIOR_METRICS = [
15
+ 'filesystem_ops',
16
+ 'network_requests',
17
+ 'cpu_percent',
18
+ 'memory_mb',
19
+ ];
20
+ // ---------------------------------------------------------------------------
21
+ // SQL schema
22
+ // ---------------------------------------------------------------------------
23
+ /** DDL for persisting baselines and anomaly records. */
24
+ export const ANOMALY_SCHEMA_SQL = /* sql */ `
25
+ CREATE TABLE IF NOT EXISTS plugin_baselines (
26
+ plugin_id TEXT NOT NULL,
27
+ metric TEXT NOT NULL,
28
+ mean REAL NOT NULL DEFAULT 0,
29
+ std_dev REAL NOT NULL DEFAULT 0,
30
+ sample_count INTEGER NOT NULL DEFAULT 0,
31
+ last_updated TEXT NOT NULL,
32
+ PRIMARY KEY (plugin_id, metric)
33
+ );
34
+
35
+ CREATE TABLE IF NOT EXISTS plugin_anomalies (
36
+ id TEXT PRIMARY KEY,
37
+ plugin_id TEXT NOT NULL,
38
+ run_id TEXT NOT NULL,
39
+ anomaly_type TEXT NOT NULL,
40
+ metric_value REAL NOT NULL,
41
+ baseline_mean REAL NOT NULL,
42
+ baseline_std_dev REAL NOT NULL,
43
+ std_devs_from_mean REAL NOT NULL,
44
+ severity TEXT NOT NULL,
45
+ detected_at TEXT NOT NULL
46
+ );
47
+
48
+ CREATE TABLE IF NOT EXISTS anomaly_review_queue (
49
+ anomaly_id TEXT PRIMARY KEY,
50
+ plugin_id TEXT NOT NULL,
51
+ anomaly_type TEXT NOT NULL,
52
+ severity TEXT NOT NULL,
53
+ metric_value REAL NOT NULL,
54
+ std_devs_from_mean REAL NOT NULL,
55
+ detected_at TEXT NOT NULL,
56
+ status TEXT NOT NULL DEFAULT 'PENDING_REVIEW',
57
+ reviewed_by TEXT,
58
+ resolved_at TEXT,
59
+ resolution_notes TEXT
60
+ );
61
+
62
+ CREATE INDEX IF NOT EXISTS idx_anomalies_plugin
63
+ ON plugin_anomalies (plugin_id, detected_at);
64
+
65
+ CREATE INDEX IF NOT EXISTS idx_review_queue_status
66
+ ON anomaly_review_queue (status, detected_at);
67
+ `;
68
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../packages/ai/src/plugins/anomaly/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA2BH,kCAAkC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAA8B;IACzD,gBAAgB;IAChB,kBAAkB;IAClB,aAAa;IACb,WAAW;CACH,CAAC;AAqJX,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,wDAAwD;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C3C,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Plugin Certification Manager
3
+ *
4
+ * Orchestrates the full certification lifecycle:
5
+ * - Accept audit request (Bronze is free and auto-approved)
6
+ * - Confirm payment for paid tiers (Silver / Gold)
7
+ * - Assign auditor and run checklist
8
+ * - Issue certification badge with expiration
9
+ * - Support marketplace listings query
10
+ * - Revoke or expire badges
11
+ *
12
+ * @module plugins/certification/certification-manager
13
+ */
14
+ import { type AuditRequest, type CertificationBadge, type CertificationStatus, type CertificationTier, type PluginCertificationSummary } from './types.js';
15
+ export interface CertificationManagerConfig {
16
+ /**
17
+ * Base URL used to build badge verification links.
18
+ * @default 'https://www.dcyfr.ai/plugins/certification'
19
+ */
20
+ verificationBaseUrl?: string;
21
+ /**
22
+ * Who issues the certificates — appears in the badge.
23
+ * @default 'DCYFR Security Team'
24
+ */
25
+ issuingAuthority?: string;
26
+ /**
27
+ * Compute the bundle hash for a plugin at certification time.
28
+ * Called with the plugin_id + version; defaults to a deterministic placeholder.
29
+ * In production, replace with actual bundle integrity hash (e.g. SHA-256 of the tarball).
30
+ */
31
+ computeBundleHash?: (pluginId: string, version: string) => Promise<string>;
32
+ }
33
+ export declare class CertificationError extends Error {
34
+ readonly code: string;
35
+ constructor(message: string, code: string);
36
+ }
37
+ /**
38
+ * Manages the full plugin certification lifecycle.
39
+ *
40
+ * State is kept in-memory for testing; production implementations should
41
+ * back this with a database (see CERTIFICATION_SCHEMA_SQL in types.ts).
42
+ */
43
+ export declare class CertificationManager {
44
+ private readonly requests;
45
+ private readonly badges;
46
+ private readonly verificationBaseUrl;
47
+ private readonly issuingAuthority;
48
+ private readonly computeBundleHash;
49
+ constructor(config?: CertificationManagerConfig);
50
+ /**
51
+ * Submit a certification request for a plugin.
52
+ *
53
+ * Bronze: Immediately moves to `PAYMENT_RECEIVED` (free, no payment needed).
54
+ * Silver/Gold: Moves to `PENDING_PAYMENT`; caller must supply payment_reference_id
55
+ * then call `confirmPayment()`.
56
+ */
57
+ submitAuditRequest(pluginId: string, version: string, tier: CertificationTier, submittedBy: string): AuditRequest;
58
+ /**
59
+ * Record payment confirmation.
60
+ * Moves request from `PENDING_PAYMENT` → `PAYMENT_RECEIVED`.
61
+ *
62
+ * @param requestId The audit request ID.
63
+ * @param paymentRefId Payment provider reference (e.g. Stripe PaymentIntent ID).
64
+ */
65
+ confirmPayment(requestId: string, paymentRefId: string): AuditRequest;
66
+ /**
67
+ * Assign an auditor and begin the audit.
68
+ * Moves request from `PAYMENT_RECEIVED` → `IN_AUDIT`.
69
+ */
70
+ startAudit(requestId: string, auditor: string): AuditRequest;
71
+ /**
72
+ * Record the result for a single audit checklist item.
73
+ */
74
+ recordChecklistResult(requestId: string, itemId: string, passed: boolean, evaluatedBy: string, notes?: string): AuditRequest;
75
+ /**
76
+ * Complete the audit.
77
+ * - If all required checklist items passed → issue badge and move to `CERTIFIED`.
78
+ * - If any required item failed → move to `FAILED`.
79
+ */
80
+ completeAudit(requestId: string, auditorNotes?: string): Promise<AuditRequest>;
81
+ private issueBadge;
82
+ /**
83
+ * Check whether a badge is currently valid (not expired, not revoked).
84
+ */
85
+ isBadgeValid(badgeId: string): boolean;
86
+ /**
87
+ * Revoke a certification badge by cancelling the associated request.
88
+ * Moves the request to `REVOKED`.
89
+ */
90
+ revokeCertification(requestId: string, reason: string): AuditRequest;
91
+ /**
92
+ * Returns the current certification summary for a plugin (for marketplace display).
93
+ * Returns the most recently certified, non-revoked request if one exists.
94
+ */
95
+ getPluginCertificationSummary(pluginId: string): PluginCertificationSummary;
96
+ getRequest(requestId: string): AuditRequest | null;
97
+ getRequestsByPlugin(pluginId: string): AuditRequest[];
98
+ getRequestsByStatus(status: CertificationStatus): AuditRequest[];
99
+ getBadge(badgeId: string): CertificationBadge | null;
100
+ private getRequestOrThrow;
101
+ }
102
+ //# sourceMappingURL=certification-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certification-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/ai/src/plugins/certification/certification-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAChC,MAAM,YAAY,CAAC;AAMpB,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5E;AAMD,qBAAa,kBAAmB,SAAQ,KAAK;aAGzB,IAAI,EAAE,MAAM;gBAD5B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM;CAM/B;AAMD;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAC5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAEhE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,Q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