governance-sdk 0.5.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 (387) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +559 -0
  3. package/dist/agent-identity-ed25519.d.ts +80 -0
  4. package/dist/agent-identity-ed25519.d.ts.map +1 -0
  5. package/dist/agent-identity-ed25519.js +134 -0
  6. package/dist/agent-identity-ed25519.js.map +1 -0
  7. package/dist/agent-identity.d.ts +65 -0
  8. package/dist/agent-identity.d.ts.map +1 -0
  9. package/dist/agent-identity.js +85 -0
  10. package/dist/agent-identity.js.map +1 -0
  11. package/dist/audit-integrity.d.ts +78 -0
  12. package/dist/audit-integrity.d.ts.map +1 -0
  13. package/dist/audit-integrity.js +173 -0
  14. package/dist/audit-integrity.js.map +1 -0
  15. package/dist/behavioral-scorer.d.ts +72 -0
  16. package/dist/behavioral-scorer.d.ts.map +1 -0
  17. package/dist/behavioral-scorer.js +223 -0
  18. package/dist/behavioral-scorer.js.map +1 -0
  19. package/dist/cli/init.d.ts +11 -0
  20. package/dist/cli/init.d.ts.map +1 -0
  21. package/dist/cli/init.js +217 -0
  22. package/dist/cli/init.js.map +1 -0
  23. package/dist/compliance-articles.d.ts +71 -0
  24. package/dist/compliance-articles.d.ts.map +1 -0
  25. package/dist/compliance-articles.js +201 -0
  26. package/dist/compliance-articles.js.map +1 -0
  27. package/dist/compliance.d.ts +24 -0
  28. package/dist/compliance.d.ts.map +1 -0
  29. package/dist/compliance.js +183 -0
  30. package/dist/compliance.js.map +1 -0
  31. package/dist/conditions/builtins.d.ts +17 -0
  32. package/dist/conditions/builtins.d.ts.map +1 -0
  33. package/dist/conditions/builtins.js +213 -0
  34. package/dist/conditions/builtins.js.map +1 -0
  35. package/dist/conditions/postprocess.d.ts +12 -0
  36. package/dist/conditions/postprocess.d.ts.map +1 -0
  37. package/dist/conditions/postprocess.js +33 -0
  38. package/dist/conditions/postprocess.js.map +1 -0
  39. package/dist/conditions/preprocess.d.ts +12 -0
  40. package/dist/conditions/preprocess.d.ts.map +1 -0
  41. package/dist/conditions/preprocess.js +47 -0
  42. package/dist/conditions/preprocess.js.map +1 -0
  43. package/dist/conditions/process.d.ts +14 -0
  44. package/dist/conditions/process.d.ts.map +1 -0
  45. package/dist/conditions/process.js +78 -0
  46. package/dist/conditions/process.js.map +1 -0
  47. package/dist/conditions/sensitive-patterns.d.ts +13 -0
  48. package/dist/conditions/sensitive-patterns.d.ts.map +1 -0
  49. package/dist/conditions/sensitive-patterns.js +42 -0
  50. package/dist/conditions/sensitive-patterns.js.map +1 -0
  51. package/dist/dry-run.d.ts +85 -0
  52. package/dist/dry-run.d.ts.map +1 -0
  53. package/dist/dry-run.js +132 -0
  54. package/dist/dry-run.js.map +1 -0
  55. package/dist/eval-red-team.d.ts +69 -0
  56. package/dist/eval-red-team.d.ts.map +1 -0
  57. package/dist/eval-red-team.js +205 -0
  58. package/dist/eval-red-team.js.map +1 -0
  59. package/dist/eval-scorer.d.ts +56 -0
  60. package/dist/eval-scorer.d.ts.map +1 -0
  61. package/dist/eval-scorer.js +148 -0
  62. package/dist/eval-scorer.js.map +1 -0
  63. package/dist/eval-trace.d.ts +30 -0
  64. package/dist/eval-trace.d.ts.map +1 -0
  65. package/dist/eval-trace.js +129 -0
  66. package/dist/eval-trace.js.map +1 -0
  67. package/dist/eval-types.d.ts +108 -0
  68. package/dist/eval-types.d.ts.map +1 -0
  69. package/dist/eval-types.js +14 -0
  70. package/dist/eval-types.js.map +1 -0
  71. package/dist/events.d.ts +57 -0
  72. package/dist/events.d.ts.map +1 -0
  73. package/dist/events.js +81 -0
  74. package/dist/events.js.map +1 -0
  75. package/dist/federation-types.d.ts +58 -0
  76. package/dist/federation-types.d.ts.map +1 -0
  77. package/dist/federation-types.js +8 -0
  78. package/dist/federation-types.js.map +1 -0
  79. package/dist/federation.d.ts +42 -0
  80. package/dist/federation.d.ts.map +1 -0
  81. package/dist/federation.js +158 -0
  82. package/dist/federation.js.map +1 -0
  83. package/dist/index.d.ts +142 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +273 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/injection-benchmark.d.ts +62 -0
  88. package/dist/injection-benchmark.d.ts.map +1 -0
  89. package/dist/injection-benchmark.js +201 -0
  90. package/dist/injection-benchmark.js.map +1 -0
  91. package/dist/injection-classifier.d.ts +69 -0
  92. package/dist/injection-classifier.d.ts.map +1 -0
  93. package/dist/injection-classifier.js +98 -0
  94. package/dist/injection-classifier.js.map +1 -0
  95. package/dist/injection-detect.d.ts +59 -0
  96. package/dist/injection-detect.d.ts.map +1 -0
  97. package/dist/injection-detect.js +175 -0
  98. package/dist/injection-detect.js.map +1 -0
  99. package/dist/injection-patterns-ext.d.ts +7 -0
  100. package/dist/injection-patterns-ext.d.ts.map +1 -0
  101. package/dist/injection-patterns-ext.js +71 -0
  102. package/dist/injection-patterns-ext.js.map +1 -0
  103. package/dist/injection-patterns.d.ts +15 -0
  104. package/dist/injection-patterns.d.ts.map +1 -0
  105. package/dist/injection-patterns.js +361 -0
  106. package/dist/injection-patterns.js.map +1 -0
  107. package/dist/iso-42001-articles.d.ts +34 -0
  108. package/dist/iso-42001-articles.d.ts.map +1 -0
  109. package/dist/iso-42001-articles.js +147 -0
  110. package/dist/iso-42001-articles.js.map +1 -0
  111. package/dist/iso-42001.d.ts +18 -0
  112. package/dist/iso-42001.d.ts.map +1 -0
  113. package/dist/iso-42001.js +156 -0
  114. package/dist/iso-42001.js.map +1 -0
  115. package/dist/kill-switch.d.ts +56 -0
  116. package/dist/kill-switch.d.ts.map +1 -0
  117. package/dist/kill-switch.js +173 -0
  118. package/dist/kill-switch.js.map +1 -0
  119. package/dist/metrics.d.ts +58 -0
  120. package/dist/metrics.d.ts.map +1 -0
  121. package/dist/metrics.js +81 -0
  122. package/dist/metrics.js.map +1 -0
  123. package/dist/monorepo-detect.d.ts +30 -0
  124. package/dist/monorepo-detect.d.ts.map +1 -0
  125. package/dist/monorepo-detect.js +107 -0
  126. package/dist/monorepo-detect.js.map +1 -0
  127. package/dist/nist-ai-rmf-articles.d.ts +40 -0
  128. package/dist/nist-ai-rmf-articles.d.ts.map +1 -0
  129. package/dist/nist-ai-rmf-articles.js +156 -0
  130. package/dist/nist-ai-rmf-articles.js.map +1 -0
  131. package/dist/nist-ai-rmf.d.ts +20 -0
  132. package/dist/nist-ai-rmf.d.ts.map +1 -0
  133. package/dist/nist-ai-rmf.js +176 -0
  134. package/dist/nist-ai-rmf.js.map +1 -0
  135. package/dist/otel-hooks.d.ts +67 -0
  136. package/dist/otel-hooks.d.ts.map +1 -0
  137. package/dist/otel-hooks.js +100 -0
  138. package/dist/otel-hooks.js.map +1 -0
  139. package/dist/owasp-agentic-articles.d.ts +42 -0
  140. package/dist/owasp-agentic-articles.d.ts.map +1 -0
  141. package/dist/owasp-agentic-articles.js +236 -0
  142. package/dist/owasp-agentic-articles.js.map +1 -0
  143. package/dist/owasp-agentic.d.ts +20 -0
  144. package/dist/owasp-agentic.d.ts.map +1 -0
  145. package/dist/owasp-agentic.js +205 -0
  146. package/dist/owasp-agentic.js.map +1 -0
  147. package/dist/plugins/a2a-types.d.ts +241 -0
  148. package/dist/plugins/a2a-types.d.ts.map +1 -0
  149. package/dist/plugins/a2a-types.js +14 -0
  150. package/dist/plugins/a2a-types.js.map +1 -0
  151. package/dist/plugins/a2a.d.ts +37 -0
  152. package/dist/plugins/a2a.d.ts.map +1 -0
  153. package/dist/plugins/a2a.js +160 -0
  154. package/dist/plugins/a2a.js.map +1 -0
  155. package/dist/plugins/anthropic-types.d.ts +188 -0
  156. package/dist/plugins/anthropic-types.d.ts.map +1 -0
  157. package/dist/plugins/anthropic-types.js +8 -0
  158. package/dist/plugins/anthropic-types.js.map +1 -0
  159. package/dist/plugins/anthropic.d.ts +32 -0
  160. package/dist/plugins/anthropic.d.ts.map +1 -0
  161. package/dist/plugins/anthropic.js +131 -0
  162. package/dist/plugins/anthropic.js.map +1 -0
  163. package/dist/plugins/autogen-types.d.ts +121 -0
  164. package/dist/plugins/autogen-types.d.ts.map +1 -0
  165. package/dist/plugins/autogen-types.js +13 -0
  166. package/dist/plugins/autogen-types.js.map +1 -0
  167. package/dist/plugins/autogen.d.ts +41 -0
  168. package/dist/plugins/autogen.d.ts.map +1 -0
  169. package/dist/plugins/autogen.js +131 -0
  170. package/dist/plugins/autogen.js.map +1 -0
  171. package/dist/plugins/bedrock-types.d.ts +246 -0
  172. package/dist/plugins/bedrock-types.d.ts.map +1 -0
  173. package/dist/plugins/bedrock-types.js +8 -0
  174. package/dist/plugins/bedrock-types.js.map +1 -0
  175. package/dist/plugins/bedrock.d.ts +43 -0
  176. package/dist/plugins/bedrock.d.ts.map +1 -0
  177. package/dist/plugins/bedrock.js +155 -0
  178. package/dist/plugins/bedrock.js.map +1 -0
  179. package/dist/plugins/cloudflare-ai-types.d.ts +85 -0
  180. package/dist/plugins/cloudflare-ai-types.d.ts.map +1 -0
  181. package/dist/plugins/cloudflare-ai-types.js +10 -0
  182. package/dist/plugins/cloudflare-ai-types.js.map +1 -0
  183. package/dist/plugins/cloudflare-ai.d.ts +32 -0
  184. package/dist/plugins/cloudflare-ai.d.ts.map +1 -0
  185. package/dist/plugins/cloudflare-ai.js +108 -0
  186. package/dist/plugins/cloudflare-ai.js.map +1 -0
  187. package/dist/plugins/composio-types.d.ts +96 -0
  188. package/dist/plugins/composio-types.d.ts.map +1 -0
  189. package/dist/plugins/composio-types.js +13 -0
  190. package/dist/plugins/composio-types.js.map +1 -0
  191. package/dist/plugins/composio.d.ts +37 -0
  192. package/dist/plugins/composio.d.ts.map +1 -0
  193. package/dist/plugins/composio.js +118 -0
  194. package/dist/plugins/composio.js.map +1 -0
  195. package/dist/plugins/crewai-types.d.ts +153 -0
  196. package/dist/plugins/crewai-types.d.ts.map +1 -0
  197. package/dist/plugins/crewai-types.js +10 -0
  198. package/dist/plugins/crewai-types.js.map +1 -0
  199. package/dist/plugins/crewai.d.ts +37 -0
  200. package/dist/plugins/crewai.d.ts.map +1 -0
  201. package/dist/plugins/crewai.js +127 -0
  202. package/dist/plugins/crewai.js.map +1 -0
  203. package/dist/plugins/deno-types.d.ts +68 -0
  204. package/dist/plugins/deno-types.d.ts.map +1 -0
  205. package/dist/plugins/deno-types.js +8 -0
  206. package/dist/plugins/deno-types.js.map +1 -0
  207. package/dist/plugins/deno.d.ts +37 -0
  208. package/dist/plugins/deno.d.ts.map +1 -0
  209. package/dist/plugins/deno.js +129 -0
  210. package/dist/plugins/deno.js.map +1 -0
  211. package/dist/plugins/e2b-types.d.ts +140 -0
  212. package/dist/plugins/e2b-types.d.ts.map +1 -0
  213. package/dist/plugins/e2b-types.js +8 -0
  214. package/dist/plugins/e2b-types.js.map +1 -0
  215. package/dist/plugins/e2b.d.ts +43 -0
  216. package/dist/plugins/e2b.d.ts.map +1 -0
  217. package/dist/plugins/e2b.js +157 -0
  218. package/dist/plugins/e2b.js.map +1 -0
  219. package/dist/plugins/genkit-types.d.ts +88 -0
  220. package/dist/plugins/genkit-types.d.ts.map +1 -0
  221. package/dist/plugins/genkit-types.js +11 -0
  222. package/dist/plugins/genkit-types.js.map +1 -0
  223. package/dist/plugins/genkit.d.ts +35 -0
  224. package/dist/plugins/genkit.d.ts.map +1 -0
  225. package/dist/plugins/genkit.js +143 -0
  226. package/dist/plugins/genkit.js.map +1 -0
  227. package/dist/plugins/langchain.d.ts +130 -0
  228. package/dist/plugins/langchain.d.ts.map +1 -0
  229. package/dist/plugins/langchain.js +172 -0
  230. package/dist/plugins/langchain.js.map +1 -0
  231. package/dist/plugins/llamaindex-types.d.ts +86 -0
  232. package/dist/plugins/llamaindex-types.d.ts.map +1 -0
  233. package/dist/plugins/llamaindex-types.js +11 -0
  234. package/dist/plugins/llamaindex-types.js.map +1 -0
  235. package/dist/plugins/llamaindex.d.ts +36 -0
  236. package/dist/plugins/llamaindex.d.ts.map +1 -0
  237. package/dist/plugins/llamaindex.js +131 -0
  238. package/dist/plugins/llamaindex.js.map +1 -0
  239. package/dist/plugins/mastra-processor-types.d.ts +126 -0
  240. package/dist/plugins/mastra-processor-types.d.ts.map +1 -0
  241. package/dist/plugins/mastra-processor-types.js +11 -0
  242. package/dist/plugins/mastra-processor-types.js.map +1 -0
  243. package/dist/plugins/mastra-processor.d.ts +32 -0
  244. package/dist/plugins/mastra-processor.d.ts.map +1 -0
  245. package/dist/plugins/mastra-processor.js +126 -0
  246. package/dist/plugins/mastra-processor.js.map +1 -0
  247. package/dist/plugins/mastra.d.ts +100 -0
  248. package/dist/plugins/mastra.d.ts.map +1 -0
  249. package/dist/plugins/mastra.js +143 -0
  250. package/dist/plugins/mastra.js.map +1 -0
  251. package/dist/plugins/mcp-annotations.d.ts +54 -0
  252. package/dist/plugins/mcp-annotations.d.ts.map +1 -0
  253. package/dist/plugins/mcp-annotations.js +110 -0
  254. package/dist/plugins/mcp-annotations.js.map +1 -0
  255. package/dist/plugins/mcp-chain-audit.d.ts +74 -0
  256. package/dist/plugins/mcp-chain-audit.d.ts.map +1 -0
  257. package/dist/plugins/mcp-chain-audit.js +134 -0
  258. package/dist/plugins/mcp-chain-audit.js.map +1 -0
  259. package/dist/plugins/mcp-trust.d.ts +59 -0
  260. package/dist/plugins/mcp-trust.d.ts.map +1 -0
  261. package/dist/plugins/mcp-trust.js +100 -0
  262. package/dist/plugins/mcp-trust.js.map +1 -0
  263. package/dist/plugins/mcp-types.d.ts +183 -0
  264. package/dist/plugins/mcp-types.d.ts.map +1 -0
  265. package/dist/plugins/mcp-types.js +12 -0
  266. package/dist/plugins/mcp-types.js.map +1 -0
  267. package/dist/plugins/mcp.d.ts +41 -0
  268. package/dist/plugins/mcp.d.ts.map +1 -0
  269. package/dist/plugins/mcp.js +228 -0
  270. package/dist/plugins/mcp.js.map +1 -0
  271. package/dist/plugins/mistral-types.d.ts +72 -0
  272. package/dist/plugins/mistral-types.d.ts.map +1 -0
  273. package/dist/plugins/mistral-types.js +8 -0
  274. package/dist/plugins/mistral-types.js.map +1 -0
  275. package/dist/plugins/mistral.d.ts +32 -0
  276. package/dist/plugins/mistral.d.ts.map +1 -0
  277. package/dist/plugins/mistral.js +133 -0
  278. package/dist/plugins/mistral.js.map +1 -0
  279. package/dist/plugins/ollama-types.d.ts +76 -0
  280. package/dist/plugins/ollama-types.d.ts.map +1 -0
  281. package/dist/plugins/ollama-types.js +8 -0
  282. package/dist/plugins/ollama-types.js.map +1 -0
  283. package/dist/plugins/ollama.d.ts +32 -0
  284. package/dist/plugins/ollama.d.ts.map +1 -0
  285. package/dist/plugins/ollama.js +130 -0
  286. package/dist/plugins/ollama.js.map +1 -0
  287. package/dist/plugins/openai-agents-types.d.ts +130 -0
  288. package/dist/plugins/openai-agents-types.d.ts.map +1 -0
  289. package/dist/plugins/openai-agents-types.js +12 -0
  290. package/dist/plugins/openai-agents-types.js.map +1 -0
  291. package/dist/plugins/openai-agents.d.ts +37 -0
  292. package/dist/plugins/openai-agents.d.ts.map +1 -0
  293. package/dist/plugins/openai-agents.js +151 -0
  294. package/dist/plugins/openai-agents.js.map +1 -0
  295. package/dist/plugins/semantic-kernel-types.d.ts +103 -0
  296. package/dist/plugins/semantic-kernel-types.d.ts.map +1 -0
  297. package/dist/plugins/semantic-kernel-types.js +13 -0
  298. package/dist/plugins/semantic-kernel-types.js.map +1 -0
  299. package/dist/plugins/semantic-kernel.d.ts +37 -0
  300. package/dist/plugins/semantic-kernel.d.ts.map +1 -0
  301. package/dist/plugins/semantic-kernel.js +149 -0
  302. package/dist/plugins/semantic-kernel.js.map +1 -0
  303. package/dist/plugins/vercel-ai.d.ts +134 -0
  304. package/dist/plugins/vercel-ai.d.ts.map +1 -0
  305. package/dist/plugins/vercel-ai.js +130 -0
  306. package/dist/plugins/vercel-ai.js.map +1 -0
  307. package/dist/policy-builder.d.ts +52 -0
  308. package/dist/policy-builder.d.ts.map +1 -0
  309. package/dist/policy-builder.js +108 -0
  310. package/dist/policy-builder.js.map +1 -0
  311. package/dist/policy-compose-presets.d.ts +18 -0
  312. package/dist/policy-compose-presets.d.ts.map +1 -0
  313. package/dist/policy-compose-presets.js +52 -0
  314. package/dist/policy-compose-presets.js.map +1 -0
  315. package/dist/policy-compose.d.ts +66 -0
  316. package/dist/policy-compose.d.ts.map +1 -0
  317. package/dist/policy-compose.js +163 -0
  318. package/dist/policy-compose.js.map +1 -0
  319. package/dist/policy-presets-extended.d.ts +35 -0
  320. package/dist/policy-presets-extended.d.ts.map +1 -0
  321. package/dist/policy-presets-extended.js +137 -0
  322. package/dist/policy-presets-extended.js.map +1 -0
  323. package/dist/policy-presets.d.ts +77 -0
  324. package/dist/policy-presets.d.ts.map +1 -0
  325. package/dist/policy-presets.js +164 -0
  326. package/dist/policy-presets.js.map +1 -0
  327. package/dist/policy-stage-defaults.d.ts +8 -0
  328. package/dist/policy-stage-defaults.d.ts.map +1 -0
  329. package/dist/policy-stage-defaults.js +34 -0
  330. package/dist/policy-stage-defaults.js.map +1 -0
  331. package/dist/policy-yaml.d.ts +23 -0
  332. package/dist/policy-yaml.d.ts.map +1 -0
  333. package/dist/policy-yaml.js +216 -0
  334. package/dist/policy-yaml.js.map +1 -0
  335. package/dist/policy.d.ts +124 -0
  336. package/dist/policy.d.ts.map +1 -0
  337. package/dist/policy.js +161 -0
  338. package/dist/policy.js.map +1 -0
  339. package/dist/remote-enforce.d.ts +44 -0
  340. package/dist/remote-enforce.d.ts.map +1 -0
  341. package/dist/remote-enforce.js +99 -0
  342. package/dist/remote-enforce.js.map +1 -0
  343. package/dist/repo-patterns.d.ts +32 -0
  344. package/dist/repo-patterns.d.ts.map +1 -0
  345. package/dist/repo-patterns.js +222 -0
  346. package/dist/repo-patterns.js.map +1 -0
  347. package/dist/sandbox.d.ts +68 -0
  348. package/dist/sandbox.d.ts.map +1 -0
  349. package/dist/sandbox.js +124 -0
  350. package/dist/sandbox.js.map +1 -0
  351. package/dist/scorer-dimensions.d.ts +10 -0
  352. package/dist/scorer-dimensions.d.ts.map +1 -0
  353. package/dist/scorer-dimensions.js +184 -0
  354. package/dist/scorer-dimensions.js.map +1 -0
  355. package/dist/scorer.d.ts +27 -0
  356. package/dist/scorer.d.ts.map +1 -0
  357. package/dist/scorer.js +138 -0
  358. package/dist/scorer.js.map +1 -0
  359. package/dist/storage-postgres-schema.d.ts +47 -0
  360. package/dist/storage-postgres-schema.d.ts.map +1 -0
  361. package/dist/storage-postgres-schema.js +134 -0
  362. package/dist/storage-postgres-schema.js.map +1 -0
  363. package/dist/storage-postgres.d.ts +41 -0
  364. package/dist/storage-postgres.d.ts.map +1 -0
  365. package/dist/storage-postgres.js +180 -0
  366. package/dist/storage-postgres.js.map +1 -0
  367. package/dist/storage.d.ts +65 -0
  368. package/dist/storage.d.ts.map +1 -0
  369. package/dist/storage.js +85 -0
  370. package/dist/storage.js.map +1 -0
  371. package/dist/supply-chain-sbom.d.ts +72 -0
  372. package/dist/supply-chain-sbom.d.ts.map +1 -0
  373. package/dist/supply-chain-sbom.js +73 -0
  374. package/dist/supply-chain-sbom.js.map +1 -0
  375. package/dist/supply-chain.d.ts +61 -0
  376. package/dist/supply-chain.d.ts.map +1 -0
  377. package/dist/supply-chain.js +95 -0
  378. package/dist/supply-chain.js.map +1 -0
  379. package/dist/token-types.d.ts +77 -0
  380. package/dist/token-types.d.ts.map +1 -0
  381. package/dist/token-types.js +31 -0
  382. package/dist/token-types.js.map +1 -0
  383. package/dist/types.d.ts +71 -0
  384. package/dist/types.d.ts.map +1 -0
  385. package/dist/types.js +6 -0
  386. package/dist/types.js.map +1 -0
  387. package/package.json +361 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lua AI, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,559 @@
