{"_id":"@aegis-sdk/google","_rev":"2-9a28879b42057ba77b47cc12360458c1","name":"@aegis-sdk/google","dist-tags":{"latest":"0.5.0"},"versions":{"0.3.0":{"name":"@aegis-sdk/google","version":"0.3.0","license":"MIT","_id":"@aegis-sdk/google@0.3.0","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"dist":{"shasum":"5ede807fd8cd3b0d34fa81b4d3456f9f1994eafb","tarball":"https://registry.npmjs.org/@aegis-sdk/google/-/google-0.3.0.tgz","fileCount":8,"integrity":"sha512-blOBhPcPY4We38a0xRaWqXLGvGoGhTb5WXoGzUCfuPCf0NX4R1A/lVlaERMDn86eA5EDZTDVMr9Gzh0kAaOv4Q==","signatures":[{"sig":"MEYCIQCdspflLMfR2QAeQdKb2kqDifYIKHB209Nr9l8pO8NEEgIhAPSrNZggS+MvUDqNDjd657CjbHM1KHsf7wwDpYn96hOw","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":79336},"main":"./dist/index.cjs","type":"module","_from":"file:aegis-sdk-google-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/8004a482f52d82080c2fbfd33ad0258c/aegis-sdk-google-0.3.0.tgz","_integrity":"sha512-blOBhPcPY4We38a0xRaWqXLGvGoGhTb5WXoGzUCfuPCf0NX4R1A/lVlaERMDn86eA5EDZTDVMr9Gzh0kAaOv4Q==","_npmVersion":"10.9.4","description":"Google Gemini 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","@google/generative-ai":">=0.21.0"},"_npmOperationalInternal":{"tmp":"tmp/google_0.3.0_1771394272772_0.6137186747306211","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@aegis-sdk/google","version":"0.5.0","description":"Google Gemini 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":{"@google/generative-ai":">=0.21.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/google@0.5.0","_integrity":"sha512-pJR3v4WUFb59NAJcYodpJd0a6yDZbm5Im9tg7cJK+EQroScssMalL0jQjiuFu2hJfhOT4oYVbipHMB+fDdgOEg==","_resolved":"/tmp/fa78422a2d0e46d4f6c4ba54e4823408/aegis-sdk-google-0.5.0.tgz","_from":"file:aegis-sdk-google-0.5.0.tgz","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-pJR3v4WUFb59NAJcYodpJd0a6yDZbm5Im9tg7cJK+EQroScssMalL0jQjiuFu2hJfhOT4oYVbipHMB+fDdgOEg==","shasum":"1f5e2378e6c5caeed80fd1a8c2fc313d066cf533","tarball":"https://registry.npmjs.org/@aegis-sdk/google/-/google-0.5.0.tgz","fileCount":9,"unpackedSize":82173,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDZBz1OmCPqcpRZG+MSvv9g/6zjgylAT9BqNzTIPBGwwwIhAMincYqokt7p94SIYoZuFIumbmpqGBewUNjamwJX0ocB"}]},"_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/google_0.5.0_1771972389719_0.3089166460775461"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-18T05:57:52.689Z","modified":"2026-02-24T22:33:10.115Z","0.3.0":"2026-02-18T05:57:52.913Z","0.5.0":"2026-02-24T22:33:09.892Z"},"license":"MIT","description":"Google Gemini SDK adapter for Aegis prompt injection defense","maintainers":[{"name":"msjoshlopez","email":"josh@memberstack.com"}],"readme":"# @aegis-sdk/google\n\nGoogle Gemini SDK adapter for Aegis prompt injection defense. Scans messages in Gemini's `parts[]` content format and monitors streaming responses.\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/google @aegis-sdk/core @google/generative-ai\n```\n\n## Quick Start\n\nWrap the Gemini model client for automatic protection:\n\n```typescript\nimport { GoogleGenerativeAI } from '@google/generative-ai';\nimport { Aegis } from '@aegis-sdk/core';\nimport { wrapGoogleClient } from '@aegis-sdk/google';\n\nconst aegis = new Aegis({ policy: 'strict' });\nconst genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY!);\nconst model = genAI.getGenerativeModel({ model: 'gemini-pro' });\nconst wrapped = wrapGoogleClient(model, aegis);\n\n// Contents are scanned before sending.\n// Streaming responses are monitored in real-time.\nconst result = await wrapped.generateContent({\n  contents: [{ role: 'user', parts: [{ text: 'Hello!' }] }],\n});\n```\n\nOr scan messages manually:\n\n```typescript\nimport { Aegis } from '@aegis-sdk/core';\nimport { guardMessages } from '@aegis-sdk/google';\n\nconst aegis = new Aegis({ policy: 'strict' });\n\nconst contents = [\n  { role: 'user' as const, parts: [{ text: userInput }] },\n];\n\nconst systemInstruction = {\n  parts: [{ text: 'You are a helpful assistant.' }],\n};\n\n// Throws AegisInputBlocked if injection is detected\nconst safe = await guardMessages(aegis, contents, systemInstruction);\n```\n\n## API\n\n### `wrapGoogleClient(client, aegis, options?)`\n\nProxy a Gemini model instance (from `getGenerativeModel()`) to automatically guard `generateContent()` and `generateContentStream()`. Input contents are scanned before sending and streaming responses are monitored. All other methods pass through unchanged.\n\n### `guardMessages(aegis, contents, systemInstruction?, options?)`\n\nScan an array of `GeminiContent[]` for prompt injection. Extracts text from Gemini's `parts[]` format (text parts, function responses) and runs them through `aegis.guardInput()`. An optional `systemInstruction` is included as a system-role message during scanning. Returns the original contents if safe, throws `AegisInputBlocked` if blocked.\n\n### `createStreamTransform(aegis)`\n\nCreate a `TransformStream<string, string>` for monitoring extracted text content from Gemini streaming chunks.\n\n### `getAuditLog(aegis)`\n\nConvenience accessor for the Aegis audit log.\n\n## Gemini message format\n\nGemini uses `role: 'model'` instead of `'assistant'`. The adapter handles this mapping automatically. Gemini's `systemInstruction` is provided separately from `contents` and is scanned as a system-role message.\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"}