{"_id":"@authensor/sdk","_rev":"2-316a0a44197565b181dbaa750779e42e","name":"@authensor/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"@authensor/sdk","version":"0.0.1","keywords":["authensor","sdk","agent","guardrails"],"license":"MIT","_id":"@authensor/sdk@0.0.1","maintainers":[{"name":"jkearn","email":"john@authensor.com"}],"homepage":"https://github.com/authensor/authensor","bugs":{"url":"https://github.com/authensor/authensor/issues"},"dist":{"shasum":"972917d31cc7eca12fa45c81b6887a6a955fc6a2","tarball":"https://registry.npmjs.org/@authensor/sdk/-/sdk-0.0.1.tgz","fileCount":33,"integrity":"sha512-fkQCX/+kE+OKMC5Np++clQeum7BZNAXrBI9aSoS48MrQUH6N/9XPyNQEBO56oDVexjz2s68Pg8oT7xqc3QSUhw==","signatures":[{"sig":"MEUCIQDtvS18huW6lTgnZZVbY/bv4g4GegiBC8zy5sxMqG9iswIgKx5KWM3vvw0C9W9p5ZvpciFKPRazzBGvNWi77Aaf34Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":64524},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"814d74dd7e0ad287ca74bfdd1730ec5aa768165b","scripts":{"dev":"tsc --watch","gen":"cd ../schemas/src && json2ts -i action-envelope.schema.json -o ../../sdk-ts/src/generated/action-envelope.ts && json2ts -i action-receipt.schema.json -o ../../sdk-ts/src/generated/action-receipt.ts && json2ts -i policy.schema.json -o ../../sdk-ts/src/generated/policy.ts","test":"vitest run --passWithNoTests","build":"tsc","clean":"rm -rf dist","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"jkearn","email":"john@authensor.com"},"repository":{"url":"git+https://github.com/authensor/authensor.git","type":"git","directory":"packages/sdk-ts"},"_npmVersion":"10.8.2","description":"Authensor TypeScript SDK for agent builders","directories":{},"_nodeVersion":"20.20.0","dependencies":{"@authensor/engine":"workspace:*","@authensor/schemas":"workspace:*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.1.0","typescript":"^5.3.0","@types/node":"^20.10.0","json-schema-to-typescript":"^13.1.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.0.1_1773535365324_0.8073758515427347","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@authensor/sdk","version":"0.1.0","description":"Authensor TypeScript SDK for agent builders","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"dependencies":{"@authensor/engine":"0.1.0","@authensor/schemas":"0.1.0"},"devDependencies":{"@types/node":"^20.10.0","json-schema-to-typescript":"^13.1.0","typescript":"^5.3.0","vitest":"^1.1.0"},"keywords":["authensor","sdk","ai-safety","agent-safety","guardrails","policy-engine","ai-agent","agentic-ai","security","open-source","authorization","agent-sdk","typescript"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/authensor/authensor.git","directory":"packages/sdk-ts"},"homepage":"https://github.com/authensor/authensor","publishConfig":{"access":"public"},"scripts":{"build":"tsc","dev":"tsc --watch","test":"vitest run --passWithNoTests","test:watch":"vitest","typecheck":"tsc --noEmit","clean":"rm -rf dist","gen":"cd ../schemas/src && json2ts -i action-envelope.schema.json -o ../../sdk-ts/src/generated/action-envelope.ts && json2ts -i action-receipt.schema.json -o ../../sdk-ts/src/generated/action-receipt.ts && json2ts -i policy.schema.json -o ../../sdk-ts/src/generated/policy.ts"},"_id":"@authensor/sdk@0.1.0","bugs":{"url":"https://github.com/authensor/authensor/issues"},"_integrity":"sha512-Jrylem8DHFP8U+c+bxkzVdeKL6KbRq1Fj/xpdZupYlZEzs08lFCeyjq85eRxCAuJ+z9tBHze8nY39JioZBNe7w==","_resolved":"/private/var/folders/_h/xdjfwx_n3qxc_plpqltl399m0000gn/T/776e634a66bd6cacf9330d9928d2039e/authensor-sdk-0.1.0.tgz","_from":"file:authensor-sdk-0.1.0.tgz","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Jrylem8DHFP8U+c+bxkzVdeKL6KbRq1Fj/xpdZupYlZEzs08lFCeyjq85eRxCAuJ+z9tBHze8nY39JioZBNe7w==","shasum":"04cf655bcf75740301df49b282bb3884523d2da8","tarball":"https://registry.npmjs.org/@authensor/sdk/-/sdk-0.1.0.tgz","fileCount":39,"unpackedSize":74906,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCvfwLuQNrduKKjBZfAoyfmRAPO1wqaLT31DALL0C732AIhAPk7WymdN7GvDC8CkTAPLczoO8imxOVi/3VM/uhlpbFR"}]},"_npmUser":{"name":"jkearn","email":"john@authensor.com"},"directories":{},"maintainers":[{"name":"jkearn","email":"john@authensor.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1781250057824_0.05774052965123566"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-15T00:42:45.189Z","modified":"2026-06-12T07:40:58.098Z","0.0.1":"2026-03-15T00:42:45.506Z","0.1.0":"2026-06-12T07:40:57.967Z"},"bugs":{"url":"https://github.com/authensor/authensor/issues"},"license":"MIT","homepage":"https://github.com/authensor/authensor","keywords":["authensor","sdk","ai-safety","agent-safety","guardrails","policy-engine","ai-agent","agentic-ai","security","open-source","authorization","agent-sdk","typescript"],"repository":{"type":"git","url":"git+https://github.com/authensor/authensor.git","directory":"packages/sdk-ts"},"description":"Authensor TypeScript SDK for agent builders","maintainers":[{"name":"jkearn","email":"john@authensor.com"}],"readme":"# @authensor/sdk\n\nTypeScript SDK for integrating Authensor into your agents. Wraps the control plane API with a clean interface for policy enforcement, action execution, and audit trails.\n\n## Install\n\n```bash\nnpm install @authensor/sdk\n```\n\n## Quickstart\n\n```typescript\nimport { Authensor } from '@authensor/sdk';\n\nconst authensor = new Authensor({\n  controlPlaneUrl: 'http://localhost:3000',\n  principalId: 'my-agent',\n});\n\n// Execute an action with policy enforcement\nconst result = await authensor.execute(\n  'stripe.charges.create',\n  'stripe://customers/cus_123/charges',\n  async () => {\n    return await stripe.charges.create({ amount: 1000, currency: 'usd' });\n  },\n);\n\nif (result.allowed) {\n  console.log(result.value); // stripe charge object\n} else {\n  console.log(result.reason); // \"Denied: amount exceeds policy limit\"\n}\n```\n\n## Local mode (no control plane)\n\nUse the SDK with just the engine for local evaluation:\n\n```typescript\nimport { Authensor } from '@authensor/sdk';\n\nconst authensor = new Authensor({\n  mode: 'local',\n  policies: [myPolicy],\n  principalId: 'my-agent',\n});\n\nconst result = await authensor.execute('file.write', '/etc/passwd', async () => {\n  // This never runs -- denied by policy\n});\n```\n\n## The `execute` pattern\n\n```typescript\nconst result = await authensor.execute(\n  action,      // 'namespace.verb' -- what the agent wants to do\n  resource,    // URI of the target resource\n  fn,          // The actual work (only runs if allowed)\n  options?,    // { constraints, metadata, content }\n);\n```\n\nThe SDK:\n1. Builds an action envelope\n2. Sends it to the control plane (or evaluates locally)\n3. If allowed, executes `fn` and records the receipt\n4. If denied, returns the reason without executing\n\n## Error handling\n\n```typescript\nimport { Authensor, AuthensorDeniedError } from '@authensor/sdk';\n\ntry {\n  await authensor.execute('shell.rm', '/production/db', dangerousFn);\n} catch (e) {\n  if (e instanceof AuthensorDeniedError) {\n    console.log(e.reason);   // Policy denial reason\n    console.log(e.policyId); // Which policy denied it\n  }\n}\n```\n\n## Configuration\n\n```typescript\nconst authensor = new Authensor({\n  controlPlaneUrl: 'http://localhost:3000',  // Control plane endpoint\n  principalId: 'agent-1',                    // Agent identity\n  apiKey: 'ak_...',                          // API key (if auth enabled)\n  timeout: 5000,                             // Request timeout (ms)\n  failClosed: true,                          // Deny on error (default: true)\n});\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}