{"_id":"@dgp-standard/dgp-js","name":"@dgp-standard/dgp-js","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dgp-standard/dgp-js","version":"1.0.0","description":"Reference implementation of the DeAlgo Governance Protocol (DGP) v1.0 — vendor-agnostic AI governance","type":"module","main":"./src/index.js","exports":{".":"./src/index.js","./validators":"./src/validators/index.js","./providers":"./src/providers/index.js","./core":"./src/core/index.js"},"scripts":{"test":"node --test test/**/*.test.js","test:watch":"node --test --watch test/**/*.test.js","example:basic":"node examples/basic-usage.js","example:custom":"node examples/custom-capsule.js","example:multi":"node examples/multi-provider.js"},"keywords":["ai","llm","governance","compliance","portability","openai","gemini","anthropic","claude","alignment","safety"],"author":{"name":"DeAlgo Labs"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/dgp-standard/dgp-standard-dgp-js.git"},"bugs":{"url":"https://github.com/dgp-standard/dgp-standard-dgp-js/issues"},"homepage":"https://github.com/dgp-standard/dgp-standard-dgp-js#readme","engines":{"node":">=18.0.0"},"devDependencies":{},"dependencies":{},"_id":"@dgp-standard/dgp-js@1.0.0","gitHead":"7b2b734898c7c182167ff780be09a1cb36938ecf","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-jGQH2aCm8B0pn6jEgBnoLM5aZYT1QkGdqLaVBTSUJzkvdoTfw9nbDcLEgxKPga5u8lqBIDC2HQspAx3grsfVOw==","shasum":"da596b779a91a5b3ce74485cb9e6f671db86c332","tarball":"https://registry.npmjs.org/@dgp-standard/dgp-js/-/dgp-js-1.0.0.tgz","fileCount":11,"unpackedSize":46270,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCyjK380ZAYOnF2EOXDbYYg+JOO4CS7zKkKgWbjHGwqFwIhAPnbvOVs7NdkFl/qDrUmNdIOVGuO9NnQD7BqQn3Zm4RP"}]},"_npmUser":{"name":"dgp-standard","email":"jonathantsmithjr.ssi@gmail.com"},"directories":{},"maintainers":[{"name":"dgp-standard","email":"jonathantsmithjr.ssi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dgp-js_1.0.0_1770878829132_0.9241294132581401"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-12T06:47:09.060Z","1.0.0":"2026-02-12T06:47:09.281Z","modified":"2026-02-12T06:47:09.448Z"},"maintainers":[{"name":"dgp-standard","email":"jonathantsmithjr.ssi@gmail.com"}],"description":"Reference implementation of the DeAlgo Governance Protocol (DGP) v1.0 — vendor-agnostic AI governance","homepage":"https://github.com/dgp-standard/dgp-standard-dgp-js#readme","keywords":["ai","llm","governance","compliance","portability","openai","gemini","anthropic","claude","alignment","safety"],"repository":{"type":"git","url":"git+https://github.com/dgp-standard/dgp-standard-dgp-js.git"},"author":{"name":"DeAlgo Labs"},"bugs":{"url":"https://github.com/dgp-standard/dgp-standard-dgp-js/issues"},"license":"MIT","readme":"# @dgp-standard/dgp-js\r\n\r\n> Reference implementation of the DeAlgo Governance Protocol (DGP) v1.0\r\n\r\n[![npm version](https://img.shields.io/npm/v/@dgp-standard/dgp-js.svg)](https://www.npmjs.com/package/@dgp-standard/dgp-js)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![DGP v1.0](https://img.shields.io/badge/DGP-v1.0%20Conformant-brightgreen.svg)](https://github.com/dgp-standard/dgp-standard-dgp-spec)\r\n\r\n✅ **DGP v1.0 Conformant** — Passes all 8 canonical protocol vectors with bit-for-bit accuracy.\r\n\r\n**Protocol Spec:** [DeAlgo Governance Protocol (DGP) v1.0](https://github.com/dgp-standard/dgp-standard-dgp-spec)\r\n\r\n## Overview\r\n\r\nThe Governance SDK enables **inference-time governance** across multiple LLM vendors (OpenAI, Google, Anthropic) without fine-tuning. Control AI behavior through portable JSON constraint capsules that enforce:\r\n\r\n- **RFE** (Reflection-First Execution): Plan before acting\r\n- **SPS** (Stability-Preserving Steps): Prefer safe operations  \r\n- **SEG** (Scope-Enforcing Gates): Respect task boundaries\r\n- **FOP** (Founder-Oversight Protocol): Escalate high-risk actions\r\n\r\n## Quick Start\r\n\r\n**Reference Implementation** (evaluates LLM output against governance policy):\r\n\r\n```bash\r\nnpm install @dgp-standard/dgp-js\r\n```\r\n\r\n```javascript\r\nimport { GovernanceEngine } from './src/core/GovernanceEngine.js';\r\n\r\n// Create engine with deterministic time injection\r\nconst engine = new GovernanceEngine({ \r\n  now: () => \"2026-02-11T00:00:00.000Z\", \r\n  engineVersion: \"1.0.0\" \r\n});\r\n\r\n// Evaluate LLM output against capsule policy\r\nconst report = engine.evaluate({ \r\n  capsule,   // Governance policy (JSON)\r\n  task,      // Task context (scope, risk level)\r\n  output,    // LLM-generated text to evaluate\r\n  baseline   // Optional: previous output for drift comparison\r\n});\r\n\r\n// Use verdict to gate/retry/escalate/block\r\nconsole.log(report.verdict);        // \"ALLOW\" | \"RETRY\" | \"ESCALATE\" | \"BLOCK\"\r\nconsole.log(report.analysis.score); // 0-100 compliance score\r\nconsole.log(report.violations);     // Detected violations (if any)\r\nconsole.log(report.actions);        // Recommended actions\r\n```\r\n\r\n**See [DGP.md](./DGP.md) for protocol overview and integration patterns.**\r\n\r\n---\r\n\r\n## Protocol Conformance\r\n\r\nThis SDK is the **reference implementation** of the **DeAlgo Governance Protocol (DGP) v1.0**.\r\n\r\n**Validate conformance:**\r\n\r\n```bash\r\nnode --test test/contract-compliance.test.js\r\n```\r\n\r\n**Expected:** 8/8 canonical vectors passing (bit-for-bit match).\r\n\r\n**Protocol artifacts:**\r\n- **Spec (RFC):** [ENGINE_CONTRACT.md](./docs/ENGINE_CONTRACT.md)  \r\n- **Conformance Suite:** [canonical-v1.json](./test/vectors/canonical-v1.json) (8 normative test vectors)  \r\n- **Conformance Guide:** [CONFORMANCE.md](./CONFORMANCE.md)\r\n\r\n**DGP positioning:** *OAuth + OpenAPI + PCI for AI governance*\r\n\r\n---\r\n\r\n## Features\r\n\r\n- ✅ **Multi-vendor support**: OpenAI GPT, Google Gemini, Anthropic Claude\r\n- ✅ **Zero fine-tuning**: Governance via prompt injection, not training\r\n- ✅ **Portable constraints**: Single JSON spec works across all models\r\n- ✅ **Production-ready**: Retry logic, rate limiting, error handling\r\n- ✅ **Extensible**: Custom validators, capsules, and providers\r\n\r\n## Documentation\r\n\r\n- [Quick Start Guide](./docs/quick-start.md)\r\n- [API Reference](./docs/api-reference.md)\r\n- [Custom Capsules](./docs/custom-capsules.md)\r\n- [Framework Integration](./docs/framework-integration.md)\r\n\r\n## Research\r\n\r\nBased on peer-reviewed research validating portability across GPT-4o-mini, Claude Sonnet 4.5, and Gemini 2.0 Flash:\r\n\r\n> **Paper**: [Inference-Time Governance via Portable Constraint Capsules](https://arxiv.org/abs/2602.xxxxx)  \r\n> **Validation**: 2/3 models achieved ≥30% drift reduction, 3/3 achieved perfect scope compliance\r\n\r\n## Examples\r\n\r\nSee [examples/](./examples) for:\r\n- Basic usage with single provider\r\n- Custom capsule creation\r\n- Multi-provider comparison\r\n- Framework integrations (Express, Next.js, LangChain)\r\n\r\n## License\r\n\r\nMIT © DeAlgo Labs\r\n\r\n## Contributing\r\n\r\nWe welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.\r\n\r\n---\r\n\r\n**Questions?** Open an issue or join our [Discord](https://discord.gg/dealgo)\r\n","readmeFilename":"README.md","_rev":"1-60f7f5bcf426c853aba13641734d1a77"}