{"_id":"@anchor-engine/sdk","_rev":"3-cc2b93d1c2330b9c17dfd30834ea0171","name":"@anchor-engine/sdk","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.0":{"name":"@anchor-engine/sdk","version":"0.1.0","keywords":["anchor","ai","llm","agents","halucination","monitoring","safety"],"author":{"name":"Anchor AI Team"},"license":"MIT","_id":"@anchor-engine/sdk@0.1.0","maintainers":[{"name":"hasin03","email":"rahmanhasin5@gmail.com"}],"dist":{"shasum":"11cb040e976c7525411566b0d99cac42bba4e5ab","tarball":"https://registry.npmjs.org/@anchor-engine/sdk/-/sdk-0.1.0.tgz","fileCount":14,"integrity":"sha512-c7muQVh0x5XctL8/ENf1O3tJHkcCLVpzW6UrtLL3oC1bZb8rlTKhP7yUBSQXUGh6KlZjLO0wnz4OnDCbQwWqFw==","signatures":[{"sig":"MEQCIHN3qQXF6efwOE4frLwi5Gdv6Cx3IKkm9UNYf39ZuJSJAiBW6sssQ9QpPfL+qDuOF4HIHbmZz0dppg7+k+vptdAjaQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18621},"main":"./dist/cjs/index.js","types":"./dist/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"}},"scripts":{"build":"npm run build:esm && npm run build:cjs && npm run build:types","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.types.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"hasin03","email":"rahmanhasin5@gmail.com"},"_npmVersion":"11.2.0","description":"Anchor AI SDK - Intent preservation layer for LLM agents","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^20.0.0","@langchain/core":"^0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1776034690747_0.9578007991874757","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@anchor-engine/sdk","version":"0.1.1","keywords":["anchor","ai","llm","agents","halucination","monitoring","safety"],"author":{"name":"anchor-engine"},"license":"MIT","_id":"@anchor-engine/sdk@0.1.1","maintainers":[{"name":"hasin03","email":"rahmanhasin5@gmail.com"}],"dist":{"shasum":"e68094e351f13fd9f801deabc9a09fbd6137a68e","tarball":"https://registry.npmjs.org/@anchor-engine/sdk/-/sdk-0.1.1.tgz","fileCount":14,"integrity":"sha512-UzyynyGgM6TtgP68XIc2PNgxsm6hEl/DOpXrCSKXlrluT6nPxSHvaJ+ItsvajDurTvQqxP8+7r5HfE80MyF2oQ==","signatures":[{"sig":"MEYCIQD6B9sf2dOX2C0//R+swxt4RkVcke775ZAQC8WGO6Yo/gIhANewKERAo/e/x3obrBjZYkVtnU8/Hoa6Bp7RBkfHuczI","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19054},"main":"./dist/cjs/index.js","types":"./dist/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"}},"gitHead":"20880c52d574477965ba07fd78f41ef393233f51","scripts":{"build":"npm run build:esm && npm run build:cjs && npm run build:types","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.types.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"hasin03","email":"rahmanhasin5@gmail.com"},"_npmVersion":"11.2.0","description":"anchor-engine SDK - Intent preservation layer for LLM agents","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^20.0.0","@langchain/core":"^0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.1_1776316882082_0.7918498624862418","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@anchor-engine/sdk","version":"0.1.4","description":"anchor-engine SDK - Intent preservation layer for LLM agents","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js","types":"./dist/index.d.ts"}},"engines":{"node":">=18"},"scripts":{"build":"npm run build:esm && npm run build:cjs && npm run build:types","build:esm":"tsc -p tsconfig.esm.json","build:cjs":"tsc -p tsconfig.cjs.json","build:types":"tsc -p tsconfig.types.json","prepublishOnly":"npm run build"},"keywords":["anchor","ai","llm","agents","halucination","monitoring","safety"],"author":{"name":"anchor-engine"},"license":"MIT","devDependencies":{"typescript":"^5.0.0","@types/node":"^20.0.0","@langchain/core":"^0.2.0"},"_id":"@anchor-engine/sdk@0.1.4","gitHead":"0503a5d54d22794706d5456816f4f6c0380dd776","_nodeVersion":"22.14.0","_npmVersion":"11.2.0","dist":{"integrity":"sha512-i5czm+FTSMhkD81bO0wNSUjZvfnfMDWWCCMxwCZlcDSX6gfxSqF3jroerDVHDZjPmL98kig4gQD1DEYsJD0T+g==","shasum":"2391a9d00c3017d04360fbbb90dd3c3080b5b8fb","tarball":"https://registry.npmjs.org/@anchor-engine/sdk/-/sdk-0.1.4.tgz","fileCount":17,"unpackedSize":25842,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDOuoJEeaMLyFrqWy4WsEXE1b32oDiHDas/ouacxfGVsQIgZ+RcKVsUC9jlzOGXD4K3Gis+NNOZEF2ZFxmXvhwN8cw="}]},"_npmUser":{"name":"hasin03","email":"rahmanhasin5@gmail.com"},"directories":{},"maintainers":[{"name":"hasin03","email":"rahmanhasin5@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.4_1776318593793_0.3100687592396194"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-12T22:58:10.618Z","modified":"2026-04-16T05:49:54.064Z","0.1.0":"2026-04-12T22:58:10.913Z","0.1.1":"2026-04-16T05:21:22.207Z","0.1.4":"2026-04-16T05:49:53.942Z"},"author":{"name":"anchor-engine"},"license":"MIT","keywords":["anchor","ai","llm","agents","halucination","monitoring","safety"],"description":"anchor-engine SDK - Intent preservation layer for LLM agents","maintainers":[{"name":"hasin03","email":"rahmanhasin5@gmail.com"}],"readme":"# @anchor-engine/sdk\n\n[![npm version](https://img.shields.io/npm/v/@anchor-engine/sdk.svg?style=flat-square)](https://www.npmjs.com/package/@anchor-engine/sdk)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/anchor-engine/anchor-sdk/blob/main/LICENSE)\n\n**Anchor** is an open-source intent preservation layer for LLM agents. It monitors agent actions in real-time, detecting and correcting \"intent drift\" before it leads to hallucinations or out-of-bounds behavior.\n\n> [!IMPORTANT]\n> **Validated Performance (CNN/DailyMail Benchmark)**:\n> - **+9.2% High-Fidelity Lift**: Significantly improves the grounding of agent-generated summaries.\n> - **0% IFEval Regression**: Zero impact on instruction-following capabilities.\n> - **0% Tau2 Regression**: Maintains absolute stability in sequential reasoning.\n>\n> **Get Started**: Sign up at **[anchor-app-one.vercel.app](https://anchor-app-one.vercel.app)** to get your free API key.\n\n---\n\n## Quickstart\n\nAdd Anchor to any AI agent project in just three lines of code.\n\n### 1. Register & Get API Key\n\nSign up at **[anchor-app-one.vercel.app](https://anchor-app-one.vercel.app)** and generate your key from the **Settings** dashboard.\n\n*Note: The SDK is a cloud-first library and will securely communicate with the Anchor Engine via this API key. No local deployment is required.*\n\n### 2. Install\n\n```bash\nnpm install @anchor-engine/sdk\n```\n\n### 2. Guard Your Agent\n\n```typescript\nimport { Anchor } from '@anchor-engine/sdk';\n\n// 1. Initialize with your API key\nconst anchor = new Anchor({ apiKey: process.env.ANCHOR_API_KEY });\n\n// 2. Define an intent contract for the task\nconst contract = await anchor.contract({ \n  task: \"Build the project in /projects/myapp only. Do not touch core library files.\" \n});\n\n// 3. Score agent actions in real-time\nconst result = await anchor.score(agentAction, contract.id);\n\nif (!result.allow) {\n  console.log(`Action blocked: ${result.intervention.message}`);\n}\n```\n\n}\n```\n\n---\n\n## Why Anchor?\n\nCurrent LLM evaluation frameworks (like HHEM or IFEval) are generally applied *post-hoc*, assessing a system's quality long after a session has ended. \n\n**Anchor** brings evaluation into the *execution loop*. We call this **Intent Preservation**. By scoring agent actions in real-time, Anchor actively prevents divergence (drift) from the user's original objective safely and transparently.\n\n---\n\n## Features\n\n- **Real-time Drift Monitoring**: Catch hallucinations the moment they occur.\n- **Auto-Correction (Critique Loop)**: Automatically rewrites drifted actions to stay within contract scope.\n- **Framework Native**: First-class support for LangChain, Claude Code, and more.\n- **Zero Latency Overhead**: Asynchronous monitoring keeps your agents fast.\n\n## Adapters\n\n### LangChain\n```typescript\nimport { LangChainAnchorCallback } from '@anchor-engine/sdk/adapters/langchain';\n\nconst executor = await initializeAgentExecutorWithOptions(tools, model, {\n  callbacks: [new LangChainAnchorCallback({ anchor, contractId: contract.id })],\n});\n```\n\n### Claude Code / Generic Interception\nUse the `watch()` proxy to automatically wrap any agent object:\n```typescript\nconst guardedAgent = anchor.watch(myAgent, contract.id);\n\n// Automatically scores every .act(), .run(), or .execute() call\nawait guardedAgent.act({ type: 'file_write', target: '/src/main.ts', ... });\n```\n\n## Examples\n\nWe provide robust examples containing copy-pasteable scripts for integrating Anchor into your existing workflows:\n- [Basic Usage (3 Lines of Code)](./examples/basic_usage.ts)\n- [LangChain Integration](./examples/langchain_callback.ts)\n- [NeMo Guardrails Integration](./examples/nemo_integration.py)\n\n---\n\n## Troubleshooting & FAQ\n\n**Q: I get `Missing ANCHOR_API_KEY` when initializing the SDK. What do I do?**\nA: Anchor requires a valid API key to communicate with the scoring engine. Sign up for free at [anchor-app-one.vercel.app](https://anchor-app-one.vercel.app), generate a key in Settings, and inject it securely via your environment variables: `export ANCHOR_API_KEY=your_key`.\n\n**Q: Does Anchor require me to run a local backend or database?**\nA: No! The open-source SDK communicates completely with our hosted cloud engine. There is zero local infrastructure required.\n\n**Q: Why was my action flagged with `Drift detected`?**\nA: Anchor acts strictly based on the `IntentContract` you defined. If the agent's action deviates from the original instruction or violates constraints, it is flagged. You can view detailed scoring telemetry for every action in your [Anchor Dashboard](https://anchor-app-one.vercel.app/app).\n\n---\n\n## Benchmarks & Research\n\nAnchor is based on research into real-time intent enforcement. Our latest benchmark on the **CNN/DailyMail** corpus with `gemma4:31b-cloud` shows a **9.2% net increase** in high-fidelity grounding.\n\nRead the full technical report: [TECHNICAL_REPORT.md](./TECHNICAL_REPORT.md)\n\n## Citation\n\nIf you use Anchor in your research or project, please cite:\n\n```bibtex\n@techreport{rahman2026anchor,\n  title={Anchor: Real-Time Intent Preservation in LLM Agents},\n  author={Rahman, Hasin},\n  year={2026},\n  url={https://github.com/anchor-engine/anchor-sdk}\n}\n```\n\n---\n\n## License\n\nMIT © [anchor-engine](https://github.com/anchor-engine)\n","readmeFilename":"README.md"}