{"_id":"@agenticcontrolplane/governance","_rev":"3-a2c835f1e3ee3903fbab16b923252274","name":"@agenticcontrolplane/governance","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@agenticcontrolplane/governance","version":"0.1.0","keywords":["agentic-control-plane","acp","agent-governance","tool-call-audit","delegation-chain"],"license":"MIT","_id":"@agenticcontrolplane/governance@0.1.0","maintainers":[{"name":"davidcrowe","email":"reducibl@gmail.com"}],"homepage":"https://agenticcontrolplane.com","bugs":{"url":"https://github.com/davidcrowe/acp-governance-sdks/issues"},"dist":{"shasum":"a93bbf280a08916f0ae5646bd61dc1c26e73d578","tarball":"https://registry.npmjs.org/@agenticcontrolplane/governance/-/governance-0.1.0.tgz","fileCount":23,"integrity":"sha512-ylkbZNEeDzxeoiSpQOglKb/KvZiikZQMJaC03EJvq54m6Popk0IbufNEqArHrQ86Ev+xTC1AF2QVEMrNtLQoBA==","signatures":[{"sig":"MEYCIQDw+hoJg8BYEe2+uruZqpOlF66p3MUx3FA2YuGvCranswIhAJY1uDHXReu+XIgp1O9W5olZAe9vjAtx47lfYxDwr0H3","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43950},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"42b5b1fe190381cf2fadb71493c9560709621d5a","scripts":{"test":"tsc -p tsconfig.test.json && node --test dist-test/client.test.js","build":"tsc -p tsconfig.json","clean":"rm -rf dist dist-test","typecheck":"tsc --noEmit"},"_npmUser":{"name":"davidcrowe","email":"reducibl@gmail.com"},"repository":{"url":"git+https://github.com/davidcrowe/acp-governance-sdks.git","type":"git","directory":"packages/governance"},"_npmVersion":"10.8.2","description":"Core SDK for the Agentic Control Plane — govern any tool call from any agent framework. Delegation chain, scope intersection, budget propagation, audit log.","directories":{},"_nodeVersion":"20.20.0","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.4.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/governance_0.1.0_1776397029791_0.002539765614106404","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@agenticcontrolplane/governance","version":"0.2.0","keywords":["agentic-control-plane","acp","agent-governance","tool-call-audit","delegation-chain"],"license":"MIT","_id":"@agenticcontrolplane/governance@0.2.0","maintainers":[{"name":"davidcrowe","email":"reducibl@gmail.com"}],"homepage":"https://agenticcontrolplane.com","bugs":{"url":"https://github.com/davidcrowe/acp-governance-sdks/issues"},"dist":{"shasum":"8187151fc4de0e8cd5f47ed5d76cdebc7a0fb1c4","tarball":"https://registry.npmjs.org/@agenticcontrolplane/governance/-/governance-0.2.0.tgz","fileCount":40,"integrity":"sha512-lR5d5uxB46iEeCY9hKLxvRwJAM1G8Jo+FmsrtQxfQMWrb0J5wJounOL/iG9QzTTe0xMYvLxcrmUxM6DY1gCZtQ==","signatures":[{"sig":"MEUCIEccTE2ucP4rrAfPRdFwdiFHqCXvNepmWbsk02YsOHwGAiEA07Dnw6J4dcNktOI5YJt5z6+BgLmxxfGiuOjRLPEhKX8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51718},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"dbd32ff89306b66fc327e5a11ce21b9b070cd4d8","scripts":{"build":"tsc -p tsconfig.json","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"davidcrowe","email":"reducibl@gmail.com"},"repository":{"url":"git+https://github.com/davidcrowe/acp-governance-sdks.git","type":"git","directory":"packages/governance"},"_npmVersion":"10.9.8","description":"Thin Node SDK for the Agentic Control Plane governance hook protocol. Wrap any tool call; ACP decides allow/deny/redact.","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.4.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/governance_0.2.0_1787167371965_0.2284852232921104","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"_id":"@agenticcontrolplane/governance@0.2.1","bugs":{"url":"https://github.com/davidcrowe/acp-governance-sdks/issues"},"dist":{"shasum":"fd910b816d23d556a4c9d7ebf4258f321bc511dd","tarball":"https://registry.npmjs.org/@agenticcontrolplane/governance/-/governance-0.2.1.tgz","fileCount":37,"integrity":"sha512-o69gwChABaS9e8pXvTTPlPJU8LrKQH3OWHUkUWUmENXvHVK8AgHG92fXX3xykArOoZZRwHCHgWZLI0DqLa7giA==","signatures":[{"sig":"MEUCIQDSfZO+qQN4HsaYJGPI/ngyG/IRtef2IMxwckEDBlIjDQIgfQV+roumadjkRRLYM+g2oq5yrEDbHelwY39saAW3c94=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCOVZPlxaGJ4vpnSvV3/w88iIb5sIszmbW9yVov8k1NwwIhALlgUeyH9/dUgI8PyLx6EkggCaIXjgLgFDnl+vscTEWn"}],"unpackedSize":69117},"main":"./dist/index.js","name":"@agenticcontrolplane/governance","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"618c42cd399f38a06e99aecbf2f292b753a9bfd8","license":"MIT","scripts":{"test":"tsx --test src/*.test.ts","build":"tsc -p tsconfig.json","clean":"rm -rf dist","prepack":"npm run clean && npm run build","typecheck":"tsc --noEmit"},"version":"0.2.1","_npmUser":{"name":"davidcrowe","email":"reducibl@gmail.com"},"homepage":"https://agenticcontrolplane.com","keywords":["agentic-control-plane","acp","agent-governance","tool-call-audit","delegation-chain"],"repository":{"url":"git+https://github.com/davidcrowe/acp-governance-sdks.git","type":"git","directory":"packages/governance"},"_npmVersion":"10.9.8","description":"Thin Node SDK for the Agentic Control Plane governance hook protocol. Wrap any tool call; ACP decides allow/deny/redact.","directories":{},"maintainers":[{"name":"davidcrowe","email":"reducibl@gmail.com"}],"_nodeVersion":"22.23.2","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.21.0","typescript":"^5.4.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/governance_0.2.1_1789605936373_0.4137689936403306"}}},"time":{"created":"2026-04-17T03:37:09.678Z","modified":"2026-09-17T00:45:36.642Z","0.1.0":"2026-04-17T03:37:09.943Z","0.2.0":"2026-08-19T19:22:52.127Z","0.2.1":"2026-09-17T00:45:36.481Z"},"bugs":{"url":"https://github.com/davidcrowe/acp-governance-sdks/issues"},"license":"MIT","homepage":"https://agenticcontrolplane.com","keywords":["agentic-control-plane","acp","agent-governance","tool-call-audit","delegation-chain"],"repository":{"url":"git+https://github.com/davidcrowe/acp-governance-sdks.git","type":"git","directory":"packages/governance"},"description":"Thin Node SDK for the Agentic Control Plane governance hook protocol. Wrap any tool call; ACP decides allow/deny/redact.","maintainers":[{"name":"davidcrowe","email":"reducibl@gmail.com"}],"readme":"# @agenticcontrolplane/governance\n\nThin Node SDK for the [Agentic Control Plane](https://agenticcontrolplane.com) governance hook protocol.\n\nWraps the two endpoints ACP exposes:\n- `POST /govern/tool-use` — pre-tool check (allow / deny / ask)\n- `POST /govern/tool-output` — post-tool audit + PII scan\n\nSame protocol Claude Code uses. Works with any Node agent runtime.\n\n## Install\n\n```bash\nnpm install @agenticcontrolplane/governance\n```\n\n## Usage\n\n```ts\nimport { withContext, governed } from \"@agenticcontrolplane/governance\";\n\n// Wrap your tool handlers once.\nconst search = governed(\"web_search\", async ({ query }: { query: string }) => {\n  return doSearch(query);  // your code, your credentials\n});\n\n// In each request handler, bind the end user's JWT to the async context.\napp.post(\"/run\", async (req, res) => {\n  const token = req.header(\"authorization\")!.slice(\"Bearer \".length);\n  await withContext({ userToken: token }, async () => {\n    const result = await search({ query: req.body.q });\n    // result is the tool's output, or \"tool_error: <reason>\" on deny.\n    res.json({ result });\n  });\n});\n```\n\n## What happens per call\n\n1. `preToolUse` POSTs to `/govern/tool-use` with `{ tool_name, tool_input, session_id }` + `Authorization: Bearer <user-jwt>`.\n2. Gateway evaluates policy, rate limits, scope, PII → returns `{ decision, reason }`.\n3. On `deny`, the wrapped handler short-circuits with `\"tool_error: <reason>\"` (model can see and adapt).\n4. On `allow`, your handler runs. Result is sent to `/govern/tool-output` for audit.\n5. If gateway returns `action: \"redact\"`, the redacted output is returned to the caller.\n\n## Fail-open\n\nNetwork errors, timeouts (5s default), or a gateway answer with no decision → the tool proceeds with reason `\"fail-open (<cause>): <detail>\"`, where the cause is one of `not-configured` (no `withContext()` in scope), `unreachable`, or `gateway-error`. Governance is never a single point of failure for the agent — and never silent about it: the first ungoverned call per cause per process is announced on `console.warn`, and every ungoverned call appends a line to `~/.acp/lapse.log` (`ACP_LAPSE_LOG=<path>` overrides, `ACP_LAPSE_LOG=off` disables) — the same ledger the Claude Code hook writes. A 4xx that carries a decision (a 429 rate-limit deny, say) is honored as the verdict, not treated as an outage.\n\n## Both planes in one call\n\n`governed()` covers what your agent *does*. The ACP proxy covers what it\n*spends*. `init()` wires both — call it before you construct a model client,\nsince the SDKs read their config from the environment at construction time:\n\n```ts\nimport { init } from \"@agenticcontrolplane/governance\";\nimport Anthropic from \"@anthropic-ai/sdk\";\n\ninit();                            // governance + proxy\nconst client = new Anthropic();    // now priced and metered by ACP\n```\n\nConstructing clients explicitly instead? Skip `init()` and pass the options:\n\n```ts\nimport { modelClientOptions } from \"@agenticcontrolplane/governance\";\n\nconst client = new Anthropic(modelClientOptions(\"anthropic\"));\n```\n\nSet `ACP_API_KEY=gsk_...` from [the console](https://cloud.agenticcontrolplane.com).\n\n**Routing is all-or-nothing per provider.** `init()` either sets both the base\nURL and the key, or leaves that provider completely alone and warns — a\nhalf-applied provider (ACP's URL against your real vendor key) is just a 401.\nSo if `OPENAI_BASE_URL` already points at your own gateway, ACP won't silently\nreroute you; it tells you those calls aren't being priced.\n\nThree API shapes, each on its own mount — `\"anthropic\"`, `\"openai\"` (chat\ncompletions), and `\"openai-responses\"`. The last two are **not**\ninterchangeable: `/v1` serves chat completions, `/openai/v1` serves responses.\n\n## Framework adapters\n\nThis package is the core. For framework-native ergonomics see:\n\n- [`@agenticcontrolplane/governance-anthropic`](https://www.npmjs.com/package/@agenticcontrolplane/governance-anthropic) — Anthropic Agent SDK + Messages API\n- [`acp-crewai`](https://pypi.org/project/acp-crewai) (Python) — CrewAI\n- [`acp-langchain`](https://pypi.org/project/acp-langchain) (Python) — LangChain / LangGraph\n\n## API\n\n```ts\nconfigure(partial: Partial<Config>): void\ngetConfig(): Config\n\nwithContext(ctx, fn): Promise<T>\ngetContext(): GovernanceContext | undefined\n\npreToolUse(toolName, toolInput?): Promise<{ allowed, reason, decision }>\npostToolOutput(toolName, toolInput, toolOutput): Promise<PostToolOutputResponse | null>\n\ngoverned<I, O>(toolName, handler, opts?): AsyncHandler<I, O | string>\n\n// proxy plane — price and meter model calls\ninit(options?: InitOptions): Record<string, string>   // both planes\nmodelBaseUrl(shape?: ModelShape): string\nmodelClientOptions(shape?: ModelShape): { baseURL, apiKey }\napiKey(): string                                      // reads ACP_API_KEY\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}