{"_id":"@agenticcontrolplane/governance-anthropic","_rev":"3-41e9cf5e53e6008f9f684480492f5a2a","name":"@agenticcontrolplane/governance-anthropic","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@agenticcontrolplane/governance-anthropic","version":"0.1.0","keywords":["agentic-control-plane","acp","anthropic","claude","agent-governance","tool-use"],"license":"MIT","_id":"@agenticcontrolplane/governance-anthropic@0.1.0","maintainers":[{"name":"davidcrowe","email":"reducibl@gmail.com"}],"homepage":"https://agenticcontrolplane.com/integrations/anthropic-agent-sdk","bugs":{"url":"https://github.com/davidcrowe/acp-governance-sdks/issues"},"dist":{"shasum":"4ad13a6882c5926f120251bc893e39eb91ce8e01","tarball":"https://registry.npmjs.org/@agenticcontrolplane/governance-anthropic/-/governance-anthropic-0.1.0.tgz","fileCount":22,"integrity":"sha512-vfrdtGupF5vV3bkWmm3wVwBBbt+qx1OrD/To8fdUe4FmrLZ7AD5/lTT2jxicVaguExv9gtHEfnPSbMtqdbPL7w==","signatures":[{"sig":"MEUCIQCepC5isr1Q9aPNLhTy/kWgDAl0CVdApp+xkjTZ3CqbagIgezvLCTPS5t78ZcBIAV8jN6BNsi249P1kwevC/Ro3rPU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35338},"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":{"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-anthropic"},"_npmVersion":"10.8.2","description":"Agentic Control Plane adapter for Anthropic SDK and Claude Agent SDK. Govern every tool_use block from Claude.","directories":{},"_nodeVersion":"20.20.0","dependencies":{"@agenticcontrolplane/governance":"0.1.0"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.4.0","@types/node":"^20.0.0","@anthropic-ai/sdk":"^0.30.0"},"peerDependencies":{"@anthropic-ai/sdk":">=0.30.0"},"peerDependenciesMeta":{"@anthropic-ai/sdk":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/governance-anthropic_0.1.0_1776397070306_0.09345977752773549","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@agenticcontrolplane/governance-anthropic","version":"0.2.0","keywords":["agentic-control-plane","acp","anthropic","claude","agent-governance","tool-use"],"license":"MIT","_id":"@agenticcontrolplane/governance-anthropic@0.2.0","maintainers":[{"name":"davidcrowe","email":"reducibl@gmail.com"}],"homepage":"https://agenticcontrolplane.com/integrations/anthropic-agent-sdk","bugs":{"url":"https://github.com/davidcrowe/acp-governance-sdks/issues"},"dist":{"shasum":"771536a92386df5ad6a7a7b80da0d14ba6343e82","tarball":"https://registry.npmjs.org/@agenticcontrolplane/governance-anthropic/-/governance-anthropic-0.2.0.tgz","fileCount":19,"integrity":"sha512-nXz8hALFQOAZijclUWaT8Df7qtTrttseXUNLWYorQLRW+YDH2RJwU8/dPIYnNMoR7lcX5an9HY2O5fScdImcDQ==","signatures":[{"sig":"MEYCIQDAgm6hNCV7ZhwGhRrKaoy5V0SiRnQKwAgf6uZsfkOEpgIhAM3x9rX4mXWIjpPSiVZXg1vHlni+tV1d+bB3JqPvh1j7","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28566},"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-anthropic"},"_npmVersion":"10.9.8","description":"Agentic Control Plane adapter for Anthropic's Messages API and Claude Agent SDK. One call wraps your tool handlers with governance.","directories":{},"_nodeVersion":"22.23.2","dependencies":{"@agenticcontrolplane/governance":"0.2.0"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.4.0","@types/node":"^20.0.0","@anthropic-ai/sdk":"^0.30.0"},"peerDependencies":{"@anthropic-ai/sdk":">=0.30.0"},"peerDependenciesMeta":{"@anthropic-ai/sdk":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/governance-anthropic_0.2.0_1787167373849_0.5234079286463633","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"_id":"@agenticcontrolplane/governance-anthropic@0.2.1","bugs":{"url":"https://github.com/davidcrowe/acp-governance-sdks/issues"},"dist":{"shasum":"a26b968f36a0645b04a4bbc2683176304b84573f","tarball":"https://registry.npmjs.org/@agenticcontrolplane/governance-anthropic/-/governance-anthropic-0.2.1.tgz","fileCount":7,"integrity":"sha512-1gVYS+7blDbRuzQMShfV60xK5dXbKrLuh9kRB77U+d0XmM1c7lzth7T9iym8BO4ANRnavHrVjr5OTXT05tCuEw==","signatures":[{"sig":"MEUCIARsbmuTk0t4rmd4AewIXenWizAyTo9KF1VCjA6cD6K0AiEA7hqppPHR3NxUejpsamplVMiyLWubXjL9HaDRGF6uAos=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH+nyxTFvAPRsepoqc4IfIi5n75VW82cSrwhmkMMlQfMAiEAz+HSF7UkvqQPACTy5IorlfOi73/nsH/IMNxtLLuJBfA="}],"unpackedSize":11748},"main":"./dist/index.js","name":"@agenticcontrolplane/governance-anthropic","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":"e6b09b5ce035fe3d51bec0eaff60cc824c80cfb0","license":"MIT","scripts":{"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/integrations/anthropic-agent-sdk","keywords":["agentic-control-plane","acp","anthropic","claude","agent-governance","tool-use"],"repository":{"url":"git+https://github.com/davidcrowe/acp-governance-sdks.git","type":"git","directory":"packages/governance-anthropic"},"_npmVersion":"10.9.8","description":"Agentic Control Plane adapter for Anthropic's Messages API and Claude Agent SDK. One call wraps your tool handlers with governance.","directories":{},"maintainers":[{"name":"davidcrowe","email":"reducibl@gmail.com"}],"_nodeVersion":"22.23.2","dependencies":{"@agenticcontrolplane/governance":"^0.2.1"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.4.0","@types/node":"^20.0.0","@anthropic-ai/sdk":"^0.30.0"},"peerDependencies":{"@anthropic-ai/sdk":">=0.30.0"},"peerDependenciesMeta":{"@anthropic-ai/sdk":{"optional":true}},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/governance-anthropic_0.2.1_1789606778018_0.4459062901950501"}}},"time":{"created":"2026-04-17T03:37:50.207Z","modified":"2026-09-17T00:59:38.344Z","0.1.0":"2026-04-17T03:37:50.448Z","0.2.0":"2026-08-19T19:22:54.008Z","0.2.1":"2026-09-17T00:59:38.174Z"},"bugs":{"url":"https://github.com/davidcrowe/acp-governance-sdks/issues"},"license":"MIT","homepage":"https://agenticcontrolplane.com/integrations/anthropic-agent-sdk","keywords":["agentic-control-plane","acp","anthropic","claude","agent-governance","tool-use"],"repository":{"url":"git+https://github.com/davidcrowe/acp-governance-sdks.git","type":"git","directory":"packages/governance-anthropic"},"description":"Agentic Control Plane adapter for Anthropic's Messages API and Claude Agent SDK. One call wraps your tool handlers with governance.","maintainers":[{"name":"davidcrowe","email":"reducibl@gmail.com"}],"readme":"# @agenticcontrolplane/governance-anthropic\n\n[Agentic Control Plane](https://agenticcontrolplane.com) adapter for the Anthropic Messages API and Claude Agent SDK. One call wraps your tool handlers with ACP governance. You keep full control of the tool-use loop.\n\nSame governance model as Claude Code: before any tool runs, ACP is consulted via `/govern/tool-use`; after it runs, the output is sent to `/govern/tool-output` for audit and PII scan.\n\n## Install\n\n```bash\nnpm install @agenticcontrolplane/governance-anthropic @anthropic-ai/sdk\n```\n\n## Usage\n\n```ts\nimport Anthropic from \"@anthropic-ai/sdk\";\nimport express from \"express\";\nimport { governHandlers, withContext } from \"@agenticcontrolplane/governance-anthropic\";\n\nconst anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });\nconst app = express();\napp.use(express.json());\n\n// Your tools. Plain async handlers — your code, your credentials.\nconst baseHandlers = {\n  web_search: async ({ query }: { query: string }) => doSearch(query),\n  send_email: async ({ to, subject, body }: { to: string; subject: string; body: string }) => sendMail(to, subject, body),\n};\n\n// Wrap once. Every dispatch through `handlers` is now ACP-governed.\nconst handlers = governHandlers(baseHandlers);\n\nconst tools: Anthropic.Tool[] = [\n  { name: \"web_search\", description: \"Search the web\", input_schema: { type: \"object\", properties: { query: { type: \"string\" } }, required: [\"query\"] } },\n  { name: \"send_email\", description: \"Send email\",     input_schema: { type: \"object\", properties: { to: { type: \"string\" }, subject: { type: \"string\" }, body: { type: \"string\" } }, required: [\"to\", \"subject\", \"body\"] } },\n];\n\napp.post(\"/run\", async (req, res) => {\n  const token = req.header(\"authorization\")!.slice(\"Bearer \".length);\n  await withContext({ userToken: token }, async () => {\n    const messages: Anthropic.MessageParam[] = [{ role: \"user\", content: req.body.prompt }];\n    for (let i = 0; i < 10; i++) {\n      const msg = await anthropic.messages.create({ model: \"claude-sonnet-4-6\", max_tokens: 1024, tools, messages });\n      messages.push({ role: \"assistant\", content: msg.content });\n      if (msg.stop_reason !== \"tool_use\") {\n        const text = msg.content.filter((b): b is Anthropic.TextBlock => b.type === \"text\").map(b => b.text).join(\"\\n\");\n        return res.json({ result: text });\n      }\n      const toolResults: Anthropic.ToolResultBlockParam[] = [];\n      for (const block of msg.content) {\n        if (block.type !== \"tool_use\") continue;\n        const output = await handlers[block.name](block.input);  // governed\n        toolResults.push({ type: \"tool_result\", tool_use_id: block.id, content: typeof output === \"string\" ? output : JSON.stringify(output) });\n      }\n      messages.push({ role: \"user\", content: toolResults });\n    }\n    res.status(500).json({ error: \"max iterations\" });\n  });\n});\n```\n\n## What `governHandlers` does\n\nTakes `Record<string, AsyncHandler>`. Returns a handler map of the same shape where each function:\n\n1. POSTs to ACP `/govern/tool-use` with the tool name + input + user JWT.\n2. If ACP denies, returns `\"tool_error: <reason>\"` (Claude sees it and adapts).\n3. If ACP allows, runs your handler.\n4. POSTs to `/govern/tool-output` for audit + post-output PII scan.\n5. If ACP redacts, returns the redacted version; if ACP blocks, returns `\"tool_error\"`.\n\n## API\n\n```ts\ngovernHandlers(handlers: Record<string, AsyncHandler>): Record<string, AsyncHandler>\ngoverned(toolName: string, handler: AsyncHandler): AsyncHandler         // from core\nwithContext({ userToken, sessionId? }, fn): Promise<T>                   // from core\n```\n\n## Fail-open\n\nNetwork errors, timeouts (5s), non-2xx responses → tool proceeds with reason `\"fail-open\"`. Matches Claude Code hook behavior. Governance is never a single point of failure for the agent.\n\n## Related\n\n- [`@agenticcontrolplane/governance`](https://www.npmjs.com/package/@agenticcontrolplane/governance) — core SDK (uses this underneath)\n- [Anthropic Agent SDK integration guide](https://agenticcontrolplane.com/integrations/anthropic-agent-sdk)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}