{"_id":"@aegis-sdk/anthropic","_rev":"3-2c9135e5a0b0380f63f90ae3a18e2465","name":"@aegis-sdk/anthropic","dist-tags":{"latest":"0.5.0"},"versions":{"0.2.0":{"name":"@aegis-sdk/anthropic","version":"0.2.0","license":"MIT","_id":"@aegis-sdk/anthropic@0.2.0","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"dist":{"shasum":"dafbbd6f800620e80a2744c119d823220800bc97","tarball":"https://registry.npmjs.org/@aegis-sdk/anthropic/-/anthropic-0.2.0.tgz","fileCount":8,"integrity":"sha512-e4Kh2CSdTOgbVhcNxl6izxZry3JcsCAmK/GMHIJtVYMXPPX9ocksi7unAJRm69PyyQPWdDG2d/cwcq6G4WQ3Nw==","signatures":[{"sig":"MEUCIQDcWq8dL+81xqupdOlv4zaNF9dBuc4CXduLY6V2XfWSeAIgSO+ZsuQGl8ivsX9HALtHJMV1TEoflfva9AK3ooHqpKU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":86610},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-anthropic-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"dev":"tsup --watch","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"msjoshlopez","email":"josh@memberstack.com"},"_resolved":"/tmp/1c13caa75354a9fb61f16fe83a747985/aegis-sdk-anthropic-0.2.0.tgz","_integrity":"sha512-e4Kh2CSdTOgbVhcNxl6izxZry3JcsCAmK/GMHIJtVYMXPPX9ocksi7unAJRm69PyyQPWdDG2d/cwcq6G4WQ3Nw==","_npmVersion":"10.9.4","description":"Anthropic Claude SDK adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.2.0"},"_hasShrinkwrap":false,"peerDependencies":{"@aegis-sdk/core":"0.2.0","@anthropic-ai/sdk":">=0.30.0"},"_npmOperationalInternal":{"tmp":"tmp/anthropic_0.2.0_1771372099900_0.16763951058379178","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@aegis-sdk/anthropic","version":"0.3.0","license":"MIT","_id":"@aegis-sdk/anthropic@0.3.0","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"dist":{"shasum":"1cb5b9898d20ccd5cfa8c60466746637bac94e8a","tarball":"https://registry.npmjs.org/@aegis-sdk/anthropic/-/anthropic-0.3.0.tgz","fileCount":8,"integrity":"sha512-YmbeRYprbq19TD43t1hye7JCvrjOuaLKqsMX/ez5ydvY7xur4n9VpFEMyjFI6ehQ/mHd/eXHUvND6zGZHrNXqw==","signatures":[{"sig":"MEUCIQDJE8MK3Se6E/KWwL2wEKi+xkIL8hN3GhvJQF1dfo8hVgIgYtIImoFGniOXNXquZovnc8AwfYIK2aqfNOweyGUq8XA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":86610},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-anthropic-0.3.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"dev":"tsup --watch","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"msjoshlopez","email":"josh@memberstack.com"},"_resolved":"/tmp/60d9fde39d72041d33a5c677fc80e405/aegis-sdk-anthropic-0.3.0.tgz","_integrity":"sha512-YmbeRYprbq19TD43t1hye7JCvrjOuaLKqsMX/ez5ydvY7xur4n9VpFEMyjFI6ehQ/mHd/eXHUvND6zGZHrNXqw==","_npmVersion":"10.9.4","description":"Anthropic Claude SDK adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.3.0"},"_hasShrinkwrap":false,"peerDependencies":{"@aegis-sdk/core":"0.3.0","@anthropic-ai/sdk":">=0.30.0"},"_npmOperationalInternal":{"tmp":"tmp/anthropic_0.3.0_1771394272783_0.6972051380306143","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@aegis-sdk/anthropic","version":"0.5.0","description":"Anthropic Claude SDK adapter for Aegis prompt injection defense","license":"MIT","type":"module","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","peerDependencies":{"@anthropic-ai/sdk":">=0.30.0","@aegis-sdk/core":"0.5.0"},"dependencies":{"@aegis-sdk/core":"0.5.0"},"engines":{"node":">=18.0.0"},"sideEffects":false,"scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@aegis-sdk/anthropic@0.5.0","_integrity":"sha512-yop72NjVaRGY6Vb/jgcREYs3OoxAbN+xq+eBJffMXKAtsnkBq76w7VypWP0QZO7YCGEdGWo5Ih5+5gRtcpwHtQ==","_resolved":"/tmp/df534ff054fe3c7606166ecf2a7833d1/aegis-sdk-anthropic-0.5.0.tgz","_from":"file:aegis-sdk-anthropic-0.5.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-yop72NjVaRGY6Vb/jgcREYs3OoxAbN+xq+eBJffMXKAtsnkBq76w7VypWP0QZO7YCGEdGWo5Ih5+5gRtcpwHtQ==","shasum":"fbad38a8364430543297ec9c303ee6bdc29856a7","tarball":"https://registry.npmjs.org/@aegis-sdk/anthropic/-/anthropic-0.5.0.tgz","fileCount":9,"unpackedSize":89551,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICli0oHr69xOAR73O57fnjnQBut/3JjHn8+qGU4lPaCrAiEArF7nVbtekqH8/f2wqJySy8VHZxOlnB/yT9z1hBS/uV8="}]},"_npmUser":{"name":"msjoshlopez","email":"josh@memberstack.com"},"directories":{},"maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/anthropic_0.5.0_1771972389871_0.27575329584251085"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-17T23:48:19.793Z","modified":"2026-02-24T22:33:10.291Z","0.2.0":"2026-02-17T23:48:20.049Z","0.3.0":"2026-02-18T05:57:52.954Z","0.5.0":"2026-02-24T22:33:10.033Z"},"license":"MIT","description":"Anthropic Claude SDK adapter for Aegis prompt injection defense","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"readme":"# @aegis-sdk/anthropic\n\nAnthropic Claude SDK adapter for Aegis prompt injection defense. Scans messages, monitors streams, and validates tool_use blocks in Anthropic's content block format.\n\nPart of the [Aegis.js](https://github.com/aegis-sdk/Aegis) prompt injection defense toolkit.\n\n## Installation\n\n```bash\nnpm install @aegis-sdk/anthropic @aegis-sdk/core @anthropic-ai/sdk\n```\n\n## Quick Start\n\nWrap the Anthropic client for automatic protection on every call:\n\n```typescript\nimport Anthropic from '@anthropic-ai/sdk';\nimport { Aegis } from '@aegis-sdk/core';\nimport { wrapAnthropicClient } from '@aegis-sdk/anthropic';\n\nconst aegis = new Aegis({ policy: 'strict' });\nconst client = wrapAnthropicClient(new Anthropic(), aegis);\n\n// Messages are scanned before sending.\n// Streaming responses are monitored in real-time.\n// tool_use blocks are validated against the policy.\nconst response = await client.messages.create({\n  model: 'claude-sonnet-4-20250514',\n  max_tokens: 1024,\n  messages: [{ role: 'user', content: 'Hello!' }],\n});\n```\n\nOr scan messages manually:\n\n```typescript\nimport { Aegis } from '@aegis-sdk/core';\nimport { guardMessages } from '@aegis-sdk/anthropic';\n\nconst aegis = new Aegis({ policy: 'strict' });\n\nconst messages = [\n  {\n    role: 'user' as const,\n    content: [\n      { type: 'text' as const, text: userInput },\n    ],\n  },\n];\n\n// Throws AegisInputBlocked if injection is detected\nconst safe = await guardMessages(aegis, messages);\n```\n\n## API\n\n### `wrapAnthropicClient(client, aegis, options?)`\n\nProxy the Anthropic client to automatically guard all `messages.create()` calls. Input messages are scanned before sending, streaming responses are monitored, and `tool_use` content blocks are validated against the Aegis policy. All other client methods pass through unchanged.\n\n### `guardMessages(aegis, messages, options?)`\n\nScan an array of `AnthropicMessageParam[]` for prompt injection. Handles Anthropic's message format -- string content, arrays of content blocks (text, tool_use, tool_result, image), and nested text within tool_result blocks. Optionally validates `tool_use` blocks against the policy (enabled by default). Returns the original messages if safe, throws `AegisInputBlocked` if blocked.\n\n### `createStreamTransform(aegis)`\n\nCreate a `TransformStream<string, string>` for monitoring extracted text deltas. Feed `text_delta` values from Anthropic streaming events through this transform for real-time output scanning.\n\n### `getAuditLog(aegis)`\n\nConvenience accessor for the Aegis audit log.\n\n## Options\n\n`guardMessages` and the client wrapper accept `AnthropicGuardOptions`:\n\n- **`scanStrategy`** -- `'last-user'` (default), `'all-user'`, or `'full-history'`\n- **`validateToolUse`** -- Whether to validate tool_use blocks against the policy (default: `true`)\n\n## Learn More\n\n- [Documentation](https://aegis-sdk.github.io/Aegis/)\n- [GitHub](https://github.com/aegis-sdk/Aegis)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}