{"_id":"@ai-abacus/core","name":"@ai-abacus/core","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@ai-abacus/core","version":"0.1.0","description":"Attribute-based access control runtime for agent actions","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"},"./package.json":"./package.json"},"sideEffects":false,"publishConfig":{"access":"public"},"keywords":[],"author":"","license":"MIT","devDependencies":{"@vitest/coverage-v8":"4.1.6","typescript":"^6.0.3","vitest":"^4.1.6"},"dependencies":{"@open-policy-agent/opa-wasm":"^1.10.0","@types/node":"^25.9.0","smol-toml":"^1.6.1","zod":"^4.4.3"},"scripts":{"build":"pnpm run build:policy:wasm && tsc --project tsconfig.build.json && node scripts/copy-policy-wasm.mjs","clean":"rm -rf dist","test":"vitest run --dir src","test:integration":"vitest run src/*.integration.test.ts","test:watch":"vitest --dir src","typecheck":"tsc --noEmit","test:rego":"opa test src/policy","build:policy:wasm":"mkdir -p src/policy/bundle && opa build -t wasm -e abacus/decision src/policy/main.rego src/policy/tool.rego src/policy/network.rego src/policy/filesystem.rego src/policy/secret.rego src/policy/skill.rego src/policy/escalate.rego -o src/policy/bundle/bundle.tar.gz && tar -xzf src/policy/bundle/bundle.tar.gz -C src/policy/bundle && rm src/policy/bundle/bundle.tar.gz && rm -f src/policy/bundle/data.json src/policy/bundle/.manifest && rm -rf src/policy/bundle/src"},"_id":"@ai-abacus/core@0.1.0","_integrity":"sha512-fB5O0hbwPbhceur+lzemmY6gB4aGetRXwxCbQ1oehJVWPo1tsLHcGKDmO/pIrWgCZWMam018yYAGCYpf7Oboeg==","_resolved":"/private/var/folders/n0/hgt520j947q6jwkct8pxdvb80000gp/T/8cc866bfb7aa426bb3e87a8c34dde21f/ai-abacus-core-0.1.0.tgz","_from":"file:ai-abacus-core-0.1.0.tgz","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-fB5O0hbwPbhceur+lzemmY6gB4aGetRXwxCbQ1oehJVWPo1tsLHcGKDmO/pIrWgCZWMam018yYAGCYpf7Oboeg==","shasum":"7fe392433cb20a0b6f6ebeb13e538a2fcfa6325a","tarball":"https://registry.npmjs.org/@ai-abacus/core/-/core-0.1.0.tgz","fileCount":31,"unpackedSize":463377,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCRpIWtXWj11QKylO654ddvBkMUM4e1HVW/cDTAobOkZgIgFmNvX9xp6eLe152wQtNwsLeztNpMyma0r1wyyzTfQSA="}]},"_npmUser":{"name":"scook12","email":"sbrcook@protonmail.com"},"directories":{},"maintainers":[{"name":"scook12","email":"sbrcook@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core_0.1.0_1779234138261_0.31564819840353975"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-19T23:42:18.113Z","0.1.0":"2026-05-19T23:42:18.445Z","modified":"2026-05-19T23:42:18.699Z"},"maintainers":[{"name":"scook12","email":"sbrcook@protonmail.com"}],"description":"Attribute-based access control runtime for agent actions","keywords":[],"license":"MIT","readme":"# @ai-abacus/core\n\nAn attribute-based access control runtime for agents.\n\n## Goal\n\nAbacus should provide:\n- a configurable rules-based engine for agent guardrails\n- auditable allow/ask/deny decisions for evaluated actions\n- a fast and portable runtime\n\n## Why\n\nAgents have permission control requirements similar to users, but with extra guardrails needed to avoid coerced behavior.\n\nWhile using agents, you may want to provide access to:\n- Tools (reproducible, pre-coded workflows/tools)\n- Skills (re-used prompts that structure agent behavior)\n- Filesystem\n- Networks\n- Secrets\n\nIn each case, agents shouldn't be allowed to use them without oversight.\nEven in sandboxes, accessing secrets or executing code should safe and transparent.\n\nAbacus aims to provide the configurable control plane for agents at these critical access junctures.\n\n## Install\n\n```bash\npnpm add @ai-abacus/core\n```\n\n## Library Usage\n\n### Evaluate with provided policy TOML\n\n```ts\nimport { evaluate } from '@ai-abacus/core'\n\nconst decision = await evaluate(\n  {\n    requestId: 'req-1',\n    timestamp: new Date().toISOString(),\n    actor: { id: 'actor-1', permissions: {} },\n    action: 'tool::use',\n    context: { type: 'tool', id: 'ctx-1', tool: 'bash', argv0: 'git' },\n  },\n  {\n    configToml: `\n[policy]\nversion = \"2026-05\"\npermission_mode = \"strict\"\n\n[default.tool.use]\n\"*\" = \"allow\"\n`,\n  },\n)\n```\n\n### Create a reusable engine\n\n```ts\nimport { createEngine, parsePolicyToml } from '@ai-abacus/core'\n\nconst policy = parsePolicyToml(`\n[policy]\nversion = \"2026-05\"\n\n[default.tool.use]\n\"*\" = \"ask\"\n`)\n\nconst engine = await createEngine({ policy })\nconst decision = await engine.evaluate({\n  requestId: 'req-2',\n  timestamp: new Date().toISOString(),\n  actor: { id: 'actor-1', permissions: {} },\n  action: 'tool::use',\n  context: { type: 'tool', id: 'ctx-2', tool: 'webfetch' },\n})\n```\n\n### Load policy via runtime config resolution\n\nResolution order:\n\n1. explicit `configPath` option\n2. `ABACUS_CONFIG_PATH`\n3. local `./abacus.toml` (current working directory)\n4. `~/.config/abacus/abacus.toml`\n\nUse `loadPolicy` directly if you want only parse/normalize behavior.\n\n## Public API\n\n- `evaluate(input, options?)`\n- `createEngine(options?)`\n- `loadPolicy(options?)`\n- `parsePolicyToml(configToml)`\n- `parseRawPolicyConfig(raw)`\n- `normalizePolicy(raw)`\n\n## Runtime Contract\n\n### Input Schema (to Rego)\n\nAbacus evaluates the `data.abacus.decision` entrypoint with an input envelope:\n\n```json\n{\n  \"config\": {\n    \"meta\": {\n      \"schemaVersion\": 1,\n      \"policyVersion\": \"2026-05\",\n      \"permissionMode\": \"strict\",\n      \"patternDialect\": \"glob\",\n      \"patternCase\": \"insensitive\",\n      \"toolMatchMode\": \"tokenized_argv\",\n      \"permissionModeEffect\": \"deny\"\n    },\n    \"rules\": [\n      {\n        \"id\": \"r_123\",\n        \"agent\": \"*\",\n        \"scope\": \"tool\",\n        \"verb\": \"use\",\n        \"effect\": \"deny\",\n        \"reason\": \"block_webfetch\",\n        \"source\": \"override_exact\",\n        \"priority\": 700,\n        \"specificity\": 2,\n        \"match\": {\n          \"tool\": \"webfetch\"\n        }\n      }\n    ]\n  },\n  \"request\": {\n    \"agent\": \"build\",\n    \"scope\": \"tool\",\n    \"verb\": \"use\",\n    \"match\": {\n      \"tool\": \"bash\",\n      \"argv0\": \"git\",\n      \"argv\": [\"status\"]\n    }\n  }\n}\n```\n\nNotes:\n- `schemaVersion` is the config-shape version.\n- `policyVersion` is a user-controlled policy value for auditing/versioning.\n\n### Output Schema (from Rego)\n\nAbacus expects a structured decision payload:\n\n```json\n{\n  \"effect\": \"deny\",\n  \"source\": \"override_exact\",\n  \"reason\": \"block_webfetch\",\n  \"rule_id\": \"r_123\",\n  \"policy_version\": \"2026-05\"\n}\n```\n\nThis is mapped into engine output:\n- `policyVersion`\n- `effect` (`deny` | `ask` | `allow`)\n- `reasons`\n- `source`\n- `ruleId`\n\n## Precedence\n\nRule winner selection is deterministic and follows:\n\n1. `priority` (higher wins)\n2. `specificity` (higher wins)\n3. agent rank (`agent != \"*\"` beats `\"*\"`)\n4. effect restrictiveness (`deny > ask > allow`)\n5. lexical `id` tie-break\n\nCurrent source layer priorities are normalized in TS and consumed in Rego:\n\n- `override_exact` (700)\n- `override_wildcard` (650)\n- `agent_rule_exact` (600)\n- `agent_rule_wildcard` (550)\n- `agent_default` (500)\n- `global_default` (400)\n- `permission_mode` fallback\n\n## Packaging Notes\n\n- Runtime decisions execute against OPA Wasm (`@open-policy-agent/opa-wasm`).\n- Published package includes `dist/policy/bundle/policy.wasm`; consumers do not need `opa` installed.\n- `opa` and `tar` are required for maintainers when rebuilding policy Wasm before publishing.\n","readmeFilename":"README.md","_rev":"1-b818a339cd1d7a48c08f6f7809acaac1"}