1
+ # governance-sdk
2
+
3
+ AI Agent Governance for TypeScript — before-action policy enforcement, 7-dimension scoring, injection detection, and 20 framework adapters.
4
+
5
+ [![Tests](https://img.shields.io/badge/tests-945%2B-brightgreen)]()
6
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-blue)]()
7
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)]()
8
+
9
+ > **Thin client SDK.** Handles policy evaluation, scoring, injection detection, and framework adapters locally. Production guarantees (server-side rate limiting, distributed kill switch, durable audit) belong in your API layer — see [Governance Cloud](#governance-cloud).
10
+
11
+ ---
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install governance-sdk
17
+ ```
18
+
19
+ ---
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { createGovernance, blockTools, requireApproval, tokenBudget } from 'governance-sdk';
25
+
26
+ // 1. Create governance instance with policy rules
27
+ const gov = createGovernance({
28
+ rules: [
29
+ blockTools(['shell_exec', 'file_delete', 'database_drop']),
30
+ requireApproval(['payment', 'bulk_export']),
31
+ tokenBudget(100_000),
32
+ ],
33
+ });
34
+
35
+ // 2. Register an agent — auto-scores across 7 dimensions
36
+ const agent = await gov.register({
37
+ name: 'my-agent',
38
+ framework: 'mastra',
39
+ owner: 'platform-team',
40
+ tools: ['web_search', 'crm_update'],
41
+ hasAuth: true,
42
+ hasGuardrails: true,
43
+ hasObservability: true,
44
+ hasAuditLog: true,
45
+ });
46
+ // agent.score = 87, agent.level = 4 (Certified)
47
+
48
+ // 3. Enforce policies BEFORE actions execute
49
+ const decision = await gov.enforce({
50
+ agentId: agent.id,
51
+ agentLevel: agent.level,
52
+ action: 'tool_call',
53
+ tool: 'shell_exec',
54
+ });
55
+ // { blocked: true, outcome: 'block', reason: 'Tool is on the blocked list: shell_exec', ruleId: 'block-tools-...' }
56
+
57
+ // 4. Query the audit trail
58
+ const events = await gov.audit.query({ agentId: agent.id });
59
+ const count = await gov.audit.count();
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Core API
65
+
66
+ ### `createGovernance(config?): GovernanceInstance`
67
+
68
+ Factory function — the main entry point.
69
+
70
+ ```typescript
71
+ interface GovernanceConfig {
72
+ rules?: PolicyRule[]; // Policy rules to enforce
73
+ storage?: GovernanceStorage; // Default: in-memory (use storage-postgres for production)
74
+ serverUrl?: string; // Optional: remote enforcement via Governance Cloud
75
+ apiKey?: string; // Required if using serverUrl
76
+ }
77
+ ```
78
+
79
+ Returns a `GovernanceInstance` with:
80
+
81
+ | Method | Signature | Description |
82
+ |--------|-----------|-------------|
83
+ | `register` | `(agent: AgentRegistration) => Promise<StoredAgent>` | Register agent, auto-score across 7 dimensions |
84
+ | `enforce` | `(ctx: EnforcementContext) => Promise<EnforcementDecision>` | Evaluate all policy rules before an action executes |
85
+ | `audit.log` | `(event: Partial<AuditEvent>) => Promise<AuditEvent>` | Write custom audit event |
86
+ | `audit.query` | `(filters?: AuditQueryFilters) => Promise<AuditEvent[]>` | Query audit events |
87
+ | `audit.count` | `(filters?: AuditQueryFilters) => Promise<number>` | Count audit events |
88
+ | `scoreFleet` | `() => Promise<{ summary: FleetSummary; agents: StoredAgent[] }>` | Fleet-wide governance assessment |
89
+ | `getAgent` | `(agentId: string) => Promise<StoredAgent \| null>` | Retrieve registered agent |
90
+ | `policies` | `ReadonlyPolicyEngine` | Access policy engine (addRule, removeRule, ruleCount) |
91
+
92
+ ### `EnforcementContext`
93
+
94
+ ```typescript
95
+ interface EnforcementContext {
96
+ agentId: string;
97
+ agentLevel?: number; // Governance level (0-4)
98
+ action: string; // e.g., 'tool_call', 'payment', 'external_request'
99
+ tool?: string; // Tool name (for tool_call actions)
100
+ sessionTokensUsed?: number; // For tokenBudget rule
101
+ recentActionCount?: number; // For rateLimit rule
102
+ dataClassification?: string; // For data_classification condition
103
+ sessionToolHistory?: string[]; // For requireSequence rule
104
+ }
105
+ ```
106
+
107
+ ### `EnforcementDecision`
108
+
109
+ ```typescript
110
+ interface EnforcementDecision {
111
+ blocked: boolean;
112
+ outcome: 'allow' | 'block' | 'warn' | 'require_approval';
113
+ reason: string;
114
+ ruleId?: string;
115
+ ruleName?: string;
116
+ }
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Policy Presets
122
+
123
+ 8 preset builders for common governance patterns. All return a `PolicyRule`.
124
+
125
+ ```typescript
126
+ import {
127
+ blockTools, // Block specific tools — priority 100
128
+ allowOnlyTools, // Allowlist-only mode — priority 90
129
+ requireLevel, // Minimum governance level — priority 95
130
+ requireSequence, // Tool prerequisites — priority 85
131
+ requireApproval, // Human review for actions — priority 80
132
+ tokenBudget, // Per-session token limit — priority 70
133
+ rateLimit, // Action rate threshold — priority 60
134
+ timeWindow, // Restrict to business hours — priority 50
135
+ } from 'governance-sdk';
136
+ ```
137
+
138
+ | Preset | Signature | Example |
139
+ |--------|-----------|---------|
140
+ | `blockTools` | `(tools: string[], reason?: string)` | `blockTools(['shell_exec', 'rm_rf'])` |
141
+ | `allowOnlyTools` | `(tools: string[], reason?: string)` | `allowOnlyTools(['web_search', 'email_read'])` |
142
+ | `requireApproval` | `(actions: PolicyAction[], reason?: string)` | `requireApproval(['payment', 'database_mutation'])` |
143
+ | `tokenBudget` | `(maxTokens: number)` | `tokenBudget(50_000)` |
144
+ | `rateLimit` | `(maxActions: number, windowMs: number)` | `rateLimit(100, 60_000)` |
145
+ | `requireLevel` | `(minLevel: number)` | `requireLevel(3)` |
146
+ | `requireSequence` | `(tool: string, requiredPrior: string[], reason?: string)` | `requireSequence('delete_record', ['backup_record'])` |
147
+ | `timeWindow` | `(startHour: number, endHour: number, reason?: string)` | `timeWindow(9, 17)` |
148
+
149
+ ### Policy Conditions
150
+
151
+ 13 condition types for custom rules:
152
+
153
+ `tool_blocked` · `tool_allowed` · `action_type` · `token_limit` · `rate_limit` · `data_classification` · `agent_level` · `tool_sequence` · `time_window` · `any_of` · `all_of` · `not` · `custom`
154
+
155
+ Boolean combinators (`any_of`, `all_of`, `not`) allow composing complex conditions from simpler ones.
156
+
157
+ ---
158
+
159
+ ## Governance Scoring
160
+
161
+ ### `assessAgent(agentId, registration): GovernanceAssessment`
162
+
163
+ Scores an agent across 7 weighted dimensions:
164
+
165
+ | Dimension | Weight | What it measures |
166
+ |-----------|--------|-----------------|
167
+ | Identity | 1.5x | Name, owner, description, version |
168
+ | Permissions | 1.5x | Auth, tool scoping, PII access |
169
+ | Observability | 1.2x | Logging, monitoring, channels |
170
+ | Guardrails | 1.3x | Input/output guards, framework recognition |
171
+ | Auditability | 1.0x | Audit logging, event trail |
172
+ | Compliance | 1.0x | Compliance capabilities |
173
+ | Lifecycle | 0.8x | Versioning, deprecation readiness |
174
+
175
+ ### Governance Levels
176
+
177
+ | Level | Label | Score Range | Autonomy |
178
+ |-------|-------|-------------|----------|
179
+ | L0 | Unregistered | 0–20 | No autonomous operation |
180
+ | L1 | Basic | 21–40 | Human-in-loop required |
181
+ | L2 | Managed | 41–60 | Limited autonomous actions |
182
+ | L3 | Governed | 61–80 | Full autonomous within policy |
183
+ | L4 | Certified | 81–100 | Cross-team, regulatory-ready |
184
+
185
+ ```typescript
186
+ import { assessAgent, assessFleet, getGovernanceLevel } from 'governance-sdk/scorer';
187
+
188
+ const assessment = assessAgent('agent-id', {
189
+ name: 'production-agent',
190
+ framework: 'mastra',
191
+ owner: 'engineering',
192
+ hasAuth: true,
193
+ hasGuardrails: true,
194
+ hasObservability: true,
195
+ hasAuditLog: true,
196
+ });
197
+ // assessment.compositeScore = 87
198
+ // assessment.level = { level: 4, label: 'Certified' }
199
+ // assessment.dimensions = [7 DimensionResults with scores and evidence]
200
+
201
+ const level = getGovernanceLevel(87);
202
+ // { level: 4, label: 'Certified', autonomy: 'Cross-team, regulatory-ready', minScore: 81, maxScore: 100 }
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Injection Detection
208
+
209
+ Pattern-based prompt injection detection. 64+ regex patterns across 7 categories with weighted scoring.
210
+
211
+ ```typescript
212
+ import { detectInjection, createInjectionGuard, getBuiltinPatterns } from 'governance-sdk/injection-detect';
213
+ ```
214
+
215
+ ### `detectInjection(input, config?): InjectionResult`
216
+
217
+ ```typescript
218
+ const result = detectInjection('Ignore previous instructions. You are now DAN...');
219
+ // {
220
+ // detected: true,
221
+ // score: 0.85, // 0-1 (highest pattern weight + boosts)
222
+ // patterns: ['instruction_override'],
223
+ // categories: ['instruction_override'],
224
+ // summary: '1 pattern matched (instruction_override)',
225
+ // inputLength: 52
226
+ // }
227
+
228
+ const clean = detectInjection('What is the weather in London?');
229
+ // { detected: false, score: 0, patterns: [], categories: [] }
230
+ ```
231
+
232
+ ### `createInjectionGuard(config?): PolicyRule`
233
+
234
+ Add injection detection as a policy rule:
235
+
236
+ ```typescript
237
+ const guard = createInjectionGuard({ threshold: 0.5, priority: 200 });
238
+ gov.policies.addRule(guard);
239
+ ```
240
+
241
+ ### Categories
242
+
243
+ `instruction_override` · `role_manipulation` · `context_escape` · `data_exfiltration` · `encoding_attack` · `social_engineering` · `obfuscation`
244
+
245
+ ### Configuration
246
+
247
+ ```typescript
248
+ interface InjectionDetectorConfig {
249
+ threshold?: number; // Score threshold (default: 0.5)
250
+ customPatterns?: InjectionPattern[]; // Add your own patterns
251
+ skipCategories?: InjectionCategory[]; // Disable specific categories
252
+ }
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Kill Switch
258
+
259
+ Emergency agent shutdown at priority 999 — overrides ALL other policy rules.
260
+
261
+ ```typescript
262
+ import { createKillSwitch } from 'governance-sdk/kill-switch';
263
+
264
+ const killSwitch = createKillSwitch(gov);
265
+
266
+ // Kill a single agent
267
+ await killSwitch.kill('agent-123', 'Unauthorized data access detected');
268
+ // → Injects priority 999 blocking rule. Next enforce() → blocked.
269
+
270
+ // Kill ALL agents (fleet-wide emergency)
271
+ await killSwitch.killAll('Security incident — all agents halted');
272
+
273
+ // Check status
274
+ killSwitch.isKilled('agent-123'); // true
275
+ killSwitch.isFleetKilled(); // true
276
+ killSwitch.getKillRecords(); // [{ agentId, reason, killedAt, storageSynced }]
277
+
278
+ // Resume
279
+ await killSwitch.revive('agent-123');
280
+ await killSwitch.reviveAll();
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Audit Integrity
286
+
287
+ HMAC-SHA256 hash-chained audit trail — tamper-evident by design.
288
+
289
+ ```typescript
290
+ import { createIntegrityAudit } from 'governance-sdk/audit-integrity';
291
+
292
+ const integrity = createIntegrityAudit(gov, { hmacKey: 'your-secret-key' });
293
+
294
+ // Log events — automatically hash-chained
295
+ await integrity.log({
296
+ agentId: 'agent-1',
297
+ eventType: 'tool_call',
298
+ outcome: 'success',
299
+ detail: { tool: 'web_search' },
300
+ });
301
+
302
+ // Verify chain integrity — detects any tampering
303
+ const verification = await integrity.verify();
304
+ // { valid: true, eventCount: 42, chainLength: 42, errors: [] }
305
+ ```
306
+
307
+ ---
308
+
309
+ ## EU AI Act Compliance
310
+
311
+ 6 articles mapped with requirements, deadlines, and SDK feature mapping.
312
+
313
+ ```typescript
314
+ import { assessCompliance, getArticles, getDaysUntilDeadline } from 'governance-sdk/compliance';
315
+
316
+ const daysLeft = getDaysUntilDeadline(); // Days until August 2, 2026
317
+
318
+ const report = await assessCompliance({
319
+ governance: gov,
320
+ agents: [agent1, agent2],
321
+ auditIntegrity: true,
322
+ humanOversight: true,
323
+ logRetention: true,
324
+ });
325
+ // report.overallStatus = 'partial' | 'compliant' | 'non-compliant'
326
+ // report.articles = [{ article, title, status, requirements: [{ met, evidence }] }]
327
+ ```
328
+
329
+ ### Articles Tracked
330
+
331
+ | Article | Title | SDK Feature |
332
+ |---------|-------|-------------|
333
+ | Art. 9 | Risk Management | Policy engine + scoring |
334
+ | Art. 11 | Technical Documentation | Audit trail + compliance reports |
335
+ | Art. 12 | Record-Keeping | Immutable audit log |
336
+ | Art. 14 | Human Oversight | Approval queue + kill switch |
337
+ | Art. 15 | Accuracy & Robustness | Injection detection + guardrails |
338
+ | Art. 50 | Transparency | Event emitter + compliance tags |
339
+
340
+ ---
341
+
342
+ ## Events
343
+
344
+ Real-time governance event emitter — zero dependencies, native `EventTarget`.
345
+
346
+ ```typescript
347
+ import { createGovernanceEmitter } from 'governance-sdk/events';
348
+
349
+ const emitter = createGovernanceEmitter();
350
+
351
+ emitter.on('enforcement', (e) => slack.post(`Decision: ${e.detail}`));
352
+ emitter.on('kill', (e) => pagerDuty.trigger(e.agentId));
353
+ emitter.on('score_change', (e) => dashboard.update(e.agentId));
354
+ emitter.onAny((e) => auditPipeline.ingest(e));
355
+ ```
356
+
357
+ Event types: `enforcement` · `registration` · `kill` · `revive` · `score_change` · `policy_added` · `policy_removed` · `audit`
358
+
359
+ ---
360
+
361
+ ## Metrics
362
+
363
+ In-memory counters and timings for observability.
364
+
365
+ ```typescript
366
+ import { createGovernanceMetrics } from 'governance-sdk/metrics';
367
+
368
+ const metrics = createGovernanceMetrics();
369
+ metrics.increment('enforcement.total');
370
+ metrics.timing('enforcement.duration_ms', 2.4);
371
+
372
+ const snapshot = metrics.snapshot();
373
+ // { counters: { 'enforcement.total': { value: 1 } }, timings: { 'enforcement.duration_ms': { count: 1, avg: 2.4 } } }
374
+ ```
375
+
376
+ ---
377
+
378
+ ## Policy Composition
379
+
380
+ Merge policies from multiple teams with conflict resolution.
381
+
382
+ ```typescript
383
+ import { composePolicies } from 'governance-sdk/policy-compose';
384
+
385
+ const { rules, conflicts } = composePolicies([
386
+ { name: 'security', source: 'security-team', rules: securityRules },
387
+ { name: 'compliance', source: 'compliance', rules: complianceRules },
388
+ { name: 'platform', source: 'platform', rules: platformRules },
389
+ ], { conflictStrategy: 'strict', deduplicate: true, maxRules: 100 });
390
+ ```
391
+
392
+ Conflict strategies: `strict` (block wins) · `permissive` (allow wins) · `priority` (higher priority wins) · `latest` (last-added wins)
393
+
394
+ ---
395
+
396
+ ## Dry Run
397
+
398
+ Test policy changes against your fleet before deploying — CI-ready.
399
+
400
+ ```typescript
401
+ import { dryRun, fleetDryRun } from 'governance-sdk/dry-run';
402
+
403
+ const result = await fleetDryRun(gov, actions);
404
+ // result.fleetSummary.agentsAffected = 11
405
+ // result.fleetSummary.blockRate = 0.12
406
+ // result.results[0].summary.rulesTriggered = ['bulk-export', 'pii-exfiltration']
407
+ ```
408
+
409
+ ---
410
+
411
+ ## Behavioral Scoring
412
+
413
+ Adjust governance scores based on runtime behavior (block rate, audit volume, tool diversity).
414
+
415
+ ```typescript
416
+ import { computeBehavioralAdjustments, applyBehavioralAdjustments } from 'governance-sdk/behavioral-scorer';
417
+
418
+ const behavioral = computeBehavioralAdjustments({ agentId: 'agent-1', events: auditEvents });
419
+ // behavioral.adjustments = [{ dimension: 'guardrails', adjustment: -8, reason: 'High block rate' }]
420
+
421
+ const adjusted = applyBehavioralAdjustments(baseDimensions, behavioral.adjustments);
422
+ ```
423
+
424
+ ---
425
+
426
+ ## Repository Scanning
427
+
428
+ Detect agent capabilities by scanning source code.
429
+
430
+ ```typescript
431
+ import { scanRepoContents, SCAN_GLOBS } from 'governance-sdk/repo-patterns';
432
+
433
+ const result = scanRepoContents(fileContents);
434
+ // result.detections = [{ capability: 'auth', confidence: 0.9, evidence: 'Found Clerk import' }]
435
+ // result.framework = 'mastra'
436
+ // result.tools = ['web_search', 'database_query']
437
+ ```
438
+
439
+ ---
440
+
441
+ ## Storage
442
+
443
+ ### In-Memory (default)
444
+
445
+ ```typescript
446
+ const gov = createGovernance(); // In-memory storage, no config needed
447
+ ```
448
+
449
+ ### PostgreSQL
450
+
451
+ ```typescript
452
+ import { createPostgresStorage } from 'governance-sdk/storage-postgres';
453
+
454
+ const storage = await createPostgresStorage({
455
+ pool: myPgPool, // Any pg.Pool-compatible object
456
+ tablePrefix: 'gov_', // Default: 'governance_'
457
+ autoMigrate: true, // Default: true — runs CREATE TABLE IF NOT EXISTS
458
+ });
459
+
460
+ const gov = createGovernance({ storage });
461
+ ```
462
+
463
+ ### Schema Export
464
+
465
+ ```typescript
466
+ import { getSchemaSQL } from 'governance-sdk/storage-postgres-schema';
467
+
468
+ const ddl = getSchemaSQL('governance_');
469
+ // Returns CREATE TABLE statements for agents and audit_events tables
470
+ ```
471
+
472
+ ---
473
+
474
+ ## Framework Adapters
475
+
476
+ 20 first-class adapters. Each wraps your framework's tool execution with governance enforcement and audit logging.
477
+
478
+ | Export | Framework | Main Function |
479
+ |--------|-----------|---------------|
480
+ | `plugins/mastra` | Mastra | `createGovernanceMiddleware(gov, config)` |
481
+ | `plugins/mastra-processor` | Mastra Processor | `GovernanceProcessor` class |
482
+ | `plugins/vercel-ai` | Vercel AI SDK | `createGovernedTools(gov, tools, config)` |
483
+ | `plugins/langchain` | LangChain / LangGraph | `governTools(gov, tools, config)` |
484
+ | `plugins/openai-agents` | OpenAI Agents SDK | `governAgent(gov, agent, config)` |
485
+ | `plugins/anthropic` | Anthropic SDK | `governAnthropicTools(gov, tools, config)` |
486
+ | `plugins/mcp` | Model Context Protocol | `governMCPTools(gov, tools, config)` |
487
+ | `plugins/crewai` | CrewAI | `governCrewTools(gov, tools, config)` |
488
+ | `plugins/bedrock` | AWS Bedrock | `governBedrockAgent(gov, agent, config)` |
489
+ | `plugins/genkit` | Firebase Genkit | `governGenkitTools(gov, tools, config)` |
490
+ | `plugins/semantic-kernel` | Semantic Kernel | `governKernelFunctions(gov, fns, config)` |
491
+ | `plugins/autogen` | AutoGen | `governAutogenAgent(gov, agent, config)` |
492
+ | `plugins/a2a` | Agent-to-Agent Protocol | `governA2AHandler(gov, handler, config)` |
493
+ | `plugins/llamaindex` | LlamaIndex | `governLlamaTools(gov, tools, config)` |
494
+ | `plugins/cloudflare-ai` | Cloudflare AI | `governCfTools(gov, tools, config)` |
495
+ | `plugins/deno` | Deno | `governDenoTools(gov, tools, config)` |
496
+ | `plugins/mistral` | Mistral AI | `governMistralTools(gov, tools, config)` |
497
+ | `plugins/ollama` | Ollama | `governOllamaTools(gov, tools, config)` |
498
+ | `plugins/e2b` | E2B | `governE2BSandbox(gov, sandbox, config)` |
499
+ | `plugins/composio` | Composio | `governComposioTools(gov, tools, config)` |
500
+
501
+ All adapters follow the same pattern:
502
+ 1. Register the agent with `gov.register()`
503
+ 2. Wrap tool execution with `gov.enforce()` before each call
504
+ 3. Log results to `gov.audit.log()` after each call
505
+
506
+ ---
507
+
508
+ ## Governance Cloud
509
+
510
+ Connect to Lua Governance Cloud for production-grade enforcement:
511
+
512
+ ```typescript
513
+ const gov = createGovernance({
514
+ serverUrl: 'https://api.heylua.ai',
515
+ apiKey: process.env.LUA_API_KEY,
516
+ });
517
+ // Same API — enforcement runs server-side
518
+ ```
519
+
520
+ Enterprise features (multi-tenant, RBAC, compliance reports, anomaly detection) are in the separate `governance-sdk-enterprise` package.
521
+
522
+ ---
523
+
524
+ ## 35 Export Paths
525
+
526
+ | # | Export Path | Key Exports |
527
+ |---|-----------|-------------|
528
+ | 1 | `governance-sdk` | `createGovernance`, `blockTools`, `allowOnlyTools`, `requireApproval`, `tokenBudget`, `rateLimit`, `requireLevel`, `requireSequence`, `timeWindow`, `assessAgent`, `assessFleet`, `getGovernanceLevel`, `createPolicyEngine`, `createMemoryStorage` |
529
+ | 2 | `./policy` | `createPolicyEngine`, `PolicyRule`, `PolicyCondition`, `EnforcementContext`, `EnforcementDecision` |
530
+ | 3 | `./scorer` | `assessAgent`, `assessFleet`, `getGovernanceLevel` |
531
+ | 4 | `./kill-switch` | `createKillSwitch` |
532
+ | 5 | `./injection-detect` | `detectInjection`, `createInjectionGuard`, `getBuiltinPatterns` |
533
+ | 6 | `./audit-integrity` | `createIntegrityAudit`, `hmacSha256`, `canonicalize` |
534
+ | 7 | `./compliance` | `assessCompliance`, `getArticles`, `getDaysUntilDeadline` |
535
+ | 8 | `./policy-compose` | `composePolicies` |
536
+ | 9 | `./dry-run` | `dryRun`, `fleetDryRun` |
537
+ | 10 | `./events` | `createGovernanceEmitter` |
538
+ | 11 | `./metrics` | `createGovernanceMetrics` |
539
+ | 12 | `./storage-postgres` | `createPostgresStorage` |
540
+ | 13 | `./storage-postgres-schema` | `getSchemaSQL`, `getIntegrityMigrationSQL` |
541
+ | 14 | `./behavioral-scorer` | `computeBehavioralAdjustments`, `applyBehavioralAdjustments`, `computeSignals` |
542
+ | 15 | `./repo-patterns` | `scanRepoContents`, `SCAN_GLOBS` |
543
+ | 16–35 | `./plugins/*` | 20 framework adapters (see table above) |
544
+
545
+ ---
546
+
547
+ ## Known Limitations
548
+
549
+ - **`rateLimit` is declarative** — checks a caller-supplied `recentActionCount` against a threshold. The SDK does not track counts. Use the governance API with Upstash/Redis for production rate limiting.
550
+ - **Kill switch is process-local** — won't propagate across processes. Use the governance API for distributed kill switch.
551
+ - **Audit integrity chain is in-memory** — doesn't survive process restart. Use PostgreSQL storage adapter or governance API for durable audit.
552
+ - **`autoMigrate` has no schema versioning** — runs `CREATE TABLE IF NOT EXISTS` only. No `ALTER TABLE`. Manage schema changes externally.
553
+ - **Injection detection is heuristic** — regex-based (64+ patterns, 7 categories), not LLM-based. Effective for known patterns but not adaptive to novel attacks. Layer with LLM-based classifier for high-security use.
554
+
555
+ ---
556
+
557
+ ## License
558
+
559
+ MIT — [Lua](https://heylua.ai)
@@ -0,0 +1,80 @@
1
+ /**
2
+ * governance-sdk — Ed25519 Cryptographic Agent Identity
3
+ *
4
+ * Public-key agent identity using Ed25519 via Web Crypto API.
5
+ * Zero dependencies. Supports key generation, action signing, verification,
6
+ * self-signed certificates, and capability-narrowing delegation.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { createEd25519Identity } from 'governance-sdk/agent-identity-ed25519';
11
+ *
12
+ * const identity = createEd25519Identity();
13
+ * const keyPair = await identity.generateKeyPair();
14
+ * const cert = await identity.createCertificate(keyPair.privateKey, {
15
+ * agentId: 'bot-1', name: 'sales-bot', capabilities: ['search', 'email'],
16
+ * });
17
+ * const signature = await identity.signAction(keyPair.privateKey, { action: 'tool_call', tool: 'search' });
18
+ * const valid = await identity.verifyAction(keyPair.publicKey, { action: 'tool_call', tool: 'search' }, signature);
19
+ * ```
20
+ */
21
+ export interface Ed25519KeyPair {
22
+ publicKey: CryptoKey;
23
+ privateKey: CryptoKey;
24
+ /** Hex-encoded public key for storage/transmission */
25
+ publicKeyHex: string;
26
+ }
27
+ export interface AgentCertificate {
28
+ agentId: string;
29
+ name: string;
30
+ publicKeyHex: string;
31
+ capabilities: string[];
32
+ issuedAt: string;
33
+ expiresAt?: string;
34
+ issuer?: string;
35
+ delegationDepth: number;
36
+ signature: string;
37
+ }
38
+ export interface DelegatedIdentity {
39
+ keyPair: Ed25519KeyPair;
40
+ certificate: AgentCertificate;
41
+ }
42
+ export interface Ed25519Config {
43
+ /** Certificate expiry in ms (default: 24 hours) */
44
+ certificateTtlMs?: number;
45
+ /** Maximum delegation depth (default: 5) */
46
+ maxDelegationDepth?: number;
47
+ }
48
+ export declare function createEd25519Identity(config?: Ed25519Config): {
49
+ /** Generate a new Ed25519 key pair */
50
+ generateKeyPair(): Promise<Ed25519KeyPair>;
51
+ /** Sign an action context with the agent's private key */
52
+ signAction(privateKey: CryptoKey, data: Record<string, unknown>): Promise<string>;
53
+ /** Verify an action signature with the agent's public key */
54
+ verifyAction(publicKey: CryptoKey, data: Record<string, unknown>, signature: string): Promise<boolean>;
55
+ /** Create a self-signed agent certificate */
56
+ createCertificate(privateKey: CryptoKey, agent: {
57
+ agentId: string;
58
+ name: string;
59
+ capabilities: string[];
60
+ }, issuer?: string): Promise<AgentCertificate>;
61
+ /** Verify a certificate's signature and expiry */
62
+ verifyCertificate(cert: AgentCertificate): Promise<{
63
+ valid: boolean;
64
+ reason?: string;
65
+ }>;
66
+ /**
67
+ * Delegate identity to a child agent with narrowed capabilities.
68
+ * Child capabilities must be a subset of parent capabilities.
69
+ */
70
+ delegate(parentKey: CryptoKey, parentCert: AgentCertificate, child: {
71
+ agentId: string;
72
+ name: string;
73
+ capabilities: string[];
74
+ }): Promise<DelegatedIdentity>;
75
+ /** Import a public key from hex for verification */
76
+ importPublicKey: typeof importPublicKey;
77
+ };
78
+ declare function importPublicKey(hex: string): Promise<CryptoKey>;
79
+ export {};
80
+ //# sourceMappingURL=agent-identity-ed25519.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-identity-ed25519.d.ts","sourceRoot":"","sources":["../src/agent-identity-ed25519.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4CAA4C;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAID,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,aAAkB;IAI5D,sCAAsC;uBACb,OAAO,CAAC,cAAc,CAAC;IAOhD,0DAA0D;2BAC7B,SAAS,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAOvF,6DAA6D;4BAC/B,SAAS,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO5G,6CAA6C;kCAE/B,SAAS,SACd;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,WACvD,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC;IAsB5B,kDAAkD;4BACpB,gBAAgB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAe7F;;;OAGG;wBAEU,SAAS,cACR,gBAAgB,SACrB;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,GAC/D,OAAO,CAAC,iBAAiB,CAAC;IA+B7B,oDAAoD;;EAGvD;AAgBD,iBAAe,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAG9D"}