{"_id":"@aegis-sdk/openai","_rev":"3-97349021d8053a61c75e4e6c65aaf0b7","name":"@aegis-sdk/openai","dist-tags":{"latest":"0.5.0"},"versions":{"0.2.0":{"name":"@aegis-sdk/openai","version":"0.2.0","license":"MIT","_id":"@aegis-sdk/openai@0.2.0","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"dist":{"shasum":"82b0ab484d73382f45fc53ac6366938a33c2f8e6","tarball":"https://registry.npmjs.org/@aegis-sdk/openai/-/openai-0.2.0.tgz","fileCount":8,"integrity":"sha512-UGMrjn5hhP6HmF9ofhsR9ookzawUqa0dVm+C6FBCPnbQYptaLPlyDHWLdJEIZOq5Ebnrteb2X8f5Cr1qul/riA==","signatures":[{"sig":"MEQCIBjG6BB97K6WlAnzE38adDNpl9iIhBgtqJv6fVFSroIeAiAUbdsbAPKhYGFDkHTZVInpiCQikaJCFrgfi+8Sx8PSCA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":107636},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-openai-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/defa6a03a6d905c3c5cf7a2d92604232/aegis-sdk-openai-0.2.0.tgz","_integrity":"sha512-UGMrjn5hhP6HmF9ofhsR9ookzawUqa0dVm+C6FBCPnbQYptaLPlyDHWLdJEIZOq5Ebnrteb2X8f5Cr1qul/riA==","_npmVersion":"10.9.4","description":"OpenAI SDK adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.2.0"},"_hasShrinkwrap":false,"peerDependencies":{"openai":">=4.0.0","@aegis-sdk/core":"0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/openai_0.2.0_1771372100338_0.5496217008343058","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@aegis-sdk/openai","version":"0.3.0","license":"MIT","_id":"@aegis-sdk/openai@0.3.0","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"dist":{"shasum":"084574f07280a73a500be1dc8e0296add7dad43b","tarball":"https://registry.npmjs.org/@aegis-sdk/openai/-/openai-0.3.0.tgz","fileCount":8,"integrity":"sha512-oJYxiVQ/iHXnTIYm4aPCmhwWvFzvEH0WEWkaDSne/ySxTAbACpLGXK/VmOxLFah0pNc7zSkoyp2J+E/XP9LOLA==","signatures":[{"sig":"MEQCIG/sI+zYYdXY7/4AQHGXHhxG9nMyBHNzYpG21C3SkDi7AiBntpvd/lIiVlkmSc8CaJnHEu6koUx7LAXYK6r93fx+4Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":107636},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-openai-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/980cef0c1521f778dd6882b92bb78b1f/aegis-sdk-openai-0.3.0.tgz","_integrity":"sha512-oJYxiVQ/iHXnTIYm4aPCmhwWvFzvEH0WEWkaDSne/ySxTAbACpLGXK/VmOxLFah0pNc7zSkoyp2J+E/XP9LOLA==","_npmVersion":"10.9.4","description":"OpenAI SDK adapter for Aegis prompt injection defense","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@aegis-sdk/core":"0.3.0"},"_hasShrinkwrap":false,"peerDependencies":{"openai":">=4.0.0","@aegis-sdk/core":"0.3.0"},"_npmOperationalInternal":{"tmp":"tmp/openai_0.3.0_1771394277680_0.12138970518902181","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@aegis-sdk/openai","version":"0.5.0","description":"OpenAI 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":{"openai":">=4.0.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/openai@0.5.0","_integrity":"sha512-c8IeidQ8RQsxFmxsm7avlFiO92OnaHouC0B3cPvPUPc/o5WgGCMivoZ5wQ5ibQROyOhxSq9NHagZe5jVMcHdZg==","_resolved":"/tmp/7e6b47dae41f2bba0c6035805040a0df/aegis-sdk-openai-0.5.0.tgz","_from":"file:aegis-sdk-openai-0.5.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-c8IeidQ8RQsxFmxsm7avlFiO92OnaHouC0B3cPvPUPc/o5WgGCMivoZ5wQ5ibQROyOhxSq9NHagZe5jVMcHdZg==","shasum":"e3687f80e256b48614ca8177e9b6d62f1507a72b","tarball":"https://registry.npmjs.org/@aegis-sdk/openai/-/openai-0.5.0.tgz","fileCount":9,"unpackedSize":110529,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIC8YTt9YCjJrHREMFlmIWgaSL7x2CZSU4vZo2AWgJ8DYAiEAtIPxuNtrFcbVQaMo719BGhApLnSj+smcpDj4afyAT/c="}]},"_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/openai_0.5.0_1771972393462_0.37689469309950363"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-17T23:48:20.272Z","modified":"2026-02-24T22:33:13.708Z","0.2.0":"2026-02-17T23:48:20.474Z","0.3.0":"2026-02-18T05:57:57.815Z","0.5.0":"2026-02-24T22:33:13.599Z"},"license":"MIT","description":"OpenAI SDK adapter for Aegis prompt injection defense","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"readme":"# @aegis-sdk/openai\n\nOpenAI SDK adapter for Aegis prompt injection defense. Scans messages, monitors streams, and validates tool calls in the OpenAI chat completion 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/openai @aegis-sdk/core openai\n```\n\n## Quick Start\n\nWrap the OpenAI client for automatic protection on every call:\n\n```typescript\nimport OpenAI from 'openai';\nimport { Aegis } from '@aegis-sdk/core';\nimport { wrapOpenAIClient } from '@aegis-sdk/openai';\n\nconst aegis = new Aegis({ policy: 'strict' });\nconst client = wrapOpenAIClient(new OpenAI(), aegis);\n\n// Messages are scanned before sending.\n// Streaming responses are monitored in real-time.\n// Tool calls are validated against the policy.\nconst stream = await client.chat.completions.create({\n  model: 'gpt-4o',\n  messages: [{ role: 'user', content: 'Hello!' }],\n  stream: true,\n});\n```\n\nOr scan messages manually:\n\n```typescript\nimport { Aegis } from '@aegis-sdk/core';\nimport { guardMessages } from '@aegis-sdk/openai';\n\nconst aegis = new Aegis({ policy: 'strict' });\n\nconst messages = [\n  { role: 'system' as const, content: 'You are a helpful assistant.' },\n  { role: 'user' as const, content: userInput },\n];\n\n// Throws AegisInputBlocked if injection is detected\nconst safe = await guardMessages(aegis, messages);\n```\n\n## API\n\n### `wrapOpenAIClient(client, aegis, options?)`\n\nProxy the OpenAI client to automatically guard all `chat.completions.create()` calls. Input messages are scanned before sending, streaming responses are monitored, and tool/function calls are validated against the Aegis policy. All other client methods pass through unchanged.\n\n### `guardMessages(aegis, messages, options?)`\n\nScan an array of `OpenAIChatCompletionMessageParam[]` for prompt injection. Extracts text from all message formats (string content, multi-modal content parts, tool/function messages) and runs them through `aegis.guardInput()`. Optionally validates `tool_calls` and `function_call` 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 `delta.content` values from OpenAI streaming chunks 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 `OpenAIGuardOptions`:\n\n- **`scanStrategy`** -- `'last-user'` (default), `'all-user'`, or `'full-history'`\n- **`validateToolCalls`** -- Whether to validate tool/function calls 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"}