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.
- package/LICENSE +21 -0
- package/README.md +559 -0
- package/dist/agent-identity-ed25519.d.ts +80 -0
- package/dist/agent-identity-ed25519.d.ts.map +1 -0
- package/dist/agent-identity-ed25519.js +134 -0
- package/dist/agent-identity-ed25519.js.map +1 -0
- package/dist/agent-identity.d.ts +65 -0
- package/dist/agent-identity.d.ts.map +1 -0
- package/dist/agent-identity.js +85 -0
- package/dist/agent-identity.js.map +1 -0
- package/dist/audit-integrity.d.ts +78 -0
- package/dist/audit-integrity.d.ts.map +1 -0
- package/dist/audit-integrity.js +173 -0
- package/dist/audit-integrity.js.map +1 -0
- package/dist/behavioral-scorer.d.ts +72 -0
- package/dist/behavioral-scorer.d.ts.map +1 -0
- package/dist/behavioral-scorer.js +223 -0
- package/dist/behavioral-scorer.js.map +1 -0
- package/dist/cli/init.d.ts +11 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +217 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/compliance-articles.d.ts +71 -0
- package/dist/compliance-articles.d.ts.map +1 -0
- package/dist/compliance-articles.js +201 -0
- package/dist/compliance-articles.js.map +1 -0
- package/dist/compliance.d.ts +24 -0
- package/dist/compliance.d.ts.map +1 -0
- package/dist/compliance.js +183 -0
- package/dist/compliance.js.map +1 -0
- package/dist/conditions/builtins.d.ts +17 -0
- package/dist/conditions/builtins.d.ts.map +1 -0
- package/dist/conditions/builtins.js +213 -0
- package/dist/conditions/builtins.js.map +1 -0
- package/dist/conditions/postprocess.d.ts +12 -0
- package/dist/conditions/postprocess.d.ts.map +1 -0
- package/dist/conditions/postprocess.js +33 -0
- package/dist/conditions/postprocess.js.map +1 -0
- package/dist/conditions/preprocess.d.ts +12 -0
- package/dist/conditions/preprocess.d.ts.map +1 -0
- package/dist/conditions/preprocess.js +47 -0
- package/dist/conditions/preprocess.js.map +1 -0
- package/dist/conditions/process.d.ts +14 -0
- package/dist/conditions/process.d.ts.map +1 -0
- package/dist/conditions/process.js +78 -0
- package/dist/conditions/process.js.map +1 -0
- package/dist/conditions/sensitive-patterns.d.ts +13 -0
- package/dist/conditions/sensitive-patterns.d.ts.map +1 -0
- package/dist/conditions/sensitive-patterns.js +42 -0
- package/dist/conditions/sensitive-patterns.js.map +1 -0
- package/dist/dry-run.d.ts +85 -0
- package/dist/dry-run.d.ts.map +1 -0
- package/dist/dry-run.js +132 -0
- package/dist/dry-run.js.map +1 -0
- package/dist/eval-red-team.d.ts +69 -0
- package/dist/eval-red-team.d.ts.map +1 -0
- package/dist/eval-red-team.js +205 -0
- package/dist/eval-red-team.js.map +1 -0
- package/dist/eval-scorer.d.ts +56 -0
- package/dist/eval-scorer.d.ts.map +1 -0
- package/dist/eval-scorer.js +148 -0
- package/dist/eval-scorer.js.map +1 -0
- package/dist/eval-trace.d.ts +30 -0
- package/dist/eval-trace.d.ts.map +1 -0
- package/dist/eval-trace.js +129 -0
- package/dist/eval-trace.js.map +1 -0
- package/dist/eval-types.d.ts +108 -0
- package/dist/eval-types.d.ts.map +1 -0
- package/dist/eval-types.js +14 -0
- package/dist/eval-types.js.map +1 -0
- package/dist/events.d.ts +57 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +81 -0
- package/dist/events.js.map +1 -0
- package/dist/federation-types.d.ts +58 -0
- package/dist/federation-types.d.ts.map +1 -0
- package/dist/federation-types.js +8 -0
- package/dist/federation-types.js.map +1 -0
- package/dist/federation.d.ts +42 -0
- package/dist/federation.d.ts.map +1 -0
- package/dist/federation.js +158 -0
- package/dist/federation.js.map +1 -0
- package/dist/index.d.ts +142 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +273 -0
- package/dist/index.js.map +1 -0
- package/dist/injection-benchmark.d.ts +62 -0
- package/dist/injection-benchmark.d.ts.map +1 -0
- package/dist/injection-benchmark.js +201 -0
- package/dist/injection-benchmark.js.map +1 -0
- package/dist/injection-classifier.d.ts +69 -0
- package/dist/injection-classifier.d.ts.map +1 -0
- package/dist/injection-classifier.js +98 -0
- package/dist/injection-classifier.js.map +1 -0
- package/dist/injection-detect.d.ts +59 -0
- package/dist/injection-detect.d.ts.map +1 -0
- package/dist/injection-detect.js +175 -0
- package/dist/injection-detect.js.map +1 -0
- package/dist/injection-patterns-ext.d.ts +7 -0
- package/dist/injection-patterns-ext.d.ts.map +1 -0
- package/dist/injection-patterns-ext.js +71 -0
- package/dist/injection-patterns-ext.js.map +1 -0
- package/dist/injection-patterns.d.ts +15 -0
- package/dist/injection-patterns.d.ts.map +1 -0
- package/dist/injection-patterns.js +361 -0
- package/dist/injection-patterns.js.map +1 -0
- package/dist/iso-42001-articles.d.ts +34 -0
- package/dist/iso-42001-articles.d.ts.map +1 -0
- package/dist/iso-42001-articles.js +147 -0
- package/dist/iso-42001-articles.js.map +1 -0
- package/dist/iso-42001.d.ts +18 -0
- package/dist/iso-42001.d.ts.map +1 -0
- package/dist/iso-42001.js +156 -0
- package/dist/iso-42001.js.map +1 -0
- package/dist/kill-switch.d.ts +56 -0
- package/dist/kill-switch.d.ts.map +1 -0
- package/dist/kill-switch.js +173 -0
- package/dist/kill-switch.js.map +1 -0
- package/dist/metrics.d.ts +58 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +81 -0
- package/dist/metrics.js.map +1 -0
- package/dist/monorepo-detect.d.ts +30 -0
- package/dist/monorepo-detect.d.ts.map +1 -0
- package/dist/monorepo-detect.js +107 -0
- package/dist/monorepo-detect.js.map +1 -0
- package/dist/nist-ai-rmf-articles.d.ts +40 -0
- package/dist/nist-ai-rmf-articles.d.ts.map +1 -0
- package/dist/nist-ai-rmf-articles.js +156 -0
- package/dist/nist-ai-rmf-articles.js.map +1 -0
- package/dist/nist-ai-rmf.d.ts +20 -0
- package/dist/nist-ai-rmf.d.ts.map +1 -0
- package/dist/nist-ai-rmf.js +176 -0
- package/dist/nist-ai-rmf.js.map +1 -0
- package/dist/otel-hooks.d.ts +67 -0
- package/dist/otel-hooks.d.ts.map +1 -0
- package/dist/otel-hooks.js +100 -0
- package/dist/otel-hooks.js.map +1 -0
- package/dist/owasp-agentic-articles.d.ts +42 -0
- package/dist/owasp-agentic-articles.d.ts.map +1 -0
- package/dist/owasp-agentic-articles.js +236 -0
- package/dist/owasp-agentic-articles.js.map +1 -0
- package/dist/owasp-agentic.d.ts +20 -0
- package/dist/owasp-agentic.d.ts.map +1 -0
- package/dist/owasp-agentic.js +205 -0
- package/dist/owasp-agentic.js.map +1 -0
- package/dist/plugins/a2a-types.d.ts +241 -0
- package/dist/plugins/a2a-types.d.ts.map +1 -0
- package/dist/plugins/a2a-types.js +14 -0
- package/dist/plugins/a2a-types.js.map +1 -0
- package/dist/plugins/a2a.d.ts +37 -0
- package/dist/plugins/a2a.d.ts.map +1 -0
- package/dist/plugins/a2a.js +160 -0
- package/dist/plugins/a2a.js.map +1 -0
- package/dist/plugins/anthropic-types.d.ts +188 -0
- package/dist/plugins/anthropic-types.d.ts.map +1 -0
- package/dist/plugins/anthropic-types.js +8 -0
- package/dist/plugins/anthropic-types.js.map +1 -0
- package/dist/plugins/anthropic.d.ts +32 -0
- package/dist/plugins/anthropic.d.ts.map +1 -0
- package/dist/plugins/anthropic.js +131 -0
- package/dist/plugins/anthropic.js.map +1 -0
- package/dist/plugins/autogen-types.d.ts +121 -0
- package/dist/plugins/autogen-types.d.ts.map +1 -0
- package/dist/plugins/autogen-types.js +13 -0
- package/dist/plugins/autogen-types.js.map +1 -0
- package/dist/plugins/autogen.d.ts +41 -0
- package/dist/plugins/autogen.d.ts.map +1 -0
- package/dist/plugins/autogen.js +131 -0
- package/dist/plugins/autogen.js.map +1 -0
- package/dist/plugins/bedrock-types.d.ts +246 -0
- package/dist/plugins/bedrock-types.d.ts.map +1 -0
- package/dist/plugins/bedrock-types.js +8 -0
- package/dist/plugins/bedrock-types.js.map +1 -0
- package/dist/plugins/bedrock.d.ts +43 -0
- package/dist/plugins/bedrock.d.ts.map +1 -0
- package/dist/plugins/bedrock.js +155 -0
- package/dist/plugins/bedrock.js.map +1 -0
- package/dist/plugins/cloudflare-ai-types.d.ts +85 -0
- package/dist/plugins/cloudflare-ai-types.d.ts.map +1 -0
- package/dist/plugins/cloudflare-ai-types.js +10 -0
- package/dist/plugins/cloudflare-ai-types.js.map +1 -0
- package/dist/plugins/cloudflare-ai.d.ts +32 -0
- package/dist/plugins/cloudflare-ai.d.ts.map +1 -0
- package/dist/plugins/cloudflare-ai.js +108 -0
- package/dist/plugins/cloudflare-ai.js.map +1 -0
- package/dist/plugins/composio-types.d.ts +96 -0
- package/dist/plugins/composio-types.d.ts.map +1 -0
- package/dist/plugins/composio-types.js +13 -0
- package/dist/plugins/composio-types.js.map +1 -0
- package/dist/plugins/composio.d.ts +37 -0
- package/dist/plugins/composio.d.ts.map +1 -0
- package/dist/plugins/composio.js +118 -0
- package/dist/plugins/composio.js.map +1 -0
- package/dist/plugins/crewai-types.d.ts +153 -0
- package/dist/plugins/crewai-types.d.ts.map +1 -0
- package/dist/plugins/crewai-types.js +10 -0
- package/dist/plugins/crewai-types.js.map +1 -0
- package/dist/plugins/crewai.d.ts +37 -0
- package/dist/plugins/crewai.d.ts.map +1 -0
- package/dist/plugins/crewai.js +127 -0
- package/dist/plugins/crewai.js.map +1 -0
- package/dist/plugins/deno-types.d.ts +68 -0
- package/dist/plugins/deno-types.d.ts.map +1 -0
- package/dist/plugins/deno-types.js +8 -0
- package/dist/plugins/deno-types.js.map +1 -0
- package/dist/plugins/deno.d.ts +37 -0
- package/dist/plugins/deno.d.ts.map +1 -0
- package/dist/plugins/deno.js +129 -0
- package/dist/plugins/deno.js.map +1 -0
- package/dist/plugins/e2b-types.d.ts +140 -0
- package/dist/plugins/e2b-types.d.ts.map +1 -0
- package/dist/plugins/e2b-types.js +8 -0
- package/dist/plugins/e2b-types.js.map +1 -0
- package/dist/plugins/e2b.d.ts +43 -0
- package/dist/plugins/e2b.d.ts.map +1 -0
- package/dist/plugins/e2b.js +157 -0
- package/dist/plugins/e2b.js.map +1 -0
- package/dist/plugins/genkit-types.d.ts +88 -0
- package/dist/plugins/genkit-types.d.ts.map +1 -0
- package/dist/plugins/genkit-types.js +11 -0
- package/dist/plugins/genkit-types.js.map +1 -0
- package/dist/plugins/genkit.d.ts +35 -0
- package/dist/plugins/genkit.d.ts.map +1 -0
- package/dist/plugins/genkit.js +143 -0
- package/dist/plugins/genkit.js.map +1 -0
- package/dist/plugins/langchain.d.ts +130 -0
- package/dist/plugins/langchain.d.ts.map +1 -0
- package/dist/plugins/langchain.js +172 -0
- package/dist/plugins/langchain.js.map +1 -0
- package/dist/plugins/llamaindex-types.d.ts +86 -0
- package/dist/plugins/llamaindex-types.d.ts.map +1 -0
- package/dist/plugins/llamaindex-types.js +11 -0
- package/dist/plugins/llamaindex-types.js.map +1 -0
- package/dist/plugins/llamaindex.d.ts +36 -0
- package/dist/plugins/llamaindex.d.ts.map +1 -0
- package/dist/plugins/llamaindex.js +131 -0
- package/dist/plugins/llamaindex.js.map +1 -0
- package/dist/plugins/mastra-processor-types.d.ts +126 -0
- package/dist/plugins/mastra-processor-types.d.ts.map +1 -0
- package/dist/plugins/mastra-processor-types.js +11 -0
- package/dist/plugins/mastra-processor-types.js.map +1 -0
- package/dist/plugins/mastra-processor.d.ts +32 -0
- package/dist/plugins/mastra-processor.d.ts.map +1 -0
- package/dist/plugins/mastra-processor.js +126 -0
- package/dist/plugins/mastra-processor.js.map +1 -0
- package/dist/plugins/mastra.d.ts +100 -0
- package/dist/plugins/mastra.d.ts.map +1 -0
- package/dist/plugins/mastra.js +143 -0
- package/dist/plugins/mastra.js.map +1 -0
- package/dist/plugins/mcp-annotations.d.ts +54 -0
- package/dist/plugins/mcp-annotations.d.ts.map +1 -0
- package/dist/plugins/mcp-annotations.js +110 -0
- package/dist/plugins/mcp-annotations.js.map +1 -0
- package/dist/plugins/mcp-chain-audit.d.ts +74 -0
- package/dist/plugins/mcp-chain-audit.d.ts.map +1 -0
- package/dist/plugins/mcp-chain-audit.js +134 -0
- package/dist/plugins/mcp-chain-audit.js.map +1 -0
- package/dist/plugins/mcp-trust.d.ts +59 -0
- package/dist/plugins/mcp-trust.d.ts.map +1 -0
- package/dist/plugins/mcp-trust.js +100 -0
- package/dist/plugins/mcp-trust.js.map +1 -0
- package/dist/plugins/mcp-types.d.ts +183 -0
- package/dist/plugins/mcp-types.d.ts.map +1 -0
- package/dist/plugins/mcp-types.js +12 -0
- package/dist/plugins/mcp-types.js.map +1 -0
- package/dist/plugins/mcp.d.ts +41 -0
- package/dist/plugins/mcp.d.ts.map +1 -0
- package/dist/plugins/mcp.js +228 -0
- package/dist/plugins/mcp.js.map +1 -0
- package/dist/plugins/mistral-types.d.ts +72 -0
- package/dist/plugins/mistral-types.d.ts.map +1 -0
- package/dist/plugins/mistral-types.js +8 -0
- package/dist/plugins/mistral-types.js.map +1 -0
- package/dist/plugins/mistral.d.ts +32 -0
- package/dist/plugins/mistral.d.ts.map +1 -0
- package/dist/plugins/mistral.js +133 -0
- package/dist/plugins/mistral.js.map +1 -0
- package/dist/plugins/ollama-types.d.ts +76 -0
- package/dist/plugins/ollama-types.d.ts.map +1 -0
- package/dist/plugins/ollama-types.js +8 -0
- package/dist/plugins/ollama-types.js.map +1 -0
- package/dist/plugins/ollama.d.ts +32 -0
- package/dist/plugins/ollama.d.ts.map +1 -0
- package/dist/plugins/ollama.js +130 -0
- package/dist/plugins/ollama.js.map +1 -0
- package/dist/plugins/openai-agents-types.d.ts +130 -0
- package/dist/plugins/openai-agents-types.d.ts.map +1 -0
- package/dist/plugins/openai-agents-types.js +12 -0
- package/dist/plugins/openai-agents-types.js.map +1 -0
- package/dist/plugins/openai-agents.d.ts +37 -0
- package/dist/plugins/openai-agents.d.ts.map +1 -0
- package/dist/plugins/openai-agents.js +151 -0
- package/dist/plugins/openai-agents.js.map +1 -0
- package/dist/plugins/semantic-kernel-types.d.ts +103 -0
- package/dist/plugins/semantic-kernel-types.d.ts.map +1 -0
- package/dist/plugins/semantic-kernel-types.js +13 -0
- package/dist/plugins/semantic-kernel-types.js.map +1 -0
- package/dist/plugins/semantic-kernel.d.ts +37 -0
- package/dist/plugins/semantic-kernel.d.ts.map +1 -0
- package/dist/plugins/semantic-kernel.js +149 -0
- package/dist/plugins/semantic-kernel.js.map +1 -0
- package/dist/plugins/vercel-ai.d.ts +134 -0
- package/dist/plugins/vercel-ai.d.ts.map +1 -0
- package/dist/plugins/vercel-ai.js +130 -0
- package/dist/plugins/vercel-ai.js.map +1 -0
- package/dist/policy-builder.d.ts +52 -0
- package/dist/policy-builder.d.ts.map +1 -0
- package/dist/policy-builder.js +108 -0
- package/dist/policy-builder.js.map +1 -0
- package/dist/policy-compose-presets.d.ts +18 -0
- package/dist/policy-compose-presets.d.ts.map +1 -0
- package/dist/policy-compose-presets.js +52 -0
- package/dist/policy-compose-presets.js.map +1 -0
- package/dist/policy-compose.d.ts +66 -0
- package/dist/policy-compose.d.ts.map +1 -0
- package/dist/policy-compose.js +163 -0
- package/dist/policy-compose.js.map +1 -0
- package/dist/policy-presets-extended.d.ts +35 -0
- package/dist/policy-presets-extended.d.ts.map +1 -0
- package/dist/policy-presets-extended.js +137 -0
- package/dist/policy-presets-extended.js.map +1 -0
- package/dist/policy-presets.d.ts +77 -0
- package/dist/policy-presets.d.ts.map +1 -0
- package/dist/policy-presets.js +164 -0
- package/dist/policy-presets.js.map +1 -0
- package/dist/policy-stage-defaults.d.ts +8 -0
- package/dist/policy-stage-defaults.d.ts.map +1 -0
- package/dist/policy-stage-defaults.js +34 -0
- package/dist/policy-stage-defaults.js.map +1 -0
- package/dist/policy-yaml.d.ts +23 -0
- package/dist/policy-yaml.d.ts.map +1 -0
- package/dist/policy-yaml.js +216 -0
- package/dist/policy-yaml.js.map +1 -0
- package/dist/policy.d.ts +124 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +161 -0
- package/dist/policy.js.map +1 -0
- package/dist/remote-enforce.d.ts +44 -0
- package/dist/remote-enforce.d.ts.map +1 -0
- package/dist/remote-enforce.js +99 -0
- package/dist/remote-enforce.js.map +1 -0
- package/dist/repo-patterns.d.ts +32 -0
- package/dist/repo-patterns.d.ts.map +1 -0
- package/dist/repo-patterns.js +222 -0
- package/dist/repo-patterns.js.map +1 -0
- package/dist/sandbox.d.ts +68 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +124 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/scorer-dimensions.d.ts +10 -0
- package/dist/scorer-dimensions.d.ts.map +1 -0
- package/dist/scorer-dimensions.js +184 -0
- package/dist/scorer-dimensions.js.map +1 -0
- package/dist/scorer.d.ts +27 -0
- package/dist/scorer.d.ts.map +1 -0
- package/dist/scorer.js +138 -0
- package/dist/scorer.js.map +1 -0
- package/dist/storage-postgres-schema.d.ts +47 -0
- package/dist/storage-postgres-schema.d.ts.map +1 -0
- package/dist/storage-postgres-schema.js +134 -0
- package/dist/storage-postgres-schema.js.map +1 -0
- package/dist/storage-postgres.d.ts +41 -0
- package/dist/storage-postgres.d.ts.map +1 -0
- package/dist/storage-postgres.js +180 -0
- package/dist/storage-postgres.js.map +1 -0
- package/dist/storage.d.ts +65 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +85 -0
- package/dist/storage.js.map +1 -0
- package/dist/supply-chain-sbom.d.ts +72 -0
- package/dist/supply-chain-sbom.d.ts.map +1 -0
- package/dist/supply-chain-sbom.js +73 -0
- package/dist/supply-chain-sbom.js.map +1 -0
- package/dist/supply-chain.d.ts +61 -0
- package/dist/supply-chain.d.ts.map +1 -0
- package/dist/supply-chain.js +95 -0
- package/dist/supply-chain.js.map +1 -0
- package/dist/token-types.d.ts +77 -0
- package/dist/token-types.d.ts.map +1 -0
- package/dist/token-types.js +31 -0
- package/dist/token-types.js.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +361 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* governance-sdk Composio Plugin
|
|
3
|
+
*
|
|
4
|
+
* Integrates governance enforcement into Composio tool execution.
|
|
5
|
+
* Wraps tools with before-action policy checks and audit logging.
|
|
6
|
+
*
|
|
7
|
+
* Updated for @composio/core v0.6+ (Actions→Tools, Apps→Toolkits).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { createGovernance, blockTools } from 'governance-sdk';
|
|
12
|
+
* import { governComposioTools } from 'governance-sdk/plugins/composio';
|
|
13
|
+
*
|
|
14
|
+
* const gov = createGovernance({
|
|
15
|
+
* rules: [blockTools(['GMAIL_SEND_EMAIL'])],
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* const { tools } = await governComposioTools(gov, myTools, {
|
|
19
|
+
* agentName: 'composio-agent',
|
|
20
|
+
* owner: 'integration-team',
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
// ─── Blocked Error ──────────────────────────────────────────
|
|
25
|
+
export class GovernanceBlockedError extends Error {
|
|
26
|
+
decision;
|
|
27
|
+
toolName;
|
|
28
|
+
constructor(decision, toolName) {
|
|
29
|
+
super(`Governance blocked: ${decision.reason} (tool: ${toolName})`);
|
|
30
|
+
this.name = "GovernanceBlockedError";
|
|
31
|
+
this.decision = decision;
|
|
32
|
+
this.toolName = toolName;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// ─── Shared Helpers ─────────────────────────────────────────
|
|
36
|
+
function buildRegistration(config, toolNames) {
|
|
37
|
+
return {
|
|
38
|
+
name: config.agentName,
|
|
39
|
+
framework: config.framework ?? "composio",
|
|
40
|
+
owner: config.owner,
|
|
41
|
+
description: config.description,
|
|
42
|
+
version: config.version,
|
|
43
|
+
channels: config.channels,
|
|
44
|
+
tools: toolNames,
|
|
45
|
+
hasAuth: config.hasAuth,
|
|
46
|
+
hasGuardrails: config.hasGuardrails,
|
|
47
|
+
hasObservability: config.hasObservability,
|
|
48
|
+
hasAuditLog: true,
|
|
49
|
+
permissions: config.permissions,
|
|
50
|
+
metadata: config.metadata,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function createEnforcer(governance, agentId, config) {
|
|
54
|
+
return async (toolName, input) => {
|
|
55
|
+
const toolkitMapper = config.toolkitActionMapper ?? config.appActionMapper;
|
|
56
|
+
const action = toolkitMapper?.(toolName.split("_")[0] ?? toolName)
|
|
57
|
+
?? config.actionMapper?.(toolName)
|
|
58
|
+
?? "tool_call";
|
|
59
|
+
const decision = await governance.enforce({
|
|
60
|
+
agentId, agentName: config.agentName, agentLevel: 0,
|
|
61
|
+
action, tool: toolName, input,
|
|
62
|
+
sessionTokensUsed: config.sessionTokenTracker?.(),
|
|
63
|
+
});
|
|
64
|
+
config.onDecision?.(decision, toolName);
|
|
65
|
+
if (decision.blocked)
|
|
66
|
+
config.onBlocked?.(decision, toolName);
|
|
67
|
+
return decision;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function createAuditor(governance, agentId) {
|
|
71
|
+
return (toolName, outcome, detail) => governance.audit.log({
|
|
72
|
+
agentId, eventType: "tool_call", outcome,
|
|
73
|
+
severity: outcome === "failure" ? "warning" : "info",
|
|
74
|
+
detail: { tool: toolName, ...detail },
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
// ─── Main Export ────────────────────────────────────────────
|
|
78
|
+
/** Govern Composio tools (v0.6+ API) */
|
|
79
|
+
export async function governComposioTools(governance, tools, config) {
|
|
80
|
+
const toolNames = tools.map((t) => t.name);
|
|
81
|
+
const reg = buildRegistration(config, toolNames);
|
|
82
|
+
const result = await governance.register(reg);
|
|
83
|
+
const enforce = createEnforcer(governance, result.id, config);
|
|
84
|
+
const audit = createAuditor(governance, result.id);
|
|
85
|
+
const governedTools = tools.map((tool) => ({
|
|
86
|
+
...tool,
|
|
87
|
+
execute: async (params) => {
|
|
88
|
+
const decision = await enforce(tool.name, params);
|
|
89
|
+
if (decision.blocked)
|
|
90
|
+
throw new GovernanceBlockedError(decision, tool.name);
|
|
91
|
+
try {
|
|
92
|
+
const output = await tool.execute(params);
|
|
93
|
+
await audit(tool.name, "success", { toolkitSlug: tool.toolkitSlug });
|
|
94
|
+
return output;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
await audit(tool.name, "failure", {
|
|
98
|
+
toolkitSlug: tool.toolkitSlug,
|
|
99
|
+
error: error instanceof Error ? error.message : String(error),
|
|
100
|
+
});
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
}));
|
|
105
|
+
return {
|
|
106
|
+
tools: governedTools,
|
|
107
|
+
actions: governedTools, // backward compat
|
|
108
|
+
agentId: result.id,
|
|
109
|
+
score: result.score,
|
|
110
|
+
level: result.level,
|
|
111
|
+
governance,
|
|
112
|
+
enforce,
|
|
113
|
+
audit,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** @deprecated Use governComposioTools instead */
|
|
117
|
+
export const governComposioActions = governComposioTools;
|
|
118
|
+
//# sourceMappingURL=composio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composio.js","sourceRoot":"","sources":["../../src/plugins/composio.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAiBH,+DAA+D;AAE/D,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/B,QAAQ,CAAsB;IAC9B,QAAQ,CAAS;IAEjC,YAAY,QAA6B,EAAE,QAAgB;QACzD,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,WAAW,QAAQ,GAAG,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AA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
|
|
5
|
+
* These types approximate CrewAI Python shapes for governance
|
|
6
|
+
* wrapping purposes. The Python SDK uses `_run()` / `_arun()`
|
|
7
|
+
* methods, not `execute()`.
|
|
8
|
+
*/
|
|
9
|
+
import type { GovernanceInstance, AuditEvent } from "../index";
|
|
10
|
+
import type { EnforcementDecision, PolicyAction } from "../policy";
|
|
11
|
+
import type { AgentFramework } from "../types";
|
|
12
|
+
/** CrewAI tool shape */
|
|
13
|
+
export interface CrewAITool {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
/** Pydantic model schema for tool input validation */
|
|
17
|
+
argsSchema?: Record<string, unknown>;
|
|
18
|
+
/** Whether result should be used as final answer */
|
|
19
|
+
resultAsAnswer?: boolean;
|
|
20
|
+
/** Maximum number of times this tool can be used per task */
|
|
21
|
+
maxUsageCount?: number;
|
|
22
|
+
/** Custom caching logic */
|
|
23
|
+
cacheFunction?: (args: Record<string, unknown>, result: unknown) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Execute the tool — governance wrapper method.
|
|
26
|
+
* Maps to Python `_run()` / `_arun()` methods.
|
|
27
|
+
*/
|
|
28
|
+
execute: (input: Record<string, unknown>) => Promise<unknown>;
|
|
29
|
+
}
|
|
30
|
+
/** CrewAI agent shape */
|
|
31
|
+
export interface CrewAIAgent {
|
|
32
|
+
role: string;
|
|
33
|
+
goal: string;
|
|
34
|
+
backstory: string;
|
|
35
|
+
tools?: CrewAITool[];
|
|
36
|
+
allowDelegation?: boolean;
|
|
37
|
+
/** Language model configuration */
|
|
38
|
+
llm?: string | Record<string, unknown>;
|
|
39
|
+
/** Language model for tool calling; overrides crew's LLM */
|
|
40
|
+
functionCallingLlm?: string | Record<string, unknown>;
|
|
41
|
+
/** Agent memory configuration (accepts Memory objects in Python SDK) */
|
|
42
|
+
memory?: boolean | unknown;
|
|
43
|
+
/** Maximum iterations before stopping (default: 25) */
|
|
44
|
+
maxIter?: number;
|
|
45
|
+
/** Maximum requests per minute to avoid rate limits */
|
|
46
|
+
maxRpm?: number;
|
|
47
|
+
/** Maximum execution time in seconds */
|
|
48
|
+
maxExecutionTime?: number;
|
|
49
|
+
/** Maximum retry attempts (default: 2) */
|
|
50
|
+
maxRetryLimit?: number;
|
|
51
|
+
/** Whether code execution is allowed — SECURITY CRITICAL */
|
|
52
|
+
allowCodeExecution?: boolean;
|
|
53
|
+
/** Code execution safety mode — SECURITY CRITICAL */
|
|
54
|
+
codeExecutionMode?: "safe" | "unsafe";
|
|
55
|
+
/** Step callback for per-step hooks */
|
|
56
|
+
stepCallback?: (step: unknown) => void;
|
|
57
|
+
/** Whether to enable verbose logging */
|
|
58
|
+
verbose?: boolean;
|
|
59
|
+
/** Enable caching for tool usage (default: true) */
|
|
60
|
+
cache?: boolean;
|
|
61
|
+
/** Custom system prompt template */
|
|
62
|
+
systemTemplate?: string;
|
|
63
|
+
/** Custom prompt template for input */
|
|
64
|
+
promptTemplate?: string;
|
|
65
|
+
/** Custom response template for output */
|
|
66
|
+
responseTemplate?: string;
|
|
67
|
+
/** Keep messages under context window size by summarizing (default: true) */
|
|
68
|
+
respectContextWindow?: boolean;
|
|
69
|
+
/** Support for multimodal capabilities */
|
|
70
|
+
multimodal?: boolean;
|
|
71
|
+
/** Whether to use system prompt — needed for o1 model support (default: true) */
|
|
72
|
+
useSystemPrompt?: boolean;
|
|
73
|
+
/** Whether agent should reflect and plan before executing */
|
|
74
|
+
reasoning?: boolean;
|
|
75
|
+
/** Maximum reasoning attempts before task execution */
|
|
76
|
+
maxReasoningAttempts?: number;
|
|
77
|
+
/** Configuration for embedder used by agent */
|
|
78
|
+
embedder?: Record<string, unknown>;
|
|
79
|
+
/** Knowledge sources available to agent */
|
|
80
|
+
knowledgeSources?: unknown[];
|
|
81
|
+
/** Automatically inject current date into tasks */
|
|
82
|
+
injectDate?: boolean;
|
|
83
|
+
/** Format string for injected dates (default: "%Y-%m-%d") */
|
|
84
|
+
dateFormat?: string;
|
|
85
|
+
}
|
|
86
|
+
/** CrewAI task shape */
|
|
87
|
+
export interface CrewAITask {
|
|
88
|
+
description: string;
|
|
89
|
+
agent?: CrewAIAgent;
|
|
90
|
+
tools?: CrewAITool[];
|
|
91
|
+
expectedOutput: string;
|
|
92
|
+
/** Task identifier label */
|
|
93
|
+
name?: string;
|
|
94
|
+
/** Task dependencies — other tasks whose outputs become context */
|
|
95
|
+
context?: CrewAITask[];
|
|
96
|
+
/** Whether this task requires human input */
|
|
97
|
+
humanInput?: boolean;
|
|
98
|
+
/** Run task asynchronously */
|
|
99
|
+
asyncExecution?: boolean;
|
|
100
|
+
/** Callback on task completion */
|
|
101
|
+
callback?: (output: unknown) => void;
|
|
102
|
+
/** Pydantic model for structured JSON output */
|
|
103
|
+
outputJson?: Record<string, unknown>;
|
|
104
|
+
/** Pydantic model for structured pydantic output */
|
|
105
|
+
outputPydantic?: Record<string, unknown>;
|
|
106
|
+
/** File path for storing task output */
|
|
107
|
+
outputFile?: string;
|
|
108
|
+
/** Whether to create directory for output_file if absent (default: true) */
|
|
109
|
+
createDirectory?: boolean;
|
|
110
|
+
/** Whether to format final answer in Markdown */
|
|
111
|
+
markdown?: boolean;
|
|
112
|
+
/** Task-specific configuration parameters */
|
|
113
|
+
config?: Record<string, unknown>;
|
|
114
|
+
/** Function to validate task output before proceeding */
|
|
115
|
+
guardrail?: (output: unknown) => unknown;
|
|
116
|
+
/** List of guardrail functions to validate task output */
|
|
117
|
+
guardrails?: Array<(output: unknown) => unknown>;
|
|
118
|
+
/** Maximum retry attempts when guardrail validation fails (default: 3) */
|
|
119
|
+
guardrailMaxRetries?: number;
|
|
120
|
+
}
|
|
121
|
+
export interface GovernCrewAIConfig {
|
|
122
|
+
agentName: string;
|
|
123
|
+
owner: string;
|
|
124
|
+
framework?: AgentFramework;
|
|
125
|
+
description?: string;
|
|
126
|
+
version?: string;
|
|
127
|
+
channels?: string[];
|
|
128
|
+
hasAuth?: boolean;
|
|
129
|
+
hasGuardrails?: boolean;
|
|
130
|
+
hasObservability?: boolean;
|
|
131
|
+
permissions?: Record<string, unknown>;
|
|
132
|
+
metadata?: Record<string, unknown>;
|
|
133
|
+
onBlocked?: (decision: EnforcementDecision, toolName: string) => void;
|
|
134
|
+
onDecision?: (decision: EnforcementDecision, toolName: string) => void;
|
|
135
|
+
actionMapper?: (toolName: string) => PolicyAction;
|
|
136
|
+
sessionTokenTracker?: () => number;
|
|
137
|
+
}
|
|
138
|
+
export interface GovernedCrewAIAgentResult {
|
|
139
|
+
agent: CrewAIAgent;
|
|
140
|
+
agentId: string;
|
|
141
|
+
score: number;
|
|
142
|
+
level: number;
|
|
143
|
+
governance: GovernanceInstance;
|
|
144
|
+
enforce: (toolName: string, input?: Record<string, unknown>) => Promise<EnforcementDecision>;
|
|
145
|
+
audit: (toolName: string, outcome: "success" | "failure", detail?: Record<string, unknown>) => Promise<AuditEvent>;
|
|
146
|
+
}
|
|
147
|
+
export interface GovernedCrewAIToolsResult {
|
|
148
|
+
tools: CrewAITool[];
|
|
149
|
+
agentId: string;
|
|
150
|
+
score: number;
|
|
151
|
+
level: number;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=crewai-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai-types.d.ts","sourceRoot":"","sources":["../../src/plugins/crewai-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,wBAAwB;AACxB,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,oDAAoD;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AC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACvE,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,YAAY,CAAC;IAClD,mBAAmB,CAAC,EAAE,MAAM,MAAM,CAAC;CACpC;AAID,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC7F,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACpH;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the CrewAI governance integration.
|
|
3
|
+
*
|
|
4
|
+
* NOTE: CrewAI is Python-first with no official TypeScript SDK.
|
|
5
|
+
* These types approximate CrewAI Python shapes for governance
|
|
6
|
+
* wrapping purposes. The Python SDK uses `_run()` / `_arun()`
|
|
7
|
+
* methods, not `execute()`.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=crewai-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai-types.js","sourceRoot":"","sources":["../../src/plugins/crewai-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* governance-sdk CrewAI Plugin
|
|
3
|
+
*
|
|
4
|
+
* Integrates governance enforcement into CrewAI agent tool execution.
|
|
5
|
+
* Wraps tools with before-action policy checks and audit logging.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createGovernance, blockTools } from 'governance-sdk';
|
|
10
|
+
* import { governCrewAIAgent } from 'governance-sdk/plugins/crewai';
|
|
11
|
+
*
|
|
12
|
+
* const gov = createGovernance({
|
|
13
|
+
* rules: [blockTools(['shell_exec'])],
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const { agent } = await governCrewAIAgent(gov, {
|
|
17
|
+
* role: 'researcher',
|
|
18
|
+
* goal: 'Find information',
|
|
19
|
+
* tools: [webSearchTool, fileReadTool],
|
|
20
|
+
* }, {
|
|
21
|
+
* agentName: 'researcher',
|
|
22
|
+
* owner: 'research-team',
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { GovernanceInstance } from "../index";
|
|
27
|
+
import type { EnforcementDecision } from "../policy";
|
|
28
|
+
import type { CrewAITool, CrewAIAgent, GovernCrewAIConfig, GovernedCrewAIAgentResult, GovernedCrewAIToolsResult } from "./crewai-types.js";
|
|
29
|
+
export type { CrewAITool, CrewAIAgent, CrewAITask, GovernCrewAIConfig, GovernedCrewAIAgentResult, GovernedCrewAIToolsResult, } from "./crewai-types.js";
|
|
30
|
+
export declare class GovernanceBlockedError extends Error {
|
|
31
|
+
readonly decision: EnforcementDecision;
|
|
32
|
+
readonly toolName: string;
|
|
33
|
+
constructor(decision: EnforcementDecision, toolName: string);
|
|
34
|
+
}
|
|
35
|
+
export declare function governCrewAIAgent(governance: GovernanceInstance, agent: CrewAIAgent, config: GovernCrewAIConfig): Promise<GovernedCrewAIAgentResult>;
|
|
36
|
+
export declare function governCrewAITools(governance: GovernanceInstance, tools: CrewAITool[], config: GovernCrewAIConfig): Promise<GovernedCrewAIToolsResult>;
|
|
37
|
+
//# sourceMappingURL=crewai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai.d.ts","sourceRoot":"","sources":["../../src/plugins/crewai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,WAAW,CAAC;AAEnE,OAAO,KAAK,EACV,UAAU,EAAE,WAAW,EACvB,kBAAkB,EAAE,yBAAyB,EAAE,yBAAyB,EACzE,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,UAAU,EAAE,WAAW,EAAE,UAAU,EACnC,kBAAkB,EAAE,yBAAyB,EAAE,yBAAyB,GACzE,MAAM,mBAAmB,CAAC;AAI3B,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,SAAgB,QAAQ,EAAE,mBAAmB,CAAC;IAC9C,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM;CAM5D;AAqED,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,yBAAyB,CAAC,CAkBpC;AAID,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,yBAAyB,CAAC,CAcpC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* governance-sdk CrewAI Plugin
|
|
3
|
+
*
|
|
4
|
+
* Integrates governance enforcement into CrewAI agent tool execution.
|
|
5
|
+
* Wraps tools with before-action policy checks and audit logging.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createGovernance, blockTools } from 'governance-sdk';
|
|
10
|
+
* import { governCrewAIAgent } from 'governance-sdk/plugins/crewai';
|
|
11
|
+
*
|
|
12
|
+
* const gov = createGovernance({
|
|
13
|
+
* rules: [blockTools(['shell_exec'])],
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const { agent } = await governCrewAIAgent(gov, {
|
|
17
|
+
* role: 'researcher',
|
|
18
|
+
* goal: 'Find information',
|
|
19
|
+
* tools: [webSearchTool, fileReadTool],
|
|
20
|
+
* }, {
|
|
21
|
+
* agentName: 'researcher',
|
|
22
|
+
* owner: 'research-team',
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
// ─── Blocked Error ──────────────────────────────────────────
|
|
27
|
+
export class GovernanceBlockedError extends Error {
|
|
28
|
+
decision;
|
|
29
|
+
toolName;
|
|
30
|
+
constructor(decision, toolName) {
|
|
31
|
+
super(`Governance blocked: ${decision.reason} (tool: ${toolName})`);
|
|
32
|
+
this.name = "GovernanceBlockedError";
|
|
33
|
+
this.decision = decision;
|
|
34
|
+
this.toolName = toolName;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// ─── Shared Helpers ─────────────────────────────────────────
|
|
38
|
+
function buildRegistration(config, toolNames, description) {
|
|
39
|
+
return {
|
|
40
|
+
name: config.agentName,
|
|
41
|
+
framework: config.framework ?? "crewai",
|
|
42
|
+
owner: config.owner,
|
|
43
|
+
description: config.description ?? description,
|
|
44
|
+
version: config.version,
|
|
45
|
+
channels: config.channels,
|
|
46
|
+
tools: toolNames,
|
|
47
|
+
hasAuth: config.hasAuth,
|
|
48
|
+
hasGuardrails: config.hasGuardrails,
|
|
49
|
+
hasObservability: config.hasObservability,
|
|
50
|
+
hasAuditLog: true,
|
|
51
|
+
permissions: config.permissions,
|
|
52
|
+
metadata: config.metadata,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function createEnforcer(governance, agentId, config) {
|
|
56
|
+
return async (toolName, input) => {
|
|
57
|
+
const action = config.actionMapper?.(toolName) ?? "tool_call";
|
|
58
|
+
const decision = await governance.enforce({
|
|
59
|
+
agentId, agentName: config.agentName, agentLevel: 0,
|
|
60
|
+
action, tool: toolName, input,
|
|
61
|
+
sessionTokensUsed: config.sessionTokenTracker?.(),
|
|
62
|
+
});
|
|
63
|
+
config.onDecision?.(decision, toolName);
|
|
64
|
+
if (decision.blocked)
|
|
65
|
+
config.onBlocked?.(decision, toolName);
|
|
66
|
+
return decision;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function createAuditor(governance, agentId) {
|
|
70
|
+
return (toolName, outcome, detail) => governance.audit.log({
|
|
71
|
+
agentId, eventType: "tool_call", outcome,
|
|
72
|
+
severity: outcome === "failure" ? "warning" : "info",
|
|
73
|
+
detail: { tool: toolName, ...detail },
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function wrapTool(tool, enforce, audit) {
|
|
77
|
+
return {
|
|
78
|
+
...tool,
|
|
79
|
+
execute: async (input) => {
|
|
80
|
+
const decision = await enforce(tool.name, input);
|
|
81
|
+
if (decision.blocked)
|
|
82
|
+
throw new GovernanceBlockedError(decision, tool.name);
|
|
83
|
+
try {
|
|
84
|
+
const output = await tool.execute(input);
|
|
85
|
+
await audit(tool.name, "success");
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
await audit(tool.name, "failure", { error: error instanceof Error ? error.message : String(error) });
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// ─── Govern CrewAI Agent ────────────────────────────────────
|
|
96
|
+
export async function governCrewAIAgent(governance, agent, config) {
|
|
97
|
+
const toolNames = (agent.tools ?? []).map((t) => t.name);
|
|
98
|
+
const reg = buildRegistration(config, toolNames, agent.goal);
|
|
99
|
+
const result = await governance.register(reg);
|
|
100
|
+
const enforce = createEnforcer(governance, result.id, config);
|
|
101
|
+
const audit = createAuditor(governance, result.id);
|
|
102
|
+
const wrappedTools = (agent.tools ?? []).map((tool) => wrapTool(tool, enforce, audit));
|
|
103
|
+
return {
|
|
104
|
+
agent: { ...agent, tools: wrappedTools },
|
|
105
|
+
agentId: result.id,
|
|
106
|
+
score: result.score,
|
|
107
|
+
level: result.level,
|
|
108
|
+
governance,
|
|
109
|
+
enforce,
|
|
110
|
+
audit,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// ─── Govern Tools Only ──────────────────────────────────────
|
|
114
|
+
export async function governCrewAITools(governance, tools, config) {
|
|
115
|
+
const toolNames = tools.map((t) => t.name);
|
|
116
|
+
const reg = buildRegistration(config, toolNames);
|
|
117
|
+
const result = await governance.register(reg);
|
|
118
|
+
const enforce = createEnforcer(governance, result.id, config);
|
|
119
|
+
const audit = createAuditor(governance, result.id);
|
|
120
|
+
return {
|
|
121
|
+
tools: tools.map((tool) => wrapTool(tool, enforce, audit)),
|
|
122
|
+
agentId: result.id,
|
|
123
|
+
score: result.score,
|
|
124
|
+
level: result.level,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=crewai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai.js","sourceRoot":"","sources":["../../src/plugins/crewai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAgBH,+DAA+D;AAE/D,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/B,QAAQ,CAAsB;IAC9B,QAAQ,CAAS;IAEjC,YAAY,QAA6B,EAAE,QAAgB;QACzD,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,WAAW,QAAQ,GAAG,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,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,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE9C,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAEnD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1D,OAAO,EAAE,MAAM,CAAC,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Deno AI governance integration.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors Deno-native AI agent patterns and permission system
|
|
5
|
+
* without requiring Deno APIs as a dependency.
|
|
6
|
+
*/
|
|
7
|
+
import type { GovernanceInstance, AuditEvent } from "../index";
|
|
8
|
+
import type { EnforcementDecision, PolicyAction } from "../policy";
|
|
9
|
+
import type { AgentFramework } from "../types";
|
|
10
|
+
/** Deno AI tool shape */
|
|
11
|
+
export interface DenoTool {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
parameters?: Record<string, unknown>;
|
|
15
|
+
execute: (args: Record<string, unknown>) => Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
/** Deno permission descriptor */
|
|
18
|
+
export interface DenoPermissionDescriptor {
|
|
19
|
+
name: "read" | "write" | "net" | "env" | "run" | "ffi" | "sys" | "import";
|
|
20
|
+
path?: string | URL;
|
|
21
|
+
host?: string;
|
|
22
|
+
command?: string | URL;
|
|
23
|
+
variable?: string;
|
|
24
|
+
/** Scope for sys permission */
|
|
25
|
+
kind?: "loadavg" | "hostname" | "systemMemoryInfo" | "networkInterfaces" | "osRelease" | "osUptime" | "uid" | "gid" | "username" | "cpus" | "homedir" | "statfs" | "getPriority" | "setPriority";
|
|
26
|
+
}
|
|
27
|
+
/** Deno AI agent shape */
|
|
28
|
+
export interface DenoAgent {
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
tools: DenoTool[];
|
|
32
|
+
permissions?: DenoPermissionDescriptor[];
|
|
33
|
+
}
|
|
34
|
+
export interface GovernDenoConfig {
|
|
35
|
+
agentName: string;
|
|
36
|
+
owner: string;
|
|
37
|
+
framework?: AgentFramework;
|
|
38
|
+
description?: string;
|
|
39
|
+
version?: string;
|
|
40
|
+
channels?: string[];
|
|
41
|
+
hasAuth?: boolean;
|
|
42
|
+
hasGuardrails?: boolean;
|
|
43
|
+
hasObservability?: boolean;
|
|
44
|
+
permissions?: Record<string, unknown>;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
46
|
+
onBlocked?: (decision: EnforcementDecision, toolName: string) => void;
|
|
47
|
+
onDecision?: (decision: EnforcementDecision, toolName: string) => void;
|
|
48
|
+
actionMapper?: (toolName: string) => PolicyAction;
|
|
49
|
+
sessionTokenTracker?: () => number;
|
|
50
|
+
/** Map Deno permissions to policy actions */
|
|
51
|
+
permissionMapper?: (perm: DenoPermissionDescriptor) => PolicyAction;
|
|
52
|
+
}
|
|
53
|
+
export interface GovernedDenoAgentResult {
|
|
54
|
+
agent: DenoAgent;
|
|
55
|
+
agentId: string;
|
|
56
|
+
score: number;
|
|
57
|
+
level: number;
|
|
58
|
+
governance: GovernanceInstance;
|
|
59
|
+
enforce: (toolName: string, input?: Record<string, unknown>) => Promise<EnforcementDecision>;
|
|
60
|
+
audit: (toolName: string, outcome: "success" | "failure", detail?: Record<string, unknown>) => Promise<AuditEvent>;
|
|
61
|
+
}
|
|
62
|
+
export interface GovernedDenoToolsResult {
|
|
63
|
+
tools: DenoTool[];
|
|
64
|
+
agentId: string;
|
|
65
|
+
score: number;
|
|
66
|
+
level: number;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=deno-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deno-types.d.ts","sourceRoot":"","sources":["../../src/plugins/deno-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,yBAAyB;AACzB,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAED,iCAAiC;AACjC,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC1E,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,SAAS,GAA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AC;CACrE;AAID,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC7F,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACpH;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deno-types.js","sourceRoot":"","sources":["../../src/plugins/deno-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* governance-sdk Deno AI Plugin
|
|
3
|
+
*
|
|
4
|
+
* Integrates governance enforcement into Deno-native AI agent patterns.
|
|
5
|
+
* Wraps tools with policy checks and integrates with Deno's permission model.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createGovernance, blockTools } from 'governance-sdk';
|
|
10
|
+
* import { governDenoAgent } from 'governance-sdk/plugins/deno';
|
|
11
|
+
*
|
|
12
|
+
* const gov = createGovernance({
|
|
13
|
+
* rules: [blockTools(['file_delete', 'shell_exec'])],
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const { agent } = await governDenoAgent(gov, {
|
|
17
|
+
* name: 'deno-agent',
|
|
18
|
+
* tools: [readFileTool, writeFileTool],
|
|
19
|
+
* permissions: [{ name: 'read', path: '/data' }],
|
|
20
|
+
* }, {
|
|
21
|
+
* agentName: 'deno-agent',
|
|
22
|
+
* owner: 'platform-team',
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { GovernanceInstance } from "../index";
|
|
27
|
+
import type { EnforcementDecision } from "../policy";
|
|
28
|
+
import type { DenoTool, DenoAgent, GovernDenoConfig, GovernedDenoAgentResult, GovernedDenoToolsResult } from "./deno-types.js";
|
|
29
|
+
export type { DenoTool, DenoAgent, DenoPermissionDescriptor, GovernDenoConfig, GovernedDenoAgentResult, GovernedDenoToolsResult, } from "./deno-types.js";
|
|
30
|
+
export declare class GovernanceBlockedError extends Error {
|
|
31
|
+
readonly decision: EnforcementDecision;
|
|
32
|
+
readonly toolName: string;
|
|
33
|
+
constructor(decision: EnforcementDecision, toolName: string);
|
|
34
|
+
}
|
|
35
|
+
export declare function governDenoAgent(governance: GovernanceInstance, agent: DenoAgent, config: GovernDenoConfig): Promise<GovernedDenoAgentResult>;
|
|
36
|
+
export declare function governDenoTools(governance: GovernanceInstance, tools: DenoTool[], config: GovernDenoConfig): Promise<GovernedDenoToolsResult>;
|
|
37
|
+
//# sourceMappingURL=deno.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deno.d.ts","sourceRoot":"","sources":["../../src/plugins/deno.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,WAAW,CAAC;AAEnE,OAAO,KAAK,EACV,QAAQ,EAAE,SAAS,EACnB,gBAAgB,EAAE,uBAAuB,EAAE,uBAAuB,EACnE,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,QAAQ,EAAE,SAAS,EAAE,wBAAwB,EAC7C,gBAAgB,EAAE,uBAAuB,EAAE,uBAAuB,GACnE,MAAM,iBAAiB,CAAC;AAIzB,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,SAAgB,QAAQ,EAAE,mBAAmB,CAAC;IAC9C,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM;CAM5D;AAwED,wBAAsB,eAAe,CACnC,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,uBAAuB,CAAC,CAiBlC;AAID,wBAAsB,eAAe,CACnC,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,QAAQ,EAAE,EACjB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,uBAAuB,CAAC,CAclC"}
|