{"_id":"@authensor/claude-agent-sdk","_rev":"2-f211d9a59611a06feba198a116aa9b9a","name":"@authensor/claude-agent-sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"@authensor/claude-agent-sdk","version":"0.0.1","keywords":["authensor","claude","claude-agent-sdk","anthropic","guardrail","ai-safety","agent-safety","agentic-ai","action-authorization","tool-governance","policy-enforcement","claude-guardrail","claude-safety"],"license":"MIT","_id":"@authensor/claude-agent-sdk@0.0.1","maintainers":[{"name":"jkearn","email":"john@authensor.com"}],"homepage":"https://github.com/authensor/authensor","bugs":{"url":"https://github.com/authensor/authensor/issues"},"dist":{"shasum":"f2f2a7a6a49decff5dc5b2b49162089d6f4707c5","tarball":"https://registry.npmjs.org/@authensor/claude-agent-sdk/-/claude-agent-sdk-0.0.1.tgz","fileCount":6,"integrity":"sha512-Dn/EArwsGAGqkDoFau4lWCGX4EW+YFCiyg3kE1llqzcSm+Sl7JDis9SUhF9e0qN4TOsKljKHVb7XdDdE2sfYmg==","signatures":[{"sig":"MEUCIQCSUrqt1KWeqLi0vHlDxxHuzRLANLJ9ZFd6SL710abJiQIgBjcNKpr6YEOViwn6mJ4j+lt7vUcynSDvcKj9vPR9Twg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20463},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"814d74dd7e0ad287ca74bfdd1730ec5aa768165b","scripts":{"dev":"tsc --watch","test":"vitest run --passWithNoTests","build":"tsc","clean":"rm -rf dist","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"jkearn","email":"john@authensor.com"},"repository":{"url":"git+https://github.com/authensor/authensor.git","type":"git","directory":"adapters/claude-agent-sdk"},"_npmVersion":"10.8.2","description":"Authensor guardrail adapter for Claude Agent SDK","directories":{},"_nodeVersion":"20.20.0","dependencies":{"@authensor/sdk":"workspace:*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.1.0","typescript":"^5.3.0","@types/node":"^20.10.0"},"peerDependencies":{"@anthropic-ai/sdk":">=0.30.0"},"peerDependenciesMeta":{"@anthropic-ai/sdk":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/claude-agent-sdk_0.0.1_1773535390022_0.4811576513032021","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@authensor/claude-agent-sdk","version":"0.1.0","description":"Authensor guardrail adapter for Claude Agent SDK","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"dependencies":{"@authensor/sdk":"0.1.0"},"peerDependencies":{"@anthropic-ai/sdk":">=0.30.0"},"peerDependenciesMeta":{"@anthropic-ai/sdk":{"optional":false}},"devDependencies":{"@types/node":"^20.10.0","typescript":"^5.3.0","vitest":"^1.1.0"},"keywords":["authensor","claude","claude-agent-sdk","anthropic","guardrail","ai-safety","agent-safety","agentic-ai","action-authorization","tool-governance","policy-enforcement","claude-guardrail","claude-safety"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/authensor/authensor.git","directory":"adapters/claude-agent-sdk"},"homepage":"https://github.com/authensor/authensor","publishConfig":{"access":"public"},"scripts":{"build":"tsc","dev":"tsc --watch","test":"vitest run --passWithNoTests","test:watch":"vitest","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@authensor/claude-agent-sdk@0.1.0","bugs":{"url":"https://github.com/authensor/authensor/issues"},"_integrity":"sha512-VStLHVu/eq3NztiTqZoLjQuznu1Iti0P5MT6/U8rnsz/vhtADd3RbqNQZ1+0LpbH/tsWLIui0g54SBFPoXnrYA==","_resolved":"/private/var/folders/_h/xdjfwx_n3qxc_plpqltl399m0000gn/T/5b857601aed1c4dcc26d779dc1c820e7/authensor-claude-agent-sdk-0.1.0.tgz","_from":"file:authensor-claude-agent-sdk-0.1.0.tgz","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-VStLHVu/eq3NztiTqZoLjQuznu1Iti0P5MT6/U8rnsz/vhtADd3RbqNQZ1+0LpbH/tsWLIui0g54SBFPoXnrYA==","shasum":"38d56acd8bd7ed1706fa5de71bbbd01dc60ff05e","tarball":"https://registry.npmjs.org/@authensor/claude-agent-sdk/-/claude-agent-sdk-0.1.0.tgz","fileCount":7,"unpackedSize":21525,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDutnnYJ+LMOFN5K2trOB3EVE1OOITjS8KgpHsaLUM8YAIhAJDbiacwaOuBhDOHy0WhIAHigQ3jWYPW4sF+cHTPTLs4"}]},"_npmUser":{"name":"jkearn","email":"john@authensor.com"},"directories":{},"maintainers":[{"name":"jkearn","email":"john@authensor.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/claude-agent-sdk_0.1.0_1781250059322_0.408372955793894"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-15T00:43:09.931Z","modified":"2026-06-12T07:40:59.586Z","0.0.1":"2026-03-15T00:43:10.178Z","0.1.0":"2026-06-12T07:40:59.452Z"},"bugs":{"url":"https://github.com/authensor/authensor/issues"},"license":"MIT","homepage":"https://github.com/authensor/authensor","keywords":["authensor","claude","claude-agent-sdk","anthropic","guardrail","ai-safety","agent-safety","agentic-ai","action-authorization","tool-governance","policy-enforcement","claude-guardrail","claude-safety"],"repository":{"type":"git","url":"git+https://github.com/authensor/authensor.git","directory":"adapters/claude-agent-sdk"},"description":"Authensor guardrail adapter for Claude Agent SDK","maintainers":[{"name":"jkearn","email":"john@authensor.com"}],"readme":"# @authensor/claude-agent-sdk\n\nAuthensor guardrail adapter for the [Claude Agent SDK](https://github.com/anthropics/anthropic-sdk-python). Evaluates every tool call against Authensor policies before execution.\n\n## Installation\n\n```bash\nnpm install @authensor/claude-agent-sdk @anthropic-ai/sdk\n```\n\n## Quick Start\n\n```typescript\nimport Anthropic from '@anthropic-ai/sdk';\nimport { AuthensorClaudeGuard } from '@authensor/claude-agent-sdk';\n\nconst client = new Anthropic();\nconst guard = new AuthensorClaudeGuard({\n  controlPlaneUrl: 'http://localhost:3000',\n  apiKey: process.env.AUTHENSOR_API_KEY,\n});\n\n// Define your tools\nconst tools = [\n  {\n    name: 'send_email',\n    description: 'Send an email',\n    input_schema: {\n      type: 'object',\n      properties: {\n        to: { type: 'string' },\n        subject: { type: 'string' },\n        body: { type: 'string' },\n      },\n      required: ['to', 'subject', 'body'],\n    },\n  },\n];\n\n// Handle tool calls with Authensor evaluation\nasync function handleToolCall(name: string, input: Record<string, unknown>) {\n  // Evaluate before executing — throws if denied\n  await guard.guard(name, input);\n\n  // If we get here, the action is allowed\n  switch (name) {\n    case 'send_email':\n      return await sendEmail(input);\n    default:\n      throw new Error(`Unknown tool: ${name}`);\n  }\n}\n```\n\n## Wrapping Tool Handlers\n\nFor a cleaner pattern, wrap your handlers directly:\n\n```typescript\nimport { AuthensorClaudeGuard } from '@authensor/claude-agent-sdk';\n\nconst guard = new AuthensorClaudeGuard('http://localhost:3000');\n\n// Wrap individual handlers\nconst safeSendEmail = guard.wrapHandler('send_email', async (input) => {\n  return await emailService.send(input);\n});\n\n// Or wrap tool/handler pairs\nconst { tool, handler } = guard.wrapTool(\n  { name: 'send_email', description: 'Send an email' },\n  async (input) => emailService.send(input),\n);\n\n// Or wrap all tools at once\nconst safeTools = guard.wrapTools([\n  { tool: sendEmailTool, handler: sendEmailHandler },\n  { tool: readFileTool, handler: readFileHandler },\n]);\n```\n\n## Approval Flow\n\nHandle `require_approval` decisions with a callback:\n\n```typescript\nconst guard = new AuthensorClaudeGuard({\n  controlPlaneUrl: 'http://localhost:3000',\n  onApprovalRequired: async (toolName, args, reason) => {\n    console.log(`Tool \"${toolName}\" requires approval: ${reason}`);\n    // Implement your approval logic (Slack notification, human-in-the-loop, etc.)\n    const approved = await askHumanForApproval(toolName, args);\n    return approved;\n  },\n});\n```\n\n## Manual Evaluation\n\nFor full control over the evaluation result:\n\n```typescript\nconst result = await guard.evaluate('send_email', { to: 'admin@company.com' });\n\nif (result.allowed) {\n  await sendEmail({ to: 'admin@company.com' });\n} else if (result.requiresApproval) {\n  // Queue for human review\n  await queueForApproval(result.receiptId);\n} else {\n  console.error(`Denied: ${result.reason}`);\n}\n```\n\n## Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `controlPlaneUrl` | `string` | (required) | Authensor control plane URL |\n| `apiKey` | `string` | `AUTHENSOR_API_KEY` env | API key for authentication |\n| `principalId` | `string` | `'claude-agent'` | Identifier for this agent |\n| `principalType` | `string` | `'agent'` | One of: user, agent, service, system |\n| `environment` | `string` | `NODE_ENV` | One of: development, staging, production |\n| `onApprovalRequired` | `function` | `undefined` | Async callback for approval decisions |\n\n## Error Handling\n\n```typescript\nimport { AuthensorDeniedError } from '@authensor/claude-agent-sdk';\n\ntry {\n  await guard.guard('dangerous_action', { target: 'production' });\n} catch (err) {\n  if (err instanceof AuthensorDeniedError) {\n    console.log(err.toolName);   // 'dangerous_action'\n    console.log(err.outcome);    // 'deny'\n    console.log(err.receiptId);  // 'receipt-...'\n  }\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}